@jetstart/shared 1.1.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.
- package/README.md +108 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/protocols/events.d.ts +114 -0
- package/dist/protocols/events.d.ts.map +1 -0
- package/dist/protocols/events.js +7 -0
- package/dist/protocols/events.js.map +1 -0
- package/dist/protocols/index.d.ts +3 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js +20 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/websocket.d.ts +110 -0
- package/dist/protocols/websocket.d.ts.map +1 -0
- package/dist/protocols/websocket.js +28 -0
- package/dist/protocols/websocket.js.map +1 -0
- package/dist/types/build.d.ts +76 -0
- package/dist/types/build.d.ts.map +1 -0
- package/dist/types/build.js +30 -0
- package/dist/types/build.js.map +1 -0
- package/dist/types/device.d.ts +45 -0
- package/dist/types/device.d.ts.map +1 -0
- package/dist/types/device.js +27 -0
- package/dist/types/device.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +22 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/log.d.ts +47 -0
- package/dist/types/log.d.ts.map +1 -0
- package/dist/types/log.js +26 -0
- package/dist/types/log.js.map +1 -0
- package/dist/types/session.d.ts +51 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +22 -0
- package/dist/types/session.js.map +1 -0
- package/dist/utils/constants.d.ts +105 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +123 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/validation.d.ts +50 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +111 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +63 -0
- package/src/index.ts +8 -0
- package/src/protocols/events.ts +50 -0
- package/src/protocols/index.ts +3 -0
- package/src/protocols/websocket.ts +149 -0
- package/src/types/build.ts +85 -0
- package/src/types/device.ts +50 -0
- package/src/types/index.ts +5 -0
- package/src/types/log.ts +51 -0
- package/src/types/session.ts +57 -0
- package/src/utils/constants.ts +135 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/validation.ts +115 -0
- package/tests/protocols.test.ts +121 -0
- package/tests/setup.ts +16 -0
- package/tests/types.test.ts +103 -0
- package/tests/validation.test.ts +226 -0
- package/tsconfig.json +22 -0
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jetstart/shared",
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Shared types, protocols, and utilities for JetStart",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"dev": "tsc --watch",
|
|
10
|
+
"clean": "rm -rf dist",
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"test:watch": "jest --watch",
|
|
13
|
+
"test:coverage": "jest --coverage",
|
|
14
|
+
"typecheck": "tsc --noEmit"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"jetstart",
|
|
18
|
+
"shared",
|
|
19
|
+
"types",
|
|
20
|
+
"protocols"
|
|
21
|
+
],
|
|
22
|
+
"author": "Phantom",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/dev-phantom/jetstart.git",
|
|
27
|
+
"directory": "packages/shared"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/dev-phantom/jetstart/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/dev-phantom/jetstart#readme",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/jest": "29.5.14",
|
|
35
|
+
"@types/node": "^20.10.0",
|
|
36
|
+
"jest": "^29.5.0",
|
|
37
|
+
"ts-jest": "^29.1.0",
|
|
38
|
+
"typescript": "5.9.3"
|
|
39
|
+
},
|
|
40
|
+
"jest": {
|
|
41
|
+
"preset": "ts-jest",
|
|
42
|
+
"testEnvironment": "node",
|
|
43
|
+
"roots": [
|
|
44
|
+
"<rootDir>/tests"
|
|
45
|
+
],
|
|
46
|
+
"testMatch": [
|
|
47
|
+
"**/*.test.ts"
|
|
48
|
+
],
|
|
49
|
+
"collectCoverageFrom": [
|
|
50
|
+
"src/**/*.ts",
|
|
51
|
+
"!src/**/*.d.ts",
|
|
52
|
+
"!src/**/index.ts"
|
|
53
|
+
],
|
|
54
|
+
"coverageThreshold": {
|
|
55
|
+
"global": {
|
|
56
|
+
"branches": 70,
|
|
57
|
+
"functions": 70,
|
|
58
|
+
"lines": 70,
|
|
59
|
+
"statements": 70
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event System
|
|
3
|
+
* Event types for internal communication within packages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface JetStartEvent<T = any> {
|
|
7
|
+
type: string;
|
|
8
|
+
payload: T;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* CLI Events
|
|
14
|
+
*/
|
|
15
|
+
export type CLIEvent =
|
|
16
|
+
| { type: 'cli:command:start'; payload: { command: string; args: string[] } }
|
|
17
|
+
| { type: 'cli:command:complete'; payload: { command: string; success: boolean } }
|
|
18
|
+
| { type: 'cli:command:error'; payload: { command: string; error: string } };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Core Events
|
|
22
|
+
*/
|
|
23
|
+
export type CoreEvent =
|
|
24
|
+
| { type: 'core:server:start'; payload: { port: number } }
|
|
25
|
+
| { type: 'core:server:stop'; payload: {} }
|
|
26
|
+
| { type: 'core:session:created'; payload: { sessionId: string } }
|
|
27
|
+
| { type: 'core:session:ended'; payload: { sessionId: string } }
|
|
28
|
+
| { type: 'core:build:queued'; payload: { sessionId: string } }
|
|
29
|
+
| { type: 'core:build:started'; payload: { sessionId: string } }
|
|
30
|
+
| { type: 'core:build:completed'; payload: { sessionId: string; duration: number } }
|
|
31
|
+
| { type: 'core:build:failed'; payload: { sessionId: string; error: string } };
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Client Events
|
|
35
|
+
*/
|
|
36
|
+
export type ClientEvent =
|
|
37
|
+
| { type: 'client:connected'; payload: { sessionId: string } }
|
|
38
|
+
| { type: 'client:disconnected'; payload: { sessionId: string } }
|
|
39
|
+
| { type: 'client:apk:downloaded'; payload: { apkPath: string; size: number } }
|
|
40
|
+
| { type: 'client:apk:installed'; payload: { packageName: string } }
|
|
41
|
+
| { type: 'client:app:launched'; payload: { packageName: string } };
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Event emitter interface
|
|
45
|
+
*/
|
|
46
|
+
export interface EventEmitter {
|
|
47
|
+
on(event: string, handler: (data: any) => void): void;
|
|
48
|
+
off(event: string, handler: (data: any) => void): void;
|
|
49
|
+
emit(event: string, data: any): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Protocol
|
|
3
|
+
* Message types for real-time communication between Core, Client, and Logs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
DeviceInfo,
|
|
8
|
+
SessionStatus,
|
|
9
|
+
BuildStatus,
|
|
10
|
+
LogEntry,
|
|
11
|
+
APKInfo,
|
|
12
|
+
} from '../types/index';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Base message structure
|
|
16
|
+
*/
|
|
17
|
+
export interface BaseMessage {
|
|
18
|
+
type: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
sessionId?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Messages from Client to Core
|
|
25
|
+
*/
|
|
26
|
+
export type ClientMessage =
|
|
27
|
+
| ClientConnectMessage
|
|
28
|
+
| ClientStatusMessage
|
|
29
|
+
| ClientLogMessage
|
|
30
|
+
| ClientHeartbeatMessage
|
|
31
|
+
| ClientDisconnectMessage;
|
|
32
|
+
|
|
33
|
+
export interface ClientConnectMessage extends BaseMessage {
|
|
34
|
+
type: 'client:connect';
|
|
35
|
+
sessionId: string;
|
|
36
|
+
token: string;
|
|
37
|
+
deviceInfo: DeviceInfo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ClientStatusMessage extends BaseMessage {
|
|
41
|
+
type: 'client:status';
|
|
42
|
+
status: SessionStatus;
|
|
43
|
+
message?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ClientLogMessage extends BaseMessage {
|
|
47
|
+
type: 'client:log';
|
|
48
|
+
log: LogEntry;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ClientHeartbeatMessage extends BaseMessage {
|
|
52
|
+
type: 'client:heartbeat';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ClientDisconnectMessage extends BaseMessage {
|
|
56
|
+
type: 'client:disconnect';
|
|
57
|
+
reason?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Messages from Core to Client
|
|
62
|
+
*/
|
|
63
|
+
export type CoreMessage =
|
|
64
|
+
| CoreConnectedMessage
|
|
65
|
+
| CoreBuildStartMessage
|
|
66
|
+
| CoreBuildStatusMessage
|
|
67
|
+
| CoreBuildCompleteMessage
|
|
68
|
+
| CoreBuildErrorMessage
|
|
69
|
+
| CoreReloadMessage
|
|
70
|
+
| CoreUIUpdateMessage
|
|
71
|
+
| CoreDisconnectMessage;
|
|
72
|
+
|
|
73
|
+
export interface CoreConnectedMessage extends BaseMessage {
|
|
74
|
+
type: 'core:connected';
|
|
75
|
+
sessionId: string;
|
|
76
|
+
projectName: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface CoreBuildStartMessage extends BaseMessage {
|
|
80
|
+
type: 'core:build-start';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface CoreBuildStatusMessage extends BaseMessage {
|
|
84
|
+
type: 'core:build-status';
|
|
85
|
+
status: BuildStatus;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface CoreBuildCompleteMessage extends BaseMessage {
|
|
89
|
+
type: 'core:build-complete';
|
|
90
|
+
apkInfo: APKInfo;
|
|
91
|
+
downloadUrl: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface CoreBuildErrorMessage extends BaseMessage {
|
|
95
|
+
type: 'core:build-error';
|
|
96
|
+
error: string;
|
|
97
|
+
details?: any;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface CoreReloadMessage extends BaseMessage {
|
|
101
|
+
type: 'core:reload';
|
|
102
|
+
reloadType: 'full' | 'hot';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface CoreUIUpdateMessage extends BaseMessage {
|
|
106
|
+
type: 'core:ui-update';
|
|
107
|
+
dslContent: string;
|
|
108
|
+
screens?: string[];
|
|
109
|
+
hash?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface CoreDisconnectMessage extends BaseMessage {
|
|
113
|
+
type: 'core:disconnect';
|
|
114
|
+
reason: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Union type of all messages
|
|
119
|
+
*/
|
|
120
|
+
export type WSMessage = ClientMessage | CoreMessage;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* WebSocket connection state
|
|
124
|
+
*/
|
|
125
|
+
export enum WSState {
|
|
126
|
+
CONNECTING = 'connecting',
|
|
127
|
+
CONNECTED = 'connected',
|
|
128
|
+
DISCONNECTING = 'disconnecting',
|
|
129
|
+
DISCONNECTED = 'disconnected',
|
|
130
|
+
ERROR = 'error',
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* WebSocket error types
|
|
135
|
+
*/
|
|
136
|
+
export interface WSError {
|
|
137
|
+
code: WSErrorCode;
|
|
138
|
+
message: string;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export enum WSErrorCode {
|
|
143
|
+
CONNECTION_FAILED = 'connection_failed',
|
|
144
|
+
AUTHENTICATION_FAILED = 'authentication_failed',
|
|
145
|
+
TIMEOUT = 'timeout',
|
|
146
|
+
INVALID_MESSAGE = 'invalid_message',
|
|
147
|
+
SESSION_EXPIRED = 'session_expired',
|
|
148
|
+
UNKNOWN = 'unknown',
|
|
149
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build System Types
|
|
3
|
+
* Types related to compilation, building, and APK generation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface BuildConfig {
|
|
7
|
+
projectPath: string;
|
|
8
|
+
outputPath: string;
|
|
9
|
+
buildType: BuildType;
|
|
10
|
+
minifyEnabled: boolean;
|
|
11
|
+
debuggable: boolean;
|
|
12
|
+
versionCode: number;
|
|
13
|
+
versionName: string;
|
|
14
|
+
applicationId: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum BuildType {
|
|
18
|
+
DEBUG = 'debug',
|
|
19
|
+
RELEASE = 'release',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface BuildResult {
|
|
23
|
+
success: boolean;
|
|
24
|
+
apkPath?: string;
|
|
25
|
+
apkSize?: number;
|
|
26
|
+
buildTime: number;
|
|
27
|
+
errors?: BuildError[];
|
|
28
|
+
warnings?: BuildWarning[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BuildError {
|
|
32
|
+
file: string;
|
|
33
|
+
line: number;
|
|
34
|
+
column: number;
|
|
35
|
+
message: string;
|
|
36
|
+
severity: ErrorSeverity;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface BuildWarning {
|
|
40
|
+
message: string;
|
|
41
|
+
file?: string;
|
|
42
|
+
line?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum ErrorSeverity {
|
|
46
|
+
ERROR = 'error',
|
|
47
|
+
WARNING = 'warning',
|
|
48
|
+
INFO = 'info',
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface BuildStatus {
|
|
52
|
+
phase: BuildPhase;
|
|
53
|
+
progress: number; // 0-100
|
|
54
|
+
message: string;
|
|
55
|
+
timestamp: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export enum BuildPhase {
|
|
59
|
+
IDLE = 'idle',
|
|
60
|
+
INITIALIZING = 'initializing',
|
|
61
|
+
COMPILING = 'compiling',
|
|
62
|
+
PACKAGING = 'packaging',
|
|
63
|
+
SIGNING = 'signing',
|
|
64
|
+
OPTIMIZING = 'optimizing',
|
|
65
|
+
COMPLETE = 'complete',
|
|
66
|
+
FAILED = 'failed',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface APKInfo {
|
|
70
|
+
path: string;
|
|
71
|
+
size: number;
|
|
72
|
+
hash: string;
|
|
73
|
+
versionCode: number;
|
|
74
|
+
versionName: string;
|
|
75
|
+
minSdkVersion: number;
|
|
76
|
+
targetSdkVersion: number;
|
|
77
|
+
applicationId: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface CacheInfo {
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
size: number;
|
|
83
|
+
lastCleared: number;
|
|
84
|
+
hitRate: number;
|
|
85
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Information Types
|
|
3
|
+
* Device and platform-related information
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface DeviceInfo {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
model: string;
|
|
10
|
+
manufacturer: string;
|
|
11
|
+
platform: Platform;
|
|
12
|
+
osVersion: string;
|
|
13
|
+
apiLevel: number;
|
|
14
|
+
screenResolution: ScreenResolution;
|
|
15
|
+
density: number;
|
|
16
|
+
isEmulator: boolean;
|
|
17
|
+
architecture: Architecture;
|
|
18
|
+
locale: string;
|
|
19
|
+
timezone: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export enum Platform {
|
|
23
|
+
ANDROID = 'android',
|
|
24
|
+
WEB = 'web',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ScreenResolution {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export enum Architecture {
|
|
33
|
+
ARM64_V8A = 'arm64-v8a',
|
|
34
|
+
ARMEABI_V7A = 'armeabi-v7a',
|
|
35
|
+
X86 = 'x86',
|
|
36
|
+
X86_64 = 'x86_64',
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface NetworkInfo {
|
|
40
|
+
ipAddress: string;
|
|
41
|
+
networkType: NetworkType;
|
|
42
|
+
isConnected: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export enum NetworkType {
|
|
46
|
+
WIFI = 'wifi',
|
|
47
|
+
CELLULAR = 'cellular',
|
|
48
|
+
ETHERNET = 'ethernet',
|
|
49
|
+
UNKNOWN = 'unknown',
|
|
50
|
+
}
|
package/src/types/log.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging Types
|
|
3
|
+
* Types for the logging system
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface LogEntry {
|
|
7
|
+
id: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
tag: string;
|
|
11
|
+
message: string;
|
|
12
|
+
source: LogSource;
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
metadata?: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum LogLevel {
|
|
18
|
+
VERBOSE = 'verbose',
|
|
19
|
+
DEBUG = 'debug',
|
|
20
|
+
INFO = 'info',
|
|
21
|
+
WARN = 'warn',
|
|
22
|
+
ERROR = 'error',
|
|
23
|
+
FATAL = 'fatal',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export enum LogSource {
|
|
27
|
+
CLI = 'cli',
|
|
28
|
+
CORE = 'core',
|
|
29
|
+
CLIENT = 'client',
|
|
30
|
+
BUILD = 'build',
|
|
31
|
+
NETWORK = 'network',
|
|
32
|
+
SYSTEM = 'system',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LogFilter {
|
|
36
|
+
levels?: LogLevel[];
|
|
37
|
+
sources?: LogSource[];
|
|
38
|
+
tags?: string[];
|
|
39
|
+
searchQuery?: string;
|
|
40
|
+
startTime?: number;
|
|
41
|
+
endTime?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface LogStats {
|
|
45
|
+
totalLogs: number;
|
|
46
|
+
errorCount: number;
|
|
47
|
+
warningCount: number;
|
|
48
|
+
lastLogTime: number;
|
|
49
|
+
logsByLevel: Record<LogLevel, number>;
|
|
50
|
+
logsBySource: Record<LogSource, number>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Management Types
|
|
3
|
+
* Used for tracking and managing development sessions between Core and Client
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DeviceInfo } from "./device";
|
|
7
|
+
|
|
8
|
+
export interface Session {
|
|
9
|
+
id: string;
|
|
10
|
+
projectName: string;
|
|
11
|
+
projectPath: string;
|
|
12
|
+
deviceId: string;
|
|
13
|
+
deviceInfo: DeviceInfo;
|
|
14
|
+
createdAt: number;
|
|
15
|
+
lastActivity: number;
|
|
16
|
+
status: SessionStatus;
|
|
17
|
+
connectionType: ConnectionType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export enum SessionStatus {
|
|
21
|
+
PENDING = 'pending',
|
|
22
|
+
CONNECTED = 'connected',
|
|
23
|
+
BUILDING = 'building',
|
|
24
|
+
READY = 'ready',
|
|
25
|
+
ERROR = 'error',
|
|
26
|
+
DISCONNECTED = 'disconnected',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export enum ConnectionType {
|
|
30
|
+
MINIMAL = 'minimal', // Manual APK installation
|
|
31
|
+
FASTER = 'faster', // ADB over TCP
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface SessionConfig {
|
|
35
|
+
enableHotReload: boolean;
|
|
36
|
+
enableLogs: boolean;
|
|
37
|
+
autoReconnect: boolean;
|
|
38
|
+
buildOnSave: boolean;
|
|
39
|
+
port: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface SessionToken {
|
|
43
|
+
sessionId: string;
|
|
44
|
+
token: string;
|
|
45
|
+
expiresAt: number;
|
|
46
|
+
serverUrl: string;
|
|
47
|
+
wsUrl: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface QRCodeData {
|
|
51
|
+
sessionId: string;
|
|
52
|
+
serverUrl: string;
|
|
53
|
+
wsUrl: string;
|
|
54
|
+
token: string;
|
|
55
|
+
projectName: string;
|
|
56
|
+
version: string;
|
|
57
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Constants and Configuration
|
|
3
|
+
* Shared constants used across all packages
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default ports
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_CORE_PORT = 8765;
|
|
10
|
+
export const DEFAULT_WS_PORT = 8766;
|
|
11
|
+
export const DEFAULT_LOGS_PORT = 8767;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Network configuration
|
|
15
|
+
*/
|
|
16
|
+
export const WS_HEARTBEAT_INTERVAL = 30000; // 30 seconds
|
|
17
|
+
export const WS_RECONNECT_DELAY = 5000; // 5 seconds
|
|
18
|
+
export const WS_MAX_RECONNECT_ATTEMPTS = 5;
|
|
19
|
+
export const REQUEST_TIMEOUT = 30000; // 30 seconds
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Session configuration
|
|
23
|
+
*/
|
|
24
|
+
export const SESSION_TOKEN_EXPIRY = 3600000; // 1 hour
|
|
25
|
+
export const SESSION_CLEANUP_INTERVAL = 60000; // 1 minute
|
|
26
|
+
export const SESSION_IDLE_TIMEOUT = 1800000; // 30 minutes
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Build configuration
|
|
30
|
+
*/
|
|
31
|
+
export const BUILD_CACHE_SIZE_LIMIT = 1073741824; // 1 GB
|
|
32
|
+
export const BUILD_TIMEOUT = 300000; // 5 minutes
|
|
33
|
+
export const MAX_CONCURRENT_BUILDS = 3;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* File size limits
|
|
37
|
+
*/
|
|
38
|
+
export const MAX_APK_SIZE = 104857600; // 100 MB
|
|
39
|
+
export const MAX_LOG_FILE_SIZE = 10485760; // 10 MB
|
|
40
|
+
export const MAX_LOG_ENTRIES = 10000;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Version information
|
|
44
|
+
*/
|
|
45
|
+
export const JETSTART_VERSION = '0.1.0';
|
|
46
|
+
export const MIN_ANDROID_API_LEVEL = 24; // Android 7.0
|
|
47
|
+
export const TARGET_ANDROID_API_LEVEL = 34; // Android 14
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* URLs and paths
|
|
51
|
+
*/
|
|
52
|
+
export const JETSTART_CONFIG_FILE = 'jetstart.config.json';
|
|
53
|
+
export const JETSTART_CACHE_DIR = '.jetstart/cache';
|
|
54
|
+
export const JETSTART_SESSIONS_DIR = '.jetstart/sessions';
|
|
55
|
+
export const JETSTART_LOGS_DIR = '.jetstart/logs';
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Error codes
|
|
59
|
+
*/
|
|
60
|
+
export const ERROR_CODES = {
|
|
61
|
+
// CLI errors (1xxx)
|
|
62
|
+
INVALID_COMMAND: 1001,
|
|
63
|
+
INVALID_PROJECT_NAME: 1002,
|
|
64
|
+
PROJECT_ALREADY_EXISTS: 1003,
|
|
65
|
+
PROJECT_NOT_FOUND: 1004,
|
|
66
|
+
|
|
67
|
+
// Core errors (2xxx)
|
|
68
|
+
SERVER_START_FAILED: 2001,
|
|
69
|
+
BUILD_FAILED: 2002,
|
|
70
|
+
SESSION_CREATION_FAILED: 2003,
|
|
71
|
+
INVALID_SESSION: 2004,
|
|
72
|
+
|
|
73
|
+
// Client errors (3xxx)
|
|
74
|
+
CONNECTION_FAILED: 3001,
|
|
75
|
+
DOWNLOAD_FAILED: 3002,
|
|
76
|
+
INSTALLATION_FAILED: 3003,
|
|
77
|
+
LAUNCH_FAILED: 3004,
|
|
78
|
+
|
|
79
|
+
// Network errors (4xxx)
|
|
80
|
+
WEBSOCKET_ERROR: 4001,
|
|
81
|
+
NETWORK_TIMEOUT: 4002,
|
|
82
|
+
AUTHENTICATION_FAILED: 4003,
|
|
83
|
+
|
|
84
|
+
// Build errors (5xxx)
|
|
85
|
+
COMPILATION_ERROR: 5001,
|
|
86
|
+
PACKAGING_ERROR: 5002,
|
|
87
|
+
SIGNING_ERROR: 5003,
|
|
88
|
+
} as const;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Success messages
|
|
92
|
+
*/
|
|
93
|
+
export const SUCCESS_MESSAGES = {
|
|
94
|
+
PROJECT_CREATED: 'Project created successfully',
|
|
95
|
+
BUILD_COMPLETE: 'Build completed successfully',
|
|
96
|
+
CONNECTION_ESTABLISHED: 'Connection established',
|
|
97
|
+
APK_INSTALLED: 'APK installed successfully',
|
|
98
|
+
} as const;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Log tags
|
|
102
|
+
*/
|
|
103
|
+
export const LOG_TAGS = {
|
|
104
|
+
CLI: 'jetstart:cli',
|
|
105
|
+
CORE: 'jetstart:core',
|
|
106
|
+
CLIENT: 'jetstart:client',
|
|
107
|
+
BUILD: 'jetstart:build',
|
|
108
|
+
NETWORK: 'jetstart:network',
|
|
109
|
+
WEBSOCKET: 'jetstart:ws',
|
|
110
|
+
LOGS: 'jetstart:logs',
|
|
111
|
+
} as const;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* File patterns
|
|
115
|
+
*/
|
|
116
|
+
export const IGNORE_PATTERNS = [
|
|
117
|
+
'node_modules',
|
|
118
|
+
'.git',
|
|
119
|
+
'.gradle',
|
|
120
|
+
'build',
|
|
121
|
+
'dist',
|
|
122
|
+
'.idea',
|
|
123
|
+
'*.iml',
|
|
124
|
+
'.DS_Store',
|
|
125
|
+
'local.properties',
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* MIME types
|
|
130
|
+
*/
|
|
131
|
+
export const MIME_TYPES = {
|
|
132
|
+
APK: 'application/vnd.android.package-archive',
|
|
133
|
+
JSON: 'application/json',
|
|
134
|
+
TEXT: 'text/plain',
|
|
135
|
+
} as const;
|