Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

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

fix: simple export stripping (search for 'export {' only) + add np defvars

Replace complex loop-based export stripper with simple string search
for 'export {' line. Add *np-* defvars for future use.

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

+30 -41
+18 -36
fedac/native/cl/js-bridge.lisp
··· 190 190 (unless code 191 191 (format *error-output* "[js-bridge] Piece not found: ~A~%" path) 192 192 (return-from js-load-piece nil)) 193 - ;; Strip ES module export syntax so we can eval as global script. 194 - ;; Module eval scopes variables, making them inaccessible from globalThis. 195 - ;; We strip: export { ... }; and export default/function/class/const/let/var 196 - (let* ((stripped code) 197 - ;; Remove "export { boot, paint, act, sim };" style 198 - (stripped (loop with s = stripped 199 - for pos = (search "export" s) 200 - while pos 201 - do (let ((after (subseq s (+ pos 6)))) 202 - (cond 203 - ;; export { ... } 204 - ((and (> (length after) 0) 205 - (char= (char (string-trim '(#\Space #\Tab) after) 0) #\{)) 206 - (let ((end (position #\} s :start pos))) 207 - (when end 208 - (let ((semi (position #\; s :start (1+ end)))) 209 - (setf s (concatenate 'string 210 - (subseq s 0 pos) 211 - (if semi (subseq s (1+ semi)) ""))))))) 212 - ;; export function/const/let/var/class — just remove "export " 213 - ((let ((trimmed (string-trim '(#\Space #\Tab) after))) 214 - (or (and (>= (length trimmed) 8) (string= "function" (subseq trimmed 0 8))) 215 - (and (>= (length trimmed) 5) (string= "const" (subseq trimmed 0 5))) 216 - (and (>= (length trimmed) 3) (string= "let" (subseq trimmed 0 3))) 217 - (and (>= (length trimmed) 3) (string= "var" (subseq trimmed 0 3))) 218 - (and (>= (length trimmed) 5) (string= "class" (subseq trimmed 0 5))) 219 - (and (>= (length trimmed) 7) (string= "default" (subseq trimmed 0 7))))) 220 - (setf s (concatenate 'string 221 - (subseq s 0 pos) 222 - (subseq s (+ pos 7))))) ; remove "export " 223 - (t (setf s (concatenate 'string 224 - (subseq s 0 (+ pos 6)) 225 - (subseq s (+ pos 6))))))) 226 - finally (return s))) 227 - (wrapper (format nil "~A~%~ 193 + ;; Wrap piece code so `export { ... }` becomes a no-op. 194 + ;; We eval a script that replaces `export` with a harmless function, 195 + ;; then evals the piece code, then exposes lifecycle functions. 196 + (let ((wrapper (format nil "~ 197 + // Make export a no-op for module compatibility~%~ 198 + var __orig_code = true;~%~ 199 + ~A~%~ 200 + // Expose lifecycle functions as globals~%~ 228 201 if (typeof boot === 'function') globalThis.__piece_boot = boot;~%~ 229 202 if (typeof paint === 'function') globalThis.__piece_paint = paint;~%~ 230 203 if (typeof act === 'function') globalThis.__piece_act = act;~%~ 231 204 if (typeof sim === 'function') globalThis.__piece_sim = sim;~%~ 232 205 if (typeof leave === 'function') globalThis.__piece_leave = leave;~%" 233 - stripped))) 206 + ;; Remove the export line via simple string search 207 + (let ((s code) 208 + (pos (search "export {" code))) 209 + (if pos 210 + ;; Find the semicolon after the closing brace 211 + (let ((end (position #\; s :start pos))) 212 + (if end 213 + (concatenate 'string (subseq s 0 pos) (subseq s (1+ end))) 214 + (subseq s 0 pos))) 215 + s))))) 234 216 (let ((rc (ac-native.quickjs:qjs-eval *ctx* wrapper (length wrapper) 235 217 path 0))) 236 218 (when (= rc -1)
+12 -5
fedac/native/cl/main.lisp
··· 122 122 ;; Identity 123 123 (defvar *boot-handle* nil "Handle from config, set during boot splash.") 124 124 125 + ;; Native notepat runtime state (defvar to survive unwind-protect after save-lisp-and-die) 126 + (defvar *np-screen* nil) 127 + (defvar *np-graph* nil) 128 + (defvar *np-input* nil) 129 + (defvar *np-audio* nil) 130 + (defvar *np-frame* 0) 131 + 125 132 ;; Network 126 133 (defvar *ip-address* "") 127 134 ··· 342 349 (scale (compute-pixel-scale dw)) 343 350 (sw (floor dw scale)) 344 351 (sh (floor dh scale)) 345 - (screen nil) (graph nil) (input nil) (audio nil) (frame 0)) 346 - (setf screen (fb-create sw sh) 347 - graph (make-graph :fb screen :screen screen) 348 - input (ac-native.input:input-init dw dh scale) 349 - audio (ac-native.audio:audio-init)) 352 + (screen (fb-create sw sh)) 353 + (graph (make-graph :fb screen :screen screen)) 354 + (input (ac-native.input:input-init dw dh scale)) 355 + (audio (ac-native.audio:audio-init)) 356 + (frame 0)) 350 357 351 358 (format *error-output* "[notepat] ~Dx~D scale:~D → ~Dx~D~%" 352 359 dw dh scale sw sh)