@salve-software/mako-types 1.0.0
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/dist/domain/component.d.ts +35 -0
- package/dist/domain/component.d.ts.map +1 -0
- package/dist/domain/component.js +18 -0
- package/dist/domain/device.d.ts +15 -0
- package/dist/domain/device.d.ts.map +1 -0
- package/dist/domain/device.js +5 -0
- package/dist/domain/index.d.ts +10 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +9 -0
- package/dist/domain/log.d.ts +19 -0
- package/dist/domain/log.d.ts.map +1 -0
- package/dist/domain/log.js +5 -0
- package/dist/domain/network.d.ts +36 -0
- package/dist/domain/network.d.ts.map +1 -0
- package/dist/domain/network.js +40 -0
- package/dist/domain/performance.d.ts +27 -0
- package/dist/domain/performance.d.ts.map +1 -0
- package/dist/domain/performance.js +26 -0
- package/dist/domain/project.d.ts +11 -0
- package/dist/domain/project.d.ts.map +1 -0
- package/dist/domain/project.js +5 -0
- package/dist/events/component.d.ts +36 -0
- package/dist/events/component.d.ts.map +1 -0
- package/dist/events/component.js +5 -0
- package/dist/events/device.d.ts +15 -0
- package/dist/events/device.d.ts.map +1 -0
- package/dist/events/device.js +5 -0
- package/dist/events/index.d.ts +18 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +9 -0
- package/dist/events/log.d.ts +25 -0
- package/dist/events/log.d.ts.map +1 -0
- package/dist/events/log.js +5 -0
- package/dist/events/network.d.ts +27 -0
- package/dist/events/network.d.ts.map +1 -0
- package/dist/events/network.js +5 -0
- package/dist/events/performance.d.ts +15 -0
- package/dist/events/performance.d.ts.map +1 -0
- package/dist/events/performance.js +5 -0
- package/dist/events/project.d.ts +11 -0
- package/dist/events/project.d.ts.map +1 -0
- package/dist/events/project.js +5 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/package.json +33 -0
- package/src/domain/component.ts +49 -0
- package/src/domain/device.ts +16 -0
- package/src/domain/index.ts +10 -0
- package/src/domain/log.ts +23 -0
- package/src/domain/network.ts +84 -0
- package/src/domain/performance.ts +58 -0
- package/src/domain/project.ts +11 -0
- package/src/events/component.ts +39 -0
- package/src/events/device.ts +16 -0
- package/src/events/index.ts +30 -0
- package/src/events/log.ts +28 -0
- package/src/events/network.ts +30 -0
- package/src/events/performance.ts +15 -0
- package/src/events/project.ts +11 -0
- package/src/index.ts +10 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Domain Types
|
|
3
|
+
* Data models used in Mako desktop app for component inspection
|
|
4
|
+
*/
|
|
5
|
+
export type RenderHeatLevel = 'cold' | 'warm' | 'hot' | 'critical';
|
|
6
|
+
export interface ComponentMetrics {
|
|
7
|
+
componentId: string;
|
|
8
|
+
componentName: string;
|
|
9
|
+
renderCount: number;
|
|
10
|
+
totalRenderTime: number;
|
|
11
|
+
averageRenderTime: number;
|
|
12
|
+
lastRenderTime: number;
|
|
13
|
+
lastRenderTimestamp: number;
|
|
14
|
+
propsChangeCount: number;
|
|
15
|
+
stateChangeCount: number;
|
|
16
|
+
contextChangeCount: number;
|
|
17
|
+
isMemoized: boolean;
|
|
18
|
+
memoType: string;
|
|
19
|
+
heatLevel: RenderHeatLevel;
|
|
20
|
+
}
|
|
21
|
+
export interface ComponentNode {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
parentId: string | null;
|
|
25
|
+
children: string[];
|
|
26
|
+
depth: number;
|
|
27
|
+
metrics: ComponentMetrics;
|
|
28
|
+
deviceId: string;
|
|
29
|
+
projectId?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Calculate heat level based on render count and average duration
|
|
33
|
+
*/
|
|
34
|
+
export declare function calculateHeatLevel(renderCount: number, avgDuration: number): RenderHeatLevel;
|
|
35
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/domain/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,eAAe,CAQjB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Domain Types
|
|
3
|
+
* Data models used in Mako desktop app for component inspection
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Calculate heat level based on render count and average duration
|
|
7
|
+
*/
|
|
8
|
+
export function calculateHeatLevel(renderCount, avgDuration) {
|
|
9
|
+
// Weighted score: render count contributes more to heat than duration
|
|
10
|
+
const score = renderCount * 2 + avgDuration * 0.1;
|
|
11
|
+
if (score > 100)
|
|
12
|
+
return 'critical';
|
|
13
|
+
if (score > 50)
|
|
14
|
+
return 'hot';
|
|
15
|
+
if (score > 20)
|
|
16
|
+
return 'warm';
|
|
17
|
+
return 'cold';
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Domain Type
|
|
3
|
+
* Represents a connected device in Mako
|
|
4
|
+
*/
|
|
5
|
+
import type { Platform } from '../events/device';
|
|
6
|
+
export interface Device {
|
|
7
|
+
type: string;
|
|
8
|
+
deviceId: string;
|
|
9
|
+
deviceName: string;
|
|
10
|
+
platform: Platform;
|
|
11
|
+
appName?: string;
|
|
12
|
+
bundleId?: string;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/domain/device.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Types - Data models used in Mako desktop app
|
|
3
|
+
*/
|
|
4
|
+
export * from './device';
|
|
5
|
+
export * from './project';
|
|
6
|
+
export * from './log';
|
|
7
|
+
export * from './network';
|
|
8
|
+
export * from './component';
|
|
9
|
+
export * from './performance';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS Log Domain Type
|
|
3
|
+
* Stored representation of a log in Mako
|
|
4
|
+
*/
|
|
5
|
+
import type { LogLevel } from '../events/log';
|
|
6
|
+
export type { LogLevel };
|
|
7
|
+
export interface JSLog {
|
|
8
|
+
deviceId: string;
|
|
9
|
+
level: LogLevel;
|
|
10
|
+
message: string;
|
|
11
|
+
metadata: Record<string, unknown>;
|
|
12
|
+
source: string;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
type: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NativeLog extends JSLog {
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/domain/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAU,SAAQ,KAAK;CAEvC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Log Domain Types
|
|
3
|
+
* Stored representation of network requests in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
6
|
+
export type HttpStatusCategory = 'info' | 'success' | 'redirect' | 'client-error' | 'server-error';
|
|
7
|
+
export type NetworkRequestState = 'pending' | 'completed' | 'failed';
|
|
8
|
+
/**
|
|
9
|
+
* NetworkLog - Merged representation of request + response
|
|
10
|
+
* Events arrive separately but stored as single entry correlated by requestId
|
|
11
|
+
*/
|
|
12
|
+
export interface NetworkLog {
|
|
13
|
+
requestId: string;
|
|
14
|
+
deviceId: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
method: HttpMethod;
|
|
17
|
+
url: string;
|
|
18
|
+
requestHeaders: Record<string, string>;
|
|
19
|
+
requestBody: string | null;
|
|
20
|
+
requestTimestamp: number;
|
|
21
|
+
statusCode: number | null;
|
|
22
|
+
responseHeaders: Record<string, string> | null;
|
|
23
|
+
responseBody: string | null;
|
|
24
|
+
responseTimestamp: number | null;
|
|
25
|
+
duration: number | null;
|
|
26
|
+
state: NetworkRequestState;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get status category from HTTP status code
|
|
30
|
+
*/
|
|
31
|
+
export declare function getStatusCategory(statusCode: number | null): HttpStatusCategory | null;
|
|
32
|
+
/**
|
|
33
|
+
* Normalize HTTP method string to HttpMethod type
|
|
34
|
+
*/
|
|
35
|
+
export declare function normalizeHttpMethod(method: string): HttpMethod;
|
|
36
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/domain/network.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,UAAU,GAClB,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN,SAAS,GACT,UAAU,GACV,cAAc,GACd,cAAc,CAAC;AAEnB,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAErE;;;GAGG;AACH,MAAM,WAAW,UAAU;IAEzB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,MAAM,EAAE,UAAU,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;IAGzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC/C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAGjC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,mBAAmB,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,kBAAkB,GAAG,IAAI,CAQ3B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAc9D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Log Domain Types
|
|
3
|
+
* Stored representation of network requests in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get status category from HTTP status code
|
|
7
|
+
*/
|
|
8
|
+
export function getStatusCategory(statusCode) {
|
|
9
|
+
if (statusCode === null)
|
|
10
|
+
return null;
|
|
11
|
+
if (statusCode >= 100 && statusCode < 200)
|
|
12
|
+
return 'info';
|
|
13
|
+
if (statusCode >= 200 && statusCode < 300)
|
|
14
|
+
return 'success';
|
|
15
|
+
if (statusCode >= 300 && statusCode < 400)
|
|
16
|
+
return 'redirect';
|
|
17
|
+
if (statusCode >= 400 && statusCode < 500)
|
|
18
|
+
return 'client-error';
|
|
19
|
+
if (statusCode >= 500)
|
|
20
|
+
return 'server-error';
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Normalize HTTP method string to HttpMethod type
|
|
25
|
+
*/
|
|
26
|
+
export function normalizeHttpMethod(method) {
|
|
27
|
+
const upper = method.toUpperCase();
|
|
28
|
+
const validMethods = [
|
|
29
|
+
'GET',
|
|
30
|
+
'POST',
|
|
31
|
+
'PUT',
|
|
32
|
+
'PATCH',
|
|
33
|
+
'DELETE',
|
|
34
|
+
'HEAD',
|
|
35
|
+
'OPTIONS',
|
|
36
|
+
];
|
|
37
|
+
return validMethods.includes(upper)
|
|
38
|
+
? upper
|
|
39
|
+
: 'GET';
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Domain Types
|
|
3
|
+
* Stored representation of performance metrics in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export type PerformanceHealthLevel = 'good' | 'moderate' | 'poor' | 'critical';
|
|
6
|
+
export interface PerformanceSnapshot {
|
|
7
|
+
timestamp: number;
|
|
8
|
+
deviceId: string;
|
|
9
|
+
uiFps: number;
|
|
10
|
+
jsFps: number;
|
|
11
|
+
memoryUsage: number;
|
|
12
|
+
cpuUsage: number;
|
|
13
|
+
healthLevel: PerformanceHealthLevel;
|
|
14
|
+
}
|
|
15
|
+
export interface PerformanceStats {
|
|
16
|
+
avgUiFps: number;
|
|
17
|
+
avgJsFps: number;
|
|
18
|
+
avgMemoryUsage: number;
|
|
19
|
+
avgCpuUsage: number;
|
|
20
|
+
healthLevel: PerformanceHealthLevel;
|
|
21
|
+
sampleCount: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Calculate overall health level from performance metrics
|
|
25
|
+
*/
|
|
26
|
+
export declare function calculateHealthLevel(uiFps: number, jsFps: number, memoryUsage: number, cpuUsage: number): PerformanceHealthLevel;
|
|
27
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/domain/performance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,UAAU,CAAC;AAE/E,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,sBAAsB,CAAC;CACrC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,sBAAsB,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,sBAAsB,CAuBxB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Domain Types
|
|
3
|
+
* Stored representation of performance metrics in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Calculate overall health level from performance metrics
|
|
7
|
+
*/
|
|
8
|
+
export function calculateHealthLevel(uiFps, jsFps, memoryUsage, cpuUsage) {
|
|
9
|
+
// Critical: Any critical metric
|
|
10
|
+
if (uiFps < 20 || jsFps < 20 || cpuUsage > 90) {
|
|
11
|
+
return 'critical';
|
|
12
|
+
}
|
|
13
|
+
// Poor: Multiple poor metrics or one very poor
|
|
14
|
+
if ((uiFps < 30 && jsFps < 30) ||
|
|
15
|
+
uiFps < 25 ||
|
|
16
|
+
jsFps < 25 ||
|
|
17
|
+
cpuUsage > 80) {
|
|
18
|
+
return 'poor';
|
|
19
|
+
}
|
|
20
|
+
// Moderate: Some metrics below ideal
|
|
21
|
+
if (uiFps < 50 || jsFps < 50 || cpuUsage > 60) {
|
|
22
|
+
return 'moderate';
|
|
23
|
+
}
|
|
24
|
+
// Good: All metrics healthy
|
|
25
|
+
return 'good';
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/domain/project.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Event Types
|
|
3
|
+
* Used by SDK to send component render tracking data to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export type MemoType = 'none' | 'React.memo' | 'useMemo' | 'useCallback' | 'PureComponent';
|
|
6
|
+
export interface ComponentRenderEvent {
|
|
7
|
+
type: 'component_render';
|
|
8
|
+
componentId: string;
|
|
9
|
+
componentName: string;
|
|
10
|
+
renderCount: number;
|
|
11
|
+
renderDuration: number;
|
|
12
|
+
timestamp: number;
|
|
13
|
+
parentId: string | null;
|
|
14
|
+
propsChanged: boolean;
|
|
15
|
+
stateChanged: boolean;
|
|
16
|
+
contextChanged: boolean;
|
|
17
|
+
isMemoized: boolean;
|
|
18
|
+
memoType: MemoType;
|
|
19
|
+
deviceId?: string;
|
|
20
|
+
projectId?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ComponentTreeNode {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
parentId: string | null;
|
|
26
|
+
children: string[];
|
|
27
|
+
depth: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ComponentTreeEvent {
|
|
30
|
+
type: 'component_tree';
|
|
31
|
+
tree: ComponentTreeNode[];
|
|
32
|
+
timestamp: number;
|
|
33
|
+
deviceId?: string;
|
|
34
|
+
projectId?: string;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/events/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,GAAG,eAAe,CAAC;AAE3F,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,kBAAkB,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,iBAAiB,EAAE,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Info Event
|
|
3
|
+
* Sent when device connects to Mako
|
|
4
|
+
*/
|
|
5
|
+
export type Platform = 'ios' | 'android';
|
|
6
|
+
export interface DeviceInfoEvent {
|
|
7
|
+
type: 'device_info';
|
|
8
|
+
deviceId: string;
|
|
9
|
+
deviceName: string;
|
|
10
|
+
platform: Platform;
|
|
11
|
+
appName?: string;
|
|
12
|
+
bundleId: string;
|
|
13
|
+
projectId: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../src/events/device.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Types - Messages sent from SDK to Mako desktop app
|
|
3
|
+
*/
|
|
4
|
+
export * from './log';
|
|
5
|
+
export * from './network';
|
|
6
|
+
export * from './device';
|
|
7
|
+
export * from './project';
|
|
8
|
+
export * from './component';
|
|
9
|
+
export * from './performance';
|
|
10
|
+
export type EventType = 'log' | 'network' | 'native' | 'device_info' | 'project_info' | 'component_render' | 'component_tree' | 'performance_metrics';
|
|
11
|
+
import type { LogEvent, NativeLogEvent } from './log';
|
|
12
|
+
import type { NetworkEvent } from './network';
|
|
13
|
+
import type { DeviceInfoEvent } from './device';
|
|
14
|
+
import type { ProjectInfoEvent } from './project';
|
|
15
|
+
import type { ComponentRenderEvent, ComponentTreeEvent } from './component';
|
|
16
|
+
import type { PerformanceMetricsEvent } from './performance';
|
|
17
|
+
export type MakoEvent = LogEvent | NativeLogEvent | NetworkEvent | DeviceInfoEvent | ProjectInfoEvent | ComponentRenderEvent | ComponentTreeEvent | PerformanceMetricsEvent;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/events/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAE9B,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,cAAc,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,qBAAqB,CAAC;AAGtJ,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAE7D,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,cAAc,GACd,YAAY,GACZ,eAAe,GACf,gBAAgB,GAChB,oBAAoB,GACpB,kBAAkB,GAClB,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Event Types
|
|
3
|
+
* Used by SDK to send logs to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export type LogLevel = 'debug' | 'info' | 'log' | 'warn' | 'error';
|
|
6
|
+
export type LogSource = 'js' | 'ios' | 'android';
|
|
7
|
+
export type NativeLogSource = 'ios' | 'android';
|
|
8
|
+
export interface BaseLogEvent {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
message: string;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
deviceId?: string;
|
|
14
|
+
projectId?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface LogEvent extends BaseLogEvent {
|
|
17
|
+
type: 'log';
|
|
18
|
+
source: LogSource;
|
|
19
|
+
}
|
|
20
|
+
export interface NativeLogEvent extends BaseLogEvent {
|
|
21
|
+
type: 'native';
|
|
22
|
+
source: NativeLogSource;
|
|
23
|
+
tag?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/events/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AACnE,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;AACjD,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,QAAQ,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAS,SAAQ,YAAY;IAC5C,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Event Types
|
|
3
|
+
* Used by SDK to send network logs to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export type NetworkStage = 'request' | 'response';
|
|
6
|
+
interface BaseNetworkEvent {
|
|
7
|
+
type: 'network';
|
|
8
|
+
timestamp: number;
|
|
9
|
+
requestId: string;
|
|
10
|
+
method: string;
|
|
11
|
+
url: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
body?: string;
|
|
14
|
+
deviceId?: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NetworkRequestEvent extends BaseNetworkEvent {
|
|
18
|
+
stage: 'request';
|
|
19
|
+
}
|
|
20
|
+
export interface NetworkResponseEvent extends BaseNetworkEvent {
|
|
21
|
+
stage: 'response';
|
|
22
|
+
statusCode: number;
|
|
23
|
+
duration: number;
|
|
24
|
+
}
|
|
25
|
+
export type NetworkEvent = NetworkRequestEvent | NetworkResponseEvent;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=network.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.d.ts","sourceRoot":"","sources":["../../src/events/network.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAC;AAElD,UAAU,gBAAgB;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Event Types
|
|
3
|
+
* Used by SDK to send performance metrics to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
export interface PerformanceMetricsEvent {
|
|
6
|
+
type: 'performance_metrics';
|
|
7
|
+
timestamp: number;
|
|
8
|
+
deviceId?: string;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
uiFps: number;
|
|
11
|
+
jsFps: number;
|
|
12
|
+
memoryUsage: number;
|
|
13
|
+
cpuUsage: number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=performance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/events/performance.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/events/project.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@salve-software/mako-types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared types for Mako ecosystem",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./events": {
|
|
14
|
+
"types": "./dist/events/index.d.ts",
|
|
15
|
+
"import": "./dist/events/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./domain": {
|
|
18
|
+
"types": "./dist/domain/index.d.ts",
|
|
19
|
+
"import": "./dist/domain/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"src"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Domain Types
|
|
3
|
+
* Data models used in Mako desktop app for component inspection
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type RenderHeatLevel = 'cold' | 'warm' | 'hot' | 'critical';
|
|
7
|
+
|
|
8
|
+
export interface ComponentMetrics {
|
|
9
|
+
componentId: string;
|
|
10
|
+
componentName: string;
|
|
11
|
+
renderCount: number;
|
|
12
|
+
totalRenderTime: number;
|
|
13
|
+
averageRenderTime: number;
|
|
14
|
+
lastRenderTime: number;
|
|
15
|
+
lastRenderTimestamp: number;
|
|
16
|
+
propsChangeCount: number;
|
|
17
|
+
stateChangeCount: number;
|
|
18
|
+
contextChangeCount: number;
|
|
19
|
+
isMemoized: boolean;
|
|
20
|
+
memoType: string;
|
|
21
|
+
heatLevel: RenderHeatLevel;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ComponentNode {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
parentId: string | null;
|
|
28
|
+
children: string[];
|
|
29
|
+
depth: number;
|
|
30
|
+
metrics: ComponentMetrics;
|
|
31
|
+
deviceId: string;
|
|
32
|
+
projectId?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Calculate heat level based on render count and average duration
|
|
37
|
+
*/
|
|
38
|
+
export function calculateHeatLevel(
|
|
39
|
+
renderCount: number,
|
|
40
|
+
avgDuration: number
|
|
41
|
+
): RenderHeatLevel {
|
|
42
|
+
// Weighted score: render count contributes more to heat than duration
|
|
43
|
+
const score = renderCount * 2 + avgDuration * 0.1;
|
|
44
|
+
|
|
45
|
+
if (score > 100) return 'critical';
|
|
46
|
+
if (score > 50) return 'hot';
|
|
47
|
+
if (score > 20) return 'warm';
|
|
48
|
+
return 'cold';
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Domain Type
|
|
3
|
+
* Represents a connected device in Mako
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Platform } from '../events/device';
|
|
7
|
+
|
|
8
|
+
export interface Device {
|
|
9
|
+
type: string;
|
|
10
|
+
deviceId: string;
|
|
11
|
+
deviceName: string;
|
|
12
|
+
platform: Platform;
|
|
13
|
+
appName?: string;
|
|
14
|
+
bundleId?: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS Log Domain Type
|
|
3
|
+
* Stored representation of a log in Mako
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { LogLevel } from '../events/log';
|
|
7
|
+
|
|
8
|
+
export type { LogLevel };
|
|
9
|
+
|
|
10
|
+
export interface JSLog {
|
|
11
|
+
deviceId: string;
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
message: string;
|
|
14
|
+
metadata: Record<string, unknown>;
|
|
15
|
+
source: string;
|
|
16
|
+
timestamp: number;
|
|
17
|
+
type: string;
|
|
18
|
+
projectId?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NativeLog extends JSLog {
|
|
22
|
+
|
|
23
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Log Domain Types
|
|
3
|
+
* Stored representation of network requests in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type HttpMethod =
|
|
7
|
+
| 'GET'
|
|
8
|
+
| 'POST'
|
|
9
|
+
| 'PUT'
|
|
10
|
+
| 'PATCH'
|
|
11
|
+
| 'DELETE'
|
|
12
|
+
| 'HEAD'
|
|
13
|
+
| 'OPTIONS';
|
|
14
|
+
|
|
15
|
+
export type HttpStatusCategory =
|
|
16
|
+
| 'info'
|
|
17
|
+
| 'success'
|
|
18
|
+
| 'redirect'
|
|
19
|
+
| 'client-error'
|
|
20
|
+
| 'server-error';
|
|
21
|
+
|
|
22
|
+
export type NetworkRequestState = 'pending' | 'completed' | 'failed';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* NetworkLog - Merged representation of request + response
|
|
26
|
+
* Events arrive separately but stored as single entry correlated by requestId
|
|
27
|
+
*/
|
|
28
|
+
export interface NetworkLog {
|
|
29
|
+
// Identity
|
|
30
|
+
requestId: string;
|
|
31
|
+
deviceId: string;
|
|
32
|
+
projectId?: string;
|
|
33
|
+
|
|
34
|
+
// Request data
|
|
35
|
+
method: HttpMethod;
|
|
36
|
+
url: string;
|
|
37
|
+
requestHeaders: Record<string, string>;
|
|
38
|
+
requestBody: string | null;
|
|
39
|
+
requestTimestamp: number;
|
|
40
|
+
|
|
41
|
+
// Response data (null if pending/failed)
|
|
42
|
+
statusCode: number | null;
|
|
43
|
+
responseHeaders: Record<string, string> | null;
|
|
44
|
+
responseBody: string | null;
|
|
45
|
+
responseTimestamp: number | null;
|
|
46
|
+
|
|
47
|
+
// Computed
|
|
48
|
+
duration: number | null;
|
|
49
|
+
state: NetworkRequestState;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get status category from HTTP status code
|
|
54
|
+
*/
|
|
55
|
+
export function getStatusCategory(
|
|
56
|
+
statusCode: number | null
|
|
57
|
+
): HttpStatusCategory | null {
|
|
58
|
+
if (statusCode === null) return null;
|
|
59
|
+
if (statusCode >= 100 && statusCode < 200) return 'info';
|
|
60
|
+
if (statusCode >= 200 && statusCode < 300) return 'success';
|
|
61
|
+
if (statusCode >= 300 && statusCode < 400) return 'redirect';
|
|
62
|
+
if (statusCode >= 400 && statusCode < 500) return 'client-error';
|
|
63
|
+
if (statusCode >= 500) return 'server-error';
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Normalize HTTP method string to HttpMethod type
|
|
69
|
+
*/
|
|
70
|
+
export function normalizeHttpMethod(method: string): HttpMethod {
|
|
71
|
+
const upper = method.toUpperCase();
|
|
72
|
+
const validMethods: HttpMethod[] = [
|
|
73
|
+
'GET',
|
|
74
|
+
'POST',
|
|
75
|
+
'PUT',
|
|
76
|
+
'PATCH',
|
|
77
|
+
'DELETE',
|
|
78
|
+
'HEAD',
|
|
79
|
+
'OPTIONS',
|
|
80
|
+
];
|
|
81
|
+
return validMethods.includes(upper as HttpMethod)
|
|
82
|
+
? (upper as HttpMethod)
|
|
83
|
+
: 'GET';
|
|
84
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Domain Types
|
|
3
|
+
* Stored representation of performance metrics in Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type PerformanceHealthLevel = 'good' | 'moderate' | 'poor' | 'critical';
|
|
7
|
+
|
|
8
|
+
export interface PerformanceSnapshot {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
deviceId: string;
|
|
11
|
+
uiFps: number;
|
|
12
|
+
jsFps: number;
|
|
13
|
+
memoryUsage: number;
|
|
14
|
+
cpuUsage: number;
|
|
15
|
+
healthLevel: PerformanceHealthLevel;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface PerformanceStats {
|
|
19
|
+
avgUiFps: number;
|
|
20
|
+
avgJsFps: number;
|
|
21
|
+
avgMemoryUsage: number;
|
|
22
|
+
avgCpuUsage: number;
|
|
23
|
+
healthLevel: PerformanceHealthLevel;
|
|
24
|
+
sampleCount: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Calculate overall health level from performance metrics
|
|
29
|
+
*/
|
|
30
|
+
export function calculateHealthLevel(
|
|
31
|
+
uiFps: number,
|
|
32
|
+
jsFps: number,
|
|
33
|
+
memoryUsage: number,
|
|
34
|
+
cpuUsage: number
|
|
35
|
+
): PerformanceHealthLevel {
|
|
36
|
+
// Critical: Any critical metric
|
|
37
|
+
if (uiFps < 20 || jsFps < 20 || cpuUsage > 90) {
|
|
38
|
+
return 'critical';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Poor: Multiple poor metrics or one very poor
|
|
42
|
+
if (
|
|
43
|
+
(uiFps < 30 && jsFps < 30) ||
|
|
44
|
+
uiFps < 25 ||
|
|
45
|
+
jsFps < 25 ||
|
|
46
|
+
cpuUsage > 80
|
|
47
|
+
) {
|
|
48
|
+
return 'poor';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Moderate: Some metrics below ideal
|
|
52
|
+
if (uiFps < 50 || jsFps < 50 || cpuUsage > 60) {
|
|
53
|
+
return 'moderate';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Good: All metrics healthy
|
|
57
|
+
return 'good';
|
|
58
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Event Types
|
|
3
|
+
* Used by SDK to send component render tracking data to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type MemoType = 'none' | 'React.memo' | 'useMemo' | 'useCallback' | 'PureComponent';
|
|
7
|
+
|
|
8
|
+
export interface ComponentRenderEvent {
|
|
9
|
+
type: 'component_render';
|
|
10
|
+
componentId: string;
|
|
11
|
+
componentName: string;
|
|
12
|
+
renderCount: number;
|
|
13
|
+
renderDuration: number; // ms
|
|
14
|
+
timestamp: number;
|
|
15
|
+
parentId: string | null;
|
|
16
|
+
propsChanged: boolean;
|
|
17
|
+
stateChanged: boolean;
|
|
18
|
+
contextChanged: boolean;
|
|
19
|
+
isMemoized: boolean;
|
|
20
|
+
memoType: MemoType;
|
|
21
|
+
deviceId?: string;
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ComponentTreeNode {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
parentId: string | null;
|
|
29
|
+
children: string[];
|
|
30
|
+
depth: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface ComponentTreeEvent {
|
|
34
|
+
type: 'component_tree';
|
|
35
|
+
tree: ComponentTreeNode[];
|
|
36
|
+
timestamp: number;
|
|
37
|
+
deviceId?: string;
|
|
38
|
+
projectId?: string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Info Event
|
|
3
|
+
* Sent when device connects to Mako
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type Platform = 'ios' | 'android';
|
|
7
|
+
|
|
8
|
+
export interface DeviceInfoEvent {
|
|
9
|
+
type: 'device_info';
|
|
10
|
+
deviceId: string;
|
|
11
|
+
deviceName: string;
|
|
12
|
+
platform: Platform;
|
|
13
|
+
appName?: string;
|
|
14
|
+
bundleId: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Types - Messages sent from SDK to Mako desktop app
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './log';
|
|
6
|
+
export * from './network';
|
|
7
|
+
export * from './device';
|
|
8
|
+
export * from './project';
|
|
9
|
+
export * from './component';
|
|
10
|
+
export * from './performance';
|
|
11
|
+
|
|
12
|
+
export type EventType = 'log' | 'network' | 'native' | 'device_info' | 'project_info' | 'component_render' | 'component_tree' | 'performance_metrics';
|
|
13
|
+
|
|
14
|
+
// Re-export union type
|
|
15
|
+
import type { LogEvent, NativeLogEvent } from './log';
|
|
16
|
+
import type { NetworkEvent } from './network';
|
|
17
|
+
import type { DeviceInfoEvent } from './device';
|
|
18
|
+
import type { ProjectInfoEvent } from './project';
|
|
19
|
+
import type { ComponentRenderEvent, ComponentTreeEvent } from './component';
|
|
20
|
+
import type { PerformanceMetricsEvent } from './performance';
|
|
21
|
+
|
|
22
|
+
export type MakoEvent =
|
|
23
|
+
| LogEvent
|
|
24
|
+
| NativeLogEvent
|
|
25
|
+
| NetworkEvent
|
|
26
|
+
| DeviceInfoEvent
|
|
27
|
+
| ProjectInfoEvent
|
|
28
|
+
| ComponentRenderEvent
|
|
29
|
+
| ComponentTreeEvent
|
|
30
|
+
| PerformanceMetricsEvent;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Event Types
|
|
3
|
+
* Used by SDK to send logs to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type LogLevel = 'debug' | 'info' | 'log' | 'warn' | 'error';
|
|
7
|
+
export type LogSource = 'js' | 'ios' | 'android';
|
|
8
|
+
export type NativeLogSource = 'ios' | 'android';
|
|
9
|
+
|
|
10
|
+
export interface BaseLogEvent {
|
|
11
|
+
timestamp: number;
|
|
12
|
+
level: LogLevel;
|
|
13
|
+
message: string;
|
|
14
|
+
metadata?: Record<string, unknown>;
|
|
15
|
+
deviceId?: string;
|
|
16
|
+
projectId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface LogEvent extends BaseLogEvent {
|
|
20
|
+
type: 'log';
|
|
21
|
+
source: LogSource;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NativeLogEvent extends BaseLogEvent {
|
|
25
|
+
type: 'native';
|
|
26
|
+
source: NativeLogSource;
|
|
27
|
+
tag?: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Event Types
|
|
3
|
+
* Used by SDK to send network logs to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type NetworkStage = 'request' | 'response';
|
|
7
|
+
|
|
8
|
+
interface BaseNetworkEvent {
|
|
9
|
+
type: 'network';
|
|
10
|
+
timestamp: number;
|
|
11
|
+
requestId: string;
|
|
12
|
+
method: string;
|
|
13
|
+
url: string;
|
|
14
|
+
headers?: Record<string, string>;
|
|
15
|
+
body?: string;
|
|
16
|
+
deviceId?: string;
|
|
17
|
+
projectId?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NetworkRequestEvent extends BaseNetworkEvent {
|
|
21
|
+
stage: 'request';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NetworkResponseEvent extends BaseNetworkEvent {
|
|
25
|
+
stage: 'response';
|
|
26
|
+
statusCode: number;
|
|
27
|
+
duration: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type NetworkEvent = NetworkRequestEvent | NetworkResponseEvent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance Event Types
|
|
3
|
+
* Used by SDK to send performance metrics to Mako desktop app
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface PerformanceMetricsEvent {
|
|
7
|
+
type: 'performance_metrics';
|
|
8
|
+
timestamp: number;
|
|
9
|
+
deviceId?: string;
|
|
10
|
+
projectId?: string;
|
|
11
|
+
uiFps: number;
|
|
12
|
+
jsFps: number;
|
|
13
|
+
memoryUsage: number; // MB
|
|
14
|
+
cpuUsage: number; // 0-100
|
|
15
|
+
}
|