@nativemason/contracts 0.0.0-stage → 0.2.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 +194 -0
- package/dist/accessibility.js +21 -0
- package/dist/constraints.d.ts +804 -0
- package/dist/constraints.js +16 -0
- package/dist/design.d.ts +1652 -0
- package/dist/design.js +29 -0
- package/dist/diagnostics.d.ts +3395 -0
- package/dist/diagnostics.js +35 -0
- package/dist/evidence.d.ts +10431 -0
- package/dist/evidence.js +44 -0
- package/dist/geometry.d.ts +122 -0
- package/dist/geometry.js +4 -0
- package/dist/graph.d.ts +1916 -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 +1726 -0
- package/dist/native-protocol.js +11 -0
- package/dist/source.d.ts +221 -0
- package/dist/source.js +17 -0
- package/dist/styles.d.ts +249 -0
- package/dist/styles.js +3 -0
- package/dist/tools.d.ts +45345 -0
- package/dist/tools.js +53 -0
- package/dist/workflow.d.ts +2391 -0
- package/dist/workflow.js +18 -0
- package/package.json +33 -3
package/dist/evidence.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SpatialSnapshotSchema } from './graph.js';
|
|
3
|
+
import { ConstraintResultSchema } from './constraints.js';
|
|
4
|
+
import { CommitReceiptSchema } from './source.js';
|
|
5
|
+
/** Public CI reports exclude physical-target evidence by construction. */
|
|
6
|
+
export const VisualEvidenceRunSchema = z.object({
|
|
7
|
+
id: z.string().regex(/^[A-Za-z0-9_-]+$/), title: z.string(),
|
|
8
|
+
target: z.enum(['web', 'android-emulator', 'ios-simulator']),
|
|
9
|
+
before: SpatialSnapshotSchema, after: SpatialSnapshotSchema,
|
|
10
|
+
results: z.array(ConstraintResultSchema), receipt: CommitReceiptSchema.optional(),
|
|
11
|
+
nativeStatus: z.enum(['passed', 'failed', 'pending', 'unavailable']), notes: z.array(z.string()),
|
|
12
|
+
}).strict().superRefine((run, ctx) => {
|
|
13
|
+
const platform = run.target === 'android-emulator' ? 'android' : run.target === 'ios-simulator' ? 'ios' : 'web';
|
|
14
|
+
for (const snapshot of [run.before, run.after]) {
|
|
15
|
+
if (snapshot.platform !== platform)
|
|
16
|
+
ctx.addIssue({ code: 'custom', message: 'Evidence target and measured platform disagree' });
|
|
17
|
+
if (snapshot.nativeTarget?.kind === 'physical')
|
|
18
|
+
ctx.addIssue({ code: 'custom', message: 'Physical-target evidence is not public report input' });
|
|
19
|
+
if (platform !== 'web' && snapshot.nativeTarget?.kind !== (platform === 'android' ? 'emulator' : 'simulator'))
|
|
20
|
+
ctx.addIssue({ code: 'custom', message: 'Native CI report requires explicit simulator/emulator identity' });
|
|
21
|
+
}
|
|
22
|
+
if (run.before.scenarioId !== run.after.scenarioId)
|
|
23
|
+
ctx.addIssue({ code: 'custom', message: 'Comparison scenarios must match' });
|
|
24
|
+
if (platform !== 'web' && run.before.nativeTarget?.targetId !== run.after.nativeTarget?.targetId)
|
|
25
|
+
ctx.addIssue({ code: 'custom', message: 'Comparison native targets must match' });
|
|
26
|
+
if (run.nativeStatus === 'passed') {
|
|
27
|
+
if (platform === 'web' || run.after.status !== 'stable' || !run.results.length || run.results.some(result => result.status !== 'pass') || run.receipt?.nativeStatus !== 'passed')
|
|
28
|
+
ctx.addIssue({ code: 'custom', message: 'Native pass requires stable native measurements, passing constraints, and a verified receipt' });
|
|
29
|
+
const measuredIds = new Set(run.after.nodes.map(node => node.id));
|
|
30
|
+
if (run.results.some(result => result.elementIds.some(id => !measuredIds.has(id))))
|
|
31
|
+
ctx.addIssue({ code: 'custom', message: 'Passing constraint evidence references an unmeasured element' });
|
|
32
|
+
for (const file of (run.receipt?.files?.length ? run.receipt.files : (run.receipt ? [run.receipt] : [])))
|
|
33
|
+
if (run.after.revisions[file.path] !== file.newHash)
|
|
34
|
+
ctx.addIssue({ code: 'custom', message: 'Native evidence revisions do not match the verified receipt' });
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
export const VisualEvidenceReportSchema = z.object({
|
|
38
|
+
schemaVersion: z.literal(1), repository: z.string().regex(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/),
|
|
39
|
+
revision: z.string().regex(/^[a-f0-9]{40,64}$/), pullRequest: z.number().int().positive().optional(),
|
|
40
|
+
runs: z.array(VisualEvidenceRunSchema).max(20), notes: z.array(z.string()),
|
|
41
|
+
}).strict();
|
|
42
|
+
export const EvidenceInputsSchema = VisualEvidenceReportSchema.pick({ repository: true, revision: true, pullRequest: true }).extend({
|
|
43
|
+
webFile: z.string().min(1).optional(), androidDirectory: z.string().min(1).optional(), iosDirectory: z.string().min(1).optional(),
|
|
44
|
+
}).strict();
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const RectSchema: z.ZodObject<{
|
|
3
|
+
x: z.ZodNumber;
|
|
4
|
+
y: z.ZodNumber;
|
|
5
|
+
width: z.ZodNumber;
|
|
6
|
+
height: z.ZodNumber;
|
|
7
|
+
}, "strict", z.ZodTypeAny, {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}, {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
}>;
|
|
18
|
+
export type Rect = z.infer<typeof RectSchema>;
|
|
19
|
+
export declare const InsetsSchema: z.ZodObject<{
|
|
20
|
+
top: z.ZodNumber;
|
|
21
|
+
right: z.ZodNumber;
|
|
22
|
+
bottom: z.ZodNumber;
|
|
23
|
+
left: z.ZodNumber;
|
|
24
|
+
}, "strict", z.ZodTypeAny, {
|
|
25
|
+
top: number;
|
|
26
|
+
right: number;
|
|
27
|
+
bottom: number;
|
|
28
|
+
left: number;
|
|
29
|
+
}, {
|
|
30
|
+
top: number;
|
|
31
|
+
right: number;
|
|
32
|
+
bottom: number;
|
|
33
|
+
left: number;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const DeviceProfileSchema: z.ZodObject<{
|
|
36
|
+
window: z.ZodObject<{
|
|
37
|
+
width: z.ZodNumber;
|
|
38
|
+
height: z.ZodNumber;
|
|
39
|
+
}, "strict", z.ZodTypeAny, {
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
}, {
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
}>;
|
|
46
|
+
pixelRatio: z.ZodNumber;
|
|
47
|
+
fontScale: z.ZodNumber;
|
|
48
|
+
insets: z.ZodObject<{
|
|
49
|
+
top: z.ZodNumber;
|
|
50
|
+
right: z.ZodNumber;
|
|
51
|
+
bottom: z.ZodNumber;
|
|
52
|
+
left: z.ZodNumber;
|
|
53
|
+
}, "strict", z.ZodTypeAny, {
|
|
54
|
+
top: number;
|
|
55
|
+
right: number;
|
|
56
|
+
bottom: number;
|
|
57
|
+
left: number;
|
|
58
|
+
}, {
|
|
59
|
+
top: number;
|
|
60
|
+
right: number;
|
|
61
|
+
bottom: number;
|
|
62
|
+
left: number;
|
|
63
|
+
}>;
|
|
64
|
+
root: z.ZodObject<{
|
|
65
|
+
x: z.ZodNumber;
|
|
66
|
+
y: z.ZodNumber;
|
|
67
|
+
width: z.ZodNumber;
|
|
68
|
+
height: z.ZodNumber;
|
|
69
|
+
}, "strict", z.ZodTypeAny, {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
}, {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
width: number;
|
|
78
|
+
height: number;
|
|
79
|
+
}>;
|
|
80
|
+
orientation: z.ZodEnum<["portrait", "landscape"]>;
|
|
81
|
+
}, "strict", z.ZodTypeAny, {
|
|
82
|
+
window: {
|
|
83
|
+
width: number;
|
|
84
|
+
height: number;
|
|
85
|
+
};
|
|
86
|
+
pixelRatio: number;
|
|
87
|
+
fontScale: number;
|
|
88
|
+
insets: {
|
|
89
|
+
top: number;
|
|
90
|
+
right: number;
|
|
91
|
+
bottom: number;
|
|
92
|
+
left: number;
|
|
93
|
+
};
|
|
94
|
+
root: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
orientation: "portrait" | "landscape";
|
|
101
|
+
}, {
|
|
102
|
+
window: {
|
|
103
|
+
width: number;
|
|
104
|
+
height: number;
|
|
105
|
+
};
|
|
106
|
+
pixelRatio: number;
|
|
107
|
+
fontScale: number;
|
|
108
|
+
insets: {
|
|
109
|
+
top: number;
|
|
110
|
+
right: number;
|
|
111
|
+
bottom: number;
|
|
112
|
+
left: number;
|
|
113
|
+
};
|
|
114
|
+
root: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
width: number;
|
|
118
|
+
height: number;
|
|
119
|
+
};
|
|
120
|
+
orientation: "portrait" | "landscape";
|
|
121
|
+
}>;
|
|
122
|
+
export type DeviceProfile = z.infer<typeof DeviceProfileSchema>;
|
package/dist/geometry.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const RectSchema = z.object({ x: z.number().finite(), y: z.number().finite(), width: z.number().finite().nonnegative(), height: z.number().finite().nonnegative() }).strict();
|
|
3
|
+
export const InsetsSchema = z.object({ top: z.number().finite().nonnegative(), right: z.number().finite().nonnegative(), bottom: z.number().finite().nonnegative(), left: z.number().finite().nonnegative() }).strict();
|
|
4
|
+
export const DeviceProfileSchema = z.object({ window: z.object({ width: z.number().finite().positive(), height: z.number().finite().positive() }).strict(), pixelRatio: z.number().finite().positive(), fontScale: z.number().finite().positive(), insets: InsetsSchema, root: RectSchema, orientation: z.enum(['portrait', 'landscape']) }).strict();
|