# Weiv Architecture ## Purpose `weiv` is a frontend framework project intended to combine the strongest parts of several existing frontend approaches while avoiding the parts that feel ergonomically expensive. The design motivation is: - keep template, script, and style clearly separated - avoid JSX as the primary UI authoring model - avoid making explicit reactive wrappers the default way to write app code - use compilation aggressively where it improves ergonomics and runtime cost - preserve strong TypeScript support - keep the runtime small and understandable `weiv` is trying to be a practical, high-ergonomics frontend framework for application developers. ## Direction `weiv` is a compiler-first frontend framework. The normalized vocabulary for this model lives in [Terminology](./terminology.md). The current direction is: - `.weiv` single-file components - TypeScript script blocks - template-first authoring - scoped CSS - direct DOM browser output - small runtime helpers - compiler-owned state scheduling and patch planning `weiv` should not center its default model around signals, refs, proxies, a virtual DOM, or public effect graphs. Where plain TypeScript becomes too ambiguous for trustworthy compile-time state analysis, `weiv` should first strengthen script-side precision through AST-backed backend analysis and explicit diagnostics. For state that escapes simple owned component boundaries, the current next-direction is explicit shared observable state created at the source rather than trying to proxy plain shared objects later inside consuming components. Optional ecosystem/runtime companions are still valid, but they are no longer part of the active top-level implementation track. The current architecture is centered on the compiler/runtime foundation already on `main`. The intended state split is: - local owned state stays simple and compiler-first - shared state beyond the component boundary should move through a Weiv-owned observable runtime contract ## Core Principles ### Template, Script, Style Separation Single-file components are a first-class product choice. The framework centers template-first authoring with ordinary TypeScript and ordinary CSS. ### Ordinary State First The default component state model should feel like ordinary TypeScript variables, object fields, and functions. Advanced runtime primitives can exist, but they should not become the everyday happy path. ### Compiler First, Runtime Second Whenever a concern can be solved at compile time without making the mental model confusing, that should be preferred. The runtime should stay focused on mounting, lifecycle, change propagation, and scheduling rather than becoming a dumping ground for every abstraction. ### TypeScript Native TypeScript is a design input, not a retrofit. That includes component prop typing, event payload typing, template-to-script validation, editor tooling, and diagnostics. ### Explicit Boundaries Over Magic Weiv can compile aggressively without becoming mysterious. Rules should stay learnable, explainable, and inspectable. ## Component Syntax Current component shape: ```html ``` Supported template features include: - interpolation: `{{ expr }}` - event binding: `on:click="handler"` - attribute/property binding: `bind:disabled="expr"` - conditionals: `if` / `else` - loops: `for="item in items"` - child components through capitalized tags - slots: ``, named slots, fallback content, and `