@nextwebwg/html-next-converter 1.0.0-alpha.59 → 1.0.0-alpha.60

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.
Files changed (2) hide show
  1. package/README.md +27 -5
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Converts a Declarative Components application or library graph into Vue 3.5 or Svelte 5 single-file
4
4
  components, or React 19.3 TSX components. Once converted, HTML Next is gone. Each `.vue` file imports Vue,
5
- its nested components, its controller (copied beside it), and only the generated helpers its
5
+ its nested components, its component module (copied beside it), and only the generated helpers its
6
6
  features need. A Vue component using
7
7
  `$html` imports `vue/html.ts`; that helper requires `parse5` as an application dependency for
8
8
  deterministic SSR. It parses inert fragments and applies one pinned safe-default allowlist in every
@@ -65,7 +65,7 @@ emit `html-next.conversion.json`, which records the input entries, output entry,
65
65
  the target version, and package-shaped `dependencies` and `peerDependencies`. Copy the relevant
66
66
  fields from `package` into the published package's `package.json`. `parse5` appears in
67
67
  `dependencies` only when an emitted `$html` helper needs it; Vue, React, or Svelte appears in
68
- `peerDependencies` for its respective output. Dependencies imported by authored controller
68
+ `peerDependencies` for its respective output. Dependencies imported by authored component
69
69
  modules remain the publisher's responsibility.
70
70
 
71
71
  Publish the `.vue` files together with the `.js` and `.d.ts` your Vue build produces from them
@@ -88,7 +88,7 @@ hydration, and exact pixels with the live runtime in Chromium, Firefox, and WebK
88
88
  that cannot be represented fail conversion explicitly rather than silently changing behavior.
89
89
  Svelte output uses Svelte 5 runes, snippets, attachments, and public lifecycle APIs, with `.svelte`
90
90
  components under `generated/svelte/`, each with its styles in its `<style>`. It supports props (including generic
91
- and state-selected types), state/computed/handlers, named and scoped slots, native events, context, data reads, controllers and refs, native form controls, safe HTML, structural
91
+ and state-selected types), state/computed/handlers, named and scoped slots, native events, context, data reads, component modules and refs, native form controls, safe HTML, structural
92
92
  flow, and keyed lists. Native-control helpers preserve authored reset defaults and dirty edits;
93
93
  Svelte's normal compiler owns rendering, SSR, and hydration. Components import the rendering and
94
94
  binding helpers their markup and handlers call from the shared `svelte/render.svelte.ts`, which an
@@ -153,8 +153,22 @@ bundlers retain CSS side-effect imports from unused named re-exports in a shared
153
153
  even when they remove the unused JavaScript. The on-demand Vite adapter handles pruning for its
154
154
  generated named exports.
155
155
 
156
- Controllers initialize once per component instance. Use `host.on("connect", setup)` for setup
157
- that must run on every connection; return its disconnect cleanup from `setup`. Register other
156
+ Use `module="./behavior.js"` on the component template and export a named `connect`:
157
+
158
+ ```js
159
+ export function connect(host, { signal }) {
160
+ host.on("click", () => { host.state.open = !host.state.open; });
161
+ const observer = new ResizeObserver(() => { /* measure the connected root */ });
162
+ observer.observe(host.root);
163
+ signal.addEventListener("abort", () => observer.disconnect(), { once: true });
164
+ }
165
+ ```
166
+
167
+ `connect` runs on each DOM connection. Disconnection aborts its signal and releases its
168
+ listeners, effects and returned cleanup. A reconnect keeps the instance's state and starts a
169
+ new activation. SSR renders supplied props without importing this browser module.
170
+ Compatibility `controller` default exports still initialize once per instance; their
171
+ `host.on("connect", setup)` handles repeated connections. Register other
158
172
  native events with `host.on(type, listener)`, which detaches listeners while disconnected and
159
173
  reattaches them on reconnect. A handler can dispatch its native `$$event` or selected event fields
160
174
  to that listener. `<method>` and automatic named-export element methods are unsupported.
@@ -163,6 +177,14 @@ to that listener. `<method>` and automatic named-export element methods are unsu
163
177
  are read through `host.data.name`, including their readonly response and status fields. Invalid
164
178
  authored state assignments retain the prior value and warn; native control edits retain their
165
179
  ordinary validity behavior. Props use `:host([prop])` styling, and state uses `:host(:state(state))`.
180
+
181
+ Vue and Svelte conversion also support an editable initial value with `<state from="$product">`.
182
+ Initialization waits for the expression's inputs to become available; the first accepted local
183
+ write takes ownership immediately. Refreshes never overwrite the draft. `$await`/`$error`/`$else`
184
+ work with these states and their inherited context, as with typed props and computed values.
185
+ React conversion currently reports an explicit error for `<state from>`. See the public
186
+ [state initialization proposal](https://nextwebwg.org/declarative-components/reactivity#state-initialization)
187
+ for the declaration's behavior.
166
188
  The [public proposal](https://nextwebwg.org/declarative-components/javascript/) defines these contracts.
167
189
 
168
190
  A component that declares a `<request>` accepts a function prop for it, named in camelCase
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextwebwg/html-next-converter",
3
- "version": "1.0.0-alpha.59",
3
+ "version": "1.0.0-alpha.60",
4
4
  "description": "Vue, React, and Svelte conversion for Declarative HTML Components.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,7 +21,7 @@
21
21
  "node": ">=22.22.2 <23 || >=24.15 <25"
22
22
  },
23
23
  "dependencies": {
24
- "@nextwebwg/html-next": "1.0.0-alpha.59"
24
+ "@nextwebwg/html-next": "1.0.0-alpha.60"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@formatjs/intl-durationformat": "0.11.1",