@typecad/cuttlefish 1.0.0-alpha.11 → 1.0.0-alpha.13

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 (65) hide show
  1. package/dist/add-preset.d.ts +4 -0
  2. package/dist/add-preset.js +74 -0
  3. package/dist/api/config.d.ts +5 -5
  4. package/dist/api/shared/display-adapters/sdl.js +1 -1
  5. package/dist/api/shared/display-profile.d.ts +11 -0
  6. package/dist/api/shared/display-profile.js +3 -0
  7. package/dist/api/shared/framework-manifest.d.ts +85 -78
  8. package/dist/api/shared/framework-manifest.js +1 -0
  9. package/dist/api/shared/hal-op-ir.d.ts +19 -0
  10. package/dist/api/shared/toolchain-types.d.ts +0 -1
  11. package/dist/cli.js +21 -4
  12. package/dist/config-loader.d.ts +8 -2
  13. package/dist/config-loader.js +202 -53
  14. package/dist/config-schema.d.ts +7 -7
  15. package/dist/config-schema.js +3 -3
  16. package/dist/create/board-spec.d.ts +122 -122
  17. package/dist/create/debug-artifacts.d.ts +20 -0
  18. package/dist/create/debug-artifacts.js +69 -0
  19. package/dist/create/eslint-rules-template.js +6 -3
  20. package/dist/create/index.d.ts +2 -0
  21. package/dist/create/index.js +1 -0
  22. package/dist/create/init-scaffold.d.ts +1 -0
  23. package/dist/create/init-scaffold.js +5 -0
  24. package/dist/create/init-templates.js +0 -2
  25. package/dist/emit/compliance/rules.js +52 -4
  26. package/dist/emit/emitters/function-emitter-impl.js +7 -1
  27. package/dist/emit/emitters/line-appender.js +6 -0
  28. package/dist/emit/emitters/setup.js +15 -2
  29. package/dist/emit/emitters/ui-emitter.js +40 -15
  30. package/dist/emit/route-hal-op.js +55 -1
  31. package/dist/emit/statement-renderer.js +5 -2
  32. package/dist/ir/build-ir.js +22 -1
  33. package/dist/ir/expression-to-ir.js +17 -0
  34. package/dist/ir/feature-registry.js +22 -6
  35. package/dist/ir/hal/hal-emitter.js +23 -5
  36. package/dist/ir/hal/hal-plugins.js +11 -0
  37. package/dist/ir/pin-mode-validation.js +32 -9
  38. package/dist/ir/pin-state-tracking.d.ts +58 -0
  39. package/dist/ir/pin-state-tracking.js +182 -0
  40. package/dist/ir/program-analysis.d.ts +10 -2
  41. package/dist/ir/program-analysis.js +40 -4
  42. package/dist/ir/statement-to-ir.js +14 -0
  43. package/dist/ir/transformers/control-flow.js +29 -0
  44. package/dist/ir/transformers/ui-call-resolver.js +105 -1
  45. package/dist/ir/ui-element-auto-wire.js +7 -4
  46. package/dist/orchestrator/graph-builder.d.ts +4 -1
  47. package/dist/orchestrator/graph-builder.js +7 -1
  48. package/dist/platform/async-runtime.d.ts +1 -1
  49. package/dist/platform/async-runtime.js +12 -3
  50. package/dist/platform/generic-strategy.js +1 -1
  51. package/dist/preview/api-shared-shim.d.ts +1 -0
  52. package/dist/preview/api-shared-shim.js +7 -0
  53. package/dist/preview/client.js +220 -1
  54. package/dist/preview/server.js +154 -62
  55. package/dist/theme-tokens.d.ts +22 -0
  56. package/dist/theme-tokens.js +172 -0
  57. package/dist/transpile.js +90 -12
  58. package/dist/types.d.ts +5 -0
  59. package/dist/ui-hook.d.ts +7 -0
  60. package/dist/utils/cli.js +9 -0
  61. package/dist/utils/fs.d.ts +2 -0
  62. package/dist/utils/fs.js +16 -0
  63. package/dist/utils/ui.d.ts +5 -0
  64. package/dist/utils/ui.js +7 -0
  65. package/package.json +7 -5
@@ -44,10 +44,10 @@ export declare const BoardSpecSchema: z.ZodObject<{
44
44
  instance: number;
45
45
  role: string;
46
46
  }[] | undefined;
