Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Before creating **any** commit, run:
cargo xtask check
```

This executes, in order: `fmt → clippy → deny → test → build`. Work is **not done** until this passes cleanly. If it fails, fix every reported issue before proceeding. No exceptions.
This executes, in order: `license-headers → fmt → clippy → deny → test → build`. Work is **not done** until this passes cleanly. If it fails, fix every reported issue before proceeding. No exceptions.

---

Expand Down Expand Up @@ -83,6 +83,19 @@ Every decision — API design, data structure choice, algorithm, error path —
- Types are `PascalCase`, functions are `snake_case`, constants are `SCREAMING_SNAKE_CASE`.
- `cargo fmt --all` is the sole formatting authority — never override or disable it.

### License header

Every source file (`.rs`, `.ts`, `.js`, `.cs`, `.h`, `.proto`) **must** start with:

```
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
```

followed by a blank line before any code. `cargo xtask check` enforces this. Run `cargo xtask license-headers --fix` to add missing headers automatically.

Files excluded from the check: `.html`, `.css`, `.json`, `.yml`, `.xml`, and auto-generated files (e.g. `webui_ffi.h`).

### Dependencies
- Keep them minimal. Prefer the standard library. Before adding a crate, justify why std doesn't suffice.
- Every dependency must pass `cargo deny check` (license allowlist + security advisories).
Expand Down Expand Up @@ -158,6 +171,8 @@ The `docs/` directory is a VitePress site for external developers consuming WebU
| Format | `cargo xtask fmt` |
| Lint | `cargo xtask clippy` |
| License & advisory audit | `cargo xtask deny` |
| License headers check | `cargo xtask license-headers` |
| License headers fix | `cargo xtask license-headers --fix` |
| Tests (workspace) | `cargo xtask test` |
| Build (workspace) | `cargo xtask build` |
| Test a single crate | `cargo test -p webui-parser` (or any crate name) |
Expand Down Expand Up @@ -265,6 +280,7 @@ Before finishing any task, confirm **all** of these:
- [ ] No new recursion or regex in core paths.
- [ ] No new `unwrap`/`expect` in library code.
- [ ] No unnecessary allocations introduced; buffers reused where possible.
- [ ] Every new source file has the license header (`// Copyright (c) Microsoft Corporation.` / `// Licensed under the MIT license.`).
- [ ] FFI changes include `# Safety` docs and never panic across the boundary.
- [ ] Proto schema changes prioritize performance and are cascade-tested.
- [ ] New dependencies use `workspace = true` and pass `cargo deny check`.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/commands/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use anyhow::{Context, Result};
use clap::Args;
use expand_tilde::expand_tilde;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/commands/common.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use clap::Args;
use std::path::PathBuf;
pub use webui::CssStrategy;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/commands/inspect.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use anyhow::{Context, Result};
use clap::Args;
use expand_tilde::expand_tilde;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

pub mod build;
pub mod common;
pub mod inspect;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/commands/serve.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use actix_web::{web, App, HttpRequest, HttpResponse, HttpServer};
use anyhow::{Context, Result};
use clap::Args;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

mod commands;
mod utils;

Expand Down
3 changes: 3 additions & 0 deletions crates/webui-cli/src/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

pub mod output;
3 changes: 3 additions & 0 deletions crates/webui-cli/src/utils/output.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

