@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
package/dist/transpile.js
CHANGED
|
@@ -20,19 +20,22 @@ const CUTTLEFISH_VERSION = (() => {
|
|
|
20
20
|
}
|
|
21
21
|
})();
|
|
22
22
|
import { buildProgramIR } from "./ir/build-ir.js";
|
|
23
|
+
import { resetTranspileResolvedHalOps } from "./ir/build-ir-state.js";
|
|
23
24
|
import { classDeclarationToIR } from "./ir/declaration-builders.js";
|
|
24
25
|
import { clickHandlers } from "./ir/transformers/ui-call-resolver.js";
|
|
25
26
|
import { requireUIHook, hasUIHook } from "./ui-hook.js";
|
|
26
27
|
import { loadUIEngine } from "./ui/ui-bridge.js";
|
|
27
28
|
import { hasSafetyHook, requireSafetyHook } from "./safety-hook.js";
|
|
28
29
|
import { loadSafetyEngine } from "./safety/safety-bridge.js";
|
|
30
|
+
import { isSafetyImportSpecifier } from "./safety/specifiers.js";
|
|
29
31
|
import { setDisplayProfile, resetDisplayProfile, getDisplayProfile } from "./stores/display-profile-store.js";
|
|
30
32
|
import { setThemeCss, resetThemeCss, setThemeClass } from "./stores/theme-store.js";
|
|
31
33
|
import { emitCpp, registerAllEnumNames } from "./emit/cpp-emitter.js";
|
|
32
|
-
import {
|
|
34
|
+
import { writeText, resetWrittenFiles, wasWrittenThisRun } from "./utils/fs.js";
|
|
33
35
|
import { debug as logDebug, info } from "./utils/logger.js";
|
|
34
36
|
import { printDebugStrategy } from "./utils/ui.js";
|
|
35
|
-
import { loadLibraryDefinitions
|
|
37
|
+
import { loadLibraryDefinitions } from "./libdef/registry.js";
|
|
38
|
+
import { resetCuttlefishLibraries, validateCuttlefishLibraries, cuttlefishLibraryLibdefs, libraryDefinitionKey, writeCuttlefishLibraryArtifacts, } from "./library-packages.js";
|
|
36
39
|
import { buildCallGraph } from "./ir/call-graph.js";
|
|
37
40
|
import { clearCaches, } from "./cache.js";
|
|
38
41
|
import { detectEntryPoints, detectExportedEntryPoints } from "./ir/entry-points.js";
|
|
@@ -69,7 +72,7 @@ function loadExpectPreprocessor() {
|
|
|
69
72
|
function cleanOutput(_entryDir, outDir) {
|
|
70
73
|
// The out dir is NOT wiped: writeText skips writing when content is
|
|
71
74
|
// identical, so keeping it lets downstream build tools (idf.py/ninja,
|
|
72
|
-
//
|
|
75
|
+
// west) reuse their build caches. Stale generated SOURCES are handled
|
|
73
76
|
// precisely instead — after emission, sweepStaleGeneratedSources() removes
|
|
74
77
|
// compiled-source files in the out dir that this run did not write (e.g. a
|
|
75
78
|
// main.cpp left behind by the old emit naming next to the current src.cpp;
|
|
@@ -79,7 +82,7 @@ function cleanOutput(_entryDir, outDir) {
|
|
|
79
82
|
void outDir;
|
|
80
83
|
resetWrittenFiles();
|
|
81
84
|
}
|
|
82
|
-
const GENERATED_SOURCE_EXTENSIONS = [".cpp", ".cc", ".c", ".h"
|
|
85
|
+
const GENERATED_SOURCE_EXTENSIONS = [".cpp", ".cc", ".c", ".h"];
|
|
83
86
|
/**
|
|
84
87
|
* Remove stale generated source files from the out dir: compiled-source files
|
|
85
88
|
* that THIS transpile run did not write. Sweeps only the source layouts the
|
|
@@ -121,13 +124,13 @@ function sweepStaleGeneratedSources(outDir) {
|
|
|
121
124
|
* Returns list of generated files.
|
|
122
125
|
*/
|
|
123
126
|
/**
|
|
124
|
-
* True iff the program imports
|
|
125
|
-
* transform pass uses this as its fast no-op guard — when no file
|
|
126
|
-
* safety, the pass returns the program unchanged.
|
|
127
|
+
* True iff the program imports the safety authoring surface anywhere. The
|
|
128
|
+
* safety transform pass uses this as its fast no-op guard — when no file
|
|
129
|
+
* imports safety, the pass returns the program unchanged.
|
|
127
130
|
*/
|
|
128
131
|
function entryImportsSafety(program) {
|
|
129
132
|
for (const imp of program.imports) {
|
|
130
|
-
if (imp.moduleSpecifier
|
|
133
|
+
if (isSafetyImportSpecifier(imp.moduleSpecifier))
|
|
131
134
|
return true;
|
|
132
135
|
}
|
|
133
136
|
return false;
|
|
@@ -258,7 +261,7 @@ function throwIfFatalDiagnostics(entries) {
|
|
|
258
261
|
* doesn't export a FrameworkStrategy, allowing emitCpp to fall back to
|
|
259
262
|
* target-based resolution via the platform registry.
|
|
260
263
|
*/
|
|
261
|
-
function loadPlatformStrategy(frameworkPackage,
|
|
264
|
+
function loadPlatformStrategy(frameworkPackage, _boardTarget, fromDir, debug) {
|
|
262
265
|
if (!frameworkPackage) {
|
|
263
266
|
if (debug) {
|
|
264
267
|
logDebug(`No framework package configured, will use target-based resolution`, true);
|
|
@@ -311,12 +314,12 @@ export async function transpileFile(options) {
|
|
|
311
314
|
const entryFile = path.resolve(options.inputFile);
|
|
312
315
|
const entryDir = path.dirname(entryFile);
|
|
313
316
|
const sourceDir = entryDir;
|
|
314
|
-
const
|
|
317
|
+
const entryBaseName = path.basename(entryFile).replace(/\.[^.]+$/, "");
|
|
315
318
|
const outBaseDir = options.outDir ?? sourceDir;
|
|
316
319
|
profiler.endTimer("setup:caches");
|
|
317
320
|
profiler.startTimer("setup:load-strategy");
|
|
318
321
|
// Load platform strategy from framework or board package, or use target-based resolution
|
|
319
|
-
const boardStrategy = loadPlatformStrategy(options.frameworkPackage, options.
|
|
322
|
+
const boardStrategy = loadPlatformStrategy(options.frameworkPackage, options.boardTarget, entryDir, options.debug);
|
|
320
323
|
profiler.endTimer("setup:load-strategy");
|
|
321
324
|
// Use the framework-loaded strategy for output path computation if available,
|
|
322
325
|
// otherwise fall back to target-based resolution. This ensures a single
|
|
@@ -330,7 +333,7 @@ export async function transpileFile(options) {
|
|
|
330
333
|
if (configDisplay) {
|
|
331
334
|
const { resolveDisplayProfile } = await import("./api/shared/display-profile.js");
|
|
332
335
|
// Build the named-profile registry. Prefer the strategy's hook (per-framework
|
|
333
|
-
// canonical profiles —
|
|
336
|
+
// canonical profiles — the framework returns its BUILT_IN_PROFILES
|
|
334
337
|
// its DT-binding profiles). Fall back to the legacy dynamic import of the
|
|
335
338
|
// framework's displays/ili9341-spi module when the strategy provides none.
|
|
336
339
|
// The registry maps a config `profile` name (e.g. "st7796-zephyr") to its
|
|
@@ -360,7 +363,7 @@ export async function transpileFile(options) {
|
|
|
360
363
|
setThemeClass(configDisplay.themeClass);
|
|
361
364
|
}
|
|
362
365
|
}
|
|
363
|
-
const outDir = path.join(outBaseDir, strategy.outputSubdirectory(
|
|
366
|
+
const outDir = path.join(outBaseDir, strategy.outputSubdirectory(entryBaseName));
|
|
364
367
|
// Start fresh: clean the output directory. (Incremental builds are disabled —
|
|
365
368
|
// see incremental-cache.ts — so we always transpile the full graph.)
|
|
366
369
|
cleanOutput(entryDir, outDir);
|
|
@@ -377,15 +380,21 @@ export async function transpileFile(options) {
|
|
|
377
380
|
return {};
|
|
378
381
|
}
|
|
379
382
|
})();
|
|
380
|
-
|
|
383
|
+
resetCuttlefishLibraries();
|
|
384
|
+
const graphResult = await collectTranspileGraph(entryFile, options.boardTarget, imageDecodeMax);
|
|
381
385
|
profiler.endTimer("graph:collect");
|
|
386
|
+
// Cuttlefish library packages registered during the graph walk — validate
|
|
387
|
+
// them against the loaded framework (and build target, when known) before
|
|
388
|
+
// any codegen. A framework/target mismatch is a hard error here, far
|
|
389
|
+
// clearer than the native compiler's take on a missing header or node.
|
|
390
|
+
validateCuttlefishLibraries(strategy.id, options.platformContext?.frameworkData?.buildTarget);
|
|
382
391
|
const transpileFiles = graphResult.files;
|
|
383
392
|
// ── Type-check all files before transpiling ────────────────────────────────
|
|
384
393
|
// Skip type-checking if explicitly disabled
|
|
385
394
|
let typeCheckProgram;
|
|
386
395
|
if (options.skipTypeCheck !== true && transpileFiles.length > 0) {
|
|
387
396
|
profiler.startTimer("typecheck:full");
|
|
388
|
-
let typeCheckResult = typeCheckFiles(transpileFiles, options.
|
|
397
|
+
let typeCheckResult = typeCheckFiles(transpileFiles, options.boardTarget, entryFile);
|
|
389
398
|
// If type-checking failed, try to auto-generate missing .d.ts files from C++ sources
|
|
390
399
|
if (!typeCheckResult.success) {
|
|
391
400
|
profiler.startTimer("typecheck:autogen-decls");
|
|
@@ -394,7 +403,7 @@ export async function transpileFile(options) {
|
|
|
394
403
|
// If we generated any declaration files, retry type-checking
|
|
395
404
|
if (generatedDecls.length > 0) {
|
|
396
405
|
profiler.startTimer("typecheck:retry");
|
|
397
|
-
typeCheckResult = typeCheckFiles(transpileFiles, options.
|
|
406
|
+
typeCheckResult = typeCheckFiles(transpileFiles, options.boardTarget, entryFile);
|
|
398
407
|
profiler.endTimer("typecheck:retry");
|
|
399
408
|
}
|
|
400
409
|
}
|
|
@@ -451,6 +460,15 @@ export async function transpileFile(options) {
|
|
|
451
460
|
}
|
|
452
461
|
const npmPackages = graphResult.npmPackages;
|
|
453
462
|
const definitions = loadLibraryDefinitions(sourceDir);
|
|
463
|
+
// Cuttlefish library packages: the import resolves to the library's shim
|
|
464
|
+
// include (e.g. '"__tc_rgbled.h"') instead of a transpiled module header.
|
|
465
|
+
// Project-local .libdef.json files keep precedence.
|
|
466
|
+
for (const libdef of cuttlefishLibraryLibdefs()) {
|
|
467
|
+
const key = libraryDefinitionKey(libdef.module);
|
|
468
|
+
if (!definitions.has(key)) {
|
|
469
|
+
definitions.set(key, libdef);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
454
472
|
let entryOutputs;
|
|
455
473
|
const diagnostics = [];
|
|
456
474
|
const allRemovedSymbols = [];
|
|
@@ -576,7 +594,9 @@ export async function transpileFile(options) {
|
|
|
576
594
|
// Printf instrumentation runs only in printf debug mode. In gdb mode
|
|
577
595
|
// (e.g. ESP32-S3), --debug emits #line markers at the emit stage and
|
|
578
596
|
// uses VS Code native breakpoints; the printf preprocessor is skipped
|
|
579
|
-
// so the source reaches IR/emit unmodified.
|
|
597
|
+
// so the source reaches IR/emit unmodified. The preprocessor instruments
|
|
598
|
+
// with the SAME strategy that emits below — its debug dialect must match
|
|
599
|
+
// the runtime the generated code links against.
|
|
580
600
|
const buildTarget = options.platformContext?.frameworkData?.buildTarget;
|
|
581
601
|
const debugMode = strategy.debugMode?.(buildTarget) ?? 'printf';
|
|
582
602
|
if (options.debug && breakpoints && debugMode === 'printf') {
|
|
@@ -584,11 +604,12 @@ export async function transpileFile(options) {
|
|
|
584
604
|
fileName: filePath,
|
|
585
605
|
breakpoints,
|
|
586
606
|
source: sourceText,
|
|
607
|
+
strategy,
|
|
587
608
|
});
|
|
588
609
|
sourceText = instrumented;
|
|
589
610
|
}
|
|
590
611
|
profiler.startTimer(`ir:build-ir:${fileBasename}`);
|
|
591
|
-
const programIR = buildProgramIR(filePath, sourceText, options.
|
|
612
|
+
const programIR = buildProgramIR(filePath, sourceText, options.boardTarget, prebuiltClassMap);
|
|
592
613
|
profiler.endTimer(`ir:build-ir:${fileBasename}`);
|
|
593
614
|
const npmPackage = npmPackages.get(filePath);
|
|
594
615
|
profiler.endTimer(`ir:build:${fileBasename}`);
|
|
@@ -605,6 +626,11 @@ export async function transpileFile(options) {
|
|
|
605
626
|
profiler.startTimer("ir:load-hal");
|
|
606
627
|
loadHALModules(true);
|
|
607
628
|
profiler.endTimer("ir:load-hal");
|
|
629
|
+
// Fresh run, fresh resolved-op set: the lowering seams record every HAL op
|
|
630
|
+
// they resolve (some never become IR nodes); analyzeProgram merges them into
|
|
631
|
+
// the peripheral usage flags at emit. Without this reset, a watch-mode
|
|
632
|
+
// rebuild in the same process would carry the previous program's ops over.
|
|
633
|
+
resetTranspileResolvedHalOps();
|
|
608
634
|
const rawIRArray = await Promise.all(filesToProcess.map(buildRawIR));
|
|
609
635
|
profiler.captureMemorySnapshot("ir:post-build");
|
|
610
636
|
profiler.endTimer("ir:build-all");
|
|
@@ -645,7 +671,7 @@ export async function transpileFile(options) {
|
|
|
645
671
|
for (const { filePath, programIR } of rawIRArray) {
|
|
646
672
|
for (const imp of programIR.imports) {
|
|
647
673
|
// Resolve the import to find which file it comes from
|
|
648
|
-
const resolved = resolveImport(filePath, imp.moduleSpecifier, options.
|
|
674
|
+
const resolved = resolveImport(filePath, imp.moduleSpecifier, options.boardTarget);
|
|
649
675
|
if (!resolved)
|
|
650
676
|
continue;
|
|
651
677
|
const targetFile = resolved.sourcePath;
|
|
@@ -872,10 +898,11 @@ export async function transpileFile(options) {
|
|
|
872
898
|
profiler.startTimer("post:native-modules");
|
|
873
899
|
const nativeModuleOutputs = [];
|
|
874
900
|
for (const [moduleSpecifier, nativeModule] of graphResult.nativeModules) {
|
|
875
|
-
// Skip copying —
|
|
876
|
-
// Copying either causes conflicts: the .cpp merges into the
|
|
877
|
-
// definitions), and the .h shadows the library's own header
|
|
878
|
-
// The gen-decls .d.ts files are sufficient for
|
|
901
|
+
// Skip copying — framework libraries provide both .h and .cpp.
|
|
902
|
+
// Copying either causes conflicts: the .cpp merges into the entry source
|
|
903
|
+
// (duplicate definitions), and the .h shadows the library's own header
|
|
904
|
+
// (link failures). The gen-decls .d.ts files are sufficient for TS
|
|
905
|
+
// type-checking.
|
|
879
906
|
info(`Native module (library-managed): ${moduleSpecifier}`);
|
|
880
907
|
}
|
|
881
908
|
profiler.endTimer("post:native-modules");
|
|
@@ -913,7 +940,7 @@ export async function transpileFile(options) {
|
|
|
913
940
|
asyncTaskNames: entryOutputs.asyncTaskNames ?? [],
|
|
914
941
|
usesTimers: entryOutputs.usesTimers ?? false,
|
|
915
942
|
target: options.target,
|
|
916
|
-
|
|
943
|
+
boardTarget: options.boardTarget,
|
|
917
944
|
frameworkPackage: options.frameworkPackage,
|
|
918
945
|
outDir,
|
|
919
946
|
outputFile: entryOutputs.sourcePath,
|
|
@@ -935,14 +962,48 @@ export async function transpileFile(options) {
|
|
|
935
962
|
});
|
|
936
963
|
}
|
|
937
964
|
}
|
|
965
|
+
// ── Persist the resolved board constants next to the emitted source ─────
|
|
966
|
+
// Framework toolchains re-read this at compile time to rebuild their chip
|
|
967
|
+
// descriptors (framework-zephyr's resolveChipFromBoard). Board packages
|
|
968
|
+
// carry chip data — controller splits, ADC channel maps, PWM specs — that
|
|
969
|
+
// lives only in the board package, so without this file the toolchain's
|
|
970
|
+
// registry fallback silently resolves board-derived targets (rpi_pico,
|
|
971
|
+
// esp32c3/c6, blackpill) to the XIAO default descriptor.
|
|
972
|
+
try {
|
|
973
|
+
// Read from the built program IRs — the IR build context (and its
|
|
974
|
+
// current-board-constants slot) is already closed at this point. Any
|
|
975
|
+
// file's IR may carry the constants (the board import is traversed while
|
|
976
|
+
// building whichever file imports it first), so scan for a populated one.
|
|
977
|
+
let boardConstants;
|
|
978
|
+
for (const pb of preBuilt.values()) {
|
|
979
|
+
const bc = pb.programIR.boardConstants;
|
|
980
|
+
if (bc && bc.size > 0) {
|
|
981
|
+
boardConstants = bc;
|
|
982
|
+
break;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
if (boardConstants && boardConstants.size > 0) {
|
|
986
|
+
fs.writeFileSync(path.join(outDir, "board-constants.json"), JSON.stringify(Object.fromEntries(boardConstants), null, 2));
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
catch {
|
|
990
|
+
// Best-effort persistence; the toolchain falls back to its registry.
|
|
991
|
+
}
|
|
992
|
+
// ── Cuttlefish library packages: shims + libraries.json sidecar ─────────
|
|
993
|
+
// Shims are written next to the emitted sources (the framework scaffold's
|
|
994
|
+
// CMake/program regen compiles them); the sidecar records the used
|
|
995
|
+
// libraries' build contributions (Kconfig lines, overlay fragments) for
|
|
996
|
+
// the framework toolchain — the board-constants.json convention.
|
|
997
|
+
try {
|
|
998
|
+
const emittedSrcDir = entryOutputs ? path.dirname(entryOutputs.sourcePath) : outDir;
|
|
999
|
+
writeCuttlefishLibraryArtifacts(outDir, emittedSrcDir);
|
|
1000
|
+
}
|
|
1001
|
+
catch {
|
|
1002
|
+
// Best-effort; a missing shim surfaces at native compile time.
|
|
1003
|
+
}
|
|
938
1004
|
return {
|
|
939
1005
|
...entryOutputs,
|
|
940
1006
|
diagnostics,
|
|
941
1007
|
diagnosticsReportPath,
|
|
942
1008
|
};
|
|
943
1009
|
}
|
|
944
|
-
export function generateLibraryDefinitions(options) {
|
|
945
|
-
const sourceText = readText(options.inputFile);
|
|
946
|
-
const programIR = buildProgramIR(options.inputFile, sourceText);
|
|
947
|
-
return generateLibdefStubs(options.inputFile, programIR.imports, options.outDir);
|
|
948
|
-
}
|
package/dist/types.d.ts
CHANGED
|
@@ -55,15 +55,15 @@ export interface TranspileOptions {
|
|
|
55
55
|
/** Tree-shaking options for dead code elimination */
|
|
56
56
|
treeShaking?: TreeShakingOptions;
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* Zephyr board target resolved from `cuttlefish.config.ts` (e.g.
|
|
59
|
+
* `'esp32s3_devkitc/esp32s3/procpu'`). When a generated board module is
|
|
60
|
+
* absent, `@typecad/board` imports resolve through it.
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
boardTarget?: string;
|
|
63
63
|
/**
|
|
64
64
|
* Framework package for code generation strategy.
|
|
65
|
-
* Can be any framework package path, e.g. '@typecad/framework-
|
|
66
|
-
* '@typecad/framework-
|
|
65
|
+
* Can be any framework package path, e.g. '@typecad/framework-zephyr',
|
|
66
|
+
* '@typecad/framework-native', or a custom local path.
|
|
67
67
|
* When not specified, the GenericStrategy (standard C++) is used.
|
|
68
68
|
*/
|
|
69
69
|
frameworkPackage?: string;
|
|
@@ -121,7 +121,7 @@ export interface LibraryDefinition {
|
|
|
121
121
|
variants?: LibraryDefinitionVariant[];
|
|
122
122
|
}
|
|
123
123
|
export interface CommandLineOptions {
|
|
124
|
-
command: "default" | "build" | "gen-
|
|
124
|
+
command: "default" | "build" | "gen-decls" | "preview" | "doctor" | "licenses";
|
|
125
125
|
/** For `licenses`: treat unknown/missing licenses as failures (exit 1). */
|
|
126
126
|
strict?: boolean;
|
|
127
127
|
/** For `licenses`: scan all installed libraries (default: this project's only). */
|
|
@@ -141,26 +141,23 @@ export interface CommandLineOptions {
|
|
|
141
141
|
monitor: boolean;
|
|
142
142
|
/** Serial port for upload and monitor (e.g. COM4 or /dev/ttyACM0) */
|
|
143
143
|
port?: string;
|
|
144
|
+
/** One-off probe-method override (a board probeMethods id) for --upload
|
|
145
|
+
* and --debug. Wins over zephyr.probe in cuttlefish.config.ts; Zephyr-only. */
|
|
146
|
+
probe?: string;
|
|
144
147
|
/** Baud rate for monitor. Undefined when --baud is absent so the consumer
|
|
145
|
-
* can fall
|
|
146
|
-
* applies only when neither is set). */
|
|
148
|
+
* can fall through to the framework monitor default. */
|
|
147
149
|
baud?: number;
|
|
148
150
|
platformContext?: PlatformContext;
|
|
149
|
-
mapFile?: string;
|
|
150
|
-
cppFile?: string;
|
|
151
|
-
cppLine?: number;
|
|
152
|
-
cppColumn?: number;
|
|
153
|
-
message?: string;
|
|
154
151
|
/** Tree-shaking options */
|
|
155
152
|
treeShaking?: TreeShakingOptions;
|
|
156
153
|
/**
|
|
157
154
|
* Board package specifier resolved from `cuttlefish.config.ts`.
|
|
158
155
|
* When present, `@typecad/board` imports are rewritten to this package.
|
|
159
156
|
*/
|
|
160
|
-
|
|
157
|
+
boardTarget?: string;
|
|
161
158
|
/**
|
|
162
159
|
* Framework package for code generation strategy.
|
|
163
|
-
* Can be '@typecad/framework-
|
|
160
|
+
* Can be '@typecad/framework-zephyr', '@typecad/framework-native', or a custom path.
|
|
164
161
|
*/
|
|
165
162
|
frameworkPackage?: string;
|
|
166
163
|
/** Enable debug mode - inject breakpoint instrumentation */
|
|
@@ -188,11 +185,6 @@ export interface CommandLineOptions {
|
|
|
188
185
|
/** Project root (dir of cuttlefish.config.ts); passed to transpileFile for the ESLint gate. */
|
|
189
186
|
projectRoot?: string;
|
|
190
187
|
}
|
|
191
|
-
export interface GenerateLibdefOptions {
|
|
192
|
-
inputFile: string;
|
|
193
|
-
outDir: string;
|
|
194
|
-
}
|
|
195
|
-
/** `cuttlefish add <preset>` — scaffold a copy-and-own asset into the project. */
|
|
196
188
|
export interface GeneratedOutputs {
|
|
197
189
|
headerPath?: string;
|
|
198
190
|
sourcePath: string;
|
|
@@ -228,14 +220,41 @@ export interface CreateCommandOptions {
|
|
|
228
220
|
target?: string;
|
|
229
221
|
framework?: string;
|
|
230
222
|
baud?: number;
|
|
231
|
-
|
|
223
|
+
noStarter?: boolean;
|
|
232
224
|
outDir?: string;
|
|
233
225
|
/** Skip the automatic `npm install` in the scaffolded project. */
|
|
234
226
|
noInstall?: boolean;
|
|
227
|
+
/** Probe method id (board probeMethods table) — skips the wizard question
|
|
228
|
+
* and writes zephyr.probe into the scaffolded config. Zephyr-only. */
|
|
229
|
+
probe?: string;
|
|
230
|
+
/** Serial port the board is attached to (COMx / /dev/tty*) — skips the
|
|
231
|
+
* wizard question and seeds test.port in the config. */
|
|
232
|
+
port?: string;
|
|
235
233
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
234
|
+
/** Parsed `cuttlefish board <subcommand>` options. */
|
|
235
|
+
export interface BoardCommandOptions {
|
|
236
|
+
command: "board";
|
|
237
|
+
subcommand: "regen" | "sync";
|
|
238
|
+
/** sync: optional explicit Zephyr checkout path to walk. */
|
|
239
|
+
zephyrBase?: string;
|
|
240
|
+
}
|
|
241
|
+
/** Parsed `cuttlefish library <subcommand>` options. */
|
|
242
|
+
export interface LibraryCommandOptions {
|
|
243
|
+
command: "library";
|
|
244
|
+
subcommand: "search" | "install" | "init" | "validate";
|
|
245
|
+
/** Non-flag tokens after the subcommand: search text, install names, init name, validate path. */
|
|
246
|
+
positionals: string[];
|
|
247
|
+
/** search: taxonomy category id. */
|
|
248
|
+
category?: string;
|
|
249
|
+
/** init: framework id from the framework catalog. */
|
|
250
|
+
framework?: string;
|
|
251
|
+
/** init: comma-separated board-target prefixes. */
|
|
252
|
+
targets?: string;
|
|
253
|
+
/** init: scaffold directory (default ./<library-id>). */
|
|
254
|
+
dir?: string;
|
|
255
|
+
/** init: skip prompts, take defaults. */
|
|
256
|
+
yes?: boolean;
|
|
257
|
+
/** Machine-readable output for search/validate. */
|
|
258
|
+
json?: boolean;
|
|
240
259
|
}
|
|
241
260
|
export {};
|
package/dist/ui-hook.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export interface TranspilerUIHook {
|
|
|
62
62
|
* native display paths). Called separately from emitRuntimeHeader so the
|
|
63
63
|
* class can be emitted BEFORE display adapter declarations that
|
|
64
64
|
* instantiate CuttlefishGFX by value. Returns "" when active is false
|
|
65
|
-
* (
|
|
65
|
+
* (console path).
|
|
66
66
|
*/
|
|
67
67
|
emitCuttlefishGfx(active: boolean): string;
|
|
68
68
|
/**
|
package/dist/utils/cli.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CommandLineOptions, CreateCommandOptions,
|
|
1
|
+
import { CommandLineOptions, CreateCommandOptions, LibraryCommandOptions, BoardCommandOptions } from "../types.js";
|
|
2
2
|
export declare function printHelp(): void;
|
|
3
|
-
export declare function parseCommandLine(argv: string[]): CommandLineOptions | CreateCommandOptions |
|
|
3
|
+
export declare function parseCommandLine(argv: string[]): CommandLineOptions | CreateCommandOptions | LibraryCommandOptions | BoardCommandOptions | "help";
|