@typecad/cuttlefish 0.1.0-alpha.1
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 +21 -0
- package/README.md +79 -0
- package/dist/api/board-types.d.ts +1 -0
- package/dist/api/board-types.js +4 -0
- package/dist/api/capabilities.d.ts +12 -0
- package/dist/api/capabilities.js +1 -0
- package/dist/api/config.d.ts +120 -0
- package/dist/api/config.js +7 -0
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.js +2 -0
- package/dist/api/schema/builder.d.ts +14 -0
- package/dist/api/schema/builder.js +15 -0
- package/dist/api/schema/index.d.ts +2 -0
- package/dist/api/schema/index.js +1 -0
- package/dist/api/schema/types.d.ts +257 -0
- package/dist/api/schema/types.js +4 -0
- package/dist/api/shared/async-runtime-static.d.ts +8 -0
- package/dist/api/shared/async-runtime-static.js +201 -0
- package/dist/api/shared/async-types.d.ts +42 -0
- package/dist/api/shared/async-types.js +8 -0
- package/dist/api/shared/board-resolver.d.ts +12 -0
- package/dist/api/shared/board-resolver.js +7 -0
- package/dist/api/shared/cpp-type-ir.d.ts +229 -0
- package/dist/api/shared/cpp-type-ir.js +672 -0
- package/dist/api/shared/display-adapter.d.ts +12 -0
- package/dist/api/shared/display-adapter.js +145 -0
- package/dist/api/shared/display-adapters/eink-mono.d.ts +2 -0
- package/dist/api/shared/display-adapters/eink-mono.js +53 -0
- package/dist/api/shared/display-adapters/sdl.d.ts +2 -0
- package/dist/api/shared/display-adapters/sdl.js +452 -0
- package/dist/api/shared/display-adapters/ssd1309.d.ts +2 -0
- package/dist/api/shared/display-adapters/ssd1309.js +136 -0
- package/dist/api/shared/display-adapters/st7796.d.ts +2 -0
- package/dist/api/shared/display-adapters/st7796.js +132 -0
- package/dist/api/shared/display-capabilities.d.ts +45 -0
- package/dist/api/shared/display-capabilities.js +54 -0
- package/dist/api/shared/display-op-ir.d.ts +62 -0
- package/dist/api/shared/display-op-ir.js +19 -0
- package/dist/api/shared/display-profile.d.ts +265 -0
- package/dist/api/shared/display-profile.js +338 -0
- package/dist/api/shared/graphics-strategy.d.ts +29 -0
- package/dist/api/shared/graphics-strategy.js +11 -0
- package/dist/api/shared/hal-op-ir.d.ts +393 -0
- package/dist/api/shared/hal-op-ir.js +18 -0
- package/dist/api/shared/index.d.ts +26 -0
- package/dist/api/shared/index.js +21 -0
- package/dist/api/shared/ir-core.d.ts +363 -0
- package/dist/api/shared/ir-core.js +8 -0
- package/dist/api/shared/ir-declarations.d.ts +201 -0
- package/dist/api/shared/ir-declarations.js +26 -0
- package/dist/api/shared/ir.d.ts +85 -0
- package/dist/api/shared/ir.js +13 -0
- package/dist/api/shared/platform-strategy.d.ts +402 -0
- package/dist/api/shared/platform-strategy.js +14 -0
- package/dist/api/shared/polyfill-helper-registry.d.ts +11 -0
- package/dist/api/shared/polyfill-helper-registry.js +86 -0
- package/dist/api/shared/polyfill-types.d.ts +33 -0
- package/dist/api/shared/polyfill-types.js +76 -0
- package/dist/api/shared/promise-runtime.d.ts +10 -0
- package/dist/api/shared/promise-runtime.js +244 -0
- package/dist/api/shared/snprintf-types.d.ts +29 -0
- package/dist/api/shared/snprintf-types.js +8 -0
- package/dist/api/shared/string-method-registry.d.ts +53 -0
- package/dist/api/shared/string-method-registry.js +168 -0
- package/dist/api/shared/toolchain-types.d.ts +63 -0
- package/dist/api/shared/toolchain-types.js +71 -0
- package/dist/api/shared/types.d.ts +50 -0
- package/dist/api/shared/types.js +6 -0
- package/dist/ast/parse.d.ts +2 -0
- package/dist/ast/parse.js +4 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +95 -0
- package/dist/cli-utils.d.ts +37 -0
- package/dist/cli-utils.js +250 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +635 -0
- package/dist/config-loader.d.ts +78 -0
- package/dist/config-loader.js +508 -0
- package/dist/config-schema.d.ts +233 -0
- package/dist/config-schema.js +83 -0
- package/dist/create/board-checklist.d.ts +2 -0
- package/dist/create/board-checklist.js +52 -0
- package/dist/create/board-codegen.d.ts +9 -0
- package/dist/create/board-codegen.js +238 -0
- package/dist/create/board-generators.d.ts +12 -0
- package/dist/create/board-generators.js +652 -0
- package/dist/create/board-spec.d.ts +640 -0
- package/dist/create/board-spec.js +215 -0
- package/dist/create/eslint-rules-template.d.ts +2 -0
- package/dist/create/eslint-rules-template.js +672 -0
- package/dist/create/index.d.ts +11 -0
- package/dist/create/index.js +8 -0
- package/dist/create/init-scaffold.d.ts +27 -0
- package/dist/create/init-scaffold.js +150 -0
- package/dist/create/init-templates.d.ts +24 -0
- package/dist/create/init-templates.js +379 -0
- package/dist/create/init-wizard.d.ts +8 -0
- package/dist/create/init-wizard.js +168 -0
- package/dist/debug/breakpoint-loader.d.ts +24 -0
- package/dist/debug/breakpoint-loader.js +137 -0
- package/dist/debug/index.d.ts +3 -0
- package/dist/debug/index.js +7 -0
- package/dist/debug/preprocessor.d.ts +9 -0
- package/dist/debug/preprocessor.js +214 -0
- package/dist/debug/types.d.ts +32 -0
- package/dist/debug/types.js +6 -0
- package/dist/diagnostics/diagnostics-report.d.ts +51 -0
- package/dist/diagnostics/diagnostics-report.js +333 -0
- package/dist/diagnostics/json-schema.d.ts +138 -0
- package/dist/diagnostics/json-schema.js +27 -0
- package/dist/diagnostics/md-writer.d.ts +10 -0
- package/dist/diagnostics/md-writer.js +336 -0
- package/dist/diagnostics/mermaid-builder.d.ts +65 -0
- package/dist/diagnostics/mermaid-builder.js +681 -0
- package/dist/emit/cpp-emitter.d.ts +6 -0
- package/dist/emit/cpp-emitter.js +48 -0
- package/dist/emit/emitters/class-emitter.d.ts +2 -0
- package/dist/emit/emitters/class-emitter.js +523 -0
- package/dist/emit/emitters/emitter-context.d.ts +174 -0
- package/dist/emit/emitters/emitter-context.js +1 -0
- package/dist/emit/emitters/entrypoint-synthesizer.d.ts +2 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +175 -0
- package/dist/emit/emitters/function-emitter-impl.d.ts +19 -0
- package/dist/emit/emitters/function-emitter-impl.js +428 -0
- package/dist/emit/emitters/line-appender.d.ts +15 -0
- package/dist/emit/emitters/line-appender.js +344 -0
- package/dist/emit/emitters/namespace-emitter.d.ts +2 -0
- package/dist/emit/emitters/namespace-emitter.js +324 -0
- package/dist/emit/emitters/output-finalizer.d.ts +4 -0
- package/dist/emit/emitters/output-finalizer.js +267 -0
- package/dist/emit/emitters/setup.d.ts +3 -0
- package/dist/emit/emitters/setup.js +851 -0
- package/dist/emit/emitters/top-level-prep.d.ts +2 -0
- package/dist/emit/emitters/top-level-prep.js +706 -0
- package/dist/emit/emitters/type-decl-emitter.d.ts +2 -0
- package/dist/emit/emitters/type-decl-emitter.js +251 -0
- package/dist/emit/emitters/ui-emitter.d.ts +21 -0
- package/dist/emit/emitters/ui-emitter.js +564 -0
- package/dist/emit/enum-emitter.d.ts +1 -0
- package/dist/emit/enum-emitter.js +1 -0
- package/dist/emit/expression-renderer.d.ts +283 -0
- package/dist/emit/expression-renderer.js +1477 -0
- package/dist/emit/native-helpers-emitter.d.ts +11 -0
- package/dist/emit/native-helpers-emitter.js +34 -0
- package/dist/emit/route-hal-op.d.ts +5 -0
- package/dist/emit/route-hal-op.js +13 -0
- package/dist/emit/snprintf-helpers.d.ts +17 -0
- package/dist/emit/snprintf-helpers.js +462 -0
- package/dist/emit/statement-renderer.d.ts +189 -0
- package/dist/emit/statement-renderer.js +948 -0
- package/dist/emit/utils/async-state-machine.d.ts +42 -0
- package/dist/emit/utils/async-state-machine.js +343 -0
- package/dist/emit/utils/comment-helpers.d.ts +20 -0
- package/dist/emit/utils/comment-helpers.js +31 -0
- package/dist/emit/utils/cpp-helpers.d.ts +47 -0
- package/dist/emit/utils/cpp-helpers.js +85 -0
- package/dist/emit/utils/include-resolver.d.ts +58 -0
- package/dist/emit/utils/include-resolver.js +155 -0
- package/dist/emit/utils/index.d.ts +8 -0
- package/dist/emit/utils/index.js +12 -0
- package/dist/emit/utils/type-inference.d.ts +159 -0
- package/dist/emit/utils/type-inference.js +559 -0
- package/dist/eslint-check.d.ts +10 -0
- package/dist/eslint-check.js +102 -0
- package/dist/framework-package.d.ts +10 -0
- package/dist/framework-package.js +58 -0
- package/dist/framework-registry.d.ts +39 -0
- package/dist/framework-registry.js +30 -0
- package/dist/incremental-cache.d.ts +116 -0
- package/dist/incremental-cache.js +335 -0
- package/dist/ir/adc-range-validation.d.ts +11 -0
- package/dist/ir/adc-range-validation.js +250 -0
- package/dist/ir/ast-node-utils.d.ts +8 -0
- package/dist/ir/ast-node-utils.js +32 -0
- package/dist/ir/board-pin-utils.d.ts +13 -0
- package/dist/ir/board-pin-utils.js +65 -0
- package/dist/ir/board-resolver.d.ts +36 -0
- package/dist/ir/board-resolver.js +437 -0
- package/dist/ir/build-ir-state.d.ts +167 -0
- package/dist/ir/build-ir-state.js +306 -0
- package/dist/ir/build-ir.d.ts +2 -0
- package/dist/ir/build-ir.js +808 -0
- package/dist/ir/call-graph.d.ts +35 -0
- package/dist/ir/call-graph.js +194 -0
- package/dist/ir/compile-time-only.d.ts +2 -0
- package/dist/ir/compile-time-only.js +16 -0
- package/dist/ir/declaration-builders.d.ts +9 -0
- package/dist/ir/declaration-builders.js +608 -0
- package/dist/ir/entry-points.d.ts +30 -0
- package/dist/ir/entry-points.js +191 -0
- package/dist/ir/expression-to-ir.d.ts +5 -0
- package/dist/ir/expression-to-ir.js +2249 -0
- package/dist/ir/extract-property-chain.d.ts +10 -0
- package/dist/ir/extract-property-chain.js +30 -0
- package/dist/ir/feature-prescan.d.ts +3 -0
- package/dist/ir/feature-prescan.js +43 -0
- package/dist/ir/feature-registry.d.ts +30 -0
- package/dist/ir/feature-registry.js +816 -0
- package/dist/ir/filter.d.ts +7 -0
- package/dist/ir/filter.js +85 -0
- package/dist/ir/function-builder.d.ts +19 -0
- package/dist/ir/function-builder.js +670 -0
- package/dist/ir/hal/hal-emitter.d.ts +62 -0
- package/dist/ir/hal/hal-emitter.js +735 -0
- package/dist/ir/hal/hal-parser.d.ts +61 -0
- package/dist/ir/hal/hal-parser.js +473 -0
- package/dist/ir/hal/hal-plugins.d.ts +34 -0
- package/dist/ir/hal/hal-plugins.js +706 -0
- package/dist/ir/hal-resolver.d.ts +5 -0
- package/dist/ir/hal-resolver.js +5 -0
- package/dist/ir/heap-analysis.d.ts +8 -0
- package/dist/ir/heap-analysis.js +350 -0
- package/dist/ir/heap-array-validation.d.ts +24 -0
- package/dist/ir/heap-array-validation.js +29 -0
- package/dist/ir/identifier-collector.d.ts +18 -0
- package/dist/ir/identifier-collector.js +439 -0
- package/dist/ir/interrupt-analysis.d.ts +39 -0
- package/dist/ir/interrupt-analysis.js +467 -0
- package/dist/ir/memory-budget-validation.d.ts +10 -0
- package/dist/ir/memory-budget-validation.js +86 -0
- package/dist/ir/namespace-builder.d.ts +7 -0
- package/dist/ir/namespace-builder.js +152 -0
- package/dist/ir/ownership-analysis.d.ts +9 -0
- package/dist/ir/ownership-analysis.js +1207 -0
- package/dist/ir/peripheral-ownership.d.ts +3 -0
- package/dist/ir/peripheral-ownership.js +152 -0
- package/dist/ir/peripheral-symbols.d.ts +7 -0
- package/dist/ir/peripheral-symbols.js +57 -0
- package/dist/ir/peripheral-usage.d.ts +54 -0
- package/dist/ir/peripheral-usage.js +691 -0
- package/dist/ir/peripheral-validation.d.ts +8 -0
- package/dist/ir/peripheral-validation.js +77 -0
- package/dist/ir/pin-alias-conflict.d.ts +4 -0
- package/dist/ir/pin-alias-conflict.js +34 -0
- package/dist/ir/pin-capability-validation.d.ts +6 -0
- package/dist/ir/pin-capability-validation.js +413 -0
- package/dist/ir/pin-mode-validation.d.ts +10 -0
- package/dist/ir/pin-mode-validation.js +301 -0
- package/dist/ir/pin-safety.d.ts +11 -0
- package/dist/ir/pin-safety.js +58 -0
- package/dist/ir/program-analysis.d.ts +44 -0
- package/dist/ir/program-analysis.js +589 -0
- package/dist/ir/pulldown-validation.d.ts +7 -0
- package/dist/ir/pulldown-validation.js +49 -0
- package/dist/ir/pwm-timer-sharing.d.ts +4 -0
- package/dist/ir/pwm-timer-sharing.js +93 -0
- package/dist/ir/reachability.d.ts +68 -0
- package/dist/ir/reachability.js +224 -0
- package/dist/ir/register-decorators.d.ts +6 -0
- package/dist/ir/register-decorators.js +49 -0
- package/dist/ir/render-expr.d.ts +4 -0
- package/dist/ir/render-expr.js +127 -0
- package/dist/ir/resource-analysis.d.ts +19 -0
- package/dist/ir/resource-analysis.js +153 -0
- package/dist/ir/statement-to-ir.d.ts +23 -0
- package/dist/ir/statement-to-ir.js +349 -0
- package/dist/ir/symbol-table.d.ts +68 -0
- package/dist/ir/symbol-table.js +179 -0
- package/dist/ir/symbol-types.d.ts +56 -0
- package/dist/ir/symbol-types.js +107 -0
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +4 -0
- package/dist/ir/timer0-pwm-timing-conflict.js +71 -0
- package/dist/ir/timing-validation.d.ts +7 -0
- package/dist/ir/timing-validation.js +95 -0
- package/dist/ir/transformers/array-methods.d.ts +8 -0
- package/dist/ir/transformers/array-methods.js +493 -0
- package/dist/ir/transformers/call-statement.d.ts +5 -0
- package/dist/ir/transformers/call-statement.js +758 -0
- package/dist/ir/transformers/callback-context-registry.d.ts +20 -0
- package/dist/ir/transformers/callback-context-registry.js +55 -0
- package/dist/ir/transformers/canvas-lowering.d.ts +42 -0
- package/dist/ir/transformers/canvas-lowering.js +249 -0
- package/dist/ir/transformers/control-flow.d.ts +8 -0
- package/dist/ir/transformers/control-flow.js +508 -0
- package/dist/ir/transformers/expressions.d.ts +7 -0
- package/dist/ir/transformers/expressions.js +406 -0
- package/dist/ir/transformers/hal-call-resolver.d.ts +29 -0
- package/dist/ir/transformers/hal-call-resolver.js +274 -0
- package/dist/ir/transformers/hal-emit-helpers.d.ts +14 -0
- package/dist/ir/transformers/hal-emit-helpers.js +63 -0
- package/dist/ir/transformers/namespace-methods.d.ts +20 -0
- package/dist/ir/transformers/namespace-methods.js +110 -0
- package/dist/ir/transformers/register-assignment.d.ts +5 -0
- package/dist/ir/transformers/register-assignment.js +56 -0
- package/dist/ir/transformers/ui-call-resolver.d.ts +149 -0
- package/dist/ir/transformers/ui-call-resolver.js +1136 -0
- package/dist/ir/transformers/ui-callback-lowering.d.ts +62 -0
- package/dist/ir/transformers/ui-callback-lowering.js +623 -0
- package/dist/ir/transformers/ui-mount.d.ts +20 -0
- package/dist/ir/transformers/ui-mount.js +35 -0
- package/dist/ir/transformers/ui-reactive.d.ts +68 -0
- package/dist/ir/transformers/ui-reactive.js +129 -0
- package/dist/ir/transformers/variables.d.ts +14 -0
- package/dist/ir/transformers/variables.js +1045 -0
- package/dist/ir/try-catch-validation.d.ts +26 -0
- package/dist/ir/try-catch-validation.js +128 -0
- package/dist/ir/type-resolution.d.ts +31 -0
- package/dist/ir/type-resolution.js +977 -0
- package/dist/ir/ui-element-auto-wire.d.ts +50 -0
- package/dist/ir/ui-element-auto-wire.js +218 -0
- package/dist/ir/unit-suspicion-validation.d.ts +12 -0
- package/dist/ir/unit-suspicion-validation.js +296 -0
- package/dist/ir/utils/walk-ir.d.ts +6 -0
- package/dist/ir/utils/walk-ir.js +162 -0
- package/dist/ir/validation-orchestrator.d.ts +4 -0
- package/dist/ir/validation-orchestrator.js +45 -0
- package/dist/libdef/base-class-resolver.d.ts +23 -0
- package/dist/libdef/base-class-resolver.js +50 -0
- package/dist/libdef/cpp-to-decl.d.ts +34 -0
- package/dist/libdef/cpp-to-decl.js +584 -0
- package/dist/libdef/header-parser.d.ts +53 -0
- package/dist/libdef/header-parser.js +269 -0
- package/dist/libdef/registry.d.ts +10 -0
- package/dist/libdef/registry.js +142 -0
- package/dist/mapping/peripheral-names.d.ts +23 -0
- package/dist/mapping/peripheral-names.js +63 -0
- package/dist/mapping/source-map.d.ts +46 -0
- package/dist/mapping/source-map.js +207 -0
- package/dist/orchestrator/dts-generator.d.ts +17 -0
- package/dist/orchestrator/dts-generator.js +83 -0
- package/dist/orchestrator/graph-builder.d.ts +18 -0
- package/dist/orchestrator/graph-builder.js +218 -0
- package/dist/orchestrator/semantic-facts-verifier.d.ts +38 -0
- package/dist/orchestrator/semantic-facts-verifier.js +121 -0
- package/dist/orchestrator/semantic-facts.d.ts +141 -0
- package/dist/orchestrator/semantic-facts.js +652 -0
- package/dist/orchestrator/type-checker.d.ts +39 -0
- package/dist/orchestrator/type-checker.js +760 -0
- package/dist/platform/async-runtime.d.ts +8 -0
- package/dist/platform/async-runtime.js +26 -0
- package/dist/platform/generic-strategy.d.ts +101 -0
- package/dist/platform/generic-strategy.js +289 -0
- package/dist/platform/index.d.ts +4 -0
- package/dist/platform/index.js +9 -0
- package/dist/platform/registry.d.ts +21 -0
- package/dist/platform/registry.js +42 -0
- package/dist/platform/toolchain.d.ts +4 -0
- package/dist/platform/toolchain.js +43 -0
- package/dist/preview/client.d.ts +1 -0
- package/dist/preview/client.js +137 -0
- package/dist/preview/server.d.ts +5 -0
- package/dist/preview/server.js +199 -0
- package/dist/profiler/index.d.ts +28 -0
- package/dist/profiler/index.js +28 -0
- package/dist/profiler/profiler.d.ts +95 -0
- package/dist/profiler/profiler.js +338 -0
- package/dist/profiler/types.d.ts +87 -0
- package/dist/profiler/types.js +12 -0
- package/dist/stores/display-profile-store.d.ts +16 -0
- package/dist/stores/display-profile-store.js +48 -0
- package/dist/stores/theme-store.d.ts +13 -0
- package/dist/stores/theme-store.js +30 -0
- package/dist/testing.d.ts +45 -0
- package/dist/testing.js +47 -0
- package/dist/transpile/resolution.d.ts +29 -0
- package/dist/transpile/resolution.js +282 -0
- package/dist/transpile.d.ts +3 -0
- package/dist/transpile.js +722 -0
- package/dist/types.d.ts +217 -0
- package/dist/types.js +1 -0
- package/dist/ui/ui-bridge.d.ts +4 -0
- package/dist/ui/ui-bridge.js +34 -0
- package/dist/ui-hook.d.ts +84 -0
- package/dist/ui-hook.js +45 -0
- package/dist/utils/cli.d.ts +3 -0
- package/dist/utils/cli.js +463 -0
- package/dist/utils/fs.d.ts +4 -0
- package/dist/utils/fs.js +23 -0
- package/dist/utils/logger.d.ts +2 -0
- package/dist/utils/logger.js +8 -0
- package/dist/utils/strings.d.ts +35 -0
- package/dist/utils/strings.js +142 -0
- package/dist/utils/ui.d.ts +66 -0
- package/dist/utils/ui.js +149 -0
- package/dist/watch.d.ts +35 -0
- package/dist/watch.js +111 -0
- package/package.json +127 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { scaffoldProject, normalizeProjectName, KNOWN_TARGETS, KNOWN_BOARDS, registerKnownTarget, printInitNextSteps } from './init-scaffold.js';
|
|
2
|
+
export { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateGitignore, generateEslintConfig, } from './init-templates.js';
|
|
3
|
+
export { runInitWizard } from './init-wizard.js';
|
|
4
|
+
// Board codegen tool (`cuttlefish board add`)
|
|
5
|
+
export { scaffoldBoardPackages } from './board-codegen.js';
|
|
6
|
+
export { generateFrameworkChecklist } from './board-checklist.js';
|
|
7
|
+
export { parseBoardSpec, safeParseBoardSpec, stripJsonc, BoardSpecSchema } from './board-spec.js';
|
|
8
|
+
export * as BoardGenerators from './board-generators.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ArchitectureIdentifier } from "../api/index.js";
|
|
2
|
+
import type { InitProjectOptions } from "./init-templates.js";
|
|
3
|
+
export interface KnownTarget {
|
|
4
|
+
id: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
isNative: boolean;
|
|
7
|
+
architecture?: ArchitectureIdentifier;
|
|
8
|
+
boardPackage?: string;
|
|
9
|
+
frameworkPackage: string;
|
|
10
|
+
framework: string;
|
|
11
|
+
buildTarget?: string;
|
|
12
|
+
mcu?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function registerKnownTarget(target: KnownTarget): void;
|
|
15
|
+
export declare const KNOWN_TARGETS: ReadonlyArray<KnownTarget>;
|
|
16
|
+
/** @deprecated Use KNOWN_TARGETS */
|
|
17
|
+
export declare const KNOWN_BOARDS: KnownTarget[];
|
|
18
|
+
/** @deprecated Use KnownTarget */
|
|
19
|
+
export type KnownBoard = KnownTarget;
|
|
20
|
+
export declare function normalizeProjectName(name: string): string;
|
|
21
|
+
export interface ScaffoldProjectResult {
|
|
22
|
+
createdFiles: string[];
|
|
23
|
+
outDir: string;
|
|
24
|
+
options: InitProjectOptions;
|
|
25
|
+
}
|
|
26
|
+
export declare function scaffoldProject(options: InitProjectOptions, outDir?: string): ScaffoldProjectResult;
|
|
27
|
+
export declare function printInitNextSteps(options: InitProjectOptions, outDir: string): void;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { generateProjectPackageJson, generateProjectTsconfig, generateProjectConfig, generateProjectEnvDts, generateStarterSketch, generateGitignore, generateBoardForwardingFile, generateEslintConfig, } from "./init-templates.js";
|
|
5
|
+
import { generateEslintRules } from "./eslint-rules-template.js";
|
|
6
|
+
const _knownTargets = [
|
|
7
|
+
{
|
|
8
|
+
id: 'native',
|
|
9
|
+
displayName: 'Native Desktop',
|
|
10
|
+
isNative: true,
|
|
11
|
+
frameworkPackage: '@typecad/framework-native',
|
|
12
|
+
framework: 'native',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'arduino-uno',
|
|
16
|
+
displayName: 'Arduino Uno',
|
|
17
|
+
isNative: false,
|
|
18
|
+
architecture: 'avr',
|
|
19
|
+
boardPackage: '@typecad/board-arduino-uno',
|
|
20
|
+
frameworkPackage: '@typecad/framework-arduino',
|
|
21
|
+
framework: 'arduino',
|
|
22
|
+
buildTarget: 'arduino:avr:uno',
|
|
23
|
+
mcu: 'atmega328p',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'esp32-devkit',
|
|
27
|
+
displayName: 'ESP32 DevKit',
|
|
28
|
+
isNative: false,
|
|
29
|
+
architecture: 'esp32',
|
|
30
|
+
boardPackage: '@typecad/board-esp32-devkit',
|
|
31
|
+
frameworkPackage: '@typecad/framework-arduino',
|
|
32
|
+
framework: 'arduino',
|
|
33
|
+
buildTarget: 'esp32:esp32:esp32',
|
|
34
|
+
mcu: 'esp32',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'esp32s3',
|
|
38
|
+
displayName: 'ESP32-S3',
|
|
39
|
+
isNative: false,
|
|
40
|
+
architecture: 'esp32s3',
|
|
41
|
+
boardPackage: '@typecad/board-esp32s3',
|
|
42
|
+
frameworkPackage: '@typecad/framework-arduino',
|
|
43
|
+
framework: 'arduino',
|
|
44
|
+
buildTarget: 'esp32:esp32:esp32s3',
|
|
45
|
+
mcu: 'esp32s3',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'esp32c3',
|
|
49
|
+
displayName: 'ESP32-C3',
|
|
50
|
+
isNative: false,
|
|
51
|
+
architecture: 'esp32c3',
|
|
52
|
+
boardPackage: '@typecad/board-esp32c3',
|
|
53
|
+
frameworkPackage: '@typecad/framework-arduino',
|
|
54
|
+
framework: 'arduino',
|
|
55
|
+
buildTarget: 'esp32:esp32:esp32c3',
|
|
56
|
+
mcu: 'esp32c3',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'esp32c6',
|
|
60
|
+
displayName: 'ESP32-C6',
|
|
61
|
+
isNative: false,
|
|
62
|
+
architecture: 'esp32c6',
|
|
63
|
+
boardPackage: '@typecad/board-esp32c6',
|
|
64
|
+
frameworkPackage: '@typecad/framework-arduino',
|
|
65
|
+
framework: 'arduino',
|
|
66
|
+
buildTarget: 'esp32:esp32:esp32c6',
|
|
67
|
+
mcu: 'esp32c6',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
export function registerKnownTarget(target) {
|
|
71
|
+
const existing = _knownTargets.findIndex(t => t.id === target.id);
|
|
72
|
+
if (existing >= 0) {
|
|
73
|
+
_knownTargets[existing] = target;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
_knownTargets.push(target);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export const KNOWN_TARGETS = _knownTargets;
|
|
80
|
+
/** @deprecated Use KNOWN_TARGETS */
|
|
81
|
+
export const KNOWN_BOARDS = _knownTargets;
|
|
82
|
+
export function normalizeProjectName(name) {
|
|
83
|
+
return name
|
|
84
|
+
.toLowerCase()
|
|
85
|
+
.replace(/[\s_]+/g, '-')
|
|
86
|
+
.replace(/[^a-z0-9-]/g, '')
|
|
87
|
+
.replace(/-+/g, '-')
|
|
88
|
+
.replace(/^-|-$/g, '');
|
|
89
|
+
}
|
|
90
|
+
export function scaffoldProject(options, outDir) {
|
|
91
|
+
const resolvedOutDir = outDir
|
|
92
|
+
? path.resolve(outDir)
|
|
93
|
+
: path.resolve(process.cwd(), options.projectName);
|
|
94
|
+
if (fs.existsSync(resolvedOutDir)) {
|
|
95
|
+
const contents = fs.readdirSync(resolvedOutDir);
|
|
96
|
+
if (contents.length > 0) {
|
|
97
|
+
throw new Error(`Directory '${resolvedOutDir}' already exists and is not empty. ` +
|
|
98
|
+
`Choose a different project name or use --outDir to specify a different location.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const srcDir = path.join(resolvedOutDir, 'src');
|
|
102
|
+
const cuttlefishDir = path.join(resolvedOutDir, '.cuttlefish');
|
|
103
|
+
const createdFiles = [];
|
|
104
|
+
fs.mkdirSync(srcDir, { recursive: true });
|
|
105
|
+
// .cuttlefish/ holds generated boilerplate (env.d.ts, eslint config, board.ts)
|
|
106
|
+
fs.mkdirSync(cuttlefishDir, { recursive: true });
|
|
107
|
+
function writeFile(fileName, content) {
|
|
108
|
+
const filePath = path.join(resolvedOutDir, fileName);
|
|
109
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
110
|
+
createdFiles.push(filePath);
|
|
111
|
+
return filePath;
|
|
112
|
+
}
|
|
113
|
+
writeFile('package.json', generateProjectPackageJson(options));
|
|
114
|
+
writeFile('tsconfig.json', generateProjectTsconfig(options));
|
|
115
|
+
writeFile('cuttlefish.config.ts', generateProjectConfig(options));
|
|
116
|
+
writeFile('.cuttlefish/cuttlefish-env.d.ts', generateProjectEnvDts(options));
|
|
117
|
+
writeFile('.cuttlefish/eslint.config.mjs', generateEslintConfig(options));
|
|
118
|
+
writeFile('.cuttlefish/eslint-transpiler-rules.mjs', generateEslintRules(options));
|
|
119
|
+
writeFile('.gitignore', generateGitignore(options));
|
|
120
|
+
if (options.boardPackage) {
|
|
121
|
+
const boardFilePath = path.join(cuttlefishDir, 'board.ts');
|
|
122
|
+
fs.writeFileSync(boardFilePath, generateBoardForwardingFile(options.boardPackage), 'utf-8');
|
|
123
|
+
createdFiles.push(boardFilePath);
|
|
124
|
+
}
|
|
125
|
+
if (options.includeSketch) {
|
|
126
|
+
const entryName = 'main.ts';
|
|
127
|
+
const sketchPath = path.join(srcDir, entryName);
|
|
128
|
+
fs.writeFileSync(sketchPath, generateStarterSketch(options), 'utf-8');
|
|
129
|
+
createdFiles.push(sketchPath);
|
|
130
|
+
}
|
|
131
|
+
return { createdFiles, outDir: resolvedOutDir, options };
|
|
132
|
+
}
|
|
133
|
+
export function printInitNextSteps(options, outDir) {
|
|
134
|
+
const relativeDir = path.relative(process.cwd(), outDir) || '.';
|
|
135
|
+
console.log();
|
|
136
|
+
console.log(chalk.cyan(`⤳ Cuttlefish`));
|
|
137
|
+
console.log();
|
|
138
|
+
console.log(chalk.bold.white("Next steps:"));
|
|
139
|
+
console.log(chalk.dim(` cd ${relativeDir}`));
|
|
140
|
+
console.log(chalk.dim(` npm install`));
|
|
141
|
+
console.log(` ${chalk.cyan("npm run compile")}`);
|
|
142
|
+
if (!options.isNative) {
|
|
143
|
+
const portHint = process.platform === 'win32' ? 'COM4' : '/dev/ttyACM0';
|
|
144
|
+
console.log();
|
|
145
|
+
console.log(chalk.bold.white("To upload to your board:"));
|
|
146
|
+
console.log(` ${chalk.cyan("npm run upload")}`);
|
|
147
|
+
console.log();
|
|
148
|
+
console.log(chalk.dim(`Edit ${chalk.white("package.json")} to change the serial port from ${chalk.white(portHint)} to your port.`));
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ArchitectureIdentifier } from '../api/index.js';
|
|
2
|
+
export interface InitProjectOptions {
|
|
3
|
+
projectName: string;
|
|
4
|
+
targetId: string;
|
|
5
|
+
targetDisplayName: string;
|
|
6
|
+
isNative: boolean;
|
|
7
|
+
architecture?: ArchitectureIdentifier;
|
|
8
|
+
boardPackage?: string;
|
|
9
|
+
frameworkPackage: string;
|
|
10
|
+
framework: string;
|
|
11
|
+
buildTarget?: string;
|
|
12
|
+
mcu?: string;
|
|
13
|
+
baudRate?: number;
|
|
14
|
+
includeSketch: boolean;
|
|
15
|
+
toolchainType?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function generateProjectPackageJson(options: InitProjectOptions): string;
|
|
18
|
+
export declare function generateProjectTsconfig(options: InitProjectOptions): string;
|
|
19
|
+
export declare function generateProjectConfig(options: InitProjectOptions): string;
|
|
20
|
+
export declare function generateProjectEnvDts(options: InitProjectOptions): string;
|
|
21
|
+
export declare function generateStarterSketch(options: InitProjectOptions): string;
|
|
22
|
+
export declare function generateBoardForwardingFile(boardPackage: string): string;
|
|
23
|
+
export declare function generateGitignore(_options: InitProjectOptions): string;
|
|
24
|
+
export declare function generateEslintConfig(_options: InitProjectOptions): string;
|
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { LINT_RULES } from '../ir/feature-registry.js';
|
|
2
|
+
export function generateProjectPackageJson(options) {
|
|
3
|
+
const { projectName, frameworkPackage, boardPackage } = options;
|
|
4
|
+
const deps = {
|
|
5
|
+
"@typecad/cuttlefish": "^0.1.0-alpha.1",
|
|
6
|
+
[frameworkPackage]: "^0.1.0-alpha.1",
|
|
7
|
+
};
|
|
8
|
+
if (boardPackage) {
|
|
9
|
+
deps[boardPackage] = "^0.1.0-alpha.1";
|
|
10
|
+
}
|
|
11
|
+
const depsJson = Object.entries(deps)
|
|
12
|
+
.map(([k, v]) => ` "${k}": "${v}"`)
|
|
13
|
+
.join(',\n');
|
|
14
|
+
// The scaffolded eslint.config.mjs imports @typescript-eslint/parser and the
|
|
15
|
+
// eslint-transpiler-rules plugin (which is plain JS, no dep). Without these
|
|
16
|
+
// devDependencies `npm run lint` fails to resolve the parser/plugin in a
|
|
17
|
+
// freshly created project. Versions mirror the repo demo's package.json.
|
|
18
|
+
const devDepsJson = [
|
|
19
|
+
' "eslint": "^10.4.1"',
|
|
20
|
+
' "@typescript-eslint/parser": "^8.61.0"',
|
|
21
|
+
' "@typescript-eslint/eslint-plugin": "^8.61.0"',
|
|
22
|
+
].join(',\n');
|
|
23
|
+
if (options.isNative) {
|
|
24
|
+
return `{
|
|
25
|
+
"name": "${projectName}",
|
|
26
|
+
"version": "1.0.0",
|
|
27
|
+
"private": true,
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "cuttlefish build",
|
|
30
|
+
"compile": "cuttlefish build --compile",
|
|
31
|
+
"lint": "eslint --config .cuttlefish/eslint.config.mjs src/"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
${depsJson}
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
${devDepsJson}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
return `{
|
|
43
|
+
"name": "${projectName}",
|
|
44
|
+
"version": "1.0.0",
|
|
45
|
+
"private": true,
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "cuttlefish build",
|
|
48
|
+
"compile": "cuttlefish build --compile",
|
|
49
|
+
"upload": "cuttlefish build --compile --upload",
|
|
50
|
+
"monitor": "cuttlefish build --compile --upload --monitor",
|
|
51
|
+
"lint": "eslint --config .cuttlefish/eslint.config.mjs src/"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
${depsJson}
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
${devDepsJson}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
export function generateProjectTsconfig(options) {
|
|
63
|
+
const paths = options.boardPackage
|
|
64
|
+
? `,
|
|
65
|
+
"paths": {
|
|
66
|
+
"@typecad/board": ["./.cuttlefish/board.ts"]
|
|
67
|
+
}`
|
|
68
|
+
: '';
|
|
69
|
+
return `{
|
|
70
|
+
"compilerOptions": {
|
|
71
|
+
"target": "ES2022",
|
|
72
|
+
"module": "ES2022",
|
|
73
|
+
"moduleResolution": "bundler",
|
|
74
|
+
"lib": ["ES2022"],
|
|
75
|
+
"strict": true,
|
|
76
|
+
"strictNullChecks": true,
|
|
77
|
+
"noImplicitAny": true,
|
|
78
|
+
"noImplicitThis": true,
|
|
79
|
+
"noImplicitOverride": true,
|
|
80
|
+
"exactOptionalPropertyTypes": true,
|
|
81
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
82
|
+
"esModuleInterop": true,
|
|
83
|
+
"skipLibCheck": true,
|
|
84
|
+
"forceConsistentCasingInFileNames": true,
|
|
85
|
+
"noEmit": true,
|
|
86
|
+
"resolveJsonModule": true,
|
|
87
|
+
"allowArbitraryExtensions": true,
|
|
88
|
+
"rootDirs": ["src", "types"]${paths}
|
|
89
|
+
},
|
|
90
|
+
"include": ["src/**/*.ts", "types/**/*.ts", "cuttlefish.config.ts"${options.boardPackage ? ', ".cuttlefish/cuttlefish-env.d.ts"' : ''}]
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
export function generateProjectConfig(options) {
|
|
95
|
+
if (options.isNative) {
|
|
96
|
+
return `// ---------------------------------------------------------------------------
|
|
97
|
+
// cuttlefish.config.ts — Project configuration
|
|
98
|
+
//
|
|
99
|
+
// Auto-generated by 'cuttlefish create'. Edit to customise your build.
|
|
100
|
+
// ---------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
const config = {
|
|
103
|
+
// Entry point — the main TypeScript file to transpile
|
|
104
|
+
entry: './src/main.ts',
|
|
105
|
+
|
|
106
|
+
// Framework package — controls code generation strategy
|
|
107
|
+
framework: '${options.frameworkPackage}',
|
|
108
|
+
|
|
109
|
+
// Output options
|
|
110
|
+
output: {
|
|
111
|
+
optimize: 'speed',
|
|
112
|
+
outDir: './out',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default config;
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
const buildTarget = options.buildTarget;
|
|
120
|
+
const resolvedToolchain = options.toolchainType ?? 'arduino-cli';
|
|
121
|
+
const buildTargetLine = buildTarget ? `\n // Framework data\n frameworkData: {\n buildTarget: '${buildTarget}',\n },` : '';
|
|
122
|
+
const mcuLine = options.mcu
|
|
123
|
+
? `\n // MCU package — provides silicon-level pin definitions\n mcu: '${options.mcu.startsWith('@') ? options.mcu : `@typecad/mcu-${options.mcu}`}',\n`
|
|
124
|
+
: '';
|
|
125
|
+
const boardLine = options.boardPackage
|
|
126
|
+
? `\n // Board package — provides pin definitions and board constants\n board: '${options.boardPackage}',`
|
|
127
|
+
: '';
|
|
128
|
+
const portHint = process.platform === 'win32' ? 'COM4' : '/dev/ttyACM0';
|
|
129
|
+
const baudLine = options.baudRate ? `\n\n // Console polyfill configuration\n console: {\n baudRate: ${options.baudRate},\n // Serial port for upload/monitor. Override with --port on the CLI.\n port: '${portHint}',\n },` : '';
|
|
130
|
+
return `// ---------------------------------------------------------------------------
|
|
131
|
+
// cuttlefish.config.ts — Project configuration
|
|
132
|
+
//
|
|
133
|
+
// Auto-generated by 'cuttlefish create'. Edit to customise your build.
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
|
|
136
|
+
import type { CuttlefishConfig } from '@typecad/cuttlefish/api';
|
|
137
|
+
|
|
138
|
+
const config: CuttlefishConfig = {
|
|
139
|
+
// Entry point — the main TypeScript file to transpile
|
|
140
|
+
entry: './src/main.ts',
|
|
141
|
+
|
|
142
|
+
// Target architecture
|
|
143
|
+
target: '${options.architecture}',${mcuLine}${boardLine}
|
|
144
|
+
|
|
145
|
+
// Framework package — controls code generation strategy
|
|
146
|
+
framework: '${options.frameworkPackage}',${buildTargetLine}
|
|
147
|
+
|
|
148
|
+
// Output / build options
|
|
149
|
+
output: {
|
|
150
|
+
framework: '${options.framework}',
|
|
151
|
+
optimize: 'size',
|
|
152
|
+
outDir: './out',
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
// Toolchain configuration
|
|
156
|
+
toolchain: {
|
|
157
|
+
type: '${resolvedToolchain}',
|
|
158
|
+
},${baudLine}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export default config;
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
export function generateProjectEnvDts(options) {
|
|
165
|
+
if (!options.boardPackage) {
|
|
166
|
+
return `// ---------------------------------------------------------------------------
|
|
167
|
+
// cuttlefish-env.d.ts — Global type declarations
|
|
168
|
+
//
|
|
169
|
+
// Auto-generated by 'cuttlefish create'. Do not edit manually.
|
|
170
|
+
// ---------------------------------------------------------------------------
|
|
171
|
+
|
|
172
|
+
declare global {
|
|
173
|
+
type Owned<T = unknown> = T;
|
|
174
|
+
type Shared<T = unknown> = T;
|
|
175
|
+
type Mutable<T = unknown> = T;
|
|
176
|
+
|
|
177
|
+
type uint8_t = number;
|
|
178
|
+
type int8_t = number;
|
|
179
|
+
type uint16_t = number;
|
|
180
|
+
type int16_t = number;
|
|
181
|
+
type uint32_t = number;
|
|
182
|
+
type int32_t = number;
|
|
183
|
+
type size_t = number;
|
|
184
|
+
type float = number;
|
|
185
|
+
type double = number;
|
|
186
|
+
|
|
187
|
+
// console — declared here (not pulled from lib.dom) so this project does not
|
|
188
|
+
// need "dom" in tsconfig lib just to type console.log. Avoiding lib.dom also
|
|
189
|
+
// keeps DOM global type names (Node, Element, Event, ...) out of scope, so a
|
|
190
|
+
// user class named e.g. Node is not shadowed by the DOM global. The
|
|
191
|
+
// transpiler regenerates this file on build and may merge extra members
|
|
192
|
+
// (readLine/readCharacter) onto the Console interface.
|
|
193
|
+
interface Console {
|
|
194
|
+
log(...args: unknown[]): void;
|
|
195
|
+
info(...args: unknown[]): void;
|
|
196
|
+
debug(...args: unknown[]): void;
|
|
197
|
+
warn(...args: unknown[]): void;
|
|
198
|
+
error(...args: unknown[]): void;
|
|
199
|
+
}
|
|
200
|
+
const console: Console;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export {};
|
|
204
|
+
`;
|
|
205
|
+
}
|
|
206
|
+
return `// ---------------------------------------------------------------------------
|
|
207
|
+
// cuttlefish-env.d.ts — Virtual module declaration for '@typecad/board'
|
|
208
|
+
//
|
|
209
|
+
// Auto-generated by 'cuttlefish create'. Do not edit manually.
|
|
210
|
+
// To change the board, update cuttlefish.config.ts and re-run the transpiler.
|
|
211
|
+
//
|
|
212
|
+
// Board: ${options.targetDisplayName}
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
declare global {
|
|
216
|
+
type Owned<T = unknown> = T;
|
|
217
|
+
type Shared<T = unknown> = T;
|
|
218
|
+
type Mutable<T = unknown> = T;
|
|
219
|
+
|
|
220
|
+
type uint8_t = number;
|
|
221
|
+
type int8_t = number;
|
|
222
|
+
type uint16_t = number;
|
|
223
|
+
type int16_t = number;
|
|
224
|
+
type uint32_t = number;
|
|
225
|
+
type int32_t = number;
|
|
226
|
+
type size_t = number;
|
|
227
|
+
type float = number;
|
|
228
|
+
type double = number;
|
|
229
|
+
|
|
230
|
+
// console — declared here (not pulled from lib.dom) so this project does not
|
|
231
|
+
// need "dom" in tsconfig lib just to type console.log. Avoiding lib.dom also
|
|
232
|
+
// keeps DOM global type names (Node, Element, Event, ...) out of scope, so a
|
|
233
|
+
// user class named e.g. Node is not shadowed by the DOM global. The
|
|
234
|
+
// transpiler regenerates this file on build and may merge extra members
|
|
235
|
+
// (readLine/readCharacter) onto the Console interface.
|
|
236
|
+
interface Console {
|
|
237
|
+
log(...args: unknown[]): void;
|
|
238
|
+
info(...args: unknown[]): void;
|
|
239
|
+
debug(...args: unknown[]): void;
|
|
240
|
+
warn(...args: unknown[]): void;
|
|
241
|
+
error(...args: unknown[]): void;
|
|
242
|
+
}
|
|
243
|
+
const console: Console;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
declare module '@typecad/board' {
|
|
247
|
+
export * from './board.js';
|
|
248
|
+
export type Owned<T = unknown> = T;
|
|
249
|
+
export type Shared<T = unknown> = T;
|
|
250
|
+
export type Mutable<T = unknown> = T;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export {};
|
|
254
|
+
`;
|
|
255
|
+
}
|
|
256
|
+
export function generateStarterSketch(options) {
|
|
257
|
+
if (options.isNative) {
|
|
258
|
+
return `// ---------------------------------------------------------------------------
|
|
259
|
+
// Hello World — Native desktop application
|
|
260
|
+
//
|
|
261
|
+
// Compiles to a native executable via g++/clang++.
|
|
262
|
+
// ---------------------------------------------------------------------------
|
|
263
|
+
|
|
264
|
+
function fibonacci(n: number): number {
|
|
265
|
+
if (n <= 1) return n;
|
|
266
|
+
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
console.log("Hello from Cuttlefish!");
|
|
270
|
+
console.log("Fibonacci(10) =", fibonacci(10));
|
|
271
|
+
`;
|
|
272
|
+
}
|
|
273
|
+
return `// ---------------------------------------------------------------------------
|
|
274
|
+
// Blink — The classic "Hello World" of embedded
|
|
275
|
+
//
|
|
276
|
+
// Toggles the onboard LED every second using the recommended GPIO pattern.
|
|
277
|
+
// ---------------------------------------------------------------------------
|
|
278
|
+
|
|
279
|
+
import { LED, delay } from '@typecad/board';
|
|
280
|
+
|
|
281
|
+
const led = LED.asOutput(false);
|
|
282
|
+
|
|
283
|
+
while (true) {
|
|
284
|
+
led.toggle();
|
|
285
|
+
delay(1000);
|
|
286
|
+
}
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
export function generateBoardForwardingFile(boardPackage) {
|
|
290
|
+
return `// ---------------------------------------------------------------------------
|
|
291
|
+
// .cuttlefish/board.ts — Dynamically generated forwarding board package
|
|
292
|
+
// ---------------------------------------------------------------------------
|
|
293
|
+
|
|
294
|
+
export * from '${boardPackage}';
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
export function generateGitignore(_options) {
|
|
298
|
+
return `node_modules/
|
|
299
|
+
out/
|
|
300
|
+
dist/
|
|
301
|
+
*.thcppmap.json
|
|
302
|
+
.cuttlefish-cache.json
|
|
303
|
+
|
|
304
|
+
# Generated boilerplate (regenerated on build — do not commit)
|
|
305
|
+
.cuttlefish/cuttlefish-env.d.ts
|
|
306
|
+
.cuttlefish/eslint.config.mjs
|
|
307
|
+
.cuttlefish/eslint-transpiler-rules.mjs
|
|
308
|
+
`;
|
|
309
|
+
}
|
|
310
|
+
export function generateEslintConfig(_options) {
|
|
311
|
+
// `no-restricted-syntax` selectors are generated from LINT_RULES
|
|
312
|
+
// (packages/cuttlefish/src/ir/feature-registry.ts), the single source of
|
|
313
|
+
// truth shared with build-time prescan diagnostics. See SUPPORT_MATRIX for
|
|
314
|
+
// the per-pattern ❌/🚫 rationale. Do not hand-edit the array below.
|
|
315
|
+
const transpilerRulesJson = JSON.stringify(LINT_RULES.map(({ selector, message }) => ({ selector, message })), null, 2).replace(/\n/g, "\n ");
|
|
316
|
+
return `import tsparser from "@typescript-eslint/parser";
|
|
317
|
+
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
318
|
+
import transpilerPlugin from "./eslint-transpiler-rules.mjs";
|
|
319
|
+
|
|
320
|
+
// Auto-generated from feature-registry.ts LINT_RULES — do not edit by hand.
|
|
321
|
+
const transpilerRules = ${transpilerRulesJson};
|
|
322
|
+
|
|
323
|
+
export default [
|
|
324
|
+
{
|
|
325
|
+
ignores: ["**/dist/**", "**/node_modules/**", "**/*.d.ts", "out/**"],
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
files: ["src/**/*.ts"],
|
|
329
|
+
languageOptions: {
|
|
330
|
+
parser: tsparser,
|
|
331
|
+
parserOptions: {
|
|
332
|
+
// Type-aware parsing so @typescript-eslint/no-explicit-any resolves
|
|
333
|
+
// imported bindings to their real types instead of defaulting to any.
|
|
334
|
+
project: "./tsconfig.json",
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
plugins: {
|
|
338
|
+
"@typescript-eslint": tseslint,
|
|
339
|
+
cuttlefish: transpilerPlugin,
|
|
340
|
+
},
|
|
341
|
+
rules: {
|
|
342
|
+
"no-restricted-syntax": ["error", ...transpilerRules],
|
|
343
|
+
// Core ESLint + @typescript-eslint AOT-safety rules.
|
|
344
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
345
|
+
"no-delete-var": "error",
|
|
346
|
+
"no-eval": "error",
|
|
347
|
+
"no-sparse-arrays": "error",
|
|
348
|
+
"no-restricted-globals": [
|
|
349
|
+
"error",
|
|
350
|
+
{ "name": "Proxy", "message": "[transpiler] Proxy is not supported (no AOT lowering). Avoid." },
|
|
351
|
+
{ "name": "Reflect", "message": "[transpiler] Reflect is not supported (no AOT lowering). Avoid." },
|
|
352
|
+
{ "name": "WeakRef", "message": "[transpiler] WeakRef depends on the GC schedule — bare metal has no GC. Avoid." },
|
|
353
|
+
{ "name": "FinalizationRegistry", "message": "[transpiler] FinalizationRegistry depends on the GC schedule — bare metal has no GC. Avoid." },
|
|
354
|
+
{ "name": "Symbol", "message": "[transpiler] Symbol depends on runtime symbol lookup / the iterator protocol, which has no AOT lowering. Avoid." },
|
|
355
|
+
],
|
|
356
|
+
// Cuttlefish transpiler-compatibility plugin rules.
|
|
357
|
+
"cuttlefish/no-delete-non-map": "error",
|
|
358
|
+
"cuttlefish/no-object-static-non-map": "error",
|
|
359
|
+
"cuttlefish/no-super-outside-method": "error",
|
|
360
|
+
"cuttlefish/no-typeof-non-primitive": "error",
|
|
361
|
+
"cuttlefish/no-destructured-without-init": "error",
|
|
362
|
+
"cuttlefish/no-fractional-to-number-type": "error",
|
|
363
|
+
"cuttlefish/no-array-param-content-mutation": "error",
|
|
364
|
+
"cuttlefish/no-container-functional-methods": "error",
|
|
365
|
+
"cuttlefish/no-undefined-compare-on-get": "error",
|
|
366
|
+
"cuttlefish/no-map-struct-mutation": "error",
|
|
367
|
+
"cuttlefish/no-mutating-method-on-const-collection": "warn",
|
|
368
|
+
"cuttlefish/no-readonly-loop-variable-mutation": "warn",
|
|
369
|
+
"cuttlefish/no-undefined-compare-on-struct-field": "error",
|
|
370
|
+
"cuttlefish/no-typed-array-param-length": "error",
|
|
371
|
+
"cuttlefish/no-typed-array-return": "error",
|
|
372
|
+
"cuttlefish/no-typed-array-field": "error",
|
|
373
|
+
"cuttlefish/no-dynamic-property-access": "error",
|
|
374
|
+
"cuttlefish/no-this-in-free-function": "error",
|
|
375
|
+
},
|
|
376
|
+
},
|
|
377
|
+
];
|
|
378
|
+
`;
|
|
379
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InitProjectOptions } from "./init-templates.js";
|
|
2
|
+
export declare function runInitWizard(partialOptions?: {
|
|
3
|
+
projectName?: string;
|
|
4
|
+
board?: string;
|
|
5
|
+
framework?: string;
|
|
6
|
+
baud?: number;
|
|
7
|
+
noSketch?: boolean;
|
|
8
|
+
}): Promise<InitProjectOptions | null>;
|