@jasonshimmy/custom-elements-runtime 1.2.3 → 2.0.1
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 +157 -83
- package/dist/custom-elements-runtime.cjs.js +6 -149
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js +2 -0
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.directive-enhancements.es.js +144 -0
- package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -0
- package/dist/custom-elements-runtime.directives.cjs.js +2 -0
- package/dist/custom-elements-runtime.directives.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.directives.es.js +49 -0
- package/dist/custom-elements-runtime.directives.es.js.map +1 -0
- package/dist/custom-elements-runtime.es.js +2147 -4451
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +2 -0
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.event-bus.es.js +147 -0
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -0
- package/dist/custom-elements-runtime.router.cjs.js +29 -0
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.router.es.js +305 -0
- package/dist/custom-elements-runtime.router.es.js.map +1 -0
- package/dist/custom-elements-runtime.ssr.cjs.js +2 -0
- package/dist/custom-elements-runtime.ssr.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.ssr.es.js +18 -0
- package/dist/custom-elements-runtime.ssr.es.js.map +1 -0
- package/dist/custom-elements-runtime.store.cjs.js +2 -0
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.store.es.js +25 -0
- package/dist/custom-elements-runtime.store.es.js.map +1 -0
- package/dist/custom-elements-runtime.transitions.cjs.js +2 -0
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -0
- package/dist/custom-elements-runtime.transitions.es.js +10 -0
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -0
- package/dist/directive-enhancements.d.ts +6 -6
- package/dist/directives.d.ts +2 -2
- package/dist/event-bus.d.ts +20 -11
- package/dist/helpers-CDfJhmMS.js +609 -0
- package/dist/helpers-CDfJhmMS.js.map +1 -0
- package/dist/helpers-D3UjNfYY.cjs +5 -0
- package/dist/helpers-D3UjNfYY.cjs.map +1 -0
- package/dist/index.d.ts +6 -20
- package/dist/logger-BpibrmKL.js +25 -0
- package/dist/logger-BpibrmKL.js.map +1 -0
- package/dist/logger-CqdBMdui.cjs +2 -0
- package/dist/logger-CqdBMdui.cjs.map +1 -0
- package/dist/router.d.ts +6 -6
- package/dist/runtime/component.d.ts +3 -3
- package/dist/runtime/event-manager.d.ts +3 -3
- package/dist/runtime/helpers.d.ts +4 -4
- package/dist/runtime/hooks.d.ts +3 -3
- package/dist/runtime/lifecycle.d.ts +1 -1
- package/dist/runtime/logger.d.ts +3 -3
- package/dist/runtime/node-metadata.d.ts +11 -2
- package/dist/runtime/props.d.ts +2 -2
- package/dist/runtime/reactive-proxy-cache.d.ts +6 -3
- package/dist/runtime/reactive.d.ts +5 -4
- package/dist/runtime/render.d.ts +4 -4
- package/dist/runtime/secure-expression-evaluator.d.ts +1 -1
- package/dist/runtime/template-compiler.d.ts +10 -10
- package/dist/runtime/transition-group-handler.d.ts +21 -0
- package/dist/runtime/transition-utils.d.ts +43 -3
- package/dist/runtime/types.d.ts +27 -17
- package/dist/runtime/vdom-model-helpers.d.ts +7 -7
- package/dist/runtime/vdom-ssr.d.ts +9 -0
- package/dist/runtime/vdom.d.ts +30 -22
- package/dist/runtime/watchers.d.ts +3 -3
- package/dist/ssr.d.ts +6 -0
- package/dist/transitions-Crm12oGl.cjs +115 -0
- package/dist/transitions-Crm12oGl.cjs.map +1 -0
- package/dist/transitions-D5YybtBE.js +1415 -0
- package/dist/transitions-D5YybtBE.js.map +1 -0
- package/dist/transitions.d.ts +5 -0
- package/package.json +56 -8
- package/dist/custom-elements-runtime.umd.js +0 -156
- package/dist/custom-elements-runtime.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -23,8 +23,15 @@ Build modern components with strict TypeScript, zero dependencies, and a clean f
|
|
|
23
23
|
|
|
24
24
|
1. **Install:** `npm install @jasonshimmy/custom-elements-runtime`
|
|
25
25
|
2. **Create a Component:**
|
|
26
|
+
|
|
26
27
|
```ts
|
|
27
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
component,
|
|
30
|
+
ref,
|
|
31
|
+
html,
|
|
32
|
+
useEmit,
|
|
33
|
+
useProps,
|
|
34
|
+
} from '@jasonshimmy/custom-elements-runtime';
|
|
28
35
|
|
|
29
36
|
component('my-counter', () => {
|
|
30
37
|
const props = useProps({ initialCount: 0 });
|
|
@@ -47,106 +54,167 @@ component('my-counter', () => {
|
|
|
47
54
|
`;
|
|
48
55
|
});
|
|
49
56
|
```
|
|
57
|
+
|
|
50
58
|
3. **Use in HTML:**
|
|
51
|
-
```html
|
|
52
|
-
<my-counter
|
|
53
|
-
initial-count="5"
|
|
54
|
-
@update:initial-count="handleCountUpdate"
|
|
55
|
-
></my-counter>
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
```html
|
|
61
|
+
<my-counter
|
|
62
|
+
initial-count="5"
|
|
63
|
+
@update:initial-count="handleCountUpdate"
|
|
64
|
+
></my-counter>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
58
67
|
function handleCountUpdate(event) {
|
|
59
68
|
console.log('Count updated to:', event.detail.count);
|
|
60
69
|
}
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
63
73
|
4. **Enjoy instant reactivity and type safety!**
|
|
64
74
|
|
|
65
75
|
## 📦 Complete API Reference
|
|
66
76
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
77
|
+
Below is the **complete list of public symbols** exported by the runtime and its named subpaths (root entry + subpath entries).
|
|
78
|
+
|
|
79
|
+
### Root Entry
|
|
80
|
+
|
|
81
|
+
**Package:** `@jasonshimmy/custom-elements-runtime`
|
|
82
|
+
|
|
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 derived, read-only reactive value from other reactives. |
|
|
90
|
+
| `watch` | Register watchers reacting to changes in reactive values. |
|
|
91
|
+
| `useProps` | Hook to declare/consume typed component props with defaults. |
|
|
92
|
+
| `useEmit` | Hook returning an emit function for dispatching custom events. |
|
|
93
|
+
| `useOnConnected` | Hook that runs a callback when the component connects. |
|
|
94
|
+
| `useOnDisconnected` | Hook that runs a callback when the component disconnects. |
|
|
95
|
+
| `useOnAttributeChanged` | Hook observing host attribute changes. |
|
|
96
|
+
| `useOnError` | Hook to register a component-level error handler. |
|
|
97
|
+
| `useStyle` | Hook to register or compute component styles at runtime. |
|
|
98
|
+
| `unsafeHTML` | Insert raw HTML into a template (**unsafe; use carefully**). |
|
|
99
|
+
| `decodeEntities` | Utility to decode HTML entities in strings. |
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Directives
|
|
104
|
+
|
|
105
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/directives`
|
|
106
|
+
|
|
107
|
+
| Export | Description |
|
|
108
|
+
| ------------- | ------------------------------------------------------------------ |
|
|
109
|
+
| `when` | Conditional rendering: render children when the condition is true. |
|
|
110
|
+
| `each` | Iterate arrays and render a VNode per item with stable keys. |
|
|
111
|
+
| `match` | Fluent branching API (`when`/`otherwise`/`done`) returning VNodes. |
|
|
112
|
+
| `anchorBlock` | Create a stable anchor VNode used as block boundaries. |
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
### Directive Enhancements
|
|
117
|
+
|
|
118
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/directive-enhancements`
|
|
119
|
+
|
|
120
|
+
| Export | Description |
|
|
121
|
+
| ------------------ | ------------------------------------------------------------------------ |
|
|
122
|
+
| `unless` | Inverse of `when` (render when condition is false). |
|
|
123
|
+
| `whenEmpty` | Render content when a collection is empty or null. |
|
|
124
|
+
| `whenNotEmpty` | Render content when a collection has items. |
|
|
125
|
+
| `eachWhere` | Filter + iterate; render only items matching a predicate. |
|
|
126
|
+
| `switchOnLength` | Render different content based on array length cases. |
|
|
127
|
+
| `eachGroup` | Group array items by a key and render per-group content. |
|
|
128
|
+
| `eachPage` | Render a paginated subset (page) of items. |
|
|
129
|
+
| `switchOnPromise` | Render loading/success/error/idle states for async data. |
|
|
130
|
+
| `whenMedia` | Render content when a CSS media query matches. |
|
|
131
|
+
| `mediaVariants` | Map of responsive media queries (`sm`, `md`, `lg`, `xl`, `2xl`, `dark`). |
|
|
132
|
+
| `responsiveOrder` | Ordered breakpoint keys used by responsive helpers. |
|
|
133
|
+
| `responsive` | Per-breakpoint helpers (`sm`/`md`/`lg`/`xl`/`2xl`/`dark`). |
|
|
134
|
+
| `whenVariants` | Compose multiple variants (e.g., `dark + lg`) into one media query. |
|
|
135
|
+
| `responsiveSwitch` | Render different content for different breakpoints. |
|
|
136
|
+
| `switchOn` | Fluent switch/case API matching a value to content. |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
### Transitions
|
|
141
|
+
|
|
142
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/transitions`
|
|
143
|
+
|
|
144
|
+
| Export | Description |
|
|
145
|
+
| ------------------------- | ------------------------------------------------------------------------------------- |
|
|
146
|
+
| `Transition` | Wrap content with enter/leave transition metadata consumed by the runtime. |
|
|
147
|
+
| `TransitionGroup` | Animate lists with enter/leave/move transitions for children. |
|
|
148
|
+
| `transitionPresets` | Built-in transition presets (`fade`, `slide`, `scale`, etc.). |
|
|
149
|
+
| `createTransitionPreset` | Create a reusable transition preset programmatically. |
|
|
150
|
+
| `getTransitionStyleSheet` | Obtain the `CSSStyleSheet` used by the transition runtime. |
|
|
151
|
+
| **Types** | `TransitionClasses`, `TransitionHooks`, `TransitionOptions`, `TransitionGroupOptions` |
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Event Bus
|
|
156
|
+
|
|
157
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/event-bus`
|
|
158
|
+
|
|
159
|
+
| Export | Description |
|
|
160
|
+
| ---------------- | ------------------------------------------------------------------------------ |
|
|
161
|
+
| `EventHandler` | Type: callback signature used by the event bus. |
|
|
162
|
+
| `GlobalEventBus` | Class: singleton implementing a global pub/sub event bus. |
|
|
163
|
+
| `eventBus` | Proxy: lazy proxy to the singleton `GlobalEventBus` instance. |
|
|
164
|
+
| `emit` | Emit a global event with an optional payload. |
|
|
165
|
+
| `on` | Register a handler for a global event (returns unsubscribe function). |
|
|
166
|
+
| `off` | Remove a handler for a global event. |
|
|
167
|
+
| `once` | Register a one-time handler; returns a Promise resolving with the payload. |
|
|
168
|
+
| `listen` | Listen for native `CustomEvent` on the global event bus (returns unsubscribe). |
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
### Store
|
|
173
|
+
|
|
174
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/store`
|
|
175
|
+
|
|
176
|
+
| Export | Description |
|
|
177
|
+
| ------------- | ----------------------------------------------------------- |
|
|
178
|
+
| `Store` | Interface describing `subscribe` / `getState` / `setState`. |
|
|
179
|
+
| `createStore` | Create a simple observable store that notifies subscribers. |
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### Router
|
|
184
|
+
|
|
185
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/router`
|
|
186
|
+
|
|
187
|
+
| Export | Description |
|
|
188
|
+
| ----------------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
189
|
+
| `useRouter` | Create and use a router instance configured with routes (client & SSR). |
|
|
190
|
+
| `initRouter` | Initialize the router and register `router-view` / `router-link`. |
|
|
191
|
+
| `matchRoute` | Match a path against configured routes and extract params. |
|
|
192
|
+
| `matchRouteSSR` | SSR-friendly wrapper for route matching. |
|
|
193
|
+
| `parseQuery` | Parse a query string into a key/value map. |
|
|
194
|
+
| `resolveRouteComponent` | Resolve/load a route's component (supports async loaders + caching). |
|
|
195
|
+
| **Types** | `Route`, `RouteState`, `RouteComponent`, `GuardResult`, `RouterLinkProps`, `RouterLinkComputed`, `RouterConfig` |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### SSR
|
|
200
|
+
|
|
201
|
+
**Package:** `@jasonshimmy/custom-elements-runtime/ssr`
|
|
202
|
+
|
|
203
|
+
| Export | Description |
|
|
204
|
+
| ---------------- | ------------------------------------------------------ |
|
|
205
|
+
| `renderToString` | Render a VNode tree to HTML for server-side rendering. |
|
|
206
|
+
| `VNode` (type) | The runtime VNode shape used by renderers and SSR. |
|
|
141
207
|
|
|
142
208
|
## 📖 Documentation Index
|
|
143
209
|
|
|
144
210
|
Explore the complete documentation for every runtime feature:
|
|
145
211
|
|
|
146
212
|
### 🚀 **Getting Started**
|
|
213
|
+
|
|
147
214
|
- [**🎯 Functional API**](./docs/functional-api.md) - **Start here!** Complete guide to the modern functional component API
|
|
148
215
|
|
|
149
216
|
### 🏗️ **Core Features**
|
|
217
|
+
|
|
150
218
|
- [🧩 Template](./docs/template.md) - Template syntax and html function
|
|
151
219
|
- [🧭 Directives](./docs/directives.md) - Conditional rendering with `when`, `each`, and `match`
|
|
152
220
|
- [🛠️ Directive Enhancements](./docs/directive-enhancements.md) - Advanced directive utilities:
|
|
@@ -164,15 +232,18 @@ Explore the complete documentation for every runtime feature:
|
|
|
164
232
|
- [🎬 Transitions Guide](./docs/transitions.md) - Animation and transition effects
|
|
165
233
|
|
|
166
234
|
### 🎨 **Styling**
|
|
235
|
+
|
|
167
236
|
- [🎨 JIT CSS](./docs/jit-css.md) - On-demand utility-first styling system
|
|
168
237
|
|
|
169
238
|
### 🔗 **Communication & State**
|
|
239
|
+
|
|
170
240
|
- [📢 Event Bus](./docs/event-bus.md) - Global event system for cross-component communication
|
|
171
241
|
- [🗄️ Store](./docs/store.md) - Global state management
|
|
172
242
|
- [🚦 Router](./docs/router.md) - Client-side routing
|
|
173
243
|
- [🤝 Cross-Component Communication](./docs/cross-component-communication.md) - Patterns for component interaction
|
|
174
244
|
|
|
175
245
|
### ⚡ **Advanced Features**
|
|
246
|
+
|
|
176
247
|
- [🔮 Virtual DOM](./docs/virtual-dom.md) - VDOM implementation and performance details
|
|
177
248
|
- [🌐 SSR](./docs/ssr.md) - Server-side rendering support
|
|
178
249
|
- [♻️ HMR](./docs/hmr.md) - Hot module replacement
|
|
@@ -180,17 +251,20 @@ Explore the complete documentation for every runtime feature:
|
|
|
180
251
|
- [🔒 Secure Expression Evaluator](./docs/secure-expression-evaluator.md) - Safe evaluation of dynamic expressions in templates
|
|
181
252
|
|
|
182
253
|
### 🔧 **Integration Guides**
|
|
254
|
+
|
|
183
255
|
- [⚛️ React Integration](./docs/react-integration.md) - Using components in React apps
|
|
184
256
|
- [🦊 Vue Integration](./docs/vue-integration.md) - Using components in Vue apps
|
|
185
257
|
- [🅰️ Angular Integration](./docs/angular-integration.md) - Using components in Angular apps
|
|
186
258
|
- [🔥 Svelte Integration](./docs/svelte-integration.md) - Using components in Svelte apps
|
|
187
259
|
|
|
188
260
|
### 🛠️ **Troubleshooting**
|
|
261
|
+
|
|
189
262
|
- [🔧 Troubleshooting](./docs/troubleshooting.md) - Common issues and solutions
|
|
190
263
|
|
|
191
264
|
For examples and implementation details, explore the source code in `src/lib/`.
|
|
192
265
|
|
|
193
266
|
## 🧑🔬 Real-World Examples
|
|
267
|
+
|
|
194
268
|
- [Form Input & Validation](./src/components/examples/FormInputValidation.ts)
|
|
195
269
|
- [Minimal Example](./src/components/examples/MinimalExample.ts)
|
|
196
270
|
- [Shopping Cart](./src/components/examples/ShoppingCart.ts)
|