Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

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

feat: add missing APIs for web line.mjs compatibility on AC Native

- num.parseColor(params): parse color names/RGB from string params
- num.randIntArr(max, len): random int array for rainbow mode
- num.timestamp(): timestamp string
- pen object: pointer_x/y from input state
- net.rewrite/net.log stubs
- pppline(points): polyline drawing on ink chain
- nopaint.mjs module stub: all exports stubbed for import resolution
- color-highlighting.mjs stub for HUD label imports

Web line.mjs should now load and run unchanged on AC Native.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+66
+66
fedac/native/src/js-bindings.c
··· 1474 1474 } else if (strstr(module_name, "pixel-sample")) { 1475 1475 stub_src = "export function decodeBitmapToSample() { return null; }\n" 1476 1476 "export function loadPaintingAsAudio() { return null; }"; 1477 + } else if (strstr(module_name, "nopaint")) { 1478 + stub_src = "export function nopaint_generateColoredLabel() {}\n" 1479 + "export function nopaint_boot() {}\n" 1480 + "export function nopaint_act() {}\n" 1481 + "export function nopaint_paint() {}\n" 1482 + "export function nopaint_is(s) { return false; }\n" 1483 + "export function nopaint_cancelStroke() {}\n" 1484 + "export function nopaint_adjust() {}\n" 1485 + "export function nopaint_handleColor(c, ink) { return ink(c); }\n" 1486 + "export function nopaint_cleanupColor() {}\n" 1487 + "export function nopaint_parseBrushParams(o) { return {color:[], mode:'fill', thickness:1}; }\n" 1488 + "export function nopaint_renderPerfHUD() {}\n" 1489 + "export function nopaint_triggerBakeFlash() {}"; 1490 + } else if (strstr(module_name, "color-highlighting")) { 1491 + stub_src = "export function generateNopaintHUDLabel() { return ''; }\n" 1492 + "export function colorizeColorName() { return ''; }"; 1477 1493 } 1478 1494 1479 1495 // Try to load the module from the filesystem ··· 1611 1627 "};\n" 1612 1628 // num.lerp 1613 1629 "globalThis.__lerp = function(a, b, t) { return a + (b - a) * t; };\n" 1630 + // num.parseColor — parse color from params array (e.g. ["purple"], ["255","0","0"], ["128"]) 1631 + "globalThis.__parseColor = function(params) {\n" 1632 + " if (!params || params.length === 0) return [];\n" 1633 + " var names = {red:[255,0,0],orange:[255,165,0],yellow:[255,255,0],green:[0,128,0],\n" 1634 + " cyan:[0,255,255],blue:[0,0,255],purple:[128,0,128],magenta:[255,0,255],\n" 1635 + " pink:[255,192,203],white:[255,255,255],gray:[128,128,128],grey:[128,128,128],\n" 1636 + " black:[0,0,0],brown:[139,69,19]};\n" 1637 + " var first = params[0];\n" 1638 + " if (typeof first === 'string' && names[first.toLowerCase()]) {\n" 1639 + " var c = names[first.toLowerCase()].slice();\n" 1640 + " if (params.length >= 2) c.push(parseInt(params[1]) || 255);\n" 1641 + " return c;\n" 1642 + " }\n" 1643 + " var nums = params.map(function(p){return parseInt(p)}).filter(function(n){return !isNaN(n)});\n" 1644 + " return nums;\n" 1645 + "};\n" 1646 + // num.randIntArr — array of N random ints in [0, max] 1647 + "globalThis.__randIntArr = function(max, len) {\n" 1648 + " var a = []; for (var i = 0; i < len; i++) a.push(Math.floor(Math.random() * (max + 1)));\n" 1649 + " return a;\n" 1650 + "};\n" 1651 + // num.timestamp — returns a timestamp string 1652 + "globalThis.__timestamp = function() { return Date.now().toString(36); };\n" 1653 + // nopaint_generateColoredLabel stub (native doesn't have HUD color highlighting) 1654 + "globalThis.__nopaint_generateColoredLabel = function() {};\n" 1614 1655 // Typeface constructor stub 1615 1656 "globalThis.__Typeface = function Typeface(name) {\n" 1616 1657 " this.name = name;\n" ··· 1798 1839 // 3D chain methods 1799 1840 JS_SetPropertyStr(ctx, paint_api, "form", JS_NewCFunction(ctx, js_chain_form, "form", 1)); 1800 1841 JS_SetPropertyStr(ctx, paint_api, "ink", JS_NewCFunction(ctx, js_chain_ink, "ink", 4)); 1842 + // pppline — polyline through array of {x,y} points (used by line.mjs for 1px strokes) 1843 + { 1844 + const char *pppline_src = 1845 + "(function(pts) {\n" 1846 + " if (!pts || pts.length < 2) return;\n" 1847 + " for (var i = 0; i < pts.length - 1; i++)\n" 1848 + " line(pts[i].x, pts[i].y, pts[i+1].x, pts[i+1].y);\n" 1849 + "})"; 1850 + JSValue pppline_fn = JS_Eval(ctx, pppline_src, strlen(pppline_src), "<pppline>", JS_EVAL_TYPE_GLOBAL); 1851 + JS_SetPropertyStr(ctx, paint_api, "pppline", pppline_fn); 1852 + } 1801 1853 JS_SetPropertyStr(ctx, global, "__paintApi", JS_DupValue(ctx, paint_api)); 1802 1854 JS_FreeValue(ctx, paint_api); 1803 1855 ··· 5663 5715 JS_SetPropertyStr(ctx, net, "udp", JS_NewCFunction(ctx, js_net_udp, "udp", 0)); 5664 5716 JS_SetPropertyStr(ctx, net, "preload", JS_NewCFunction(ctx, js_promise_null, "preload", 1)); 5665 5717 JS_SetPropertyStr(ctx, net, "pieces", JS_NewCFunction(ctx, js_promise_null, "pieces", 1)); 5718 + JS_SetPropertyStr(ctx, net, "rewrite", JS_NewCFunction(ctx, js_noop, "rewrite", 1)); 5719 + JS_SetPropertyStr(ctx, net, "log", JS_NewCFunction(ctx, js_noop, "log", 2)); 5666 5720 JS_SetPropertyStr(ctx, api, "net", net); 5721 + } 5722 + 5723 + // pen — current pointer position 5724 + if (rt->input) { 5725 + JSValue pen = JS_NewObject(ctx); 5726 + JS_SetPropertyStr(ctx, pen, "x", JS_NewInt32(ctx, rt->input->pointer_x)); 5727 + JS_SetPropertyStr(ctx, pen, "y", JS_NewInt32(ctx, rt->input->pointer_y)); 5728 + JS_SetPropertyStr(ctx, pen, "down", JS_NewBool(ctx, rt->input->pointer_down)); 5729 + JS_SetPropertyStr(ctx, api, "pen", pen); 5667 5730 } 5668 5731 5669 5732 // store ··· 5716 5779 JS_SetPropertyStr(ctx, num, "dist", JS_GetPropertyStr(ctx, global, "__dist")); 5717 5780 JS_SetPropertyStr(ctx, num, "map", JS_GetPropertyStr(ctx, global, "__map")); 5718 5781 JS_SetPropertyStr(ctx, num, "lerp", JS_GetPropertyStr(ctx, global, "__lerp")); 5782 + JS_SetPropertyStr(ctx, num, "parseColor", JS_GetPropertyStr(ctx, global, "__parseColor")); 5783 + JS_SetPropertyStr(ctx, num, "randIntArr", JS_GetPropertyStr(ctx, global, "__randIntArr")); 5784 + JS_SetPropertyStr(ctx, num, "timestamp", JS_GetPropertyStr(ctx, global, "__timestamp")); 5719 5785 JS_SetPropertyStr(ctx, api, "num", num); 5720 5786 } 5721 5787