Commit 38b8c3a
feat(safe-dom): add minimal SafeDOM package and runnable example (#26)
## Summary
- New workspace package `tools/safe-dom/` implementing the SafeDOM
surface that the orphaned `examples/SafeDOMExample.res` already assumed
(`ProvenSelector` / `ProvenHTML`, `mount`, `mountSafe`,
`mountWhenReady`, `mountBatch`).
- Moves the example into the package so the build now actually verifies
it. Fixes three latent bugs in the example revealed by the first
compile:
1. `mountWithValidation` was missing one `}` (outer `switch` never
closed).
2. Multi-arg `Console.log("label", value)` was JS-style; switched to
RescriptCore's `Console.log2` / `Console.error2`.
3. Template literal with `Array.length(...)` needed `->Int.toString` (no
implicit int→string in ReScript).
- Root `package-lock.json` is committed because npm hoisted the
workspace on install — it locks the resolved tree across all members.
## Why this matters
Closes the last gap in the TS→ReScript migration: every `.res` source in
the repo now builds. Previously `examples/SafeDOMExample.res` referenced
`open SafeDOM` with no implementation anywhere — aspirational code
masquerading as a runnable example.
## Test plan
- [x] `rescript build` in `tools/safe-dom` succeeds (no warnings).
- [x] All other ReScript packages still build (cli, github-action,
monitoring-api, stale/core, stale/scanner, stale/components/react —
exit=0 each).
- [x] `find . -name "*.ts" -not -path "*/node_modules/*" -not -path
"*/.git/*"` returns 0 results — antipattern check trivially passes.
- [ ] Reviewer: confirm the safety story for `mountBatch` (documented
in-source: validation is atomic, mutation phase is best-effort and not
transactionally reversible).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 16cd81a commit 38b8c3a
7 files changed
Lines changed: 3846 additions & 9 deletions
File tree
- tools/safe-dom
- src
0 commit comments