Skip to content

Commit 23c6d67

Browse files
feat: diagnostics jump-to with keyboard navigation. (#17)
1 parent 9ba2a1c commit 23c6d67

13 files changed

Lines changed: 701 additions & 160 deletions

README.md

Lines changed: 25 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,41 @@
1-
# @knighted/develop
1+
<h1>
2+
<img src="src/logo.svg" alt="@knighted/develop logo" width="32" height="32" valign="middle" />
3+
<code>@knighted/develop</code>
4+
</h1>
25

3-
Compiler-as-a-Service (at the edge of your browser) with `@knighted/jsx` and `@knighted/css`.
6+
CDN-first browser IDE for building UI components with [`@knighted/jsx`](https://github.com/knightedcodemonkey/jsx) and [`@knighted/css`](https://github.com/knightedcodemonkey/css).
47

5-
> ⚠️ Early project status: this package is pre-`1.0.0` and still actively evolving.
8+
![Animated flow showing editing, diagnostics, jump-to-source, and fix loop](docs/media/develop-ide-flow.gif)
69

710
## What it is
811

9-
`@knighted/develop` is a lightweight dev app that lets you:
12+
`@knighted/develop` is a browser-native IDE that demonstrates modern component
13+
authoring without a local bundler-first inner loop.
1014

11-
- write component code in the browser
12-
- switch render mode between DOM and React
13-
- switch style mode between native CSS, CSS Modules, Less, and Sass
14-
- preview results immediately
15-
16-
## Local development
17-
18-
```bash
19-
npm install
20-
npm run dev
21-
```
22-
23-
Then open the URL printed by the dev server (it should open `src/index.html`).
24-
25-
## End-to-end tests
15+
The app is designed to showcase two libraries:
2616

27-
Install Playwright browsers once before your first local run:
17+
- [`@knighted/jsx`](https://github.com/knightedcodemonkey/jsx) for DOM-first and React-mode JSX authoring
18+
- [`@knighted/css`](https://github.com/knightedcodemonkey/css) for in-browser CSS compilation workflows
2819

29-
```bash
30-
npx playwright install
31-
```
20+
Dependencies are delivered over CDN ESM with on-demand loading by mode, so the
21+
browser acts as the runtime host for render, lint, and typecheck flows.
3222

33-
If your environment needs system dependencies too (for example Linux CI-like containers), use:
23+
## Core capabilities
3424

35-
```bash
36-
npx playwright install --with-deps
37-
```
25+
`@knighted/develop` lets you:
3826

39-
Run local Playwright tests (Chromium):
40-
41-
```bash
42-
npm run test:e2e
43-
```
44-
45-
Run locally with headed browser:
46-
47-
```bash
48-
npm run test:e2e:headed
49-
```
50-
51-
CI runs Playwright on Chromium and WebKit.
27+
- write component code in the browser
28+
- switch render mode between DOM and React
29+
- switch style mode between native CSS, CSS Modules, Less, and Sass
30+
- run in-browser lint and type diagnostics
31+
- open diagnostics in a shared drawer and jump to source locations
32+
- toggle ShadowRoot preview isolation while iterating
33+
- switch layout and theme while preserving fast feedback loops
5234

53-
## Notes
35+
## Try it
5436

55-
- This is currently a development playground, not a stable product.
56-
- Expect breaking changes while APIs and UX are still being shaped.
57-
- Documentation will expand closer to `1.0.0`.
37+
- Live IDE: https://knightedcodemonkey.github.io/develop/
38+
- Source repository: https://github.com/knightedcodemonkey/develop
5839

5940
## License
6041

docs/article.md

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,78 @@
1-
# Forget The Build Step: Building A Compiler-as-a-Service Playground
1+
# Forget The Build Step: A Browser-Native IDE For JSX + CSS
22

3-
In modern frontend development, we have normalized a heavy local setup cost. Want JSX and modern CSS dialects? Install a large dependency graph, start a dev server, and wait for transpilation loops before you can really iterate.
3+
Frontend tooling has become incredibly capable.
44

5-
I wanted to test a different path: what if we removed the terminal from the inner loop?
5+
It has also become very heavy.
66

7-
That experiment became @knighted/develop, a browser-native playground that treats your tab as a real-time compiler host.
7+
For many UI experiments, the first thing you do is not write code. You install dependencies, run a dev server, wait for transforms, and only then start iterating.
88

9-
## The Core Idea
9+
I wanted to try a different baseline:
1010

11-
Most playgrounds rely on a backend build service. @knighted/develop flips that model:
11+
What if the browser is the dev environment?
1212

13-
- JSX compilation and execution happen in the browser.
14-
- CSS transforms (including CSS Modules, Less, and Sass) run in the browser.
15-
- Compilers are loaded on demand from CDN sources.
13+
That idea became [@knighted/develop](https://github.com/knightedcodemonkey/develop).
1614

17-
The result is a development loop that feels direct: type, compile, render, repeat.
15+
It is a lightweight in-browser IDE built to showcase [@knighted/jsx](https://github.com/knightedcodemonkey/jsx) and [@knighted/css](https://github.com/knightedcodemonkey/css), with dependencies delivered over CDN ESM instead of requiring a local build step in the inner loop.
1816

19-
## The Stack Behind It
17+
## The Loop, In Practice
2018

21-
Two libraries power the runtime:
19+
Open a page, write JSX and styles, switch rendering/style modes, run lint/typecheck, and see results immediately.
2220

23-
- @knighted/jsx: JSX that resolves to real DOM nodes.
24-
- No virtual DOM requirement.
25-
- You can use declarative JSX and imperative DOM APIs in the same flow.
26-
- @knighted/css: A browser-capable CSS compiler pipeline.
27-
- Supports native CSS, CSS Modules, Less, and Sass.
28-
- Uses WASM-backed tooling for modern transforms.
21+
No local bundler needed for that loop.
2922

30-
Under the hood, the app leans on CDN resolution and lazy loading, so it fetches compiler/runtime pieces only when a mode needs them.
23+
## What Makes It Fun To Use
3124

32-
## Why "Compiler-as-a-Service"?
25+
The app is intentionally practical, not just a demo shell:
3326

34-
Compiler-as-a-Service here does not mean a remote build cluster.
27+
- Render mode switch: DOM or React
28+
- Style mode switch: CSS, CSS Modules, Less, Sass
29+
- Live preview with ShadowRoot toggle
30+
- In-browser lint and type diagnostics
31+
- Diagnostics drawer with jump-to-line navigation (mouse or keyboard)
3532

36-
It means the service boundary is split between:
33+
So it is not only "can this compile?" It is closer to "can I actually iterate on a component quickly?"
3734

38-
- global CDN infrastructure (module and WASM delivery), and
39-
- the user device (actual compilation and execution).
35+
## Why `@knighted/jsx` + `@knighted/css` Matter Here
4036

41-
If you switch into Sass mode, the browser loads Sass support. If you stay in native CSS mode, it does not pay that cost. The compiler behaves like an on-demand service, but the work stays local to the tab.
37+
`@knighted/develop` is primarily a showcase app.
4238

43-
## What This Enables
39+
It demonstrates how these libraries behave in a real authoring environment:
4440

45-
- Fast feedback loops
46-
- Rendering updates track edits with minimal overhead.
47-
- Mixed declarative and imperative workflows
48-
- Useful for low-level UI experiments and DOM-heavy component prototypes.
49-
- Isolation testing with ShadowRoot
50-
- Toggle encapsulation to verify style boundary behavior.
51-
- Zero install inner loop
52-
- Open a page and start building.
41+
- `@knighted/jsx` gives you a direct path from JSX to rendered output, including DOM-first workflows.
42+
- `@knighted/css` handles modern style pipelines in-browser, including Modules/Less/Sass.
43+
44+
Using both together in one interface makes the bigger point obvious: modern browsers can do much more of the compile/authoring cycle than we usually ask them to.
45+
46+
## "Compiler-as-a-Service" Without A Backend Build Farm
47+
48+
In this project, Compiler-as-a-Service means:
49+
50+
- CDN handles module and WASM delivery.
51+
- The browser tab does the actual compile, lint, typecheck, and render work.
52+
53+
It is service-oriented distribution, local execution.
54+
55+
And because loading is mode-aware, you only pay for what you use. If you never touch Sass, you never load Sass.
5356

5457
## Why This Matters
5558

56-
The point is not to replace every production build pipeline.
59+
This is not trying to replace production pipelines.
5760

58-
The point is to prove a stronger baseline: modern browsers are now capable enough to host substantial parts of the authoring and compile cycle directly, without defaulting to local toolchain setup for every experiment.
61+
It is about lowering the cost of exploration.
5962

60-
For prototyping and component iteration, that changes the cost model dramatically.
63+
When the setup tax drops, you try more ideas. When feedback is instant, you discover faster. And when the browser is the platform, sharing a repro can be as easy as sharing a URL.
6164

62-
## Try It
65+
For prototyping and component iteration, that is a meaningful shift.
6366

64-
- Live playground: https://knightedcodemonkey.github.io/develop/
65-
- Source repository: https://github.com/knightedcodemonkey/develop
67+
## Try It
6668

67-
## Notes For Publishing
69+
- Live IDE: https://knightedcodemonkey.github.io/develop/
70+
- Source: https://github.com/knightedcodemonkey/develop
6871

69-
If you post this on Medium (or similar), include a short screen recording that shows:
72+
If you are curious, start by toggling:
7073

71-
- switching style modes (CSS -> Modules -> Less -> Sass),
72-
- toggling ShadowRoot on and off, and
73-
- immediate preview updates while typing.
74+
1. DOM -> React render mode
75+
2. CSS -> Modules -> Less -> Sass style mode
76+
3. ShadowRoot on/off
7477

75-
That visual sequence communicates the Compiler-as-a-Service model faster than any architecture diagram.
78+
That sequence tells the story better than any architecture diagram.

docs/contributing.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Contributing
2+
3+
Thanks for contributing to `@knighted/develop`.
4+
5+
This project is a CDN-first browser IDE for showcasing `@knighted/jsx` and
6+
`@knighted/css`, so local workflows should preserve browser execution behavior
7+
and avoid bundler-only assumptions in `src/` runtime code.
8+
9+
## Project docs
10+
11+
- Type checking notes: `docs/type-checking.md`
12+
- Build and deploy notes: `docs/build-and-deploy.md`
13+
- CodeMirror integration notes: `docs/code-mirror.md`
14+
- Roadmap: `docs/next-steps.md`
15+
- Article draft: `docs/article.md`
16+
17+
## Prerequisites
18+
19+
- Node.js `>= 22.22.1`
20+
- npm
21+
22+
## Install
23+
24+
```bash
25+
npm install
26+
```
27+
28+
## Local development
29+
30+
Start the local app:
31+
32+
```bash
33+
npm run dev
34+
```
35+
36+
The local server opens `src/index.html`.
37+
38+
## Build commands
39+
40+
Build prep + CSS + import map generation:
41+
42+
```bash
43+
npm run build
44+
```
45+
46+
Build with explicit primary CDN modes:
47+
48+
```bash
49+
npm run build:esm
50+
npm run build:jspm
51+
npm run build:importmap-mode
52+
```
53+
54+
Preview generated dist output:
55+
56+
```bash
57+
npm run preview
58+
```
59+
60+
## Validation commands
61+
62+
Lint source and Playwright files:
63+
64+
```bash
65+
npm run lint
66+
```
67+
68+
Type check TS tooling files:
69+
70+
```bash
71+
npm run check-types
72+
```
73+
74+
## Playwright end-to-end tests
75+
76+
Install browser binaries once:
77+
78+
```bash
79+
npx playwright install
80+
```
81+
82+
If your environment also needs system deps (for example CI-like Linux
83+
containers):
84+
85+
```bash
86+
npx playwright install --with-deps
87+
```
88+
89+
Run preview-mode E2E suite:
90+
91+
```bash
92+
npm run test:e2e
93+
```
94+
95+
Run dev-mode E2E suite:
96+
97+
```bash
98+
npm run test:e2e:dev
99+
```
100+
101+
Run preview-mode suite headed:
102+
103+
```bash
104+
npm run test:e2e:headed
105+
```
106+
107+
## Contributor checklist
108+
109+
Before opening a PR:
110+
111+
1. Run `npm run lint`.
112+
2. Run `npm run build:esm` for runtime/build changes.
113+
3. Run relevant Playwright tests for UI/runtime changes.
114+
4. Update docs when user-facing behavior or workflows change.
115+
116+
## Scope guidance
117+
118+
- Keep changes focused to `@knighted/develop`.
119+
- Preserve CDN-first loading and fallback behavior.
120+
- Avoid editing generated output unless explicitly required.

docs/media/develop-ide-flow.gif

1.14 MB
Loading

docs/next-steps.md

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,16 @@
22

33
Focused follow-up work for `@knighted/develop`.
44

5-
1. **In-browser lint rules review and expansion**
6-
- Review the currently active Biome lint configuration in `src/modules/lint-diagnostics.js`, including rule groups, severities, and any custom suppression behavior.
7-
- Produce a recommended rule profile for component and style linting that balances signal quality with playground ergonomics.
8-
- Evaluate additional Biome rules to enable (or elevate severity) for:
9-
- correctness and suspicious patterns in component code,
10-
- accessibility and style consistency in JSX output,
11-
- CSS quality checks for style sources currently supported by Biome.
12-
- Revisit existing exceptions (for example unused App/View/render bindings) and document clear criteria for when suppression is acceptable.
13-
- Add/update regression coverage for the chosen rule profile in Playwright so diagnostics button/drawer behavior remains stable as rules evolve.
14-
- Document the finalized lint rule strategy in project docs so contributors can reason about why each rule is enabled, disabled, or downgraded.
15-
- Suggested implementation prompt:
16-
- "Audit the current Biome lint rules used by `@knighted/develop`, propose and apply a refined rule profile for component/styles linting, and add/update Playwright coverage to keep diagnostics UX stable under the new rules. Preserve intentional suppressions only when justified and document the reasoning. Validate with `npm run lint`, `npm run build:esm`, and targeted lint diagnostics Playwright tests."
17-
18-
2. **In-browser component type checking**
19-
- Add editor-linked diagnostics navigation so each issue can jump to the exact line/column in the component source.
20-
- Surface line/column context directly in the diagnostics UI (not just message text) to speed up triage.
21-
- Continue improving typecheck performance for first-run and large sources while keeping the preview loop non-blocking.
22-
23-
3. **In-browser component testing**
5+
1. **In-browser component testing**
246
- Explore authoring and running component-focused tests in-browser (for example, a Vitest-compatible flow) using CDN-delivered tooling.
257
- Define a lightweight test UX that supports writing tests, running them on demand, and displaying results in-app.
268

27-
4. **CDN failure recovery UX**
9+
2. **CDN failure recovery UX**
2810
- Detect transient CDN/module loading failures and surface a clear recovery action in-app.
2911
- Add a user-triggered retry path (for example, Reload page / Force reload) when runtime bootstrap imports fail.
3012
- Consider an optional automatic one-time retry before showing recovery controls, while avoiding infinite reload loops.
3113

32-
5. **Type reference parsing hardening (TS preprocessor-first)**
33-
- Transition declaration/reference discovery in in-browser type diagnostics to a TypeScript preprocessor-first flow (`ts.preProcessFile`) instead of regex-driven parsing.
34-
- Scope this to the lazy React type environment loader first, then evaluate whether the same parser path should be reused for all type package graph walking.
35-
- Keep current lazy-loading behavior intact: no React type graph fetch until the user switches to React render mode and triggers Typecheck.
36-
- Preserve CDN provider fallback behavior and existing diagnostics UX while changing parser internals.
37-
- Add a strict fallback contract:
38-
- Primary: `preProcessFile` outputs (`importedFiles`, `referencedFiles`, `typeReferenceDirectives`).
39-
- Secondary fallback only when unavailable: current lightweight parsing logic.
40-
- Never treat commented example code as imports/references.
41-
- Add guardrails around known failure classes discovered during development:
42-
- Relative declaration references like `global.d.ts` must resolve as file paths, not package names.
43-
- Extensionless declaration references (for example `./user-context`) must attempt `.d.ts` candidates first.
44-
- Avoid noisy parallel fetch fan-out for bad candidates; use ordered fallback to reduce 404/CORS console noise.
45-
- Add focused test coverage (unit or Playwright) that proves:
46-
- React-mode typecheck does not trigger fake fetches from commented examples in declaration files.
47-
- React-mode typecheck resolves `react` and `react-dom/client` without module-not-found diagnostics.
48-
- DOM mode still avoids React type graph hydration.
49-
- Suggested implementation prompt:
50-
- "Refactor `src/modules/type-diagnostics.js` to make TypeScript preprocessor parsing (`preProcessFile`) the source of truth for declaration graph discovery in the lazy React type loader. Keep current CDN fallback and lazy hydration semantics. Ensure references from comments are ignored, `*.d.ts`/relative path handling is correct, and candidate fetch ordering minimizes noisy failed requests. Add regression coverage for `global.d.ts` and commented `./user-context` examples. Validate with `npm run lint`, `npm run build:esm`, and targeted React/typecheck Playwright runs."
51-
52-
6. **Deterministic E2E lane in CI**
14+
3. **Deterministic E2E lane in CI**
5315
- Add an integration-style E2E path that uses locally served/pinned copies of CDN runtime dependencies for test execution, while keeping production runtime behavior unchanged.
5416
- Keep the current true CDN-backed E2E path as a separate smoke check, but make the deterministic lane the required gate for pull requests.
5517
- Run this deterministic E2E suite on **every pull request** in CI.

0 commit comments

Comments
 (0)