47
+ notes?: string | undefined;
47
48
  alt?: string[] | undefined;
48
49
  warnings?: string[] | undefined;
49
50
  unsafe?: boolean | undefined;
50
- notes?: string | undefined;
51
51
  onboardLed?: boolean | undefined;
52
52
  }, {
53
53
  gpio: number;
@@ -57,10 +57,10 @@ export declare const BoardSpecSchema: z.ZodObject<{
57
57
  instance: number;
58
58
  role: string;
59
59
  }[] | undefined;
60
+ notes?: string | undefined;
60
61
  alt?: string[] | undefined;
61
62
  warnings?: string[] | undefined;
62
63
  unsafe?: boolean | undefined;
63
- notes?: string | undefined;
64
64
  onboardLed?: boolean | undefined;
65
65
  }>, "many">;
66
66
  unsafe: z.ZodArray<z.ZodString, "many">;
@@ -75,21 +75,21 @@ export declare const BoardSpecSchema: z.ZodObject<{
75
75
  tx: z.ZodOptional<z.ZodString>;
76
76
  rx: z.ZodOptional<z.ZodString>;
77
77
  }, "strict", z.ZodTypeAny, {
78
- sda?: string | undefined;
79
- scl?: string | undefined;
78
+ cs?: string | undefined;
80
79
  mosi?: string | undefined;
81
- miso?: string | undefined;
82
80
  sck?: string | undefined;
83
- cs?: string | undefined;
81
+ miso?: string | undefined;
82
+ sda?: string | undefined;
83
+ scl?: string | undefined;
84
84
  tx?: string | undefined;
85
85
  rx?: string | undefined;
86
86
  }, {
87
- sda?: string | undefined;
88
- scl?: string | undefined;
87
+ cs?: string | undefined;
89
88
  mosi?: string | undefined;
90
- miso?: string | undefined;
91
89
  sck?: string | undefined;
92
- cs?: string | undefined;
90
+ miso?: string | undefined;
91
+ sda?: string | undefined;
92
+ scl?: string | undefined;
93
93
  tx?: string | undefined;
94
94
  rx?: string | undefined;
95
95
  }>>;
@@ -103,21 +103,21 @@ export declare const BoardSpecSchema: z.ZodObject<{
103
103
  tx: z.ZodOptional<z.ZodString>;
104
104
  rx: z.ZodOptional<z.ZodString>;
105
105
  }, "strict", z.ZodTypeAny, {
106
- sda?: string | undefined;
107
- scl?: string | undefined;
106
+ cs?: string | undefined;
108
107
  mosi?: string | undefined;
109
- miso?: string | undefined;
110
108
  sck?: string | undefined;
111
- cs?: string | undefined;
109
+ miso?: string | undefined;
110
+ sda?: string | undefined;
111
+ scl?: string | undefined;
112
112
  tx?: string | undefined;
113
113
  rx?: string | undefined;
114
114
  }, {
115
- sda?: string | undefined;
116
- scl?: string | undefined;
115
+ cs?: string | undefined;
117
116
  mosi?: string | undefined;
118
- miso?: string | undefined;
119
117
  sck?: string | undefined;
120
- cs?: string | undefined;
118
+ miso?: string | undefined;
119
+ sda?: string | undefined;
120
+ scl?: string | undefined;
121
121
  tx?: string | undefined;
122
122
  rx?: string | undefined;
123
123
  }>>;
@@ -131,21 +131,21 @@ export declare const BoardSpecSchema: z.ZodObject<{
131
131
  tx: z.ZodOptional<z.ZodString>;
132
132
  rx: z.ZodOptional<z.ZodString>;
133
133
  }, "strict", z.ZodTypeAny, {
134
- sda?: string | undefined;
135
- scl?: string | undefined;
134
+ cs?: string | undefined;
136
135
  mosi?: string | undefined;
137
- miso?: string | undefined;
138
136
  sck?: string | undefined;
139
- cs?: string | undefined;
137
+ miso?: string | undefined;
138
+ sda?: string | undefined;
139
+ scl?: string | undefined;
140
140
  tx?: string | undefined;
141
141
  rx?: string | undefined;
142
142
  }, {
143
- sda?: string | undefined;
144
- scl?: string | undefined;
143
+ cs?: string | undefined;
145
144
  mosi?: string | undefined;
146
- miso?: string | undefined;
147
145
  sck?: string | undefined;
148
- cs?: string | undefined;
146
+ miso?: string | undefined;
147
+ sda?: string | undefined;
148
+ scl?: string | undefined;
149
149
  tx?: string | undefined;
150
150
  rx?: string | undefined;
151
151
  }>>;
