@native-sdk/cli 0.9.4 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +3 -3
  2. package/build/app.zig +68 -57
  3. package/build.zig +12 -1
  4. package/package.json +10 -9
  5. package/packages/core/package-lock.json +2 -2
  6. package/packages/core/package.json +1 -1
  7. package/packages/core/scripts/run_external_core_compiler.mjs +19 -9
  8. package/packages/core/scripts/run_external_service_compiler.mjs +17 -8
  9. package/packages/core/scripts/vendor_service_packages.mjs +121 -8
  10. package/packages/core/sdk/events.d.ts +33 -4
  11. package/packages/core/sdk/events.ts +45 -6
  12. package/packages/core/src/checker.ts +103 -8
  13. package/packages/core/src/modules.ts +6 -2
  14. package/packages/core/src/sqlite_cli.ts +22 -2
  15. package/packages/core/src/typed_ast.ts +4 -2
  16. package/packages/core/src/types.ts +8 -8
  17. package/schemas/app.schema.json +435 -0
  18. package/skill-data/core/SKILL.md +53 -15
  19. package/skill-data/core/references/project-anatomy.md +6 -6
  20. package/skill-data/native-ui/SKILL.md +26 -5
  21. package/skill-data/ts-core/SKILL.md +6 -6
  22. package/skills/native-sdk/SKILL.md +2 -2
  23. package/src/automation/snapshot.zig +91 -3
  24. package/src/platform/macos/appkit_host.h +41 -2
  25. package/src/platform/macos/appkit_host.m +198 -9
  26. package/src/platform/macos/cef_host.mm +191 -9
  27. package/src/platform/macos/root.zig +110 -3
  28. package/src/platform/null_platform.zig +50 -1
  29. package/src/platform/null_platform_tests.zig +53 -0
  30. package/src/platform/root.zig +9 -0
  31. package/src/platform/types.zig +58 -0
  32. package/src/platform/windows/root.zig +88 -15
  33. package/src/primitives/canvas/reference.zig +37 -15
  34. package/src/primitives/canvas/reference_tests.zig +63 -0
  35. package/src/primitives/canvas/ui.zig +9 -0
  36. package/src/primitives/canvas/ui_markup.zig +29 -0
  37. package/src/primitives/canvas/ui_markup_compiled.zig +32 -0
  38. package/src/primitives/canvas/ui_markup_compiled_tests.zig +4 -2
  39. package/src/primitives/canvas/ui_markup_contract.zig +7 -0
  40. package/src/primitives/canvas/ui_markup_contract_tests.zig +21 -0
  41. package/src/primitives/canvas/ui_markup_tests.zig +6 -0
  42. package/src/primitives/canvas/ui_markup_view.zig +28 -0
  43. package/src/primitives/canvas/ui_markup_view_tests.zig +32 -3
  44. package/src/primitives/canvas/ui_schema.zig +9 -0
  45. package/src/primitives/canvas/ui_schema_tests.zig +5 -3
  46. package/src/primitives/canvas/ui_tests.zig +4 -2
  47. package/src/primitives/canvas/widget_render.zig +7 -2
  48. package/src/primitives/canvas/widget_semantics_tests.zig +3 -1
  49. package/src/root.zig +4 -0
  50. package/src/runtime/automation_snapshot.zig +3 -0
  51. package/src/runtime/flow.zig +1 -1
  52. package/src/runtime/state.zig +14 -0
  53. package/src/runtime/system_services.zig +62 -0
  54. package/src/runtime/ts_ui_app.zig +161 -33
  55. package/src/runtime/ui_app.zig +33 -1
  56. package/src/runtime/ui_app_tests.zig +63 -0
  57. package/src/runtime/validation.zig +87 -1
  58. package/src/tooling/android.zig +5 -4
  59. package/src/tooling/buildgraph.zig +24 -8
  60. package/src/tooling/db.zig +1 -1
  61. package/src/tooling/doctor.zig +1 -1
  62. package/src/tooling/ios.zig +5 -4
  63. package/src/tooling/json_to_zon.zig +136 -0
  64. package/src/tooling/manifest.zig +120 -33
  65. package/src/tooling/raw_manifest.zig +4 -0
  66. package/src/tooling/root.zig +1 -0
  67. package/src/tooling/templates.zig +165 -116
  68. package/src/tooling/ts_core.zig +11 -7
  69. package/src/tooling/verbs.zig +7 -6
  70. package/src/tooling/web_engine.zig +17 -1
@@ -7,7 +7,8 @@ export type ThemeState = {
7
7
  readonly accent?: string;
8
8
  };
9
9
  export type StatusItemTone = "normal" | "warning" | "critical";
