@nativemason/contracts 0.0.0-stage → 0.3.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/LICENSE +202 -0
- package/README.md +4 -2
- package/dist/accessibility.d.ts +92 -0
- package/dist/accessibility.js +21 -0
- package/dist/constraints.d.ts +179 -0
- package/dist/constraints.js +16 -0
- package/dist/design.d.ts +304 -0
- package/dist/design.js +29 -0
- package/dist/diagnostics.d.ts +580 -0
- package/dist/diagnostics.js +35 -0
- package/dist/evidence.d.ts +854 -0
- package/dist/evidence.js +44 -0
- package/dist/geometry.d.ts +39 -0
- package/dist/geometry.js +4 -0
- package/dist/graph.d.ts +456 -0
- package/dist/graph.js +36 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/native-protocol.d.ts +262 -0
- package/dist/native-protocol.js +13 -0
- package/dist/source.d.ts +119 -0
- package/dist/source.js +17 -0
- package/dist/styles.d.ts +105 -0
- package/dist/styles.js +3 -0
- package/dist/tools.d.ts +7411 -0
- package/dist/tools.js +55 -0
- package/dist/workflow.d.ts +688 -0
- package/dist/workflow.js +18 -0
- package/package.json +33 -3
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Explicit local interface for development pairing; never a wildcard/public listener. */
|
|
3
|
+
export declare const NativeBindHostSchema: z.ZodIPv4;
|
|
4
|
+
export type NativeBindHost = z.infer<typeof NativeBindHostSchema>;
|
|
5
|
+
export declare const NativeClientMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
6
|
+
type: z.ZodLiteral<"hello">;
|
|
7
|
+
token: z.ZodString;
|
|
8
|
+
scenarioId: z.ZodString;
|
|
9
|
+
protocolVersion: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
10
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
android: "android";
|
|
12
|
+
ios: "ios";
|
|
13
|
+
}>>;
|
|
14
|
+
targetId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
capabilities: z.ZodOptional<z.ZodObject<{
|
|
16
|
+
textFits: z.ZodBoolean;
|
|
17
|
+
scenarioActions: z.ZodBoolean;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
20
|
+
type: z.ZodLiteral<"action_result">;
|
|
21
|
+
requestId: z.ZodString;
|
|
22
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
23
|
+
type: z.ZodLiteral<"snapshot">;
|
|
24
|
+
requestId: z.ZodString;
|
|
25
|
+
snapshot: z.ZodObject<{
|
|
26
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
27
|
+
sessionId: z.ZodString;
|
|
28
|
+
snapshotId: z.ZodString;
|
|
29
|
+
platform: z.ZodEnum<{
|
|
30
|
+
web: "web";
|
|
31
|
+
android: "android";
|
|
32
|
+
ios: "ios";
|
|
33
|
+
}>;
|
|
34
|
+
scenarioId: z.ZodString;
|
|
35
|
+
profile: z.ZodObject<{
|
|
36
|
+
window: z.ZodObject<{
|
|
37
|
+
width: z.ZodNumber;
|
|
38
|
+
height: z.ZodNumber;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
pixelRatio: z.ZodNumber;
|
|
41
|
+
fontScale: z.ZodNumber;
|
|
42
|
+
insets: z.ZodObject<{
|
|
43
|
+
top: z.ZodNumber;
|
|
44
|
+
right: z.ZodNumber;
|
|
45
|
+
bottom: z.ZodNumber;
|
|
46
|
+
left: z.ZodNumber;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
root: z.ZodObject<{
|
|
49
|
+
x: z.ZodNumber;
|
|
50
|
+
y: z.ZodNumber;
|
|
51
|
+
width: z.ZodNumber;
|
|
52
|
+
height: z.ZodNumber;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
orientation: z.ZodEnum<{
|
|
55
|
+
portrait: "portrait";
|
|
56
|
+
landscape: "landscape";
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strict>;
|
|
59
|
+
revisions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
60
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
61
|
+
id: z.ZodString;
|
|
62
|
+
parentId: z.ZodNullable<z.ZodString>;
|
|
63
|
+
kind: z.ZodEnum<{
|
|
64
|
+
View: "View";
|
|
65
|
+
Text: "Text";
|
|
66
|
+
Pressable: "Pressable";
|
|
67
|
+
TextInput: "TextInput";
|
|
68
|
+
ScrollView: "ScrollView";
|
|
69
|
+
Image: "Image";
|
|
70
|
+
}>;
|
|
71
|
+
role: z.ZodNullable<z.ZodString>;
|
|
72
|
+
rect: z.ZodObject<{
|
|
73
|
+
x: z.ZodNumber;
|
|
74
|
+
y: z.ZodNumber;
|
|
75
|
+
width: z.ZodNumber;
|
|
76
|
+
height: z.ZodNumber;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
styles: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
79
|
+
source: z.ZodNullable<z.ZodObject<{
|
|
80
|
+
path: z.ZodString;
|
|
81
|
+
styleForm: z.ZodOptional<z.ZodLiteral<"pressable-state">>;
|
|
82
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
83
|
+
hash: z.ZodString;
|
|
84
|
+
start: z.ZodNumber;
|
|
85
|
+
end: z.ZodNumber;
|
|
86
|
+
line: z.ZodNumber;
|
|
87
|
+
column: z.ZodNumber;
|
|
88
|
+
}, z.core.$strict>>;
|
|
89
|
+
editable: z.ZodBoolean;
|
|
90
|
+
editReason: z.ZodNullable<z.ZodString>;
|
|
91
|
+
pressableState: z.ZodOptional<z.ZodEnum<{
|
|
92
|
+
pressed: "pressed";
|
|
93
|
+
rest: "rest";
|
|
94
|
+
}>>;
|
|
95
|
+
accessibility: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
authoredLabel: z.ZodOptional<z.ZodString>;
|
|
97
|
+
authoredHint: z.ZodOptional<z.ZodString>;
|
|
98
|
+
accessible: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
focusable: z.ZodOptional<z.ZodBoolean>;
|
|
100
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
101
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
direction: z.ZodEnum<{
|
|
103
|
+
unknown: "unknown";
|
|
104
|
+
ltr: "ltr";
|
|
105
|
+
rtl: "rtl";
|
|
106
|
+
}>;
|
|
107
|
+
directionSource: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
unknown: "unknown";
|
|
109
|
+
authored: "authored";
|
|
110
|
+
"native-global": "native-global";
|
|
111
|
+
"browser-computed": "browser-computed";
|
|
112
|
+
}>>;
|
|
113
|
+
browser: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
name: z.ZodNullable<z.ZodString>;
|
|
115
|
+
focusOrder: z.ZodNullable<z.ZodNumber>;
|
|
116
|
+
focusOrderSource: z.ZodLiteral<"dom-sequential-estimate">;
|
|
117
|
+
contrast: z.ZodObject<{
|
|
118
|
+
status: z.ZodEnum<{
|
|
119
|
+
measured: "measured";
|
|
120
|
+
unavailable: "unavailable";
|
|
121
|
+
}>;
|
|
122
|
+
ratio: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
requiredRatio: z.ZodOptional<z.ZodNumber>;
|
|
124
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
125
|
+
}, z.core.$strict>;
|
|
126
|
+
}, z.core.$strict>>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
textFit: z.ZodOptional<z.ZodObject<{
|
|
129
|
+
status: z.ZodEnum<{
|
|
130
|
+
unavailable: "unavailable";
|
|
131
|
+
supported: "supported";
|
|
132
|
+
}>;
|
|
133
|
+
fullLineCount: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
limitedLineCount: z.ZodOptional<z.ZodNumber>;
|
|
135
|
+
fullHeight: z.ZodOptional<z.ZodNumber>;
|
|
136
|
+
availableHeight: z.ZodOptional<z.ZodNumber>;
|
|
137
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
138
|
+
}, z.core.$strict>>;
|
|
139
|
+
authoredTextProps: z.ZodOptional<z.ZodObject<{
|
|
140
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
141
|
+
lineHeight: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
numberOfLines: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
allowFontScaling: z.ZodOptional<z.ZodBoolean>;
|
|
144
|
+
ellipsizeMode: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
head: "head";
|
|
146
|
+
middle: "middle";
|
|
147
|
+
tail: "tail";
|
|
148
|
+
clip: "clip";
|
|
149
|
+
}>>;
|
|
150
|
+
}, z.core.$strict>>;
|
|
151
|
+
measuredLineCount: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, z.core.$strict>>;
|
|
153
|
+
status: z.ZodEnum<{
|
|
154
|
+
stable: "stable";
|
|
155
|
+
unstable: "unstable";
|
|
156
|
+
}>;
|
|
157
|
+
generation: z.ZodNumber;
|
|
158
|
+
nativeTarget: z.ZodOptional<z.ZodObject<{
|
|
159
|
+
targetId: z.ZodString;
|
|
160
|
+
platform: z.ZodEnum<{
|
|
161
|
+
android: "android";
|
|
162
|
+
ios: "ios";
|
|
163
|
+
}>;
|
|
164
|
+
kind: z.ZodEnum<{
|
|
165
|
+
physical: "physical";
|
|
166
|
+
emulator: "emulator";
|
|
167
|
+
simulator: "simulator";
|
|
168
|
+
}>;
|
|
169
|
+
}, z.core.$strict>>;
|
|
170
|
+
webDiagnostics: z.ZodOptional<z.ZodObject<{
|
|
171
|
+
nodes: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
172
|
+
clipping: z.ZodEnum<{
|
|
173
|
+
unknown: "unknown";
|
|
174
|
+
confirmed: "confirmed";
|
|
175
|
+
clear: "clear";
|
|
176
|
+
}>;
|
|
177
|
+
centerHitTest: z.ZodEnum<{
|
|
178
|
+
unknown: "unknown";
|
|
179
|
+
confirmed: "confirmed";
|
|
180
|
+
clear: "clear";
|
|
181
|
+
}>;
|
|
182
|
+
scrollOverflow: z.ZodObject<{
|
|
183
|
+
horizontal: z.ZodBoolean;
|
|
184
|
+
vertical: z.ZodBoolean;
|
|
185
|
+
}, z.core.$strict>;
|
|
186
|
+
paintOrder: z.ZodNullable<z.ZodNumber>;
|
|
187
|
+
fonts: z.ZodArray<z.ZodObject<{
|
|
188
|
+
family: z.ZodString;
|
|
189
|
+
glyphCount: z.ZodNumber;
|
|
190
|
+
isCustom: z.ZodNullable<z.ZodBoolean>;
|
|
191
|
+
}, z.core.$strict>>;
|
|
192
|
+
lineBoxCount: z.ZodNullable<z.ZodNumber>;
|
|
193
|
+
}, z.core.$strict>>;
|
|
194
|
+
warnings: z.ZodArray<z.ZodObject<{
|
|
195
|
+
elementId: z.ZodString;
|
|
196
|
+
code: z.ZodEnum<{
|
|
197
|
+
CLIPPED: "CLIPPED";
|
|
198
|
+
OCCLUDED: "OCCLUDED";
|
|
199
|
+
FONT_LOAD_FAILED: "FONT_LOAD_FAILED";
|
|
200
|
+
EVIDENCE_UNAVAILABLE: "EVIDENCE_UNAVAILABLE";
|
|
201
|
+
}>;
|
|
202
|
+
severity: z.ZodEnum<{
|
|
203
|
+
confirmed: "confirmed";
|
|
204
|
+
uncertain: "uncertain";
|
|
205
|
+
}>;
|
|
206
|
+
message: z.ZodString;
|
|
207
|
+
}, z.core.$strict>>;
|
|
208
|
+
}, z.core.$strict>>;
|
|
209
|
+
}, z.core.$strict>;
|
|
210
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"error">;
|
|
212
|
+
requestId: z.ZodString;
|
|
213
|
+
error: z.ZodObject<{
|
|
214
|
+
code: z.ZodEnum<{
|
|
215
|
+
INVALID_INPUT: "INVALID_INPUT";
|
|
216
|
+
MISSING_ELEMENT: "MISSING_ELEMENT";
|
|
217
|
+
DUPLICATE_ELEMENT: "DUPLICATE_ELEMENT";
|
|
218
|
+
STALE_SNAPSHOT: "STALE_SNAPSHOT";
|
|
219
|
+
STALE_SOURCE: "STALE_SOURCE";
|
|
220
|
+
UNSUPPORTED_EDIT: "UNSUPPORTED_EDIT";
|
|
221
|
+
UNSUPPORTED_PROFILE: "UNSUPPORTED_PROFILE";
|
|
222
|
+
UNSTABLE_LAYOUT: "UNSTABLE_LAYOUT";
|
|
223
|
+
NATIVE_DISCONNECTED: "NATIVE_DISCONNECTED";
|
|
224
|
+
TIMEOUT: "TIMEOUT";
|
|
225
|
+
VERIFICATION_FAILED: "VERIFICATION_FAILED";
|
|
226
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
227
|
+
TRIAL_NOT_FOUND: "TRIAL_NOT_FOUND";
|
|
228
|
+
SOURCE_OUTSIDE_PROJECT: "SOURCE_OUTSIDE_PROJECT";
|
|
229
|
+
INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
230
|
+
RECOVERY_CONFLICT: "RECOVERY_CONFLICT";
|
|
231
|
+
TRANSACTION_CONFLICT: "TRANSACTION_CONFLICT";
|
|
232
|
+
UNSUPPORTED_ACTION: "UNSUPPORTED_ACTION";
|
|
233
|
+
PROTOCOL_MISMATCH: "PROTOCOL_MISMATCH";
|
|
234
|
+
}>;
|
|
235
|
+
message: z.ZodString;
|
|
236
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
}, z.core.$strict>], "type">;
|
|
239
|
+
export type NativeClientMessage = z.infer<typeof NativeClientMessageSchema>;
|
|
240
|
+
export declare const NativeServerMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
241
|
+
type: z.ZodLiteral<"capture">;
|
|
242
|
+
requestId: z.ZodString;
|
|
243
|
+
sessionId: z.ZodString;
|
|
244
|
+
expectedRevisions: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
245
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
246
|
+
type: z.ZodLiteral<"action">;
|
|
247
|
+
requestId: z.ZodString;
|
|
248
|
+
sessionId: z.ZodString;
|
|
249
|
+
name: z.ZodString;
|
|
250
|
+
value: z.ZodOptional<z.ZodUnknown>;
|
|
251
|
+
}, z.core.$strict>], "type">;
|
|
252
|
+
export type NativeServerMessage = z.infer<typeof NativeServerMessageSchema>;
|
|
253
|
+
export interface NativeConnectionOptions {
|
|
254
|
+
port: number;
|
|
255
|
+
token: string;
|
|
256
|
+
scenarioId: string;
|
|
257
|
+
sessionId: string;
|
|
258
|
+
timeoutMs?: number;
|
|
259
|
+
targetId?: string;
|
|
260
|
+
platform?: 'android' | 'ios';
|
|
261
|
+
host?: NativeBindHost;
|
|
262
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SpatialSnapshotSchema } from './graph.js';
|
|
3
|
+
import { SourceRevisionsSchema, BridgeErrorSchema } from './source.js';
|
|
4
|
+
/** Explicit local interface for development pairing; never a wildcard/public listener. */
|
|
5
|
+
export const NativeBindHostSchema = z.ipv4().refine(host => { const [a = 0, b = 0] = host.split('.').map(Number); return a === 127 || a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168); }, 'Use a loopback or private LAN IPv4 interface address');
|
|
6
|
+
export const NativeClientMessageSchema = z.discriminatedUnion('type', [
|
|
7
|
+
z.object({ type: z.literal('hello'), token: z.string(), scenarioId: z.string(), protocolVersion: z.union([z.literal(1), z.literal(2)]), platform: z.enum(['android', 'ios']).optional(), targetId: z.string().optional(), capabilities: z.object({ textFits: z.boolean(), scenarioActions: z.boolean() }).optional() }).strict(),
|
|
8
|
+
z.object({ type: z.literal('action_result'), requestId: z.string() }).strict(),
|
|
9
|
+
z.object({ type: z.literal('snapshot'), requestId: z.string(), snapshot: SpatialSnapshotSchema }).strict(),
|
|
10
|
+
z.object({ type: z.literal('error'), requestId: z.string(), error: BridgeErrorSchema }).strict()
|
|
11
|
+
]).superRefine((message, ctx) => { if (message.type === 'hello' && message.protocolVersion === 2 && (!message.platform || !message.targetId || !message.capabilities))
|
|
12
|
+
ctx.addIssue({ code: 'custom', message: 'Protocol v2 requires platform, targetId and capabilities' }); });
|
|
13
|
+
export const NativeServerMessageSchema = z.discriminatedUnion('type', [z.object({ type: z.literal('capture'), requestId: z.string(), sessionId: z.string(), expectedRevisions: SourceRevisionsSchema }).strict(), z.object({ type: z.literal('action'), requestId: z.string(), sessionId: z.string(), name: z.string(), value: z.unknown().optional() }).strict()]);
|
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const SourceRefSchema: z.ZodObject<{
|
|
3
|
+
path: z.ZodString;
|
|
4
|
+
styleForm: z.ZodOptional<z.ZodLiteral<"pressable-state">>;
|
|
5
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
hash: z.ZodString;
|
|
7
|
+
start: z.ZodNumber;
|
|
8
|
+
end: z.ZodNumber;
|
|
9
|
+
line: z.ZodNumber;
|
|
10
|
+
column: z.ZodNumber;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
export type SourceRef = z.infer<typeof SourceRefSchema>;
|
|
13
|
+
export declare const SourceRevisionsSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
14
|
+
export type SourceRevisions = z.infer<typeof SourceRevisionsSchema>;
|
|
15
|
+
export declare const ErrorCodeSchema: z.ZodEnum<{
|
|
16
|
+
INVALID_INPUT: "INVALID_INPUT";
|
|
17
|
+
MISSING_ELEMENT: "MISSING_ELEMENT";
|
|
18
|
+
DUPLICATE_ELEMENT: "DUPLICATE_ELEMENT";
|
|
19
|
+
STALE_SNAPSHOT: "STALE_SNAPSHOT";
|
|
20
|
+
STALE_SOURCE: "STALE_SOURCE";
|
|
21
|
+
UNSUPPORTED_EDIT: "UNSUPPORTED_EDIT";
|
|
22
|
+
UNSUPPORTED_PROFILE: "UNSUPPORTED_PROFILE";
|
|
23
|
+
UNSTABLE_LAYOUT: "UNSTABLE_LAYOUT";
|
|
24
|
+
NATIVE_DISCONNECTED: "NATIVE_DISCONNECTED";
|
|
25
|
+
TIMEOUT: "TIMEOUT";
|
|
26
|
+
VERIFICATION_FAILED: "VERIFICATION_FAILED";
|
|
27
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
28
|
+
TRIAL_NOT_FOUND: "TRIAL_NOT_FOUND";
|
|
29
|
+
SOURCE_OUTSIDE_PROJECT: "SOURCE_OUTSIDE_PROJECT";
|
|
30
|
+
INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
31
|
+
RECOVERY_CONFLICT: "RECOVERY_CONFLICT";
|
|
32
|
+
TRANSACTION_CONFLICT: "TRANSACTION_CONFLICT";
|
|
33
|
+
UNSUPPORTED_ACTION: "UNSUPPORTED_ACTION";
|
|
34
|
+
PROTOCOL_MISMATCH: "PROTOCOL_MISMATCH";
|
|
35
|
+
}>;
|
|
36
|
+
export type ErrorCode = z.infer<typeof ErrorCodeSchema>;
|
|
37
|
+
export declare const BridgeErrorSchema: z.ZodObject<{
|
|
38
|
+
code: z.ZodEnum<{
|
|
39
|
+
INVALID_INPUT: "INVALID_INPUT";
|
|
40
|
+
MISSING_ELEMENT: "MISSING_ELEMENT";
|
|
41
|
+
DUPLICATE_ELEMENT: "DUPLICATE_ELEMENT";
|
|
42
|
+
STALE_SNAPSHOT: "STALE_SNAPSHOT";
|
|
43
|
+
STALE_SOURCE: "STALE_SOURCE";
|
|
44
|
+
UNSUPPORTED_EDIT: "UNSUPPORTED_EDIT";
|
|
45
|
+
UNSUPPORTED_PROFILE: "UNSUPPORTED_PROFILE";
|
|
46
|
+
UNSTABLE_LAYOUT: "UNSTABLE_LAYOUT";
|
|
47
|
+
NATIVE_DISCONNECTED: "NATIVE_DISCONNECTED";
|
|
48
|
+
TIMEOUT: "TIMEOUT";
|
|
49
|
+
VERIFICATION_FAILED: "VERIFICATION_FAILED";
|
|
50
|
+
SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
51
|
+
TRIAL_NOT_FOUND: "TRIAL_NOT_FOUND";
|
|
52
|
+
SOURCE_OUTSIDE_PROJECT: "SOURCE_OUTSIDE_PROJECT";
|
|
53
|
+
INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
54
|
+
RECOVERY_CONFLICT: "RECOVERY_CONFLICT";
|
|
55
|
+
TRANSACTION_CONFLICT: "TRANSACTION_CONFLICT";
|
|
56
|
+
UNSUPPORTED_ACTION: "UNSUPPORTED_ACTION";
|
|
57
|
+
PROTOCOL_MISMATCH: "PROTOCOL_MISMATCH";
|
|
58
|
+
}>;
|
|
59
|
+
message: z.ZodString;
|
|
60
|
+
details: z.ZodOptional<z.ZodUnknown>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
export type BridgeError = z.infer<typeof BridgeErrorSchema>;
|
|
63
|
+
export type Result<T> = {
|
|
64
|
+
ok: true;
|
|
65
|
+
value: T;
|
|
66
|
+
} | {
|
|
67
|
+
ok: false;
|
|
68
|
+
error: BridgeError;
|
|
69
|
+
};
|
|
70
|
+
export declare class BridgeFault extends Error {
|
|
71
|
+
readonly code: ErrorCode;
|
|
72
|
+
readonly details?: unknown | undefined;
|
|
73
|
+
constructor(code: ErrorCode, message: string, details?: unknown | undefined);
|
|
74
|
+
}
|
|
75
|
+
export interface SourceFile {
|
|
76
|
+
path: string;
|
|
77
|
+
text: string;
|
|
78
|
+
hash: string;
|
|
79
|
+
}
|
|
80
|
+
export declare const EditPlanSchema: z.ZodObject<{
|
|
81
|
+
source: z.ZodObject<{
|
|
82
|
+
path: z.ZodString;
|
|
83
|
+
styleForm: z.ZodOptional<z.ZodLiteral<"pressable-state">>;
|
|
84
|
+
dependencies: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
85
|
+
hash: z.ZodString;
|
|
86
|
+
start: z.ZodNumber;
|
|
87
|
+
end: z.ZodNumber;
|
|
88
|
+
line: z.ZodNumber;
|
|
89
|
+
column: z.ZodNumber;
|
|
90
|
+
}, z.core.$strict>;
|
|
91
|
+
expectedHash: z.ZodString;
|
|
92
|
+
updatedText: z.ZodString;
|
|
93
|
+
diff: z.ZodString;
|
|
94
|
+
}, z.core.$strict>;
|
|
95
|
+
export type EditPlan = z.infer<typeof EditPlanSchema>;
|
|
96
|
+
export declare const CommitReceiptSchema: z.ZodObject<{
|
|
97
|
+
commitId: z.ZodString;
|
|
98
|
+
path: z.ZodString;
|
|
99
|
+
oldHash: z.ZodString;
|
|
100
|
+
newHash: z.ZodString;
|
|
101
|
+
diff: z.ZodString;
|
|
102
|
+
files: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
103
|
+
path: z.ZodString;
|
|
104
|
+
oldHash: z.ZodString;
|
|
105
|
+
newHash: z.ZodString;
|
|
106
|
+
diff: z.ZodString;
|
|
107
|
+
}, z.core.$strict>>>;
|
|
108
|
+
revertsCommitId: z.ZodOptional<z.ZodString>;
|
|
109
|
+
nativeStatus: z.ZodEnum<{
|
|
110
|
+
pending: "pending";
|
|
111
|
+
passed: "passed";
|
|
112
|
+
failed: "failed";
|
|
113
|
+
}>;
|
|
114
|
+
}, z.core.$strict>;
|
|
115
|
+
export type CommitReceipt = z.infer<typeof CommitReceiptSchema>;
|
|
116
|
+
export interface SourcePort {
|
|
117
|
+
read(path: string): Promise<SourceFile>;
|
|
118
|
+
apply(plan: EditPlan): Promise<CommitReceipt>;
|
|
119
|
+
}
|
package/dist/source.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const SourceRefSchema = z.object({ path: z.string().min(1), styleForm: z.literal('pressable-state').optional(), dependencies: z.array(z.string().min(1)).optional(), hash: z.string().regex(/^[a-f0-9]{64}$/), start: z.number().int().nonnegative(), end: z.number().int().positive(), line: z.number().int().positive(), column: z.number().int().nonnegative() }).strict().refine(s => s.end > s.start, 'Invalid source range');
|
|
3
|
+
export const SourceRevisionsSchema = z.record(z.string(), z.string().regex(/^[a-f0-9]{64}$/));
|
|
4
|
+
export const ErrorCodeSchema = z.enum(['INVALID_INPUT', 'MISSING_ELEMENT', 'DUPLICATE_ELEMENT', 'STALE_SNAPSHOT', 'STALE_SOURCE', 'UNSUPPORTED_EDIT', 'UNSUPPORTED_PROFILE', 'UNSTABLE_LAYOUT', 'NATIVE_DISCONNECTED', 'TIMEOUT', 'VERIFICATION_FAILED', 'SESSION_NOT_FOUND', 'TRIAL_NOT_FOUND', 'SOURCE_OUTSIDE_PROJECT', 'INTERNAL_ERROR', 'RECOVERY_CONFLICT', 'TRANSACTION_CONFLICT', 'UNSUPPORTED_ACTION', 'PROTOCOL_MISMATCH']);
|
|
5
|
+
export const BridgeErrorSchema = z.object({ code: ErrorCodeSchema, message: z.string(), details: z.unknown().optional() }).strict();
|
|
6
|
+
export class BridgeFault extends Error {
|
|
7
|
+
code;
|
|
8
|
+
details;
|
|
9
|
+
constructor(code, message, details) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.details = details;
|
|
13
|
+
this.name = 'BridgeFault';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export const EditPlanSchema = z.object({ source: SourceRefSchema, expectedHash: z.string(), updatedText: z.string(), diff: z.string() }).strict();
|
|
17
|
+
export const CommitReceiptSchema = z.object({ commitId: z.string(), path: z.string(), oldHash: z.string(), newHash: z.string(), diff: z.string(), files: z.array(z.object({ path: z.string(), oldHash: z.string(), newHash: z.string(), diff: z.string() }).strict()).optional(), revertsCommitId: z.string().optional(), nativeStatus: z.enum(['pending', 'passed', 'failed']) }).strict();
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RnStylePatchSchema: z.ZodObject<{
|
|
3
|
+
flex: z.ZodOptional<z.ZodNumber>;
|
|
4
|
+
flexWrap: z.ZodOptional<z.ZodEnum<{
|
|
5
|
+
wrap: "wrap";
|
|
6
|
+
nowrap: "nowrap";
|
|
7
|
+
"wrap-reverse": "wrap-reverse";
|
|
8
|
+
}>>;
|
|
9
|
+
alignContent: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
center: "center";
|
|
11
|
+
"flex-start": "flex-start";
|
|
12
|
+
"flex-end": "flex-end";
|
|
13
|
+
stretch: "stretch";
|
|
14
|
+
"space-between": "space-between";
|
|
15
|
+
"space-around": "space-around";
|
|
16
|
+
}>>;
|
|
17
|
+
position: z.ZodOptional<z.ZodEnum<{
|
|
18
|
+
relative: "relative";
|
|
19
|
+
absolute: "absolute";
|
|
20
|
+
static: "static";
|
|
21
|
+
}>>;
|
|
22
|
+
top: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
bottom: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
left: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
right: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
start: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
end: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
aspectRatio: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
paddingStart: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
paddingEnd: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
marginStart: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
marginEnd: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
fontSize: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
lineHeight: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
fontFamily: z.ZodOptional<z.ZodString>;
|
|
36
|
+
fontWeight: z.ZodOptional<z.ZodEnum<{
|
|
37
|
+
normal: "normal";
|
|
38
|
+
bold: "bold";
|
|
39
|
+
100: "100";
|
|
40
|
+
200: "200";
|
|
41
|
+
300: "300";
|
|
42
|
+
400: "400";
|
|
43
|
+
500: "500";
|
|
44
|
+
600: "600";
|
|
45
|
+
700: "700";
|
|
46
|
+
800: "800";
|
|
47
|
+
900: "900";
|
|
48
|
+
}>>;
|
|
49
|
+
flexDirection: z.ZodOptional<z.ZodEnum<{
|
|
50
|
+
column: "column";
|
|
51
|
+
row: "row";
|
|
52
|
+
"row-reverse": "row-reverse";
|
|
53
|
+
"column-reverse": "column-reverse";
|
|
54
|
+
}>>;
|
|
55
|
+
justifyContent: z.ZodOptional<z.ZodEnum<{
|
|
56
|
+
center: "center";
|
|
57
|
+
"flex-start": "flex-start";
|
|
58
|
+
"flex-end": "flex-end";
|
|
59
|
+
"space-between": "space-between";
|
|
60
|
+
"space-around": "space-around";
|
|
61
|
+
"space-evenly": "space-evenly";
|
|
62
|
+
}>>;
|
|
63
|
+
alignItems: z.ZodOptional<z.ZodEnum<{
|
|
64
|
+
center: "center";
|
|
65
|
+
"flex-start": "flex-start";
|
|
66
|
+
"flex-end": "flex-end";
|
|
67
|
+
stretch: "stretch";
|
|
68
|
+
baseline: "baseline";
|
|
69
|
+
}>>;
|
|
70
|
+
alignSelf: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
center: "center";
|
|
72
|
+
"flex-start": "flex-start";
|
|
73
|
+
"flex-end": "flex-end";
|
|
74
|
+
stretch: "stretch";
|
|
75
|
+
baseline: "baseline";
|
|
76
|
+
auto: "auto";
|
|
77
|
+
}>>;
|
|
78
|
+
flexGrow: z.ZodOptional<z.ZodNumber>;
|
|
79
|
+
flexShrink: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
width: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
81
|
+
height: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
|
|
82
|
+
minWidth: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
maxWidth: z.ZodOptional<z.ZodNumber>;
|
|
84
|
+
minHeight: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
maxHeight: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
gap: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
rowGap: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
columnGap: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
padding: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
paddingHorizontal: z.ZodOptional<z.ZodNumber>;
|
|
91
|
+
paddingVertical: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
paddingTop: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
paddingBottom: z.ZodOptional<z.ZodNumber>;
|
|
94
|
+
paddingLeft: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
paddingRight: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
margin: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
marginHorizontal: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
marginVertical: z.ZodOptional<z.ZodNumber>;
|
|
99
|
+
marginTop: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
marginBottom: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
marginLeft: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
marginRight: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
}, z.core.$strict>;
|
|
104
|
+
export type RnStylePatch = z.infer<typeof RnStylePatchSchema>;
|
|
105
|
+
export type NormalizedPatch = Readonly<RnStylePatch>;
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const n = z.number().finite().nonnegative();
|
|
3
|
+
export const RnStylePatchSchema = z.object({ flex: z.number().finite().optional(), flexWrap: z.enum(['wrap', 'nowrap', 'wrap-reverse']).optional(), alignContent: z.enum(['flex-start', 'flex-end', 'center', 'stretch', 'space-between', 'space-around']).optional(), position: z.enum(['relative', 'absolute', 'static']).optional(), top: z.number().finite().optional(), bottom: z.number().finite().optional(), left: z.number().finite().optional(), right: z.number().finite().optional(), start: z.number().finite().optional(), end: z.number().finite().optional(), aspectRatio: z.number().positive().optional(), paddingStart: n.optional(), paddingEnd: n.optional(), marginStart: z.number().finite().optional(), marginEnd: z.number().finite().optional(), fontSize: n.optional(), lineHeight: n.optional(), fontFamily: z.string().min(1).optional(), fontWeight: z.enum(['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900']).optional(), flexDirection: z.enum(['row', 'column', 'row-reverse', 'column-reverse']).optional(), justifyContent: z.enum(['flex-start', 'flex-end', 'center', 'space-between', 'space-around', 'space-evenly']).optional(), alignItems: z.enum(['flex-start', 'flex-end', 'center', 'stretch', 'baseline']).optional(), alignSelf: z.enum(['auto', 'flex-start', 'flex-end', 'center', 'stretch', 'baseline']).optional(), flexGrow: n.optional(), flexShrink: n.optional(), width: z.union([n, z.string().regex(/^\d+(?:\.\d+)?%$/)]).optional(), height: z.union([n, z.string().regex(/^\d+(?:\.\d+)?%$/)]).optional(), minWidth: n.optional(), maxWidth: n.optional(), minHeight: n.optional(), maxHeight: n.optional(), gap: n.optional(), rowGap: n.optional(), columnGap: n.optional(), padding: n.optional(), paddingHorizontal: n.optional(), paddingVertical: n.optional(), paddingTop: n.optional(), paddingBottom: n.optional(), paddingLeft: n.optional(), paddingRight: n.optional(), margin: z.number().finite().optional(), marginHorizontal: z.number().finite().optional(), marginVertical: z.number().finite().optional(), marginTop: z.number().finite().optional(), marginBottom: z.number().finite().optional(), marginLeft: z.number().finite().optional(), marginRight: z.number().finite().optional() }).strict().refine(p => Object.keys(p).length > 0, 'Patch must not be empty');
|