Commit Graph

8 Commits

Author SHA1 Message Date
Buddy
76d78e1925 Accept a CSSStyleSheet as css; move example CSS and templates into files
css is now string | CSSStyleSheet. A sheet is adopted as-is: into its own
shadow root, an enclosing shadow root, or document.adoptedStyleSheets for
light DOM at the document level. Strings behave as before.

The examples import their styles with `with { type: 'css' }` and their
static templates with `with { type: 'text' }`. Safari doesn't support those
yet, so vite.config.ts rewrites them into modules Vite builds: a constructed
CSSStyleSheet, or the file's text. npm run examples now just runs vite,
with root set in the config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:44:27 -08:00
Buddy
be8ee0198f Add typed events map: true, listener options, listen<E>(), or custom<T>()
events maps a name to true, listener options, listen<E>(options?) for an
explicit event type, or custom<T>(options?) for a CustomEvent<T> (the same as
listen<CustomEvent<T>>()). Otherwise an event is typed from HTMLElementEventMap
by name. The array form is gone. handleEvent gets HandledEvent<S>, each event
tagged with its literal type so event.type narrows.
2026-11-10 09:59:09 -08:00
Buddy
6ece00c8cc Allow static names as props and rename attributeFor back to attributes
Props live on instances, so statics on the generated class or the base
can't collide with them. Only instance members of the base and the
mixin are reserved now.
2026-11-07 12:25:11 -08:00
Buddy
98c209741d Throw on wrong-class [selector, Class] refs instead of skipping them 2026-11-06 21:33:42 -08:00
Buddy
b26cff3468 Support [selector, Class] refs and show resolved types for refs, observedAttributes, and attributeFor 2026-11-06 21:31:14 -08:00
Buddy
a398fc98f1 Reserve static names for props and reject keys shared by element and elements 2026-11-06 14:10:53 -08:00
Buddy
6efcdd210e Rename static attributes map to attributeFor and reserve the name 2026-11-06 14:09:38 -08:00
Buddy
c961d01fc4 Add typed WebComponent mixin factory
WebComponent(spec) builds a custom-element base class from a spec:
shadow root or declarative shadow DOM, template, shared stylesheet
(adopted, or a <style> once per root for light DOM), reflected props
with two-way attribute sync, a per-connection AbortSignal, host event
wiring, and typed element refs.

Types derive exact observedAttributes, prop value types, ref element
types from selectors, and reject prop names that collide with the base
class or mixin members.

Tooling: strict tsconfig, type-aware oxlint, oxfmt, and Vitest browser
mode (Chromium) with type tests.
2026-11-06 00:08:56 -08:00