@tschk/moonshine-vue 0.4.4 → 0.4.80

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 CHANGED
@@ -20,17 +20,23 @@ import { fromMoonshineSignal } from "@tschk/moonshine-vue";
20
20
  import { ref } from "@tschk/moonshine-vue/reactive";
21
21
  ```
22
22
 
23
- | Subpath | Provides |
24
- | ---------------- | -------------------------------------------------------------------------------------------------------------------- |
25
- | `.` | signal bridges, lazy native SSR compatibility renderer |
26
- | `./vue` | `vue` runtime re-exports |
27
- | `./compiler-sfc` | `vue/compiler-sfc` re-exports |
28
- | `./reactive` | native refs/`shallowRef`, `toRef`/`toRefs`/`unref`/`isRef`, `reactive`/`isReactive`, `computed`, synchronous `watch` |
29
- | `./context` | native component `provide`, `inject`, `hasInjectionContext` |
30
- | `./text` | native DOM and SSR interpolation conversion |
31
- | `./props` | compiler-facing shallow declared props and owned parent refresh |
32
- | `./events` | compiler-facing typed component callbacks, callback arrays and per-instance once delivery |
33
- | `./normalize` | native class/style normalization and compiler-facing DOM/SSR policies |
23
+ | Subpath | Provides |
24
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
25
+ | `.` | signal bridges, lazy native SSR compatibility renderer |
26
+ | `./vue` | `vue` runtime re-exports |
27
+ | `./compiler-sfc` | `vue/compiler-sfc` re-exports |
28
+ | `./reactive` | native `ref`/`shallowRef`/`customRef`/`triggerRef`/`useTemplateRef`/`useModel`/`createModel`/`useId` (`ModelRef`, `DefineModelOptions`), `toRef`/`toRefs`/`unref`/`toValue`/`isRef`, `reactive`/`shallowReactive`/`readonly`/`shallowReadonly`, `isReactive`/`isReadonly`/`isShallow`/`isProxy`/`toRaw`/`markRaw`, `computed`, `watch`/`watchEffect`/`watchPostEffect`/`watchSyncEffect`/`onWatcherCleanup` (`WatchHandle`, `WatchEffect`, `WatchEffectOptions`), `nextTick`, `mergeProps`, `defineComponent`, `defineAsyncComponent` (`AsyncComponentOptions`), `Teleport` (`TeleportProps`), `KeepAlive` (`KeepAliveProps`, `MatchPattern`), `Transition` (`TransitionProps`), `TransitionGroup` (`TransitionGroupProps`), `Suspense` (`SuspenseProps`), `createApp`, `createSSRApp`, `definePlugin`, `resolveComponent`, `resolveDirective`, `withDirectives`, `warn`, `useSSRContext`, `version`, `effectScope`/`getCurrentScope`/`onScopeDispose` |
29
+ | `./context` | native component `provide`, `inject`, `hasInjectionContext`, `useId`, `useAttrs`, `useSlots` (`Slots`), `useSSRContext`, `withSSRContext`, `withSSRContextAsync` (`SSRContext`, `AppConfig`, `AppContextState`) |
30
+ | `./lifecycle` | native component `onBeforeMount`, `onMounted`, `onBeforeUpdate`, `onUpdated`, `onBeforeUnmount`, `onUnmounted`, `onActivated`, `onDeactivated`, `onServerPrefetch`, `onErrorCaptured` (`ErrorCapturedHook`) |
31
+ | `./text` | native DOM and SSR interpolation conversion |
32
+ | `./props` | compiler-facing shallow declared props and owned parent refresh |
33
+ | `./events` | compiler-facing typed component callbacks, callback arrays and per-instance once delivery |
34
+ | `./normalize` | native class/style normalization and compiler-facing DOM/SSR policies |
35
+ | `./expose` | compiler-facing `exposeRefs`, `bindRef`, `bindComponentRef`, and `useTemplateRef` for `defineExpose` and template refs |
36
+ | `./app` | native `createApp`, `createSSRApp`, `definePlugin`, `resolveComponent`, `resolveDirective`, `withDirectives`, `warn` returning a Vue 3 `App` instance (`version`, `config`, `_context`, `use`, `provide`, `runWithContext`, `component`, `directive`, `mixin`, `onUnmount`, `mount`, `unmount`) |
37
+ | `./server-renderer` | host-free Vue 3 SSR runtime (`renderToString`, `renderToWebStream`, `renderToSimpleStream`, `useSSRContext`, `SSRContext`, `ssrInterpolate`, `ssrRenderAttr`, `ssrRenderAttrs`, `ssrRenderClass`, `ssrRenderStyle`, `ssrRenderTeleport`) awaiting `onServerPrefetch` hooks and recording `<Teleport>` targets into `context.teleports` |
38
+ | `./router` | host-free Vue Router 4 runtime (`createRouter`, `createMemoryHistory`, `createWebHistory`, `createWebHashHistory`, `useRouter`, `useRoute`, `useLink`, `onBeforeRouteLeave`, `onBeforeRouteUpdate`, `RouterLink`, `RouterView`, `parseQuery`, `stringifyQuery`, `START_LOCATION`, `NavigationFailureType`, `isNavigationFailure`, `createRouterError`, `routerKey`, `routeLocationKey`, `routerViewLocationKey`) |
39
+ | `./store` | host-free Pinia store runtime (`createPinia`, `setActivePinia`, `getActivePinia`, `defineStore`, `storeToRefs`, `mapStores`, `mapState`, `mapGetters`, `mapWritableState`, `mapActions`, `setMapStoreSuffix`, `MutationType`, `piniaSymbol`) |
34
40
 
35
41
  `./framework` exports the same lazy `crepusRenderer` compatibility name as the
36
42
  root. Its optional `@tschk/moonshine-framework` peer is needed only when rendering.
@@ -41,14 +47,36 @@ The compatibility root renderer loads source files under Bun. Bundled deployment
41
47
 
42
48
  Legacy peer: `vue` >= 3, needed only for `/vue` and `/compiler-sfc`.
43
49
 
44
- Native `watch` requires `{ flush: "sync" }`; component scheduling, deep watches,
45
- and Vue collection proxies are not implemented by this entry. Plain objects and
46
- arrays are reactive; nested refs unwrap on object properties and retain their
47
- identity at integer array entries.
48
- Each watcher run can register multiple cleanup callbacks. Reruns and stops drain
50
+ Native `watch` requires `{ flush: "sync" }` and supports `immediate`, `deep`
51
+ (`boolean` or finite depth `number`), `once`, reactive object sources (deep by
52
+ default for `reactive`, depth `1` by default for `shallowReactive` or
53
+ `{ deep: false }`), `onWatcherCleanup(fn, failSilently?)`, and `WatchHandle`
54
+ (`stop()`, `pause()`, `resume()`, and callable `handle()`). Component
55
+ pre/post render scheduling and Vue WeakMap/WeakSet collection proxies are
56
+ not implemented by this entry. Plain objects, arrays, `Set`, and `Map` are
57
+ reactive; nested refs unwrap on object properties and retain their
58
+ identity at integer array entries and `Set`/`Map` collection entries.
59
+ Each watcher run can register multiple cleanup callbacks (via the callback's
60
+ third parameter or `onWatcherCleanup`). Reruns and stops drain
49
61
  them in registration order, attempt all callbacks after a failure, and preserve
50
62
  the first error. A cleanup that stops its watcher prevents another callback run.
51
63
 
64
+ ### Native Set and Map tracking
65
+
66
+ `reactive(new Set())`, `reactive(new Map())`, `shallowReactive`, `readonly`,
67
+ `shallowReadonly`, deep refs containing `Set`/`Map` instances, and `Set`/`Map` instances nested in plain state
68
+ use the independent native graph. Membership (`has`) and key lookups (`get`) track individual keys;
69
+ size, iteration (`keys`, `values`, `entries`, `[Symbol.iterator]`) and `forEach` track collection changes. Duplicate additions,
70
+ equal-value `Map.set` writes (`Object.is`), missing deletions and empty clears do not notify. Object keys and entries retain
71
+ raw/proxy membership identity and wrap on access/iteration in deep `reactive`/`readonly`; stored native refs retain
72
+ their identity. `shallowRef` keeps external `Set`/`Map` instances raw and tracks replacement only.
73
+ `WeakMap`/`WeakSet` reactivity and `Set` algebra methods remain unsupported. Mutating an original raw `Set` or `Map` bypasses notification.
74
+
75
+ The local compiler accepts unshadowed global `Set<T>` and `Map<K, V>` prop values. Local `Set` or `Map`
76
+ bindings, including conservative checks in nested scopes, remain rejected until
77
+ full type-resolution metadata is available. The existing authored counter fixture grows by 730 gzip bytes with
78
+ this support; the default signal kernel remains unchanged. No speed claim.
79
+
52
80
  ### Optional native watch errors
53
81
 
54
82
  `./errors` exports `withComponentErrorHandler(handler, setup)`, which requires a
@@ -76,15 +104,37 @@ configuration or `onErrorCaptured`, and adds no watcher or component frame.
76
104
  and wraps getters in readonly refs without caching their results. Its optional
77
105
  property default applies only to `undefined`; an alias does not make a plain
78
106
  source object reactive. Function-valued properties and
79
- defaults stay literal. `unref` unwraps native refs once and never calls functions.
80
- `isRef` recognizes only this entry's native refs, including computed/getter refs;
107
+ defaults stay literal. `unref` unwraps native refs once and never calls functions;
108
+ `toValue` unwraps native refs and invokes zero-argument getter functions while
109
+ keeping `ref(fn)` function values literal.
110
+ `isRef` recognizes only this entry's native refs, including computed/getter/custom refs;
81
111
  it does not accept Vue host refs or objects with a spoofed `__v_isRef` flag.
82
112
 
83
113
  `shallowRef` stores raw values unchanged and tracks replacement of `.value` using
84
114
  `Object.is` equality. It preserves existing native refs, existing reactive proxies,
85
- and literal function values. Nested raw mutations do not notify; an already
86
- reactive proxy keeps its own tracking. This supports external snapshots without
87
- deep conversion. `triggerRef` is not implemented.
115
+ and literal function values. Nested raw mutations do not notify automatically;
116
+ calling `triggerRef(ref)` forces subscribers (including `computed`, `watchSyncEffect`,
117
+ and synchronous `watch`) to re-evaluate after in-place mutations. `customRef((track, trigger) => ({ get, set }))`
118
+ creates a native ref with explicit dependency tracking and notification control.
119
+
120
+ `shallowReactive` tracks root-level object properties, array indices/length/mutations,
121
+ and `Set`/`Map` membership and entries without deep wrapping or nested ref unwrapping. `readonly`
122
+ creates a deep read-only view over plain objects, arrays, `Set`s, `Map`s, reactive proxies,
123
+ and refs (forwarding reactive tracking when wrapping a reactive target while throwing
124
+ `TypeError` on writes, deletes, `defineProperty`, or `Set`/`Map` mutations); `shallowReadonly`
125
+ enforces read-only access only at the root level. `markRaw` marks an object, `Set`, or `Map`
126
+ so `reactive`, `shallowReactive`, `readonly`, `shallowReadonly`, and `ref` return it
127
+ unwrapped (both at root and nested positions), and `toRaw` unwraps any native proxy
128
+ layer back to the underlying raw object. `isReactive`, `isReadonly`, `isShallow`,
129
+ and `isProxy` inspect native proxy and ref flags.
130
+
131
+ `effectScope(detached?)`, `EffectScope`, `getCurrentScope()`, and `onScopeDispose(fn, failSilently?)`
132
+ manage grouped reactive ownership (`watch`, `watchSyncEffect`, `computed`, nested
133
+ non-detached `effectScope`s, and `onScopeDispose` callbacks). Non-detached scopes
134
+ attach to the enclosing active `EffectScope` or native component/root owner;
135
+ detached scopes (`effectScope(true)`) remain active until their own `.stop()` is called.
136
+ Inside native component initialization, `getCurrentScope()` and `onScopeDispose()`
137
+ bind to the component's scope and clean up on component unmount.
88
138
 
89
139
  Native computed refs are lazy and cached, propagate previous successful values,
90
140
  and keep writable setters. Stopping an owner releases its watchers without
@@ -100,67 +150,209 @@ handlers, non-finite defaults and unsupported Boolean prop variants still diagno
100
150
  scheduling, effectful parent getter timing, general component composition and
101
151
  the VNode ABI remain incomplete. These compiler changes are local and unreleased.
102
152
 
103
- Native `./context` provides `provide`, `inject`, `hasInjectionContext`, and typed
104
- `InjectionKey` symbols during synchronous native component initialization. Injection
153
+ The local compiler also accepts ordinary props-less `<script setup>` components,
154
+ including empty setup, constants, JavaScript/TypeScript counters and imported
155
+ children. It supplies an empty props type when no props macro is present, after
156
+ the existing macro, import and async-setup validation. Components that declare
157
+ typed props keep their existing contract. This removes an unnecessary
158
+ `defineProps` declaration; it adds no attrs fallthrough, Options API or host VNode
159
+ support. The compiler work is unpublished. Set
160
+ `MOONSHINE_CREPUS_COMPILER` to the local compiler to enable the isolated source
161
+ regression in `test/standalone.test.ts`.
162
+
163
+ The local compiler lowers text and numeric input/textarea `v-model` to the opt-in
164
+ `./model` DOM factory and `./model/ssr` server factory. Plain models and `.lazy`,
165
+ `.trim`, `.number` use the independent graph, including IME composition handling,
166
+ focused trimming, empty numeric strings and owner cleanup. Writable setup
167
+ `ref`/`shallowRef` targets and member targets rooted in setup refs or `reactive`
168
+ objects are supported. Input types must be static text, search, tel, url, email,
169
+ password, number or range; textarea children and explicit value/defaultValue
170
+ conflicts reject. Static checkbox/radio models also compile locally: scalar typed
171
+ true/false values, loose array membership in click order, identity-based Sets,
172
+ programmatic Set updates and listener cleanup use independent factories.
173
+ Checked-model modifiers and file models remain unsupported,
174
+ as do dynamic types and readonly/unknown targets. Source lowering
175
+ is local and unpublished; this does not implement Vue directives or hydration.
176
+
177
+ Checked models match eleven direct browser cases and thirteen authored SFC phases
178
+ against Vue 3.5.13. Source SSR follows Vue's distinct root/nested policy: empty
179
+ Sets are truthy on the server, while DOM Set membership is identity-based;
180
+ nested scalar models use `true-value`, while root fallthrough SSR uses scalar
181
+ truthiness. Explicit checked attributes remain meaningful. Repeated Bun and
182
+ minified Node SSR compare all structure, attributes and text, ignoring only
183
+ attribute order and equivalent checked-attribute spelling. This is mount/SSR
184
+ support, without hydration. The existing counter bundle has no size change;
185
+ the compared form workload is 9,957 gzip bytes native versus 21,855 for Vue.
186
+ These are fixture sizes, without a startup or runtime speed claim.
187
+
188
+ Native `./select` supports single/multiple select models with inline options and
189
+ optgroups, typed option values, `.number`, Array/Set outputs and owner cleanup.
190
+ Undefined models do not adopt authored defaults. Arrays use loose membership;
191
+ Sets retain identity. Accepted writes preserve the user's duplicate option choice;
192
+ later authored component updates reconcile selection through the existing Vue
193
+ scheduler. Typed option updates and programmatic Set changes remain reactive.
194
+ `./select/ssr` follows source SSR selection, including duplicate selected options,
195
+ null models with omitted option values, and distinct Set behavior. It does not
196
+ infer an omitted option value from its label on the server. These DOM/SSR
197
+ policies intentionally differ, matching the compared Vue source behavior.
198
+
199
+ The local Crepus compiler supplies the select/option factories and writable-target
200
+ checks. Other select modifiers, nested selects, component-supplied options and
201
+ non-option markup in selects reject. Hydration remains unsupported. Eight direct
202
+ Chromium cases, eleven source SSR cases, thirteen actual SFC browser phases, repeated fresh Bun/minified Node SSR and both source
203
+ and declaration-consumer type lanes pass. The existing counter bundle stays
204
+ unchanged. This select fixture is 11,722 gzip bytes versus Vue 3.5.13's 21,900;
205
+ there is no startup/runtime speed claim. Compiler changes remain unpublished.
206
+
207
+ Plain component `v-model` compiles locally when the imported Vue SFC child declares
208
+ `modelValue` in typed props and `update:modelValue` in typed emits, or declares
209
+ `defineModel`. It uses the
210
+ existing live props and event protocol, with no added runtime or dependencies.
211
+ Explicit update listeners retain template attribute order relative to the setter;
212
+ `.once` listeners preserve the distinct DOM/server policies. Readonly targets,
213
+ conflicting explicit model props/listeners and missing child contracts reject.
214
+ Static named and multiple models also compile locally: identifier/kebab arguments
215
+ normalize to canonical child prop names, each with a matching declared update
216
+ event. Listener order is tracked separately for each model. Model props named
217
+ `class` and `style` use the existing component normalizers. Dynamic model arguments
218
+ remain unsupported. Component modifiers compile locally as described
219
+ below. This is source support, not Vue's compiled component ABI or hydration.
220
+
221
+ `@tschk/moonshine-vue/reactive` exports `useModel(props, name, options?)`,
222
+ compiler-facing `createModel`, `ModelRef<T, M, G, S>`, and
223
+ `DefineModelOptions<T, G, S>`. Top-level `const` `defineModel` declarations
224
+ (including `const [model, modifiers] = defineModel<T, M>(...)` and
225
+ `const [model, modifiers] = useModel(props, name, options)`) lower in the local
226
+ Crepus compiler to `createModel`, augmenting the component's public TypeScript
227
+ props type with the model prop (`required` when `{ required: true }` without
228
+ `default`), modifier prop (`modelModifiers`/`modelValueModifiers` or
229
+ `<name>Modifiers`), and `EventListeners<{ "update:<name>": [value: T] }>` while
230
+ registering child `defineModel` metadata for parent `v-model` and boolean-cast
231
+ validation. `createModel` / `useModel` support static and cached factory
232
+ defaults (running factories within the component consumer context for `inject()`
233
+ and preserving function defaults when the model type is a sole function),
234
+ Boolean prop casting, custom `get` and `set` transforms (with normalization
235
+ force-trigger when `set` normalizes an assigned value back to the current model
236
+ value), standalone local state when the parent omits `v-model`, controlled
237
+ parent props, and SSR reads/writes.
238
+
239
+ Thirteen authored parent/child browser phases compare both listener orders,
240
+ `.once`, external parent updates, multiple instances and disposal against Vue
241
+ 3.5.13. Server setup emits are compared across repeated fresh Bun/minified Node
242
+ renders; both source and declaration consumers pass in tsc/tsgo, including invalid
243
+ prop and callback payload checks. Before emit modifier support, this default-model
244
+ fixture was 10,510 gzip bytes versus Vue's 21,104. No startup/runtime speed claim; compiler changes remain
245
+ local and unpublished.
246
+
247
+ The named-model fixture adds fourteen browser phases covering distinct payloads,
248
+ kebab arguments, per-model listener order, `.once`, class/style normalization,
249
+ multiple roots and disposal. Repeated Bun/minified Node SSR setup emits and both
250
+ source/declaration type lanes pass. Before emit modifier support, its production
251
+ browser bundle was 10,983 gzip bytes versus Vue 3.5.13's 21,335 for the same fixture; this is no timing claim.
252
+ These compiler changes remain local and unpublished.
253
+
254
+ Component modifiers now compile locally through the opt-in event protocol.
255
+ `.trim` maps string arguments; `.number` converts every original emitted argument
256
+ with `parseFloat`, retaining the original value on NaN. When both flags are set,
257
+ number conversion uses the original arguments, including their whitespace.
258
+ Regular and once listeners receive the same converted arguments. Custom flags
259
+ are available to children that declare the corresponding modifier prop; they do
260
+ not change payloads automatically. Flag order is preserved and repeated flags
261
+ collapse. Bare models add no modifier object. Explicit `v-model:modelValue.trim`
262
+ passes `modelValueModifiers`, unlike plain `v-model.trim`'s `modelModifiers`,
263
+ preserving Vue's distinct behavior. Empty and `__proto__` modifiers reject.
264
+
265
+ Nine authored cases pass nineteen Chromium phases and repeated fresh
266
+ Bun/minified Node SSR comparisons against Vue 3.5.13. Source and declaration
267
+ consumers pass both typecheckers. Undeclared modifier props still reach the raw
268
+ emitter; Vue's extra root DOM attribute is omitted because native attrs
269
+ fallthrough remains unsupported. Modifier objects have stable identity per native
270
+ component instance. Mutating a modifier object after a parent model update differs
271
+ from Vue: native emits observe that mutation, while Vue emits use the new render's
272
+ raw modifier object. This mutation pattern is not compatible yet. This
273
+ fixture is 10,943 gzip bytes versus Vue's 21,493. The unchanged named-model control
274
+ adds 158 gzip bytes for emit conversion (11,141 versus its previous 10,983);
275
+ the signal kernel stays unchanged. No startup/runtime speed claim. Compiler
276
+ changes remain local and unpublished; dynamic model arguments and hydration
277
+ remain unsupported.
278
+
279
+ Native `./context` provides `provide`, `inject`, `hasInjectionContext`, `useId`, and typed
280
+ `InjectionKey` symbols during synchronous native component initialization (`./reactive` also re-exports `useId`). Injection
105
281
  searches ancestors, never the same component's own providers. Nearest ancestors
106
282
  shadow outer values, including explicitly provided `undefined`; refs stay refs.
107
283
  Defaults are values unless the third argument is `true`, which invokes a missing
108
284
  value's factory untracked. Factories have no Vue public-instance `this` receiver.
109
- Outside initialization, `provide`/`inject` throw; `hasInjectionContext` returns false.
285
+ `useId()` generates deterministic tree-scoped IDs (`v-0`, `v-1`, ...) scoped to the
286
+ root owner of the component/render/SSR tree so DOM and SSR produce identical IDs
287
+ without cross-request or cross-instance counter state.
288
+ Outside initialization, `provide`/`inject`/`useId` throw; `hasInjectionContext` returns false.
110
289
  This supports DOM and SSR component scopes, not Vue app-level injection or
111
290
  `app.runWithContext`, and does not establish full SFC compiler compatibility.
112
291
 
113
292
  ### Optional native lifecycle
114
293
 
115
- `@tschk/moonshine-vue/lifecycle` exports `onMounted`, `onBeforeUnmount`, and
116
- `onUnmounted`. Register synchronously during native component initialization, or
294
+ `@tschk/moonshine-vue/lifecycle` exports `onBeforeMount`, `onMounted`, `onBeforeUnmount`,
295
+ `onUnmounted`, `onErrorCaptured`, and `ErrorCapturedHook`. Register synchronously during native component initialization,
296
+ register `onMounted`/`onBeforeUnmount`/`onUnmounted` inside an `onBeforeMount` callback, or
117
297
  register `onUnmounted` inside an `onMounted` or `onBeforeUnmount` callback.
118
- SSR skips all three. Mounted hooks run after synchronous children and DOM commits,
298
+ SSR skips `onBeforeMount`, `onMounted`, `onBeforeUnmount`, and `onUnmounted` (`onErrorCaptured` remains active in both DOM and SSR for setup/watch error propagation).
299
+ `onBeforeMount` hooks run synchronously as each component's setup finishes before its template nodes are attached to the parent DOM container and before `onMounted` hooks flush.
300
+ Mounted hooks run after synchronous children and DOM commits,
119
301
  with pending component references published first. Disposed components skip queued
120
302
  mounts. Before-unmount hooks run parent first with DOM and watchers still active;
121
303
  unmounted hooks run child first after DOM removal and reactive teardown. Callbacks
122
304
  are untracked; returned cleanup functions are ignored. Mounted callbacks flush
123
305
  pending references first, recheck that the owner is live, then invoke the hook
124
- with its component context. Mounted and before-unmount callbacks restore the previous
306
+ with its component context. Before-mount, mounted, and before-unmount callbacks restore the previous
125
307
  context even when they throw. Registration from an already disposed owner,
126
308
  including an unmounted callback, is rejected.
309
+ `onErrorCaptured(hook)` intercepts descendant component errors (synchronous or asynchronous `watch` getter/callback/effect/cleanup errors and descendant lifecycle hook errors) bottom-up across the native component hierarchy (`hook(err, instance, info)` runs untracked in the capturing ancestor's injection context; returning `false` stops further propagation and prevents unhandled rethrow).
127
310
 
128
311
  This optional entry has no Vue dependency. It does not provide Vue public-instance
129
312
  receivers, app lifecycle, update hooks, async component/Suspense scheduling, or
130
- full SFC compatibility. Crepus lowers named/aliased imports of these three hooks
313
+ full SFC compatibility. Crepus lowers named/aliased imports of these five hooks
131
314
  in the accepted authored source slice. Permanent DOM/SSR fixtures verify nested
132
315
  registration, connected mount/before phases, disconnected child-first cleanup,
133
- two instances and server callback suppression. Template refs and Vue's full
134
- error-handler policy remain unproven. A failed native mounted hook tears down
135
- its owner; the reference can retain the subtree until unmount.
316
+ two instances and server callback suppression. Intrinsic and imported component
317
+ template refs (`ref="x"` and `:ref="'x'"` targeting top-level `const` `ref`,
318
+ `shallowRef`, or `useTemplateRef` setup declarations) publish before `onMounted` hooks run and clear
319
+ to `null` on unmount. Vue's full error-handler policy remains unproven. A failed
320
+ native mounted hook tears down its owner; the reference can retain the subtree
321
+ until unmount.
136
322
 
137
- Callback failures propagate after pending peers and disposal finish. Native
138
- exported-instance reference cleanup remains deferred; Vue template-ref lowering
139
- is still pending.
323
+ Callback failures propagate after pending peers and disposal finish.
140
324
 
141
325
  A watch started under an already disposed native owner throws. Ownerless watches
142
326
  remain manually stoppable.
143
327
 
144
- `./reactive` also exports `watchSyncEffect(effect)`, returning a stop function.
145
- The effect runs immediately and tracks synchronous reads, including conditional
146
- sources. Its supplied cleanup registrar accepts multiple callbacks, including
147
- late registrations while active; registrations after stopping are ignored.
148
- Cleanup runs untracked before reruns and on stop. Writes made by the effect or
149
- its cleanup do not recursively invoke that same effect; cleanup writes remain
150
- visible to the following run. Native owners stop their effects on disposal;
151
- ownerless effects require manual stopping. SSR sync effects run and stop with the
152
- request owner. Promise continuations are not tracked.
328
+ `./reactive` also exports `watchSyncEffect(effect)` and
329
+ `onWatcherCleanup(cleanupFn, failSilently?)`, with `watch` and `watchSyncEffect`
330
+ returning a `WatchHandle` (`stop()`, `pause()`, `resume()`, and callable
331
+ `handle()`). The effect runs immediately and tracks synchronous reads, including
332
+ conditional sources. Its supplied cleanup registrar and `onWatcherCleanup`
333
+ accept multiple callbacks while active; registrations after stopping are ignored
334
+ in `watchSyncEffect` and run immediately in `watch`. Calling `onWatcherCleanup`
335
+ outside an active watcher execution (or inside a `watch` source getter or
336
+ cleanup function) throws unless `failSilently` is `true`. Cleanup runs untracked
337
+ before reruns and on stop. Writes made by the effect or its cleanup do not
338
+ recursively invoke that same effect; cleanup writes remain visible to the
339
+ following run. `pause()` suspends callback/effect reruns while retaining tracked
340
+ dependencies, and `resume()` synchronously flushes if any tracked dependency
341
+ changed while paused. Native owners stop their effects on disposal; ownerless
342
+ effects require manual stopping. SSR sync effects run and stop with the request
343
+ owner. Promise continuations are not tracked.
153
344
 
154
345
  Cleanup attempts every registered callback and propagates the first failure;
155
346
  failed effect runs release their registered cleanup while preserving the effect
156
347
  error. This follows native error handling rather than Vue's app error handler.
157
- This entry does not supply scheduled `watchEffect`, pause/resume handles, or a
158
- Vue component render scheduler.
348
+ This entry does not supply scheduled `watchEffect` / `watchPostEffect` or a Vue
349
+ component render scheduler.
159
350
 
160
- `./reactive` exports `toRefs(object)` for destructuring linked properties without
161
- losing live reads or writes. It snapshots enumerable string keys (including
351
+ `./reactive` exports `toRefs(object)` and `proxyRefs(objectWithRefs)` (`ShallowUnwrapRef<T>`) for destructuring and unwrapping linked properties without
352
+ losing live reads or writes. `toRefs` snapshots enumerable string keys (including
162
353
  inherited keys), omits symbols and preserves array length and holes. Properties
163
354
  added later need `toRef(object, key)`. Existing native refs retain their identity.
355
+ `proxyRefs` shallowly unwraps ref reads and forwards non-ref property writes into existing refs while returning `reactive` objects unchanged.
164
356
  Getter/setter descriptors keep their source receiver; writes to getter-only
165
357
  properties throw. This does not implement Vue readonly-proxy warnings or SFC
166
358
  compilation.
@@ -276,12 +468,47 @@ error policy. Render-expression evaluation and fallback, props-job error
276
468
  attribution, and full Vue lifecycle timing remain separate work. The optional `/errors` scope handles watch phases; it does not
277
469
  turn a default factory failure into an app error handler call.
278
470
 
471
+ ### Compiler-facing expose and template refs
472
+
473
+ `@tschk/moonshine-vue/expose` exports `exposeRefs(exposed)` and its
474
+ `ShallowUnwrap<T>` type helper, `bindRef`, `bindComponentRef`, and re-exports
475
+ `useTemplateRef` and `TemplateRef<T>` from `@tschk/moonshine-vue/reactive`.
476
+ `exposeRefs` returns a shallow-unwrapping proxy for `defineExpose(record)` where
477
+ top-level native refs (`ref`, `shallowRef`, `computed`, `toRef`,
478
+ `useTemplateRef`) unwrap on `get` and forward `set` to writable `.value`
479
+ (throwing `TypeError` on readonly refs), while plain values, getters/setters and
480
+ reactive objects retain their descriptors and prototype checks. When a `<script setup>`
481
+ component omits `defineExpose` or calls `defineExpose()`, it exposes an empty
482
+ null-prototype object (`exposeRefs({})`) so component template refs receive a
483
+ non-null exposed instance rather than leaking internal setup bindings.
484
+
485
+ `useTemplateRef<T>(key)` requires active component initialization and a unique
486
+ non-empty string key per component instance, returning a `TemplateRef<T>`
487
+ (`Readonly<Ref<T | null>>`) initialized to `null` whose user `.value = ...`
488
+ setter throws `TypeError` while internal `bindRef` / `bindComponentRef` bindings
489
+ publish and clear the reference.
490
+
491
+ The local Crepus compiler lowers top-level `defineExpose` and static template
492
+ refs (`ref="x"` and `:ref="'x'"` targeting a top-level `const` `ref`,
493
+ `shallowRef`, or `useTemplateRef("x")` setup binding) on intrinsic elements
494
+ (including `<input>`, `<textarea>`, `<select>`, and `<option>` with `v-model`)
495
+ and imported PascalCase components. Intrinsic refs bind through `bindRef` and
496
+ component refs bind through `componentRef` (or `bindComponentRef` for
497
+ `useTemplateRef` targets) with `cleanup: "commit"`, publishing before `onMounted`
498
+ hooks run and clearing to `null` on unmount. In SSR, `defineExpose` runtime
499
+ evaluation and template `ref` attributes are erased while preserving the
500
+ component's `ComponentView<Node, Exports, Props>` return brand. Dynamic ref
501
+ expressions, function refs, and `v-for` ref arrays remain explicit compile errors.
502
+
279
503
  ### Optional native application mount
280
504
 
281
- `@tschk/moonshine-vue/app` exports `createApp(component, props)` for native
282
- component factories, including Crepus-compiled Vue components. Props retain the
283
- factory's public type. The returned native application has only `mount(target)`
284
- and `unmount()`; `mount` returns `void`, not a Vue public instance.
505
+ `@tschk/moonshine-vue/app` exports `createApp(component, props)` and the
506
+ `ComponentExports<C>` type helper for native component factories, including
507
+ Crepus-compiled Vue components. Props retain the factory's public type. The
508
+ returned native application has `mount(target)` and `unmount()`; `mount` returns
509
+ the root component's exposed value (`ComponentExports<typeof component>`, or a
510
+ null-prototype empty object when nothing is exposed), not a full Vue public
511
+ instance (`$el`, `$props`, `$emit`).
285
512
 
286
513
  `mount` accepts a selector, Element or ShadowRoot in the current DOM realm,
287
514
  clears its existing children and mounts one owned root. A private container lease
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tschk/moonshine-vue",
3
- "version": "0.4.4",
3
+ "version": "0.4.80",
4
4
  "description": "Native composition helpers and signal bridges with optional legacy Vue runtime/compiler entries",
5
5
  "license": "ISC",
6
6
  "type": "module",
@@ -15,23 +15,31 @@
15
15
  "./context": "./src/context.ts",
16
16
  "./lifecycle": "./src/lifecycle.ts",
17
17
  "./text": "./src/text.ts",
18
+ "./model": "./src/model.ts",
19
+ "./model/ssr": "./src/model-ssr.ts",
20
+ "./select": "./src/select.ts",
21
+ "./select/ssr": "./src/select-ssr.ts",
18
22
  "./props": "./src/props.ts",
19
23
  "./slots": "./src/slots.ts",
20
24
  "./events": "./src/events.ts",
21
25
  "./normalize": "./src/normalize.ts",
22
26
  "./errors": "./src/errors.ts",
23
- "./app": "./src/app.ts"
27
+ "./expose": "./src/expose.ts",
28
+ "./app": "./src/app.ts",
29
+ "./router": "./src/router.ts",
30
+ "./store": "./src/store.ts",
31
+ "./server-renderer": "./src/server-renderer.ts"
24
32
  },
25
33
  "dependencies": {
26
- "@tschk/moonshine": "^0.4.4",
27
- "@tschk/moonshine-dom": "^0.4.4"
34
+ "@tschk/moonshine": "^0.4.80",
35
+ "@tschk/moonshine-dom": "^0.4.80"
28
36
  },
29
37
  "devDependencies": {
30
38
  "typescript": "7.0.2"
31
39
  },
32
40
  "peerDependencies": {
33
41
  "vue": ">=3",
34
- "@tschk/moonshine-framework": "^0.4.4"
42
+ "@tschk/moonshine-framework": "^0.4.80"
35
43
  },
36
44
  "peerDependenciesMeta": {
37
45
  "vue": {