Add initial set of parts ported from protoboard; introduce interface protocol builder functions - #1
Add initial set of parts ported from protoboard; introduce interface protocol builder functions#1MarkDannemiller wants to merge 6 commits into
Conversation
One file per protocol (pin, gpio, power, i2c, spi, uart, pwm, analog) exporting typed builder functions that emit InterfaceDef objects with the canonical protocol types, roles, capability tags, and parameter IDs the matching/binding engines understand. Adds defineModule(), a validating constructor that reuses validateProfile to fail bad part definitions at import time. All builders re-exported from the package root. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Bus builders (I2C/SPI/UART/ADC/DAC/PWM) now accept each signal (SDA, SCL, MOSI, TX, channels, ...) declared inline in the part file: physical pin number, display name, and electrical limits (V, mA, Hz). Builders generate the leaf pin InterfaceDefs and auto-wire the default profile, returning InterfaceDef[] to spread into the module. Signals may still reference pre-declared pin ids (MCU/GPIO-matrix style). New `instance` option numbers repeated peripherals (i2c1 -> SDA1/SCL1, adc2 -> ADC2_CH0). InterfaceDef gains an optional `pin` field for the physical package pin, also settable on Pin/PowerIn/PowerOut/Ground. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
merge drc work and validation into define parts
Establish library/parts/ as the canonical home for audited ModuleDefs per showcase-plan section 2.3, and add the build step that turns them into a consumable manifest. - library/parts/: 18 audited ModuleDefs (one file per part) spanning the electrical, mechanical, thermal, network, and pneumatic domains, each with a thumbnail artifact, plus an index.ts barrel re-exporting them. Imports were rehomed from ./OpenUHD/src/... to ../../src/... since the defs were authored outside the repo; content is otherwise as-audited. - scripts/build-library.ts + npm run build:library: emits library/dist/index.json (search manifest with id, name, taxonomy, protocols, domains, thumbnail, manufacturer, part_number, version) and library/dist/parts/<id>.json per part. Fails fast on duplicate ids. - tsconfig.json: include library/**/*.ts and scripts/**/*.ts so both are typechecked. tsconfig.build.json stays src-only, so dist is unaffected. - package.json: add tsx devDependency and ship "library" in files. - test: add esp32-d0wdq6 coverage and fixture. library/dist/ stays gitignored as generated output, so consumers must run build:library before publish. Verified: tsc --noEmit clean, 89/89 tests passing, build:library emits 18 parts. Known issue: hcsr04-ultrasonic-sensor.ts declares id "HCSR04-Ultrasonic-Sensor" while the other 17 use lowercase kebab-case. Left as-audited rather than silently edited; it propagates to the dist filename and artifacts path and should be normalized at the source.
Add the generated standalone and fragment preview renders for the pair visualizer, alongside the existing visualizer spec and .pen source in design/. These are generated output kept in the repo for reference when iterating on the visualizer design.
Resolve the two follow-ups left open by the parts library commit. - hcsr04-ultrasonic-sensor.ts declared id "HCSR04-Ultrasonic-Sensor" while the other 17 parts use lowercase kebab-case. The casing leaked into the dist filename, the thumbnail path, and the public URL slug. Normalized to "hcsr04-ultrasonic-sensor" and renamed the artifacts directory to match, since build-library resolves thumbnails from library/parts/<id>/artifacts/thumbnail.png keyed on the id. All 18 manifest ids are now lowercase. The remaining "HCSR04-Ultrasonic-Sensor" strings in the file are provenance pointers to the upstream ProtoPart source directory, which is genuinely named that. Left intact. - Add a prepack script running build then build:library. library/dist is gitignored generated output, so without this a publish could ship the "library" files entry with no manifest inside it. Verified: tsc --noEmit clean, 89/89 tests passing, and prepack from a cold start emits dist/index.js plus 18 part JSONs and 18 thumbnails.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e23e4d568
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "files": [ | ||
| "dist", | ||
| "src", | ||
| "library", |
There was a problem hiding this comment.
Expose the generated library subpaths
Adding library to the packed files does not make it importable because this package already has an explicit exports map that only allows . and ./drc. Any website or consumer trying to statically import the generated manifest/part JSON via a package subpath such as @deltarobotics/uhd/library/dist/index.json will hit ERR_PACKAGE_PATH_NOT_EXPORTED, so the new library artifacts need matching exports entries (or another documented access path) before they can be consumed from the published package.
Useful? React with 👍 / 👎.
| ...(config.pin !== undefined ? { pin: config.pin } : {}), | ||
| domain: "electrical", | ||
| exposed: config.exposed ?? true, | ||
| default_active: config.defaultActive ?? true, |
There was a problem hiding this comment.
Avoid activating every supply alternative by default
For parts that model mutually exclusive supply inputs with a one_of group, such as Arduino Nano VIN vs USB and ESP32 DevKit USB/5V/3V3, callers omit defaultActive, so this default marks every PowerIn() rail active. A fresh instantiateModule() followed by validateInterfaceGroups() then reports multiple active power-source members before the user has selected a path, making those newly added library parts invalid by default; make alternative supply inputs opt-in or default only one selected profile active.
Useful? React with 👍 / 👎.
This PR adds helpers for initializing modules, interfaces, protocols, and a small set of parts for use by the Protoboard website showcase: https://protoboard.ai/parts