@typecad/cuttlefish 1.0.0-alpha.12 → 1.0.0-alpha.14

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 (101) hide show
  1. package/assets/editor-extensions/typecad-debug/README.md +142 -0
  2. package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
  3. package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
  4. package/assets/editor-extensions/typecad-debug/package.json +76 -0
  5. package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
  6. package/assets/editor-extensions/typecad-ui/README.md +52 -0
  7. package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
  8. package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
  9. package/assets/editor-extensions/typecad-ui/icon.png +0 -0
  10. package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
  11. package/assets/editor-extensions/typecad-ui/package.json +54 -0
  12. package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
  13. package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
  14. package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
  15. package/dist/add-preset.d.ts +4 -0
  16. package/dist/add-preset.js +74 -0
  17. package/dist/api/config.d.ts +8 -5
  18. package/dist/api/shared/display-adapters/sdl.js +1 -1
  19. package/dist/api/shared/display-profile.d.ts +11 -0
  20. package/dist/api/shared/display-profile.js +3 -0
  21. package/dist/api/shared/framework-manifest.d.ts +61 -504
  22. package/dist/api/shared/hal-op-ir.d.ts +19 -0
  23. package/dist/api/shared/toolchain-types.d.ts +0 -1
  24. package/dist/cli.js +31 -9
  25. package/dist/config-loader.d.ts +0 -2
  26. package/dist/config-loader.js +13 -6
  27. package/dist/config-schema.d.ts +17 -230
  28. package/dist/config-schema.js +1 -3
  29. package/dist/contract/contract-parser.d.ts +9 -127
  30. package/dist/create/board-checklist.js +1 -1
  31. package/dist/create/board-codegen.js +4 -4
  32. package/dist/create/board-spec.d.ts +74 -530
  33. package/dist/create/debug-artifacts.d.ts +20 -0
  34. package/dist/create/debug-artifacts.js +69 -0
  35. package/dist/create/editor-integration.d.ts +30 -0
  36. package/dist/create/editor-integration.js +218 -0
  37. package/dist/create/eslint-rules-template.d.ts +2 -2
  38. package/dist/create/framework-catalog.d.ts +8 -0
  39. package/dist/create/framework-catalog.js +28 -5
  40. package/dist/create/index.d.ts +9 -6
  41. package/dist/create/index.js +6 -4
  42. package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +5 -4
  43. package/dist/create/{init-scaffold.js → scaffold.js} +38 -2
  44. package/dist/create/templates.d.ts +29 -0
  45. package/dist/create/{init-templates.js → templates.js} +15 -2
  46. package/dist/create/wizard.d.ts +8 -0
  47. package/dist/create/{init-wizard.js → wizard.js} +11 -4
  48. package/dist/emit/compliance/rules.js +18 -4
  49. package/dist/emit/emitters/function-emitter-impl.js +7 -1
  50. package/dist/emit/emitters/line-appender.js +6 -0
  51. package/dist/emit/emitters/setup.js +22 -0
  52. package/dist/emit/emitters/ui-emitter.js +40 -15
  53. package/dist/emit/route-hal-op.js +55 -1
  54. package/dist/emit/statement-renderer.js +5 -2
  55. package/dist/ir/build-ir.js +46 -4
  56. package/dist/ir/expression-to-ir.js +17 -0
  57. package/dist/ir/hal/hal-emitter.js +23 -5
  58. package/dist/ir/hal/hal-plugins.js +11 -0
  59. package/dist/ir/pin-mode-validation.js +32 -9
  60. package/dist/ir/pin-state-tracking.d.ts +58 -0
  61. package/dist/ir/pin-state-tracking.js +182 -0
  62. package/dist/ir/program-analysis.d.ts +6 -0
  63. package/dist/ir/program-analysis.js +38 -0
  64. package/dist/ir/statement-to-ir.js +14 -0
  65. package/dist/ir/transformers/control-flow.js +29 -0
  66. package/dist/ir/transformers/ui-call-resolver.js +105 -1
  67. package/dist/ir/ui-element-auto-wire.js +7 -4
  68. package/dist/library/catalog.d.ts +35 -0
  69. package/dist/library/catalog.js +67 -0
  70. package/dist/library/cli.d.ts +2 -0
  71. package/dist/library/cli.js +168 -0
  72. package/dist/library/init.d.ts +25 -0
  73. package/dist/library/init.js +397 -0
  74. package/dist/library/install.d.ts +9 -0
  75. package/dist/library/install.js +80 -0
  76. package/dist/library/registry-search.d.ts +34 -0
  77. package/dist/library/registry-search.js +50 -0
  78. package/dist/library/validate.d.ts +17 -0
  79. package/dist/library/validate.js +175 -0
  80. package/dist/library-packages.d.ts +95 -0
  81. package/dist/library-packages.js +275 -0
  82. package/dist/orchestrator/graph-builder.d.ts +4 -1
  83. package/dist/orchestrator/graph-builder.js +23 -1
  84. package/dist/preview/api-shared-shim.d.ts +1 -0
  85. package/dist/preview/api-shared-shim.js +7 -0
  86. package/dist/preview/client.js +235 -2
  87. package/dist/preview/server.js +154 -62
  88. package/dist/testing.d.ts +2 -2
  89. package/dist/testing.js +1 -1
  90. package/dist/theme-tokens.d.ts +22 -0
  91. package/dist/theme-tokens.js +172 -0
  92. package/dist/transpile.js +90 -5
  93. package/dist/types.d.ts +24 -0
  94. package/dist/ui-hook.d.ts +7 -0
  95. package/dist/utils/cli.d.ts +2 -2
  96. package/dist/utils/cli.js +77 -3
  97. package/dist/utils/ui.d.ts +5 -0
  98. package/dist/utils/ui.js +7 -0
  99. package/package.json +18 -9
  100. package/dist/create/init-templates.d.ts +0 -28
  101. package/dist/create/init-wizard.d.ts +0 -8
