MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add welcome.js demo and example scripts

+95 -14
+30
examples/demo/welcome.js
··· 1 + console.log(`Hello from ${navigator.userAgent}! Did you know:\n`); 2 + 3 + const rows = [ 4 + ['Feature', 'Description'], 5 + ['Async/Await', 'Full coroutine support with minicoro'], 6 + ['HTTP Server', 'Built-in Ant.serve() with TLS support'], 7 + ['Fetch API', 'HTTP client with TLS via tlsuv'], 8 + ['File System', 'Async/sync fs with ant:fs module'], 9 + ['FFI', 'Native library integration'], 10 + ['Web Locks', 'Navigator.locks API'], 11 + ['TypeScript', 'Built-in type stripping via oxc'], 12 + ['Garbage Collection', 'Mark-copy compacting + Boehm-Demers'], 13 + ['', ''], 14 + ['And more...'] 15 + ]; 16 + 17 + const widths = [0, 0]; 18 + for (const r of rows) { 19 + if (r[0].length > widths[0]) widths[0] = r[0].length; 20 + if (r[1].length > widths[1]) widths[1] = r[1].length; 21 + } 22 + 23 + const border = '+' + '-'.repeat(widths[0] + 2) + '+' + '-'.repeat(widths[1] + 2) + '+'; 24 + console.log(border); 25 + for (let i = 0; i < rows.length; i++) { 26 + const r = rows[i]; 27 + console.log('| ' + r[0].padEnd(widths[0], ' ') + ' | ' + r[1].padEnd(widths[1], ' ') + ' |'); 28 + if (i === 0) console.log(border); 29 + } 30 + console.log(border);
+34
libant/example.sh
··· 1 + #!/bin/bash 2 + set -e 3 + 4 + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 5 + DIST_DIR="$SCRIPT_DIR/dist" 6 + SOURCE="$SCRIPT_DIR/../examples/embed/embed.c" 7 + OUTPUT="$SCRIPT_DIR/dist/embed" 8 + 9 + if [ ! -f "$DIST_DIR/libant.a" ]; then 10 + echo "Error: libant.a not found in $DIST_DIR" 11 + echo "Run ./build.sh first" 12 + exit 1 13 + fi 14 + 15 + case "$(uname -s)" in 16 + Darwin) 17 + LIBS="-framework Security -framework CoreFoundation -lpthread" 18 + ;; 19 + Linux) 20 + LIBS="-lpthread -ldl -lm" 21 + ;; 22 + MINGW*|MSYS*|CYGWIN*|Windows_NT) 23 + LIBS="-lws2_32 -lrpcrt4 -lsecur32 -lntdll -lcrypt32 -luserenv" 24 + ;; 25 + *) 26 + LIBS="-lpthread" 27 + ;; 28 + esac 29 + 30 + CC="${CC:-clang}" 31 + 32 + echo "Compiling embed example..." 33 + $CC "$SOURCE" -I"$DIST_DIR" "$DIST_DIR/libant.a" $LIBS -o "$OUTPUT" 34 + echo "Done: $OUTPUT"
+1
libant/meson
··· 1 + ../meson
+16 -5
libant/meson.build
··· 13 13 vendor_dir = 'vendor' 14 14 is_static = true 15 15 16 - subdir('../meson') 16 + subdir('meson') 17 17 18 18 module_files = run_command('sh', '-c', 19 19 'ls ' + src_root / 'src' / 'modules' / '*.c', ··· 48 48 libant_core = static_library( 49 49 'ant_core', 50 50 lib_sources + [snapshot_h], 51 - include_directories: [include, build_include, strip_include], 51 + include_directories: [ 52 + include, 53 + build_include, 54 + version_include, 55 + strip_include 56 + ], 52 57 dependencies: ant_deps + [oxc_dep], 53 58 ) 54 59 ··· 56 61 libant_core_lto = static_library( 57 62 'ant_core_lto', 58 63 lib_sources + [snapshot_h], 59 - include_directories: [include, build_include, strip_include], 64 + include_directories: [ 65 + include, 66 + build_include, 67 + version_include, 68 + strip_include 69 + ], 60 70 dependencies: ant_deps + [oxc_dep], 61 71 c_args: ['-flto'], 62 72 ) ··· 82 92 libraries: ['-L${libdir}', '-lant'] + pkg_libs 83 93 ) 84 94 85 - gen_header = custom_target( 95 + custom_target( 86 96 'ant_header', 87 97 input: [config_h], 88 98 output: 'libant.h', ··· 90 100 'bash', meson.project_source_root() / 'scripts' / 'header.sh', 91 101 '@INPUT0@', '@OUTPUT@' 92 102 ], 93 - build_by_default: true 103 + build_by_default: true, 104 + build_always_stale: true 94 105 )
+6 -2
libant/scripts/compile.sh
··· 7 7 8 8 export PKG_CONFIG_PATH="$DEPS_DIR/lib/pkgconfig:$PKG_CONFIG_PATH" 9 9 10 - meson setup build --prefer-static -Dtls_library=mbedtls -Ddeps_prefix_cmake="$DEPS_DIR" "$@" 11 - meson compile -C build 10 + mkdir -p "$BUILD_DIR/vendor/tlsuv" 11 + rm -rf "$BUILD_DIR/vendor/tlsuv/deps" 12 + cp -RL "$BUILD_DIR/deps" "$BUILD_DIR/vendor/tlsuv/deps" 13 + 14 + meson setup build --prefer-static -Dtls_library=mbedtls -Ddeps_prefix_cmake="$BUILD_DIR/vendor/tlsuv/deps" "$@" 15 + meson compile -C build
+6 -5
libant/scripts/header.sh
··· 16 16 17 17 HEADERS=( 18 18 "config.h:$CONFIG_H" 19 + "common.h:$INCLUDE_DIR/common.h" 19 20 "compat.h:$INCLUDE_DIR/compat.h" 20 21 "ant.h:$INCLUDE_DIR/ant.h" 21 22 "utils.h:$INCLUDE_DIR/utils.h" 22 - "gc_version.h:$VENDOR_DIR/gc-8.2.10/include/gc_version.h" 23 - "gc_config_macros.h:$VENDOR_DIR/gc-8.2.10/include/gc_config_macros.h" 24 - "gc.h:$VENDOR_DIR/gc-8.2.10/include/gc.h" 25 23 "minicoro.h:$VENDOR_DIR/minicoro/minicoro.h" 26 - "arena.h:$INCLUDE_DIR/arena.h" 27 24 "runtime.h:$INCLUDE_DIR/runtime.h" 28 25 "esm/remote.h:$INCLUDE_DIR/esm/remote.h" 26 + "argtable3.h:$VENDOR_DIR/argtable-v3.3.0.116da6c/src/argtable3.h" 29 27 ) 30 28 31 29 for f in "$INCLUDE_DIR"/modules/*.h; do ··· 71 69 #ifndef LIBANT_H 72 70 #define LIBANT_H 73 71 72 + /* forward declarations */ 73 + struct arg_file; 74 + 74 75 EOF 75 76 76 77 for entry in "${HEADERS[@]}"; do ··· 99 100 continue 100 101 fi 101 102 102 - if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\<config\.h\> ]]; then 103 + if [[ "$line" =~ ^[[:space:]]*#[[:space:]]*include[[:space:]]+\<(config|common|argtable3)\.h\> ]]; then 103 104 continue 104 105 fi 105 106
+2 -2
meson/version/meson.build
··· 4 4 timestamp_opt = get_option('build_timestamp') 5 5 timestamp = timestamp_opt != '' ? timestamp_opt : run_command('date', '+%s', check: true).stdout().strip() 6 6 7 - ant_version = '0.4.0.' + timestamp + '-g' + git_hash 7 + ant_version = '0.4.1.' + timestamp + '-g' + git_hash 8 8 cmd_cc = meson.get_compiler('c') 9 9 10 10 target_triple = run_command(cmd_cc.cmd_array(), '-dumpmachine', check: true).stdout().strip() ··· 22 22 version_conf.set_quoted('ANT_GIT_HASH', git_hash) 23 23 version_conf.set_quoted('ANT_TARGET_TRIPLE', target_triple) 24 24 25 - configure_file( 25 + config_h = configure_file( 26 26 output: 'config.h', 27 27 configuration: version_conf 28 28 )