10
- export type StatusItemMenuRole = "command" | "info" | "header" | "hero" | "agent" | "context";
10
+ export type StatusItemFontWeight = "regular" | "medium" | "semibold" | "bold";
11
+ export type StatusItemMenuRole = "command" | "info" | "header" | "hero" | "agent" | "context" | "segmented" | "chart";
11
12
  export interface StatusItemModifiers {
12
13
  readonly primary: boolean;
13
14
  readonly command: boolean;
@@ -15,14 +16,39 @@ export interface StatusItemModifiers {
15
16
  readonly option: boolean;
16
17
  readonly shift: boolean;
17
18
  }
18
- export interface StatusItemPresentation {
19
+ export type StatusItemPresentation = {
19
20
  readonly title: Uint8Array;
20
21
  readonly width: number;
21
22
  readonly tone: StatusItemTone;
22
23
  readonly iconOpacity: number;
23
24
  readonly monospaced: boolean;
25
+ readonly fontSize?: number;
26
+ readonly fontWeight?: StatusItemFontWeight;
27
+ };
28
+ export interface StatusItemSegmentOption {
29
+ readonly id: number;
30
+ readonly label: Uint8Array;
31
+ readonly command: Uint8Array;
32
+ readonly selected: boolean;
33
+ readonly enabled: boolean;
24
34
  }
25
- export interface StatusItemMenuItem {
35
+ export interface StatusItemSegmentedRow {
36
+ readonly options: readonly StatusItemSegmentOption[];
37
+ }
38
+ export interface StatusItemMetricRow {
39
+ readonly primaryText: Uint8Array;
40
+ readonly secondaryText: Uint8Array;
41
+ readonly accessibilityLabel: Uint8Array;
42
+ }
43
+ export interface StatusItemChartRow {
44
+ readonly values: readonly number[];
45
+ readonly minValue: number;
46
+ readonly maxValue: number;
47
+ readonly leadingCaption: Uint8Array;
48
+ readonly trailingSummary: Uint8Array;
49
+ readonly accessibilityLabel: Uint8Array;
50
+ }
51
+ export type StatusItemMenuItem = {
26
52
  readonly id: number;
27
53
  readonly label: Uint8Array;
28
54
  readonly command: Uint8Array;
@@ -32,7 +58,10 @@ export interface StatusItemMenuItem {
32
58
  readonly role: StatusItemMenuRole;
33
59
  readonly key: Uint8Array;
34
60
  readonly modifiers: StatusItemModifiers;
35
- }
61
+ readonly segmented?: StatusItemSegmentedRow;
62
+ readonly metric?: StatusItemMetricRow;
63
+ readonly chart?: StatusItemChartRow;
64
+ };
36
65
  export interface StatusItemState {
37
66
  readonly iconPath: Uint8Array;
38
67
  readonly tooltip: Uint8Array;
@@ -63,12 +63,14 @@ export type ThemeState = {
63
63
  /// One row in a menu-bar status item's menu. Non-separator rows need a
64
64
  /// unique non-zero `id`, a non-empty `label`, and (when actionable) a
65
65
  /// command name accepted by `commandMsg`. Rich readout roles may carry
66
- /// secondary `detail`; command rows may carry a key equivalent. Spell
67
- /// every field explicitly because app-core records have one exact shape.
66
+ /// secondary `detail`; command rows may carry a key equivalent. Core row
67
+ /// records have one exact shape; only the documented rich payloads and
68
+ /// presentation typography may be omitted.
68
69
  /// A status item may expose at most 32 rows.
69
70
  export type StatusItemTone = "normal" | "warning" | "critical";
71
+ export type StatusItemFontWeight = "regular" | "medium" | "semibold" | "bold";
70
72
 
71
- export type StatusItemMenuRole = "command" | "info" | "header" | "hero" | "agent" | "context";
73
+ export type StatusItemMenuRole = "command" | "info" | "header" | "hero" | "agent" | "context" | "segmented" | "chart";
72
74
 
73
75
  export interface StatusItemModifiers {
74
76
  readonly primary: boolean;
@@ -78,15 +80,46 @@ export interface StatusItemModifiers {
78
80
  readonly shift: boolean;
79
81
  }
80
82
 
81
- export interface StatusItemPresentation {
83
+ export type StatusItemPresentation = {
82
84
  readonly title: Uint8Array;
83
85
  readonly width: number;
84
86
  readonly tone: StatusItemTone;
85
87
  readonly iconOpacity: number;
86
88
  readonly monospaced: boolean;
89
+ /// Omit to keep the platform menu-bar default size.
90
+ readonly fontSize?: number;
91
+ /// Omit to keep regular weight.
92
+ readonly fontWeight?: StatusItemFontWeight;
93
+ };
94
+
95
+ export interface StatusItemSegmentOption {
96
+ readonly id: number;
97
+ readonly label: Uint8Array;
98
+ readonly command: Uint8Array;
99
+ readonly selected: boolean;
100
+ readonly enabled: boolean;
101
+ }
102
+
103
+ export interface StatusItemSegmentedRow {
104
+ readonly options: readonly StatusItemSegmentOption[];
105
+ }
106
+
107
+ export interface StatusItemMetricRow {
108
+ readonly primaryText: Uint8Array;
109
+ readonly secondaryText: Uint8Array;
110
+ readonly accessibilityLabel: Uint8Array;
87
111
  }
88
112
 
89
- export interface StatusItemMenuItem {
113
+ export interface StatusItemChartRow {
114
+ readonly values: readonly number[];
115
+ readonly minValue: number;
116
+ readonly maxValue: number;
117
+ readonly leadingCaption: Uint8Array;
118
+ readonly trailingSummary: Uint8Array;
119
+ readonly accessibilityLabel: Uint8Array;
120
+ }
121
+
122
+ export type StatusItemMenuItem = {
90
123
  readonly id: number;
91
124
  readonly label: Uint8Array;
92
125
  readonly command: Uint8Array;
@@ -96,7 +129,13 @@ export interface StatusItemMenuItem {
96
129
  readonly role: StatusItemMenuRole;
97
130
  readonly key: Uint8Array;
98
131
  readonly modifiers: StatusItemModifiers;
99
- }
132
+ /// Present exactly when `role` is `segmented`.
133
+ readonly segmented?: StatusItemSegmentedRow;
134
+ /// Present on a `hero` row to declare a typed dropdown metric block.
135
+ readonly metric?: StatusItemMetricRow;
136
+ /// Present exactly when `role` is `chart`.
137
+ readonly chart?: StatusItemChartRow;
138
+ };
100
139
 
101
140
  /// The generated launcher's model-derived menu-bar status item. Export
102
141
  /// `statusItem(model: Model): StatusItemState` from `src/core.ts`; its
@@ -992,6 +992,8 @@ export class SubsetChecker {
992
992
  const tone = presentation?.fields.find((field) => field.tsName === "tone");
993
993
  const iconOpacity = presentation?.fields.find((field) => field.tsName === "iconOpacity");
994
994
  const monospaced = presentation?.fields.find((field) => field.tsName === "monospaced");
995
+ const fontSize = presentation?.fields.find((field) => field.tsName === "fontSize");
996
+ const fontWeight = presentation?.fields.find((field) => field.tsName === "fontWeight");
995
997
  const itemType = items?.type.k === "slice" && items.type.elem.k === "struct" ? items.type.elem : null;
996
998
  const item = itemType === null ? undefined : this.table.structs.get(itemType.name);
997
999
  const itemNames = item?.fields.map((field) => field.tsName).sort() ?? [];
@@ -1004,9 +1006,27 @@ export class SubsetChecker {
1004
1006
  const role = item?.fields.find((field) => field.tsName === "role");
1005
1007
  const key = item?.fields.find((field) => field.tsName === "key");
1006
1008
  const modifiersField = item?.fields.find((field) => field.tsName === "modifiers");
1009
+ const segmentedField = item?.fields.find((field) => field.tsName === "segmented");
1010
+ const metricField = item?.fields.find((field) => field.tsName === "metric");
1011
+ const chartField = item?.fields.find((field) => field.tsName === "chart");
1007
1012
  const modifiersType = modifiersField?.type.k === "struct" ? modifiersField.type : null;
1008
1013
  const modifiers = modifiersType === null ? undefined : this.table.structs.get(modifiersType.name);
1009
1014
  const modifierNames = modifiers?.fields.map((field) => field.tsName).sort() ?? [];
1015
+ const optionalStruct = (field: typeof segmentedField) =>
1016
+ field?.type.k === "optional" && field.type.inner.k === "struct" ? this.table.structs.get(field.type.inner.name) : undefined;
1017
+ const segmented = optionalStruct(segmentedField);
1018
+ const segmentedNames = segmented?.fields.map((field) => field.tsName).sort() ?? [];
1019
+ const segmentOptions = segmented?.fields.find((field) => field.tsName === "options");
1020
+ const segmentOptionType = segmentOptions?.type.k === "slice" && segmentOptions.type.elem.k === "struct" ? segmentOptions.type.elem : null;
1021
+ const segmentOption = segmentOptionType === null ? undefined : this.table.structs.get(segmentOptionType.name);
1022
+ const segmentOptionNames = segmentOption?.fields.map((field) => field.tsName).sort() ?? [];
1023
+ const segmentOptionField = (name: string) => segmentOption?.fields.find((field) => field.tsName === name);
1024
+ const chart = optionalStruct(chartField);
1025
+ const chartNames = chart?.fields.map((field) => field.tsName).sort() ?? [];
1026
+ const chartFieldNamed = (name: string) => chart?.fields.find((field) => field.tsName === name);
1027
+ const metric = optionalStruct(metricField);
1028
+ const metricNames = metric?.fields.map((field) => field.tsName).sort() ?? [];
1029
+ const metricFieldNamed = (name: string) => metric?.fields.find((field) => field.tsName === name);
1010
1030
  const allByteFields = [iconPath, tooltip, activationCommand, alternateActivationCommand, openCommand].every(
1011
1031
  (field) => field?.type.k === "bytes",
1012
1032
  );
@@ -1019,27 +1039,54 @@ export class SubsetChecker {
1019
1039
  const numericId = id !== undefined && ["number", "i64", "f64", "numAlias"].includes(id.type.k);
1020
1040
  const numericWidth = width !== undefined && ["number", "i64", "f64", "numAlias"].includes(width.type.k);
1021
1041
  const numericOpacity = iconOpacity !== undefined && ["number", "i64", "f64", "numAlias"].includes(iconOpacity.type.k);
1042
+ const optionalNumeric = (field: typeof fontSize): boolean =>
1043
+ field?.type.k === "optional" && ["number", "i64", "f64", "numAlias"].includes(field.type.inner.k);
1044
+ const optionalEnumMembersAre = (field: typeof fontWeight, expected: readonly string[]): boolean => {
1045
+ if (field?.type.k !== "optional" || field.type.inner.k !== "enum") return false;
1046
+ const found = this.table.enums.get(field.type.inner.name)?.members.slice().sort() ?? [];
1047
+ return found.join(",") === expected.slice().sort().join(",");
1048
+ };
1022
1049
  const valid =
1023
1050
  stateNames.join(",") === "activationCommand,alternateActivationCommand,iconPath,items,openCommand,presentation,tooltip" &&
1024
1051
  allByteFields &&
1025
- presentationNames.join(",") === "iconOpacity,monospaced,title,tone,width" &&
1052
+ presentationNames.join(",") === "fontSize,fontWeight,iconOpacity,monospaced,title,tone,width" &&
1026
1053
  title?.type.k === "bytes" &&
1027
1054
  numericWidth &&
1028
1055
  enumMembersAre(tone, ["normal", "warning", "critical"]) &&
1029
1056
  numericOpacity &&
1030
1057
  monospaced?.type.k === "bool" &&
1058
+ optionalNumeric(fontSize) &&
1059
+ optionalEnumMembersAre(fontWeight, ["regular", "medium", "semibold", "bold"]) &&
1031
1060
  item !== undefined &&
1032
- itemNames.join(",") === "command,detail,enabled,id,key,label,modifiers,role,separator" &&
1061
+ itemNames.join(",") === "chart,command,detail,enabled,id,key,label,metric,modifiers,role,segmented,separator" &&
1033
1062
  numericId &&
1034
1063
  label?.type.k === "bytes" &&
1035
1064
  command?.type.k === "bytes" &&
1036
1065
  separator?.type.k === "bool" &&
1037
1066
  enabled?.type.k === "bool" &&
1038
1067
  detail?.type.k === "bytes" &&
1039
- enumMembersAre(role, ["command", "info", "header", "hero", "agent", "context"]) &&
1068
+ enumMembersAre(role, ["command", "info", "header", "hero", "agent", "context", "segmented", "chart"]) &&
1040
1069
  key?.type.k === "bytes" &&
1041
1070
  modifierNames.join(",") === "command,control,option,primary,shift" &&
1042
- boolModifierFields;
1071
+ boolModifierFields &&
1072
+ segmentedNames.join(",") === "options" &&
1073
+ segmentOptionNames.join(",") === "command,enabled,id,label,selected" &&
1074
+ segmentOptionField("id") !== undefined && ["number", "i64", "f64", "numAlias"].includes(segmentOptionField("id")!.type.k) &&
1075
+ segmentOptionField("label")?.type.k === "bytes" &&
1076
+ segmentOptionField("command")?.type.k === "bytes" &&
1077
+ segmentOptionField("selected")?.type.k === "bool" &&
1078
+ segmentOptionField("enabled")?.type.k === "bool" &&
1079
+ metricNames.join(",") === "accessibilityLabel,primaryText,secondaryText" &&
1080
+ metricFieldNamed("primaryText")?.type.k === "bytes" &&
1081
+ metricFieldNamed("secondaryText")?.type.k === "bytes" &&
1082
+ metricFieldNamed("accessibilityLabel")?.type.k === "bytes" &&
1083
+ chartNames.join(",") === "accessibilityLabel,leadingCaption,maxValue,minValue,trailingSummary,values" &&
1084
+ chartFieldNamed("values")?.type.k === "slice" && chartFieldNamed("values")?.type.elem.k === "number" &&
1085
+ chartFieldNamed("minValue") !== undefined && ["number", "i64", "f64", "numAlias"].includes(chartFieldNamed("minValue")!.type.k) &&
1086
+ chartFieldNamed("maxValue") !== undefined && ["number", "i64", "f64", "numAlias"].includes(chartFieldNamed("maxValue")!.type.k) &&
1087
+ chartFieldNamed("leadingCaption")?.type.k === "bytes" &&
1088
+ chartFieldNamed("trailingSummary")?.type.k === "bytes" &&
1089
+ chartFieldNamed("accessibilityLabel")?.type.k === "bytes";
1043
1090
  if (!valid) {
1044
1091
  this.report(
1045
1092
  "NS1033",
@@ -1352,6 +1399,8 @@ export class SubsetChecker {
1352
1399
  const tone = presentationFieldNamed("tone");
1353
1400
  const iconOpacity = presentationFieldNamed("iconOpacity");
1354
1401
  const monospaced = presentationFieldNamed("monospaced");
1402
+ const fontSize = presentationFieldNamed("fontSize");
1403
+ const fontWeight = presentationFieldNamed("fontWeight");
1355
1404
  const items = field("items");
1356
1405
  const itemType = items?.type.k === "slice" && items.type.elem.k === "struct" ? items.type.elem : null;
1357
1406
  const item = itemType === null ? undefined : this.table.structs.get(itemType.name);
@@ -1366,41 +1415,87 @@ export class SubsetChecker {
1366
1415
  const role = itemField("role");
1367
1416
  const key = itemField("key");
1368
1417
  const modifiersField = itemField("modifiers");
1418
+ const segmentedField = itemField("segmented");
1419
+ const metricField = itemField("metric");
1420
+ const chartField = itemField("chart");
1369
1421
  const modifiersType = modifiersField?.type.k === "struct" ? modifiersField.type : null;
1370
1422
  const modifiers = modifiersType === null ? undefined : this.table.structs.get(modifiersType.name);
1371
1423
  const modifierNames = modifiers?.fields.map((candidate) => candidate.tsName).sort() ?? [];
1424
+ const optionalStruct = (candidate: typeof segmentedField) =>
1425
+ candidate?.type.k === "optional" && candidate.type.inner.k === "struct" ? this.table.structs.get(candidate.type.inner.name) : undefined;
1426
+ const segmented = optionalStruct(segmentedField);
1427
+ const segmentedNames = segmented?.fields.map((candidate) => candidate.tsName).sort() ?? [];
1428
+ const segmentOptions = segmented?.fields.find((candidate) => candidate.tsName === "options");
1429
+ const segmentOptionType = segmentOptions?.type.k === "slice" && segmentOptions.type.elem.k === "struct" ? segmentOptions.type.elem : null;
1430
+ const segmentOption = segmentOptionType === null ? undefined : this.table.structs.get(segmentOptionType.name);
1431
+ const segmentOptionNames = segmentOption?.fields.map((candidate) => candidate.tsName).sort() ?? [];
1432
+ const segmentOptionField = (name: string) => segmentOption?.fields.find((candidate) => candidate.tsName === name);
1433
+ const chart = optionalStruct(chartField);
1434
+ const chartNames = chart?.fields.map((candidate) => candidate.tsName).sort() ?? [];
1435
+ const chartFieldNamed = (name: string) => chart?.fields.find((candidate) => candidate.tsName === name);
1436
+ const chartValues = chartFieldNamed("values");
1437
+ const metric = optionalStruct(metricField);
1438
+ const metricNames = metric?.fields.map((candidate) => candidate.tsName).sort() ?? [];
1439
+ const metricFieldNamed = (name: string) => metric?.fields.find((candidate) => candidate.tsName === name);
1372
1440
  const numericId = id !== undefined && ["number", "i64", "f64", "numAlias"].includes(id.type.k);
1373
1441
  const numericItemId = itemId !== undefined && ["number", "i64", "f64", "numAlias"].includes(itemId.type.k);
1374
1442
  const numericWidth = width !== undefined && ["number", "i64", "f64", "numAlias"].includes(width.type.k);
1375
1443
  const numericOpacity = iconOpacity !== undefined && ["number", "i64", "f64", "numAlias"].includes(iconOpacity.type.k);
1444
+ const optionalNumeric = (candidate: typeof fontSize): boolean =>
1445
+ candidate?.type.k === "optional" && ["number", "i64", "f64", "numAlias"].includes(candidate.type.inner.k);
1376
1446
  const enumMembersAre = (candidate: typeof tone, expected: readonly string[]): boolean => {
1377
1447
  if (candidate?.type.k !== "enum") return false;
1378
1448
  const found = this.table.enums.get(candidate.type.name)?.members.slice().sort() ?? [];
1379
1449
  return found.join(",") === expected.slice().sort().join(",");
1380
1450
  };
1451
+ const optionalEnumMembersAre = (candidate: typeof fontWeight, expected: readonly string[]): boolean => {
1452
+ if (candidate?.type.k !== "optional" || candidate.type.inner.k !== "enum") return false;
1453
+ const found = this.table.enums.get(candidate.type.inner.name)?.members.slice().sort() ?? [];
1454
+ return found.join(",") === expected.slice().sort().join(",");
1455
+ };
1381
1456
  const boolModifierFields = modifiers !== undefined && modifiers.fields.every((candidate) => candidate.type.k === "bool");
1382
1457
  const valid =
1383
1458
  names.join(",") === "activationCommand,alternateActivationCommand,iconPath,id,items,openCommand,presentation,tooltip,visible" &&
1384
1459
  numericId &&
1385
1460
  visible?.type.k === "bool" &&
1386
1461
  byteFields.every((candidate) => candidate?.type.k === "bytes") &&
1387
- presentationNames.join(",") === "iconOpacity,monospaced,title,tone,width" &&
1462
+ presentationNames.join(",") === "fontSize,fontWeight,iconOpacity,monospaced,title,tone,width" &&
1388
1463
  title?.type.k === "bytes" &&
1389
1464
  numericWidth &&
1390
1465
  enumMembersAre(tone, ["normal", "warning", "critical"]) &&
1391
1466
  numericOpacity &&
1392
1467
  monospaced?.type.k === "bool" &&
1393
- itemNames.join(",") === "command,detail,enabled,id,key,label,modifiers,role,separator" &&
1468
+ optionalNumeric(fontSize) &&
1469
+ optionalEnumMembersAre(fontWeight, ["regular", "medium", "semibold", "bold"]) &&
1470
+ itemNames.join(",") === "chart,command,detail,enabled,id,key,label,metric,modifiers,role,segmented,separator" &&
1394
1471
  numericItemId &&
1395
1472
  label?.type.k === "bytes" &&
1396
1473
  command?.type.k === "bytes" &&
1397
1474
  separator?.type.k === "bool" &&
1398
1475
  enabled?.type.k === "bool" &&
1399
1476
  detail?.type.k === "bytes" &&
1400
- enumMembersAre(role, ["command", "info", "header", "hero", "agent", "context"]) &&
1477
+ enumMembersAre(role, ["command", "info", "header", "hero", "agent", "context", "segmented", "chart"]) &&
1401
1478
  key?.type.k === "bytes" &&
1402
1479
  modifierNames.join(",") === "command,control,option,primary,shift" &&
1403
- boolModifierFields;
1480
+ boolModifierFields &&
1481
+ segmentedNames.join(",") === "options" &&
1482
+ segmentOptionNames.join(",") === "command,enabled,id,label,selected" &&
1483
+ segmentOptionField("id") !== undefined && ["number", "i64", "f64", "numAlias"].includes(segmentOptionField("id")!.type.k) &&
1484
+ segmentOptionField("label")?.type.k === "bytes" &&
1485
+ segmentOptionField("command")?.type.k === "bytes" &&
1486
+ segmentOptionField("selected")?.type.k === "bool" &&
1487
+ segmentOptionField("enabled")?.type.k === "bool" &&
1488
+ metricNames.join(",") === "accessibilityLabel,primaryText,secondaryText" &&
1489
+ metricFieldNamed("primaryText")?.type.k === "bytes" &&
1490
+ metricFieldNamed("secondaryText")?.type.k === "bytes" &&
1491
+ metricFieldNamed("accessibilityLabel")?.type.k === "bytes" &&
1492
+ chartNames.join(",") === "accessibilityLabel,leadingCaption,maxValue,minValue,trailingSummary,values" &&
1493
+ chartValues?.type.k === "slice" && chartValues.type.elem.k === "number" &&
1494
+ chartFieldNamed("minValue") !== undefined && ["number", "i64", "f64", "numAlias"].includes(chartFieldNamed("minValue")!.type.k) &&
1495
+ chartFieldNamed("maxValue") !== undefined && ["number", "i64", "f64", "numAlias"].includes(chartFieldNamed("maxValue")!.type.k) &&
1496
+ chartFieldNamed("leadingCaption")?.type.k === "bytes" &&
1497
+ chartFieldNamed("trailingSummary")?.type.k === "bytes" &&
1498
+ chartFieldNamed("accessibilityLabel")?.type.k === "bytes";
1404
1499
  if (!valid) {
1405
1500
  this.report(
1406
1501
  "NS1033",
@@ -83,7 +83,6 @@ export function resolveModuleGraph(
83
83
  const entryPath = path.resolve(entry);
84
84
  const boundary = path.dirname(entryPath);
85
85
  const servicesBoundary = path.join(boundary, "services");
86
- const sdkBoundary = path.dirname(coreModulePath);
87
86
  const diagnostics: SubsetDiagnostic[] = [];
88
87
  const files: string[] = [];
89
88
  const coreFiles: string[] = [];
@@ -133,7 +132,12 @@ export function resolveModuleGraph(
133
132
  const text = fs.readFileSync(filePath, "utf8");
134
133
  const parsed = ts.createSourceFile(filePath, text, ts.ScriptTarget.ESNext, true);
135
134
  const isSdk = sdkFiles.has(filePath);
136
- const root = isSdk ? sdkBoundary : boundary;
135
+ // A generated relational core may live under .native/cache while the
136
+ // published library modules still resolve from the SDK package. Fence a
137
+ // library module against its own module directory, not the generated
138
+ // intrinsic core's directory; otherwise events.ts's valid ./text.ts
139
+ // re-export is falsely diagnosed as escaping the SDK.
140
+ const root = isSdk ? path.dirname(filePath) : boundary;
137
141
 
138
142
  for (const edge of edgesOf(parsed)) {
139
143
  const spec = edge.specifier;
@@ -21,15 +21,25 @@ try {
21
21
  const sdkIn = args.get("sdk-in");
22
22
  const staticIn = args.get("static-in");
23
23
  const sdkOut = args.get("sdk-out");
24
+ const sdkEventsOut = args.get("sdk-events-out");
25
+ const sdkTextOut = args.get("sdk-text-out");
26
+ const sdkBytesTextMethodsOut = args.get("sdk-bytes-text-methods-out");
27
+ const sdkEventsDtsOut = args.get("sdk-events-dts-out");
28
+ const sdkTextDtsOut = args.get("sdk-text-dts-out");
24
29
  const staticOut = args.get("static-out");
25
30
  const zigOut = args.get("zig-out");
26
31
  const metadataOut = args.get("metadata-out");
27
32
  const dtsOut = args.get("dts-out");
28
33
  const state = args.get("state");
29
34
  if (!zigOut) throw new Error("usage: sqlite_cli.ts --src <src> --zig-out <file> [--sdk-in <core.ts> --static-in <core.ts> --sdk-out <file> --static-out <file> --metadata-out <file>] [--state <file>]");
30
- const surfaceArgs = [sdkIn, staticIn, sdkOut, staticOut];
35
+ const surfaceArgs = [
36
+ sdkIn, staticIn, sdkOut, staticOut,
37
+ sdkEventsOut, sdkTextOut, sdkBytesTextMethodsOut, sdkEventsDtsOut, sdkTextDtsOut,
38
+ ];
31
39
  const emitsSurface = surfaceArgs.every((value) => value !== undefined);
32
- if (!emitsSurface && surfaceArgs.some((value) => value !== undefined)) throw new Error("SQLite SDK generation requires --sdk-in, --static-in, --sdk-out, and --static-out together");
40
+ if (!emitsSurface && surfaceArgs.some((value) => value !== undefined)) {
41
+ throw new Error("SQLite SDK generation requires its core, static, and SDK sibling outputs together");
42
+ }
33
43
  const analysis = analyzeSqlite(src);
34
44
  const diagnostics = [...analysis.diagnostics, ...(state ? checkMigrationState(analysis, state) : [])];
35
45
  for (const diagnostic of [...diagnostics, ...analysis.warnings]) console.error(formatSqliteDiagnostic(diagnostic));
@@ -37,6 +47,16 @@ try {
37
47
  if (emitsSurface) {
38
48
  const sdkSource = generateCoreSurface(fs.readFileSync(sdkIn!, "utf8"), analysis);
39
49
  fs.writeFileSync(sdkOut!, sdkSource);
50
+ const sdkDir = path.dirname(sdkIn!);
51
+ for (const [source, destination] of [
52
+ ["events.ts", sdkEventsOut!],
53
+ ["text.ts", sdkTextOut!],
54
+ ["bytes_text_methods.d.ts", sdkBytesTextMethodsOut!],
55
+ ["events.d.ts", sdkEventsDtsOut!],
56
+ ["text.d.ts", sdkTextDtsOut!],
57
+ ] as const) {
58
+ fs.copyFileSync(path.join(sdkDir, source), destination);
59
+ }
40
60
  if (dtsOut) {
41
61
  const compilerOptions: ts.CompilerOptions = {
42
62
  strict: true,
@@ -343,8 +343,10 @@ export class TypedAst {
343
343
  /// identifier-named, annotated property signature), so
344
344
  /// a shape this walk cannot carry whole refuses as an unsupported
345
345
  /// alias instead of registering a struct with silently missing fields.
346
- /// The one omission-carrying value record is the SDK-owned ThemeState;
347
- /// its caller opts in explicitly so authored/service records keep the
346
+ /// A tiny closed set of SDK-owned shell records carries omission
347
+ /// intentionally (ThemeState inheritance, optional tray typography, and
348
+ /// optional rich tray payloads);
349
+ /// their caller opts in explicitly so authored/service records keep the
348
350
  /// fixed-shape rule.
349
351
  propsOfTypeLiteral(node: tsImpl.TypeLiteralNode, allowOptional = false): PropInfo[] | null {
350
352
  const out: PropInfo[] = [];
@@ -266,7 +266,7 @@ export class TypeTable {
266
266
  this.declOrder.push(name);
267
267
  continue;
268
268
  }
269
- const projectOptional = this.isCanonicalThemeState(stmt);
269
+ const projectOptional = this.isCanonicalOptionalSdkRecord(stmt);
270
270
  if (ts.isTypeLiteralNode(stmt.type) && this.tast.propsOfTypeLiteral(stmt.type, projectOptional) !== null) {
271
271
  // A plain-record object-literal alias is a struct exactly like
272
272
  // an interface; the alias FORM is how a contract projection
@@ -275,8 +275,8 @@ export class TypeTable {
275
275
  // promotion walk. Shapes the plain-record walk cannot carry
276
276
  // whole (quoted or optional properties) stay unclassified and
277
277
  // refuse at emission instead of losing fields silently. The
278
- // canonical SDK ThemeState is the sole optional-property record:
279
- // omission is its manifest/system inheritance signal.
278
+ // A tiny closed set of SDK shell records may carry optional
279
+ // properties; authored records still spell absence as `| null`.
280
280
  this.structs.set(name, {
281
281
  name,
282
282
  decl: stmt,
@@ -323,7 +323,7 @@ export class TypeTable {
323
323
  }
324
324
  const structInfo = this.structs.get(stmt.name.text);
325
325
  if (structInfo && structInfo.decl === stmt && ts.isTypeLiteralNode(stmt.type)) {
326
- const projectOptional = this.isCanonicalThemeState(stmt);
326
+ const projectOptional = this.isCanonicalOptionalSdkRecord(stmt);
327
327
  const props = this.tast.propsOfTypeLiteral(stmt.type, projectOptional);
328
328
  if (props) structInfo.fields = props.map((p) => this.fieldOf(p, projectOptional));
329
329
  }
@@ -331,9 +331,9 @@ export class TypeTable {
331
331
  }
332
332
  }
333
333
 
334
- private isCanonicalThemeState(decl: ts.TypeAliasDeclaration): boolean {
334
+ private isCanonicalOptionalSdkRecord(decl: ts.TypeAliasDeclaration): boolean {
335
335
  const events = sdkLibraryModules.get("@native-sdk/core/events");
336
- return decl.name.text === "ThemeState" && events !== undefined &&
336
+ return (decl.name.text === "ThemeState" || decl.name.text === "StatusItemPresentation" || decl.name.text === "StatusItemMenuItem") && events !== undefined &&
337
337
  path.resolve(decl.getSourceFile().fileName) === path.resolve(events);
338
338
  }
339
339
 
@@ -342,8 +342,8 @@ export class TypeTable {
342
342
  return {
343
343
  tsName: p.name,
344
344
  zigName: zigDeclName(p.name),
345
- // Only the canonical ThemeState projects JS `undefined` omission onto
346
- // the contract's ordinary optional slot. Applying this globally would
345
+ // Only canonical SDK shell records project JS `undefined` omission
346
+ // onto the contract's ordinary optional slot. Applying this globally would
347
347
  // let service records acquire an absent state while their generated
348
348
  // codecs still accept only explicit null.
349
349
  type: projectOptional && p.optional && resolved.k !== "void" && resolved.k !== "optional"