@@ -0,0 +1,4 @@
1
+ import type { AddCommandOptions } from "./types.js";
2
+ export declare function listAddPresets(): string;
3
+ /** Run `cuttlefish add <preset>`: copy the preset into the project. */
4
+ export declare function runAddPreset(options: AddCommandOptions): void;
@@ -0,0 +1,74 @@
1
+ // ---------------------------------------------------------------------------
2
+ // `cuttlefish add <preset>` — scaffold copy-and-own assets into a project.
3
+ //
4
+ // Presets are files shipped with the package under assets/. The command COPIES
5
+ // them into the user's project (never injected at build time): the user owns
6
+ // the file from day one and the build only reads what they reference. This is
7
+ // the same philosophy as shadcn/ui — components as source you keep, not a
8
+ // runtime dependency.
9
+ // ---------------------------------------------------------------------------
10
+ import fs from "node:fs";
11
+ import path from "node:path";
12
+ import { fileURLToPath } from "node:url";
13
+ import { loadShadcnTheme, applyShadcnTheme } from "./theme-tokens.js";
14
+ import chalk from "chalk";
15
+ const ASSETS_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../assets");
16
+ const PRESETS = {
17
+ shadcn: {
18
+ source: "shadcn/shadcn.css",
19
+ dest: "src/styles/shadcn.css",
20
+ description: "shadcn-style CSS variable tokens + component class recipes (buttons, cards, badges, alerts, ...)",
21
+ nextSteps: [
22
+ `Link it from a stylesheet (sibling .ui.css file or a <style> block):`,
23
+ ``,
24
+ ` @import "./styles/shadcn.css";`,
25
+ ``,
26
+ `Then use the classes on native elements:`,
27
+ ` <button class="btn btn-primary">Save</button>`,
28
+ ` <view class="card"> ... <text class="card-title">Title</text> ... </view>`,
29
+ ``,
30
+ `Dark theme: the file defines a .dark token set — activate it with`,
31
+ `themeClass: 'dark' in cuttlefish.config.ts's display block.`,
32
+ `The file is yours: tune tokens and prune recipes freely.`,
33
+ ``,
34
+ `Themes: start from an included one with --theme <name>`,
35
+ `(see \`cuttlefish theme\` for the list); swap later with the same command.`,
36
+ ],
37
+ },
38
+ };
39
+ export function listAddPresets() {
40
+ return Object.entries(PRESETS).map(([id, p]) => ` ${id.padEnd(10)} ${p.description}`).join("\n");
41
+ }
42
+ /** Run `cuttlefish add <preset>`: copy the preset into the project. */
43
+ export function runAddPreset(options) {
44
+ const preset = PRESETS[options.preset];
45
+ if (!preset) {
46
+ throw new Error(`Unknown preset "${options.preset}". Available presets:\n${listAddPresets()}`);
47
+ }
48
+ const src = path.join(ASSETS_DIR, preset.source);
49
+ if (!fs.existsSync(src)) {
50
+ throw new Error(`Preset asset missing from the cuttlefish package: ${src}`);
51
+ }
52
+ const dest = path.resolve(options.projectRoot, preset.dest);
53
+ if (fs.existsSync(dest) && !options.force) {
54
+ throw new Error(`${dest} already exists — re-run with --force to overwrite (your edits will be lost).`);
55
+ }
56
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
57
+ fs.copyFileSync(src, dest);
58
+ // --theme <name>: merge an included shadcn theme's tokens into the copied
59
+ // stylesheet (shadcn preset only; no-op for future presets without themes).
60
+ if (options.theme) {
61
+ if (options.preset !== "shadcn") {
62
+ throw new Error(`--theme applies to the shadcn preset only (got "${options.preset}").`);
63
+ }
64
+ const theme = loadShadcnTheme(options.theme, options.projectRoot);
65
+ fs.writeFileSync(dest, applyShadcnTheme(fs.readFileSync(dest, "utf-8"), theme), "utf-8");
66
+ console.log(chalk.green(`✓`) + ` Theme ${chalk.cyan(theme.name)} tokens merged into the copied file.`);
67
+ }
68
+ console.log(chalk.green(`✓`) + ` Added preset ${chalk.cyan(options.preset)} → ${path.relative(options.projectRoot, dest)}`);
69
+ console.log();
70
+ console.log(chalk.bold(`Next steps:`));
71
+ for (const line of preset.nextSteps) {
72
+ console.log(line ? ` ${line}` : ``);
73
+ }
74
+ }
@@ -2,8 +2,6 @@ import type { ArchitectureIdentifier } from './board-types.js';
2
2
  import type { DisplayConfig } from './shared/display-profile.js';
