@typecad/cuttlefish 1.0.0-alpha.13 → 1.0.0-alpha.15
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/README.md +82 -79
- package/assets/editor-extensions/typecad-debug/README.md +141 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js +347 -0
- package/assets/editor-extensions/typecad-debug/out/extension.js.map +1 -0
- package/assets/editor-extensions/typecad-debug/package.json +76 -0
- package/assets/editor-extensions/typecad-ui/LICENSE +27 -0
- package/assets/editor-extensions/typecad-ui/README.md +52 -0
- package/assets/editor-extensions/typecad-ui/file-icon-dark.png +0 -0
- package/assets/editor-extensions/typecad-ui/file-icon-light.png +0 -0
- package/assets/editor-extensions/typecad-ui/icon.png +0 -0
- package/assets/editor-extensions/typecad-ui/language-configuration.json +43 -0
- package/assets/editor-extensions/typecad-ui/package.json +54 -0
- package/assets/editor-extensions/typecad-ui/snippets/typecad-ui.json +80 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/markdown-ui.json +45 -0
- package/assets/editor-extensions/typecad-ui/syntaxes/typecad-ui.tmLanguage.json +1269 -0
- package/dist/api/config.d.ts +30 -27
- package/dist/api/schema/types.d.ts +20 -3
- package/dist/api/shared/async-runtime-static.d.ts +1 -1
- package/dist/api/shared/async-runtime-static.js +5 -5
- package/dist/api/shared/async-types.d.ts +3 -2
- package/dist/api/shared/board-catalog.d.ts +2 -0
- package/dist/api/shared/board-catalog.js +6 -0
- package/dist/api/shared/board-resolver.d.ts +4 -7
- package/dist/api/shared/board-resolver.js +2 -1
- package/dist/api/shared/coop-scheduler.d.ts +1 -1
- package/dist/api/shared/coop-scheduler.js +1 -1
- package/dist/api/shared/cpp-type-ir.d.ts +1 -1
- package/dist/api/shared/cpp-type-ir.js +1 -1
- package/dist/api/shared/display-profile.d.ts +1 -1
- package/dist/api/shared/display-profile.js +3 -5
- package/dist/api/shared/framework-manifest-registry.d.ts +1 -1
- package/dist/api/shared/framework-manifest-registry.js +0 -1
- package/dist/api/shared/framework-manifest.d.ts +65 -507
- package/dist/api/shared/framework-manifest.js +6 -11
- package/dist/api/shared/hal-op-ir.d.ts +294 -685
- package/dist/api/shared/hal-op-ir.js +31 -65
- package/dist/api/shared/index.d.ts +0 -4
- package/dist/api/shared/index.js +1 -7
- package/dist/api/shared/ir-core.d.ts +6 -0
- package/dist/api/shared/ir-declarations.d.ts +4 -0
- package/dist/api/shared/ir.d.ts +1 -3
- package/dist/api/shared/platform-strategy.d.ts +14 -37
- package/dist/api/shared/polyfill-helper-registry.js +0 -5
- package/dist/api/shared/polyfill-types.js +0 -27
- package/dist/api/shared/promise-runtime.js +3 -3
- package/dist/api/shared/spdx-licenses.d.ts +12 -10
- package/dist/api/shared/spdx-licenses.js +1 -1
- package/dist/api/shared/toolchain-types.d.ts +1 -1
- package/dist/api/shared/toolchain-types.js +3 -3
- package/dist/api/shared/types.d.ts +0 -3
- package/dist/api/shared/validate-framework-manifest.js +13 -33
- package/dist/board-catalog/dts-reader.d.ts +220 -0
- package/dist/board-catalog/dts-reader.js +1052 -0
- package/dist/board-catalog/index.d.ts +11 -0
- package/dist/board-catalog/index.js +12 -0
- package/dist/board-catalog/pinconfig.d.ts +48 -0
- package/dist/board-catalog/pinconfig.js +263 -0
- package/dist/board-catalog/sdk.d.ts +82 -0
- package/dist/board-catalog/sdk.js +180 -0
- package/dist/board-catalog/store.d.ts +196 -0
- package/dist/board-catalog/store.js +363 -0
- package/dist/board-catalog/types.d.ts +233 -0
- package/dist/board-catalog/types.js +7 -0
- package/dist/board-catalog/walker.d.ts +112 -0
- package/dist/board-catalog/walker.js +1101 -0
- package/dist/cli-utils.d.ts +2 -2
- package/dist/cli-utils.js +5 -5
- package/dist/cli.js +227 -244
- package/dist/config-loader.d.ts +14 -19
- package/dist/config-loader.js +242 -78
- package/dist/config-schema.d.ts +19 -227
- package/dist/config-schema.js +9 -8
- package/dist/contract/board-generator.d.ts +4 -4
- package/dist/contract/board-generator.js +16 -5
- package/dist/contract/contract-parser.d.ts +36 -127
- package/dist/contract/contract-parser.js +76 -0
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +70 -21
- package/dist/create/active-board-catalog.d.ts +9 -0
- package/dist/create/active-board-catalog.js +94 -0
- package/dist/create/board-catalog.generated.d.ts +96 -0
- package/dist/create/board-catalog.generated.js +128737 -0
- package/dist/create/board-search.d.ts +23 -0
- package/dist/create/board-search.js +88 -0
- package/dist/create/editor-integration.d.ts +32 -0
- package/dist/create/editor-integration.js +257 -0
- package/dist/create/eslint-rules-template.d.ts +2 -2
- package/dist/create/framework-catalog.d.ts +48 -8
- package/dist/create/framework-catalog.js +58 -44
- package/dist/create/index.d.ts +8 -13
- package/dist/create/index.js +5 -9
- package/dist/create/mcu-target.d.ts +39 -0
- package/dist/create/mcu-target.js +80 -0
- package/dist/create/pack-targets.d.ts +19 -0
- package/dist/create/pack-targets.js +56 -0
- package/dist/create/{init-scaffold.d.ts → scaffold.d.ts} +8 -11
- package/dist/create/{init-scaffold.js → scaffold.js} +28 -87
- package/dist/create/templates.d.ts +51 -0
- package/dist/create/{init-templates.js → templates.js} +135 -116
- package/dist/create/wizard.d.ts +19 -0
- package/dist/create/wizard.js +314 -0
- package/dist/debug/preprocessor.d.ts +5 -0
- package/dist/debug/preprocessor.js +31 -7
- package/dist/diagnostics/diagnostics-report.d.ts +1 -1
- package/dist/diagnostics/diagnostics-report.js +3 -11
- package/dist/diagnostics/json-schema.d.ts +1 -1
- package/dist/diagnostics/md-writer.js +2 -2
- package/dist/diagnostics/mermaid-builder.d.ts +1 -1
- package/dist/diagnostics/mermaid-builder.js +1 -1
- package/dist/emit/cpp-emitter.js +4 -1
- package/dist/emit/emitters/class-emitter.js +32 -4
- package/dist/emit/emitters/emitter-context.d.ts +11 -0
- package/dist/emit/emitters/entrypoint-synthesizer.js +1 -1
- package/dist/emit/emitters/function-emitter-impl.js +33 -17
- package/dist/emit/emitters/output-finalizer.d.ts +7 -0
- package/dist/emit/emitters/output-finalizer.js +31 -23
- package/dist/emit/emitters/setup.js +147 -63
- package/dist/emit/emitters/top-level-prep.js +1 -1
- package/dist/emit/emitters/type-decl-emitter.js +13 -8
- package/dist/emit/emitters/ui-emitter.js +1 -1
- package/dist/emit/expression-renderer.d.ts +3 -3
- package/dist/emit/expression-renderer.js +17 -7
- package/dist/emit/route-hal-op.js +17 -48
- package/dist/emit/snprintf-helpers.d.ts +1 -3
- package/dist/emit/snprintf-helpers.js +1 -39
- package/dist/emit/statement-renderer.d.ts +0 -4
- package/dist/emit/statement-renderer.js +54 -45
- package/dist/emit/utils/async-state-machine.d.ts +16 -9
- package/dist/emit/utils/async-state-machine.js +56 -54
- package/dist/emit/utils/comment-helpers.d.ts +0 -8
- package/dist/emit/utils/comment-helpers.js +1 -1
- package/dist/emit/utils/cpp-helpers.d.ts +2 -2
- package/dist/emit/utils/cpp-helpers.js +2 -2
- package/dist/emit/utils/hal-op-cpp-type.js +4 -6
- package/dist/emit/utils/index.d.ts +3 -3
- package/dist/emit/utils/index.js +3 -3
- package/dist/emit/utils/type-inference.d.ts +1 -29
- package/dist/emit/utils/type-inference.js +0 -75
- package/dist/framework-package.d.ts +3 -0
- package/dist/framework-package.js +23 -6
- package/dist/framework-registry.d.ts +5 -5
- package/dist/frameworks/native/graphics/terminal-preview.d.ts +5 -0
- package/dist/frameworks/native/graphics/terminal-preview.js +33 -0
- package/dist/frameworks/native/index.d.ts +3 -0
- package/dist/frameworks/native/index.js +15 -0
- package/dist/frameworks/native/native-compile.d.ts +17 -0
- package/dist/frameworks/native/native-compile.js +170 -0
- package/dist/frameworks/native/native-config.d.ts +41 -0
- package/dist/frameworks/native/native-config.js +7 -0
- package/dist/frameworks/native/strategy.d.ts +97 -0
- package/dist/frameworks/native/strategy.js +664 -0
- package/dist/ir/board-resolver.d.ts +18 -23
- package/dist/ir/board-resolver.js +43 -401
- package/dist/ir/build-ir-state.d.ts +3 -0
- package/dist/ir/build-ir-state.js +42 -0
- package/dist/ir/build-ir.d.ts +1 -1
- package/dist/ir/build-ir.js +64 -45
- package/dist/ir/declaration-builders.js +1 -0
- package/dist/ir/expression-to-ir.js +17 -10
- package/dist/ir/hal/hal-emitter.d.ts +0 -2
- package/dist/ir/hal/hal-emitter.js +92 -41
- package/dist/ir/hal/hal-parser.d.ts +5 -5
- package/dist/ir/hal/hal-parser.js +128 -36
- package/dist/ir/hal/hal-plugins.d.ts +0 -1
- package/dist/ir/hal/hal-plugins.js +425 -716
- package/dist/ir/heap-analysis.js +2 -41
- package/dist/ir/identifier-collector.js +32 -20
- package/dist/ir/network-validation.js +7 -11
- package/dist/ir/ownership-analysis.js +75 -13
- package/dist/ir/peripheral-usage.d.ts +8 -2
- package/dist/ir/peripheral-usage.js +78 -149
- package/dist/ir/peripheral-validation.js +23 -3
- package/dist/ir/pin-capability-validation.d.ts +12 -0
- package/dist/ir/pin-capability-validation.js +61 -97
- package/dist/ir/pin-mode-validation.js +5 -5
- package/dist/ir/program-analysis.d.ts +8 -15
- package/dist/ir/program-analysis.js +140 -323
- package/dist/ir/pulldown-validation.js +11 -4
- package/dist/ir/resource-analysis.js +15 -3
- package/dist/ir/statement-to-ir.js +0 -6
- package/dist/ir/timing-validation.js +1 -1
- package/dist/ir/transformers/array-methods.js +11 -5
- package/dist/ir/transformers/call-statement.js +20 -87
- package/dist/ir/transformers/callback-context-registry.d.ts +1 -1
- package/dist/ir/transformers/callback-context-registry.js +8 -16
- package/dist/ir/transformers/control-flow.js +0 -13
- package/dist/ir/transformers/expressions.js +10 -9
- package/dist/ir/transformers/hal-call-resolver.d.ts +2 -2
- package/dist/ir/transformers/hal-call-resolver.js +24 -10
- package/dist/ir/transformers/hal-emit-helpers.d.ts +2 -2
- package/dist/ir/transformers/hal-emit-helpers.js +2 -2
- package/dist/ir/transformers/namespace-methods.js +1 -1
- package/dist/ir/transformers/ui-callback-lowering.d.ts +0 -2
- package/dist/ir/transformers/ui-callback-lowering.js +0 -24
- package/dist/ir/transformers/variables.js +338 -42
- package/dist/ir/try-catch-validation.js +4 -3
- package/dist/ir/type-resolution.js +15 -4
- package/dist/ir/validation-orchestrator.js +0 -9
- package/dist/libdef/cpp-to-decl.d.ts +0 -9
- package/dist/libdef/cpp-to-decl.js +0 -72
- package/dist/libdef/registry.d.ts +0 -1
- package/dist/libdef/registry.js +1 -24
- package/dist/library/catalog.d.ts +35 -0
- package/dist/library/catalog.js +67 -0
- package/dist/library/cli.d.ts +2 -0
- package/dist/library/cli.js +168 -0
- package/dist/library/init.d.ts +25 -0
- package/dist/library/init.js +397 -0
- package/dist/library/install.d.ts +9 -0
- package/dist/library/install.js +80 -0
- package/dist/library/registry-search.d.ts +34 -0
- package/dist/library/registry-search.js +50 -0
- package/dist/library/validate.d.ts +17 -0
- package/dist/library/validate.js +175 -0
- package/dist/library-packages.d.ts +95 -0
- package/dist/library-packages.js +275 -0
- package/dist/mapping/peripheral-names.js +9 -4
- package/dist/mapping/source-map.d.ts +3 -4
- package/dist/mapping/source-map.js +12 -18
- package/dist/orchestrator/graph-builder.d.ts +3 -3
- package/dist/orchestrator/graph-builder.js +29 -12
- package/dist/orchestrator/type-checker.d.ts +3 -3
- package/dist/orchestrator/type-checker.js +3 -3
- package/dist/platform/async-runtime.js +1 -1
- package/dist/platform/coop-scheduler-runtime.js +2 -2
- package/dist/platform/generic-debug-codegen.d.ts +36 -0
- package/dist/platform/generic-debug-codegen.js +185 -0
- package/dist/platform/generic-strategy.d.ts +3 -4
- package/dist/platform/generic-strategy.js +5 -80
- package/dist/platform/index.js +1 -1
- package/dist/platform/registry.d.ts +2 -2
- package/dist/platform/registry.js +2 -2
- package/dist/preview/client.js +17 -3
- package/dist/safety/asil-decorators.d.ts +32 -0
- package/dist/safety/asil-decorators.js +32 -0
- package/dist/safety/authoring.d.ts +85 -0
- package/dist/safety/authoring.js +61 -0
- package/dist/safety/engine.d.ts +3 -0
- package/dist/safety/engine.js +83 -0
- package/dist/safety/hal/ops.d.ts +48 -0
- package/dist/safety/hal/ops.js +46 -0
- package/dist/safety/iso26262/analyze.d.ts +13 -0
- package/dist/safety/iso26262/analyze.js +29 -0
- package/dist/safety/iso26262/asil.d.ts +10 -0
- package/dist/safety/iso26262/asil.js +22 -0
- package/dist/safety/iso26262/collect.d.ts +14 -0
- package/dist/safety/iso26262/collect.js +137 -0
- package/dist/safety/iso26262/goto-checker.d.ts +10 -0
- package/dist/safety/iso26262/goto-checker.js +72 -0
- package/dist/safety/iso26262/heap-checker.d.ts +7 -0
- package/dist/safety/iso26262/heap-checker.js +57 -0
- package/dist/safety/iso26262/init-checker.d.ts +13 -0
- package/dist/safety/iso26262/init-checker.js +127 -0
- package/dist/safety/iso26262/loop-checker.d.ts +7 -0
- package/dist/safety/iso26262/loop-checker.js +86 -0
- package/dist/safety/iso26262/recursion-checker.d.ts +9 -0
- package/dist/safety/iso26262/recursion-checker.js +134 -0
- package/dist/safety/iso26262/sidecar-writer.d.ts +25 -0
- package/dist/safety/iso26262/sidecar-writer.js +13 -0
- package/dist/safety/passes/pinMode-intercept.d.ts +3 -0
- package/dist/safety/passes/pinMode-intercept.js +60 -0
- package/dist/safety/runtime/mode-table.d.ts +5 -0
- package/dist/safety/runtime/mode-table.js +55 -0
- package/dist/safety/runtime/polyfills.d.ts +6 -0
- package/dist/safety/runtime/polyfills.js +12 -0
- package/dist/safety/runtime/result-struct.d.ts +11 -0
- package/dist/safety/runtime/result-struct.js +98 -0
- package/dist/safety/runtime/safe-int.d.ts +33 -0
- package/dist/safety/runtime/safe-int.js +170 -0
- package/dist/safety/runtime/safe-traits.d.ts +4 -0
- package/dist/safety/runtime/safe-traits.js +95 -0
- package/dist/safety/runtime/safe-variable.d.ts +39 -0
- package/dist/safety/runtime/safe-variable.js +226 -0
- package/dist/safety/runtime/vote.d.ts +8 -0
- package/dist/safety/runtime/vote.js +92 -0
- package/dist/safety/runtime/write-verify.d.ts +8 -0
- package/dist/safety/runtime/write-verify.js +71 -0
- package/dist/safety/safe-int-types.d.ts +45 -0
- package/dist/safety/safe-int-types.js +25 -0
- package/dist/safety/safe-variable-types.d.ts +29 -0
- package/dist/safety/safe-variable-types.js +19 -0
- package/dist/safety/safety-bridge.d.ts +5 -6
- package/dist/safety/safety-bridge.js +15 -28
- package/dist/safety/sidecar-bridge.d.ts +1 -3
- package/dist/safety/sidecar-bridge.js +3 -20
- package/dist/safety/specifiers.d.ts +6 -0
- package/dist/safety/specifiers.js +14 -0
- package/dist/safety-hook.d.ts +8 -7
- package/dist/safety-hook.js +12 -13
- package/dist/testing.d.ts +5 -6
- package/dist/testing.js +5 -5
- package/dist/transpile/resolution.d.ts +1 -1
- package/dist/transpile/resolution.js +18 -9
- package/dist/transpile/test-pins.d.ts +18 -0
- package/dist/transpile/test-pins.js +142 -0
- package/dist/transpile.d.ts +1 -2
- package/dist/transpile.js +90 -29
- package/dist/types.d.ts +45 -26
- package/dist/ui-hook.d.ts +1 -1
- package/dist/utils/cli.d.ts +2 -2
- package/dist/utils/cli.js +160 -157
- package/dist/utils/fs.d.ts +3 -4
- package/dist/utils/fs.js +4 -5
- package/dist/utils/strings.d.ts +0 -1
- package/dist/utils/strings.js +0 -8
- package/dist/utils/ui.d.ts +5 -2
- package/dist/utils/ui.js +13 -3
- package/package.json +158 -149
- package/dist/add-preset.d.ts +0 -4
- package/dist/add-preset.js +0 -74
- package/dist/api/shared/async-symbol-detector.d.ts +0 -11
- package/dist/api/shared/async-symbol-detector.js +0 -140
- package/dist/api/shared/native-display-op-resolver.d.ts +0 -10
- package/dist/api/shared/native-display-op-resolver.js +0 -64
- package/dist/create/board-checklist.d.ts +0 -2
- package/dist/create/board-checklist.js +0 -52
- package/dist/create/board-codegen.d.ts +0 -9
- package/dist/create/board-codegen.js +0 -238
- package/dist/create/board-generators.d.ts +0 -12
- package/dist/create/board-generators.js +0 -651
- package/dist/create/board-spec.d.ts +0 -637
- package/dist/create/board-spec.js +0 -214
- package/dist/create/init-templates.d.ts +0 -28
- package/dist/create/init-wizard.d.ts +0 -8
- package/dist/create/init-wizard.js +0 -182
- package/dist/install/framework-catalog.d.ts +0 -53
- package/dist/install/framework-catalog.js +0 -107
- package/dist/install/handle-install.d.ts +0 -35
- package/dist/install/handle-install.js +0 -177
- package/dist/install/index.d.ts +0 -4
- package/dist/install/index.js +0 -3
- package/dist/ir/pin-state-tracking.d.ts +0 -58
- package/dist/ir/pin-state-tracking.js +0 -182
- package/dist/ir/pwm-timer-sharing.d.ts +0 -4
- package/dist/ir/pwm-timer-sharing.js +0 -94
- package/dist/ir/timer0-pwm-timing-conflict.d.ts +0 -4
- package/dist/ir/timer0-pwm-timing-conflict.js +0 -72
- package/dist/libdef/component-decls.d.ts +0 -2
- package/dist/libdef/component-decls.js +0 -6
- package/dist/libdef/component-discovery.d.ts +0 -43
- package/dist/libdef/component-discovery.js +0 -83
- package/dist/theme-tokens.d.ts +0 -22
- package/dist/theme-tokens.js +0 -172
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { LINT_RULES } from '../ir/feature-registry.js';
|
|
2
|
+
import { isBuiltinFramework } from './framework-catalog.js';
|
|
2
3
|
export function generateProjectPackageJson(options) {
|
|
3
|
-
const { projectName, frameworkPackage
|
|
4
|
+
const { projectName, frameworkPackage } = options;
|
|
4
5
|
// @typecad/hal is needed by every build, not just embedded ones: the
|
|
5
6
|
// transpiler unconditionally warms the HAL source modules (loadHALModules in
|
|
6
7
|
// transpile.ts), and resolveHALSourceDir() throws "Could not resolve
|
|
7
8
|
// @typecad/hal/src/" if the package is absent. Embedded targets pull it in
|
|
8
|
-
// transitively (
|
|
9
|
-
// but native targets have no board package
|
|
10
|
-
//
|
|
9
|
+
// transitively (framework + board packages depend on it),
|
|
10
|
+
// but native targets have no board package, so HAL must be an explicit
|
|
11
|
+
// direct dependency here.
|
|
11
12
|
const deps = {
|
|
12
13
|
"@typecad/cuttlefish": "^1.0.0-alpha.3",
|
|
13
14
|
"@typecad/hal": "^1.0.0-alpha.3",
|
|
14
|
-
[frameworkPackage]: "^1.0.0-alpha.3",
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// Built-in frameworks (native) ship inside @typecad/cuttlefish — no
|
|
17
|
+
// separate dependency entry.
|
|
18
|
+
if (!isBuiltinFramework(frameworkPackage)) {
|
|
19
|
+
deps[frameworkPackage] = "^1.0.0-alpha.3";
|
|
18
20
|
}
|
|
19
21
|
const depsJson = Object.entries(deps)
|
|
20
22
|
.map(([k, v]) => ` "${k}": "${v}"`)
|
|
@@ -28,19 +30,13 @@ export function generateProjectPackageJson(options) {
|
|
|
28
30
|
' "@typescript-eslint/parser": "^8.61.0"',
|
|
29
31
|
' "@typescript-eslint/eslint-plugin": "^8.61.0"',
|
|
30
32
|
];
|
|
31
|
-
// Developer-utility
|
|
32
|
-
//
|
|
33
|
-
// dev
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// gen-decls — generate TypeScript .d.ts from C++ headers. File-argument:
|
|
37
|
-
// `npm run gen-decls -- lib/foo.h` or `-- --all lib/`.
|
|
38
|
-
// gen-libdefs — generate library-definition stubs from a TS file's imports.
|
|
39
|
-
// File-argument: `npm run gen-libdefs -- src/main.ts`.
|
|
33
|
+
// Developer-utility script shared by every target (native + embedded).
|
|
34
|
+
// Requires no hardware or extra dependencies:
|
|
35
|
+
// dev — auto-retranspile on save (transpile-only; append --compile
|
|
36
|
+
// to also compile on each change). The fast "does it typecheck"
|
|
37
|
+
// feedback loop.
|
|
40
38
|
const devScripts = [
|
|
41
39
|
'"dev": "cuttlefish build --watch"',
|
|
42
|
-
'"gen-decls": "cuttlefish gen-decls"',
|
|
43
|
-
'"gen-libdefs": "cuttlefish gen-libdefs"',
|
|
44
40
|
];
|
|
45
41
|
if (options.isNative) {
|
|
46
42
|
const devDepsJson = baseDevDeps.join(',\n');
|
|
@@ -100,10 +96,15 @@ ${devDepsJson}
|
|
|
100
96
|
`;
|
|
101
97
|
}
|
|
102
98
|
export function generateProjectTsconfig(options) {
|
|
103
|
-
|
|
99
|
+
// The @typecad/board virtual import resolves for board AND MCU-only targets
|
|
100
|
+
// (the transpile writes .cuttlefish/board.ts re-exporting either). The
|
|
101
|
+
// @typecad/test-pins module is board data — MCU-only targets have none.
|
|
102
|
+
const hasBoard = !!options.board || !!options.soc;
|
|
103
|
+
const paths = (hasBoard || options.soc)
|
|
104
104
|
? `,
|
|
105
105
|
"paths": {
|
|
106
|
-
"@typecad/board": ["./.cuttlefish/board.ts"]
|
|
106
|
+
"@typecad/board": ["./.cuttlefish/board.ts"]${hasBoard ? `,
|
|
107
|
+
"@typecad/test-pins": ["./.cuttlefish/test-pins.ts"]` : ''}
|
|
107
108
|
}`
|
|
108
109
|
: '';
|
|
109
110
|
return `{
|
|
@@ -156,26 +157,59 @@ const config = {
|
|
|
156
157
|
export default config;
|
|
157
158
|
`;
|
|
158
159
|
}
|
|
160
|
+
// The build target rides `board:` for board projects; only board-less
|
|
161
|
+
// projects (bare silicon / contract, whose target is a generated custom
|
|
162
|
+
// board) need the explicit frameworkData entry.
|
|
159
163
|
const buildTarget = options.buildTarget;
|
|
160
|
-
const resolvedToolchain = options.toolchainType
|
|
161
|
-
?? 'arduino-cli';
|
|
162
164
|
let frameworkDataBlock = '';
|
|
163
|
-
if (buildTarget) {
|
|
164
|
-
frameworkDataBlock = `\n // Framework data
|
|
165
|
+
if (buildTarget && buildTarget !== options.board) {
|
|
166
|
+
frameworkDataBlock = `\n // Framework data — the generated custom board's name (no upstream board).\n frameworkData: {\n buildTarget: '${buildTarget}',\n },`;
|
|
165
167
|
}
|
|
166
|
-
const
|
|
167
|
-
?
|
|
168
|
+
const socLine = options.soc
|
|
169
|
+
? `
|
|
170
|
+
// Zephyr SoC — bare silicon; the board module is generated from the
|
|
171
|
+
// curated soc descriptor (contract projects narrow it further).
|
|
172
|
+
soc: '${options.soc}',
|
|
173
|
+
`
|
|
168
174
|
: '';
|
|
169
|
-
const boardLine = options.
|
|
170
|
-
?
|
|
175
|
+
const boardLine = options.board
|
|
176
|
+
? `
|
|
177
|
+
// Zephyr board target — the project-local board module is generated
|
|
178
|
+
// from the framework's board data pack on first build.
|
|
179
|
+
board: '${options.board}',`
|
|
171
180
|
: '';
|
|
172
181
|
const portHint = process.platform === 'win32' ? 'COM4' : '/dev/ttyACM0';
|
|
173
|
-
const
|
|
182
|
+
const portValue = options.port ?? portHint;
|
|
183
|
+
// zephyr.* section — probe (boards with a probe-method table) and/or
|
|
184
|
+
// customBoard (MCU-only targets: generate an out-of-tree board for the
|
|
185
|
+
// chip, named after frameworkData.buildTarget).
|
|
186
|
+
const zephyrFields = [];
|
|
187
|
+
if (options.zephyrCustomBoard) {
|
|
188
|
+
zephyrFields.push(` // Generate an out-of-tree Zephyr board for this MCU under
|
|
189
|
+
// boards/typecad/ (no board package exists for this hardware). The
|
|
190
|
+
// board's name comes from frameworkData.buildTarget above.
|
|
191
|
+
customBoard: true,`);
|
|
192
|
+
}
|
|
193
|
+
if (options.probeMethod) {
|
|
194
|
+
const probeIds = (options.probeMethods ?? []).map((m) => m.id).join(', ');
|
|
195
|
+
zephyrFields.push(` // How this board attaches a probe (picked at create time;
|
|
196
|
+
// the board also supports: ${probeIds || 'see the framework docs'}). Serves
|
|
197
|
+
// flashing AND debugging.
|
|
198
|
+
probe: '${options.probeMethod}',`);
|
|
199
|
+
}
|
|
200
|
+
const zephyrProbeBlock = zephyrFields.length > 0
|
|
201
|
+
? `
|
|
202
|
+
|
|
203
|
+
// Zephyr-specific configuration.
|
|
204
|
+
zephyr: {
|
|
205
|
+
${zephyrFields.join('\n')}
|
|
206
|
+
},`
|
|
207
|
+
: '';
|
|
174
208
|
// Hardware test runner configuration — used by \`npm run test:hw\` (cuttlefish-test,
|
|
175
|
-
// provided by @typecad/expect).
|
|
176
|
-
//
|
|
177
|
-
const
|
|
178
|
-
const testLine = `\n\n // Hardware test runner (@typecad/expect / \`npm run test:hw\`)\n test: {\n // Serial port for the test board. Override with --port on the CLI or the\n // CUTTLEFISH_PORT env var (e.g. CUTTLEFISH_PORT=/dev/ttyUSB0 npm run test:hw).\n port: '${
|
|
209
|
+
// provided by @typecad/expect). Defaults: baudRate 115200, timeout 30000,
|
|
210
|
+
// include tests/**/*.test.ts.
|
|
211
|
+
const testBaud = options.baudRate && options.baudRate !== 115200 ? `\n baudRate: ${options.baudRate},` : '';
|
|
212
|
+
const testLine = `\n\n // Hardware test runner (@typecad/expect / \`npm run test:hw\`)\n test: {\n // Serial port for the test board. Override with --port on the CLI or the\n // CUTTLEFISH_PORT env var (e.g. CUTTLEFISH_PORT=/dev/ttyUSB0 npm run test:hw).\n port: '${portValue}',${testBaud}\n },`;
|
|
179
213
|
return `// ---------------------------------------------------------------------------
|
|
180
214
|
// cuttlefish.config.ts — Project configuration
|
|
181
215
|
//
|
|
@@ -187,30 +221,23 @@ import type { CuttlefishConfig } from '@typecad/cuttlefish/api';
|
|
|
187
221
|
const config: CuttlefishConfig = {
|
|
188
222
|
// Entry point — the main TypeScript file to transpile
|
|
189
223
|
entry: './src/main.ts',
|
|
190
|
-
|
|
191
|
-
// Target architecture
|
|
192
|
-
target: '${options.architecture}',${mcuLine}${boardLine}
|
|
193
|
-
|
|
224
|
+
${socLine}${boardLine}
|
|
194
225
|
// Framework package — controls code generation strategy
|
|
195
226
|
framework: '${options.frameworkPackage}',${frameworkDataBlock}
|
|
196
227
|
|
|
197
|
-
//
|
|
228
|
+
// Transpiled output (the Zephyr app lands in src/out)
|
|
198
229
|
output: {
|
|
199
|
-
framework: '${options.framework}',
|
|
200
230
|
outDir: './out',
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Toolchain configuration
|
|
204
|
-
toolchain: {
|
|
205
|
-
type: '${resolvedToolchain}',
|
|
206
|
-
},${baudLine}${testLine}
|
|
231
|
+
},${zephyrProbeBlock}${testLine}
|
|
207
232
|
};
|
|
208
233
|
|
|
209
234
|
export default config;
|
|
210
235
|
`;
|
|
211
236
|
}
|
|
212
237
|
export function generateProjectEnvDts(options) {
|
|
213
|
-
|
|
238
|
+
// The @typecad/board virtual module resolves for board AND MCU-only targets
|
|
239
|
+
// — the transpile's first build rewrites this placeholder either way.
|
|
240
|
+
if (!options.board && !options.soc) {
|
|
214
241
|
return `// ---------------------------------------------------------------------------
|
|
215
242
|
// cuttlefish-env.d.ts — Global type declarations
|
|
216
243
|
//
|
|
@@ -248,34 +275,9 @@ declare global {
|
|
|
248
275
|
type float = number;
|
|
249
276
|
type double = number;
|
|
250
277
|
|
|
251
|
-
// console — declared here (not pulled from lib.dom) so this project does not
|
|
252
|
-
// need "dom" in tsconfig lib just to type console.log. Avoiding lib.dom also
|
|
253
|
-
// keeps DOM global type names (Node, Element, Event, ...) out of scope, so a
|
|
254
|
-
// user class named e.g. Node is not shadowed by the DOM global. The
|
|
255
|
-
// transpiler regenerates this file on build and may merge extra members
|
|
256
|
-
// (readLine/readCharacter) onto the Console interface.
|
|
257
|
-
interface Console {
|
|
258
|
-
log(...args: unknown[]): void;
|
|
259
|
-
info(...args: unknown[]): void;
|
|
260
|
-
debug(...args: unknown[]): void;
|
|
261
|
-
warn(...args: unknown[]): void;
|
|
262
|
-
error(...args: unknown[]): void;
|
|
263
|
-
}
|
|
264
|
-
const console: Console;
|
|
265
|
-
|
|
266
278
|
// Convenience helper for volatile variables in TypeCAD programs.
|
|
267
279
|
// The transpiler detects calls to volatile() and emits the C++ volatile qualifier.
|
|
268
280
|
declare function volatile<T>(value: T): T;
|
|
269
|
-
|
|
270
|
-
// JS-style timers (declared here so a project does not need "dom" in tsconfig
|
|
271
|
-
// lib to type setInterval/setTimeout). The transpiler rewrites these to
|
|
272
|
-
// __tc_setInterval/__tc_setTimeout and emits the timer_methods polyfill when
|
|
273
|
-
// used. Note: Timing.setInterval/setTimeout (from @typecad/hal) is the
|
|
274
|
-
// preferred single entry point and is typed via the @typecad/board import.
|
|
275
|
-
declare function setInterval(handler: () => void, timeout?: number): number;
|
|
276
|
-
declare function setTimeout(handler: () => void, timeout?: number): number;
|
|
277
|
-
declare function clearInterval(id: number): void;
|
|
278
|
-
declare function clearTimeout(id: number): void;
|
|
279
281
|
}
|
|
280
282
|
|
|
281
283
|
export {};
|
|
@@ -321,34 +323,9 @@ declare global {
|
|
|
321
323
|
type float = number;
|
|
322
324
|
type double = number;
|
|
323
325
|
|
|
324
|
-
// console — declared here (not pulled from lib.dom) so this project does not
|
|
325
|
-
// need "dom" in tsconfig lib just to type console.log. Avoiding lib.dom also
|
|
326
|
-
// keeps DOM global type names (Node, Element, Event, ...) out of scope, so a
|
|
327
|
-
// user class named e.g. Node is not shadowed by the DOM global. The
|
|
328
|
-
// transpiler regenerates this file on build and may merge extra members
|
|
329
|
-
// (readLine/readCharacter) onto the Console interface.
|
|
330
|
-
interface Console {
|
|
331
|
-
log(...args: unknown[]): void;
|
|
332
|
-
info(...args: unknown[]): void;
|
|
333
|
-
debug(...args: unknown[]): void;
|
|
334
|
-
warn(...args: unknown[]): void;
|
|
335
|
-
error(...args: unknown[]): void;
|
|
336
|
-
}
|
|
337
|
-
const console: Console;
|
|
338
|
-
|
|
339
326
|
// Convenience helper for volatile variables in TypeCAD programs.
|
|
340
327
|
// The transpiler detects calls to volatile() and emits the C++ volatile qualifier.
|
|
341
328
|
declare function volatile<T>(value: T): T;
|
|
342
|
-
|
|
343
|
-
// JS-style timers (declared here so a project does not need "dom" in tsconfig
|
|
344
|
-
// lib to type setInterval/setTimeout). The transpiler rewrites these to
|
|
345
|
-
// __tc_setInterval/__tc_setTimeout and emits the timer_methods polyfill when
|
|
346
|
-
// used. Note: Timing.setInterval/setTimeout (from @typecad/hal) is the
|
|
347
|
-
// preferred single entry point and is typed via the @typecad/board import.
|
|
348
|
-
declare function setInterval(handler: () => void, timeout?: number): number;
|
|
349
|
-
declare function setTimeout(handler: () => void, timeout?: number): number;
|
|
350
|
-
declare function clearInterval(id: number): void;
|
|
351
|
-
declare function clearTimeout(id: number): void;
|
|
352
329
|
}
|
|
353
330
|
|
|
354
331
|
declare module '@typecad/board' {
|
|
@@ -361,12 +338,13 @@ declare module '@typecad/board' {
|
|
|
361
338
|
export {};
|
|
362
339
|
`;
|
|
363
340
|
}
|
|
364
|
-
export function
|
|
341
|
+
export function generateStarterProgram(options) {
|
|
365
342
|
if (options.isNative) {
|
|
366
343
|
return `// ---------------------------------------------------------------------------
|
|
367
344
|
// Hello World — Native desktop application
|
|
368
345
|
//
|
|
369
|
-
// Compiles to a native executable via g++/clang++.
|
|
346
|
+
// Compiles to a native executable via g++/clang++. There is no console.* here
|
|
347
|
+
// — results are observable through the debugger or your own channels.
|
|
370
348
|
// ---------------------------------------------------------------------------
|
|
371
349
|
|
|
372
350
|
function fibonacci(n: number): number {
|
|
@@ -374,24 +352,58 @@ function fibonacci(n: number): number {
|
|
|
374
352
|
return fibonacci(n - 1) + fibonacci(n - 2);
|
|
375
353
|
}
|
|
376
354
|
|
|
377
|
-
|
|
378
|
-
console.log("Fibonacci(10) =", fibonacci(10));
|
|
355
|
+
const fib10 = fibonacci(10);
|
|
379
356
|
`;
|
|
380
357
|
}
|
|
381
|
-
|
|
358
|
+
// MCU-only target: bare silicon has no board-level LED alias — blink a
|
|
359
|
+
// port pin from the MCU datasheet instead.
|
|
360
|
+
if (!options.board && options.starterPin) {
|
|
361
|
+
return `// ---------------------------------------------------------------------------
|
|
382
362
|
// Blink — The classic "Hello World" of embedded
|
|
383
363
|
//
|
|
384
|
-
//
|
|
364
|
+
// MCU-only target (no board package): ${options.targetDisplayName}. Pins are
|
|
365
|
+
// addressed by their datasheet port names — see the MCU package for the full
|
|
366
|
+
// pinout and each pin's capabilities.
|
|
385
367
|
// ---------------------------------------------------------------------------
|
|
386
368
|
|
|
387
|
-
import {
|
|
369
|
+
import { GPIO, Time } from '@typecad/hal';
|
|
370
|
+
import { ${options.starterPin} } from '@typecad/board';
|
|
388
371
|
|
|
389
|
-
const led =
|
|
372
|
+
const led = new GPIO(${options.starterPin}, GPIO.OUTPUT);
|
|
390
373
|
|
|
391
374
|
while (true) {
|
|
392
375
|
led.toggle();
|
|
393
|
-
|
|
376
|
+
Time.sleep(1000);
|
|
394
377
|
}
|
|
378
|
+
`;
|
|
379
|
+
}
|
|
380
|
+
return `// ---------------------------------------------------------------------------
|
|
381
|
+
// Starter — The skeleton every program grows from
|
|
382
|
+
//
|
|
383
|
+
// ${options.hasLed === false
|
|
384
|
+
? `This board's devicetree declares no LED — wire up your board's I/O below.`
|
|
385
|
+
: `Toggles the onboard LED every second using the recommended GPIO pattern.`}
|
|
386
|
+
// ---------------------------------------------------------------------------
|
|
387
|
+
|
|
388
|
+
${options.hasLed === false
|
|
389
|
+
? `import { Time } from '@typecad/hal';
|
|
390
|
+
|
|
391
|
+
// This board exports no LED alias — add a peripheral here (GPIO on a header
|
|
392
|
+
// pin, UART0/USB0 for serial output, ...) and drive it in the loop.
|
|
393
|
+
while (true) {
|
|
394
|
+
Time.sleep(1000);
|
|
395
|
+
}
|
|
396
|
+
`
|
|
397
|
+
: `import { GPIO, Time } from '@typecad/hal';
|
|
398
|
+
import { LED } from '@typecad/board';
|
|
399
|
+
|
|
400
|
+
const led = new GPIO(LED, GPIO.OUTPUT);
|
|
401
|
+
|
|
402
|
+
while (true) {
|
|
403
|
+
led.toggle();
|
|
404
|
+
Time.sleep(1000);
|
|
405
|
+
}
|
|
406
|
+
`}
|
|
395
407
|
`;
|
|
396
408
|
}
|
|
397
409
|
export function generateStarterTest(_options) {
|
|
@@ -451,7 +463,7 @@ export function generateStarterSim(options) {
|
|
|
451
463
|
// Hardware simulation — Button + LED
|
|
452
464
|
//
|
|
453
465
|
// Runs entirely on your computer with \`npm run simulate\` (vitest + the
|
|
454
|
-
// @typecad/simulator package). No board, serial port, or
|
|
466
|
+
// @typecad/simulator package). No board, serial port, or west build required.
|
|
455
467
|
// The simulator mirrors the pins/peripherals of your ${options.targetDisplayName}
|
|
456
468
|
// (${boardType}); you inject fake inputs and assert on the outputs in Node.
|
|
457
469
|
//
|
|
@@ -536,14 +548,6 @@ describe("Button + LED (simulator)", () => {
|
|
|
536
548
|
});
|
|
537
549
|
`;
|
|
538
550
|
}
|
|
539
|
-
export function generateBoardForwardingFile(boardPackage) {
|
|
540
|
-
return `// ---------------------------------------------------------------------------
|
|
541
|
-
// .cuttlefish/board.ts — Dynamically generated forwarding board package
|
|
542
|
-
// ---------------------------------------------------------------------------
|
|
543
|
-
|
|
544
|
-
export * from '${boardPackage}';
|
|
545
|
-
`;
|
|
546
|
-
}
|
|
547
551
|
export function generateGitignore(_options) {
|
|
548
552
|
return `node_modules/
|
|
549
553
|
out/
|
|
@@ -557,11 +561,26 @@ dist/
|
|
|
557
561
|
.cuttlefish/eslint-transpiler-rules.mjs
|
|
558
562
|
`;
|
|
559
563
|
}
|
|
564
|
+
export function generateEditorconfig(_options) {
|
|
565
|
+
return `# Auto-generated by 'cuttlefish create'. Edit to customise your build.
|
|
566
|
+
root = true
|
|
567
|
+
|
|
568
|
+
[*]
|
|
569
|
+
charset = utf-8
|
|
570
|
+
end_of_line = lf
|
|
571
|
+
insert_final_newline = true
|
|
572
|
+
trim_trailing_whitespace = true
|
|
573
|
+
|
|
574
|
+
[*.{ts,js,mjs,cjs,json,css,ui,md,yml}]
|
|
575
|
+
indent_style = space
|
|
576
|
+
indent_size = 2
|
|
577
|
+
`;
|
|
578
|
+
}
|
|
560
579
|
export function generateEslintConfig(_options) {
|
|
561
580
|
// `no-restricted-syntax` selectors are generated from LINT_RULES
|
|
562
581
|
// (packages/cuttlefish/src/ir/feature-registry.ts), the single source of
|
|
563
|
-
// truth shared with build-time prescan diagnostics.
|
|
564
|
-
//
|
|
582
|
+
// truth shared with build-time prescan diagnostics. Do not hand-edit the
|
|
583
|
+
// array below.
|
|
565
584
|
const transpilerRulesJson = JSON.stringify(LINT_RULES.map(({ selector, message }) => ({ selector, message })), null, 2).replace(/\n/g, "\n ");
|
|
566
585
|
return `import tsparser from "@typescript-eslint/parser";
|
|
567
586
|
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CreateProjectOptions } from "./templates.js";
|
|
2
|
+
/**
|
|
3
|
+
* Attached serial ports for the wizard's port question — dependency-free
|
|
4
|
+
* (the wizard runs before any project deps exist, and cuttlefish itself
|
|
5
|
+
* carries no native serialport binding). Windows asks the .NET SerialPort
|
|
6
|
+
* class via PowerShell; macOS/Linux scan /dev for USB CDC/bridge nodes.
|
|
7
|
+
* Returns [] when enumeration fails — the question then falls back to a
|
|
8
|
+
* free-text prompt with the platform hint as default.
|
|
9
|
+
*/
|
|
10
|
+
export declare function detectSerialPorts(): string[];
|
|
11
|
+
export declare function runCreateWizard(partialOptions?: {
|
|
12
|
+
probe?: string;
|
|
13
|
+
port?: string;
|
|
14
|
+
projectName?: string;
|
|
15
|
+
board?: string;
|
|
16
|
+
framework?: string;
|
|
17
|
+
baud?: number;
|
|
18
|
+
noStarter?: boolean;
|
|
19
|
+
}): Promise<CreateProjectOptions | null>;
|