-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1742 lines (908 loc) · 79.4 KB
/
Copy pathindex.html
File metadata and controls
1742 lines (908 loc) · 79.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Home</h1>
<h3> </h3>
<section>
<article><p><img src="https://raw.githubusercontent.com/Avenx-JS/.github/refs/heads/main/media/core-header.jpeg" alt="Avenx Header"></p>
<h1>🚀 Avenx-JS</h1>
<p><strong>Avenx-JS</strong> is a lightweight, experimental frontend framework designed for simplicity and performance. It features a custom compiler-driven component system, Proxy-based reactivity, scoped CSS, and powerful CLI tooling—all with zero runtime dependencies.</p>
<hr>
<h2>✨ Why Avenx?</h2>
<p>Modern frontend development often requires complex build chains and heavy runtime libraries. Avenx explores a different path by providing:</p>
<ul>
<li><strong>⚡ Zero Boilerplate:</strong> Logic, state, and template in a single unified component file.</li>
<li><strong>🔄 Transparent Reactivity:</strong> Automatic UI updates via JavaScript Proxies without manual <code>setState</code> or <code>ref</code> calls.</li>
<li><strong>🎨 Scoped Styling:</strong> CSS is automatically scoped to your component using hashed class generation.</li>
<li><strong>🛠️ Integrated Tooling:</strong> A built-in CLI handles project scaffolding, component generation, and development servers.</li>
<li><strong>📦 Lightweight Core:</strong> Minimal runtime footprint for fast loading and execution.</li>
<li><strong>🗺️ Compiler Semantic Model:</strong> Ask the compiler what depends on a piece of state, before you change it.</li>
<li><strong>🔍 Causal Tracing:</strong> Record why your app did what it did, then export that recording as a regression test.</li>
<li><strong>↩️ Atomic Actions:</strong> Mark an action <code>atomic</code> and every state write it makes is undone if it fails.</li>
</ul>
<hr>
<h2>⚡ Key Features</h2>
<h3>🔄 Proxy-based Reactivity</h3>
<p>State management is built directly into the core. Changing a property on the <code>state</code> object automatically updates the DOM that reads it.</p>
<h3>⚙️ Compiled Rendering</h3>
<p>The compiler turns a template into a <strong>render program</strong>: a static HTML skeleton
plus one binding operation per dynamic part. The skeleton is parsed once per
component class; each binding becomes its own reactive effect. A state change
wakes the bindings that read it and writes to their nodes — nothing is
serialised, reparsed or diffed.</p>
<p>The cost of an update is therefore proportional to the change rather than to the
template. Changing one text binding, measured in happy-dom:</p>
<table>
<thead>
<tr>
<th style="text-align:right">Bindings in the component</th>
<th style="text-align:right">Before</th>
<th style="text-align:right">After</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">10</td>
<td style="text-align:right">0.371 ms</td>
<td style="text-align:right">0.015 ms</td>
</tr>
<tr>
<td style="text-align:right">500</td>
<td style="text-align:right">16.758 ms</td>
<td style="text-align:right">0.019 ms</td>
</tr>
<tr>
<td style="text-align:right">1500</td>
<td style="text-align:right">161.018 ms</td>
<td style="text-align:right">0.050 ms</td>
</tr>
</tbody>
</table>
<p>The compiler reads the template through a typed <strong>intermediate representation</strong>,
so <code><@if></code>, <code><@for></code>, <code><slot></code>, <code><@defer></code> and component tags arrive at the
backend as the constructs they are rather than as markup a previous pass rewrote
them into. Control flow compiles to a <strong>block</strong>: a skeleton parsed once for the
life of the page and cloned per arm or per row, reconciled by key.</p>
<p>A template using a construct the IR does not model yet — a suspense or error
boundary, a deadlock boundary, a transition, a template ref — renders through
the previous string renderer instead, and <code>avenx build</code> says which and why
(<code>AVX_W47</code>). There is no partial mode: a template is compiled entirely or not at
all.</p>
<p>That renderer is only linked into a bundle when something in the build needs it,
so an application whose every template compiles does not carry it. Measured on a
scaffolded hello-world, production build: <strong>366,780 → 320,431 bytes raw,
82,654 → 72,636 gzipped</strong>, with <code><@if></code>, compiled lists, compiled slots and
compiled <code><@defer></code> added over the same period.</p>
<p>A keyed list update, measured against the same component on both paths
(<code>benches/list-rendering.bench.js</code>, happy-dom — ratios, not milliseconds):</p>
<table>
<thead>
<tr>
<th style="text-align:right">Rows</th>
<th style="text-align:right">Rename one</th>
<th style="text-align:right">Move one</th>
<th style="text-align:right">Append one</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:right">20</td>
<td style="text-align:right">8.0x</td>
<td style="text-align:right">4.1x</td>
<td style="text-align:right">8.6x</td>
</tr>
<tr>
<td style="text-align:right">100</td>
<td style="text-align:right">8.5x</td>
<td style="text-align:right">4.6x</td>
<td style="text-align:right">9.1x</td>
</tr>
<tr>
<td style="text-align:right">500</td>
<td style="text-align:right">6.0x</td>
<td style="text-align:right">3.4x</td>
<td style="text-align:right">6.3x</td>
</tr>
</tbody>
</table>
<p>See the <a href="docs/src/content/docs/core-concepts/rendering.md">rendering guide</a>.</p>
<h3>🔒 Compiled Expressions — no <code>eval</code>, no <code>new Function</code></h3>
<p>Every template interpolation, computed value, directive binding, inline handler
and <code><action></code> body is compiled to an ordinary JavaScript function <strong>at build
time</strong> and linked into the bundle, so the browser's own engine compiles it.</p>
<pre class="prettyprint source lang-text"><code>count * 2 -> ($s) => (axGet($s, "count") * 2)
if (!text) { return; } -> ($s) => { if (!axGet($s, "text")) { return; } … }
</code></pre>
<p>A production bundle contains no <code>eval</code>, no <code>new Function</code> and no <code>with</code>, so it
runs under <code>script-src 'self'</code> — checked on the emitted bundle by the test
suite, not asserted here. Earlier versions shipped this code as <strong>source text</strong>
and interpreted it in the browser, which put a JavaScript parser and a
tree-walking evaluator in every bundle and still fell back to <code>new Function</code> for
any action using <code>if</code>, <code>for</code>, <code>try</code> or a declaration.</p>
<p>The security checks did not move, they are only called rather than interpreted:
a member read still passes the key already resolved through one gate, so
<code>x['const'+'ructor']</code> and <code>x.constructor</code> meet the same check. Two checks moved
<em>earlier</em> — naming a restricted global, or writing <code>__proto__</code> / <code>constructor</code> /
<code>prototype</code>, now fails the build with a file and a line.</p>
<p>A development build still carries the interpreter, so a template you are editing
keeps rendering; <code>AVX_W48</code> names anything the compiler could not compile.</p>
<p>See the <a href="docs/src/content/docs/core-concepts/template-expressions.md">template expressions guide</a>
and the <a href="docs/src/content/docs/guides/deployment.md">deployment guide</a>.</p>
<h3>🔀 Conditional Rendering (<code><@if></code>)</h3>
<pre class="prettyprint source lang-html"><code><@if user.isAdmin>
<AdminPanel />
<@elseif user.isMember>
<p>Welcome back, {{ user.name }}.</p>
<@else>
<a href="/signup">Create an account</a>
</@if>
</code></pre>
<p>Each arm is its own compiled block, so switching arms is the only thing that
rebuilds DOM — an update that leaves the same arm selected touches nothing, and
focus, selection and scroll position inside the branch survive.</p>
<p>Bracket a top-level comparison: <code><@if (count > 3)></code>, not <code><@if count > 3></code>. The
<code>></code> that means "greater than" and the <code>></code> that ends the tag are the same
character, so the compiler refuses the ambiguous form and names the one that
works rather than silently testing <code>count</code>.</p>
<h3>🧩 Declarative Components</h3>
<p>Define your UI using standard HTML with added superpowers. Components support <code>state</code>, <code>computed</code> properties, and <code>actions</code> (methods) defined directly in the <code>.component.js</code> file.</p>
<h3>🎨 Intelligent Scoped CSS</h3>
<p>Styles defined in <code>.component.css</code> are automatically scoped to that specific component. Use the <code><@global></code> tag for global variables and the <code><@css></code> tag for component-specific styles.</p>
<h3>🌐 Bridges (Shared State)</h3>
<p>Shared state lives in <strong>Bridges</strong> — small modules created with <code>bridge()</code> and consumed by importing them. Because the import is the connection, the compiler can see every consumer: it drops unused bridges from the bundle and catches mistyped members before you run the app.</p>
<h3>🌊 Declarative Async Data, Suspense & Error Boundaries</h3>
<p>Fetch data seamlessly with <code><resource></code> declarations and handle loading & error states declaratively using <code><@suspense></code> and <code><@errorBoundary></code>:</p>
<pre class="prettyprint source lang-html"><code><resource name="users">
return fetch('/api/users').then(res => res.json());
</resource>
<@errorBoundary>
<@fallback as="err">
<div class="error">Failed to load users: {{ err.message }}</div>
</@fallback>
<@suspense>
<@fallback>
<div class="loading">Loading user list...</div>
</@fallback>
<div class="user-list">
<@for user in users>
<p>{{ user.username }}</p>
</@for>
</div>
</@suspense>
</@errorBoundary>
</code></pre>
<h3>🛡️ Reactive Deadlock Boundary (<code><@deadlock></code>)</h3>
<p>Define a named fallback boundary for reactive-cycle recovery:</p>
<pre class="prettyprint source lang-html"><code><@deadlock name="dashboard-boundary">
<Sidebar />
<Content />
<Stats />
<@fallback as="err">
<div class="deadlock-alert">
⚠️ Reactive cycle intercepted in {{ name }}: {{ err.message }}
</div>
</@fallback>
</@deadlock>
</code></pre>
<ul>
<li><strong>Global Detection:</strong> Scheduler and watcher guards stop runaway reactive work and log <code>AVX_R18</code> diagnostics.</li>
<li><strong>Manual Recovery:</strong> Call <code>$tripDeadlockBoundary('dashboard-boundary', error)</code> to replace that boundary's active content with its fallback.</li>
<li><strong>Explicit Integration:</strong> Use <code>onSchedulerDeadlock()</code> when you want to connect global scheduler detection to a particular component boundary.</li>
</ul>
<p>Detection does not automatically trip the nearest boundary. The compiled <code>maxDepth</code>, <code>action</code>, and <code>isolated</code> attributes are currently metadata rather than active per-boundary controls. See the <a href="docs/src/content/docs/core-concepts/deadlock.md">reactive deadlock boundary guide</a> for current behavior and limitations.</p>
<h3>↩️ Avenx Rewind — an optimistic update that undoes itself</h3>
<p>Mark an action <code>atomic</code> and every state write it makes is journaled. If the
action throws, or returns a promise that rejects, the journal is played
backwards and the state is what it was before the action ran.</p>
<pre class="prettyprint source lang-html"><code><action name="incQty" atomic>
busy = true; cart.addQty(props.id, 1);
<!-- writes bridge state, through a bridge action -->
return api.setQty(props.id, qty);
<!-- if this rejects, none of the above stands -->
</action>
</code></pre>
<p>No <code>catch</code>, no snapshot, no inverse. Component state, bridge state, nested
properties, array and <code>Map</code>/<code>Set</code> mutations, and keys the action created or
deleted all come back — and because the restore goes through the same reactive
machinery as an ordinary write, the DOM corrects itself.</p>
<p>Every framework can be made to do that much with a library. What a library
cannot do is tell you, at build time, <strong>which of the action's effects a rewind
will not undo</strong>:</p>
<pre class="prettyprint source lang-text"><code>[AVX_W43] session.save is atomic, but 2 effect(s) cannot be rewound:
storage localStorage.setItem( src/bridges/session.bridge.js:14
emit emit('saved' src/bridges/session.bridge.js:15
[AVX_W44] PostCard.like and PostCard.unlike are both atomic and both write
PostCard.likes — if they can be in flight at once, a rewind may find a value
it did not write.
[AVX_W42] cart.setField is atomic, but its write set could not be resolved
completely: dynamic-member "item[field]".
</code></pre>
<p>That last one is the house rule again: Avenx reports where its own analysis was
incomplete rather than concluding from it. The rewind is unaffected — the
journal watches the reactive proxies, not the prediction — but the two warnings
above it are not to be trusted for that action.</p>
<p>Two optimistic updates racing on the same value is the case naive rollback gets
wrong. The default <code>safe</code> policy restores a path only if the value there is
still the one the transaction wrote, so the second click's increment survives
the first click's rollback, and the conflict is reported rather than hidden.</p>
<p>With no transaction open, a write costs one boolean read — the same guard shape
tracing uses. Measured over 100,000 writes: 89.24 ms idle, 89.89 ms inside a
transaction.</p>
<p>See the <a href="docs/src/content/docs/core-concepts/rewind.md">Avenx Rewind guide</a>.</p>
<h3>🗺️ Avenx Atlas — ask the compiler what breaks before you break it</h3>
<p>The compiler keeps a semantic model of your whole application: components,
pages, bridges, <strong>individual state keys</strong>, computed values, actions, resources,
template bindings, event handlers, routes and guards — and the relationships
between them.</p>
<pre class="prettyprint source lang-bash"><code>npx avenx atlas # what is in this application
npx avenx impact cart.items # what can be affected if this changes
npx avenx why cart.total # where this value comes from
</code></pre>
<pre class="prettyprint source lang-text"><code>What depends on: cart.items
state src/bridges/cart.bridge.js:5
├─ reads cart.total .reduce src/bridges/cart.bridge.js:10
│ ├─ reads CartSummary {{ }} "cart.total" src/components/cart-summary/cart-summary.component.js:14
│ └─ reads Checkout {{ }} "cart.total" src/pages/checkout.page.js:7
│ └─ declares Checkout src/pages/checkout.page.js
│ └─ routes-to /checkout src/main.app.js:9
├─ reads CartList <@for> "cart.items" src/components/cart-list/cart-list.component.js:9
├─ reads CartList {{ }} "item.qty" .[].qty src/components/cart-list/cart-list.component.js:10
└─ writes cart.addQty .[].qty [possible] src/bridges/cart.bridge.js:23
└─ invokes CartItem.incQty src/components/cart-item/cart-item.component.js:7
└─ invokes CartItem @click="incQty()" src/components/cart-item/cart-item.component.js:19
0 unresolved relationships in this answer.
</code></pre>
<p>This is a <strong>data-flow</strong> map, not a module graph. The loop variable inside
<code><@for item in cart.items></code> resolves back to the state it iterates, so
<code>{{ item.qty }}</code> is reported as a read of <code>cart.items[].qty</code>.</p>
<p>Every edge declares how much to trust it — <code>certain</code> when it follows from a
declaration, <code>possible</code> when it does not — and everything the analyser could
<strong>not</strong> follow is listed with its reason and location rather than silently
dropped. Every answer prints that count, including when it is zero. An
uncertain answer is better than a confidently wrong one.</p>
<p>Two diagnostics fall out of the model, and both refuse to fire when the
analysis behind them was incomplete:</p>
<pre class="prettyprint source lang-text"><code>[AVX_W40] cart.discount is written by cart.applyCoupon but read nowhere.
[AVX_W41] CartSummary.neverCalled is never invoked from a template, action or guard.
</code></pre>
<p>Atlas is <strong>compile-time only</strong>. <code>avenx build</code> writes <code>dist/bundle.atlas.json</code>
beside the bundle and never references it, so the runtime is byte-for-byte
unchanged.</p>
<p>Atlas and <a href="docs/src/content/docs/core-concepts/trace.md">Trace</a> are two sides of
one model: <strong>Atlas is what can happen, Trace is what did.</strong> A test in this
repository checks that every causal step in a recorded trace corresponds to an
edge Atlas predicted.</p>
<p>See the <a href="docs/src/content/docs/core-concepts/atlas.md">Avenx Atlas guide</a>.</p>
<h3>🔍 Avenx Trace — reproduce a bug once, get a test forever</h3>
<p>Avenx records <strong>why</strong> your application did what it did — the click, the action,
the bridge mutation, the state write, the watchers that woke, the DOM nodes that
changed — and turns that recording into an executable regression test.</p>
<pre class="prettyprint source lang-bash"><code>npx avenx serve --trace # reproduce the bug in the browser
npx avenx trace view latest # read why it happened
npx avenx trace export latest --out test/cart-qty.test.js
</code></pre>
<pre class="prettyprint source lang-text"><code>▸ click <button.qty-inc> CartItem
└─ action CartItem.incQty() src/components/cart-item/cart-item.component.js:3
└─ bridge cart · addQty("a", 1)
├─ write cart.items.0.qty 2 → 3
│ ├─ woke CartItem#render
│ │ └─ patched <span.qty> text "2" → "3"
│ └─ woke CartSummary#render
│ ├─ getter cart.total 36 → 48
│ └─ patched <strong.total> text "$36.00" → "$48.00"
└─ emit cart:changed → 0 listeners
Determinism: deterministic — this trace can be exported as a regression test.
</code></pre>
<p>The exported test replays the recorded inputs through the real framework and
compares <strong>every</strong> state and DOM change against the recording. When the code
regresses you get the cause, not a bare mismatch:</p>
<pre class="prettyprint source lang-text"><code>Step 1 (click <button.qty-inc>) diverged at position 1:
recorded: write count 0 -> 1
replayed: write count 0 -> 2
</code></pre>
<p>Avenx can do this because every identifier an expression resolves — including
<code>Date</code> and <code>Math</code> — passes through <strong>one substitution point</strong>, every state write
through one Proxy trap, and every DOM change through one patcher. That is what
lets a recorded session be replayed deterministically.</p>
<p>Expressions and action bodies are compiled to closures at build time, and that
costs Trace nothing: a compiled expression naming <code>Date</code> emits a call to the
same resolver the recorder substitutes. What compiling removes is the parser and
the tree-walking evaluator from your production bundle, neither of which the
recorder needed.</p>
<p>Recording is off by default and never reaches a production build — with tracing
off, each instrumented site is a single boolean check. Determinism is <strong>verified
by replay</strong>, not claimed by the recorder: a trace that says it is reproducible
and is not fails loudly rather than passing for the wrong reason.</p>
<p>Configure redaction so a trace never captures what it should not:</p>
<pre class="prettyprint source lang-json"><code>{ "trace": { "redact": ["auth.token", "user.*", "*.password"] } }
</code></pre>
<p>See the <a href="docs/src/content/docs/core-concepts/trace.md">Avenx Trace guide</a>.</p>
<h3>🛠️ CLI-First Workflow</h3>
<p>Generate components, pages, and bridges with a single command. The built-in dev server provides hot-reloading for a seamless development experience.</p>
<h3>📦 Production Builds</h3>
<p><code>avenx build</code> compiles your components to ES modules and links them with Avenx's own bundler. The runtime is an ordinary dependency in that graph, resolved through <code>avenx-core/runtime</code> — not a prebuilt file prepended to your application.</p>
<p>That means your imports are <strong>resolved, not rewritten</strong>: npm packages work from components, pages, bridges and guards, ES and CommonJS alike; local modules resolve by path, by extension-less path or through a directory index; and an import that names nothing <strong>fails the build</strong> with the specifier and the file that asked for it. Nothing is ever dropped silently.</p>
<p>It also means the build can leave things out. A module ships when something reaches it, so a production bundle does not carry the trace recorder — nothing in it can start a recording. A development build does, which is what <code>avenx serve --trace</code> uses. Testing helpers live behind <code>avenx-core/testing</code> and the ESLint tooling behind <code>avenx-core/tooling</code>, so neither can reach an application bundle, and an import of a Node built-in is a build error rather than a shim.</p>
<p>The bundle publishes <code>globalThis.Avenx</code> plus seven named globals for compatibility. Everything else is reached by importing it, because importing now works.</p>
<p>See the <a href="docs/src/content/docs/guides/deployment.md">deployment guide</a>.</p>
<hr>
<h2>🚀 Quick Start</h2>
<h3>Installation</h3>
<pre class="prettyprint source lang-bash"><code>npm install avenx-core
</code></pre>
<h3>Scaffolding a Project</h3>
<pre class="prettyprint source lang-bash"><code># Initialize project structure
npx avenx init
# Create a new component
npx avenx g counter
# Start development server
npx avenx serve
# Build for production
npx avenx build
</code></pre>
<p>Your app will be running at <code>http://localhost:3000</code>.</p>
<hr>
<h2>🧠 Core Concepts & Syntax</h2>
<h3>1. Component Structure</h3>
<p>An Avenx component consists of two files: <code><name>.component.js</code> and <code><name>.component.css</code>.</p>
<h4>JavaScript (<code>.component.js</code>)</h4>
<pre class="prettyprint source lang-html"><code><state count="0" title="Counter" />
<computed name="doubleCount" value="count * 2" />
<action name="increment"> state.count++; </action>
<div @css card>
<h1>{{ title }}</h1>
<p>Count: {{ count }} (Double: {{ doubleCount }})</p>
<button @css button @click="increment()">Increment</button>
</div>
</code></pre>
<h4>CSS (<code>.component.css</code>)</h4>
<pre class="prettyprint source lang-css"><code><@global>
@def primary-color #646cff;
@def bg-color #242424;
</@global>
<@css>
card {
padding: 2rem;
border-radius: 8px;
background: @bg-color;
}
button {
background-color: @primary-color;
color: white;
border: none;
padding: 0.6em 1.2em;
cursor: pointer;
}
</@css>
</code></pre>
<h3>2. Bridges (Shared State)</h3>
<p>A <strong>Bridge</strong> holds state that several components need, plus the actions that change it. You create one with <code>bridge()</code> and use it by importing it.</p>
<h4>Creation</h4>
<pre class="prettyprint source lang-bash"><code>npx avenx g bridge auth
</code></pre>
<h4>Definition (<code>src/global/auth.bridge.js</code>)</h4>
<pre class="prettyprint source lang-javascript"><code>import { bridge } from 'avenx-core/runtime';
export default bridge({
state: {
user: null,
status: 'anonymous',
},
get displayName() {
return this.user ? this.user.name : 'Guest';
},
login(user) {
this.user = user;
this.status = 'authenticated';
this.emit('login', user);
},
});
</code></pre>
<h4>Usage in Component</h4>
<p>Import the bridge, then read it straight from the template. Reads are tracked, so the component re-renders when the data it uses changes — no subscription to write, and none to clean up.</p>
<pre class="prettyprint source lang-html"><code>import auth from '../global/auth.bridge.js';
<p>Welcome, {{ auth.displayName }}</p>
<action name="signIn"> auth.login({ name: 'John Doe' }); </action>
</code></pre>
<p>Because a bridge is reached through an import, the compiler knows exactly which components use it: unused bridges are left out of the bundle, mistyped members and unknown event names are reported at build time, and the whole surface is typed in TypeScript. State is read-only outside the bridge, so every mutation has one traceable origin.</p>
<hr>
<h3>3. Pages & Routing</h3>
<p>Pages are special components designed for top-level routing. They reside in <code>src/pages/</code>.</p>
<h4>Creation</h4>
<pre class="prettyprint source lang-bash"><code>npx avenx g page profile
</code></pre>
<h4>Definition (<code>src/pages/profile.page.js</code>)</h4>
<p>Pages use the same syntax as components (<code><state></code>, <code><computed></code>, <code><action></code>).</p>
<pre class="prettyprint source lang-html"><code><state userId="123" />
<div class="profile-page">
<h1>User Profile</h1>
<p>Viewing ID: {{ userId }}</p>
</div>
</code></pre>
<h4>Routing (<code>src/main.app.js</code>)</h4>
<p>Avenx-JS projects built with the CLI automatically scan, compile, and register page components. In your main application entry point, you initialize the built-in router with the route mappings:</p>
<pre class="prettyprint source lang-javascript"><code>import { AvenxApp } from 'avenx-core/runtime';
const app = new AvenxApp({ target: '#app' });
// Initialize the router mapping paths to page component names.
// Note: Pages inside src/pages/ are automatically registered by the compiler.
app.initRouter({
'': 'Home',
'#/': 'Home',
'#/profile/:userId': 'Profile',
});
</code></pre>
<hr>
<h3>4. Nesting Components</h3>
<p>Components can be nested by using their name in PascalCase. Use <code><slot /></code> tags to define where transcluded child content should render:</p>
<pre class="prettyprint source lang-html"><code><Navbar />
<main>
<Sidebar />
<slot />
</main>
</code></pre>
<h3>5. Events</h3>
<p>Use the <code>@</code> prefix to bind event listeners:</p>
<pre class="prettyprint source lang-html"><code><button @click="count++">Inline Action</button> <input @input="state.text = event.target.value" />
</code></pre>
<h3>6. CSS Preprocessors (Sass, SCSS, PostCSS, Less)</h3>
<p>Avenx-JS supports Sass/SCSS, PostCSS, and Less preprocessors inside <code>.component.css</code> or <code>.page.css</code> files.</p>
<p>To enable a preprocessor, add the <code>style</code> settings to your <code>avenx.config.json</code> file:</p>
<pre class="prettyprint source lang-json"><code>{
"style": {
"preprocessor": "scss"
}
}
</code></pre>
<p>Available preprocessor options are <code>"sass"</code>, <code>"scss"</code>, <code>"postcss"</code>, and <code>"less"</code>.</p>
<p>When a preprocessor is enabled:</p>
<ul>
<li>You can write nested SCSS/Sass styles, variables, functions, and mixins directly inside your stylesheet.</li>
<li>The compiler will automatically run your styles through the preprocessor module before applying Avenx-JS scoping logic.</li>
<li>If the configured preprocessor package (e.g. <code>sass</code>) is not installed, the compiler gracefully falls back to raw CSS processing and logs a warning.</li>
</ul>
<hr>
<h2>📁 Project Structure</h2>
<p>A typical Avenx project looks like this:</p>
<pre class="prettyprint source lang-text"><code>my-avenx-app/
├── src/
│ ├── components/ # UI Components
│ │ └── counter/
│ │ ├── counter.component.js
│ │ └── counter.component.css
│ ├── pages/ # Application Pages (Routed)
│ ├── global/ # Shared Bridges & Styles
│ └── main.app.js # App entry point & registration
├── dist/ # Compiled bundle (generated)
├── index.html # Main entry HTML
└── package.json
</code></pre>
<hr>
<h2>🛠️ CLI Reference</h2>
<table>
<thead>
<tr>
<th style="text-align:left">Command</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>avenx init</code></td>
<td style="text-align:left">Scaffolds a new project structure.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx g <name></code></td>
<td style="text-align:left">Generates a new component (alias: <code>generate</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx g p <name></code></td>
<td style="text-align:left">Generates a new page for routing (alias: <code>g page</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx g bridge <name></code></td>
<td style="text-align:left">Generates a new shared reactive bridge.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx g guard <name></code></td>
<td style="text-align:left">Generates a new route guard.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx d <name></code></td>
<td style="text-align:left">Deletes a component (alias: <code>destroy</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx d p <name></code></td>
<td style="text-align:left">Deletes a page (alias: <code>d page</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx d bridge <name></code></td>
<td style="text-align:left">Deletes a shared reactive bridge.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx d guard <name></code></td>
<td style="text-align:left">Deletes a route guard.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx build</code> (or <code>b</code>)</td>
<td style="text-align:left">Compiles the project into <code>dist/</code>.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx clean</code></td>
<td style="text-align:left">Clears build output directory.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx check</code> (or <code>lint</code>)</td>
<td style="text-align:left">Validates component templates without building.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx doctor</code></td>
<td style="text-align:left">Runs environment and project health diagnostics.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx serve [port]</code></td>
<td style="text-align:left">Starts the dev server with hot-reload (default: 3000).</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx atlas</code></td>
<td style="text-align:left">Prints the compiler's semantic map of the application.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx impact <symbol></code></td>
<td style="text-align:left">What can be affected if this symbol changes.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx why <symbol></code></td>
<td style="text-align:left">Where this symbol's value comes from.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx trace list</code></td>
<td style="text-align:left">Lists recorded causal traces.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx trace view <id></code></td>
<td style="text-align:left">Prints a trace as a causal tree.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx trace export <id></code></td>
<td style="text-align:left">Turns a recorded trace into a regression test.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx trace prune</code></td>
<td style="text-align:left">Removes stored traces.</td>
</tr>
<tr>
<td style="text-align:left"><code>avenx watch</code> (or <code>w</code>)</td>
<td style="text-align:left">Watch for file changes and rebuild automatically.</td>
</tr>
</tbody>
</table>
<h3>Options</h3>
<table>
<thead>
<tr>
<th style="text-align:left">Option</th>
<th style="text-align:left">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left"><code>--dry-run</code>, <code>-d</code></td>
<td style="text-align:left">Preview actions for generators and destructors without writing/deleting files.</td>
</tr>
<tr>
<td style="text-align:left"><code>--port</code>, <code>-p <port></code></td>
<td style="text-align:left">Configure the port for the development server.</td>
</tr>
<tr>
<td style="text-align:left"><code>--host</code>, <code>-h <host></code></td>
<td style="text-align:left">Configure the host for the development server (default: <code>localhost</code>).</td>
</tr>
<tr>
<td style="text-align:left"><code>--trace</code></td>
<td style="text-align:left">Record a causal trace while serving. Development only, off by default.</td>
</tr>
<tr>
<td style="text-align:left"><code>--out</code>, <code>-o <file></code></td>
<td style="text-align:left">Where <code>trace export</code> writes the generated regression test.</td>
</tr>
<tr>
<td style="text-align:left"><code>--json</code>, <code>-j</code></td>
<td style="text-align:left">Machine-readable output for <code>check</code>, <code>atlas</code>, <code>impact</code> and <code>why</code>.</td>
</tr>
<tr>
<td style="text-align:left"><code>--depth=<n></code></td>
<td style="text-align:left">How many hops <code>impact</code> and <code>why</code> follow (default: 12).</td>
</tr>
</tbody>
</table>
<hr>
<h2>🧪 Testing</h2>
<p>Avenx-JS provides comprehensive testing support, from fast unit tests to full browser E2E test suites:</p>
<ul>
<li><strong>Unit Tests:</strong> <code>npm run test:unit</code></li>
<li><strong>Integration Tests:</strong> <code>npm run test:integration</code></li>
<li><strong>System Benchmarks & CLI Tests:</strong> <code>npm run test:system</code></li>
<li><strong>Playwright End-to-End (E2E) Browser Tests:</strong> <code>npm run test:e2e</code></li>
<li><strong>Full Test Suite:</strong> <code>npm test</code></li>
</ul>
<p>The E2E suite compiles real Avenx applications with the CLI and drives the compiled bundle in a browser, so a test cannot pass unless the compiler and runtime both ran. Every pull request runs it on <strong>Chromium</strong>; <strong>Firefox</strong> and <strong>WebKit</strong> run nightly.</p>
<p>See <a href="test/e2e/README.md">test/e2e/README.md</a> for the fixture-app layout, the conventions, what belongs in E2E rather than unit tests, and the framework gaps the suite currently pins.</p>
<hr>
<h2>📌 Status</h2>
<p>This project is currently a proof-of-concept framework and actively evolving.</p>
<hr>
<h2>🤝 Contributing</h2>
<p>We are actively looking for contributors! Avenx-JS is PR and first-time open-source friendly. Whether you are fixing a typo, updating documentation, or adding features, we welcome your help.</p>
<p>Check out our <a href="CONTRIBUTING.md">CONTRIBUTING.md</a> to get started!</p>
<hr>
<h2>📄 License</h2>
<p>Distributed under the <strong>MIT License</strong>. See <code>LICENSE</code> for more information.</p>
<hr>
<h2>⭐ Support</h2>
<p>If you like what we're building, please give us a ⭐ on <a href="https://github.com/avenx-js/avenx-js">GitHub</a>!</p>
<p>Built with ❤️ by the Avenx Team.</p></article>
</section>
<section>
<header>
<h2>bin/colors.js</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Zero-dependency ANSI styling helpers for the Avenx CLI.</p>
<p>Styles are applied only when the active terminal can render them. Detection
follows the widely adopted conventions so that piped output, CI logs, and
<code>--json</code> consumers keep receiving clean, parseable text:</p>
<ul>
<li><code>--no-color</code> / <code>--no-colors</code> argument → always disabled</li>
<li><code>NO_COLOR</code> environment variable → always disabled (https://no-color.org)</li>
<li><code>FORCE_COLOR</code> environment variable → enabled unless set to <code>0</code>/<code>false</code></li>
<li><code>TERM=dumb</code> → disabled</li>
<li>non-TTY stdout (pipes, files, CI) → disabled</li>
</ul>
<p>When styling is disabled every helper returns the plain string unchanged,
so call sites never need to branch on color support themselves.</p></div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="bin_colors.js.html">bin/colors.js</a>, <a href="bin_colors.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
</article>
</section>
<section>
<header>
<h2>lib/compiler/BridgeParser.js</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Static analysis of Avenx bridge modules.</p>
<p>A bridge is a normal ES module whose default export is a <code>bridge({...})</code>
call. Because consumers reach it through an <code>import</code>, the compiler can read
the whole picture from source alone: which bridges exist, what each one
declares, which events it emits, and who imports it.</p>
<p>This module answers those questions without a full JavaScript parser. It
scans the <code>bridge({...})</code> argument with a brace/string-aware walker and reads
only the top level of the object literal, which is all the declaration
surface a bridge has.</p></div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_compiler_BridgeParser.js.html">lib/compiler/BridgeParser.js</a>, <a href="lib_compiler_BridgeParser.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>
</article>
</section>
<section>
<header>
<h2>lib/core/reactive/proxyHandler.js</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>Factory for creating proxy handlers used in reactive state.
Handles normal property access and computed property redirection.</p></div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="lib_core_reactive_proxyHandler.js.html">lib/core/reactive/proxyHandler.js</a>, <a href="lib_core_reactive_proxyHandler.js.html#line1">line 1</a>
</li></ul></dd>
</dl>
</div>