3
3
  /** Build-system / framework the transpiler should target. */
4
4
  type OutputFramework = string & {};
5
- /** Optimization strategy. */
6
- type OptimizationLevel = 'none' | 'size' | 'speed' | 'balanced';
7
5
  /**
8
6
  * Output section — controls how generated C++ is laid out.
9
7
  */
@@ -14,8 +12,6 @@ interface CuttlefishOutputConfig {
14
12
  * Matches the optional Zod `output.framework` in config-schema.ts.
15
13
  */
16
14
  framework?: OutputFramework;
17
- /** Optimization level. */
18
- optimize?: OptimizationLevel;
19
15
  /** Directory to write generated files into (relative to project root). */
20
16
  outDir?: string;
21
17
  /** Additional compiler defines (KEY = value). */
@@ -40,8 +36,15 @@ export interface CuttlefishZephyrConfig {
40
36
  kconfig?: Record<string, string>;
41
37
  /** Extra arguments forwarded to `west build`. */
42
38
  cmakeArgs?: string[];
43
- /** Override the west flash runner (e.g. 'nrfjprog', 'jlink'). */
39
+ /** Override the west flash runner (e.g. 'nrfjprog', 'jlink', 'openocd'). */
44
40
  runner?: string;
41
+ /**
42
+ * Extra arguments appended verbatim to `west flash` after the runner —
43
+ * anything the chosen runner's parser accepts. Example for an ST-Link
44
+ * clone with no SRST line wired to the target:
45
+ * runnerArgs: ['--cmd-pre-init=reset_config none']
46
+ */
47
+ runnerArgs?: string[];
45
48
  }
46
49
  /**
47
50
  * Root configuration object exported from `cuttlefish.config.ts`.
@@ -323,7 +323,7 @@ export const sdlAdapter = (display) => {
323
323
  ` __tc_display.put(dx, dy, pixels[i]);`,
324
324
  ` }`,
325
325
  `}`,
326
- `static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) { return new SdlGfxCanvas(w, h); }`,
326
+ `static inline CuttlefishCanvas16* display_createCanvas(int16_t w, int16_t h) { return new (std::nothrow) SdlGfxCanvas(w, h); }`,
327
327
  `static inline CuttlefishCanvas16* display_createCanvasPsram(int16_t, int16_t) { return nullptr; }`,
328
328
  `static inline void display_deleteCanvas(CuttlefishCanvas16* c) { delete c; }`,
329
329
  `static inline int16_t display_canvasWidth(CuttlefishCanvas16* c) { return c->width(); }`,
@@ -86,6 +86,11 @@ export interface DisplayProfile {
86
86
  * is read, so a missing/unsafe readback path must not affect normal drawing.
87
87
  */
88
88
  scanlineSync?: boolean;
89
+ /** Tearing-effect (TE) sync, hardware variant: GPIO number of the panel's
90
+ * TE output. Opt-in — few off-the-shelf display boards break the pin out.
91
+ * When wired, panel updates wait for the TE frame pulse instead of the
92
+ * GET_SCANLINE readback (no MISO needed; see also scanlineSync). */
93
+ tearingEffectPin?: number;
89
94
  touch?: TouchProfile;
90
95
  /** Enable antialiased rendering for circles, lines, rounded corners, and text
91
96
  * unless a node opts out with font-smoothing:none.
@@ -158,6 +163,12 @@ export interface DisplayConfig {
158
163
  * default because some ST7796S modules misbehave when this command is read.
159
164
  */
160
165
  scanlineSync?: boolean;
166
+ /** Tearing-effect (TE) hardware sync: GPIO number of the panel's TE output
167
+ * (ST7796S TE / ILI9341 TE pin). Strictly opt-in — few off-the-shelf
168
+ * display boards break the pin out. When wired, panel updates arm on the
169
+ * TE frame pulse (tear-free writes, no MISO readback); the Zephyr overlay
170
+ * emits te-gpios on the display DT node and the adapter raises TEON. */
171
+ tearingEffectPin?: number;
161
172
  touch?: TouchProfile | false;
162
173
  cs?: number;
163
174
  dc?: number;
@@ -81,6 +81,7 @@ export function resolveDisplayProfile(config, registry) {
81
81
  spiPins: config.spiPins,
82
82
  colorOrder: config.colorOrder,
83
83
  invertDisplay: config.invertDisplay,
84
+ tearingEffectPin: config.tearingEffectPin,
84
85
  touch: config.touch === false ? undefined : config.touch,
85
86
  displayClass: config.displayClass,
86
87
  capabilities: config.capabilities,
@@ -112,6 +113,8 @@ export function resolveDisplayProfile(config, registry) {
112
113
  base.colorOrder = config.colorOrder;
113
114
  if (config.invertDisplay !== undefined)
114
115
  base.invertDisplay = config.invertDisplay;
116
+ if (config.tearingEffectPin !== undefined)
117
+ base.tearingEffectPin = config.tearingEffectPin;
115
118
  if (config.scanlineSync !== undefined)
116
119
  base.scanlineSync = config.scanlineSync;
117
120
  if (config.touch === false)