@tschk/moonshine-svelte 0.0.0-stage → 0.4.49

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
@@ -1,3 +1,595 @@
1
- # Temporary Holding Version
1
+ # `@tschk/moonshine-svelte`
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Independent stores, native component context/events, lifecycle helpers, and Moonshine signal bridges.
4
+ No Svelte runtime, React, WASM, or parser is required. The framework peer is
5
+ optional at runtime and loaded only when using the compatibility renderer.
6
+
7
+ Strict TypeScript checking of the root entry requires installing
8
+ `@tschk/moonshine-framework`, even when importing only a bridge: the root also
9
+ exports `crepusRenderer` with the framework's `Renderer` contract. The framework
10
+ remains optional for runtime imports and bridge-only browser/Bun/Node bundles.
11
+ This requirement does not apply to the signal-only `@tschk/moonshine` core entry.
12
+
13
+ | Subpath | Provides |
14
+ | ---------- | -------------------------------------------------------------------------------------------- |
15
+ | `.` | signal bridges and lazy native SSR compatibility renderer |
16
+ | `./svelte` | lifecycle, context, typed `createContext`, component event dispatch |
17
+ | `./class` | opt-in `classValue` and `classDirectives` for source classes |
18
+ | `./store` | independent `writable`, `readable`, `readonly`, `derived`, `get`, `toStore`, and `fromStore` |
19
+
20
+ `classValue` flattens nested class arrays and includes truthy object keys. Empty
21
+ results return `undefined`, omitting the DOM/SSR attribute. Top-level primitive
22
+ values retain Svelte 5.57 stringification; nested falsy values are omitted. This
23
+ helper does not change ordinary native `h()` attributes.
24
+
25
+ `classDirectives(base, hash, flags)` normalizes the base, appends an optional scope
26
+ hash, then applies own class flags in order. Truthy flags append tokens; false
27
+ flags remove matching tokens, including a matching hash. The local Crepus compiler
28
+ uses it for authored intrinsic `class:` directives, including dynamic elements.
29
+ Source parsing and independent input memoization belong to Crepus; this helper
30
+ does not execute Svelte's compiled component instructions or implement style directives.
31
+
32
+ The optional `/runes` entry exports compiler-facing `createState`, `createDerived`
33
+ and `createRuneEffect`.
34
+
35
+ Compiler-facing `/runes` also exports `spreadProps(...layers)` for live component
36
+ props. Layers are objects, nullish values, or object getters; later layers win.
37
+ Source getters keep their receiver and are read lazily. Layer getters are not
38
+ cached: the compiler must memoize call expressions where required. Nullish
39
+ layers are skipped during setter lookup, avoiding the pinned host's null-layer
40
+ assignment error. Pass component
41
+ children through the named props object to preserve source precedence.
42
+
43
+ The separate `/ssr` `spreadServerProps(layers)` copies enumerable own string-key
44
+ descriptors once per render pass. Getters remain lazy and read from the merged
45
+ object; symbols and inherited properties are omitted. DOM and SSR spread helpers
46
+ intentionally have different contracts. The native SFC gate verifies bounded component spread lowering, including
47
+ call-expression caching, live rest props, explicit children and component
48
+ references. Intrinsic forwarding has the separate bounded contract below.
49
+ Implicit body/legacy slots and hydration remain unverified.
50
+
51
+ ### Native intrinsic attribute forwarding
52
+
53
+ The local unpublished Crepuscularity compiler now lowers spreads on ordinary
54
+ static HTML elements through independent Moonshine helpers. This includes a
55
+ wrapper's live `$props()` rest object, multiple interspersed layers, removed keys,
56
+ and named attributes that override or fall back when spread keys disappear.
57
+ `installElementSpread` on `/runes` owns DOM updates and direct event listeners;
58
+ `installBoundElementSpread` installs compiler-owned binding callbacks once between
59
+ capture and ordinary input/change listeners, without filtering spread-provided
60
+ live values. Details toggle handlers precede their binding write;
61
+ `spreadServerEntries` on `/ssr` supplies explicit server attribute entries.
62
+ The local form-spread work adds `spreadServerElement` for input defaults and
63
+ typed select/option identity; these form helpers require Moonshine 0.4.40 or newer.
64
+ Component prop spreads keep their existing contract.
65
+
66
+ Each layer expression and enumerable getter runs once per update/render in
67
+ source order, including overridden values. Function data is not invoked.
68
+ Class values use the source class normalizer; spread style values use string
69
+ coercion, not the native DOM factory's object-style API. Event handler replacement
70
+ retains a stable listener; removal and owner disposal release it. Listeners are
71
+ direct rather than Svelte's delegated events. Mixed-case event-like attribute
72
+ strings are filtered consistently with native SSR, which is stricter than Svelte.
73
+ DOM content-replacement keys reject before mutation. String-valued `ref` and
74
+ `children` remain attributes and do not replace template children.
75
+
76
+ The locally verified compiler also admits unbound input/select/option/textarea
77
+ spreads. DOM values remain separate from reset defaults; option and input values
78
+ use Moonshine's typed stores. Selects reconcile live/default selection after
79
+ children mount and observe inserted options. An authored fixture matches Svelte
80
+ in five Chromium phases and repeated SSR; an isolated Bun/Node source regression
81
+ checks typed option identity. This does not establish full form compatibility.
82
+
83
+ The local compiler also combines spreads with input/textarea `bind:value`,
84
+ checkbox `bind:checked`, select `bind:value`, static file-input `bind:files`,
85
+ and static checkbox/radio `bind:group`.
86
+ Authored input/checkbox/select/file/group
87
+ fixtures match Svelte in Chromium and repeated SSR, including handler order and
88
+ typed selections. File SSR preserves authored attributes without reading the
89
+ bound model. The local compiler additionally admits spread `bind:open` on details. This
90
+ requires Moonshine 0.4.41 or newer: existing toggle
91
+ handlers run before the binding write; handlers removed and re-added follow
92
+ ordinary listener registration order. Authored Chromium and six SSR renders
93
+ cover this bounded path. Spread `bind:group` requires a static `type="checkbox"`
94
+ or `type="radio"` attribute; spread-only `value` changes update the input value
95
+ without re-evaluating `checked` until the group model or an authored dynamic
96
+ `value={expr}` updates, and SSR derives `checked` at the `bind:group` position
97
+ only when an authored `value` attribute is present.
98
+
99
+ Source admission still rejects spreads on title, dynamic or namespaced/custom
100
+ elements, and combinations with actions,
101
+ attachments, class/style directives or scoped CSS. Attachment symbols and
102
+ autofocus behavior are not implemented by this helper. Hydration and arbitrary
103
+ precompiled Svelte instructions remain unsupported.
104
+
105
+ The authored wrapper matches Svelte 5.57.1 through five Chromium update phases,
106
+ including two independent instances, attribute fallback, clicks, node/focus
107
+ retention and disposal. Repeated SSR and isolated Bun/Node source tests verify
108
+ getter order and attribute output without installing a host runtime. These checks do
109
+ not establish complete source compatibility.
110
+
111
+ Reproduce the form SSR comparison with
112
+ `bun scripts/benchmark-svelte-form-ssr.ts --compiler /path/to/crepus`
113
+ from the repository root. Use `--svelte /path/to/installed/svelte` when the
114
+ reference package is installed outside the root resolver. It runs seven
115
+ alternating fresh Bun processes, 1,000 warmups and 5,000 timed renders per
116
+ process, and reports minified bundle bytes, first-render and process wall time.
117
+ Process wall time includes warmup/workload and is not startup-only. The measured
118
+ native form bundle is smaller, while its repeated SSR is slower than Svelte
119
+ 5.57.1 in this workload. Machine contention is uncontrolled; this does not
120
+ establish a general speed or size ranking.
121
+
122
+ Lifecycle helpers require a live native owner. `onMount` runs untracked in a
123
+ microtask after synchronous DOM insertion; a synchronous returned function is
124
+ owned cleanup. Async callbacks do not register returned promise values as
125
+ cleanup. Disposed roots skip pending mounts, including synchronous SSR roots.
126
+ `onDestroy` runs on owner disposal, including SSR. `tick()` yields, then commits
127
+ pending native rune work across the default effect and opt-in render queues.
128
+ Future promise/timer updates and hydration remain separate contracts.
129
+
130
+ Mount hooks share the post-DOM rune-effect queue, preserving registration order
131
+ across sibling components. By default, pending native component references publish before
132
+ mount/effect callbacks. Opaque exported instances preserve live getters and methods;
133
+ source fixtures now verify named/empty exports and scalar/member `bind:this` in Chromium and SSR. Other export forms and loop-dependent references remain separate acceptance work.
134
+
135
+ Stores implement the subscription protocol, but reads are not automatically
136
+ tracked by native DOM bindings. Subscribe into a native signal and unsubscribe
137
+ on destruction:
138
+
139
+ ```ts
140
+ import { createSignal } from "@tschk/moonshine-dom/reactive";
141
+ import { writable } from "@tschk/moonshine-svelte/store";
142
+ import { onDestroy } from "@tschk/moonshine-svelte/svelte";
143
+
144
+ // During native component initialization:
145
+ const count = writable(0);
146
+ const [value, setValue] = createSignal(0);
147
+ onDestroy(count.subscribe((next) => setValue(next)));
148
+ // Use value as a native DOM child accessor.
149
+ ```
150
+
151
+ Context and dispatch APIs require native function-component initialization through
152
+ `h(Component, props)` or `createComponent` from `@tschk/moonshine-dom/component`.
153
+ Each instance inherits its own context map; `getAllContexts()` returns that live
154
+ map. Mutating it changes subsequent context reads and child inheritance without
155
+ changing sibling or ancestor maps.
156
+ `createContext<T>()` returns typed get/set/has functions.
157
+
158
+ `createEventDispatcher` delivers non-bubbling `CustomEvent`s to the explicit
159
+ listener map on the `componentEvents` symbol from the component module. It
160
+ supports detail, listener arrays and cancellation. Callback props remain separate.
161
+ Disposed instances stop dispatching; listeners have no legacy exported-instance
162
+ `this`. This is a native compiler contract, not Svelte's internal component ABI.
163
+
164
+ This package does not execute existing Svelte compiler instructions or alias
165
+ `svelte`; existing output must be recompiled through Crepus. Authored top-level/imported `$store` reads, replacement and writable expressions have bounded DOM/SSR proof. The tested local compiler supports a bounded authored
166
+ SFC slice: scalar, shallow raw and ordinary deep `$state`, `$state.snapshot`, `$derived`,
167
+ post-DOM `$effect`, and live `$props()` (whole-object or destructured with rename,
168
+ defaults and read-only rest), click handlers, static/dynamic child components,
169
+ keyed blocks, `$effect.tracking()`, manual `$effect.root`, checkbox/value/range
170
+ bindings, named/empty component exports, scalar/member `bind:this` and named context helpers. Reachable plain
171
+ TypeScript context helpers use the native bridge too. Fixtures are verified in
172
+ Chromium and SSR, including skipped effect factories on the server.
173
+ Full source-compatibility remains unfinished; the acceptance surface is
174
+ tracked in [the SFC coverage ledger](../../docs/native-sfc-coverage.md).
175
+
176
+ The `/runes` helpers are compiler targets. `createState` isolates proxy writes
177
+ from ordinary object/array inputs and tracks deep mutations. Unusual property
178
+ descriptors reject explicitly. Reads capture raw properties lazily; proxy writes
179
+ remain isolated from the input. Own properties shadowing inherited names enumerate
180
+ consistently, intentionally differing from Svelte's edge behavior. Complete Svelte
181
+ proxy parity remains unfinished. `stateSnapshot` clones plain data and supported
182
+ platform values, handles `toJSON` and cycles, and retains uncloneable values.
183
+ Map/Set snapshots are shallow, matching Svelte production.
184
+ `createRawState` preserves object/function identity and tracks only replacement,
185
+ with Svelte's `===` equality and the same teardown-history policy as deep cells.
186
+ Nested mutation remains ordinary JavaScript; this helper does not create proxies.
187
+ `createRuneEffect` deduplicates post-DOM microtask effects, owns
188
+ teardown and nested work, and skips synchronous SSR, including bare renders and
189
+ retained foreign owners. It does not implement
190
+ the pre scheduler or asynchronous Svelte boundaries; `/pre` stays separate. `runeTracking()` reports whether
191
+ synchronous dependency collection is active: true inside native render accessors,
192
+ derived computations and rune effects; false during component setup, ordinary
193
+ event callbacks and `untrack`. The tracking source fixture verifies these contexts
194
+ in Chromium and SSR.
195
+
196
+ `createDerived` evaluates on demand and allows optimistic `.value` overrides.
197
+ Dependency invalidation resets an override even when the computed value is equal;
198
+ dynamic dependencies, errors and diamond updates preserve the kernel's pull graph.
199
+ Runtime helper tests do not establish compiler coverage for every rune form.
200
+
201
+ The source gate also admits imported `.svelte.ts` and `.svelte.js` factories with
202
+ function-local state, raw state and derived declarations. Typed and JavaScript
203
+ factories preserve independent instances, cached reads, live getters and SSR
204
+ request output. Top-level exported rune cells remain explicitly unsupported,
205
+ including declarations supplying types without a runtime implementation. Two
206
+ synchronous writes can still cause an extra native derived callback; the current
207
+ source fixture tests writes separately and does not establish full batching
208
+ parity.
209
+
210
+ `createProp` supplies writable compiler prop cells: ordinary writes stay local;
211
+ declared bindable props forward an actual parent setter. Defaults use a lazy,
212
+ reactive derived value, matching the Svelte 5.57.1 reference. A bound undefined prop
213
+ with a fallback rejects in the browser; SSR forwards a defined fallback instead.
214
+ This helper does not validate source binding declarations or implement `bind:this`.
215
+ Its SSR forwarding is not Svelte `$bindable` parity. Source SSR lowering must use
216
+ the optional `/ssr` local prop cells and buffered retries with one-time setup and
217
+ lifecycle callbacks retained only from the accepted render pass.
218
+
219
+ The root `crepusRenderer` is a lazy native SSR compatibility renderer. Pages
220
+ must explicitly use `@tschk/moonshine-dom/ssr`. Source-path loading is supported
221
+ under Bun; bundled deployments use
222
+ `@tschk/moonshine-dom/framework-native` with their bundled module table.
223
+
224
+ The optional `/binding` entry wraps native single-select and radio bindings with
225
+ state-origin comparison: a native state proxy and its original object compare
226
+ equal. Selected values are forwarded unchanged, preserving proxy overlays.
227
+ Multiple selects and checkbox groups retain array `includes` identity semantics.
228
+ Single selects match a typed `undefined` option before adopting browser defaults;
229
+ choosing a duplicate option retains that node when its model value is unchanged.
230
+ Checkbox binding and typed-value metadata helpers forward to native bindings. This entry does not add source binding
231
+ syntax support or recognize proxies created by an installed Svelte runtime.
232
+
233
+ `createRuneRoot` on `/runes` runs untracked setup synchronously and returns an
234
+ idempotent disposer. Its effects have a manual lifetime: enclosing component
235
+ unmounts and effect reruns do not dispose the root. Returned setup cleanup runs
236
+ when explicitly stopped, after owned effects. SSR component frames skip setup
237
+ entirely; server lowering must also erase source `$effect.root` callbacks.
238
+ Svelte `/binding` also maps empty numeric `bindValue` writes to `null`;
239
+ invalid nonempty numeric defaults reset to `NaN`, while text fields still write
240
+ empty strings. Generic native DOM bindings keep their
241
+ existing `undefined` numeric contract. Input type must remain fixed.
242
+
243
+ Teardown history is confined to this adapter. Within a pending flush, cleanup
244
+ reads the first previous values of compiler-created state and derived cells;
245
+ cleanup writes remain immediately readable. Derived historical reads keep a
246
+ separate cache, and synchronous native DOM consumers continue to read live values.
247
+ Proxy property history follows Svelte's lazy sources: previously unread properties
248
+ can read as undefined during cleanup, while key enumeration follows current structure.
249
+ External kernel getters without instrumented writers cannot reconstruct history.
250
+ SSR destruction reads live values. The source acceptance gate checks pending
251
+ teardown, derived values, manual stop, disposal and isolated SSR requests.
252
+
253
+ The optional `/ssr` entry exposes compiler-facing `createServerProp`, `afterRender`
254
+ and `settle` helpers for synchronous server bindings. Server prop assignments stay
255
+ local until successful serialization ends; only a currently undefined parent with
256
+ an own setter receives the final defined child value. `settle` buffers retryable
257
+ template output while setup stays outside the callback. Discarded attempts run
258
+ internal cleanup but suppress Svelte destroy callbacks, including nested accepted
259
+ attempts inside a discarded parent. Only accepted output updates select bookkeeping.
260
+ Runaway invalidation throws after 1,000 attempts. The native source gate now
261
+ verifies scalar component `bind:value` with a child `$bindable(3)` default:
262
+ two-way browser writes, retained nodes, independent instances, all four SSR
263
+ initial/assignment cases and accepted cleanup. Failed undefined browser setup
264
+ cleans the partial native parent owner, differing from the pinned reference.
265
+ The composite source fixtures also verify typed member targets, renamed child
266
+ bindable props, reactive fallback values without premature parent publication,
267
+ and binding precedence over spreads in either attribute order. Named component
268
+ getter/setter pairs also have source acceptance: boolean/string transformations,
269
+ captured member functions called without a receiver, and strict literal-union
270
+ types. Dynamic replacements retain their captured functions, set up the new
271
+ component before old cleanup, and keep both write directions live. Unlike ordinary bindings, SSR function bindings publish an undefined
272
+ getter's child fallback once without retrying setup. Browser undefined values
273
+ still reject when the child has a fallback. Other binding forms, asynchronous
274
+ rendering and hydration remain unverified.
275
+
276
+ The separate `/pre` entry exports `withRuneScheduler(callback)` and
277
+ `createRunePreEffect(callback)`. Enter scheduling under a live native owner:
278
+
279
+ ```ts
280
+ import { h, render } from "@tschk/moonshine-dom/dom";
281
+ import { withRuneScheduler } from "@tschk/moonshine-svelte/pre";
282
+
283
+ const dispose = render(() => withRuneScheduler(() => h(App, {})), target);
284
+ ```
285
+
286
+ Within this tree, pre-effects run initially during setup. Later writes coalesce
287
+ into a microtask: parent pre-effects see current state and old DOM, structural
288
+ work removes hidden descendants before their queued callbacks, retained keyed
289
+ rows follow current index order, and DOM updates precede post-effects. References
290
+ publish before mounts/effects by default; opt-in `publication: "post"` on the
291
+ component reference can register after child mounts/effects and before ancestor
292
+ posts. Scheduled control branches dispose children before parent hooks while
293
+ retained rows survive updates. Child post callbacks precede ancestor callbacks.
294
+ Reference publication can invalidate pre-effects and text bindings; that work
295
+ waits until pending posts finish. Ordinary post-effect cleanup writes still
296
+ render before nested posts. Structural branches follow owner order, so an earlier
297
+ branch invalidated by a later branch waits for the next pass. Render/structural
298
+ job descendants dispose before their component's hooks; pre-effect shutdown
299
+ retains subscription-first error precedence.
300
+ Pure derived values remain pullable. Cleanup history spans the complete cycle.
301
+ Errors drain queued peers, ownership cancels disposed work, and repeated feedback
302
+ is limited per callback rather than per distinct job. Ownerless entry rejects;
303
+ Synchronous SSR bypasses new scheduling and suppresses pre callbacks, including
304
+ bare callbacks and foreign scopes.
305
+
306
+ The ordinary native renderer stays synchronous. `/runes` does not import this
307
+ scheduler. The authored pre-effect pair has bounded DOM/SSR source acceptance,
308
+ including skipped SSR factories and child-first destruction. Other pre-effect
309
+ variants, actions, attachments, async boundaries and hydration need separate
310
+ source acceptance. `tick()` also drains synchronous writes between these native
311
+ queues; this does not establish Svelte's asynchronous compiler semantics.
312
+
313
+ The separate `/directives` entry provides manual `installAction(element, invoke,
314
+ readParameter?)` and `installAttachment(element, readAttachment)` under a live
315
+ `withRuneScheduler` tree. Install them before the element's attribute/text jobs
316
+ (for native `h`, use its first `ref` prop). Factories run after insertion; action
317
+ updates keep their source position before later DOM jobs. Attachment identity
318
+ changes clean up before replacement, while retained callback dependencies rerun
319
+ after DOM updates. Final cleanup sees the element removed.
320
+
321
+ Action parameters observe deep native state, including lazy cyclic aliases;
322
+ merely reading another alias does not trigger an update. Traversal interests
323
+ are removed on rerun/disposal. SSR skips all directive thunks. Native cleanup
324
+ drains peers and reports the first failure, differing from Svelte's early abort.
325
+ These helpers do not establish `use:` or `{@attach}` source lowering, attachment
326
+ spread support, hydration or complete Svelte directive compatibility.
327
+
328
+ The optional `/await` entry exports `awaitBlock(read, { pending, then, catch })`.
329
+ Use it under a live `withRuneScheduler` owner; branch values and errors are
330
+ accessors. Promise completion commits within one microtask, ignores stale or
331
+ disposed generations, and preserves a retained branch's nodes and local state.
332
+ Replacement branches initialize before old cleanup. Plain values, including
333
+ `false` and `null`, select `then`; already resolved promises skip pending output.
334
+
335
+ Synchronous SSR reads once and emits pending output for promises, or `then` for
336
+ plain values. It does not await. Missing rejection branches use native owner
337
+ error handling; unhandled callback failures retain the original error in a
338
+ microtask. This helper does not establish authored `{#await}` lowering,
339
+ asynchronous SSR, hydration, transitions or complete Svelte compatibility.
340
+
341
+ The optional `/store-binding` entry exports `createStoreReference<T>()` for
342
+ compiler-owned component subscriptions. Create one per store variable under a
343
+ live native owner. Its `get(store)` subscribes lazily, caches repeated reads and
344
+ tracks later notifications, including identical object/function values.
345
+ `releaseIfChanged(next)` releases the old subscription immediately and returns
346
+ `next`, without eagerly subscribing to it. Call `finish()` at the end of instance
347
+ setup, after registering authored destruction hooks; this preserves cached store
348
+ reads during teardown and releases child subscriptions before parent hooks. A
349
+ failed-setup fallback still releases acquired subscriptions.
350
+
351
+ Both function and observable-object unsubscriptions retain their protocol and
352
+ receiver. Effect cleanup uses the existing previous-flush history. SSR caches
353
+ subscriptions within the request owner and releases them on disposal. Retained
354
+ reads after disposal use temporary subscriptions; callbacks emitted after
355
+ unsubscription are ignored. Compiled SSR instead selects the separate server
356
+ group described below. Native failures drain cleanup peers. The local Crepuscularity `dafde4ab` compiler verifies authored top-level and
357
+ imported `$store` reads plus simple `$state` store-variable replacement. It
358
+ rejects `$store` assignments and mutations. This compiler patch is applied locally in
359
+ Crepuscularity but is not released; legacy reactive statements, async SSR and hydration
360
+ remain unsupported.
361
+
362
+ `/ssr` also provides `createServerState(initial)` and
363
+ `createServerDerived(compute, cache?)` for server lowering. State is a plain box.
364
+ Derived caching defaults to the render context at creation; component lowering
365
+ passes `true` explicitly. Nullish overrides resume computation, while falsy and
366
+ function values remain literal overrides. This centralizes server runtime policy
367
+ in Moonshine. The verified compiler source gate checks these imports for
368
+ components and both JS and TS companion factories, including a companion sharing
369
+ its importing SFC's basename.
370
+
371
+ The verified local `dafde4ab` compiler installs the rune scheduler in generated DOM
372
+ components. Native handwritten rendering remains synchronous by default. The
373
+ same authored counter built by this compiler is 10,766 gzip bytes versus pinned
374
+ Svelte 5.57.1's 17,389; this is one workload, not a universal size or speed claim.
375
+ The optional adapter-event hook in the shared DOM factory adds 32 gzip bytes to
376
+ this workload; the signal kernel is unchanged.
377
+
378
+ The 340-module source gate includes a self-imported recursive component tree.
379
+ Conditional updates preserve local state, focus and context; removed descendants
380
+ stop before their stale props can be evaluated. Disposal/remounting and fresh
381
+ escaped SSR match the pinned reference. Broader component compatibility remains
382
+ tracked in the coverage ledger.
383
+
384
+ Named component snippets preserve lexical values, consumer arguments, inherited
385
+ context, retained focus/local state and child-first cleanup. Type-only `Snippet`
386
+ imports use Moonshine's host-free contract; both generated graphs pass strict
387
+ checking, with fresh escaped SSR verified.
388
+
389
+ Bare intrinsic attributes preserve empty strings, expression attributes retain
390
+ boolean values, and bare component props remain `true`. The source gate also
391
+ checks boolean controls, empty file values and quoted event expressions in DOM
392
+ and SSR. A bounded form-reset fixture also checks literal versus expression
393
+ defaults, bound text/number/checkbox models, user/programmatic writes, reset after
394
+ tick, independent instances, disposal and fresh SSR. Broader reset variants remain open.
395
+
396
+ Function-local TS and JS companion factories can contain `$effect`. Two factories in
397
+ each of two component instances match the reference post-DOM and cleanup traces;
398
+ SSR erases registration and callback evaluation. Same-basename SFC/JS companions
399
+ are supported through explicit compiler inventory mapping and collision-safe
400
+ component output names. The source gate checks strict TS graphs, emitted JS
401
+ syntax, host-free imports and fresh escaped requests.
402
+
403
+ Textarea source checks cover literal versus expression defaults, unchanged-output
404
+ dirty-edit retention, changed values and independent instances. Raw closing tags,
405
+ component-looking markup and script strings remain text. Literal CR/CRLF, named
406
+ entities, semicolonless ampersands and static/dynamic decoding differences match
407
+ pinned Svelte DOM and parsed SSR; fixtures declare UTF-8 explicitly. Ordinary
408
+ text fragment whitespace and programmatic raw-snippet ownership remain open.
409
+
410
+ The source gate also checks bounded ordinary whitespace, snippet boundaries,
411
+ NBSP edges and pre/textarea indentation against exact DOM and parsed SSR
412
+ references. Leading pre newlines before conditionals, keys, snippets, raw HTML and imported
413
+ components now have exact DOM/parsed SSR checks; SVG and nested snippet
414
+ whitespace remain separate work.
415
+
416
+ Private raw-snippet bridges are available on `/raw-snippet`, `/raw-snippet-dom`
417
+ and `/raw-snippet-ssr`. They separate source callable metadata, DOM getter cells
418
+ and SSR values, with explicit consumer ownership and cleanup. These entries
419
+ require compiler lowering; authored `createRawSnippet` remains outside the source
420
+ acceptance gate. Only one trimmed HTML element root is supported, without
421
+ hydration. See the coverage ledger for the exact runtime and reference checks.
422
+
423
+ The private DOM entry also exports `createRawSnippetSlot`. Lowering creates one
424
+ slot per `@render`, passes `slot.deferRemoved` to `mapArray`, wraps invocation in
425
+ `slot.render`, and returns `slot.commit(mapped())` for every output, including
426
+ ordinary and empty snippets. This commits replacement setup before disposing
427
+ the previous branch and drains canceled work when its owner is disposed.
428
+
429
+ The private raw insertion hook adds 30 gzip bytes to the authored counter;
430
+ the signal-only default bundle remains unchanged.
431
+
432
+ The source gate verifies textarea body/reset-default independence, exact reader
433
+ order and complete SSR defaultValue expression erasure. Coercion/error-order
434
+ variants remain separate reference work.
435
+
436
+ Textarea expression bodies also preserve dirty edits when a forced rerun returns
437
+ the same object, without repeating its conversion. The source gate checks
438
+ conversion failures, DOM Symbol assignment errors, reset/disposal, literal versus
439
+ expression newlines, independent instances and fresh escaped SSR. Mixed body
440
+ expressions and default-value conversion ordering remain separate work.
441
+
442
+ One-level object and fixed-array `$derived` patterns now have authored DOM/SSR
443
+ proof, including renames, lazy defaults, bounded iterator closing, typed tuples,
444
+ independent overrides and error recovery. Nested/rest/computed patterns still
445
+ reject. Imperatively read derived chains remain lazy after source writes.
446
+
447
+ `/ssr` exports `createServerStoreReferences()` for compiler-owned server groups.
448
+ Create per-variable refs through `group.create<T>()`; call `group.finish()` after
449
+ successful serialization and accepted settlement, before bindable prop commits.
450
+ Cleanup follows first-read order and preserves completed same-source caches for
451
+ destruction hooks. Failed/discarded attempts still release resources. Late/new
452
+ destruction reads are balanced one-shot subscriptions, and peer cleanup drains
453
+ after errors; these deliberately avoid reference leaks. The DOM `/store-binding`
454
+ helper retains its separate destruction-before-release contract.
455
+
456
+ Compiler-facing `/store-binding` exports `setStoreValue`, `mutateStoreValue`
457
+ and `updateStoreValue`; `/ssr` exports `setStoreValue`, `mutateServerStore`
458
+ and `updateStoreValue`. Lowering captures the writable source before evaluating
459
+ an assignment and preserves the expression result. DOM member writes and SSR
460
+ member writes deliberately have different read/notification ordering. These
461
+ helpers require compiler-owned evaluation order; they are not general mutation
462
+ utilities. The frozen writable-store compiler passes the 346-module source gate,
463
+ including direct/compound/logical/member writes and prefix/postfix updates.
464
+ Destructuring, delete and iteration write targets remain rejected.
465
+
466
+ Scheduled list cleanup follows current retained keyed row order, children before
467
+ parents, while deferred removed rows remain alive until commit or owner disposal.
468
+ Authored keyed and unkeyed `#each` blocks now pass real CLI source acceptance
469
+ with identifier and static nested object item bindings, live indices,
470
+ arrays/iterables/array-like/nullish inputs,
471
+ key visits interleaved with setup and physical movement, retained row state and
472
+ empty fallbacks. Repeated empty inputs retain the same fallback root and DOM.
473
+ SSR does not evaluate keys. Renamed aliases, nested member bindings and unbound
474
+ callback/tag receivers have minified browser and fresh SSR proof. Defaults,
475
+ rest/array patterns and direct item/index write targets still diagnose;
476
+ transitions and hydration remain open.
477
+
478
+ Plain modern/legacy module scripts preserve module-once execution and named
479
+ exports. Bounded module runes now support state/raw state, snapshots and private
480
+ derived values. Stable exported state is the actual value/proxy; reassigned
481
+ state exports and derived exports reject. Module state persists across SSR
482
+ requests; module derived reads recompute while component derived values cache.
483
+ Module async/generator factories preserve rune creation-time ownership and caching.
484
+ Instance scripts and companion factories keep their placement restrictions.
485
+ The permanent gate covers 784 modules using frozen combined compiler
486
+ `ae8c6f6f`,
487
+ including shared module-rune state, snapshots, export identity, lifetime and SSR
488
+ cache behavior, bounded action/attachment source behavior and eight SSR prop-order
489
+ cases plus finite Vue defaults, explicit Solid source and authored await blocks. All 778 emitted TypeScript modules pass both strict checkers,
490
+ with no type exceptions. Await alias `typeof` queries have bounded source proof,
491
+ including qualified queries, nested defaults and annotations; invalid value-as-type
492
+ uses still fail both strict checkers.
493
+
494
+ The optional `/each` compiler entry reuses native insertion ranges and owners.
495
+ Duplicate or unstable keys diagnose and provisional roots always clean up;
496
+ reference production failure leaks are deliberately not reproduced. Cleanup
497
+ continues through sibling errors. With frozen compiler `c2ae808e` and the
498
+ invalidation/demand runtime, the unchanged authored SFC counter measures
499
+ 34,650 raw / 12,683 gzip9 / 11,482 Brotli11 bytes versus the production
500
+ reference's 46,617 / 17,344 / 15,628. Correct derived overrides and equal-value
501
+ effect suppression add 1,386 browser gzip bytes; SSR gzip stays at 4,361 bytes.
502
+ The signal-only core is 4,041 raw bytes, up 243 raw / 86 gzip bytes from the
503
+ previous runtime. Native full-row list updates are slower in the measured workload;
504
+ smaller output does not establish a speed advantage.
505
+
506
+ A derived value first read after its component stops computes once from current
507
+ inputs, then freezes without subscribing. Failed computations keep and rethrow
508
+ the original error; dependency writes and newly attached owned work still reject.
509
+ This preserves native error/override policies rather than claiming exact Svelte
510
+ behavior for those cases.
511
+
512
+ Authored styles containing only explicit `:global(selector)` rules or a
513
+ `:global { ... }` block now compile to inventoried external CSS assets. Browser
514
+ checks cover scriptless and stateful components, outside matching elements,
515
+ independent instances, retained input edits/focus and disposal. No runtime style
516
+ injector is used, and ordinary counter output stays byte-identical.
517
+
518
+ Bounded local rules now scope authored intrinsic selector participants, including
519
+ ordinary compounds/combinators and global prefixes/suffixes. Sixteen state
520
+ predicates and before/after pseudo elements retain scope across hover, focus,
521
+ checked and disabled changes; unrelated elements and opaque child/raw HTML
522
+ boundaries remain untouched. Generated CSS is external, with matching DOM/SSR
523
+ hashes. Prefix matching memoizes selector/node states to avoid exponential
524
+ ancestor-path enumeration.
525
+
526
+ Bounded first/last/only child and of-type selectors, `:empty`, and four nth
527
+ selectors are supported. Nth arguments remain unscoped, including foreign
528
+ siblings. Other functional selectors, at-rules/keyframes, complex global placement,
529
+ preprocessing, external references, escapes, spreads and uncertain relational
530
+ branch/slot cases remain unsupported. The optional compiler uses the MIT Raffia
531
+ parser; no browser dependency is added. Its safety guard rejects more than 256
532
+ opening delimiters, including those in literals/comments. Full scoped CSS and
533
+ unused-selector diagnostics remain open.
534
+
535
+ Public instance rune fields now compile through Crepus: state/raw/derived/by,
536
+ including typed and zero-argument state fields. Bounded source checks cover
537
+ inheritance, initialization order, nonenumerable DOM accessors, ordinary SSR
538
+ state fields, callable receivers, independent instances and disposal. Private
539
+ identifier-keyed instance state/raw/derived initializers also have browser/SSR
540
+ source proof. Full constructor coverage remains open, including JavaScript SFC computed members.
541
+ Static fields and cast-wrapped state assignments with top-level await/yield
542
+ remain unsupported; full class compatibility is unfinished.
543
+
544
+ The compiler-facing `/runes` entry also exports private-field state/raw cells.
545
+ They reuse native state/history, expose historical tracked `value` and live
546
+ untracked `peek()`, and deep `assign()` returns its resolved proxy before feedback
547
+ or disposal can replace the current value. These runtime contracts have focused
548
+ behavior/type tests and bounded private-class source acceptance in the shared
549
+ shared source gate.
550
+
551
+ The optional `/mount` entry freshly mounts compiler-marked native SFC factories and returns their synchronous typed exports. It supports owned teardown, target-local anchors and copied root contexts; `/server-mount` rejects client mounting on the server. Hydration, transitions/outros, legacy event options and error transforms remain unsupported and reject explicitly. Both boolean `intro` values are accepted for sources without transitions. The erased `ComponentView<View, Exports, Props>` return metadata and `ComponentFactory<Implementation>` callable type preserve required/optional props and export types. Generated public functions must also preserve ESM hoisting. Public mounting checks metadata props rather than an implementation parameter typed `any`. The standalone `scripts/check-native-svelte-mount.ts --compiler <path>` source check verifies 28 generated modules with frozen compiler `703ceb65`: unchanged authored launchers, typed synchronous exports, two independent instances, anchor/context/cleanup behavior, DOM-free server imports and real Bun/Node ESM cycles. The combined await/source gate currently uses a separate compiler snapshot; merging those compiler lineages remains open. Declaration emission for setup-local interfaces is also unfinished.
552
+
553
+ `readonly(store)` exposes only a bound `subscribe`, preserving custom store
554
+ receivers, invalidators and cleanup. Writes through the original store still
555
+ notify its subscribers. This facade does not freeze stored values. `toStore(get,
556
+ set?)` bridges reactive state into a `Readable` or `Writable` store with eager
557
+ initial evaluation, post-order Rune effect scheduling on the client, independent
558
+ root survival across component disposal while subscribers remain active, and
559
+ one-shot `writable(get())` behavior on SSR. `fromStore(store)` bridges a
560
+ `Readable` or `Writable` store (or `{ subscribe }` observable) into a `{ current }`
561
+ reactive wrapper, sharing one store subscription across tracked readers and
562
+ derived chains on the client, releasing after a microtask when demand drops to
563
+ zero, and reading via `get(store)` outside tracking or on SSR. Authored
564
+ `svelte/store` named imports, aliases and re-exports of `readonly`, `toStore`
565
+ and `fromStore` are admitted by the locally verified Crepus compiler for DOM and
566
+ SSR. That compiler change is not published yet; the direct Moonshine `/store`
567
+ API is available independently.
568
+
569
+ The optional `/binding` entry re-exports native `bindFiles` for independent
570
+ file-input factories. Nullish models preserve selected files; clearing requires
571
+ an empty `FileList`. Change and connected-form reset write the current list.
572
+ Disposal removes listeners, including on retained detached inputs; Svelte's
573
+ reference can still update its model from those saved elements. The locally
574
+ verified Crepus compiler lowers authored `bind:files` on static file inputs with
575
+ identifier/member targets, including keyed rows. SSR omits the value without
576
+ reading it and retains unreachable checks for typed assignments/change handlers.
577
+ Function bindings, dynamic input types, spreads and hydration remain unsupported.
578
+ This compiler change is unpublished and requires the `bindFiles` runtime from
579
+ Moonshine 0.4.13 or newer.
580
+
581
+ The locally verified Crepus compiler also lowers `bind:open` on static HTML
582
+ `<details>` elements through the existing independent `bindOpen` helper. Shorthand,
583
+ state/prop identifiers, member targets, writable stores, keyed rows and imported
584
+ child bindings have DOM/SSR source coverage. User `ontoggle` handlers run before
585
+ the binding write, and member-based handlers are read at dispatch. SSR snapshots
586
+ the boolean `open` attribute without installing listeners or running handlers.
587
+ Nullish state closes the element without adopting its DOM state.
588
+
589
+ This compiler work remains unpublished. Function-pair targets, dynamic elements,
590
+ other element types, duplicate bindings and conflicting `open` attributes reject.
591
+ Native owner cleanup removes listeners even from saved detached nodes; the
592
+ Svelte 5.57.1 reference retains them. This is bounded authored-source support,
593
+ without hydration or Svelte's compiled component ABI. Set
594
+ `MOONSHINE_CREPUS_COMPILER` to the local compiler to enable the isolated source
595
+ regression in `test/standalone.test.ts`.