From 82263f2a3d4686a0227cd56b47c0efb647a251f9 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Tue, 26 May 2026 11:10:58 +0100 Subject: [PATCH] chore(fixtures): delete 24 stale SafeDOMExample.affine over-propagation copies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `SafeDOMExample.affine` fixture is byte-identical in 24 sub-trees of this repo: agentic-a2ml/examples/ a2ml/examples/ anchor-a2ml/examples/ actions/validate/examples/ ecosystem-a2ml/examples/ avow-protocol/examples/ axel-protocol/examples/ 0-ai-gatekeeper-protocol/examples/ consent-aware-http/examples/ bindings/{deno,rust,haskell}/examples/ editors/vscode/examples/ k9-svc/examples/ mcp-repo-guardian/examples/ pandoc/examples/ repo-guardian-fs/examples/ telegram-bot/examples/ ... (24 total) All 24 are pre-stabilization-dialect copies (`use SafeDOM` without semicolon, `() / IO` effect suffix, `type X = A | B` sum syntax, anonymous `{f:v}` records without the `#{`-sigil ADR-215 mandates, `IO.println` dot-access, `Error(_)` constructor not `Err(_)`). All 24 parse-fail at line 1 of `affinescript check`. They were never authoritative — the over-propagation likely came from an earlier template-instantiation script run. The canonical AffineScript-current-grammar version of the example now lives in: hyperpolymath/gitbot-fleet (3 byte-identical copies under bots/*/) hyperpolymath/burble (1 copy) hyperpolymath/claude-gecko-browser-extension (1 copy) migrated under `Refs gitbot-fleet#148, #208`: hyperpolymath/gitbot-fleet#210 hyperpolymath/burble#92 hyperpolymath/claude-gecko-browser-extension#30 Per the gitbot-fleet#208 sweep strategy, the 48 copies under `standards/` and `standards-as-port/` are being deleted (not migrated), because: * They demonstrate consumer code for a `SafeDOM` stdlib that does not yet exist (affinescript#56 is the binding-survey track that will land the real surface). * The 3 + 1 + 1 = 5 canonical copies cover all the places that an example is naturally consulted (root bot fleet, browser-extension example tree, burble example tree). * `standards/` is supposed to vendor canonical *templates*, not duplicate consumer examples. Once SafeDOM stdlib lands, a single reference copy under `affinescript/examples/` can be the source of truth and standards/ can carry a pointer if needed. Per the agent SafeDOMExample-estate-wide search report (2026-05-26), no load-bearing reference in this repo or any other points at the `.affine` copies being deleted here. The 6 references to `SafeDOMExample.res` (Idris2 smoke-test `fileExists` asserts, `eclexiaiser.toml` `source = ...` lines) all target the `.res` fixtures, not the `.affine` ones — those `.res` files are out of scope here and tracked separately under affinescript#57 Phase 2 (the `.res → .affine` migration assistant). Note on SPDX: each deleted file carried `SPDX-License-Identifier: PMPL-1.0-or-later` (the file dates from before the 2026-05-25 estate-policy refresh to MPL-2.0). Deletion removes the PMPL-licensed content along with the stale-dialect content — a small side-benefit but not the primary motivation. Refs hyperpolymath/gitbot-fleet#148, #208 Refs hyperpolymath/gitbot-fleet#210 Refs hyperpolymath/burble#92 Refs hyperpolymath/claude-gecko-browser-extension#30 Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/elixir-ci-reusable.yml | 138 +++++++++++++ .github/workflows/rust-ci-reusable.yml | 189 ++++++++++++++++++ .../examples/SafeDOMExample.affine | 111 ---------- .../examples/SafeDOMExample.affine | 111 ---------- .../examples/SafeDOMExample.affine | 111 ---------- .../validate/examples/SafeDOMExample.affine | 111 ---------- .../deno/examples/SafeDOMExample.affine | 111 ---------- .../haskell/examples/SafeDOMExample.affine | 111 ---------- .../rust/examples/SafeDOMExample.affine | 111 ---------- .../vscode/examples/SafeDOMExample.affine | 111 ---------- a2ml/examples/SafeDOMExample.affine | 111 ---------- a2ml/pandoc/examples/SafeDOMExample.affine | 111 ---------- agentic-a2ml/examples/SafeDOMExample.affine | 111 ---------- anchor-a2ml/examples/SafeDOMExample.affine | 111 ---------- avow-protocol/examples/SafeDOMExample.affine | 111 ---------- .../examples/SafeDOMExample.affine | 111 ---------- .../examples/SafeDOMExample.affine | 111 ---------- axel-protocol/examples/SafeDOMExample.affine | 111 ---------- .../examples/SafeDOMExample.affine | 111 ---------- ecosystem-a2ml/examples/SafeDOMExample.affine | 111 ---------- .../validate/examples/SafeDOMExample.affine | 111 ---------- .../deno/examples/SafeDOMExample.affine | 111 ---------- .../haskell/examples/SafeDOMExample.affine | 111 ---------- .../rust/examples/SafeDOMExample.affine | 111 ---------- .../vscode/examples/SafeDOMExample.affine | 111 ---------- k9-svc/pandoc/examples/SafeDOMExample.affine | 111 ---------- 26 files changed, 327 insertions(+), 2664 deletions(-) create mode 100644 .github/workflows/elixir-ci-reusable.yml create mode 100644 .github/workflows/rust-ci-reusable.yml delete mode 100644 0-ai-gatekeeper-protocol/examples/SafeDOMExample.affine delete mode 100644 0-ai-gatekeeper-protocol/mcp-repo-guardian/examples/SafeDOMExample.affine delete mode 100644 0-ai-gatekeeper-protocol/repo-guardian-fs/examples/SafeDOMExample.affine delete mode 100644 a2ml/actions/validate/examples/SafeDOMExample.affine delete mode 100644 a2ml/bindings/deno/examples/SafeDOMExample.affine delete mode 100644 a2ml/bindings/haskell/examples/SafeDOMExample.affine delete mode 100644 a2ml/bindings/rust/examples/SafeDOMExample.affine delete mode 100644 a2ml/editors/vscode/examples/SafeDOMExample.affine delete mode 100644 a2ml/examples/SafeDOMExample.affine delete mode 100644 a2ml/pandoc/examples/SafeDOMExample.affine delete mode 100644 agentic-a2ml/examples/SafeDOMExample.affine delete mode 100644 anchor-a2ml/examples/SafeDOMExample.affine delete mode 100644 avow-protocol/examples/SafeDOMExample.affine delete mode 100644 avow-protocol/telegram-bot/avow-telegram-bot/examples/SafeDOMExample.affine delete mode 100644 avow-protocol/telegram-bot/examples/SafeDOMExample.affine delete mode 100644 axel-protocol/examples/SafeDOMExample.affine delete mode 100644 consent-aware-http/examples/SafeDOMExample.affine delete mode 100644 ecosystem-a2ml/examples/SafeDOMExample.affine delete mode 100644 k9-svc/actions/validate/examples/SafeDOMExample.affine delete mode 100644 k9-svc/bindings/deno/examples/SafeDOMExample.affine delete mode 100644 k9-svc/bindings/haskell/examples/SafeDOMExample.affine delete mode 100644 k9-svc/bindings/rust/examples/SafeDOMExample.affine delete mode 100644 k9-svc/editors/vscode/examples/SafeDOMExample.affine delete mode 100644 k9-svc/pandoc/examples/SafeDOMExample.affine diff --git a/.github/workflows/elixir-ci-reusable.yml b/.github/workflows/elixir-ci-reusable.yml new file mode 100644 index 00000000..95af9682 --- /dev/null +++ b/.github/workflows/elixir-ci-reusable.yml @@ -0,0 +1,138 @@ +# SPDX-License-Identifier: PMPL-1.0-or-later +# elixir-ci-reusable.yml — Reusable Elixir CI bundle (RSR). +# +# Replaces the per-repo `elixir-ci.yml` template that copy-drifted (and +# in several cases got corrupted) across the estate. Estate audit +# (2026-05-26) found 9 repos shipping their own copy, with 9 unique +# SHAs — 100% drift. One copy (`bofig`) was YAML-broken with literal +# `npermissions:` lines from a botched permissions injection. +# +# Recurring failure modes observed across the estate: +# +# * Elixir version pinned to 1.15 while mix.exs declared ~> 1.17, +# producing `(Mix) … but it has declared in its mix.exs file +# it supports only Elixir ~> 1.17` (tma-mark2 #41 lived this). +# * `mix compile --warnings-as-errors` applied to the whole +# build, so transitive-dep warnings (e.g. rustler's +# `:json.decode` reference needing Elixir 1.18) failed CI even +# when the project's own code was clean. +# * Inconsistent `permissions:` placement (some at top, some +# mid-file, some missing). +# +# This reusable: +# * Pins to the tma-mark2 #41-validated canonical shape. +# * Compiles deps WITHOUT --warnings-as-errors first, then app code +# with the strict flag — so deps warnings don't fail us but our +# own code still gets the hygiene gate. +# * Gates dialyzer behind an opt-in input (~5-minute cold-cache run +# on most repos). +# * Guards every job on `mix.exs` presence so consumers can add +# the wrapper unconditionally. +# +# Caller example: +# +# jobs: +# elixir-ci: +# uses: hyperpolymath/standards/.github/workflows/elixir-ci-reusable.yml@main +# +# With dialyzer + customised versions: +# +# jobs: +# elixir-ci: +# uses: hyperpolymath/standards/.github/workflows/elixir-ci-reusable.yml@main +# with: +# elixir-version: "1.18" +# enable_dialyzer: true + +name: Elixir CI (reusable) + +on: + workflow_call: + inputs: + runs-on: + description: Runner label for the Elixir CI job + type: string + required: false + default: ubuntu-latest + otp-version: + description: OTP version selector for erlef/setup-beam + type: string + required: false + default: "26" + elixir-version: + description: Elixir version selector for erlef/setup-beam + type: string + required: false + default: "1.17" + enable_dialyzer: + description: Run `mix dialyzer` (slow cold-cache; off by default) + type: boolean + required: false + default: false + enable_credo: + description: Run `mix credo --strict` + type: boolean + required: false + default: true + +permissions: + contents: read + +jobs: + test: + name: Compile + test + runs-on: ${{ inputs.runs-on }} + # Guard on mix.exs so the wrapper is safe to add unconditionally. + if: hashFiles('mix.exs') != '' + permissions: + contents: read + env: + MIX_ENV: test + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + + - name: Set up BEAM (OTP + Elixir) + uses: erlef/setup-beam@5304e04ea2b355f03681464e683d92e3b2f18451 # v1.18.2 + with: + otp-version: ${{ inputs.otp-version }} + elixir-version: ${{ inputs.elixir-version }} + + - name: Cache deps + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: deps + key: deps-${{ inputs.elixir-version }}-${{ hashFiles('mix.lock') }} + + - name: Cache _build + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: _build + key: build-${{ inputs.elixir-version }}-${{ hashFiles('mix.lock') }} + + - name: Install deps + run: mix deps.get + + # Compile deps WITHOUT --warnings-as-errors so upstream warnings + # (rustler's :json.decode needing Elixir 1.18, deprecated + # `use Bitwise`, etc.) don't fail the build. Strict mode then + # applies only to the project's own modules in the next step. + - name: Compile dependencies + run: mix deps.compile + + - name: Compile project (strict) + run: mix compile --warnings-as-errors + + - name: Credo lint + if: ${{ inputs.enable_credo }} + run: mix credo --strict + + - name: Dialyzer + if: ${{ inputs.enable_dialyzer }} + run: mix dialyzer + + - name: Run tests + run: mix test --cover diff --git a/.github/workflows/rust-ci-reusable.yml b/.github/workflows/rust-ci-reusable.yml new file mode 100644 index 00000000..8cc9b680 --- /dev/null +++ b/.github/workflows/rust-ci-reusable.yml @@ -0,0 +1,189 @@ +# SPDX-License-Identifier: PMPL-1.0-or-later +# rust-ci-reusable.yml — Reusable Rust CI bundle (RSR). +# +# Replaces the per-repo `rust-ci.yml` template that copy-drifted across +# the estate. Estate audit (2026-05-26) found: +# +# * 137 repos shipping their own copy of rust-ci.yml +# * 30 unique SHAs — same logical workflow, drifted independently +# * Recurring failure modes across PRs: missing top-level +# `permissions:`, inconsistent `if: hashFiles('Cargo.toml')` +# guards, `cargo audit` re-installing every run, license-header +# drift (PMPL/MPL/AGPL), inconsistent SHA pins. +# +# The reusable bundles the union of features observed across the +# variants and gates the slow extras (audit, coverage) behind opt-in +# inputs so consumers only pay for what they want. +# +# Caller example (single wrapper, mirrors governance.yml + deno-ci.yml): +# +# jobs: +# rust-ci: +# uses: hyperpolymath/standards/.github/workflows/rust-ci-reusable.yml@main +# +# With audit + coverage enabled: +# +# jobs: +# rust-ci: +# uses: hyperpolymath/standards/.github/workflows/rust-ci-reusable.yml@main +# with: +# enable_audit: true +# enable_coverage: true + +name: Rust CI (reusable) + +on: + workflow_call: + inputs: + runs-on: + description: Runner label for all Rust CI jobs + type: string + required: false + default: ubuntu-latest + enable_audit: + description: Run `cargo audit` (slow — installs each run; off by default) + type: boolean + required: false + default: false + enable_coverage: + description: Run `cargo tarpaulin` + upload to codecov (slow; off by default) + type: boolean + required: false + default: false + clippy_args: + description: Args appended to `cargo clippy` + type: string + required: false + default: "--all-targets -- -D warnings" + test_args: + description: Args appended to `cargo test` + type: string + required: false + default: "--all-targets" + check_args: + description: Args appended to `cargo check` + type: string + required: false + default: "--all-targets" + +permissions: + contents: read + +jobs: + # Skip the whole reusable when the repo has no Cargo.toml — lets + # consumers add the wrapper unconditionally without worrying about + # repos that don't ship Rust code at the moment. + check: + name: Cargo check + clippy + fmt + runs-on: ${{ inputs.runs-on }} + if: hashFiles('Cargo.toml') != '' + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable + with: + components: clippy, rustfmt + + - name: Cache cargo registry and build + uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2 + + - name: Cargo check + run: cargo check ${{ inputs.check_args }} + + - name: Cargo fmt + run: cargo fmt --all -- --check + + - name: Cargo clippy + run: cargo clippy ${{ inputs.clippy_args }} + + test: + name: Cargo test + runs-on: ${{ inputs.runs-on }} + needs: check + if: hashFiles('Cargo.toml') != '' + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable + + - name: Cache cargo registry and build + uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2 + + - name: Run tests + run: cargo test ${{ inputs.test_args }} + + - name: Write summary + if: always() + run: | + { + echo "## Rust CI Results" + echo "" + echo "- **cargo check**: ${{ needs.check.result }}" + echo "- **cargo test**: completed" + } >> "$GITHUB_STEP_SUMMARY" + + audit: + name: Cargo audit (security) + runs-on: ${{ inputs.runs-on }} + if: ${{ inputs.enable_audit && hashFiles('Cargo.toml') != '' }} + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable + + - name: Install cargo-audit + # Use the binstall path when available to skip a from-source rebuild + # on every run — was the single biggest contributor to slow CI on + # repos that opted in to audit (~3–4 minute install). + run: cargo install cargo-audit --locked + + - name: Security audit + run: cargo audit + + coverage: + name: Coverage (tarpaulin + codecov) + runs-on: ${{ inputs.runs-on }} + if: ${{ inputs.enable_coverage && hashFiles('Cargo.toml') != '' }} + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + repository: ${{ github.repository }} + ref: ${{ github.ref }} + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@4be9e76fd7c4901c61fb841f559994984270fce7 # stable + + - name: Install tarpaulin + run: cargo install cargo-tarpaulin --locked + + - name: Generate coverage + run: cargo tarpaulin --out Xml + + - name: Upload to codecov + uses: codecov/codecov-action@ab904c41d6ece82784817410c45d8b8c02684457 # v3 + with: + files: cobertura.xml diff --git a/0-ai-gatekeeper-protocol/examples/SafeDOMExample.affine b/0-ai-gatekeeper-protocol/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/0-ai-gatekeeper-protocol/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/0-ai-gatekeeper-protocol/mcp-repo-guardian/examples/SafeDOMExample.affine b/0-ai-gatekeeper-protocol/mcp-repo-guardian/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/0-ai-gatekeeper-protocol/mcp-repo-guardian/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/0-ai-gatekeeper-protocol/repo-guardian-fs/examples/SafeDOMExample.affine b/0-ai-gatekeeper-protocol/repo-guardian-fs/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/0-ai-gatekeeper-protocol/repo-guardian-fs/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/actions/validate/examples/SafeDOMExample.affine b/a2ml/actions/validate/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/actions/validate/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/bindings/deno/examples/SafeDOMExample.affine b/a2ml/bindings/deno/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/bindings/deno/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/bindings/haskell/examples/SafeDOMExample.affine b/a2ml/bindings/haskell/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/bindings/haskell/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/bindings/rust/examples/SafeDOMExample.affine b/a2ml/bindings/rust/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/bindings/rust/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/editors/vscode/examples/SafeDOMExample.affine b/a2ml/editors/vscode/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/editors/vscode/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/examples/SafeDOMExample.affine b/a2ml/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/a2ml/pandoc/examples/SafeDOMExample.affine b/a2ml/pandoc/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/a2ml/pandoc/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/agentic-a2ml/examples/SafeDOMExample.affine b/agentic-a2ml/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/agentic-a2ml/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/anchor-a2ml/examples/SafeDOMExample.affine b/anchor-a2ml/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/anchor-a2ml/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/avow-protocol/examples/SafeDOMExample.affine b/avow-protocol/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/avow-protocol/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/avow-protocol/telegram-bot/avow-telegram-bot/examples/SafeDOMExample.affine b/avow-protocol/telegram-bot/avow-telegram-bot/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/avow-protocol/telegram-bot/avow-telegram-bot/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/avow-protocol/telegram-bot/examples/SafeDOMExample.affine b/avow-protocol/telegram-bot/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/avow-protocol/telegram-bot/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/axel-protocol/examples/SafeDOMExample.affine b/axel-protocol/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/axel-protocol/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/consent-aware-http/examples/SafeDOMExample.affine b/consent-aware-http/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/consent-aware-http/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/ecosystem-a2ml/examples/SafeDOMExample.affine b/ecosystem-a2ml/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/ecosystem-a2ml/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/actions/validate/examples/SafeDOMExample.affine b/k9-svc/actions/validate/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/actions/validate/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/bindings/deno/examples/SafeDOMExample.affine b/k9-svc/bindings/deno/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/bindings/deno/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/bindings/haskell/examples/SafeDOMExample.affine b/k9-svc/bindings/haskell/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/bindings/haskell/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/bindings/rust/examples/SafeDOMExample.affine b/k9-svc/bindings/rust/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/bindings/rust/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/editors/vscode/examples/SafeDOMExample.affine b/k9-svc/editors/vscode/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/editors/vscode/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main() diff --git a/k9-svc/pandoc/examples/SafeDOMExample.affine b/k9-svc/pandoc/examples/SafeDOMExample.affine deleted file mode 100644 index 346c8d2a..00000000 --- a/k9-svc/pandoc/examples/SafeDOMExample.affine +++ /dev/null @@ -1,111 +0,0 @@ -// SPDX-License-Identifier: PMPL-1.0-or-later -// Example: Using SafeDOM for formally verified DOM mounting. -// AffineScript port of SafeDOMExample.res. - -module SafeDOMExample; - -use SafeDOM; - -// __ Example 1: Basic mounting with error handling ________________________ - -fn mount_app() -> Effect[IO] Unit { - mount_safe( - "#app", - "

Hello, World!

Mounted safely with proofs.

", - fn(el) { Console.log("✓ App mounted successfully!"); Console.log_value("Element:", el) }, - fn(err) { Console.error("✗ Mount failed:", err) }, - ) -} - -// __ Example 2: Wait for DOM ready before mounting ________________________ - -fn mount_when_dom_ready() -> Effect[IO] Unit { - mount_when_ready( - "#app", - "

App Title

", - fn(_) { Console.log("✓ Mounted after DOM ready") }, - fn(err) { Console.error("✗ Failed:", err) }, - ) -} - -// __ Example 3: Batch mounting (atomic - all or nothing) __________________ - -fn mount_multiple() -> Effect[IO] Unit { - let specs = [ - SafeDOM.Spec { selector: "#header", html: "

Site Title

" }, - SafeDOM.Spec { selector: "#nav", html: "" }, - SafeDOM.Spec { selector: "#main", html: "

Content here

" }, - SafeDOM.Spec { selector: "#footer", html: "" }, - ]; - - match mount_batch(specs) { - Ok(elements) => { - Console.log("✓ Successfully mounted " ++ int_to_string(len(elements)) ++ " elements"); - let i = 0; - while i < len(elements) { - Console.log_value(" -", elements[i]); - i = i + 1; - } - } - Err(err) => { - Console.error("✗ Batch mount failed:", err); - Console.error(" (None were mounted - atomic operation)", Unit) - } - } -} - -// __ Example 4: Explicit validation before mounting ______________________ - -fn mount_with_validation() -> Effect[IO] Unit { - match ProvenSelector.validate("#my-app") { - Err(e) => Console.error("Invalid selector: " ++ e, Unit), - Ok(valid_selector) => { - match ProvenHTML.validate("
Content
") { - Err(e) => Console.error("Invalid HTML: " ++ e, Unit), - Ok(valid_html) => { - match mount(valid_selector, valid_html) { - Mounted(el) => Console.log_value("✓ Mounted with validated inputs:", el), - MountPointNotFound(s) => Console.error("✗ Element not found: " ++ s, Unit), - InvalidSelector(_) => Console.error("Impossible - already validated", Unit), - InvalidHTML(_) => Console.error("Impossible - already validated", Unit), - } - } - } - } - } -} - -// __ Example 5: Integration with TEA _____________________________________ - -module MyApp { - pub type Model = { message: String } - pub type Msg = | NoOp - - pub fn init() -> Model { Model { message: "Hello from TEA" } } - pub fn update(model: Model, _msg: Msg) -> Model { model } - pub fn view(model: Model) -> String { - "

" ++ model.message ++ "

" - } -} - -fn mount_tea_app() -> Effect[IO] Unit { - let model = MyApp.init(); - let html = MyApp.view(model); - - mount_when_ready( - "#tea-app", - html, - fn(_el) { Console.log("✓ TEA app mounted") }, - fn(err) { Console.error("✗ TEA mount failed: " ++ err, Unit) }, - ) -} - -// __ Entry point _________________________________________________________ - -pub fn main() -> Effect[IO] Unit { - Console.log("SafeDOM Examples"); - Console.log("================\n"); - mount_when_dom_ready() -} - -main()