@jasonshimmy/custom-elements-runtime 2.8.2 → 3.1.0
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/README.md +223 -73
- package/dist/css-utils-Cg4o1MqY.js +643 -0
- package/dist/css-utils-Cg4o1MqY.js.map +1 -0
- package/dist/css-utils-RqkyBWft.cjs +576 -0
- package/dist/css-utils-RqkyBWft.cjs.map +1 -0
- package/dist/custom-elements-runtime.cjs.js +3 -3
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js +7 -0
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.dom-jit-css.es.js +136 -0
- package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -0
- package/dist/custom-elements-runtime.es.js +105 -97
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +62 -46
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.cjs.js +2 -0
- package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.jit-css.es.js +37 -0
- package/dist/custom-elements-runtime.jit-css.es.js.map +1 -0
- package/dist/custom-elements-runtime.router.cjs.js +20 -20
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +472 -458
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +2 -0
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.ssr-middleware.es.js +63 -0
- package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -0
- package/dist/custom-elements-runtime.ssr.cjs.js +3 -1
- package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +137 -24
- package/dist/custom-elements-runtime.ssr.es.js.map +1 -1
- package/dist/custom-elements-runtime.store.cjs.js +1 -1
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +21 -16
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +279 -7
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +2 -0
- package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.vite-plugin.es.js +105 -0
- package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -0
- package/dist/dom-jit-css.d.ts +66 -0
- package/dist/event-bus.d.ts +3 -1
- package/dist/hooks-B50HhrHh.cjs +6 -0
- package/dist/hooks-B50HhrHh.cjs.map +1 -0
- package/dist/hooks-Cze3o-F7.js +1462 -0
- package/dist/hooks-Cze3o-F7.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/jit-css.d.ts +30 -0
- package/dist/namespace-helpers-D4wC2-qA.js +61 -0
- package/dist/namespace-helpers-D4wC2-qA.js.map +1 -0
- package/dist/namespace-helpers-ckeEOxpR.cjs +2 -0
- package/dist/namespace-helpers-ckeEOxpR.cjs.map +1 -0
- package/dist/router/matcher.d.ts +14 -0
- package/dist/router/types.d.ts +4 -2
- package/dist/runtime/component/factory.d.ts +16 -2
- package/dist/runtime/css-utils.d.ts +33 -0
- package/dist/runtime/discovery-state.d.ts +3 -0
- package/dist/runtime/hooks.d.ts +78 -0
- package/dist/runtime/hydration.d.ts +33 -0
- package/dist/runtime/jit-hooks.d.ts +28 -0
- package/dist/runtime/render-bridge.d.ts +37 -0
- package/dist/runtime/scheduler.d.ts +3 -4
- package/dist/runtime/secure-expression-evaluator.d.ts +0 -1
- package/dist/runtime/ssr-context.d.ts +45 -0
- package/dist/runtime/style.d.ts +84 -26
- package/dist/runtime/template-compiler/lru-cache.d.ts +0 -3
- package/dist/runtime/types.d.ts +18 -0
- package/dist/runtime/vdom-helpers.d.ts +0 -1
- package/dist/runtime/vdom-ssr-dsd.d.ts +58 -0
- package/dist/ssr-middleware.d.ts +125 -0
- package/dist/ssr.d.ts +120 -16
- package/dist/{transitions-DMJXs_tY.js → style-BmyOIMcU.js} +904 -1344
- package/dist/style-BmyOIMcU.js.map +1 -0
- package/dist/style-D40DsIqJ.cjs +55 -0
- package/dist/style-D40DsIqJ.cjs.map +1 -0
- package/dist/style.css +1 -1
- package/dist/template-compiler-Cshhqxyd.cjs +23 -0
- package/dist/template-compiler-Cshhqxyd.cjs.map +1 -0
- package/dist/template-compiler-DtpNsqE-.js +3744 -0
- package/dist/template-compiler-DtpNsqE-.js.map +1 -0
- package/dist/variables.css +1 -1
- package/dist/vite-plugin.d.ts +142 -0
- package/package.json +60 -6
- package/dist/namespace-helpers-Ctd_h7j2.cjs +0 -5
- package/dist/namespace-helpers-Ctd_h7j2.cjs.map +0 -1
- package/dist/namespace-helpers-DhLBqt-7.js +0 -1009
- package/dist/namespace-helpers-DhLBqt-7.js.map +0 -1
- package/dist/template-compiler-Bvx02nAT.js +0 -4020
- package/dist/template-compiler-Bvx02nAT.js.map +0 -1
- package/dist/template-compiler-bj-MFC_Y.cjs +0 -23
- package/dist/template-compiler-bj-MFC_Y.cjs.map +0 -1
- package/dist/transitions-DMJXs_tY.js.map +0 -1
- package/dist/transitions-f4KfN29T.cjs +0 -330
- package/dist/transitions-f4KfN29T.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
|
|
7
7
|
Build modern components with strict TypeScript, zero dependencies, and a clean functional API. Designed for speed, standards compliance, and productivity.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- Try it on [Codepen.io](https://codepen.io/jshimkoski/pen/JoYmpxm).
|
|
10
|
+
- Check out the [Material Design 3 Components](https://github.com/jshimkoski/cer-material) built with this runtime.
|
|
11
|
+
- Play a game of [Solatro](https://solatro.netlify.app) built with this runtime in 100% Web Components.
|
|
12
|
+
- Learn more about the author at [jasonshimmy.com](https://jasonshimmy.com).
|
|
10
13
|
|
|
11
14
|
## ✨ Why You'll Love It
|
|
12
15
|
|
|
@@ -30,8 +33,11 @@ import {
|
|
|
30
33
|
defineModel,
|
|
31
34
|
html,
|
|
32
35
|
} from '@jasonshimmy/custom-elements-runtime';
|
|
36
|
+
import { useJITCSS } from '@jasonshimmy/custom-elements-runtime/jit-css';
|
|
33
37
|
|
|
34
38
|
component('my-counter', () => {
|
|
39
|
+
useJITCSS();
|
|
40
|
+
|
|
35
41
|
const count = defineModel('count', 0);
|
|
36
42
|
|
|
37
43
|
const handleClick = () => {
|
|
@@ -74,47 +80,50 @@ Below is the **complete list of public symbols** exported by the runtime and its
|
|
|
74
80
|
|
|
75
81
|
**Package:** `@jasonshimmy/custom-elements-runtime`
|
|
76
82
|
|
|
77
|
-
| Export | Description
|
|
78
|
-
| ---------------------------- |
|
|
79
|
-
| `component` | Define a custom element with the functional component API.
|
|
80
|
-
| `html` | Template tag function producing runtime VNodes from template literals.
|
|
81
|
-
| `css` | Define component-scoped/JIT styles or register stylesheets.
|
|
82
|
-
| `ref` | Create a reactive reference object with a `.value` property.
|
|
83
|
-
| `computed` | Create a memoized, derived read-only value from other reactive sources.
|
|
84
|
-
| `watch` | Register watchers reacting to changes in reactive values.
|
|
85
|
-
| `watchEffect` | Auto-track reactive reads and re-run a side-effect whenever dependencies change.
|
|
86
|
-
| `nextTick` | Returns a Promise resolving after all pending DOM updates are flushed.
|
|
87
|
-
| `flushDOMUpdates` | Synchronously flush all pending DOM update tasks (useful in tests).
|
|
88
|
-
| `scheduleWithPriority` | Schedule a callback at a given `UpdatePriority` level.
|
|
89
|
-
| `provide` | Store a value on the current component for descendant injection.
|
|
90
|
-
| `inject` | Retrieve a value provided by an ancestor component.
|
|
91
|
-
| `createComposable` | Package reusable stateful logic (hooks, reactive state) into a composable.
|
|
92
|
-
| `getCurrentComponentContext` | Access the active component context from within a composable or render function.
|
|
93
|
-
| `useProps` | Hook to declare/consume typed component props with defaults.
|
|
94
|
-
| `defineModel` | Declare a two-way model binding prop; combines `useProps` + `useEmit` in one ergonomic hook.
|
|
95
|
-
| `useEmit` | Hook returning an emit function for dispatching custom events.
|
|
96
|
-
| `useOnConnected` | Hook that runs a callback when the component connects.
|
|
97
|
-
| `useOnDisconnected` | Hook that runs a callback when the component disconnects.
|
|
98
|
-
| `useOnAttributeChanged` | Hook observing host attribute changes.
|
|
99
|
-
| `useOnError` | Hook to register a component-level error handler.
|
|
100
|
-
| `useStyle` | Hook to register or compute component styles at runtime.
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
| `
|
|
115
|
-
| `
|
|
116
|
-
| `
|
|
117
|
-
|
|
|
83
|
+
| Export | Description |
|
|
84
|
+
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
85
|
+
| `component` | Define a custom element with the functional component API. |
|
|
86
|
+
| `html` | Template tag function producing runtime VNodes from template literals. |
|
|
87
|
+
| `css` | Define component-scoped/JIT styles or register stylesheets. |
|
|
88
|
+
| `ref` | Create a reactive reference object with a `.value` property. |
|
|
89
|
+
| `computed` | Create a memoized, derived read-only value from other reactive sources. |
|
|
90
|
+
| `watch` | Register watchers reacting to changes in reactive values. |
|
|
91
|
+
| `watchEffect` | Auto-track reactive reads and re-run a side-effect whenever dependencies change. |
|
|
92
|
+
| `nextTick` | Returns a Promise resolving after all pending DOM updates are flushed. |
|
|
93
|
+
| `flushDOMUpdates` | Synchronously flush all pending DOM update tasks (useful in tests). |
|
|
94
|
+
| `scheduleWithPriority` | Schedule a callback at a given `UpdatePriority` level. |
|
|
95
|
+
| `provide` | Store a value on the current component for descendant injection. |
|
|
96
|
+
| `inject` | Retrieve a value provided by an ancestor component. |
|
|
97
|
+
| `createComposable` | Package reusable stateful logic (hooks, reactive state) into a composable. |
|
|
98
|
+
| `getCurrentComponentContext` | Access the active component context from within a composable or render function. |
|
|
99
|
+
| `useProps` | Hook to declare/consume typed component props with defaults. |
|
|
100
|
+
| `defineModel` | Declare a two-way model binding prop; combines `useProps` + `useEmit` in one ergonomic hook. |
|
|
101
|
+
| `useEmit` | Hook returning an emit function for dispatching custom events. |
|
|
102
|
+
| `useOnConnected` | Hook that runs a callback when the component connects. |
|
|
103
|
+
| `useOnDisconnected` | Hook that runs a callback when the component disconnects. |
|
|
104
|
+
| `useOnAttributeChanged` | Hook observing host attribute changes. |
|
|
105
|
+
| `useOnError` | Hook to register a component-level error handler. |
|
|
106
|
+
| `useStyle` | Hook to register or compute component styles at runtime. |
|
|
107
|
+
| `useDesignTokens` | Apply typed design token overrides to `:host` as CSS custom properties. |
|
|
108
|
+
| `useGlobalStyle` | Inject CSS into `document.adoptedStyleSheets`, escaping Shadow DOM encapsulation. Use sparingly. |
|
|
109
|
+
| `useExpose` | Publish methods and properties onto the host element as an imperative public API. |
|
|
110
|
+
| `useSlots` | Inspect which named slots have been filled by the component consumer. |
|
|
111
|
+
| `useTeleport` | Render virtual DOM content into any DOM node outside the shadow root. |
|
|
112
|
+
| `registerKeepAlive` | Register `<cer-keep-alive>` to preserve component state across DOM removals. |
|
|
113
|
+
| `registerSuspense` | Register the `<cer-suspense>` built-in component. |
|
|
114
|
+
| `registerErrorBoundary` | Register the `<cer-error-boundary>` built-in component. |
|
|
115
|
+
| `registerBuiltinComponents` | Register `<cer-keep-alive>`, `<cer-suspense>` and `<cer-error-boundary>` in one call. |
|
|
116
|
+
| `unsafeHTML` | Insert raw HTML into a template (**unsafe; use carefully**). |
|
|
117
|
+
| `decodeEntities` | Utility to decode HTML entities in strings. |
|
|
118
|
+
| `setDevMode` | Toggle dev-mode logging on or off at runtime. |
|
|
119
|
+
| `devLog` | Log a message to the console in dev mode only (no-op in production). |
|
|
120
|
+
| `isReactiveState` | Type-guard returning `true` when a value is a `ReactiveState` instance. |
|
|
121
|
+
| `createHealthMonitor` | Create a new health monitor instance (factory; each call returns an independent instance). |
|
|
122
|
+
| `getHealthMonitor` | Return the global singleton health monitor instance (lazily created). |
|
|
123
|
+
| `updateHealthMetric` | Update a named metric on the global singleton health monitor. |
|
|
124
|
+
| `getHealthStatus` | Return the current `HealthReport` from the global singleton health monitor. |
|
|
125
|
+
| `hydrateApp` | Trigger hydration of all DSD-rendered custom elements within a root (call after registering all components on the client). |
|
|
126
|
+
| **Types** | `ModelRef`, `HealthMonitorInstance`, `HealthReport`, `UpdatePriority`, `TeleportHandle`, `ReactiveState`, `VNode`, `JITCSSOptions`, `DesignTokens`, `ComponentOptions`, `HydrateStrategy` |
|
|
118
127
|
|
|
119
128
|
---
|
|
120
129
|
|
|
@@ -202,25 +211,25 @@ Below is the **complete list of public symbols** exported by the runtime and its
|
|
|
202
211
|
|
|
203
212
|
**Package:** `@jasonshimmy/custom-elements-runtime/router`
|
|
204
213
|
|
|
205
|
-
| Export | Description
|
|
206
|
-
| ----------------------- |
|
|
207
|
-
| `useRouter` | Create and use a router instance configured with routes (client & SSR).
|
|
208
|
-
| `initRouter` | Initialize the router and register `router-view` / `router-link`.
|
|
209
|
-
| `matchRoute` | Match a path against configured routes and extract params.
|
|
210
|
-
| `matchRouteSSR` | SSR-friendly wrapper for route matching.
|
|
211
|
-
| `findMatchedRoute` | Find the first matching route entry from an array of routes (lower-level helper).
|
|
212
|
-
| `parseQuery` | Parse a query string into a key/value map.
|
|
213
|
-
| `serializeQuery` | Serialize a key/value map into a query string (e.g. `?a=b`).
|
|
214
|
-
| `normalizePathForRoute` | Normalize a path string for consistent route matching (strips trailing slashes, etc.).
|
|
215
|
-
| `DEFAULT_SCROLL_CONFIG` | Default scroll-to-fragment configuration object used by the router.
|
|
216
|
-
| `isDangerousScheme` | Returns `true` for dangerous URL schemes (e.g. `javascript:`).
|
|
217
|
-
| `isAbsoluteUrl` | Returns `true` when a URL string is absolute (has a protocol).
|
|
218
|
-
| `safeDecode` | Decode a URI component, returning the original string on error.
|
|
219
|
-
| `canonicalizeBase` | Normalize a router base path string (strips trailing slashes, ensures leading slash).
|
|
220
|
-
| `resolveRouteComponent` | Resolve/load a route's component (supports async loaders + caching).
|
|
221
|
-
| `clearComponentCache` | Clear the resolved route component cache (useful for testing and HMR).
|
|
222
|
-
| `activeRouterProxy` | Stable proxy to the currently active router; forwards subscriptions and method calls (advanced/testing use).
|
|
223
|
-
| **Types** | `Route`, `RouteState`, `RouteComponent`, `GuardResult`, `RouterLinkProps`, `RouterLinkComputed`, `RouterConfig`, `Router`
|
|
214
|
+
| Export | Description |
|
|
215
|
+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
216
|
+
| `useRouter` | Create and use a router instance configured with routes (client & SSR). |
|
|
217
|
+
| `initRouter` | Initialize the router and register `router-view` / `router-link`. |
|
|
218
|
+
| `matchRoute` | Match a path against configured routes and extract params. |
|
|
219
|
+
| `matchRouteSSR` | SSR-friendly wrapper for route matching. Automatically strips query strings and URL fragments before matching, so `req.url` can be passed directly. |
|
|
220
|
+
| `findMatchedRoute` | Find the first matching route entry from an array of routes (lower-level helper). |
|
|
221
|
+
| `parseQuery` | Parse a query string into a key/value map. |
|
|
222
|
+
| `serializeQuery` | Serialize a key/value map into a query string (e.g. `?a=b`). |
|
|
223
|
+
| `normalizePathForRoute` | Normalize a path string for consistent route matching (strips trailing slashes, etc.). |
|
|
224
|
+
| `DEFAULT_SCROLL_CONFIG` | Default scroll-to-fragment configuration object used by the router. |
|
|
225
|
+
| `isDangerousScheme` | Returns `true` for dangerous URL schemes (e.g. `javascript:`). |
|
|
226
|
+
| `isAbsoluteUrl` | Returns `true` when a URL string is absolute (has a protocol). |
|
|
227
|
+
| `safeDecode` | Decode a URI component, returning the original string on error. |
|
|
228
|
+
| `canonicalizeBase` | Normalize a router base path string (strips trailing slashes, ensures leading slash). |
|
|
229
|
+
| `resolveRouteComponent` | Resolve/load a route's component (supports async loaders + caching). |
|
|
230
|
+
| `clearComponentCache` | Clear the resolved route component cache (useful for testing and HMR). |
|
|
231
|
+
| `activeRouterProxy` | Stable proxy to the currently active router; forwards subscriptions and method calls (advanced/testing use). |
|
|
232
|
+
| **Types** | `Route`, `RouteState`, `RouteComponent`, `GuardResult`, `RouterLinkProps`, `RouterLinkComputed`, `RouterConfig`, `Router` |
|
|
224
233
|
|
|
225
234
|
---
|
|
226
235
|
|
|
@@ -228,14 +237,35 @@ Below is the **complete list of public symbols** exported by the runtime and its
|
|
|
228
237
|
|
|
229
238
|
**Package:** `@jasonshimmy/custom-elements-runtime/ssr`
|
|
230
239
|
|
|
231
|
-
| Export
|
|
232
|
-
|
|
|
233
|
-
| `renderToString`
|
|
234
|
-
| `
|
|
235
|
-
| `
|
|
236
|
-
| `
|
|
237
|
-
| `
|
|
238
|
-
| `
|
|
240
|
+
| Export | Description |
|
|
241
|
+
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
242
|
+
| `renderToString` | Render a VNode tree to HTML for server-side rendering (backwards-compatible baseline). |
|
|
243
|
+
| `renderToStringWithJITCSS` | Render to HTML + pre-generate JIT CSS. Pass `dsd: true` for Declarative Shadow DOM output with full per-shadow-root CSS stack. |
|
|
244
|
+
| `renderToStringWithJITCSSDSD` | **Recommended.** Convenience alias: `renderToStringWithJITCSS(vnode, { dsd: true, ... })`. Full DSD output, hydration-ready, zero FOUC. Requires a **single root VNode** — wrap multi-element templates in one container. |
|
|
245
|
+
| `renderToStringDSD` | Render to DSD HTML string (no JIT CSS pipeline). Appends DSD polyfill by default. |
|
|
246
|
+
| `renderToStream` | Render to a `ReadableStream<string>` for streaming SSR / chunked transfer encoding. |
|
|
247
|
+
| `DSD_POLYFILL_SCRIPT` | Minified inline `<script>` that implements DSD for Firefox < 123. Injected automatically; export it for manual placement. |
|
|
248
|
+
| `registerEntityMap` | Register a custom named-entity map for SSR `decodeEntities`. |
|
|
249
|
+
| `loadEntityMap` | Async loader for the full HTML5 named-entity map. |
|
|
250
|
+
| `clearRegisteredEntityMap` | Reset the entity map to the built-in minimal set. |
|
|
251
|
+
| `VNode` (type) | The runtime VNode shape used by renderers and SSR. |
|
|
252
|
+
| `RenderOptions` (type) | Options for `renderToString` (`injectSvgNamespace`, `injectKnownNamespaces`). |
|
|
253
|
+
| `DSDRenderOptions` (type) | Options for DSD rendering (`dsd`, `dsdPolyfill`, plus all `RenderOptions`). |
|
|
254
|
+
| `SSRJITResult` (type) | Result of `renderToStringWithJITCSS`: `{ html, css, globalStyles, htmlWithStyles }`. |
|
|
255
|
+
|
|
256
|
+
### SSR Middleware
|
|
257
|
+
|
|
258
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/ssr-middleware`
|
|
259
|
+
|
|
260
|
+
Framework-agnostic handler factories for Express, Fastify, Hono, and raw Node.js.
|
|
261
|
+
|
|
262
|
+
| Export | Description |
|
|
263
|
+
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
264
|
+
| `createSSRHandler` | Returns an `async (req, res)` handler that SSR-renders a VNode and sends the full HTML document response. |
|
|
265
|
+
| `createStreamingSSRHandler` | Returns an `async (req, res)` handler that streams the rendered HTML using chunked transfer encoding. |
|
|
266
|
+
| `MinimalRequest` (type) | Minimal `{ url?, method?, headers? }` interface compatible with all major Node.js HTTP frameworks. |
|
|
267
|
+
| `MinimalResponse` (type) | Minimal `{ setHeader, write?, end }` interface compatible with all major Node.js HTTP frameworks. |
|
|
268
|
+
| `SSRMiddlewareOptions` (type) | Options for `createSSRHandler` and `createStreamingSSRHandler`. |
|
|
239
269
|
|
|
240
270
|
### Global Styles (CSS)
|
|
241
271
|
|
|
@@ -291,6 +321,107 @@ component('branded-card', () => {
|
|
|
291
321
|
| `extendedColors` | Full extended palette — `Record<string, Record<string, string>>` (name → shade → hex). |
|
|
292
322
|
| `ColorScale` | Type: single color scale with shade keys `50`–`950`. |
|
|
293
323
|
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
### JIT CSS Engine
|
|
327
|
+
|
|
328
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/jit-css`
|
|
329
|
+
|
|
330
|
+
Opt-in JIT CSS engine with hooks, global control, and the `cls()` helper for IDE tooling.
|
|
331
|
+
|
|
332
|
+
| Export | Description |
|
|
333
|
+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
|
334
|
+
| `useJITCSS` | Enable JIT CSS for the current component (per-component opt-in). Pass `JITCSSOptions` to configure colors/variants. |
|
|
335
|
+
| `useDesignTokens` | Apply typed design token overrides to `:host` as CSS custom properties. |
|
|
336
|
+
| `useGlobalStyle` | Inject CSS into `document.adoptedStyleSheets`, escaping Shadow DOM encapsulation. |
|
|
337
|
+
| `enableJITCSS` | Enable JIT CSS globally for all components. |
|
|
338
|
+
| `disableJITCSS` | Disable JIT CSS globally. |
|
|
339
|
+
| `isJITCSSEnabled` | Returns `true` when JIT CSS is globally active. |
|
|
340
|
+
| `isJITCSSEnabledFor` | Returns `true` when JIT CSS is active for a specific `ShadowRoot`. |
|
|
341
|
+
| `jitCSS` | Generate CSS from an HTML string (low-level engine). |
|
|
342
|
+
| `extractClassesFromHTML` | Extract unique class names from an HTML string. |
|
|
343
|
+
| `cls` | Identity function that signals JIT class names to IDE tooling and static scanners (no-op at runtime). |
|
|
344
|
+
| `parseColorClass` | Parse a color utility class name to its CSS declaration. |
|
|
345
|
+
| `parseColorWithOpacity` | Parse a color class with an optional `/opacity` modifier into its CSS declaration. |
|
|
346
|
+
| `parseGradientColorStop` | Parse a gradient color stop utility (`from-*`, `via-*`, `to-*`) to its CSS declaration. |
|
|
347
|
+
| `parseSpacing` | Parse a spacing utility class name to its CSS declaration. |
|
|
348
|
+
| `parseArbitrary` | Parse an arbitrary value utility class name. |
|
|
349
|
+
| `utilityMap` | Complete mapping of all static utility class names to their CSS declarations. |
|
|
350
|
+
| `selectorVariants` | State and pseudo-class variant selector map (`hover:`, `focus:`, `disabled:`, `inert:`, etc.). |
|
|
351
|
+
| `mediaVariants` | Responsive breakpoint media query map (`sm:`, `md:`, `lg:`, `xl:`, `2xl:`, `dark:`). |
|
|
352
|
+
| `containerVariants` | Container query breakpoint map (`@sm:`, `@md:`, `@lg:`, `@xl:`, `@2xl:`). |
|
|
353
|
+
| `colors` | Semantic color palette object (`neutral`, `primary`, `secondary`, `success`, `info`, `warning`, `error`). |
|
|
354
|
+
| **Types** | `JITCSSOptions`, `DesignTokens` |
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### DOM JIT CSS
|
|
359
|
+
|
|
360
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/dom-jit-css`
|
|
361
|
+
|
|
362
|
+
Runtime DOM scanner for non-Shadow DOM contexts (React, Svelte, Vue, plain HTML).
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
import { createDOMJITCSS } from '@jasonshimmy/custom-elements-runtime/dom-jit-css';
|
|
366
|
+
|
|
367
|
+
const jit = createDOMJITCSS({ extendedColors: true });
|
|
368
|
+
jit.mount(); // start watching
|
|
369
|
+
jit.destroy(); // tear down
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
| Export | Description |
|
|
373
|
+
| ----------------- | --------------------------------------------------------------------------------------------------- |
|
|
374
|
+
| `createDOMJITCSS` | Create a DOM JIT CSS instance that watches class changes and injects utility CSS into the document. |
|
|
375
|
+
| **Types** | `DOMJITCSSOptions`, `DOMJITCSSHandle` |
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
### Vite Plugin
|
|
380
|
+
|
|
381
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/vite-plugin`
|
|
382
|
+
|
|
383
|
+
Build-time static analysis plugin that emits pre-generated CSS, eliminating runtime parsing cost entirely. Two exports are available:
|
|
384
|
+
|
|
385
|
+
- **`cerPlugin`** — All-in-one: JIT CSS + SSR configuration. Recommended for SSR apps.
|
|
386
|
+
- **`cerJITCSS`** — JIT CSS only.
|
|
387
|
+
|
|
388
|
+
```ts
|
|
389
|
+
// vite.config.ts — SSR app (recommended)
|
|
390
|
+
import { cerPlugin } from '@jasonshimmy/custom-elements-runtime/vite-plugin';
|
|
391
|
+
|
|
392
|
+
export default defineConfig({
|
|
393
|
+
plugins: [
|
|
394
|
+
cerPlugin({
|
|
395
|
+
content: ['./src/**/*.{ts,tsx,html}'],
|
|
396
|
+
ssr: { dsd: true, jit: { extendedColors: true } },
|
|
397
|
+
}),
|
|
398
|
+
],
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
// vite.config.ts — JIT CSS only
|
|
404
|
+
import { cerJITCSS } from '@jasonshimmy/custom-elements-runtime/vite-plugin';
|
|
405
|
+
|
|
406
|
+
export default defineConfig({
|
|
407
|
+
plugins: [
|
|
408
|
+
cerJITCSS({
|
|
409
|
+
content: ['./src/**/*.{ts,tsx,html}'],
|
|
410
|
+
output: 'src/generated-jit.css',
|
|
411
|
+
extendedColors: true,
|
|
412
|
+
}),
|
|
413
|
+
],
|
|
414
|
+
});
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
| Export | Description |
|
|
418
|
+
| ----------- | --------------------------------------------------------------------------------------------- |
|
|
419
|
+
| `cerPlugin` | Combined plugin: JIT CSS + SSR config (`virtual:cer-ssr-config`). Returns a `Plugin[]` array. |
|
|
420
|
+
| `cerJITCSS` | JIT CSS-only Vite plugin that scans source files at build time and emits pre-generated CSS. |
|
|
421
|
+
| **Types** | `CerPluginOptions`, `CerSSROptions`, `CerJITCSSPluginOptions` |
|
|
422
|
+
|
|
423
|
+
---
|
|
424
|
+
|
|
294
425
|
## 📖 Documentation Index
|
|
295
426
|
|
|
296
427
|
Explore the complete documentation for every runtime feature:
|
|
@@ -319,7 +450,9 @@ Explore the complete documentation for every runtime feature:
|
|
|
319
450
|
|
|
320
451
|
### 🎨 **Styling**
|
|
321
452
|
|
|
322
|
-
- [🎨 JIT CSS](./docs/jit-css.md) - On-demand utility-first styling system
|
|
453
|
+
- [🎨 JIT CSS](./docs/jit-css.md) - On-demand utility-first styling system (opt-in architecture, all utilities, `useJITCSS`, `useDesignTokens`, `useGlobalStyle`, `cls`)
|
|
454
|
+
- [⚡ DOM JIT CSS](./docs/dom-jit-css.md) - Runtime DOM scanner for non-Shadow DOM contexts (React, Svelte, Vue, plain HTML)
|
|
455
|
+
- [🔧 Vite Plugin](./docs/vite-plugin.md) - `cerPlugin` (JIT CSS + SSR config) and `cerJITCSS` (JIT CSS only) build-time plugins
|
|
323
456
|
- [📏 Space Utilities](./docs/space-utilities.md) - Tailwind-style `space-x-*` and `space-y-*` spacing utilities
|
|
324
457
|
- [📝 Prose Typography](./docs/prose.md) - Beautiful typography for long-form content
|
|
325
458
|
- [🎨 Colors](./docs/colors.md) - Extended Tailwind-compatible color palette (`/css/colors` subpath)
|
|
@@ -340,7 +473,8 @@ Explore the complete documentation for every runtime feature:
|
|
|
340
473
|
- [♻️ Keep-Alive](./docs/keep-alive.md) - Preserve component state across DOM removals with `<cer-keep-alive>`
|
|
341
474
|
- [🩺 Health Monitor](./docs/health-monitor.md) - Track runtime metrics and receive periodic health reports with `createHealthMonitor()`
|
|
342
475
|
- [🔮 Virtual DOM](./docs/virtual-dom.md) - VDOM implementation and performance details
|
|
343
|
-
- [🌐 SSR](./docs/ssr.md) -
|
|
476
|
+
- [🌐 SSR](./docs/ssr.md) - Complete SSR guide: Declarative Shadow DOM output, hydration, streaming, partial hydration (island architecture), `useStyle` in SSR, routing with SSR, and framework integration
|
|
477
|
+
- [🌐 SSR Middleware](./docs/ssr-middleware.md) - `createSSRHandler` and `createStreamingSSRHandler` for Express, Fastify, Hono, raw Node.js, and router integration
|
|
344
478
|
- [♻️ HMR](./docs/hmr.md) - Hot module replacement
|
|
345
479
|
- [🛡️ Infinite Loop Protection](./docs/infinite-loop-protection.md) - Runtime safeguards against infinite loops
|
|
346
480
|
- [🔒 Secure Expression Evaluator](./docs/secure-expression-evaluator.md) - Safe evaluation of dynamic expressions in templates
|
|
@@ -352,10 +486,21 @@ Explore the complete documentation for every runtime feature:
|
|
|
352
486
|
- [🅰️ Angular Integration](./docs/angular-integration.md) - Using components in Angular apps
|
|
353
487
|
- [🔥 Svelte Integration](./docs/svelte-integration.md) - Using components in Svelte apps
|
|
354
488
|
|
|
355
|
-
###
|
|
489
|
+
### 🛡️ **Security & Quality**
|
|
356
490
|
|
|
491
|
+
- [🔒 Security](./docs/security.md) - XSS prevention, `unsafeHTML`, CSP guidance, and safe input handling
|
|
492
|
+
- [🧪 Testing](./docs/testing.md) - Testing components with Vitest + happy-dom, reactive state, events, and async components
|
|
493
|
+
- [⚡ Performance](./docs/performance.md) - Update scheduler, `computed` memoization, avoiding re-renders, profiling
|
|
357
494
|
- [🔧 Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
|
|
358
495
|
|
|
496
|
+
### 🔄 **Upgrading**
|
|
497
|
+
|
|
498
|
+
- [📦 Migration Guide](./docs/migration.md) - Upgrade instructions, including the v3.0 JIT CSS opt-in change
|
|
499
|
+
|
|
500
|
+
### 📖 **Reference**
|
|
501
|
+
|
|
502
|
+
- [📚 Glossary](./docs/glossary.md) - Definitions for library-specific and web-components terms
|
|
503
|
+
|
|
359
504
|
For examples and implementation details, explore the source code in `src/lib/`.
|
|
360
505
|
|
|
361
506
|
## 🧑🔬 Real-World Examples
|
|
@@ -372,8 +517,13 @@ For examples and implementation details, explore the source code in `src/lib/`.
|
|
|
372
517
|
- **Contribute:** We welcome PRs for docs, features, and examples.
|
|
373
518
|
- ❤️ Like what you see? [Support ongoing development on Patreon](https://patreon.com/jshimkoski)
|
|
374
519
|
|
|
520
|
+
### Community Gallery
|
|
521
|
+
|
|
522
|
+
- [Material Design 3 Components](https://github.com/jshimkoski/cer-material) built with this runtime.
|
|
523
|
+
- [Solatro](https://solatro.netlify.app) is a RTS card-based game built with this runtime.
|
|
524
|
+
|
|
375
525
|
## 💖 Support This Project
|
|
376
526
|
|
|
377
|
-
Custom Elements Runtime is a labor of love built to make modern web development faster and more expressive. If it's helping you build better components, consider [supporting me on Patreon](https://patreon.com/jshimkoski) to help keep the momentum going.
|
|
527
|
+
Custom Elements Runtime is a labor of love built to make modern web development faster and more expressive. If it's helping you build better components, [learn more about me](https://jasonshimmy.com) or consider [supporting me on Patreon](https://patreon.com/jshimkoski) to help keep the momentum going.
|
|
378
528
|
|
|
379
529
|
Your support helps fund continued development, documentation, and community engagement. Every bit helps—thank you!
|