Short: JS runtime for AmigaOS Author: Juen/R3D+Appendix+Nah-Kolor Uploader: biuro cdlabel info (Pawel Nowak) Type: dev/lang Version: 0.25.0 Requires: 68000+, 1 MB RAM (060/32MB recommended) Architecture: m68k-amigaos A complete JavaScript engine and runtime environment for Classic Amiga, MorphOs and AmigaOs4 Built from scratch in C, targeting MC68000 and AmigaOS 2.0+. Inspired by Node.js, adapted for the Amiga platform. Documentation: http://juen.in/NodeAmiga/ Support author: http://juen.in/support/ Features -------- * JavaScript engine (ES5.1 + ES6+ features) - Arrow functions, classes with inheritance, super(), static - Class fields: public, private (#field), static - Template literals, tagged - Destructuring, spread/rest, default parameters - for-of loops, labeled break/continue - Regex literal /pattern/flags - Optional chaining (?.), nullish coalescing (??) - BigInt (123n, arithmetic, comparison, BigInt()) - let/const block scoping, numeric separators - async/await, Promises, dynamic import() - Generators (function*, yield, yield* delegation) - Async generators (async function*, for await...of) - Generator methods in classes and objects - Automatic Semicolon Insertion (ASI) - Closures, prototype chain * Built-in objects and functions - console (log, error, warn, dir, time/timeEnd, table, count/countReset) - Math (27 functions incl. cbrt/fround/clz32/imul) - JSON (with reviver/replacer) - Date (full API incl. UTC, getUTC*/setUTC*) - RegExp (lookahead, non-capturing groups, quantifiers, lazy, named groups, lookbehind, flags g/i/m/s/u/y) - Buffer (hex/base64) - Promise (then/catch/finally/all/race/allSettled) - Map, Set, WeakMap, WeakSet, Symbol - setTimeout/setInterval/clearTimeout - crypto (MD5, SHA-256), structuredClone - TextEncoder, TextDecoder - Typed Arrays: Uint8Array, Int8Array, Uint16Array, Int16Array, Uint32Array, Int32Array, Float32Array, Float64Array, Uint8ClampedArray, ArrayBuffer, DataView (from/of, forEach/map/filter/find/every/some/reduce, set/fill/slice/subarray/reverse/indexOf/includes/join) - fetch() global HTTP client - performance.now() timer - Error.cause (ES2022) - process.stdout.write, process.stdin.read - process.hrtime, process.nextTick, queueMicrotask * String methods: 29+ (charAt, indexOf, slice, split, replace, replaceAll, trim, includes, startsWith, padStart, normalize, localeCompare, codePointAt, etc.) * Array methods: 37+ (push, pop, map, filter, reduce, reduceRight, sort, find, findLast, findLastIndex, forEach, every, some, splice, flat, flatMap, entries, keys, values, copyWithin, at, Array.from/of/isArray, toReversed, toSorted, toSpliced, with) * Object: keys, values, entries, assign, create, freeze, seal, is, fromEntries, defineProperty/ies, hasOwn, getPrototypeOf, setPrototypeOf, getOwnPropertyNames, getOwnPropertyDescriptor(s), preventExtensions, isExtensible, groupBy, getOwnPropertySymbols, getters/setters * Number: isInteger, isFinite, isNaN, isSafeInteger, parseInt, parseFloat, toString(radix), toFixed, toExponential, toPrecision, constants (EPSILON, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, NaN, Infinity) * Global functions: encodeURIComponent, decodeURIComponent, encodeURI, decodeURI, parseInt, parseFloat, isNaN, isFinite, eval(), fetch() * Symbol: Symbol(), Symbol.for/keyFor, well-known symbols, Symbol as property key, Iterator protocol (Symbol.iterator) * Amiga Intuition GUI bindings - Open windows with title, size, position - Graphics: lines, rects, circles, text, pixels - Mouse and keyboard events - System requesters (alert, confirm) - Screen information query * GadTools GUI toolkit (gui module) - createWindow() with declarative gadget layout - 12 widget types: button, string, text, integer, checkbox, cycle, slider, listview, mx, number, scroller, area (bevel box) - gui.gfx: drawing on GadTools windows (setColor, drawLine, fillRect, drawCircle, drawText, setPixel, setFont, etc.) - innerSize() for drawable area, auto GZZ offset - Resizable windows (GIMMEZEROZERO clipping) - Percentage layout (left: "50%", width: "80%") - Negative positioning (top: -20 = anchor bottom) - flex: true - gadget expands to fill available space - minWidth/minHeight - font: { name, size } per-window custom font (e.g. topaz.font 8 for fixed-width column alignment) - Event-driven: waitEvent/pollEvent, gadgetup/gadgetdown/ mousemove/close/key - evt.x, evt.y mouse coords on gadget events - get/set gadget values at runtime - setTitle, listview dynamic item update - Menu bar: setMenu() with keyboard shortcuts - ASL file requester: fileRequest() with patterns - ASL font requester: fontRequest() - Proper GadTools cleanup * Clipboard module (clipboard) - read() - read text from system clipboard - write(text) - write text - clear() - clear clipboard - Uses IFF FTXT/CHRS via iffparse.library * ARexx module (arexx) - send(port, command) - send ARexx command to app - createPort(name) / closePort() - getMsg() / waitMsg() / reply() - listPorts() - list all public message ports - Uses rexxsyslib.library * FFI module (amiga) - Direct Amiga library function calls from JavaScript - openLibrary(name, version) / closeLibrary(lib) - call(lib, offset, regs) - call any library function with register args - peek8/16/32(addr), poke8/16/32(addr, val) - memory access - peekString(addr), pokeString(addr, str) - allocMem(size, flags) / freeMem(ptr, size) - makeTags(array) - build TagItem array for Amiga tag-based APIs - Full 32-bit unsigned support (0xDEADBEEF etc.) * Interactive debugger (--debug) - Step, next, step-out, continue - Breakpoints by line number - Variable inspection (p varname) - Call stack backtrace (bt) - Source listing around current line * Node.js-compatible modules - require() with caching - CommonJS exports (module.exports) - ES modules: import/export (default, named, namespace) - Dynamic import() expression - Native modules: fs, http, net, buffer, os, child_process, crypto, intuition, gui, readline, dns, clipboard, arexx, amiga - JS modules: path, events, url, querystring, util, stream, assert, repl, timers, string_decoder, punycode, console, constants, zlib, iff * File I/O (fs module) - readFileSync, writeFileSync, appendFileSync - existsSync, unlinkSync, renameSync, statSync - readdirSync, mkdirSync, rmdirSync, copyFileSync - readFile, writeFile (async) - createReadStream, createWriteStream - Full AmigaOS path support (Volume:dir/file) * HTTP/HTTPS server and client - http.createServer() non-blocking, 8 concurrent - http.get(), http.post(), http.request() - HTTPS via AmiSSL (build with -DENABLE_AMISSL) - Auto redirect following (301/302/307) - 10-second socket timeout, dns.lookup() - Requires bsdsocket.library (Roadshow, Miami, AmiTCP) * OS integration - process.platform ("amigaos"), process.arch ("m68k") - process.argv, process.env, process.cwd(), process.exit - os.cpus() (detects 68000/020/030/040/060) - os.freemem(), os.version() (Kickstart version) - child_process.execSync() via SystemTagList() * Interactive REPL with command history (arrow up/down) * Error types: Error, TypeError, RangeError, ReferenceError, SyntaxError, EvalError, URIError * Error messages with filename and line number * Compiler: bundle JS + interpreter into standalone executable - NodeAmiga -compile MyApp script.js - Automatic require() and import dependency resolution - All JS modules bundled into single executable - No NodeAmiga, no libs/ needed to run the output Usage ----- NodeAmiga script.js Execute a JavaScript file NodeAmiga -e "code" Evaluate inline JavaScript NodeAmiga -compile out script Compile to standalone exe NodeAmiga Start interactive REPL NodeAmiga -help Show help NodeAmiga -v Show version NodeAmiga --vm script.js Use bytecode VM (experimental) NodeAmiga --tree script.js Use tree-walking interpreter (default) NodeAmiga --debug script.js Run with interactive debugger NodeAmiga --ast script.js Print AST (debug) Installation ------------ 1. Copy NodeAmiga to C: or any directory in your path 2. Copy the libs/ directory to PROGDIR: (same directory as NodeAmiga), or to LIBS:node/ 3. Optional: copy examples/ for demo scripts Quick test: NodeAmiga -e "console.log('Hello Amiga!')" NodeAmiga examples/hello.js NodeAmiga examples/gui_hello.js NodeAmiga examples/fibonacci.js Compile to standalone exe: NodeAmiga -compile Hello examples/hello.js Hello ; Runs without NodeAmiga or libs/ ! System Requirements ------------------- * MC68000 or higher CPU * AmigaOS 2.04 (Kickstart 37) or higher * Minimum 1 MB RAM (2+ MB recommended) * bsdsocket.library for networking features (Roadshow, Miami, AmiTCP) * No FPU required (software floating-point) Technical Details ----------------- * Engine: custom-built lexer, recursive descent parser with Pratt precedence climbing, tree-walking interpreter (default). A bytecode VM is also bundled (--vm) but currently experimental and disabled by default while issues are sorted out. * Memory: reference counting (no GC pauses), arena allocator for AST, integer cache 0-255 * Stack: auto-allocates 64 KB via StackSwap Included Examples ----------------- hello.js Platform info and greeting fibonacci.js Recursive/iterative benchmark file_io.js File read/write/append http_server.js HTTP server with routing http_client.js HTTP GET and POST requests classes.js ES6 classes with inheritance closures.js Closures, IIFE, module pat. array_fun.js map/filter/reduce/sort regex.js RegExp /literal/ and methods events.js EventEmitter custom events promises.js Promise chains, all, race timers.js setTimeout and setInterval buffer.js Binary data manipulation streams.js Readable/Writable/Transform sysinfo.js Full system info display todo_app.js TODO app with persistence mini_grep.js Pattern search in files url_parser.js URL and query string parsing calculator.js Recursive descent expr parser json_db.js JSON file-based database myip.js Fetch public IP from internet nettime.js Internet time via HTTP API weather.js Weather info for a city download.js Download file and save gui_hello.js Simplest Intuition window gui_demo.js Interactive drawing + mouse gui_calculator.js GadTools calculator (320x200) 3d.js Rotating 3D wireframe cube 3d_tunnel.js Wireframe tunnel fly-through pong.js Bouncing ball (XOR, circle) gui_translator.js Google Translate with GUI gui_window.js GadTools widget gallery gui_menu.js Menu bar + ASL requesters gui_drawing.js gui.gfx primitives (4 scenes) gui_gfx_clock.js Analog clock (resizable) gui_keyboard_and_scrolls.js Arrow keys + scrollers demo gui_weather.js Weather app with GadTools GUI aminet_browser.js Aminet archive browser + GUI aminet_browser_opt.js Optimized variant of aminet_browser gui_disasm.js 68k disassembler for Amiga EXE gui_monitor.js System monitor (mem/tasks/libs) gui_ftp_client.js FTP client (PASV) with GUI gui_extra_demo.js Modal dialogs + image + colour clipboard.js System clipboard read/write arexx.js ARexx port communication dns_lookup.js DNS hostname resolution readline_chat.js Interactive readline + prompt ffi.js Amiga library FFI demo iff_info.js IFF/ILBM/8SVX file viewer Known Limitations ----------------- * No Proxy * await is synchronous (spin-waits on event loop) Version History --------------- 0.25.0 (2026-05-07) Spec correctness pass + memory hardening, driven by a new 2300-assertion test suite - test/test_extra.js (2319 assertions over 50 sections) catches the boundary cases test.js skipped: NaN equality, sparse arrays, refcount stress, proto chain, property descriptors, etc. - parseInt("") / parseFloat("") and any input whose first non-space char is not [-+.0-9] now return NaN. Some libcs ate 'a' as a hex digit and gave 0. - parseFloat("abc") rejects up front instead of relying on strtod's endptr. - JSON.stringify(undefined / function / symbol) returns the JS undefined value (not the string "null"). - JSON.stringify(o, null, "\t") accepts string indent (was numbers only). - JSON.parse on malformed input throws SyntaxError (was returning null). - Object.prototype.constructor now points at the Object global; same for Array.prototype.constructor. - Plain {} now has Object.prototype as proto; Object.getPrototypeOf({}) returns Object.prototype, "hasOwnProperty" in {} works. Object.create(null) still gives a null-proto object. - All built-in prototype methods are now non-enumerable; for-in over a user object no longer yields hasOwnProperty, push, map, etc. - Array's `length` property is non-enum. - Date arithmetic via _timestamp lookup; d2 - d1 returns ms delta (was NaN). - Array.from(Set/Map) and [...Set/Map] walk via [@@iterator]; spread on generators ([...g()]) walks via .next(). - Array length: a[10]=x extends length; a.length=N truncates and deletes orphan entries. - [NaN].includes(NaN) true (SameValueZero). - js_new_number(NaN) no longer aliases to g_int_cache[0]. (NaN >= 0 evaluates true on some -Os/m68k combos, which had been silently turning NaN into 0 everywhere ? Math.sign, isNaN of parseInt failures, etc.) - Custom math_ceil / floor / round ? Amiga -noixemul libc's ceil(0.0) returned 1.0; ours uses long-cast truncation for inputs in long range. - Object.defineProperty {writable:false} enforced via PROP_FLAG_NON_WRITABLE on JsProperty (checked in both js_object_set and js_object_set_by_ref). - Arrow function `this` is lexical: is_- arrow flag on JsFunction; call_function skips the env_define("this") step for arrows so lookup walks up to enclosing scope. - for (let i...) creates a per-iteration binding; closures captured in body see this iteration's value, not the post- update one. Update runs in loop_env so iter_env stays "frozen" for closures. - WeakMap.set / WeakSet.add throw real TypeError on primitive keys (was stderr-only). - readline.createInterface({input: fs.- createReadStream(path)}) drains lines synchronously when 'line' attaches. - Template `${"a"}-${"b"}` produces `a-b` (was `"a"-"b"`). - RegExp.flags string in canonical order gimsuy. - RE_MAX_CAPTURES 16 -> 64; METAR-class patterns with 50+ capture groups now compile + match. RE_MAX_STEPS 100k -> 1M so legitimate big regexes don't spuriously bail. - fetch() Response gains text() and json() methods (were missing ? `await res.text()` called undefined). - fs.writeFileSync(path, buffer) writes raw bytes (was stringifying Buffer to "[object Object]"). - Stack bumped 64 KB -> 256 KB so sum(100)-class recursion fits. - module_cache_cleanup and interp_destroy no longer cascade-release on exit; the pool sweep in value_cleanup handles everything without traversing references. Plugs an ~19 MB-per-run leak that survived process termination. - examples/readline_file.js demonstrates the readline+stream pattern. 0.24.0 (2026-05-05) Readline file streaming + 7 spec bugs caught by 1000-test extra suite - readline.createInterface({input: stream}) now actually fires line/close events (was a stub that ignored input). - Template `${"a"}-${"b"}` produced `"a"-"b"`. eval_template_literal now uses parts-list parity rather than node type to tell template text apart from inline string-literal expressions. - RegExp.flags string was missing; added canonical-order gimsuy string at both construction sites (literal + ctor). - `"hasOwnProperty" in {}` returned false because eval_object never wired up the Object.prototype as new-object proto. - Array sparse assign (a[10]=x) did not bump a.length, and a.length=N did not truncate. Both fixed in eval_assign. - [NaN].includes(NaN) returned false; added SameValueZero NaN special case. - (3.5).toFixed(0) returned "3"; rewrote to scale-and-round so half-up applies at any digits, including digits=0. - New test/test_extra.js with 1010 assertions covering refcount stress, proto chain, NaN equality, sparse arrays, all option combinations. - examples/readline_file.js demonstrates the new readline+stream API. - Makefile uses wildcard for test/*.js. 0.23.0 (2026-05-04) Refcount leak fix, runtime cycle/mx update, diagnostics - FIX: every `var x = LITERAL;` and every property in every `{a: 1, b: 2}` was leaking one refcount. The JsValue could never reach 0 and stayed pinned in the pool for the rest of the process. A budget app with hundreds of object-literal accounts would gradually exhaust the JsProperty pool, causing js_alloc_property to return NULL and env_define to silently fail to add the binding -- the script seemed to "lose" variables (even consts). eval_var_declaration and eval_object_expression now release the extra ref ONLY when the init expression type is one that is guaranteed to produce a fresh JsValue (NUMBER/STRING/BIGINT/OBJECT/ARRAY/BINARY/ UNARY/UPDATE/FUNCTION/NEW/REGEX/TEMPLATE literals). Identifier, member, call, tagged-template, assign, logical, conditional and sequence expressions stay conservative -- they may return a borrowed ref which we must not free. - NEW: gui.set(win, id, items) on cycle and mx (radio) gadgets accepts an array, replacing the items list at runtime. Previously cycle/mx only accepted a number to change the active index, which forced callers to destroy and rebuild the whole window whenever the menu of choices changed. - NEW: process.poolStats() returns the live counts in each internal pool (jsval, jsobj, jsfn, jsprop, env). Useful for spotting refcount leaks before they exhaust the heap. - FIX: env_define, env_set and js_object_set print to stderr when js_alloc_property or PROP_SET_KEY's malloc fails. Previously the property simply didn't get added and the script saw "var undefined" with no clue why. - DOC: docs/limitations.html refreshed -- the entries claiming Array.prototype.sort is bubble sort and that fromCharCode writes only the low byte both pre-dated the 0.22.0 audit and were stale. 0.22.0 (2026-04-30) Raw TCP, FTP client example - NEW: net.connect(host, port [, timeoutMs]) ? synchronous raw-TCP client. Returns a Socket object with .write(data) (String or Buffer), .read(maxLen) (Buffer), .readLine() (String, strips trailing CRLF, null on EOF), .close(), .isOpen() and .setTimeout(ms). Pool of 16 sockets; net_cleanup() closes any survivors on exit so fds don't leak across runs. - NEW: examples/gui_ftp_client.js ? minimal FTP client (passive mode) using the new net.connect. Supports directory listing, change-dir, upload, download, delete, mkdir. Blocks the GUI during transfers and shows progress in the status bar. - FIX: gui listview gadgets now keep the clicked row visually highlighted (GTLV_ShowSelected was missing, so the selection vanished on mouse-up). - FIX: socket.write now loops until every byte has left the socket (or fails). Bsdsocket's send() is allowed to return a short write -- the previous one-shot send would silently truncate uploads of files larger than a few kB. - FIX: socket.readLine drains the rest of an over-long line up to the next LF before returning, so the next readLine starts on a fresh record instead of picking up the truncated tail as a new line. - FIX: gui_ftp_client wraps every transfer in try/finally so a recv timeout / connection drop releases the data socket. After enough errors the pool of 16 sockets used to fill up and even reconnect would fail. - NEW: gui_ftp_client also parses Windows / IIS LIST output ("MM-DD-YY HH:MMxM