pub fn header(title: &str) {
eprintln!(
"\n {} {}\n",
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-discovery/src/cache.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Component discovery cache for avoiding repeated filesystem traversal.
//!
//! Caches discovered component data at `~/.webui/cache/components/` and
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-discovery/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! External component discovery for the WebUI framework.
//!
//! Discovers components from npm packages and local filesystem paths.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-discovery/src/npm.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! npm package resolution for external component discovery.
//!
//! Resolves npm packages from `node_modules/` using Node.js-style upward
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-expressions/benches/expressions_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use criterion::{criterion_group, criterion_main, Criterion};
use serde_json::json;
use std::hint::black_box;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-expressions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! WebUI expression evaluation module.
//!
//! This module handles the evaluation of condition expressions in WebUI templates.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

extern crate cbindgen;

use std::env;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! WebUI FFI (Foreign Function Interface) for interoperability with other languages.
//!
//! This crate provides C-compatible APIs for the WebUI handler to be used from languages
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-ffi/tests/csharp/WebUIFFITest.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// Integration tests for the webui-ffi shared library via P/Invoke.
//
// Usage (macOS):
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-ffi/tests/ffi_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Integration tests for the webui-ffi C ABI.
//!
//! These tests call every `#[no_mangle] extern "C"` function through the
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/benches/handler_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use serde_json::json;
use serde_json::Value;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! WebUI Handler implementation for Rust.
//!
//! This crate provides functionality to process and render WebUI protocols
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/src/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Handler plugin trait and built-in plugin implementations.
//!
//! The plugin system is framework-agnostic — WebUI provides lifecycle hooks
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/src/plugin/fast.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! FAST Hydration plugin for the WebUI handler.
//!
//! Injects HTML comment markers and data attributes that enable client-side
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/src/route_handler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Route component inventory management for incremental route rendering.
//!
//! These helpers walk the normal render fragment graph. The request-aware path is
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-handler/src/route_matcher.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Iterative path template matcher for server-side route resolution.
//!
//! Matches request paths against route path templates without regex.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-node/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

fn main() {
napi_build::setup();
}
3 changes: 3 additions & 0 deletions crates/webui-node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Node.js native addon for the WebUI framework via napi-rs.
//!
//! Provides high-performance server-side rendering by compiling the Rust
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/benches/parser_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use std::hint::black_box;
use webui_parser::{plugin::FastParserPlugin, CssStrategy, HtmlParser};
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/component_registry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Component registry for WebUI framework.
//!
//! This module manages the registry of web components used in the application.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/condition_parser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Parser for WebUI condition expressions.
//!
//! This module handles parsing condition expressions used in if directives.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/css_parser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! CSS parser for WebUI components.
//!
//! This module uses tree-sitter-css to parse CSS files
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Error handling for the WebUI parser.

use std::fmt;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/handlebars_parser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use crate::Result;
use webui_protocol::WebUIFragment;

Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Directive parser for WebUI template directives.
//!
//! This module handles parsing WebUI-specific directives like <for>, <if>, etc.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/plugin/fast.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! FAST parser plugin for the WebUI parser.
//!
//! Tracks component definitions during HTML parsing and generates `<f-template>`
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/plugin/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Parser plugin trait and built-in plugin implementations.
//!
//! The plugin system is framework-agnostic — WebUI provides parsing hooks
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-parser/src/route_parser.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Route element parsing for `<route>` directives.
//!
//! Parses `<route path="..." component="..." ...>` elements into
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-protocol/benches/protocol_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
use std::collections::HashMap;
use std::hint::black_box;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-protocol/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use std::io::Result;

fn main() -> Result<()> {
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-protocol/proto/webui.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

syntax = "proto3";

package webui;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-protocol/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! WebUI Protocol implementation.
//!
//! This crate defines the protocol used by the WebUI framework for cross-platform
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-state/benches/state_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use serde_json::json;
use std::hint::black_box;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-state/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

extern crate serde_json;

use serde_json::Value;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Test utilities for WebUI framework.
//!
//! This crate provides testing helpers and should only be used in test code.
Expand Down
3 changes: 3 additions & 0 deletions crates/webui-wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! WebAssembly bindings for the WebUI framework.
//!
//! This crate exposes the WebUI rendering pipeline to JavaScript via `wasm-bindgen`,
Expand Down
3 changes: 3 additions & 0 deletions crates/webui/benches/contact_book_bench.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! End-to-end benchmark for the contact-book-manager example application.
//!
//! Compiles the real contact-book-manager templates into a protocol binary at
Expand Down
3 changes: 3 additions & 0 deletions crates/webui/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Error types for the WebUI library.

use thiserror::Error;
Expand Down
3 changes: 3 additions & 0 deletions crates/webui/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

//! Programmatic API for the WebUI build-time rendering framework.
//!
//! This crate provides the core build, render, and inspection APIs
Expand Down
3 changes: 3 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export default {
title: "WebUI Framework",
description: "Native HTML Templating for Every Platform",
Expand Down
3 changes: 3 additions & 0 deletions docs/.vitepress/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import DefaultTheme from 'vitepress/theme'
import './custom.css'

Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/Microsoft.WebUI/NativeBindings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

using System;
using System.Reflection;
using System.Runtime.InteropServices;
Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/Microsoft.WebUI/WebUIException.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

using System;

namespace Microsoft.WebUI;
Expand Down
Loading
Loading