@webjsdev/cli 0.10.65 → 0.10.66
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/bin/webjs.js
CHANGED
|
@@ -1577,7 +1577,16 @@ async function main() {
|
|
|
1577
1577
|
let tscPath;
|
|
1578
1578
|
try {
|
|
1579
1579
|
const req = createRequire(join(cwd, 'package.json'));
|
|
1580
|
-
|
|
1580
|
+
// The `tsc` bin the package itself declares. TypeScript 7 (the native
|
|
1581
|
+
// compiler) restricts its subpaths with `exports`, so
|
|
1582
|
+
// `typescript/bin/tsc` no longer resolves; its package.json does, in
|
|
1583
|
+
// every major, and names the bin. Its launcher spawns the native
|
|
1584
|
+
// binary: about a quarter of the 6.x compiler's memory, five times
|
|
1585
|
+
// faster.
|
|
1586
|
+
const pkgPath = req.resolve('typescript/package.json');
|
|
1587
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
1588
|
+
const bin = typeof pkg.bin === 'string' ? pkg.bin : pkg.bin?.tsc;
|
|
1589
|
+
tscPath = bin ? join(dirname(pkgPath), bin) : req.resolve('typescript/bin/tsc');
|
|
1581
1590
|
} catch {
|
|
1582
1591
|
console.error(
|
|
1583
1592
|
'webjs typecheck: TypeScript is not installed in this project.\n' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webjsdev/cli",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.66",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The CLI for WebJs, a full-stack JavaScript framework built on web components with server-side rendering and no build step. Runs the dev and production servers, scaffolds apps, validates conventions, and drives the database. Node 24+ or Bun.",
|
|
6
6
|
"bin": {
|
|
@@ -30,7 +30,7 @@ Most of what follows restates widely held component-model advice, ported. Lit's
|
|
|
30
30
|
|
|
31
31
|
**4. ARIA state is a hole in `render()`, derived from the same state that drives behaviour.** `aria-expanded=${this.open ? 'true' : 'false'}` cannot disagree with `this.open`. A second function that re-finds the button and calls `setAttribute` can, and does, the first time someone adds a close path that forgets to call it. The same holds for `class`, `?disabled`, and any `.prop`. Two caveats ride this rule:
|
|
32
32
|
|
|
33
|
-
-
|
|
33
|
+
- A plain-attribute hole follows one rule on the server and the client (#1573): `null` / `undefined` omit the attribute, `false` omits it except on an `aria-*` name, where it is written as `"false"`. So `aria-expanded=${this.open}` serves `"true"` / `"false"` and hydrates unchanged, and `aria-current=${active ? 'page' : null}` omits the attribute on an inactive link. `?attr=${bool}` is not a substitute for a tri-state ARIA attribute, since a boolean binding omits the attribute when false.
|
|
34
34
|
- A hole commits on the next render, one microtask later. The one place a direct write is still correct is a synchronous snapshot read such as `webjs:before-cache`, where the router reads `outerHTML` in the same task. That is a documented exception, not the normal path.
|
|
35
35
|
|
|
36
36
|
**5. Behaviour needs an importable surface, or its test is a copy of it.** An inline `<script>` in a layout has no module identity, so a browser test cannot import it. It can only transcribe the listener into the test file and assert against the transcription, which then needs a SECOND test to grep the original for drift. Two tests, neither running shipping code. A component is importable, so its browser test mounts the real element and drives real events. A page or layout may still carry an inline `<script>`, but only for pre-paint boot work no module can do: reading a stored theme before first paint so the wrong palette never flashes, or measuring the header height into a CSS custom property. It must not be interactivity, and WHERE it sits decides how often it runs. The ROOT layout's markup sits OUTSIDE every swap range, so a soft navigation does not re-run its script, which is what makes it the right home for boot work and the wrong home for anything that has to respond to a later navigation. A page or a NESTED layout sits inside the swap range instead, so its script re-executes on every navigation that swaps that range (#1102), which means it has to be idempotent or guard on a flag it sets the first time. Neither shape gives you a listener that simply works, which is what a custom element is for. Under an opt-in CSP the script also needs the nonce from `cspNonce()`. `client-router-and-streaming.md` carries the full re-execution rule.
|
|
@@ -402,7 +402,7 @@ A component that does no client-side work renders the same SSR'd HTML with or wi
|
|
|
402
402
|
- a factory-declared reactive property that is not `{ state: true }`
|
|
403
403
|
- an overridden lifecycle hook (including `renderFallback` / `renderError`)
|
|
404
404
|
- an imported `signal` / `computed` / `watch` / `Task` / `ref` / streaming directive, or `addController` / `requestUpdate`
|
|
405
|
-
- code that runs at module load (a top-level call, non-data `new`, dynamic `import(...)`, top-level `await`); only declarations and `X.register(...)` are allowed. TypeScript types are erased before the analyser reads a module, so an annotation can never be a blocker however call-shaped it looks (`readonly (readonly [number, number, number])[]` is fine)
|
|
405
|
+
- code that runs at module load (a top-level call, non-data `new`, dynamic `import(...)`, top-level `await`); only declarations and `X.register(...)` are allowed. A call inside a declaration does not run at load, so it is not a blocker: an arrow's expression body (`export const usd = (m) => Math.round(m) / MICROS`) and a function parameter default (`function relativeTime(when, now = Date.now())`) are both fine. TypeScript types are erased before the analyser reads a module, so an annotation can never be a blocker however call-shaped it looks (`readonly (readonly [number, number, number])[]` is fine)
|
|
406
406
|
- the dynamic slot READ surface (`slotchange`, `assignedNodes` / `assignedElements` / `assignedSlot`); merely RENDERING a `<slot>` does not ship (the SSR output carries the placed children, so a display-only slotted wrapper is byte-identical without its JS; native-write liveness is consumer-driven and the consumer's tag reference forces the ship)
|
|
407
407
|
- being rendered by a component that itself ships
|
|
408
408
|
|
|
@@ -174,7 +174,7 @@ html`<form action=${submitFeedback}><input name="email"></form>`;
|
|
|
174
174
|
html`<form method="post"><input name="email"></form>`;
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
A hole that resolves to `null`
|
|
177
|
+
A plain attribute hole that resolves to `null` or `undefined` omits the attribute on both renderers (#1573), so `method=${null}` and `?method=${false}` both emit nothing and WebJs supplies `method="post"`. An EMPTY string is different: `method=${''}` renders `method=""`, which cannot submit and is refused.
|
|
178
178
|
|
|
179
179
|
A string stays a string: `action="/search"` and `action=${'/search'}` are unchanged, which is what a search form (`<form method="get" action="/search">`) and a `route.ts` endpoint both want. Other attributes keep their existing stringify behaviour; only a FUNCTION under `action` / `formaction` is claimed.
|
|
180
180
|
|
|
@@ -81,9 +81,9 @@ So the loop is: `add` the component, then query `ui <name>` (MCP) or
|
|
|
81
81
|
## Inventory (run `npx webjsdev ui list` or the MCP `ui` tool for the authoritative, current set)
|
|
82
82
|
|
|
83
83
|
**Tier 1 (class helpers):** accordion, alert, aspect-ratio, avatar, badge,
|
|
84
|
-
breadcrumb, button, card, checkbox, collapsible, input, kbd,
|
|
85
|
-
native-select, pagination, popover, progress, radio-group, separator,
|
|
86
|
-
switch, table, textarea.
|
|
84
|
+
breadcrumb, button, card, checkbox, collapsible, empty, field, input, kbd,
|
|
85
|
+
label, native-select, pagination, popover, progress, radio-group, separator,
|
|
86
|
+
skeleton, spinner, switch, table, textarea.
|
|
87
87
|
|
|
88
88
|
**Tier 2 (custom elements, own their ARIA):** alert-dialog, dialog,
|
|
89
89
|
dropdown-menu, hover-card, sonner, tabs, tooltip, plus toggle and toggle-group
|
|
@@ -93,6 +93,17 @@ dropdown-menu, hover-card, sonner, tabs, tooltip, plus toggle and toggle-group
|
|
|
93
93
|
|
|
94
94
|
- A helper is a function, so compose it: `class=${buttonClass({ variant: 'outline' })}`.
|
|
95
95
|
The unquoted `${...}` is a normal `html` attribute hole.
|
|
96
|
+
- The three states a screen owes its user each have a primitive, so do not hand-roll
|
|
97
|
+
them. A list or table with no rows renders `empty` (title as a real heading, a
|
|
98
|
+
description saying what to do next, and the create action). A form field is
|
|
99
|
+
`field` (`fieldClass()` holding a `<label for>`, the control, `fieldDescriptionClass()`
|
|
100
|
+
text, and on a validation error `data-invalid="true"`, `aria-invalid` on the control,
|
|
101
|
+
and a `fieldErrorClass()` message with `role="alert"` whose id the control's
|
|
102
|
+
`aria-describedby` lists, with the typed value kept). A pending save puts
|
|
103
|
+
`spinner({ decorative: true })` in a `disabled` + `aria-busy="true"` submit button
|
|
104
|
+
that keeps its text. The `fieldClass` / `fieldLabelClass` in `components/ui/field.ts`
|
|
105
|
+
are not the same-named rhythm helpers in `lib/utils/cn.ts`; import each from its own
|
|
106
|
+
module and alias one if a file needs both.
|
|
96
107
|
- Tier-1 helpers assume the design tokens exist; if a component paints unstyled,
|
|
97
108
|
the tokens are missing (re-run `npx webjsdev ui init` or let `add` self-heal them).
|
|
98
109
|
- Custom elements are display-only-safe at SSR and hydrate in the browser, the
|