@@ -230,18 +230,18 @@ export declare const BoardSpecSchema: z.ZodObject<{
230
230
  maxValue: z.ZodNumber;
231
231
  referenceVoltages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
232
232
  }, "strict", z.ZodTypeAny, {
233
+ maxValue: number;
233
234
  instance: number;
234
235
  channels: number;
235
236
  resolution: number;
236
237
  referenceVoltage: number;
237
- maxValue: number;
238
238
  referenceVoltages?: Record<string, number> | undefined;
239
239
  }, {
240
+ maxValue: number;
240
241
  instance: number;
241
242
  channels: number;
242
243
  resolution: number;
243
244
  referenceVoltage: number;
244
- maxValue: number;
245
245
  referenceVoltages?: Record<string, number> | undefined;
246
246
  }>, "many">;
247
247
  pwm: z.ZodObject<{
@@ -273,14 +273,14 @@ export declare const BoardSpecSchema: z.ZodObject<{
273
273
  bits: z.ZodUnion<[z.ZodLiteral<8>, z.ZodLiteral<16>, z.ZodLiteral<32>, z.ZodLiteral<64>]>;
274
274
  features: z.ZodOptional<z.ZodArray<z.ZodEnum<["pwm", "capture", "compare", "interrupt", "dma"]>, "many">>;
275
275
  }, "strict", z.ZodTypeAny, {
276
+ bits: 8 | 16 | 32 | 64;
276
277
  type: "general" | "high_speed" | "rtc" | "sys";
277
278
  instance: number;
278
- bits: 8 | 16 | 32 | 64;
279
279
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
280
280
  }, {
281
+ bits: 8 | 16 | 32 | 64;
281
282
  type: "general" | "high_speed" | "rtc" | "sys";
282
283
  instance: number;
283
- bits: 8 | 16 | 32 | 64;
284
284
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
285
285
  }>, "many">;
286
286
  wifi: z.ZodObject<{
@@ -365,68 +365,42 @@ export declare const BoardSpecSchema: z.ZodObject<{
365
365
  }>;
366
366
  }, "strict", z.ZodTypeAny, {
367
367
  architecture: string;
368
- mcuId: string;
369
- mcuName: string;
370
- boardId: string;
371
- boardName: string;
372
- vendor: string;
373
- clockSpeed: number;
374
- fqbn: string;
375
- arduinoDefine: string;
376
- moduleFlash: number | null;
377
- externalRam: number | null;
378
- gpioRange: [number, number];
379
- excludedGpio: number[];
380
- pins: {
381
- gpio: number;
382
- capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
383
- functions?: {
384
- type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
385
- instance: number;
386
- role: string;
387
- }[] | undefined;
388
- alt?: string[] | undefined;
389
- warnings?: string[] | undefined;
390
- unsafe?: boolean | undefined;
391
- notes?: string | undefined;
392
- onboardLed?: boolean | undefined;
393
- }[];
394
368
  i2c: Record<string, {
395
- sda?: string | undefined;
396
- scl?: string | undefined;
369
+ cs?: string | undefined;
397
370
  mosi?: string | undefined;
398
- miso?: string | undefined;
399
371
  sck?: string | undefined;
400
- cs?: string | undefined;
372
+ miso?: string | undefined;
373
+ sda?: string | undefined;
374
+ scl?: string | undefined;
401
375
  tx?: string | undefined;
402
376
  rx?: string | undefined;
403
377
  }>;
404
378
  spi: Record<string, {
405
- sda?: string | undefined;
406
- scl?: string | undefined;
379
+ cs?: string | undefined;
407
380
  mosi?: string | undefined;
408
- miso?: string | undefined;
409
381
  sck?: string | undefined;
410
- cs?: string | undefined;
382
+ miso?: string | undefined;
383
+ sda?: string | undefined;
384
+ scl?: string | undefined;
411
385
  tx?: string | undefined;
412
386
  rx?: string | undefined;
413
387
  }>;
414
388
  uart: Record<string, {
415
- sda?: string | undefined;
416
- scl?: string | undefined;
389
+ cs?: string | undefined;
417
390
  mosi?: string | undefined;
418
- miso?: string | undefined;
419
391
  sck?: string | undefined;
420
- cs?: string | undefined;
392
+ miso?: string | undefined;
393
+ sda?: string | undefined;
394
+ scl?: string | undefined;
421
395
  tx?: string | undefined;
422
396
  rx?: string | undefined;
423
397
  }>;
424
398
  adc: {
399
+ maxValue: number;
425
400
  instance: number;
426
401
  channels: number;
427
402
  resolution: number;
428
403
  referenceVoltage: number;
429
- maxValue: number;
430
404
  referenceVoltages?: Record<string, number> | undefined;
431
405
  }[];
432
406
  pwm: {
@@ -439,6 +413,37 @@ export declare const BoardSpecSchema: z.ZodObject<{
439
413
  vid: string;
440
414
  pid: string;
441
415
  };
416
+ wifi: {
417
+ type: "wifi" | "wifi6";
418
+ supportsStation: boolean;
419
+ supportsAp: boolean;
420
+ };
421
+ mcuId: string;
422
+ mcuName: string;
423
+ boardId: string;
424
+ boardName: string;
425
+ vendor: string;
426
+ clockSpeed: number;
427
+ fqbn: string;
428
+ arduinoDefine: string;
429
+ moduleFlash: number | null;
430
+ externalRam: number | null;
431
+ gpioRange: [number, number];
432
+ excludedGpio: number[];
433
+ pins: {
434
+ gpio: number;
435
+ capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
436
+ functions?: {
437
+ type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
438
+ instance: number;
439
+ role: string;
440
+ }[] | undefined;
441
+ notes?: string | undefined;
442
+ alt?: string[] | undefined;
443
+ warnings?: string[] | undefined;
444
+ unsafe?: boolean | undefined;
445
+ onboardLed?: boolean | undefined;
446
+ }[];
442
447
  unsafe: string[];
443
448
  analog: string[];
444
449
  peripheralInstances: {
@@ -459,9 +464,9 @@ export declare const BoardSpecSchema: z.ZodObject<{
459
464
  }[];
460
465
  };
461
466
  timers: {
467
+ bits: 8 | 16 | 32 | 64;
462
468
  type: "general" | "high_speed" | "rtc" | "sys";
463
469
  instance: number;
464
- bits: 8 | 16 | 32 | 64;
465
470
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
466
471
  }[];
467
472
  features: {
@@ -473,11 +478,6 @@ export declare const BoardSpecSchema: z.ZodObject<{
473
478
  hardwareRng: boolean;
474
479
  fpu: boolean;
475
480
  };
476
- wifi: {
477
- type: "wifi" | "wifi6";
478
- supportsStation: boolean;
479
- supportsAp: boolean;
480
- };
481
481
  bluetooth: {
482
482
  type: "classic" | "ble" | "dual";
483
483
  version: string;
@@ -489,75 +489,49 @@ export declare const BoardSpecSchema: z.ZodObject<{
489
489
  externalRam?: number | undefined;
490
490
  rtcMemory?: number | undefined;
491
491
  };
492
- description?: string | undefined;
493
492
  touch?: {
494
493
  pins: string[];
495
494
  channels: number;
496
495
  } | null | undefined;
496
+ description?: string | undefined;
497
497
  }, {
498
498
  architecture: string;
499
- mcuId: string;
500
- mcuName: string;
501
- boardId: string;
502
- boardName: string;
503
- vendor: string;
504
- clockSpeed: number;
505
- fqbn: string;
506
- arduinoDefine: string;
507
- moduleFlash: number | null;
508
- externalRam: number | null;
509
- gpioRange: [number, number];
510
- excludedGpio: number[];
511
- pins: {
512
- gpio: number;
513
- capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
514
- functions?: {
515
- type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
516
- instance: number;
517
- role: string;
518
- }[] | undefined;
519
- alt?: string[] | undefined;
520
- warnings?: string[] | undefined;
521
- unsafe?: boolean | undefined;
522
- notes?: string | undefined;
523
- onboardLed?: boolean | undefined;
524
- }[];
525
499
  i2c: Record<string, {
526
- sda?: string | undefined;
527
- scl?: string | undefined;
500
+ cs?: string | undefined;
528
501
  mosi?: string | undefined;
529
- miso?: string | undefined;
530
502
  sck?: string | undefined;
531
- cs?: string | undefined;
503
+ miso?: string | undefined;
504
+ sda?: string | undefined;
505
+ scl?: string | undefined;
532
506
  tx?: string | undefined;
533
507
  rx?: string | undefined;
534
508
  }>;
535
509
  spi: Record<string, {
536
- sda?: string | undefined;
537
- scl?: string | undefined;
510
+ cs?: string | undefined;
538
511
  mosi?: string | undefined;
539
- miso?: string | undefined;
540
512
  sck?: string | undefined;
541
- cs?: string | undefined;
513
+ miso?: string | undefined;
514
+ sda?: string | undefined;
515
+ scl?: string | undefined;
542
516
  tx?: string | undefined;
543
517
  rx?: string | undefined;
544
518
  }>;
545
519
  uart: Record<string, {
546
- sda?: string | undefined;
547
- scl?: string | undefined;
520
+ cs?: string | undefined;
548
521
  mosi?: string | undefined;
549
- miso?: string | undefined;
550
522
  sck?: string | undefined;
551
- cs?: string | undefined;
523
+ miso?: string | undefined;
524
+ sda?: string | undefined;
525
+ scl?: string | undefined;
552
526
  tx?: string | undefined;
553
527
  rx?: string | undefined;
554
528
  }>;
555
529
  adc: {
530
+ maxValue: number;
556
531
  instance: number;
557
532
  channels: number;
558
533
  resolution: number;
559
534
  referenceVoltage: number;
560
- maxValue: number;
561
535
  referenceVoltages?: Record<string, number> | undefined;
562
536
  }[];
563
537
  pwm: {
@@ -570,6 +544,37 @@ export declare const BoardSpecSchema: z.ZodObject<{
570
544
  vid: string;
571
545
  pid: string;
572
546
  };
547
+ wifi: {
548
+ type: "wifi" | "wifi6";
549
+ supportsStation: boolean;
550
+ supportsAp: boolean;
551
+ };
552
+ mcuId: string;
553
+ mcuName: string;
554
+ boardId: string;
555
+ boardName: string;
556
+ vendor: string;
557
+ clockSpeed: number;
558
+ fqbn: string;
559
+ arduinoDefine: string;
560
+ moduleFlash: number | null;
561
+ externalRam: number | null;
562
+ gpioRange: [number, number];
563
+ excludedGpio: number[];
564
+ pins: {
565
+ gpio: number;
566
+ capabilities: "FULL_GPIO" | "FULL_GPIO_ANALOG" | "FULL_GPIO_TOUCH" | "FULL_GPIO_ANALOG_TOUCH" | "FULL_GPIO_DAC" | "INPUT_ONLY";
567
+ functions?: {
568
+ type: "i2c" | "spi" | "uart" | "adc" | "dac" | "pwm" | "touch" | "usb";
569
+ instance: number;
570
+ role: string;
571
+ }[] | undefined;
572
+ notes?: string | undefined;
573
+ alt?: string[] | undefined;
574
+ warnings?: string[] | undefined;
575
+ unsafe?: boolean | undefined;
576
+ onboardLed?: boolean | undefined;
577
+ }[];
573
578
  unsafe: string[];
574
579
  analog: string[];
575
580
  peripheralInstances: {
@@ -590,9 +595,9 @@ export declare const BoardSpecSchema: z.ZodObject<{
590
595
  }[];
591
596
  };
592
597
  timers: {
598
+ bits: 8 | 16 | 32 | 64;
593
599
  type: "general" | "high_speed" | "rtc" | "sys";
594
600
  instance: number;
595
- bits: 8 | 16 | 32 | 64;
596
601
  features?: ("pwm" | "capture" | "compare" | "interrupt" | "dma")[] | undefined;
597
602
  }[];
598
603
  features: {
@@ -604,11 +609,6 @@ export declare const BoardSpecSchema: z.ZodObject<{
604
609
  hardwareRng: boolean;
605
610
  fpu: boolean;
606
611
  };
607
- wifi: {
608
- type: "wifi" | "wifi6";
609
- supportsStation: boolean;
610
- supportsAp: boolean;
611
- };
612
612
  bluetooth: {
613
613
  type: "classic" | "ble" | "dual";
614
614
  version: string;
@@ -620,11 +620,11 @@ export declare const BoardSpecSchema: z.ZodObject<{
620
620
  externalRam?: number | undefined;
621
621
  rtcMemory?: number | undefined;
622
622
  };
623
- description?: string | undefined;
624
623
  touch?: {
625
624
  pins: string[];
626
625
  channels: number;
627
626
  } | null | undefined;
627
+ description?: string | undefined;
628
628
  }>;
629
629
  export type BoardSpec = z.infer<typeof BoardSpecSchema>;
630
630
  export declare function parseBoardSpec(jsoncText: string): BoardSpec;
@@ -0,0 +1,20 @@
1
+ export interface FrameworkDebugArtifactsOptions {
2
+ /** Framework package name (e.g. '@typecad/framework-zephyr'), if known. */
3
+ frameworkPackage?: string;
4
+ /** Absolute path to the new cuttlefish project root. */
5
+ workspaceRoot: string;
6
+ /** The framework build target (e.g. Zephyr board id), if known. */
7
+ buildTarget?: string;
8
+ }
9
+ /**
10
+ * Module loader for the framework package. Returns the loaded module, or
11
+ * undefined when it cannot be resolved. Injectable for tests.
12
+ */
13
+ export type FrameworkModuleLoader = (packageName: string) => any | undefined;
14
+ /**
15
+ * Generate the framework's starter debug artifacts for a new project.
16
+ * Returns the workspace-relative paths written (e.g. ['.vscode/launch.json']),
17
+ * or [] when the framework has no debug support, isn't resolvable yet, or the
18
+ * generator failed (warns, never throws).
19
+ */
20
+ export declare function generateFrameworkDebugArtifacts(o: FrameworkDebugArtifactsOptions, loadModule?: FrameworkModuleLoader): string[];
@@ -0,0 +1,69 @@
1
+ // ---------------------------------------------------------------------------
2
+ // debug-artifacts.ts — create-time framework debug profile generation
3
+ //
4
+ // `cuttlefish create` scaffolds a project that has never been built, so the
5
+ // framework toolchain's post-build debug-artifact writer (e.g. Zephyr's
6
+ // writeDebugConfig, which runs after a successful `west build --debug`) has
7
+ // never had a chance to run. Without a .vscode/launch.json, pressing F5 in VS
8
+ // Code just opens the "select a debugger" menu.
9
+ //
10
+ // Frameworks that support native debugging may export
11
+ // `writeProjectDebugArtifacts({ workspaceRoot, buildTarget })` from their
12
+ // package root (see @typecad/framework-zephyr). This helper loads the freshly
13
+ // installed framework package and invokes that export — the framework decides
14
+ // whether the target is debug-capable and what to write. Frameworks without
15
+ // the export (or targets without native debug support) are a silent no-op.
16
+ //
17
+ // Everything here is best-effort: a failed or skipped generation never fails
18
+ // `cuttlefish create`, because the first `--debug` build still writes the
19
+ // artifacts the hard way.
20
+ // ---------------------------------------------------------------------------
21
+ import path from "node:path";
22
+ import { fileURLToPath } from "node:url";
23
+ import { loadFrameworkPackage } from "../framework-package.js";
24
+ const cliModuleDir = path.dirname(fileURLToPath(import.meta.url));
25
+ /**
26
+ * Generate the framework's starter debug artifacts for a new project.
27
+ * Returns the workspace-relative paths written (e.g. ['.vscode/launch.json']),
28
+ * or [] when the framework has no debug support, isn't resolvable yet, or the
29
+ * generator failed (warns, never throws).
30
+ */
31
+ export function generateFrameworkDebugArtifacts(o, loadModule) {
32
+ if (!o.frameworkPackage || !o.workspaceRoot)
33
+ return [];
34
+ // Default loader: prefer the new project's node_modules (populated by the
35
+ // create install step), then the CLI's own module location (monorepo /
36
+ // --no-install flows where the framework is a workspace sibling of the
37
+ // running cuttlefish).
38
+ const loader = loadModule ?? ((packageName) => {
39
+ for (const dir of [o.workspaceRoot, cliModuleDir]) {
40
+ try {
41
+ return loadFrameworkPackage(packageName, dir);
42
+ }
43
+ catch {
44
+ // not resolvable from this location — try the next
45
+ }
46
+ }
47
+ return undefined;
48
+ });
49
+ let mod;
50
+ try {
51
+ mod = loader(o.frameworkPackage);
52
+ }
53
+ catch {
54
+ return [];
55
+ }
56
+ if (!mod || typeof mod.writeProjectDebugArtifacts !== "function")
57
+ return [];
58
+ try {
59
+ const written = mod.writeProjectDebugArtifacts({
60
+ workspaceRoot: o.workspaceRoot,
61
+ buildTarget: o.buildTarget,
62
+ });
63
+ return Array.isArray(written) ? written.map(String) : [];
64
+ }
65
+ catch (e) {
66
+ console.warn(`! Debug profile generation failed: ${e.message}`);
67
+ return [];
68
+ }
69
+ }
@@ -300,9 +300,12 @@ export default {
300
300
  return "";
301
301
  }
302
302
  function isContainerVar(node) {
303
- if (node.type === "Identifier" && containerVars.has(node.name)) return true;
304
- if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.property.type === "Identifier" && FUNCTIONAL_METHODS.has(node.callee.property.name)) return true;
305
- return false;
303
+ // Only identifiers with a known container type count. A
304
+ // CallExpression receiver (e.g. arr.map(f).filter(g)) is the RESULT
305
+ // of a functional method — on arrays that's another array, which
306
+ // the transpiler lowers; treating it as a container flagged every
307
+ // supported method chain as an error.
308
+ return node.type === "Identifier" && containerVars.has(node.name);
306
309
  }
307
310
  return {
308
311
  VariableDeclarator(node) {
@@ -7,6 +7,8 @@ export type { ProjectInstallResult } from './install-deps.js';
7
7
  export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateStarterTest, generateStarterSim, generateGitignore, generateEslintConfig, } from './init-templates.js';
8
8
  export type { InitProjectOptions } from './init-templates.js';
9
9
  export { runInitWizard } from './init-wizard.js';
10
+ export { generateFrameworkDebugArtifacts } from './debug-artifacts.js';
11
+ export type { FrameworkDebugArtifactsOptions, FrameworkModuleLoader } from './debug-artifacts.js';
10
12
  export { scaffoldBoardPackages } from './board-codegen.js';
11
13
  export type { ScaffoldBoardResult } from './board-codegen.js';
12
14
  export { generateFrameworkChecklist } from './board-checklist.js';
@@ -3,6 +3,7 @@ export { FRAMEWORK_CATALOG, frameworksForTarget, frameworkCatalogEntry, detectPa
3
3
  export { installProjectDependencies, __setProjectInstallRunnerForTest } from './install-deps.js';
4
4
  export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateStarterTest, generateStarterSim, generateGitignore, generateEslintConfig, } from './init-templates.js';
5
5
  export { runInitWizard } from './init-wizard.js';
6
+ export { generateFrameworkDebugArtifacts } from './debug-artifacts.js';
6
7
  // Board codegen tool (`cuttlefish board add`)
7
8
  export { scaffoldBoardPackages } from './board-codegen.js';
8
9
  export { generateFrameworkChecklist } from './board-checklist.js';
@@ -33,4 +33,5 @@ export interface ScaffoldProjectResult {
33
33
  export declare function scaffoldProject(options: InitProjectOptions, outDir?: string): ScaffoldProjectResult;
34
34
  export declare function printInitNextSteps(options: InitProjectOptions, outDir: string, opts?: {
35
35
  installed?: boolean;
36
+ debugProfile?: boolean;
36
37
  }): void;
@@ -168,6 +168,11 @@ export function printInitNextSteps(options, outDir, opts = {}) {
168
168
  console.log(chalk.dim(` npm install`));
169
169
  }
170
170
  console.log(` ${chalk.cyan("npm run compile")}`);
171
+ if (opts.debugProfile) {
172
+ console.log();
173
+ console.log(chalk.bold.white("To debug (VS Code):"));
174
+ console.log(` ${chalk.cyan("open the folder and press F5")} ${chalk.dim("(builds + flashes, then attaches GDB)")}`);
175
+ }
171
176
  if (!options.isNative) {
172
177
  const portHint = process.platform === 'win32' ? 'COM4' : '/dev/ttyACM0';
173
178
  console.log();
@@ -149,7 +149,6 @@ const config = {
149
149
 
150
150
  // Output options
151
151
  output: {
152
- optimize: 'speed',
153
152
  outDir: './out',
154
153
  },
155
154
  };
@@ -198,7 +197,6 @@ const config: CuttlefishConfig = {
198
197
  // Output / build options
199
198
  output: {
200
199
  framework: '${options.framework}',
201
- optimize: 'size',
202
200
  outDir: './out',
203
201
  },
204
202