Skip to content

Instantly share code, notes, and snippets.

View bcardarella's full-sized avatar
Out sailing

Brian Cardarella bcardarella

Out sailing
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Benchmark Results</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
<style>
* {
INFO 2025-09-30T18:03:44 +42ms service=default version=0.13.5 args=["run","hello","--print-logs","--model","opencode/claude-sonnet-4-5"] opencode
INFO 2025-09-30T18:03:44 +0ms service=project directory=/Users/bcardarella/projects/zig/zigdom fromDirectory
INFO 2025-09-30T18:03:44 +4ms service=config path=/Users/bcardarella/.config/opencode/config.json loading
INFO 2025-09-30T18:03:44 +0ms service=config path=/Users/bcardarella/.config/opencode/opencode.json loading
INFO 2025-09-30T18:03:44 +2ms service=config path=/Users/bcardarella/.config/opencode/opencode.jsonc loading
INFO 2025-09-30T18:03:44 +1ms service=plugin [email protected] loading plugin
INFO 2025-09-30T18:03:44 +1ms service=plugin [email protected] loading plugin
INFO 2025-09-30T18:03:44 +8ms service=bus type=* subscribing
INFO 2025-09-30T18:03:44 +0ms service=bus type=session.updated subscribing
INFO 2025-09-30T18:03:44 +0ms service=bus type=message.updated subscribing

View Markup Language (VML) Specification

Version 1.0
Status: Definitive Specification
Date: 2025-09-05

Abstract

This specification defines the View Markup Language (VML), a declarative SGML-based markup language for describing SwiftUI user interface hierarchies. VML provides a static, server-renderable representation of SwiftUI views that can be transmitted over HTTP and interpreted by compliant clients.

SwiftUI to VML Conversion Rules

Basic Conversion Principles

  1. Element Mapping: SwiftUI view types map 1:1 to VML elements with exact name preservation
  2. Attribute Mapping: SwiftUI initializer parameters become VML element attributes
  3. Modifier Mapping: SwiftUI view modifiers become comma-separated values in the style attribute
  4. Static Content Only: VML represents static UI structure - remove all dynamic bindings, closures, and runtime logic
  5. Template System: ViewBuilder closures convert to template/slot patterns using template attributes

View Markup Language (VML) Specification

Version 1.0
Status: Definitive Specification
Date: 2025-09-05

Abstract

This specification defines the View Markup Language (VML), a declarative SGML-based markup language for describing SwiftUI user interface hierarchies. VML provides a static, server-renderable representation of SwiftUI views that can be transmitted over HTTP and interpreted by compliant clients.

VML Specification (Canonical)

VML (View Markup Language) is a declarative markup for describing SwiftUI-compatible UI hierarchies. It encodes structure, attributes, and modifiers (via a style string). VML does not encode closures, actions, or control flow; the client runtime handles events and data flow outside of this spec.

This document supersedes earlier drafts and incorporates all refinements, including Templates, attr(...) with CSS‑aligned type(<…>) hints, strict formatting, serialization rules, and an EBNF grammar. It also contains an exhaustive SwiftUI → VML conversion cookbook with before/after examples.


1. Core Principles

SwiftUI Modern Design System Rules

🚀 Core SwiftUI API Guidelines

Modern API Usage - CRITICAL

  • ALWAYS use .foregroundStyle() instead of deprecated .foregroundColor()
  • ALWAYS use .clipShape(.rect(cornerRadius: X)) instead of RoundedRectangle for simple rounded corners
  • NEVER use views inside background modifiers - use nested modifiers or enums only
  • NEVER use localStorage or sessionStorage in SwiftUI artifacts (not supported)
  • NEVER invent APIs that don't exist - verify all modifiers exist in SwiftUI
v0.1.0
v0.1.1
v0.10.0
v0.11.0
v0.11.1
v0.12.0
v0.12.1
v0.13.0
v0.13.1
v0.13.2
Power:
Battery Information:
Model Information:
Serial Number: D865185A5631LP9CR
Device Name: bq40z651
Pack Lot Code: 0
PCB Lot Code: 0
Firmware Version: 0b00

What changes inside Lightpanda (revised scope)

0) Repository layout & boundaries

  • New VML subsystem parallel to HTML (no inheritance from HTML classes):

    • src/browser/vml/

      • parser/ (tokenizer + treebuilder)
  • dom/ (VMLElement, VML*Element subclasses)