poor_web 2025.5.15+1 copy "poor_web: ^2025.5.15+1" to clipboard
poor_web: ^2025.5.15+1 copied to clipboard

light web wrapper library.

Light web wrapper library.

Usage #

// example/example.dart
import 'package:poor_web/poor_web.dart';

void main() {
  document.querySelector('#example')?.appendAll([
    HTMLHeadingElement.h1()..append(Text('Hello, Example!')),
    HTMLParagraphElement()..append(Text('This is a simple web application.')),
  ]);

  final global = globalThis;

  global['calc'] = Object()..['add'] = Fn.a2((Number a, Number b) => a + b);

  final a = 1;
  final b = 2;
  final c = global['calc']?.object?['add']?.function?.call(
    Number(a),
    Number(b),
  );
  print('$a + $b = $c'); // 1 + 2 = 3

  global['calc']?.object?['print'] = Fn(
    ([a, b, c, _]) => switch ((a?.number, b?.number, c?.number)) {
      (Number a, Number b, Number c) => String('$a + $b = $c'),
      _ => null,
    },
  );
}
<!-- example/index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Example</title>
    <script type="module">
      import {
        compileStreaming,
        instantiate,
        invoke,
      } from "./example.mjs";

      const instance = await instantiate(
        compileStreaming(
          fetch(new URL("./example.wasm", import.meta.url)),
        ),
      );

      invoke(instance);

      const a = 1;
      const b = 2;
      const c = calc.add(a, b);
      document.querySelector("#example").append(new Text(calc.print(a, b, c)));
    </script>
  </head>
  <body>
    <main id="example"></main>
  </body>
</html>

Additional information #

0
likes
150
points
263
downloads

Publisher

unverified uploader

Weekly Downloads

light web wrapper library.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

web

More

Packages that depend on poor_web