@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,336 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Markdown Report Writer
|
|
3
|
+
//
|
|
4
|
+
// Assembles the human-readable diagnostics.md file with embedded
|
|
5
|
+
// Mermaid diagrams and summary tables.
|
|
6
|
+
//
|
|
7
|
+
// Note: Source maps and transpile diagnostics are EXCLUDED from the
|
|
8
|
+
// Markdown report (they appear only in JSON).
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
import { buildExecutionFlowDiagram, buildPinUsagePie, buildPinDetailTable, buildPeripheralDiagram, buildPeripheralTable, buildAsyncTaskDiagram, buildHeapPie, buildConflictTable, buildInterruptMap, buildMemoryMap, buildStackPathsMap, buildModuleGraphDiagram, buildTreeShakingTable, buildTimingTable, } from "./mermaid-builder.js";
|
|
11
|
+
// ── Section Builders ────────────────────────────────────────────────────────
|
|
12
|
+
function buildMetadataSection(report) {
|
|
13
|
+
const m = report.metadata;
|
|
14
|
+
const lines = [];
|
|
15
|
+
lines.push(`# Build Diagnostics`);
|
|
16
|
+
lines.push("");
|
|
17
|
+
lines.push(`> **Source:** \`${m.sourceFile}\` | **Target:** \`${m.target}\` | **Generated:** ${new Date(m.timestamp).toLocaleString()}`);
|
|
18
|
+
if (m.board)
|
|
19
|
+
lines.push(`> **Board:** ${m.board} | **Framework:** ${m.framework || "None"}`);
|
|
20
|
+
if (m.boardDetails) {
|
|
21
|
+
const d = m.boardDetails;
|
|
22
|
+
const specs = [];
|
|
23
|
+
if (d.mcu)
|
|
24
|
+
specs.push(`**MCU:** ${d.mcu}`);
|
|
25
|
+
if (d.flashKb)
|
|
26
|
+
specs.push(`**Flash:** ${d.flashKb}KB`);
|
|
27
|
+
if (d.sramKb)
|
|
28
|
+
specs.push(`**SRAM:** ${d.sramKb}KB`);
|
|
29
|
+
if (d.clockSpeedMhz)
|
|
30
|
+
specs.push(`**Clock:** ${d.clockSpeedMhz}MHz`);
|
|
31
|
+
if (specs.length > 0)
|
|
32
|
+
lines.push(`> ${specs.join(" | ")}`);
|
|
33
|
+
}
|
|
34
|
+
lines.push("");
|
|
35
|
+
lines.push("---");
|
|
36
|
+
return lines.join("\n");
|
|
37
|
+
}
|
|
38
|
+
function buildSummarySection(report) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
lines.push("## Project Summary");
|
|
41
|
+
lines.push("");
|
|
42
|
+
lines.push("| Metric | Status / Value |");
|
|
43
|
+
lines.push("| :--- | :--- |");
|
|
44
|
+
lines.push(`| **Output File** | \`${report.metadata.outputFile}\` |`);
|
|
45
|
+
lines.push(`| **Entry Points** | ${report.executionFlow.entryPoints.length} |`);
|
|
46
|
+
lines.push(`| **Static Memory** | ${report.heapEstimate.totalStaticBytes} bytes |`);
|
|
47
|
+
lines.push(`| **Async Tasks** | ${report.asyncTasks.length || "None"} |`);
|
|
48
|
+
const pins = report.pinUsage.summary;
|
|
49
|
+
lines.push(`| **Pin Usage** | ${pins.usedPins} / ${pins.totalPins} pins |`);
|
|
50
|
+
lines.push("");
|
|
51
|
+
lines.push("---");
|
|
52
|
+
return lines.join("\n");
|
|
53
|
+
}
|
|
54
|
+
function buildExecutionFlowSection(flow, callGraph) {
|
|
55
|
+
const lines = [];
|
|
56
|
+
lines.push("## Execution Flow");
|
|
57
|
+
lines.push("");
|
|
58
|
+
lines.push("> This graph shows the relationships between entry points, HAL objects, and Arduino APIs.");
|
|
59
|
+
lines.push("");
|
|
60
|
+
lines.push(buildExecutionFlowDiagram(flow, callGraph));
|
|
61
|
+
lines.push("");
|
|
62
|
+
if (flow.isrHandlers.length > 0) {
|
|
63
|
+
lines.push("### Interrupt Logic Map");
|
|
64
|
+
lines.push("");
|
|
65
|
+
lines.push("> Specialized view showing only hardware-triggered event paths.");
|
|
66
|
+
lines.push("");
|
|
67
|
+
lines.push(buildInterruptMap(flow, callGraph));
|
|
68
|
+
lines.push("");
|
|
69
|
+
}
|
|
70
|
+
if (flow.entryPoints.length > 0) {
|
|
71
|
+
lines.push("### Entry Points");
|
|
72
|
+
for (const ep of flow.entryPoints) {
|
|
73
|
+
lines.push(`- \`${ep}()\``);
|
|
74
|
+
}
|
|
75
|
+
lines.push("");
|
|
76
|
+
}
|
|
77
|
+
if (flow.isrHandlers.length > 0) {
|
|
78
|
+
lines.push("### ISR Handlers");
|
|
79
|
+
for (const isr of flow.isrHandlers) {
|
|
80
|
+
lines.push(`- \`${isr}()\` ⚡ (interrupt service routine)`);
|
|
81
|
+
}
|
|
82
|
+
lines.push("");
|
|
83
|
+
}
|
|
84
|
+
if (flow.usesTimers) {
|
|
85
|
+
lines.push("### Timer Usage");
|
|
86
|
+
lines.push("- ⏱ `millis()` / `micros()` timer is **active**");
|
|
87
|
+
lines.push("");
|
|
88
|
+
}
|
|
89
|
+
return lines.join("\n");
|
|
90
|
+
}
|
|
91
|
+
function buildResourceAccessMatrixSection(flow, callGraph, pinUsage) {
|
|
92
|
+
const entries = [...flow.entryPoints, ...flow.isrHandlers, ...flow.asyncTaskNames];
|
|
93
|
+
if (entries.length === 0)
|
|
94
|
+
return "";
|
|
95
|
+
const lines = [];
|
|
96
|
+
lines.push("### Resource Access Matrix");
|
|
97
|
+
lines.push("");
|
|
98
|
+
lines.push("> High-level overview of hardware resources accessed by each entry point.");
|
|
99
|
+
lines.push("");
|
|
100
|
+
// Collect all unique resources used in the project
|
|
101
|
+
const resources = new Set();
|
|
102
|
+
for (const p of pinUsage.peripherals)
|
|
103
|
+
resources.add(p.displayName);
|
|
104
|
+
for (const g of pinUsage.gpio)
|
|
105
|
+
resources.add(g.pinName);
|
|
106
|
+
const resourceList = [...resources].sort();
|
|
107
|
+
if (resourceList.length === 0)
|
|
108
|
+
return "";
|
|
109
|
+
lines.push(`| Entry Point | ${resourceList.join(" | ")} |`);
|
|
110
|
+
lines.push(`| :--- | ${resourceList.map(() => ":---:").join(" | ")} |`);
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
// Find all APIs called by this entry (recursive)
|
|
113
|
+
const calledAPIs = new Set();
|
|
114
|
+
const visited = new Set();
|
|
115
|
+
const walk = (name) => {
|
|
116
|
+
if (visited.has(name))
|
|
117
|
+
return;
|
|
118
|
+
visited.add(name);
|
|
119
|
+
const node = callGraph.nodes.get(name);
|
|
120
|
+
if (node) {
|
|
121
|
+
for (const dep of node.dependencies) {
|
|
122
|
+
calledAPIs.add(dep);
|
|
123
|
+
walk(dep);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
walk(entry);
|
|
128
|
+
const row = [`\`${entry}()\``];
|
|
129
|
+
for (const res of resourceList) {
|
|
130
|
+
let used = false;
|
|
131
|
+
// Check peripherals
|
|
132
|
+
const peri = pinUsage.peripherals.find(p => p.displayName === res);
|
|
133
|
+
if (peri) {
|
|
134
|
+
if (calledAPIs.has(res) || peri.pins.some(p => calledAPIs.has(p)))
|
|
135
|
+
used = true;
|
|
136
|
+
// Also check for common API names associated with the peripheral
|
|
137
|
+
if (res === "Serial" && (calledAPIs.has("println") || calledAPIs.has("print")))
|
|
138
|
+
used = true;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Check GPIO pins
|
|
142
|
+
if (calledAPIs.has(res))
|
|
143
|
+
used = true;
|
|
144
|
+
}
|
|
145
|
+
row.push(used ? "✅" : "—");
|
|
146
|
+
}
|
|
147
|
+
lines.push(`| ${row.join(" | ")} |`);
|
|
148
|
+
}
|
|
149
|
+
lines.push("");
|
|
150
|
+
return lines.join("\n");
|
|
151
|
+
}
|
|
152
|
+
function buildPinUsageSection(gpio, peripherals, summary) {
|
|
153
|
+
const lines = [];
|
|
154
|
+
lines.push("## Pin Configuration");
|
|
155
|
+
lines.push("");
|
|
156
|
+
lines.push("> **Tip:** Unused pins are available for connecting additional sensors, actuators, or peripherals.");
|
|
157
|
+
lines.push("");
|
|
158
|
+
lines.push(buildPinUsagePie(gpio, summary));
|
|
159
|
+
lines.push("");
|
|
160
|
+
lines.push("### 🔌 GPIO Assignments");
|
|
161
|
+
lines.push("");
|
|
162
|
+
lines.push(buildPinDetailTable(gpio));
|
|
163
|
+
lines.push("");
|
|
164
|
+
lines.push("### 🧩 Peripheral Resource Allocation");
|
|
165
|
+
lines.push("");
|
|
166
|
+
lines.push(buildPeripheralTable(peripherals));
|
|
167
|
+
lines.push("");
|
|
168
|
+
lines.push(buildPeripheralDiagram(peripherals));
|
|
169
|
+
lines.push("");
|
|
170
|
+
return lines.join("\n");
|
|
171
|
+
}
|
|
172
|
+
function buildAsyncTasksSection(tasks) {
|
|
173
|
+
const lines = [];
|
|
174
|
+
lines.push("## Cooperative Multitasking");
|
|
175
|
+
lines.push("");
|
|
176
|
+
if (tasks.length === 0) {
|
|
177
|
+
lines.push("> _No async tasks registered in this sketch._");
|
|
178
|
+
lines.push("");
|
|
179
|
+
return lines.join("\n");
|
|
180
|
+
}
|
|
181
|
+
lines.push("### 📅 Task Schedule");
|
|
182
|
+
lines.push("");
|
|
183
|
+
lines.push("| Task | Interval |");
|
|
184
|
+
lines.push("| :--- | :--- |");
|
|
185
|
+
for (const task of tasks) {
|
|
186
|
+
const interval = task.intervalMs ? `${task.intervalMs} ms` : "unspecified";
|
|
187
|
+
lines.push(`| \`fn ${task.name}()\` | ${interval} |`);
|
|
188
|
+
}
|
|
189
|
+
lines.push("");
|
|
190
|
+
lines.push("### 📊 Timeline Visualization");
|
|
191
|
+
lines.push("");
|
|
192
|
+
lines.push(buildAsyncTaskDiagram(tasks));
|
|
193
|
+
lines.push("");
|
|
194
|
+
return lines.join("\n");
|
|
195
|
+
}
|
|
196
|
+
function buildHeapEstimateSection(heap) {
|
|
197
|
+
const lines = [];
|
|
198
|
+
lines.push("## Memory Estimate");
|
|
199
|
+
lines.push("");
|
|
200
|
+
lines.push("> ⚠️ Static estimate only — excludes dynamic heap allocations (malloc/new).");
|
|
201
|
+
lines.push("> String literals may be deduplicated by the compiler/linker.");
|
|
202
|
+
lines.push("> **Tip:** Compare this static estimate to the total SRAM of your target board.");
|
|
203
|
+
lines.push("");
|
|
204
|
+
lines.push(buildHeapPie(heap));
|
|
205
|
+
lines.push("");
|
|
206
|
+
lines.push("### 🧱 SRAM Memory Map");
|
|
207
|
+
lines.push("");
|
|
208
|
+
lines.push(buildMemoryMap(heap));
|
|
209
|
+
lines.push("");
|
|
210
|
+
if (heap.stackPaths.length > 0) {
|
|
211
|
+
lines.push("### Stack Analysis (Deepest Paths)");
|
|
212
|
+
lines.push("");
|
|
213
|
+
lines.push("> The following call sequences represent the maximum stack depth detected.");
|
|
214
|
+
lines.push("");
|
|
215
|
+
lines.push(buildStackPathsMap(heap.stackPaths));
|
|
216
|
+
lines.push("");
|
|
217
|
+
}
|
|
218
|
+
if (heap.globalVariables.length > 0) {
|
|
219
|
+
lines.push("### Global Variables");
|
|
220
|
+
lines.push("");
|
|
221
|
+
lines.push("| Variable | Type | Est. Bytes |");
|
|
222
|
+
lines.push("|----------|------|------------|");
|
|
223
|
+
for (const v of heap.globalVariables) {
|
|
224
|
+
lines.push(`| \`${v.name}\` | \`${v.cppType}\` | ${v.estimatedBytes} |`);
|
|
225
|
+
}
|
|
226
|
+
lines.push("");
|
|
227
|
+
}
|
|
228
|
+
return lines.join("\n");
|
|
229
|
+
}
|
|
230
|
+
function buildConflictsSection(conflicts) {
|
|
231
|
+
const lines = [];
|
|
232
|
+
lines.push("## Peripheral Conflicts");
|
|
233
|
+
lines.push("");
|
|
234
|
+
lines.push(buildConflictTable(conflicts));
|
|
235
|
+
lines.push("");
|
|
236
|
+
return lines.join("\n");
|
|
237
|
+
}
|
|
238
|
+
function buildModuleGraphSection(graph) {
|
|
239
|
+
if (!graph)
|
|
240
|
+
return "";
|
|
241
|
+
const lines = [];
|
|
242
|
+
lines.push("## Module Dependency Graph");
|
|
243
|
+
lines.push("");
|
|
244
|
+
lines.push("> Displays the file import hierarchy and dependencies.");
|
|
245
|
+
lines.push("");
|
|
246
|
+
lines.push(buildModuleGraphDiagram(graph));
|
|
247
|
+
lines.push("");
|
|
248
|
+
return lines.join("\n");
|
|
249
|
+
}
|
|
250
|
+
function buildTreeShakingSection(report) {
|
|
251
|
+
if (!report)
|
|
252
|
+
return "";
|
|
253
|
+
const lines = [];
|
|
254
|
+
lines.push("## Tree Shaking Report");
|
|
255
|
+
lines.push("");
|
|
256
|
+
lines.push("> Symbols that were removed by the transpiler because they were unused.");
|
|
257
|
+
lines.push("");
|
|
258
|
+
lines.push(buildTreeShakingTable(report));
|
|
259
|
+
lines.push("");
|
|
260
|
+
return lines.join("\n");
|
|
261
|
+
}
|
|
262
|
+
function buildTimingSection(timing) {
|
|
263
|
+
if (!timing)
|
|
264
|
+
return "";
|
|
265
|
+
const lines = [];
|
|
266
|
+
lines.push("## Build Timing Breakdown");
|
|
267
|
+
lines.push("");
|
|
268
|
+
lines.push("> Execution time for each transpiler phase.");
|
|
269
|
+
lines.push("");
|
|
270
|
+
lines.push(buildTimingTable(timing));
|
|
271
|
+
lines.push("");
|
|
272
|
+
return lines.join("\n");
|
|
273
|
+
}
|
|
274
|
+
function buildDiagnosticsSection(diagnostics) {
|
|
275
|
+
if (!diagnostics || diagnostics.length === 0)
|
|
276
|
+
return "";
|
|
277
|
+
const lines = [];
|
|
278
|
+
lines.push("## Transpile Diagnostics");
|
|
279
|
+
lines.push("");
|
|
280
|
+
lines.push("> Issues detected during code generation.");
|
|
281
|
+
lines.push("");
|
|
282
|
+
lines.push("| Severity | Message | Location |");
|
|
283
|
+
lines.push("| :--- | :--- | :--- |");
|
|
284
|
+
for (const d of diagnostics) {
|
|
285
|
+
const sev = d.severity === "error" ? "🔴 Error" : "🟡 Warning";
|
|
286
|
+
const loc = d.startLine !== undefined ? `Line ${d.startLine}` : "—";
|
|
287
|
+
lines.push(`| ${sev} | ${d.message} | ${loc} |`);
|
|
288
|
+
}
|
|
289
|
+
lines.push("");
|
|
290
|
+
return lines.join("\n");
|
|
291
|
+
}
|
|
292
|
+
// ── Main Entry Point ────────────────────────────────────────────────────────
|
|
293
|
+
/**
|
|
294
|
+
* Generate the complete diagnostics.md report as a string.
|
|
295
|
+
*
|
|
296
|
+
* @param report - The full diagnostics report with all data populated.
|
|
297
|
+
* @param callGraph - The raw CallGraph (Map-based) for Mermaid node walk.
|
|
298
|
+
* @returns The complete Markdown string ready to write to disk.
|
|
299
|
+
*/
|
|
300
|
+
export function generateMarkdownReport(report, callGraph) {
|
|
301
|
+
const sections = [];
|
|
302
|
+
// 1. Metadata header & Summary
|
|
303
|
+
sections.push(buildMetadataSection(report));
|
|
304
|
+
sections.push(buildSummarySection(report));
|
|
305
|
+
// 2. Execution flow (call graph, entry points, ISRs)
|
|
306
|
+
sections.push(buildExecutionFlowSection(report.executionFlow, callGraph));
|
|
307
|
+
// 2b. Resource Access Matrix
|
|
308
|
+
sections.push(buildResourceAccessMatrixSection(report.executionFlow, callGraph, report.pinUsage));
|
|
309
|
+
// 3. Pin usage (GPIO + peripheral allocation)
|
|
310
|
+
sections.push(buildPinUsageSection(report.pinUsage.gpio, report.pinUsage.peripherals, report.pinUsage.summary));
|
|
311
|
+
// 4. Peripheral conflicts (only if there are any)
|
|
312
|
+
if (report.peripheralConflicts.length > 0) {
|
|
313
|
+
sections.push(buildConflictsSection(report.peripheralConflicts));
|
|
314
|
+
}
|
|
315
|
+
// 5. Async tasks
|
|
316
|
+
sections.push(buildAsyncTasksSection(report.asyncTasks));
|
|
317
|
+
// 6. Heap / memory estimate
|
|
318
|
+
sections.push(buildHeapEstimateSection(report.heapEstimate));
|
|
319
|
+
// 7. Module Graph
|
|
320
|
+
if (report.moduleGraph) {
|
|
321
|
+
sections.push(buildModuleGraphSection(report.moduleGraph));
|
|
322
|
+
}
|
|
323
|
+
// 8. Tree Shaking
|
|
324
|
+
if (report.treeShaking) {
|
|
325
|
+
sections.push(buildTreeShakingSection(report.treeShaking));
|
|
326
|
+
}
|
|
327
|
+
// 9. Build Timing
|
|
328
|
+
if (report.buildTiming) {
|
|
329
|
+
sections.push(buildTimingSection(report.buildTiming));
|
|
330
|
+
}
|
|
331
|
+
// 10. Transpile Diagnostics
|
|
332
|
+
if (report.transpileDiagnostics) {
|
|
333
|
+
sections.push(buildDiagnosticsSection(report.transpileDiagnostics));
|
|
334
|
+
}
|
|
335
|
+
return sections.join("\n\n");
|
|
336
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { CallGraph } from "../ir/call-graph.js";
|
|
2
|
+
import type { GpioPinEntry, PeripheralAllocation, AsyncTaskEntry, ExecutionFlow, HeapEstimate, PeripheralConflictEntry, ModuleGraph, TreeShakingReport, BuildTiming } from "./json-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build a categorized architecture diagram showing how the sketch
|
|
5
|
+
* is organized: entry points, HAL objects, Arduino APIs (grouped by
|
|
6
|
+
* subsystem), state variables, and custom functions.
|
|
7
|
+
*
|
|
8
|
+
* Noise symbols (true/false/HIGH/board chain) are filtered out.
|
|
9
|
+
* Nodes are laid out horizontally within subgraphs for readability.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildExecutionFlowDiagram(flow: ExecutionFlow, callGraph: CallGraph): string;
|
|
12
|
+
/**
|
|
13
|
+
* Build a specialized flow diagram for ISR (Interrupt) handlers.
|
|
14
|
+
* Shows only the paths starting from hardware events to their deep dependencies.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildInterruptMap(flow: ExecutionFlow, callGraph: CallGraph): string;
|
|
17
|
+
/**
|
|
18
|
+
* Build a pie chart showing pin usage distribution.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildPinUsagePie(gpio: GpioPinEntry[], summary: {
|
|
21
|
+
totalPins: number;
|
|
22
|
+
usedPins: number;
|
|
23
|
+
unusedPins: number;
|
|
24
|
+
}): string;
|
|
25
|
+
/**
|
|
26
|
+
* Build a markdown table of individual pin assignments.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildPinDetailTable(gpio: GpioPinEntry[]): string;
|
|
29
|
+
/**
|
|
30
|
+
* Build a flowchart showing peripheral resource allocation.
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildPeripheralDiagram(peripherals: PeripheralAllocation[]): string;
|
|
33
|
+
export declare function buildPeripheralTable(peripherals: PeripheralAllocation[]): string;
|
|
34
|
+
/**
|
|
35
|
+
* Build a Gantt chart showing async task intervals (if timing data is available).
|
|
36
|
+
*/
|
|
37
|
+
export declare function buildAsyncTaskDiagram(tasks: AsyncTaskEntry[]): string;
|
|
38
|
+
/**
|
|
39
|
+
* Build a pie chart showing static memory allocation breakdown.
|
|
40
|
+
*/
|
|
41
|
+
export declare function buildHeapPie(heap: HeapEstimate): string;
|
|
42
|
+
/**
|
|
43
|
+
* Build a vertical "stack" visualization of static memory allocation.
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildMemoryMap(heap: HeapEstimate): string;
|
|
46
|
+
/**
|
|
47
|
+
* Build a visualization of the deepest call paths.
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildStackPathsMap(paths: string[][]): string;
|
|
50
|
+
/**
|
|
51
|
+
* Build a conflict table for the markdown report.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildConflictTable(conflicts: PeripheralConflictEntry[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* Build a Mermaid dependency graph of imported modules.
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildModuleGraphDiagram(graph: ModuleGraph): string;
|
|
58
|
+
/**
|
|
59
|
+
* Build a table showing symbols removed by tree shaking.
|
|
60
|
+
*/
|
|
61
|
+
export declare function buildTreeShakingTable(report: TreeShakingReport): string;
|
|
62
|
+
/**
|
|
63
|
+
* Build a table showing build timing phases.
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildTimingTable(timing: BuildTiming): string;
|