207 Commits

Author SHA1 Message Date
John Alanbrook
cecf841d82 managed frames 2025-12-29 22:58:51 -06:00
John Alanbrook
a0038a7ab2 blob 2025-12-29 17:53:21 -06:00
John Alanbrook
d0674e7921 remove internal scripts 2025-12-29 15:45:21 -06:00
John Alanbrook
b586df63ad move internals to pure C 2025-12-29 14:28:54 -06:00
John Alanbrook
05b57550da vm trampoline setup 2025-12-29 13:01:05 -06:00
John Alanbrook
fa616ee444 trampoline 2025-12-29 01:35:57 -06:00
John Alanbrook
0720368c48 go 2025-12-29 01:26:25 -06:00
John Alanbrook
4f3e2819fe var behaves like let 2025-12-29 00:48:28 -06:00
John Alanbrook
3b53a9dcc3 prop ic 2025-12-28 23:55:57 -06:00
John Alanbrook
6d7581eff8 IC structure 2025-12-28 23:38:10 -06:00
John Alanbrook
dca1963b5d null access 2025-12-28 22:57:53 -06:00
John Alanbrook
1833a3c74c remove some globals 2025-12-28 22:46:05 -06:00
John Alanbrook
4201be47ee dump_profile 2025-12-28 21:53:12 -06:00
John Alanbrook
c388fb311b larger test suite 2025-12-28 21:04:30 -06:00
John Alanbrook
c432bc211f bench 2025-12-28 19:50:27 -06:00
John Alanbrook
5f471ee003 fix array length creation 2025-12-28 16:22:11 -06:00
John Alanbrook
5d384e2706 fix meme 2025-12-28 16:14:29 -06:00
John Alanbrook
a0daf98ca8 patch so core path is recognized 2025-12-28 16:03:13 -06:00
John Alanbrook
3b42426e6f string + number throws 2025-12-28 14:25:57 -06:00
John Alanbrook
a035e28100 string add throw 2025-12-28 13:43:10 -06:00
John Alanbrook
4f076bc868 better commands 2025-12-27 13:51:11 -06:00
John Alanbrook
c8831c85d0 proper dylib loading order 2025-12-27 13:15:59 -06:00
John Alanbrook
3cf7aa473e add wf and w16 fns to blob 2025-12-22 16:29:38 -06:00
John Alanbrook
8b9e088385 util 2025-12-21 10:37:02 -06:00
John Alanbrook
d50f4119ee remove global 2025-12-18 18:43:23 -06:00
John Alanbrook
aa18a8c8d2 remove json as a global 2025-12-18 11:20:39 -06:00
John Alanbrook
04a648a73e mkdocs website 2025-12-17 03:45:09 -06:00
John Alanbrook
363ca1c3c1 docs revamp 2025-12-17 02:53:01 -06:00
John Alanbrook
3211b59408 no more js 2025-12-17 00:48:02 -06:00
John Alanbrook
169448f156 fix random() 2025-12-14 13:30:46 -06:00
John Alanbrook
b98cef6e8d add pronto and tests 2025-12-13 19:14:20 -06:00
John Alanbrook
33dc6b053c fix fetch failure 2025-12-12 17:27:51 -06:00
John Alanbrook
6ff54d8347 fix module resolution 2025-12-11 23:18:58 -06:00
John Alanbrook
bf421743a5 fix scheduler 2025-12-11 14:42:30 -06:00
John Alanbrook
5a3e260821 simplify docs 2025-12-10 15:18:53 -06:00
John Alanbrook
d0f5dc6951 playdate cake 2025-12-10 15:01:20 -06:00
John Alanbrook
752479e250 fix links, fix hot reload 2025-12-10 01:37:21 -06:00
John Alanbrook
37f2cff6ec fix 2025-12-09 23:19:25 -06:00
John Alanbrook
657e342159 core is now at packages/core 2025-12-09 01:00:10 -06:00
John Alanbrook
de4c9c724e fixing shop 2025-12-09 00:48:59 -06:00
John Alanbrook
5c5427fdd9 reduce shop 2025-12-08 19:50:09 -06:00
John Alanbrook
38d6b4d4e8 turn into a cell package 2025-12-08 17:39:17 -06:00
John Alanbrook
aae267a6e9 dynamic works; static works for non cell builds 2025-12-08 15:27:20 -06:00
John Alanbrook
dbc1b2c31e reorganize 2025-12-08 13:49:27 -06:00
John Alanbrook
32301cf61f remove some comments 2025-12-08 13:38:18 -06:00
John Alanbrook
270521a01e fix link and remove 2025-12-08 13:22:07 -06:00
John Alanbrook
401f69b503 global cell shops 2025-12-08 13:01:44 -06:00
John Alanbrook
1bcdab64ff add toolchain targets; better names for logging 2025-12-07 18:49:05 -06:00
John Alanbrook
107c4a5dce tests can now start actor based tests 2025-12-07 15:35:45 -06:00
John Alanbrook
16aba47782 packing 2025-12-07 13:50:57 -06:00
John Alanbrook
14cf48931d add emscripten target 2025-12-07 11:54:03 -06:00
John Alanbrook
c24a5079cb playdate support 2025-12-07 04:04:11 -06:00
John Alanbrook
ce5949e0ee remove tracy, mimalloc, enet subprojects; now it's just enet.h 2025-12-07 00:44:02 -06:00
John Alanbrook
3f2b4177d6 start playdate support 2025-12-06 17:35:23 -06:00
John Alanbrook
687c6d264f playdate cross file 2025-12-06 15:20:40 -06:00
John Alanbrook
abf1332bf5 remove curl dep 2025-12-06 14:54:00 -06:00
John Alanbrook
7c0f4dcd5f fixme freeze 2025-12-06 12:30:14 -06:00
John Alanbrook
33ebd8f45d more debug functions 2025-12-06 12:02:19 -06:00
John Alanbrook
5ac58dfbb0 reload module 2025-12-06 11:33:34 -06:00
John Alanbrook
825c6aa284 fix why 2025-12-06 10:37:00 -06:00
John Alanbrook
3bcc642158 add linking 2025-12-06 10:35:06 -06:00
John Alanbrook
ea510d609f fix tests 2025-12-05 23:21:07 -06:00
John Alanbrook
744f64b83b remove sdl header reqs; better compile invalidation 2025-12-05 19:31:56 -06:00
John Alanbrook
7a6209df72 add tests 2025-12-05 15:38:38 -06:00
John Alanbrook
dde0efc8aa better list; add why 2025-12-05 14:57:50 -06:00
John Alanbrook
d6daa97ac7 main wrapper 2025-12-05 12:52:40 -06:00
John Alanbrook
230880a02f fix 2025-12-05 08:30:51 -06:00
John Alanbrook
d229784d8d fix cached modules 2025-12-04 21:54:38 -06:00
John Alanbrook
19e747c120 fixed linking 2025-12-04 20:15:32 -06:00
John Alanbrook
22d3adca93 update local dirs 2025-12-04 14:56:11 -06:00
John Alanbrook
20fa012b57 add symlink capabilities to fd.c 2025-12-04 14:19:02 -06:00
John Alanbrook
95ac4bd096 fix blob 2025-12-04 13:54:00 -06:00
John Alanbrook
6b8464aca4 fix blob 2025-12-04 07:35:31 -06:00
John Alanbrook
39ac340e01 compilation 2025-12-03 23:42:19 -06:00
John Alanbrook
fc87c05daf ls 2025-12-03 20:18:46 -06:00
John Alanbrook
1886f10211 add list and ls functions 2025-12-03 19:03:01 -06:00
John Alanbrook
c8ce152ade use build if built 2025-12-03 16:40:37 -06:00
John Alanbrook
1a9734f265 grabbing module works now 2025-12-03 15:39:49 -06:00
John Alanbrook
ac718fdb13 remove some scripts 2025-12-03 15:34:01 -06:00
John Alanbrook
1769d7f456 update shop 2025-12-03 15:29:42 -06:00
John Alanbrook
85e0e3dab1 check hashes on cached files 2025-12-03 13:53:47 -06:00
John Alanbrook
ddfa636ac0 locks 2025-12-03 09:11:51 -06:00
John Alanbrook
ee3a890d4a fix 2025-12-03 08:28:33 -06:00
John Alanbrook
76bdccc4ee fix 2025-12-03 07:59:31 -06:00
John Alanbrook
814ee7c0db use 2025-12-03 06:41:18 -06:00
John Alanbrook
0c5609c4e9 fix compile 2025-12-02 06:45:09 -06:00
John Alanbrook
20f5e4e81c fix random numer generating; add cell_random_fit to complement cell_random) 2025-12-01 16:26:27 -06:00
John Alanbrook
139405a30b update miniz to 3.1 2025-12-01 16:10:58 -06:00
John Alanbrook
495f145524 single threaded executor 2025-12-01 15:54:12 -06:00
John Alanbrook
6cfba975e5 remove sdl dependency 2025-12-01 15:38:04 -06:00
John Alanbrook
fd4222f196 fix compile 2025-12-01 09:10:12 -06:00
John Alanbrook
5971924785 scheduler 2025-12-01 08:47:09 -06:00
John Alanbrook
8e4c60baf3 remove sdl from os.c 2025-12-01 06:21:00 -06:00
John Alanbrook
53085d7e3a remove jsffi 2025-11-30 20:43:25 -06:00
John Alanbrook
c88d551cad remove qjs_wota 2025-11-30 20:30:57 -06:00
John Alanbrook
4b5ceb4c02 fix compile warnings; remove soloud 2025-11-30 19:33:04 -06:00
John Alanbrook
2b90a160ba remove qjs_macros.h 2025-11-30 17:28:05 -06:00
John Alanbrook
4df134b327 intenrals no longer depend on cellfs 2025-11-30 17:24:02 -06:00
John Alanbrook
b44d79ccab compile cpp files 2025-11-30 16:37:36 -06:00
John Alanbrook
b29cdc8b93 add variable linker flags per platform 2025-11-30 14:59:35 -06:00
John Alanbrook
42bede58bc js doc 2025-11-30 01:26:59 -06:00
John Alanbrook
3800c23eae remove num.c 2025-11-29 23:47:47 -06:00
John Alanbrook
8fa80b4720 move away from cellfs 2025-11-29 23:44:40 -06:00
John Alanbrook
acf842e2a1 remove cell doc 2025-11-29 23:35:10 -06:00
John Alanbrook
1d295d11e5 modifications to importing 2025-11-29 18:34:37 -06:00
John Alanbrook
0ddbc3e953 remove more unneeded from the std 2025-11-29 17:26:29 -06:00
John Alanbrook
9f696a0342 random 2025-11-29 16:43:03 -06:00
John Alanbrook
efe93b7206 move random number gen 2025-11-29 14:22:19 -06:00
John Alanbrook
a9cff079d9 cell2 2025-11-29 12:40:59 -06:00
John Alanbrook
d361cb0555 get c symbol 2025-11-28 13:07:36 -06:00
John Alanbrook
b577e889a1 script folder 2025-11-26 20:25:00 -06:00
John Alanbrook
e28e241485 cleanup 2025-11-26 18:22:22 -06:00
John Alanbrook
2110688fa5 strip out prosperon from cell 2025-11-26 12:23:57 -06:00
John Alanbrook
fd19ecb41e sdl audio 2025-11-26 02:07:44 -06:00
John Alanbrook
155d0bf4b5 remove quirc 2025-11-25 23:36:56 -06:00
John Alanbrook
311a57b1e2 header cleanup 2025-11-25 21:05:48 -06:00
John Alanbrook
2cf94f7c57 allow installing headers for cell mods 2025-11-25 16:06:48 -06:00
John Alanbrook
9b19d19698 qopconv; now uses cell's own qopconv for building 2025-11-25 12:25:28 -06:00
John Alanbrook
67badc3e48 remove physfs; cellfs now is at parity 2025-11-25 09:56:44 -06:00
John Alanbrook
820413a72a cellfs 2025-11-25 09:16:50 -06:00
John Alanbrook
8bc31e3ac6 fetch 2025-11-24 23:08:40 -06:00
John Alanbrook
b613c7b6fa qop 2025-11-24 08:40:20 -06:00
John Alanbrook
8bdcaf7d9d qop 2025-11-23 11:20:59 -06:00
John Alanbrook
2beb369af9 move rtree to its own lib 2025-11-23 10:11:54 -06:00
John Alanbrook
44c46f2bb4 use curl 2025-11-22 22:25:59 -06:00
John Alanbrook
20685d80f1 add big file test to cellfs 2025-11-22 20:23:10 -06:00
John Alanbrook
532cfd0ed0 initial attempt at cellfs 2025-11-22 19:07:22 -06:00
John Alanbrook
34de9e6dc4 remove prosperon 2025-11-22 17:46:53 -06:00
John Alanbrook
9881158e62 init 2025-11-22 15:02:21 -06:00
John Alanbrook
be416b0124 clay 2025-11-22 01:48:30 -06:00
John Alanbrook
906b60276a update dmon to work on macos 2025-11-22 01:00:03 -06:00
John Alanbrook
d61f98f81d hover 2025-11-22 00:37:05 -06:00
John Alanbrook
dbf9f8ef30 clay 2025-11-18 19:12:30 -06:00
John Alanbrook
0082eab729 clay accepts any size canvas now 2025-11-06 18:23:39 -06:00
John Alanbrook
60d2d3b8d6 fix text 2025-11-06 18:11:01 -06:00
John Alanbrook
0dd4ad8046 fix font 2025-11-06 15:02:03 -06:00
John Alanbrook
c02b42f710 attempting to fix text wrapping ... 2025-11-06 14:47:36 -06:00
John Alanbrook
6961e19114 clay tree 2025-11-06 13:49:51 -06:00
John Alanbrook
721ac3bb93 fix word wrap meausrement 2025-11-06 13:15:38 -06:00
John Alanbrook
768ad399de clay recognize text size 2025-11-05 17:40:01 -06:00
John Alanbrook
a05dda4914 text wrap 2025-11-04 19:16:36 -06:00
John Alanbrook
149ee23e45 imgui with sdl gpu 2025-11-03 23:24:34 -06:00
John Alanbrook
c9b504ead4 feat: improve image and text rendering defaults
- Added default dimensions for images when width/height not specified, using original image size
- Enhanced text rendering to use natural text dimensions when width/height not provided
- Disabled file monitoring system by nullifying dmon to prevent unnecessary file watching
2025-11-03 14:00:02 -06:00
John Alanbrook
a8eed4e0d8 fix clay 2025-11-01 14:12:58 -05:00
John Alanbrook
708c01ee29 use prosperon.camera 2025-10-26 13:59:08 -05:00
John Alanbrook
8a33be3550 fix camera 2025-10-24 12:45:39 -05:00
John Alanbrook
175146ab37 sprites don't warp 2025-10-24 11:06:37 -05:00
John Alanbrook
ef7b492984 update render 2025-10-23 15:10:41 -05:00
John Alanbrook
923b5bc3d6 tilemap no longer uses ppu 2025-10-09 03:32:08 -05:00
John Alanbrook
5b2a88d520 fix nota 2025-09-15 22:52:55 -05:00
John Alanbrook
b5496d93bc refactor out duplicate and dead code 2025-08-08 14:40:59 -04:00
John Alanbrook
faf19db27e hud cursor coordinates 2025-08-04 21:29:33 -05:00
John Alanbrook
07595aad63 gpu backend uniform binding 2025-08-01 13:13:54 -05:00
John Alanbrook
8033c161d0 change pipelines 2025-08-01 06:35:25 -05:00
John Alanbrook
625503e654 ppu rendering 2025-08-01 05:46:33 -05:00
John Alanbrook
6a9a1a90dd add image conversion functions 2025-07-31 13:18:18 -05:00
John Alanbrook
ce5b4950d4 camera render to surface 2025-07-30 08:47:11 -05:00
John Alanbrook
cba6f4fd59 gpu renderer 2025-07-29 19:14:58 -05:00
John Alanbrook
e5c19e7e80 working gpu renderer 2025-07-29 15:15:18 -05:00
John Alanbrook
09c3d5cc4e sdl 3 gpu 2025-07-28 16:34:29 -05:00
John Alanbrook
5ae95aee01 render update 2025-07-27 17:08:29 -05:00
John Alanbrook
d5789598a0 clay screen res 2025-07-26 23:02:41 -05:00
John Alanbrook
8ffb4ec73a fix crash for mouse y inversion 2025-07-26 17:45:26 -05:00
John Alanbrook
fecc4b1285 tilemap clear 2025-07-25 14:29:59 -05:00
John Alanbrook
f82d924577 tween cancel 2025-07-23 23:33:25 -05:00
John Alanbrook
f389609bd9 improvements 2025-07-21 14:42:26 -05:00
John Alanbrook
ff7b2f4db7 add scale to draw2d image 2025-07-20 11:48:05 -05:00
John Alanbrook
8fb50a129f add gamepad type grabbing 2025-07-19 15:29:29 -05:00
John Alanbrook
b3c4b1fee9 tween timelines 2025-07-19 13:43:21 -05:00
John Alanbrook
bb3c2c34d0 add tween update callback 2025-07-19 07:52:41 -05:00
John Alanbrook
7fb0d9e80a fix sound destruction 2025-07-18 14:20:33 -05:00
John Alanbrook
f49d4180ed warning when compiled without profiling when attempting to enable 2025-07-18 06:31:11 -05:00
John Alanbrook
7bfd244bf2 add compile time configs for tracy, mimalloc and qrencode 2025-07-18 05:23:00 -05:00
John Alanbrook
881407a64f massively expand steam api 2025-07-17 20:28:47 -05:00
John Alanbrook
e677832b12 fix dmon leak; fix underlings not stopping when overling crashes 2025-07-17 16:32:22 -05:00
John Alanbrook
13c1e7560a empty text works 2025-07-16 20:18:50 -05:00
John Alanbrook
2e275adcd2 bug fix: graphics now correctly returns frames of single anims 2025-07-16 18:11:38 -05:00
John Alanbrook
2607604a0b play gifs with strings 2025-07-16 17:45:12 -05:00
John Alanbrook
d1d9a296a8 separate clay layout and clay input 2025-07-16 14:51:19 -05:00
John Alanbrook
7edbb85e4e clay id handling 2025-07-16 14:37:38 -05:00
John Alanbrook
874252db87 fix text menu render 2025-07-16 05:03:40 -05:00
John Alanbrook
13dd685f65 render layers 2025-07-15 20:33:55 -05:00
John Alanbrook
4b817b8d1b text drawing 2025-07-15 16:22:11 -05:00
John Alanbrook
09b78781e6 animations 2025-07-15 15:06:06 -05:00
John Alanbrook
19ce1008b1 emitter 2025-07-14 09:52:25 -05:00
John Alanbrook
d1c7ff768d prosperon module 2025-07-14 03:14:06 -05:00
John Alanbrook
0d97b47728 support for gamepad events 2025-07-12 22:38:18 -05:00
John Alanbrook
c87f85cf6c Update files for cross compilation fixes; add dockerfiles for windows/linux/emscripten builds; add commands to makefile to build via dockerfiles
Some checks failed
Build and Deploy / build-macos (push) Failing after 29s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
2025-07-12 20:39:25 -05:00
John Alanbrook
f0afdfc7d9 add base64 and base64url encoder/decoders 2025-07-12 10:31:54 -05:00
John Alanbrook
ac9f40fd26 add set window size 2025-07-11 21:22:10 -05:00
John Alanbrook
39152c1eb2 fix base32 conversion/deconversion 2025-07-11 19:38:49 -05:00
John Alanbrook
6ff50cb521 add combo box to imgui 2025-07-11 14:11:34 -05:00
John Alanbrook
2b7b3985d5 tilemap render 2025-07-10 18:10:55 -05:00
John Alanbrook
a9b59750e3 fix mouse pos 2025-07-09 22:55:41 -05:00
John Alanbrook
525263a8a6 add imgui 2025-07-08 01:43:52 -05:00
John Alanbrook
310a0db99e fix draw 2025-07-07 18:51:18 -05:00
John Alanbrook
6e66bf59f6 input reports mod keys now 2025-07-07 15:26:45 -05:00
John Alanbrook
71c0056df4 layout uses x,y 2025-07-06 20:35:15 -05:00
John Alanbrook
d4f0059419 add benchmark and cell doc 2025-07-05 10:25:27 -05:00
John Alanbrook
d52d50fe61 fixes for gameplay 2025-07-05 10:24:09 -05:00
John Alanbrook
1bc34bb99c fix some rendering bug 2025-06-24 08:33:29 -05:00
John Alanbrook
8ac78e0be6 add layout 2025-06-23 22:58:25 -05:00
John Alanbrook
dca3ede464 add function disassembler 2025-06-23 21:28:15 -05:00
John Alanbrook
7b622d9788 initial attempt at adding IC 2025-06-23 17:20:39 -05:00
John Alanbrook
42087910ab remove proxy and many exotic methods 2025-06-23 15:32:05 -05:00
John Alanbrook
c581935fd8 add detail to cell.md 2025-06-23 10:21:33 -05:00
John Alanbrook
632b038561 remove last two master updates and remove proxy 2025-06-23 10:21:07 -05:00
922 changed files with 44210 additions and 240700 deletions

View File

@@ -1,17 +0,0 @@
sdl_video = "main"
[dependencies]
extramath = "https://gitea.pockle.world/john/extramath@master"
[system]
ar_timer = 60
actor_memory = 0
net_service = 0.1
reply_timeout = 60
actor_max = "10_000"
stack_max = 0
[actors]
[actors.prosperon/sdl_video]
main = true
[actors.prosperon/prosperon]
main = true
[actors.prosperon]
main = true

View File

@@ -1,30 +0,0 @@
# Dockerfile.alpine
FROM alpine:edge
# Enable the edge and edge/community repositories.
# If you already have those in your base image, you might not need these echo lines.
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories && \
echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
# Update indexes and install packages
RUN apk update && \
apk add --no-cache \
build-base \
binutils \
mold \
meson \
cmake \
ninja \
git \
pkgconf \
ccache \
nodejs \
npm \
zip \
alsa-lib-dev \
pulseaudio-dev \
libudev-zero-dev \
wayland-dev \
wayland-protocols \
mesa-dev \
sdl3

View File

@@ -1,32 +0,0 @@
FROM ubuntu:plucky
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip \
libasound2-dev \
libpulse-dev \
libudev-dev \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxss-dev \
libegl1-mesa-dev \
libgl1-mesa-dev \
cmake \
ninja-build \
git \
build-essential \
binutils \
mold \
pkg-config \
meson \
ccache \
mingw-w64 \
wine \
npm nodejs zip && \
rm -rf /var/lib/apt/lists/*

View File

@@ -1,15 +0,0 @@
FROM ubuntu:plucky
RUN apt-get update && \
apt-get install -y --no-install-recommends \
mingw-w64 \
cmake \
ninja-build \
git \
build-essential \
binutils \
pkg-config \
zip \
ccache \
npm nodejs && \
rm -rf /var/lib/apt/lists/*

View File

@@ -1,304 +0,0 @@
name: Build and Deploy
on:
push:
branches: [ "*" ]
tags: [ "v*" ]
pull_request:
jobs:
# ──────────────────────────────────────────────────────────────
# LINUX BUILD
# ──────────────────────────────────────────────────────────────
build-linux:
runs-on: ubuntu-latest
container:
image: gitea.pockle.world/john/prosperon/linux:latest
steps:
- name: Check Out Code
uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Build Prosperon (Linux)
run: |
meson setup build -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true
meson compile -C build
- name: Test Prosperon (Linux)
env: { TRACY_NO_INVARIANT_CHECK: 1 }
run: |
meson test --print-errorlogs -C build
- name: Upload Test Log (Linux)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testlog-linux
path: build/meson-logs/testlog.txt
- name: Upload Artifact (Linux)
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: prosperon-artifacts-linux
path: build/prosperon
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.pockle.world
username: ${{ secrets.USER_GITEA }}
password: ${{ secrets.TOKEN_GITEA }}
- name: Determine Docker Tag
id: docker_tag
run: |
if [[ "${{ github.ref }}" =~ ^refs/tags/v.* ]]; then
TAG=$(echo "${{ github.ref }}" | sed 's#refs/tags/##')
echo "tag=$TAG" >> $GITHUB_OUTPUT
else
echo "tag=latest" >> $GITHUB_OUTPUT
fi
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: gitea.pockle.world/john/prosperon:${{ steps.docker_tag.outputs.tag }}
platforms: linux/amd64
# ──────────────────────────────────────────────────────────────
# WINDOWS BUILD (MSYS2 / CLANG64)
# ──────────────────────────────────────────────────────────────
build-windows:
runs-on: win-native
strategy:
matrix: { msystem: [ CLANG64 ] }
steps:
- name: Check Out Code
uses: actions/checkout@v4
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
cache: true
install: |
git zip gzip tar base-devel
pacboy: |
meson
cmake
toolchain
- name: Build Prosperon (Windows)
shell: msys2 {0}
run: |
meson setup build -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true -Dtracy:only_localhost=true -Dtracy:no_broadcast=true
meson compile -C build
- name: Test Prosperon (Windows)
shell: msys2 {0}
env:
TRACY_NO_INVARIANT_CHECK: 1
run: |
meson test --print-errorlogs -C build
- name: Upload Test Log (Windows)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testlog-windows
path: build/meson-logs/testlog.txt
- name: Upload Artifact (Windows)
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: prosperon-artifacts-windows
path: build/prosperon.exe
# ──────────────────────────────────────────────────────────────
# MACOS BUILD
# ──────────────────────────────────────────────────────────────
build-macos:
runs-on: macos-latest
steps:
- name: Check Out Code
uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Build Prosperon (macOS)
run: |
meson setup build -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true
meson compile -C build
- name: Test Prosperon (macOS)
run: |
meson test --print-errorlogs -C build
- name: Upload Test Log (macOS)
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: testlog-macos
path: build/meson-logs/testlog.txt
- name: Upload Artifact (macOS)
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v3
with:
name: prosperon-artifacts-macos
path: build/prosperon
# ──────────────────────────────────────────────────────────────
# PACKAGE CROSS-PLATFORM DIST
# ──────────────────────────────────────────────────────────────
package-dist:
needs: [ build-linux, build-windows, build-macos ]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Get Latest Tag
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Download Linux Artifacts
uses: actions/download-artifact@v3
with:
name: prosperon-artifacts-linux
path: linux_artifacts
- name: Download Windows Artifacts
uses: actions/download-artifact@v3
with:
name: prosperon-artifacts-windows
path: windows_artifacts
- name: Download macOS Artifacts
uses: actions/download-artifact@v3
with:
name: prosperon-artifacts-macos
path: mac_artifacts
- name: Create Dist Folder
run: |
mkdir -p dist/linux dist/win dist/mac
cp README.md dist/
cp license.txt dist/
cp -r examples dist/
cp linux_artifacts/* dist/linux/
cp windows_artifacts/* dist/win/
cp mac_artifacts/* dist/mac/
- name: Package Final Dist
run: |
TAG=${{ steps.get_tag.outputs.tag }}
zip -r "prosperon-${TAG}.zip" dist
echo "Created prosperon-${TAG}.zip"
- name: Upload Final Dist
uses: actions/upload-artifact@v3
with:
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
path: "prosperon-${{ steps.get_tag.outputs.tag }}.zip"
# ──────────────────────────────────────────────────────────────
# DEPLOY TO ITCH.IO (single ZIP containing all OSes)
# ──────────────────────────────────────────────────────────────
deploy-itch:
needs: [ package-dist ]
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Get Latest Tag
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Download Final Distribution
uses: actions/download-artifact@v3
with:
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
path: dist
- name: Set up Butler
uses: jdno/setup-butler@v1
- name: Push to itch.io
run: |
butler push "dist/prosperon-${{ steps.get_tag.outputs.tag }}.zip" \
${{ secrets.ITCHIO_USERNAME }}/prosperon:universal \
--userversion ${{ steps.get_tag.outputs.tag }}
env:
BUTLER_API_KEY: ${{ secrets.ITCHIO_API_KEY }}
# ──────────────────────────────────────────────────────────────
# DEPLOY TO SELF-HOSTED GITEA
# ──────────────────────────────────────────────────────────────
deploy-gitea:
needs: [ package-dist ]
runs-on: ubuntu-latest
steps:
- name: Check Out Code
uses: actions/checkout@v3
with: { fetch-depth: 0 }
- name: Get Latest Tag & Commit Message
id: get_tag
run: |
TAG=$(git describe --tags --abbrev=0)
COMMIT_MSG=$(git log -1 --pretty=%B "$TAG")
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "commit_msg=$COMMIT_MSG" >> $GITHUB_OUTPUT
- name: Download Final Distribution
uses: actions/download-artifact@v3
with:
name: "prosperon-${{ steps.get_tag.outputs.tag }}"
path: dist
- name: Create / Update Gitea Release
run: |
TAG=${{ steps.get_tag.outputs.tag }}
ZIP=dist/prosperon-${TAG}.zip
BODY=$(echo "${{ steps.get_tag.outputs.commit_msg }}" | jq -R -s '.')
RELEASE=$(curl -s -H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/tags/$TAG" | jq -r '.id')
if [ "$RELEASE" = "null" ] || [ -z "$RELEASE" ]; then
RELEASE=$(curl -X POST \
-H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"target_commitish\":\"${{ github.sha }}\",\"name\":\"$TAG\",\"body\":$BODY,\"draft\":false,\"prerelease\":false}" \
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases" | jq -r '.id')
fi
curl -X POST \
-H "Authorization: token ${{ secrets.TOKEN_GITEA }}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$ZIP" \
"https://gitea.pockle.world/api/v1/repos/john/prosperon/releases/$RELEASE/assets?name=prosperon-${TAG}.zip"
env:
TOKEN_GITEA: ${{ secrets.TOKEN_GITEA }}

7
.gitignore vendored
View File

@@ -21,3 +21,10 @@ steam/
subprojects/*/
build_dbg/
modules/
sdk/
artifacts/
discord_social_sdk/
discord_partner_sdk/
steam_api64.dll
subprojects/.wraplock
.gemini

View File

@@ -1,26 +0,0 @@
# AGENTS.md
## Project Overview
This is a game engine developed using a QuickJS fork as its scripting language. It is an actor based system, based on Douglas Crockford's Misty. It is a Meson compiled project with a number of dependencies.
## File Structure
- `source/`: Contains the C source code
- `scripts/`: Contains script code that is loaded on executable start, and modules
- `shaders/`: Contains shaders that ship with the engine (for shader based backends)
- `benchmarks/`: Benchmark programs for testing speed
- `tests/`: Unit tests
- `examples/`: Contains full game examples
## Coding Practices
- Use K&R style C
- Javascript style prefers objects and prototypical inheritence over ES6 classes, liberal use of closures, and var everywhere
## Instructions
- When generating code, adhere to the coding practices outlined above.
- When adding new features, ensure they align with the project's goals.
- When fixing bugs, review the code carefully before making changes.
- When writing unit tests, cover all important scenarios.
## Compiling, running, and testing
- To compile the code, run "make", which generates a prosperon executable in build_dbg/, and copy it into the root folder
- Run a test by giving it as its command: so ./prosperon tests/overling.js would run the test overling.js, ./prosperon tests/nota.js runs the nota benchmark

405
CLAUDE.md
View File

@@ -1,405 +0,0 @@
# CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
## Build Commands
### Build variants
- `make` - Make and install debug version. Usually all that's needed.
- `make fast` - Build optimized version
- `make release` - Build release version with LTO and optimizations
- `make small` - Build minimal size version
- `make web` - Build for web/emscripten platform
- `make crosswin` - Cross-compile for Windows using mingw32
### Testing
After install with 'make', just run 'cell' and point it at the actor you want to launch. "cell tests/toml" runs the actor "tests/toml.js"
## Scripting language
This is called "cell", but it is is a variant of javascript and extremely similar.
### Common development commands
- `meson setup build_<variant>` - Configure build directory
- `meson compile -C build_<variant>` - Compile in build directory
- `./build_dbg/prosperon examples/<example>` - Run example from build directory
- Copy prosperon to game directory and run: `cp build_dbg/prosperon <game-dir>/ && cd <game-dir> && ./prosperon`
## Architecture Overview
Prosperon is an actor-based game engine inspired by Douglas Crockford's Misty system. Key architectural principles:
### Actor Model
- Each actor runs on its own thread
- Communication only through message passing (no shared JavaScript objects)
- Hierarchical actor system with spawning/killing
- Actor lifecycle: awake, update, draw, garbage collection
### JavaScript Style Guide
- Use `use()` function for imports (Misty-style, not ES6 import/export)
- Prefer closures and javascript objects and prototypes over ES6 style classes
- Follow existing JavaScript patterns in the codebase
- Functions as first-class citizens
- Do not use const or let; only var
### Core Systems
1. **Actor System** (scripts/core/engine.js)
- Message passing via `send()`, `$_.receive()`
- Actor spawning/management
- Register-based component system (update, draw, gui, etc.)
2. **Module System**
- `use()` function for loading modules
- Module paths: `scripts/modules/`, `scripts/modules/ext/`
- Custom QuickJS build with embedded C modules
3. **Build System**
- Meson build configuration (Makefile is convenience wrapper)
- Multiple platform targets (Windows, macOS, Linux, Web)
- Custom QuickJS build in `subprojects/`
- Uses SDL3 for cross-platform support
### Engine Entry Points
- `source/prosperon.c` - Main C entry point
- `scripts/core/engine.js` - JavaScript engine initialization for system
- `scripts/core/base.js` has modifications to this Javascript runtime (for example, additions to the base Array, String, etc)
### Subprojects
- C code has many subprojects, who's source and sometimes documentation can be found in subprojects. subprojects/quickjs/doc has documentation for quickjs
### Resource System
- Scripts are bundled into `core.zip` during build
- Runtime module loading via PhysFS
- Resource paths checked in order: `/`, `scripts/modules/`, `scripts/modules/ext/`
### Notable Dependencies
- QuickJS (custom build) - JavaScript runtime
- SDL3 - Platform abstraction
- Chipmunk2D - Physics
- ENet - Networking
- Soloud - Audio
- Tracy - Profiling (when enabled)
## Development Tips
### Running Games
```bash
# Build first
make debug
# Run example from build directory
./build_dbg/prosperon examples/chess
# Or copy to game directory
cp build_dbg/prosperon examples/chess/
cd examples/chess
./prosperon
```
### Documentation
- Documentation is found in docs
- Documentation for the JS modules loaded with 'use' is docs/api/modules
- .md files directly in docs gives a high level overview
- docs/dull is what this specific Javascript system is (including alterations from quickjs/es6)
### Shader Development
- Shaders are in `shaders/` directory as HLSL
- Compile script: `shaders/compile.sh`
- Outputs to platform-specific formats: `dxil/`, `msl/`, `spv/`
### Example Games
Located in `examples/` directory:
- `chess` - Chess implementation (has its own Makefile)
- `pong` - Classic pong game
- `snake` - Snake game
- `tetris` - Tetris clone
- `bunnymark` - Performance test
### Testing
```bash
# Run all tests
meson test -C build_dbg
# Run specific test
./build_dbg/prosperon tests/spawn_actor.js
```
### Debugging
- Use debug build: `make debug`
- Tracy profiler support when enabled
- Console logging available via `log.console()`, `log.error()`, etc.
- Log files written to `.prosperon/log.txt`
# Project Structure Notes
## Core JavaScript Modules
- JavaScript modules are defined using the MISTUSE macro in jsffi.c
- The `js_os_funcs`, `js_io_funcs`, etc. arrays define the available functions for each module
- New functions are added with MIST_FUNC_DEF(module, function, args_count)
## File I/O
- `io.slurp(path)` - Reads a file as text
- `io.slurpbytes(path)` - Reads a file as an ArrayBuffer
- `io.slurpwrite(path, data)` - Writes data (string or ArrayBuffer) to a file
- `io.exists(path)` - Checks if a file exists
## Script Loading
- The `use(path)` function in engine.js loads JavaScript modules
- Script loading happens in prosperon.c and the engine.js script
- jsffi.c contains the C hooks for the QuickJS JavaScript engine
- Added functionality for bytecode compilation and loading:
- `os.compile_bytecode(source, filename)` - Compiles JS to bytecode, returns ArrayBuffer
- `os.eval_bytecode(bytecode)` - Evaluates bytecode from an ArrayBuffer
- `compile(scriptPath)` - Compiles a JS file to a .jso bytecode file
- Modified `use()` to check for .jso files before loading .js files
## QuickJS Bytecode API
- `JS_Eval` with JS_EVAL_FLAG_COMPILE_ONLY - Compiles without executing
- `JS_WriteObject` with JS_WRITE_OBJ_BYTECODE - Serializes to bytecode
- `JS_ReadObject` with JS_READ_OBJ_BYTECODE - Deserializes and loads bytecode
- Bytecode files use .jso extension alongside .js files
## Available JavaScript APIs
### Core APIs
- `actor` - Base prototype for all actor objects
- `$_` - Special global for actor messaging
- `prosperon` - Global engine interface
- `console` - Logging and debugging interface
### Framework APIs
- `moth` - Higher-level game framework that simplifies Prosperon usage
- Handles window creation, game loop, and event dispatching
- Provides simple configuration via config.js
- Auto-initializes systems like rendering and input
- Manages camera, resolution, and FPS automatically
### Rendering
- `draw2d` - 2D drawing primitives
- `render` - Low-level rendering operations
- `graphics` - Higher-level graphics utilities
- `camera` - Camera controls and transformations
- `sprite` - Sprite rendering and management
### Physics and Math
- `math` - Mathematical utilities
- `geometry` - Geometric calculations and shapes
- `transform` - Object transformations
### Input and Events
- `input` - Mouse, keyboard, and touch handling
- `event` - Event management system
### Networking
- `enet` - Networking through ENet library
- `http` - HTTP client capabilities
### Audio
- `sound` - Audio playback using SoLoud
### Utility Modules
- `time` - Time management and delays
- **Must be imported with `use('time')`**
- No `time.now()` function - use:
- `time.number()` - Number representation of current time
- `time.record()` - Struct representation of current time
- `time.text()` - Text representation of current time
- `io` - File I/O operations
- `json` - JSON parsing and serialization
- `util` - General utilities
- `color` - Color manipulation
- `miniz` - Compression utilities
- `nota` - Structured data format
- `wota` - Serialization format
- `qr` - QR code generation/reading
- `tween` - Animation tweening
- `spline` - Spline calculations
- `imgui` - Immediate mode GUI
## Game Development Patterns
### Project Structure
- Game config is typically in `config.js`
- Main entry point is `main.js`
- Resource loading through `resources.js`
### Actor Pattern Usage
- Create actors with `actor.spawn(script, config)`
- Start actors with `$_.start(callback, script)` - the system automatically sends a greeting, callback receives {type: 'greet', actor: actor_ref}
- No need to manually send greetings - `$_.start` handles this automatically
- Manage actor hierarchy with overlings and underlings
- Schedule actor tasks with `$_.delay()` method
- Clean up with `kill()` and `garbage()`
### Actor Messaging with Callbacks
When sending a message with a callback, respond by sending to the message itself:
```javascript
// Sender side:
send(actor, {type: 'status'}, response => {
log.console(response); // Handle the response
});
// Receiver side:
$_.receiver(msg => {
if (msg.type === 'status') {
send(msg, {status: 'ok'}); // Send response to the message itself
}
});
```
**Critical Rules for Message Callbacks**:
- **A message can only be used ONCE as a send target** - after sending a response to a message, it cannot be used again
- If you need to send multiple updates (like progress), only the download request message should be used for the final response
- Status requests should each get their own individual response
- Actor objects and message headers are completely opaque - never try to access internal properties
- Never access `msg.__HEADER__` or similar - the actor system handles routing internally
- Use `$_.delay()` to schedule work and avoid blocking the message receiver
### Game Loop Registration
- Register functions like `update`, `draw`, `gui`, etc.
- Set function.layer property to control execution order
- Use `Register` system to manage callbacks
### Program vs Module Pattern
- Programs are actor scripts that don't return values, they execute top-to-bottom
- Modules are files that return single values (usually objects) that get frozen
- Programs can spawn other programs as underlings
- Programs have lifecycle hooks: awake, update, draw, garbage, etc.
## Technical Capabilities
### Graphics Pipeline
- Supports multiple render backends (Direct3D, Metal, Vulkan via SDL3)
- Custom shader system with cross-platform compilation
- Sprite batching for efficient 2D rendering
- Camera systems for both 2D and 3D
### Asset Support
- Images: PNG, JPG, QOI, etc.
- Audio: Various formats through SoLoud
- Models: Basic 3D model support
- Custom formats: Aseprite animations, etc.
### Developer Tools
- Built-in documentation system with `cell.DOC`
- Tracy profiler integration for performance monitoring
- Imgui debugging tools
- Console logging with various severity levels
## Misty Networking Patterns
Prosperon implements the Misty actor networking model. Understanding these patterns is critical for building distributed applications.
### Portal Reply Pattern
Portals must reply with an actor object, not application data:
```javascript
// CORRECT: Portal replies with actor
$_.portal(e => {
send(e, $_); // Reply with server actor
}, 5678);
// WRONG: Portal sends application data
$_.portal(e => {
send(e, {type: 'game_start'}); // This breaks the pattern
}, 5678);
```
### Two-Phase Connection Protocol
Proper Misty networking follows a two-phase pattern:
**Phase 1: Actor Connection**
- Client contacts portal using `$_.contact()`
- Portal replies with an actor object
- This establishes the communication channel
**Phase 2: Application Communication**
- Client sends application messages to the received actor
- Normal bidirectional messaging begins
- Application logic handles game/service initialization
### Message Handling Best Practices
Messages should be treated as opaque objects with your application data:
```javascript
// CORRECT: Store actor references separately
var players = {};
$_.receiver(msg => {
if (msg.type === 'join_game' && msg.player_id) {
// Store the message for later response
players[msg.player_id] = msg;
// Later, respond to the stored message
send(players[msg.player_id], {type: 'game_start'});
}
});
// WRONG: Trying to access internal message properties
$_.receiver(msg => {
var sender = msg.__HEADER__.replycc; // Never do this!
});
```
### Return ID Lifecycle
- Each reply callback gets a unique return ID
- Return IDs are consumed once and then deleted
- Reusing message objects with return headers causes "Could not find return function" errors
- Always create clean actor references for ongoing communication
### Actor Object Transparency
Actor objects must be completely opaque black boxes that work identically regardless of transport:
```javascript
// Actor objects work transparently for:
// - Same-process communication (fastest - uses mailbox)
// - Inter-process communication (uses mailbox)
// - Network communication (uses ENet)
// The actor shouldn't know or care about the transport mechanism
send(opponent, {type: 'move', from: [0,0], to: [1,1]});
```
**Key Implementation Details:**
- `actor_send()` in `scripts/core/engine.js` handles routing based on available actor data
- Actor objects sent in message data automatically get address/port populated when received over network
- Three communication pathways: `os.mailbox_exist()` check → mailbox send → network send
- Actor objects must contain all necessary routing information for transparent messaging
### Common Networking Bugs
1. **Portal sending application data**: Portal should only establish actor connections
2. **Return ID collision**: Reusing messages with return headers for multiple sends
3. **Mixed phases**: Trying to do application logic during connection establishment
4. **Header pollution**: Using received message objects as actor references
5. **Missing actor address info**: Actor objects in message data need network address population (fixed in engine.js:746-766)
### Example: Correct Chess Networking
```javascript
// Server: Portal setup
$_.portal(e => {
send(e, $_); // Just reply with actor
}, 5678);
// Client: Two-phase connection
$_.contact((actor, reason) => {
if (actor) {
opponent = actor;
send(opponent, {type: 'join_game'}); // Phase 2: app messaging
}
}, {address: "localhost", port: 5678});
// Server: Handle application messages
$_.receiver(e => {
if (e.type === 'join_game') {
opponent = e.__HEADER__.replycc;
send(opponent, {type: 'game_start', your_color: 'black'});
}
});
```
## Memory Management
- When working with a conversational AI system like Claude, it's important to maintain a clean and focused memory
- Regularly review and update memories to ensure they remain relevant and helpful
- Delete or modify memories that are no longer accurate or useful
- Prioritize information that can genuinely assist in future interactions

View File

@@ -1,54 +0,0 @@
# Builder stage
FROM ubuntu:plucky AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 python3-pip \
libasound2-dev \
libpulse-dev \
libudev-dev \
libwayland-dev \
wayland-protocols \
libxkbcommon-dev \
libx11-dev \
libxext-dev \
libxrandr-dev \
libxcursor-dev \
libxi-dev \
libxinerama-dev \
libxss-dev \
libegl1-mesa-dev \
libgl1-mesa-dev \
cmake \
ninja-build \
git \
build-essential \
binutils \
pkg-config \
meson \
zip && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
RUN git clone https://gitea.pockle.world/john/prosperon.git
WORKDIR /app/prosperon
RUN git checkout jsffi_refactor
RUN meson setup build -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true
RUN meson compile -C build
# Runtime stage
FROM ubuntu:latest
# Install minimal runtime dependencies (e.g., for dynamically linked libraries)
RUN apt-get update && apt-get install -y libstdc++6 && rm -rf /var/lib/apt/lists/*
# Copy the compiled prosperon binary from the build stage
COPY --from=builder /app/prosperon/build/prosperon /usr/local/bin/prosperon
# Create an entrypoint script
RUN echo '#!/bin/bash' > /entrypoint.sh && \
echo '/usr/local/bin/prosperon "$@" &' >> /entrypoint.sh && \
echo 'tail -f /dev/null' >> /entrypoint.sh && \
chmod +x /entrypoint.sh
WORKDIR /workdir
ENTRYPOINT ["/entrypoint.sh"]

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>Prosperon</string>
<key>CFBundleIdentifier</key>
<string>pockle.world.prosperon</string>
<key>CFBundleName</key>
<string>Prosperon</string>
<key>CFBundleVersion</key>
<string>0.5</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2024 Pockle World. All rights reserved.</string>
</dict>
</plist>

26
LICENSE
View File

@@ -1,26 +0,0 @@
Prosperon Game Engine
Copyright (c) 2019-2024 John Alanbrook
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
(1) The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
(2) Any games or other derivative software must display the "Prosperon" logo
at near the beginning of the software's startup, before the chief purpose
of the software is underway.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

105
Makefile
View File

@@ -1,29 +1,80 @@
debug: FORCE
# Development build: creates libcell_runtime.dylib + thin main wrapper
# This is the default target for working on cell itself
#
# If cell doesn't exist yet, use 'make bootstrap' first (requires meson)
# or manually build with meson once.
#
# The cell shop is at ~/.cell and core scripts are installed to ~/.cell/core
CELL_SHOP = $(HOME)/.cell
CELL_CORE_PACKAGE = $(CELL_SHOP)/packages/core
makecell:
cell pack core -o cell
cp cell /opt/homebrew/bin/
# Install core: symlink this directory to ~/.cell/core
install: bootstrap $(CELL_SHOP)
@echo "Linking cell core to $(CELL_CORE_PACKAGE)"
rm -rf $(CELL_CORE_PACKAGE)
ln -s $(PWD) $(CELL_CORE_PACKAGE)
cp cell /opt/homebrew/bin/
cp libcell_runtime.dylib /opt/homebrew/lib/
@echo "Core installed."
cell: libcell_runtime.dylib cell_main
cp cell_main cell
chmod +x cell
cp cell /opt/homebrew/bin/cell
cp libcell_runtime.dylib /opt/homebrew/lib/
# Build the shared runtime library (everything except main.c)
# Uses existing cell to run build -d
libcell_runtime.dylib: $(CELL_SHOP)/build/dynamic
cell build -d
cp $(CELL_SHOP)/build/dynamic/libcell_runtime.dylib .
# Build the thin main wrapper that links to libcell_runtime
cell_main: source/main.c libcell_runtime.dylib
cc -o cell_main source/main.c -L. -lcell_runtime -Wl,-rpath,@loader_path -Wl,-rpath,/opt/homebrew/lib
# Create the cell shop directories
$(CELL_SHOP):
mkdir -p $(CELL_SHOP)
mkdir -p $(CELL_SHOP)/packages
mkdir -p $(CELL_SHOP)/cache
mkdir -p $(CELL_SHOP)/build
$(CELL_CORE):
ln -s $(PWD) $(CELL_CORE)
# Static build: creates a fully static cell binary (for distribution)
static:
cell build
cp $(CELL_SHOP)/build/static/cell .
# Bootstrap: build cell from scratch using meson (only needed once)
# Also installs core scripts to ~/.cell/core
bootstrap:
meson setup build_bootstrap -Dbuildtype=debugoptimized
meson compile -C build_bootstrap
cp build_bootstrap/cell .
cp build_bootstrap/libcell_runtime.dylib .
@echo "Bootstrap complete. Cell shop initialized at $(CELL_SHOP)"
@echo "Now run 'make' to rebuild with cell itself."
# Clean build artifacts
clean:
rm -rf $(CELL_SHOP)/build build_bootstrap
rm -f cell cell_main libcell_runtime.dylib
# Ensure dynamic build directory exists
$(CELL_SHOP)/build/dynamic: $(CELL_SHOP)
mkdir -p $(CELL_SHOP)/build/dynamic
# Legacy meson target
meson:
meson setup build_dbg -Dbuildtype=debugoptimized
meson install --only-changed -C build_dbg
fast: FORCE
meson setup build_fast
meson install -C build_fast
meson install -C build_dbg
release: FORCE
meson setup -Dbuildtype=release -Db_lto=true -Db_lto_mode=thin -Db_ndebug=true build_release
meson install -C build_release
sanitize: FORCE
meson setup -Db_sanitize=address -Db_sanitize=memory -Db_sanitize=leak -Db_sanitize=undefined build_sani
meson install -C build_sani
small: FORCE
meson setup -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true build_small
meson install -C build_small
web: FORCE
meson setup -Deditor=false -Dbuildtype=minsize -Db_lto=true -Db_ndebug=true --cross-file emscripten.cross build_web
meson compile -C build_web
crosswin: FORCE
meson setup -Dbuildtype=debugoptimized --cross-file mingw32.cross build_win
meson compile -C build_win
FORCE:
.PHONY: cell static bootstrap clean meson install

View File

@@ -1,7 +1 @@
Thank you for using Prosperon!
Provided are prosperon builds for all available platforms. Simply run prosperon for your platform in a game folder to play!
To get started, take a dive into the provided example games in the examples folder. You can either copy the prosperon executable into an example directory and run it there, or run `prosperon path/to/example` from the project root.
You can take a look through the docs folder for the prosperon manual to learn all about it. The manual is available on the web at [docs.prosperon.dev](https://docs.prosperon.dev).
Read the docs to get started.

28
add.ce Normal file
View File

@@ -0,0 +1,28 @@
// cell add <locator> [alias] - Add and install a package with its dependencies
var shop = use('internal/shop')
var fd = use('fd')
if (args.length < 1) {
log.console("Usage: cell add <locator> [alias]")
log.console("Examples:")
log.console(" cell add gitea.pockle.world/john/prosperon@main")
log.console(" cell add github.com/user/repo@v1.0.0 myalias")
$stop()
return
}
var locator = args[0]
// Resolve relative paths to absolute paths
if (locator == '.' || locator.startsWith('./') || locator.startsWith('../') || fd.is_dir(locator)) {
var resolved = fd.realpath(locator)
if (resolved) {
locator = resolved
}
}
var alias = args.length > 1 ? args[1] : null
shop.get(locator, alias)
$stop()

View File

@@ -1,6 +1,6 @@
#include "quickjs.h"
#include "miniz.h"
#include "qjs_blob.h"
#include "cell.h"
static JSClassID js_reader_class_id;
static JSClassID js_writer_class_id;
@@ -42,14 +42,20 @@ static JSValue js_miniz_read(JSContext *js, JSValue self, int argc, JSValue *arg
{
size_t len;
void *data = js_get_blob_data(js, &len, argv[0]);
if (!data)
return JS_ThrowReferenceError(js, "Could not create data.\n");
if (data == -1)
return JS_EXCEPTION;
mz_zip_archive *zip = calloc(sizeof(*zip),1);
int success = mz_zip_reader_init_mem(zip, data, len, 0);
int err = mz_zip_get_last_error(zip);
if (err)
return JS_ThrowInternalError(js, "miniz error: %s\n", mz_zip_get_error_string(err));
mz_zip_archive *zip = calloc(sizeof(*zip), 1);
if (!zip)
return JS_ThrowOutOfMemory(js);
mz_bool success = mz_zip_reader_init_mem(zip, data, len, 0);
if (!success) {
int err = mz_zip_get_last_error(zip);
free(zip);
return JS_ThrowInternalError(js, "Failed to initialize zip reader: %s", mz_zip_get_error_string(err));
}
JSValue jszip = JS_NewObjectClass(js, js_reader_class_id);
JS_SetOpaque(jszip, zip);
@@ -101,11 +107,10 @@ static JSValue js_miniz_compress(JSContext *js, JSValue this_val,
if (!cstring)
return JS_EXCEPTION;
in_ptr = cstring;
} else { /* assume ArrayBuffer / TypedArray */
} else {
in_ptr = js_get_blob_data(js, &in_len, argv[0]);
if (!in_ptr)
return JS_ThrowTypeError(js,
"Argument must be a string or ArrayBuffer");
if (in_ptr == -1)
return JS_EXCEPTION;
}
/* ─── 2. Allocate an output buffer big enough ────────────── */
@@ -148,9 +153,8 @@ static JSValue js_miniz_decompress(JSContext *js,
/* grab compressed data */
size_t in_len;
void *in_ptr = js_get_blob_data(js, &in_len, argv[0]);
if (!in_ptr)
return JS_ThrowTypeError(js,
"decompress: first arg must be an ArrayBuffer");
if (in_ptr == -1)
return JS_EXCEPTION;
/* zlib header present → tell tinfl to parse it */
size_t out_len = 0;
@@ -162,15 +166,8 @@ static JSValue js_miniz_decompress(JSContext *js,
return JS_ThrowInternalError(js,
"miniz: decompression failed");
/* wrap for JS */
JSValue ret;
int asString = (argc > 1) && JS_ToBool(js, argv[1]);
// if (asString)
ret = JS_NewStringLen(js, (const char *)out_ptr, out_len);
// else
// ret = JS_NewArrayBufferCopy(js, out_ptr, out_len);
#ifdef MZ_FREE
MZ_FREE(out_ptr);
#else
@@ -199,9 +196,9 @@ JSValue js_writer_add_file(JSContext *js, JSValue self, int argc, JSValue *argv)
size_t dataLen;
void *data = js_get_blob_data(js, &dataLen, argv[1]);
if (!data) {
if (data == -1) {
JS_FreeCString(js, pathInZip);
return JS_ThrowTypeError(js, "Second argument must be an ArrayBuffer");
return JS_EXCEPTION;
}
int success = mz_zip_writer_add_mem(zip, pathInZip, data, dataLen, MZ_DEFAULT_COMPRESSION);
@@ -220,6 +217,7 @@ static const JSCFunctionListEntry js_writer_funcs[] = {
JSValue js_reader_mod(JSContext *js, JSValue self, int argc, JSValue *argv)
{
#ifndef MINIZ_NO_TIME
const char *file = JS_ToCString(js,argv[0]);
if (!file)
return JS_EXCEPTION;
@@ -246,6 +244,9 @@ JSValue js_reader_mod(JSContext *js, JSValue self, int argc, JSValue *argv)
}
return JS_NewFloat64(js, pstat.m_time);
#else
return JS_ThrowInternalError(js, "MINIZ_NO_TIME is defined");
#endif
}
JSValue js_reader_exists(JSContext *js, JSValue self, int argc, JSValue *argv)
@@ -365,7 +366,6 @@ JSValue js_reader_count(JSContext *js, JSValue self, int argc, JSValue *argv)
mz_zip_archive *zip = js2reader(js, self);
if (!zip)
return JS_ThrowInternalError(js, "Invalid zip reader");
return JS_NewUint32(js, mz_zip_reader_get_num_files(zip));
}

603
bench.ce Normal file
View File

@@ -0,0 +1,603 @@
var shop = use('internal/shop')
var pkg = use('package')
var fd = use('fd')
var time = use('time')
var json = use('json')
var blob = use('blob')
var os = use('os')
var testlib = use('internal/testlib')
var math = use('math/radians')
if (!args) args = []
var target_pkg = null // null = current package
var target_bench = null // null = all benchmarks, otherwise specific bench file
var all_pkgs = false
// Benchmark configuration
def WARMUP_BATCHES = 3
def SAMPLES = 11 // Number of timing samples to collect
def TARGET_SAMPLE_NS = 20000000 // 20ms per sample (fast mode)
def MIN_SAMPLE_NS = 2000000 // 2ms minimum sample duration
def MIN_BATCH_SIZE = 1
def MAX_BATCH_SIZE = 100000000 // 100M iterations max per batch
// Statistical functions
function median(arr) {
if (arr.length == 0) return 0
var sorted = arr.slice().sort(function(a, b) { return a - b })
var mid = number.floor(arr.length / 2)
if (arr.length % 2 == 0) {
return (sorted[mid - 1] + sorted[mid]) / 2
}
return sorted[mid]
}
function mean(arr) {
if (arr.length == 0) return 0
var sum = 0
for (var i = 0; i < arr.length; i++) {
sum += arr[i]
}
return sum / arr.length
}
function stddev(arr, mean_val) {
if (arr.length < 2) return 0
var sum_sq_diff = 0
for (var i = 0; i < arr.length; i++) {
var diff = arr[i] - mean_val
sum_sq_diff += diff * diff
}
return math.sqrt(sum_sq_diff / (arr.length - 1))
}
function percentile(arr, p) {
if (arr.length == 0) return 0
var sorted = arr.slice().sort(function(a, b) { return a - b })
var idx = number.floor(arr.length * p / 100)
if (idx >= arr.length) idx = arr.length - 1
return sorted[idx]
}
function min_val(arr) {
if (arr.length == 0) return 0
var m = arr[0]
for (var i = 1; i < arr.length; i++) {
if (arr[i] < m) m = arr[i]
}
return m
}
function max_val(arr) {
if (arr.length == 0) return 0
var m = arr[0]
for (var i = 1; i < arr.length; i++) {
if (arr[i] > m) m = arr[i]
}
return m
}
// Parse arguments similar to test.ce
function parse_args() {
if (args.length == 0) {
if (!testlib.is_valid_package('.')) {
log.console('No cell.toml found in current directory')
return false
}
target_pkg = null
return true
}
if (args[0] == 'all') {
if (!testlib.is_valid_package('.')) {
log.console('No cell.toml found in current directory')
return false
}
target_pkg = null
return true
}
if (args[0] == 'package') {
if (args.length < 2) {
log.console('Usage: cell bench package <name> [bench]')
log.console(' cell bench package all')
return false
}
if (args[1] == 'all') {
all_pkgs = true
log.console('Benchmarking all packages...')
return true
}
var name = args[1]
var lock = shop.load_lock()
if (lock[name]) {
target_pkg = name
} else if (name.startsWith('/') && testlib.is_valid_package(name)) {
target_pkg = name
} else {
if (testlib.is_valid_package('.')) {
var resolved = pkg.alias_to_package(null, name)
if (resolved) {
target_pkg = resolved
} else {
log.console(`Package not found: ${name}`)
return false
}
} else {
log.console(`Package not found: ${name}`)
return false
}
}
if (args.length >= 3) {
target_bench = args[2]
}
log.console(`Benchmarking package: ${target_pkg}`)
return true
}
// cell bench benches/suite or cell bench <path>
var bench_path = args[0]
// Normalize path - add benches/ prefix if not present
if (!bench_path.startsWith('benches/') && !bench_path.startsWith('/')) {
if (!fd.is_file(bench_path + '.cm') && !fd.is_file(bench_path)) {
if (fd.is_file('benches/' + bench_path + '.cm') || fd.is_file('benches/' + bench_path)) {
bench_path = 'benches/' + bench_path
}
}
}
target_bench = bench_path
target_pkg = null
if (!testlib.is_valid_package('.')) {
log.console('No cell.toml found in current directory')
return false
}
return true
}
if (!parse_args()) {
$stop()
return
}
// Collect benchmark files from a package
function collect_benches(package_name, specific_bench) {
var prefix = testlib.get_pkg_dir(package_name)
var benches_dir = prefix + '/benches'
if (!fd.is_dir(benches_dir)) return []
var files = pkg.list_files(package_name)
var bench_files = []
for (var i = 0; i < files.length; i++) {
var f = files[i]
if (f.startsWith("benches/") && f.endsWith(".cm")) {
if (specific_bench) {
var bench_name = f.substring(0, f.length - 3)
var match_name = specific_bench
if (!match_name.startsWith('benches/')) match_name = 'benches/' + match_name
var match_base = match_name.endsWith('.cm') ? match_name.substring(0, match_name.length - 3) : match_name
if (bench_name != match_base) continue
}
bench_files.push(f)
}
}
return bench_files
}
// Calibrate batch size for a benchmark
function calibrate_batch_size(bench_fn, is_batch) {
if (!is_batch) return 1
var n = MIN_BATCH_SIZE
var dt = 0
// Find a batch size that takes at least MIN_SAMPLE_NS
while (n < MAX_BATCH_SIZE) {
// Ensure n is a valid number before calling
if (typeof n != 'number' || n < 1) {
n = 1
break
}
var start = os.now()
bench_fn(n)
dt = os.now() - start
if (dt >= MIN_SAMPLE_NS) break
// Double the batch size
var new_n = n * 2
// Check if multiplication produced a valid number
if (typeof new_n != 'number' || new_n > MAX_BATCH_SIZE) {
n = MAX_BATCH_SIZE
break
}
n = new_n
}
// Adjust to target sample duration
if (dt > 0 && dt < TARGET_SAMPLE_NS && typeof n == 'number' && typeof dt == 'number') {
var calc = n * TARGET_SAMPLE_NS / dt
if (typeof calc == 'number' && calc > 0) {
var target_n = number.floor(calc)
// Check if floor returned a valid number
if (typeof target_n == 'number' && target_n > 0) {
if (target_n > MAX_BATCH_SIZE) target_n = MAX_BATCH_SIZE
if (target_n < MIN_BATCH_SIZE) target_n = MIN_BATCH_SIZE
n = target_n
}
}
}
// Safety check - ensure we always return a valid batch size
if (typeof n != 'number' || n < 1) {
n = 1
}
return n
}
// Run a single benchmark function
function run_single_bench(bench_fn, bench_name) {
var timings_per_op = []
// Detect benchmark format:
// 1. Object with { setup, run, teardown } - structured format
// 2. Function that accepts (n) - batch format
// 3. Function that accepts () - legacy format
var is_structured = typeof bench_fn == 'object' && bench_fn.run
var is_batch = false
var batch_size = 1
var setup_fn = null
var run_fn = null
var teardown_fn = null
if (is_structured) {
setup_fn = bench_fn.setup || function() { return null }
run_fn = bench_fn.run
teardown_fn = bench_fn.teardown || function(state) {}
// Check if run function accepts batch size
try {
var test_state = setup_fn()
run_fn(1, test_state)
is_batch = true
if (teardown_fn) teardown_fn(test_state)
} catch (e) {
is_batch = false
}
// Create wrapper for calibration
var calibrate_fn = function(n) {
var state = setup_fn()
run_fn(n, state)
if (teardown_fn) teardown_fn(state)
}
batch_size = calibrate_batch_size(calibrate_fn, is_batch)
// Safety check for structured benchmarks
if (typeof batch_size != 'number' || batch_size < 1) {
batch_size = 1
}
} else {
// Simple function format
try {
bench_fn(1)
is_batch = true
} catch (e) {
is_batch = false
}
batch_size = calibrate_batch_size(bench_fn, is_batch)
}
// Safety check - ensure batch_size is valid
if (!batch_size || batch_size < 1) {
batch_size = 1
}
// Warmup phase
for (var i = 0; i < WARMUP_BATCHES; i++) {
// Ensure batch_size is valid before warmup
if (typeof batch_size != 'number' || batch_size < 1) {
log.console(`WARNING: batch_size became ${typeof batch_size} = ${batch_size}, resetting to 1`)
batch_size = 1
}
if (is_structured) {
var state = setup_fn()
if (is_batch) {
run_fn(batch_size, state)
} else {
run_fn(state)
}
if (teardown_fn) teardown_fn(state)
} else {
if (is_batch) {
bench_fn(batch_size)
} else {
bench_fn()
}
}
}
// Measurement phase - collect SAMPLES timing samples
for (var i = 0; i < SAMPLES; i++) {
// Double-check batch_size is valid (should never happen, but defensive)
if (typeof batch_size != 'number' || batch_size < 1) {
batch_size = 1
}
if (is_structured) {
var state = setup_fn()
var start = os.now()
if (is_batch) {
run_fn(batch_size, state)
} else {
run_fn(state)
}
var duration = os.now() - start
if (teardown_fn) teardown_fn(state)
var ns_per_op = is_batch ? duration / batch_size : duration
timings_per_op.push(ns_per_op)
} else {
var start = os.now()
if (is_batch) {
bench_fn(batch_size)
} else {
bench_fn()
}
var duration = os.now() - start
var ns_per_op = is_batch ? duration / batch_size : duration
timings_per_op.push(ns_per_op)
}
}
// Calculate statistics
var mean_ns = mean(timings_per_op)
var median_ns = median(timings_per_op)
var min_ns = min_val(timings_per_op)
var max_ns = max_val(timings_per_op)
var stddev_ns = stddev(timings_per_op, mean_ns)
var p95_ns = percentile(timings_per_op, 95)
var p99_ns = percentile(timings_per_op, 99)
// Calculate ops/s from median
var ops_per_sec = 0
if (median_ns > 0) {
ops_per_sec = number.floor(1000000000 / median_ns)
}
return {
name: bench_name,
batch_size: batch_size,
samples: SAMPLES,
mean_ns: number.round(mean_ns),
median_ns: number.round(median_ns),
min_ns: number.round(min_ns),
max_ns: number.round(max_ns),
stddev_ns: number.round(stddev_ns),
p95_ns: number.round(p95_ns),
p99_ns: number.round(p99_ns),
ops_per_sec: ops_per_sec
}
}
// Format nanoseconds for display
function format_ns(ns) {
if (ns < 1000) return `${ns}ns`
if (ns < 1000000) return `${number.round(ns / 1000 * 100) / 100}µs`
if (ns < 1000000000) return `${number.round(ns / 1000000 * 100) / 100}ms`
return `${number.round(ns / 1000000000 * 100) / 100}s`
}
// Format ops/sec for display
function format_ops(ops) {
if (ops < 1000) return `${ops} ops/s`
if (ops < 1000000) return `${number.round(ops / 1000 * 100) / 100}K ops/s`
if (ops < 1000000000) return `${number.round(ops / 1000000 * 100) / 100}M ops/s`
return `${number.round(ops / 1000000000 * 100) / 100}G ops/s`
}
// Run benchmarks for a package
function run_benchmarks(package_name, specific_bench) {
var bench_files = collect_benches(package_name, specific_bench)
var pkg_result = {
package: package_name || "local",
files: [],
total: 0
}
if (bench_files.length == 0) return pkg_result
if (package_name) log.console(`Running benchmarks for ${package_name}`)
else log.console(`Running benchmarks for local package`)
for (var i = 0; i < bench_files.length; i++) {
var f = bench_files[i]
var mod_path = f.substring(0, f.length - 3)
var file_result = {
name: f,
benchmarks: []
}
try {
var bench_mod
var use_pkg = package_name ? package_name : fd.realpath('.')
bench_mod = shop.use(mod_path, use_pkg)
var benches = []
if (typeof bench_mod == 'function') {
benches.push({name: 'main', fn: bench_mod})
} else if (typeof bench_mod == 'object') {
for (var k in bench_mod) {
if (typeof bench_mod[k] == 'function') {
benches.push({name: k, fn: bench_mod[k]})
}
}
}
if (benches.length > 0) {
log.console(` ${f}`)
for (var j = 0; j < benches.length; j++) {
var b = benches[j]
try {
var result = run_single_bench(b.fn, b.name)
result.package = pkg_result.package
file_result.benchmarks.push(result)
pkg_result.total++
log.console(` ${result.name}`)
log.console(` ${format_ns(result.median_ns)}/op ${format_ops(result.ops_per_sec)}`)
log.console(` min: ${format_ns(result.min_ns)} max: ${format_ns(result.max_ns)} stddev: ${format_ns(result.stddev_ns)}`)
if (result.batch_size > 1) {
log.console(` batch: ${result.batch_size} samples: ${result.samples}`)
}
} catch (e) {
log.console(` ERROR ${b.name}: ${e}`)
log.error(e)
var error_result = {
package: pkg_result.package,
name: b.name,
error: e.toString()
}
file_result.benchmarks.push(error_result)
pkg_result.total++
}
}
}
} catch (e) {
log.console(` Error loading ${f}: ${e}`)
var error_result = {
package: pkg_result.package,
name: "load_module",
error: `Error loading module: ${e}`
}
file_result.benchmarks.push(error_result)
pkg_result.total++
}
if (file_result.benchmarks.length > 0) {
pkg_result.files.push(file_result)
}
}
return pkg_result
}
// Run all benchmarks
var all_results = []
if (all_pkgs) {
if (testlib.is_valid_package('.')) {
all_results.push(run_benchmarks(null, null))
}
var packages = shop.list_packages()
for (var i = 0; i < packages.length; i++) {
all_results.push(run_benchmarks(packages[i], null))
}
} else {
all_results.push(run_benchmarks(target_pkg, target_bench))
}
// Calculate totals
var total_benches = 0
for (var i = 0; i < all_results.length; i++) {
total_benches += all_results[i].total
}
log.console(`----------------------------------------`)
log.console(`Benchmarks: ${total_benches} total`)
// Generate reports
function generate_reports() {
var timestamp = text(number.floor(time.number()))
var report_dir = shop.get_reports_dir() + '/bench_' + timestamp
testlib.ensure_dir(report_dir)
var txt_report = `BENCHMARK REPORT
Date: ${time.text(time.number())}
Total benchmarks: ${total_benches}
=== SUMMARY ===
`
for (var i = 0; i < all_results.length; i++) {
var pkg_res = all_results[i]
if (pkg_res.total == 0) continue
txt_report += `Package: ${pkg_res.package}\n`
for (var j = 0; j < pkg_res.files.length; j++) {
var f = pkg_res.files[j]
txt_report += ` ${f.name}\n`
for (var k = 0; k < f.benchmarks.length; k++) {
var b = f.benchmarks[k]
if (b.error) {
txt_report += ` ERROR ${b.name}: ${b.error}\n`
} else {
txt_report += ` ${b.name}: ${format_ns(b.median_ns)}/op (${format_ops(b.ops_per_sec)})\n`
}
}
}
}
txt_report += `\n=== DETAILED RESULTS ===\n`
for (var i = 0; i < all_results.length; i++) {
var pkg_res = all_results[i]
if (pkg_res.total == 0) continue
for (var j = 0; j < pkg_res.files.length; j++) {
var f = pkg_res.files[j]
for (var k = 0; k < f.benchmarks.length; k++) {
var b = f.benchmarks[k]
if (b.error) continue
txt_report += `\n${pkg_res.package}::${b.name}\n`
txt_report += ` batch_size: ${b.batch_size} samples: ${b.samples}\n`
txt_report += ` median: ${format_ns(b.median_ns)}/op\n`
txt_report += ` mean: ${format_ns(b.mean_ns)}/op\n`
txt_report += ` min: ${format_ns(b.min_ns)}\n`
txt_report += ` max: ${format_ns(b.max_ns)}\n`
txt_report += ` stddev: ${format_ns(b.stddev_ns)}\n`
txt_report += ` p95: ${format_ns(b.p95_ns)}\n`
txt_report += ` p99: ${format_ns(b.p99_ns)}\n`
txt_report += ` ops/s: ${format_ops(b.ops_per_sec)}\n`
}
}
}
testlib.ensure_dir(report_dir)
fd.slurpwrite(`${report_dir}/bench.txt`, stone(new blob(txt_report)))
log.console(`Report written to ${report_dir}/bench.txt`)
// Generate JSON per package
for (var i = 0; i < all_results.length; i++) {
var pkg_res = all_results[i]
if (pkg_res.total == 0) continue
var pkg_benches = []
for (var j = 0; j < pkg_res.files.length; j++) {
var f = pkg_res.files[j]
for (var k = 0; k < f.benchmarks.length; k++) {
pkg_benches.push(f.benchmarks[k])
}
}
var json_path = `${report_dir}/${pkg_res.package.replace(/\//g, '_')}.json`
fd.slurpwrite(json_path, stone(new blob(json.encode(pkg_benches))))
}
}
generate_reports()
$stop()

262
benches/micro_ops.cm Normal file
View File

@@ -0,0 +1,262 @@
// micro_ops.bench.ce (or .cm depending on your convention)
// Note: We use a function-local sink in each benchmark to avoid cross-contamination
function blackhole(sink, x) {
// Prevent dead-code elimination
return (sink + (x | 0)) | 0
}
function make_obj_xy(x, y) {
return { x, y }
}
function make_obj_yx(x, y) {
// Different insertion order to force a different shape in many engines
return { y, x }
}
function make_shapes(n) {
var out = []
for (var i = 0; i < n; i++) {
var o = { a: i }
o[`p${i}`] = i
out.push(o)
}
return out
}
function make_packed_array(n) {
var a = []
for (var i = 0; i < n; i++) a.push(i)
return a
}
function make_holey_array(n) {
var a = []
for (var i = 0; i < n; i += 2) a[i] = i
return a
}
return {
// 0) Baseline loop cost
loop_empty: function(n) {
var sink = 0
for (var i = 0; i < n; i++) {}
return blackhole(sink, n)
},
// 1) Numeric pipelines
i32_add: function(n) {
var sink = 0
var x = 1
for (var i = 0; i < n; i++) x = (x + 3) | 0
return blackhole(sink, x)
},
f64_add: function(n) {
var sink = 0
var x = 1.0
for (var i = 0; i < n; i++) x = x + 3.14159
return blackhole(sink, x | 0)
},
mixed_add: function(n) {
var sink = 0
var x = 1
for (var i = 0; i < n; i++) x = x + 0.25
return blackhole(sink, x | 0)
},
bit_ops: function(n) {
var sink = 0
var x = 0x12345678
for (var i = 0; i < n; i++) x = ((x << 5) ^ (x >>> 3)) | 0
return blackhole(sink, x)
},
overflow_path: function(n) {
var sink = 0
var x = 0x70000000
for (var i = 0; i < n; i++) x = (x + 0x10000000) | 0
return blackhole(sink, x)
},
// 2) Branching
branch_predictable: function(n) {
var sink = 0
var x = 0
for (var i = 0; i < n; i++) {
if ((i & 7) != 0) x++
else x += 2
}
return blackhole(sink, x)
},
branch_alternating: function(n) {
var sink = 0
var x = 0
for (var i = 0; i < n; i++) {
if ((i & 1) == 0) x++
else x += 2
}
return blackhole(sink, x)
},
// 3) Calls
call_direct: function(n) {
var sink = 0
function f(a) { return (a + 1) | 0 }
var x = 0
for (var i = 0; i < n; i++) x = f(x)
return blackhole(sink, x)
},
call_indirect: function(n) {
var sink = 0
function f(a) { return (a + 1) | 0 }
var g = f
var x = 0
for (var i = 0; i < n; i++) x = g(x)
return blackhole(sink, x)
},
call_closure: function(n) {
var sink = 0
function make_adder(k) {
return function(a) { return (a + k) | 0 }
}
var add3 = make_adder(3)
var x = 0
for (var i = 0; i < n; i++) x = add3(x)
return blackhole(sink, x)
},
// 4) Object props (ICs / shapes)
prop_read_mono: function(n) {
var sink = 0
var o = make_obj_xy(1, 2)
var x = 0
for (var i = 0; i < n; i++) x = (x + o.x) | 0
return blackhole(sink, x)
},
prop_read_poly_2: function(n) {
var sink = 0
var a = make_obj_xy(1, 2)
var b = make_obj_yx(1, 2)
var x = 0
for (var i = 0; i < n; i++) {
var o = (i & 1) == 0 ? a : b
x = (x + o.x) | 0
}
return blackhole(sink, x)
},
prop_read_mega: function(n) {
var sink = 0
var objs = make_shapes(32)
var x = 0
for (var i = 0; i < n; i++) {
var o = objs[i & 31]
x = (x + o.a) | 0
}
return blackhole(sink, x)
},
prop_write_mono: function(n) {
var sink = 0
var o = make_obj_xy(1, 2)
for (var i = 0; i < n; i++) o.x = (o.x + 1) | 0
return blackhole(sink, o.x)
},
// 5) Arrays
array_read_packed: function(n) {
var sink = 0
var a = make_packed_array(1024)
var x = 0
for (var i = 0; i < n; i++) x = (x + a[i & 1023]) | 0
return blackhole(sink, x)
},
array_write_packed: function(n) {
var sink = 0
var a = make_packed_array(1024)
for (var i = 0; i < n; i++) a[i & 1023] = i
return blackhole(sink, a[17] | 0)
},
array_read_holey: function(n) {
var sink = 0
var a = make_holey_array(2048)
var x = 0
for (var i = 0; i < n; i++) {
var v = a[(i & 2047)]
// If "missing" is a special value in your language, this stresses that path too
if (v) x = (x + v) | 0
}
return blackhole(sink, x)
},
array_push_steady: function(n) {
var sink = 0
var x = 0
for (var j = 0; j < n; j++) {
var a = []
for (var i = 0; i < 256; i++) a.push(i)
x = (x + a.length) | 0
}
return blackhole(sink, x)
},
// 6) Strings
string_concat_small: function(n) {
var sink = 0
var x = 0
for (var j = 0; j < n; j++) {
var s = ""
for (var i = 0; i < 16; i++) s = s + "x"
x = (x + s.length) | 0
}
return blackhole(sink, x)
},
// 7) Allocation / GC pressure
alloc_tiny_objects: function(n) {
var sink = 0
var x = 0
for (var i = 0; i < n; i++) {
var o = { a: i, b: i + 1, c: i + 2 }
x = (x + o.b) | 0
}
return blackhole(sink, x)
},
alloc_linked_list: function(n) {
var sink = 0
var head = null
for (var i = 0; i < n; i++) head = { v: i, next: head }
var x = 0
var p = head
while (p) {
x = (x + p.v) | 0
p = p.next
}
return blackhole(sink, x)
},
// 8) meme-specific (adapt these to your exact semantics)
meme_clone_read: function(n) {
// If meme(obj) clones like Object.create / prototypal clone, this hits it hard.
// Replace with your exact meme call form.
var sink = 0
var base = { x: 1, y: 2 }
var x = 0
for (var i = 0; i < n; i++) {
var o = meme(base)
x = (x + o.x) | 0
}
return blackhole(sink, x)
},
}

View File

@@ -1,5 +1,5 @@
function mainThread() {
var maxDepth = Math.max(6, Number(arg[0] || 16));
var maxDepth = number.max(6, Number(arg[0] || 16));
var stretchDepth = maxDepth + 1;
var check = itemCheck(bottomUpTree(stretchDepth));
@@ -40,4 +40,4 @@ function bottomUpTree(depth) {
mainThread()
$_.stop()
$stop()

View File

@@ -1,8 +1,9 @@
var blob = use('blob')
var math = use('math/radians')
function eratosthenes (n) {
var sieve = new blob(n, true)
var sqrtN = Math.trunc(Math.sqrt(n));
var sqrtN = number.whole(math.sqrt(n));
for (i = 2; i <= sqrtN; i++)
if (sieve.read_logical(i))
@@ -21,4 +22,4 @@ for (var i = 0; i < sieve.length; i++)
log.console(c)
$_.stop()
$stop()

View File

@@ -55,4 +55,4 @@ var n = arg[0] || 10
log.console(`Pfannkuchen(${n}) = ${fannkuch(n)}`)
$_.stop()
$stop()

16
benchmarks/fib.ce Normal file
View File

@@ -0,0 +1,16 @@
var time = use('time')
function fib(n) {
if (n<2) return n
return fib(n-1) + fib(n-2)
}
var now = time.number()
var arr = [1,2,3,4,5]
for (var i in arr) {
log.console(fib(28))
}
log.console(`elapsed: ${time.number()-now}`)
$stop()

View File

@@ -1,4 +1,5 @@
var time = use('time')
var math = use('math/radians')
////////////////////////////////////////////////////////////////////////////////
// JavaScript Performance Benchmark Suite
@@ -6,7 +7,7 @@ var time = use('time')
////////////////////////////////////////////////////////////////////////////////
// Test configurations
const iterations = {
def iterations = {
simple: 10000000,
medium: 1000000,
complex: 100000
@@ -154,7 +155,7 @@ function benchObjectCreation() {
this.y = y;
}
var constructorTime = measureTime(function() {
var defructorTime = measureTime(function() {
for (var i = 0; i < iterations.medium; i++) {
var p = new Point(i, i * 2);
}
@@ -171,7 +172,7 @@ function benchObjectCreation() {
var prototypeTime = measureTime(function() {
for (var i = 0; i < iterations.medium; i++) {
var obj = Object.create(protoObj);
var obj = meme(protoObj);
obj.x = i;
obj.y = i * 2;
}
@@ -179,7 +180,7 @@ function benchObjectCreation() {
return {
literalTime: literalTime,
constructorTime: constructorTime,
defructorTime: defructorTime,
prototypeTime: prototypeTime
};
}
@@ -237,8 +238,8 @@ function benchArithmetic() {
var floatMathTime = measureTime(function() {
var result = 1.5;
for (var i = 0; i < iterations.simple; i++) {
result = Math.sin(result) + Math.cos(i * 0.01);
result = Math.sqrt(Math.abs(result)) + 0.1;
result = math.sine(result) + math.cosine(i * 0.01);
result = math.sqrt(number.abs(result)) + 0.1;
}
});
@@ -342,9 +343,9 @@ var objResults = benchObjectCreation();
log.console(" Literal: " + objResults.literalTime.toFixed(3) + "s => " +
(iterations.medium / objResults.literalTime).toFixed(1) + " creates/sec [" +
(objResults.literalTime / iterations.medium * 1e9).toFixed(1) + " ns/op]");
log.console(" Constructor: " + objResults.constructorTime.toFixed(3) + "s => " +
(iterations.medium / objResults.constructorTime).toFixed(1) + " creates/sec [" +
(objResults.constructorTime / iterations.medium * 1e9).toFixed(1) + " ns/op]");
log.console(" Constructor: " + objResults.defructorTime.toFixed(3) + "s => " +
(iterations.medium / objResults.defructorTime).toFixed(1) + " creates/sec [" +
(objResults.defructorTime / iterations.medium * 1e9).toFixed(1) + " ns/op]");
log.console(" Prototype: " + objResults.prototypeTime.toFixed(3) + "s => " +
(iterations.medium / objResults.prototypeTime).toFixed(1) + " creates/sec [" +
(objResults.prototypeTime / iterations.medium * 1e9).toFixed(1) + " ns/op]");
@@ -392,4 +393,4 @@ log.console("");
log.console("---------------------------------------------------------");
log.console("Benchmark complete.\n");
$_.stop()
$stop()

View File

@@ -37,4 +37,4 @@ for (let y = 0; y < h; ++y) {
log.console(text(row, 'b'));
}
$_.stop()
$stop()

View File

@@ -1,11 +1,12 @@
var math = use('math/radians')
var N = 1000000;
var num = 0;
for (var i = 0; i < N; i ++) {
var x = 2 * $_.random();
var y = $_.random();
if (y < Math.sin(x * x))
var x = 2 * $random();
var y = $random();
if (y < math.sine(x * x))
num++;
}
log.console(2 * num / N);
$_.stop()
$stop()

View File

@@ -1,5 +1,5 @@
var PI = Math.PI;
var SOLAR_MASS = 4 * PI * PI;
var math = use('math/radians')
var SOLAR_MASS = 4 * pi * pi;
var DAYS_PER_YEAR = 365.24;
function Body(x, y, z, vx, vy, vz, mass) {
@@ -67,11 +67,11 @@ function Sun() {
var bodies = Array(Sun(), Jupiter(), Saturn(), Uranus(), Neptune());
function offsetMomentum() {
let px = 0;
let py = 0;
let pz = 0;
var px = 0;
var py = 0;
var pz = 0;
var size = bodies.length;
for (let i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var body = bodies[i];
var mass = body.mass;
px += body.vx * mass;
@@ -88,19 +88,19 @@ function offsetMomentum() {
function advance(dt) {
var size = bodies.length;
for (let i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var bodyi = bodies[i];
let vxi = bodyi.vx;
let vyi = bodyi.vy;
let vzi = bodyi.vz;
for (let j = i + 1; j < size; j++) {
var vxi = bodyi.vx;
var vyi = bodyi.vy;
var vzi = bodyi.vz;
for (var j = i + 1; j < size; j++) {
var bodyj = bodies[j];
var dx = bodyi.x - bodyj.x;
var dy = bodyi.y - bodyj.y;
var dz = bodyi.z - bodyj.z;
var d2 = dx * dx + dy * dy + dz * dz;
var mag = dt / (d2 * Math.sqrt(d2));
var mag = dt / (d2 * math.sqrt(d2));
var massj = bodyj.mass;
vxi -= dx * massj * mag;
@@ -117,7 +117,7 @@ function advance(dt) {
bodyi.vz = vzi;
}
for (let i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var body = bodies[i];
body.x += dt * body.vx;
body.y += dt * body.vy;
@@ -126,36 +126,36 @@ function advance(dt) {
}
function energy() {
let e = 0;
var e = 0;
var size = bodies.length;
for (let i = 0; i < size; i++) {
for (var i = 0; i < size; i++) {
var bodyi = bodies[i];
e += 0.5 * bodyi.mass * ( bodyi.vx * bodyi.vx +
bodyi.vy * bodyi.vy + bodyi.vz * bodyi.vz );
for (let j = i + 1; j < size; j++) {
for (var j = i + 1; j < size; j++) {
var bodyj = bodies[j];
var dx = bodyi.x - bodyj.x;
var dy = bodyi.y - bodyj.y;
var dz = bodyi.z - bodyj.z;
var distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
var distance = math.sqrt(dx * dx + dy * dy + dz * dz);
e -= (bodyi.mass * bodyj.mass) / distance;
}
}
return e;
}
var n = arg[0] || 1000000
var n = arg[0] || 100000
offsetMomentum();
log.console(`n = ${n}`)
log.console(energy().toFixed(9))
for (let i = 0; i < n; i++)
for (var i = 0; i < n; i++)
advance(0.01);
log.console(energy().toFixed(9))
$_.stop()
$stop()

View File

@@ -1,6 +1,7 @@
var nota = use('nota')
var os = use('os')
var io = use('io')
var io = use('fd')
var json = use('json')
var ll = io.slurp('benchmarks/nota.json')
@@ -43,8 +44,8 @@ for (let i = 0; i < 100; i++) {
// Calculate statistics
function getStats(arr) {
def avg = arr.reduce((a, b) => a + b) / arr.length;
def min = Math.min(...arr);
def max = Math.max(...arr);
def min = number.min(...arr);
def max = number.max(...arr);
return { avg, min, max };
}

View File

@@ -1,3 +1,5 @@
const math = require('math/radians');
function A(i,j) {
return 1/((i+j)*(i+j+1)/2+i+1);
}
@@ -42,9 +44,9 @@ function spectralnorm(n) {
vv += v[i]*v[i];
}
return Math.sqrt(vBv/vv);
return math.sqrt(vBv/vv);
}
log.console(spectralnorm(arg[0]).toFixed(9));
$_.stop()
$stop()

View File

@@ -15,7 +15,7 @@
// Parse command line arguments
if (arg.length != 2) {
log.console('Usage: cell benchmark_wota_nota_json.ce <LibraryName> <ScenarioName>');
$_.stop()
$stop()
}
var lib_name = arg[0];
@@ -172,13 +172,13 @@ var bench = benchmarks.find(b => b.name == scenario_name);
if (!lib) {
log.console('Unknown library:', lib_name);
log.console('Available libraries:', libraries.map(l => l.name).join(', '));
$_.stop()
$stop()
}
if (!bench) {
log.console('Unknown scenario:', scenario_name);
log.console('Available scenarios:', benchmarks.map(b => b.name).join(', '));
$_.stop()
$stop()
}
// Run the benchmark for this library/scenario combination
@@ -199,6 +199,6 @@ var result = {
decodeNsPerOp: (decodeTime / totalOps) * 1e9
};
log.console(json.encode(result));
log.console(result);
$_.stop()
$stop()

102
build.ce Normal file
View File

@@ -0,0 +1,102 @@
// cell build [options] - Build dynamic libraries locally for the current machine
//
// Usage:
// cell build Build dynamic libraries for all packages
// cell build -p <pkg> Build dynamic library for specific package
// cell build -t <target> Cross-compile dynamic libraries for target platform
var build = use('build')
var shop = use('internal/shop')
var pkg_tools = use('package')
var fd = use('fd')
var target = null
var target_package = null
var buildtype = 'debug'
for (var i = 0; i < args.length; i++) {
if (args[i] == '-t' || args[i] == '--target') {
if (i + 1 < args.length) {
target = args[++i]
} else {
log.error('-t requires a target')
$stop()
}
} else if (args[i] == '-p' || args[i] == '--package') {
if (i + 1 < args.length) {
target_package = args[++i]
} else {
log.error('-p requires a package name')
$stop()
}
} else if (args[i] == '-b' || args[i] == '--buildtype') {
if (i + 1 < args.length) {
buildtype = args[++i]
if (buildtype != 'release' && buildtype != 'debug' && buildtype != 'minsize') {
log.error('Invalid buildtype: ' + buildtype + '. Must be release, debug, or minsize')
$stop()
}
} else {
log.error('-b requires a buildtype (release, debug, minsize)')
$stop()
}
} else if (args[i] == '--list-targets') {
log.console('Available targets:')
var targets = build.list_targets()
for (var t = 0; t < targets.length; t++) {
log.console(' ' + targets[t])
}
$stop()
}
}
// Detect target if not specified
if (!target) {
target = build.detect_host_target()
if (target) log.console('Target: ' + target)
}
if (target && !build.has_target(target)) {
log.error('Invalid target: ' + target)
log.console('Available targets: ' + build.list_targets().join(', '))
$stop()
}
var packages = shop.list_packages()
log.console('Preparing packages...')
for (var package of packages) {
if (package == 'core') continue
shop.extract(package)
}
if (target_package) {
// Build single package
log.console('Building ' + target_package + '...')
try {
var lib = build.build_dynamic(target_package, target, buildtype)
if (lib) {
log.console('Built: ' + lib)
}
} catch (e) {
log.error('Build failed: ' + e)
$stop()
}
} else {
// Build all packages
log.console('Building all packages...')
var results = build.build_all_dynamic(target, buildtype)
var success = 0
var failed = 0
for (var i = 0; i < results.length; i++) {
if (results[i].library) {
success++
} else if (results[i].error) {
failed++
}
}
log.console(`Build complete: ${success} libraries built${failed > 0 ? `, ${failed} failed` : ''}`)
}
$stop()

406
build.cm Normal file
View File

@@ -0,0 +1,406 @@
// build.cm - Simplified build utilities for Cell
//
// Key functions:
// Build.compile_file(pkg, file, target) - Compile a C file, returns object path
// Build.build_package(pkg, target) - Build all C files for a package
// Build.build_dynamic(pkg, target) - Build dynamic library for a package
// Build.build_static(packages, target, output) - Build static binary
var fd = use('fd')
var crypto = use('crypto')
var blob = use('blob')
var os = use('os')
var toolchains = use('toolchains')
var shop = use('internal/shop')
var pkg_tools = use('package')
var Build = {}
// ============================================================================
// Sigil replacement
// ============================================================================
// Get the local directory for prebuilt libraries
function get_local_dir() {
return shop.get_local_dir()
}
// Replace sigils in a string
// Currently supports: $LOCAL -> .cell/local full path
function replace_sigils(str) {
return str.replaceAll('$LOCAL', get_local_dir())
}
// Replace sigils in an array of flags
function replace_sigils_array(flags) {
var result = []
for (var i = 0; i < flags.length; i++) {
result.push(replace_sigils(flags[i]))
}
return result
}
Build.get_local_dir = get_local_dir
// ============================================================================
// Toolchain helpers
// ============================================================================
Build.list_targets = function() {
return array(toolchains)
}
Build.has_target = function(target) {
return toolchains[target] != null
}
Build.detect_host_target = function() {
var platform = os.platform()
var arch = os.arch ? os.arch() : 'arm64'
if (platform == 'macOS' || platform == 'darwin') {
return arch == 'x86_64' ? 'macos_x86_64' : 'macos_arm64'
} else if (platform == 'Linux' || platform == 'linux') {
return arch == 'x86_64' ? 'linux' : 'linux_arm64'
} else if (platform == 'Windows' || platform == 'windows') {
return 'windows'
}
return null
}
// ============================================================================
// Content-addressed build cache
// ============================================================================
function content_hash(str) {
var bb = stone(new blob(str))
return text(crypto.blake2(bb, 32), 'h')
}
function get_build_dir() {
return shop.get_build_dir()
}
function ensure_dir(path) {
if (fd.stat(path).isDirectory) return
var parts = path.split('/')
var current = path.startsWith('/') ? '/' : ''
for (var i = 0; i < parts.length; i++) {
if (parts[i] == '') continue
current += parts[i] + '/'
if (!fd.stat(current).isDirectory) {
fd.mkdir(current)
}
}
}
Build.ensure_dir = ensure_dir
// ============================================================================
// Compilation
// ============================================================================
// Compile a single C file for a package
// Returns the object file path (content-addressed in .cell/build)
Build.compile_file = function(pkg, file, target, buildtype = 'release') {
var pkg_dir = shop.get_package_dir(pkg)
var src_path = pkg_dir + '/' + file
if (!fd.is_file(src_path)) {
throw new Error('Source file not found: ' + src_path)
}
// Get flags (with sigil replacement)
var cflags = replace_sigils_array(pkg_tools.get_flags(pkg, 'CFLAGS', target))
var target_cflags = toolchains[target].c_args || []
var cc = toolchains[target].c
// Symbol name for this file
var sym_name = shop.c_symbol_for_file(pkg, file)
// Build command
var cmd_parts = [cc, '-c', '-fPIC']
// Add buildtype-specific flags
if (buildtype == 'release') {
cmd_parts.push('-O3', '-DNDEBUG')
} else if (buildtype == 'debug') {
cmd_parts.push('-O2', '-g')
} else if (buildtype == 'minsize') {
cmd_parts.push('-Os', '-DNDEBUG')
}
cmd_parts.push('-DCELL_USE_NAME=' + sym_name)
cmd_parts.push('-I"' + pkg_dir + '"')
// Add package CFLAGS (resolve relative -I paths)
for (var i = 0; i < cflags.length; i++) {
var flag = cflags[i]
if (flag.startsWith('-I') && !flag.startsWith('-I/')) {
flag = '-I"' + pkg_dir + '/' + flag.substring(2) + '"'
}
cmd_parts.push(flag)
}
// Add target CFLAGS
for (var i = 0; i < target_cflags.length; i++) {
cmd_parts.push(target_cflags[i])
}
cmd_parts.push('"' + src_path + '"')
var cmd_str = cmd_parts.join(' ')
// Content hash: command + file content
var file_content = fd.slurp(src_path)
var hash_input = cmd_str + '\n' + text(file_content)
var hash = content_hash(hash_input)
var build_dir = get_build_dir()
ensure_dir(build_dir)
var obj_path = build_dir + '/' + hash
// Check if already compiled
if (fd.is_file(obj_path)) {
return obj_path
}
// Compile
var full_cmd = cmd_str + ' -o "' + obj_path + '"'
log.console('Compiling ' + file)
var ret = os.system(full_cmd)
if (ret != 0) {
throw new Error('Compilation failed: ' + file)
}
return obj_path
}
// Build all C files for a package
// Returns array of object file paths
Build.build_package = function(pkg, target = Build.detect_host_target(), exclude_main, buildtype = 'release') {
var c_files = pkg_tools.get_c_files(pkg, target, exclude_main)
var objects = []
for (var i = 0; i < c_files.length; i++) {
var obj = Build.compile_file(pkg, c_files[i], target, buildtype)
objects.push(obj)
}
return objects
}
// ============================================================================
// Dynamic library building
// ============================================================================
// Build a dynamic library for a package
// Output goes to .cell/lib/<package_name>.<ext>
// Dynamic libraries do NOT link against core; undefined symbols are resolved at dlopen time
Build.build_dynamic = function(pkg, target = Build.detect_host_target(), buildtype = 'release') {
var objects = Build.build_package(pkg, target, true, buildtype) // exclude main.c
if (objects.length == 0) {
log.console('No C files in ' + pkg)
return null
}
var lib_dir = shop.get_lib_dir()
ensure_dir(lib_dir)
var lib_name = shop.lib_name_for_package(pkg)
var dylib_ext = toolchains[target].system == 'windows' ? '.dll' : (toolchains[target].system == 'darwin' ? '.dylib' : '.so')
var lib_path = lib_dir + '/' + lib_name + dylib_ext
// Get link flags (with sigil replacement)
var ldflags = replace_sigils_array(pkg_tools.get_flags(pkg, 'LDFLAGS', target))
var target_ldflags = toolchains[target].c_link_args || []
var cc = toolchains[target].cpp || toolchains[target].c
var pkg_dir = shop.get_package_dir(pkg)
var local_dir = get_local_dir()
var tc = toolchains[target]
// Build link command
var cmd_parts = [cc, '-shared', '-fPIC']
// Platform-specific flags for undefined symbols (resolved at dlopen) and size optimization
if (tc.system == 'darwin') {
// Allow undefined symbols - they will be resolved when dlopen'd into the main executable
cmd_parts.push('-undefined', 'dynamic_lookup')
// Dead-strip unused code
cmd_parts.push('-Wl,-dead_strip')
// rpath for .cell/local libraries
cmd_parts.push('-Wl,-rpath,@loader_path/../local')
cmd_parts.push('-Wl,-rpath,' + local_dir)
} else if (tc.system == 'linux') {
// Allow undefined symbols at link time
cmd_parts.push('-Wl,--allow-shlib-undefined')
// Garbage collect unused sections
cmd_parts.push('-Wl,--gc-sections')
// rpath for .cell/local libraries
cmd_parts.push('-Wl,-rpath,$ORIGIN/../local')
cmd_parts.push('-Wl,-rpath,' + local_dir)
} else if (tc.system == 'windows') {
// Windows DLLs: use --allow-shlib-undefined for mingw
cmd_parts.push('-Wl,--allow-shlib-undefined')
}
// Add .cell/local to library search path
cmd_parts.push('-L"' + local_dir + '"')
for (var i = 0; i < objects.length; i++) {
cmd_parts.push('"' + objects[i] + '"')
}
// Do NOT link against core library - symbols resolved at dlopen time
// Add LDFLAGS (resolve relative -L paths)
for (var i = 0; i < ldflags.length; i++) {
var flag = ldflags[i]
if (flag.startsWith('-L') && !flag.startsWith('-L/')) {
flag = '-L"' + pkg_dir + '/' + flag.substring(2) + '"'
}
cmd_parts.push(flag)
}
for (var i = 0; i < target_ldflags.length; i++) {
cmd_parts.push(target_ldflags[i])
}
cmd_parts.push('-o', '"' + lib_path + '"')
var cmd_str = cmd_parts.join(' ')
log.console('Linking ' + lib_path)
var ret = os.system(cmd_str)
if (ret != 0) {
throw new Error('Linking failed: ' + pkg)
}
return lib_path
}
// ============================================================================
// Static binary building
// ============================================================================
// Build a static binary from multiple packages
// packages: array of package names
// output: output binary path
Build.build_static = function(packages, target = Build.detect_host_target(), output, buildtype = 'release') {
var all_objects = []
var all_ldflags = []
var seen_flags = {}
// Compile all packages
for (var i = 0; i < packages.length; i++) {
var pkg = packages[i]
var is_core = (pkg == 'core')
// For core, include main.c; for others, exclude it
var objects = Build.build_package(pkg, target, !is_core, buildtype)
for (var j = 0; j < objects.length; j++) {
all_objects.push(objects[j])
}
// Collect LDFLAGS (with sigil replacement)
var ldflags = replace_sigils_array(pkg_tools.get_flags(pkg, 'LDFLAGS', target))
var pkg_dir = shop.get_package_dir(pkg)
// Deduplicate based on the entire LDFLAGS string for this package
var ldflags_key = pkg + ':' + ldflags.join(' ')
if (!seen_flags[ldflags_key]) {
seen_flags[ldflags_key] = true
for (var j = 0; j < ldflags.length; j++) {
var flag = ldflags[j]
// Resolve relative -L paths
if (flag.startsWith('-L') && !flag.startsWith('-L/')) {
flag = '-L"' + pkg_dir + '/' + flag.substring(2) + '"'
}
all_ldflags.push(flag)
}
}
}
if (all_objects.length == 0) {
throw new Error('No object files to link')
}
// Link
var cc = toolchains[target].c
var target_ldflags = toolchains[target].c_link_args || []
var exe_ext = toolchains[target].system == 'windows' ? '.exe' : ''
if (!output.endsWith(exe_ext) && exe_ext) {
output = output + exe_ext
}
var cmd_parts = [cc]
for (var i = 0; i < all_objects.length; i++) {
cmd_parts.push('"' + all_objects[i] + '"')
}
for (var i = 0; i < all_ldflags.length; i++) {
cmd_parts.push(all_ldflags[i])
}
for (var i = 0; i < target_ldflags.length; i++) {
cmd_parts.push(target_ldflags[i])
}
cmd_parts.push('-o', '"' + output + '"')
var cmd_str = cmd_parts.join(' ')
log.console('Linking ' + output)
var ret = os.system(cmd_str)
if (ret != 0) {
throw new Error('Linking failed with command: ' + cmd_str)
}
log.console('Built ' + output)
return output
}
// ============================================================================
// Convenience functions
// ============================================================================
// Build dynamic libraries for all installed packages
Build.build_all_dynamic = function(target, buildtype = 'release') {
target = target || Build.detect_host_target()
var packages = shop.list_packages()
var results = []
// Build core first
if (packages.indexOf('core') >= 0) {
try {
var lib = Build.build_dynamic('core', target, buildtype)
results.push({ package: 'core', library: lib })
} catch (e) {
log.error('Failed to build core: ' + text(e))
results.push({ package: 'core', error: e })
}
}
// Build other packages
for (var i = 0; i < packages.length; i++) {
var pkg = packages[i]
if (pkg == 'core') continue
try {
var lib = Build.build_dynamic(pkg, target, buildtype)
results.push({ package: pkg, library: lib })
} catch (e) {
log.error('Failed to build ' + pkg + ': ')
log.error(e)
results.push({ package: pkg, error: e })
}
}
return results
}
return Build

1
cake/playdate.cm Normal file
View File

@@ -0,0 +1 @@
// cake file for making a playdate package

124
cell.md
View File

@@ -1,124 +0,0 @@
JAVASCRIPT VISION
I see objects as being a sort of combination of a lisp cell and a record: symbols, which are used internally, and are private and non iterable, and record string values, which are iterable, readable, and writable; of course everything becomes locked in when stone.
CELLSCRIPT
Javascript to its core. Objects. What does the language need? It can be quite small, I think. The key is, ANYTHING that we want to be fast and JIT'd, must be present. So, record lookups. These are actually quicker in a jit'd language that have them as a feature. Most things should be libraries. Blobs need to be in the runtime.
The purpose of this is to be a great language for passing messages. So it should be fast at creating records first and foremost, and finding items on them. So it needs first class, jitt'd records.
Finally, it needs to use less memory. Deleting a bunch of this stuff should make that simpler.
What is present?
Objects, prototypes, numbers, arrays, strings, true, false, null.
Things to do:
merge typeof and instanceof. Misty has array? stone? number? etc; it needs to be generic. 5 is number returns true.
No new operator. It's the same idea though: simply instead of 'var guy = new sprite({x,y})' you would say 'var guy = sprite({x,y})', and sprite would simply be a function written to return a sprite object.
One number type. Dec64. Numeric stack can be added in later: a bigint library, for example, built inside cell.
Simplify the property attributes stuff. It is simple: objects have text keys and whatever values. Objects can also have objects as values. These work like symbols. You can share them, if desired. No well known symbols exist to eliminate that much misdirection. Obejcts basically work like private keys. If you serialize an object, objects that are keys are not serialized; only textual keys are. You can do something about it with a json() method that is invoked, if you desire. You cannot retrieve
var works like let; use var instead of let
no const
Function closures and _ => all work the same and close over the 'this' variable
Totally delete modules, coroutines, generators, proxy .. this deletes a lot of the big switch statement
Add the 'go' statement for tail calls
Add the 'do' statement
Implementation detail: separate out arrays and objects. They are not the same. Objects no longer need to track if they're fast arrays or not. They're not. Arrays are. Always.
Add the functional proxy idea. Log will be implemented through that.
Remove ===; it's just == now, and !=.
Remove 'continue'; now, break handles both. For a do statement, label it, and break to that label; so
var x = 0
do loop {
x++
if (x < 5) break loop // goes back to loop
break // exits loop
}
rename instanceof to 'is'
remove undefined; all are 'null' now
remove 'delete'; to remove a field, assign it to null
remove with
Remove Object. New records have a prototype of nothing. There are no more 'type prototypes' at all.
Arrays are their own type
Remove property descriptors. Properties are always settable, unless the object as a whole is stone. Stone is an object property instead of a shape property.
Syntax stuff .. would like to invoke functions without (). This can effectively simulate a "getter". Make ? and all other characters usable for names. No reserve words, which are endlessly irritating.
----
This will all actually come about gradually. Add a few things at a time, fix up code that did not adhere. For a lot of this, no new functions will even need to be written; it's a matter of not calling certain functions that are no longer relevant, or calling different functions when required.
## Benchmarks to implement
### general speed
binarytrees
coro-prime-sieve
edigits
fannkuch-redux
fasta
http-server
json serialize/deserialize
knucleotide
lru
mandelbrot
merkletrees
nbody
nsieve
pidigits
regex-redux
secp256k1
spectral-norm
### function calling and recursion stress - test goto
naive recursive fibonacci [fib(35) or fib(40)]
tak
ackermann
### numeric
sieve of eratosthenes [10^7 bits]
spectral norm [5500 x 5500 matrix]
n-body sim [50 000 - 100 000 steps]
mandelbrot [1600x1200 image, max iter = 50]
### memory & gc torture
binary trees [depth 18 (~500 000 nodes)]
richards task scheduler
fannkuch redux [n=11 or 12]
### dynamic object & property access
deltablue constraint solver
splay tree [256k nodes]
json, wota, nota decode->encode [use 2MB example]
### string / regex kernels
regex-DNA
fasta
word-frequency
### concurrency/message passing
ping-pong [two actors exhange a small record N times, 1M messages end to end]
chameneos [mating color swap game w/ randezvous]
For all, track memory and time.

13
cell.toml Normal file
View File

@@ -0,0 +1,13 @@
[compilation]
CFLAGS = "-Isource -Wno-incompatible-pointer-types -Wno-missing-braces -Wno-strict-prototypes -Wno-unused-function -Wno-int-conversion"
LDFLAGS = "-lstdc++ -lm"
[compilation.macos_arm64]
CFLAGS = "-x objective-c"
LDFLAGS = "-framework CoreFoundation -framework CFNetwork"
[compilation.playdate]
CFLAGS = "-DMINIZ_NO_TIME -DTARGET_EXTENSION -DTARGET_PLAYDATE -I$LOCAL/PlaydateSDK/C_API"
[compilation.windows]
LDFLAGS = "-lws2_32 -lwinmm -liphlpapi -lbcrypt -lwinhttp -static-libgcc -static-libstdc++"

481
cellfs.cm Normal file
View File

@@ -0,0 +1,481 @@
var cellfs = {}
// CellFS: A filesystem implementation using miniz and raw OS filesystem
// Supports mounting multiple sources (fs, zip) and named mounts (@name)
var fd = use('fd')
var miniz = use('miniz')
var qop = use('qop')
var wildstar = use('wildstar')
// Internal state
var mounts = [] // Array of {source, type, handle, name}
var writepath = "."
// Helper to normalize paths
function normalize_path(path) {
if (!path) return ""
// Remove leading/trailing slashes and normalize
return path.replace(/^\/+|\/+$/g, "")
}
// Helper to get directory from path
function dirname(path) {
var idx = path.lastIndexOf("/")
if (idx == -1) return ""
return path.substring(0, idx)
}
// Helper to get basename from path
function basename(path) {
var idx = path.lastIndexOf("/")
if (idx == -1) return path
return path.substring(idx + 1)
}
// Helper to join paths
function join_paths(base, rel) {
base = base.replace(/\/+$/, "")
rel = rel.replace(/^\/+/, "")
if (!base) return rel
if (!rel) return base
return base + "/" + rel
}
// Check if a file exists in a specific mount
function mount_exists(mount, path) {
if (mount.type == 'zip') {
try {
mount.handle.mod(path)
return true
} catch (e) {
return false
}
} else if (mount.type == 'qop') {
try {
return mount.handle.stat(path) != null
} catch (e) {
return false
}
} else { // fs
var full_path = join_paths(mount.source, path)
try {
var st = fd.stat(full_path)
return st.isFile || st.isDirectory
} catch (e) {
return false
}
}
}
// Check if a path refers to a directory in a specific mount
function is_directory(path) {
var res = resolve(path)
var mount = res.mount
if (mount.type == 'zip') {
try {
return mount.handle.is_directory(path);
} catch (e) {
return false;
}
} else if (mount.type == 'qop') {
try {
return mount.handle.is_directory(path);
} catch (e) {
return false;
}
} else { // fs
var full_path = join_paths(mount.source, path)
try {
var st = fd.stat(full_path)
return st.isDirectory
} catch (e) {
return false
}
}
}
// Resolve a path to a specific mount and relative path
// Returns { mount, path } or throws/returns null
function resolve(path, must_exist) {
path = normalize_path(path)
// Check for named mount
if (path.startsWith("@")) {
var idx = path.indexOf("/")
var mount_name = ""
var rel_path = ""
if (idx == -1) {
mount_name = path.substring(1)
rel_path = ""
} else {
mount_name = path.substring(1, idx)
rel_path = path.substring(idx + 1)
}
// Find named mount
var mount = null
for (var m of mounts) {
if (m.name == mount_name) {
mount = m
break
}
}
if (!mount) {
throw new Error("Unknown mount point: @" + mount_name)
}
return { mount: mount, path: rel_path }
}
// Search path
for (var mount of mounts) {
if (mount_exists(mount, path)) {
return { mount: mount, path: path }
}
}
if (must_exist) {
throw new Error("File not found in any mount: " + path)
}
}
// Mount a source
function mount(source, name) {
// Check if source exists
var st = fd.stat(source)
var mount_info = {
source: source,
name: name || null,
type: 'fs',
handle: null,
zip_blob: null
}
if (st.isDirectory) {
mount_info.type = 'fs'
} else if (st.isFile) {
var blob = fd.slurp(source)
// Try QOP first (it's likely faster to fail?) or Zip?
// QOP open checks magic.
var qop_archive = null
try {
qop_archive = qop.open(blob)
} catch(e) {}
if (qop_archive) {
mount_info.type = 'qop'
mount_info.handle = qop_archive
mount_info.zip_blob = blob // keep blob alive
} else {
var zip = miniz.read(blob)
if (!zip || typeof zip.count != 'function') {
throw new Error("Invalid archive file (not zip or qop): " + source)
}
mount_info.type = 'zip'
mount_info.handle = zip
mount_info.zip_blob = blob // keep blob alive
}
} else {
throw new Error("Unsupported mount source type: " + source)
}
mounts.push(mount_info)
}
// Unmount
function unmount(name_or_source) {
for (var i = 0; i < mounts.length; i++) {
if (mounts[i].name == name_or_source || mounts[i].source == name_or_source) {
mounts.splice(i, 1)
return
}
}
throw new Error("Mount not found: " + name_or_source)
}
// Read file
function slurp(path) {
var res = resolve(path, true)
if (!res) throw new Error("File not found: " + path)
if (res.mount.type == 'zip') {
return res.mount.handle.slurp(res.path)
} else if (res.mount.type == 'qop') {
var data = res.mount.handle.read(res.path)
if (!data) throw new Error("File not found in qop: " + path)
return data
} else {
var full_path = join_paths(res.mount.source, res.path)
return fd.slurp(full_path)
}
}
// Write file
function slurpwrite(path, data) {
var full_path = writepath + "/" + path
var f = fd.open(full_path, 'w')
fd.write(f, data)
fd.close(f)
}
// Check existence
function exists(path) {
var res = resolve(path, false)
if (path.startsWith("@")) {
return mount_exists(res.mount, res.path)
}
return res != null
}
// Stat
function stat(path) {
var res = resolve(path, true)
if (!res) throw new Error("File not found: " + path)
if (res.mount.type == 'zip') {
var mod = res.mount.handle.mod(res.path)
return {
filesize: 0,
modtime: mod * 1000,
isDirectory: false
}
} else if (res.mount.type == 'qop') {
var s = res.mount.handle.stat(res.path)
if (!s) throw new Error("File not found in qop: " + path)
return {
filesize: s.size,
modtime: s.modtime,
isDirectory: s.isDirectory
}
} else {
var full_path = join_paths(res.mount.source, res.path)
var s = fd.stat(full_path)
return {
filesize: s.size,
modtime: s.mtime,
isDirectory: s.isDirectory
}
}
}
// Get search paths
function searchpath() {
return mounts.slice()
}
// Mount a package using the shop system
function mount_package(name) {
if (name == null) {
mount('.', null)
return
}
var shop = use('internal/shop')
var dir = shop.get_package_dir(name)
if (!dir) {
throw new Error("Package not found: " + name)
}
mount(dir, name)
}
// New functions for qjs_io compatibility
function match(str, pattern) {
return wildstar.match(pattern, str, wildstar.WM_PATHNAME | wildstar.WM_PERIOD | wildstar.WM_WILDSTAR)
}
function rm(path) {
var res = resolve(path, true)
if (res.mount.type != 'fs') throw new Error("Cannot delete from non-fs mount")
var full_path = join_paths(res.mount.source, res.path)
var st = fd.stat(full_path)
if (st.isDirectory) fd.rmdir(full_path)
else fd.unlink(full_path)
}
function mkdir(path) {
var full = join_paths(writepath, path)
fd.mkdir(full)
}
function set_writepath(path) {
writepath = path
}
function basedir() {
return fd.getcwd()
}
function prefdir(org, app) {
return "./"
}
function realdir(path) {
var res = resolve(path, false)
if (!res) return null
return join_paths(res.mount.source, res.path)
}
function enumerate(path, recurse) {
if (path == null) path = ""
var res = resolve(path, true)
var results = []
function visit(curr_full, rel_prefix) {
var list = fd.readdir(curr_full)
if (!list) return
for (var item of list) {
var item_rel = rel_prefix ? rel_prefix + "/" + item : item
results.push(item_rel)
if (recurse) {
var st = fd.stat(join_paths(curr_full, item))
if (st.isDirectory) {
visit(join_paths(curr_full, item), item_rel)
}
}
}
}
if (res.mount.type == 'fs') {
var full = join_paths(res.mount.source, res.path)
var st = fd.stat(full)
if (st && st.isDirectory) {
visit(full, "")
}
} else if (res.mount.type == 'qop') {
var all = res.mount.handle.list()
var prefix = res.path ? res.path + "/" : ""
var prefix_len = prefix.length
// Use a set to avoid duplicates if we are simulating directories
var seen = {}
for (var p of all) {
if (p.startsWith(prefix)) {
var rel = p.substring(prefix_len)
if (rel.length == 0) continue
if (!recurse) {
var slash = rel.indexOf('/')
if (slash != -1) {
rel = rel.substring(0, slash)
}
}
if (!seen[rel]) {
seen[rel] = true
results.push(rel)
}
}
}
}
return results
}
function globfs(globs, dir) {
if (dir == null) dir = ""
var res = resolve(dir, true)
var results = []
function check_neg(path) {
for (var g of globs) {
if (g.startsWith("!") && wildstar.match(g.substring(1), path, wildstar.WM_WILDSTAR)) return true;
}
return false;
}
function check_pos(path) {
for (var g of globs) {
if (!g.startsWith("!") && wildstar.match(g, path, wildstar.WM_WILDSTAR)) return true;
}
return false;
}
function visit(curr_full, rel_prefix) {
if (rel_prefix && check_neg(rel_prefix)) return
var list = fd.readdir(curr_full)
if (!list) return
for (var item of list) {
var item_rel = rel_prefix ? rel_prefix + "/" + item : item
var child_full = join_paths(curr_full, item)
var st = fd.stat(child_full)
if (st.isDirectory) {
if (!check_neg(item_rel)) {
visit(child_full, item_rel)
}
} else {
if (!check_neg(item_rel) && check_pos(item_rel)) {
results.push(item_rel)
}
}
}
}
if (res.mount.type == 'fs') {
var full = join_paths(res.mount.source, res.path)
var st = fd.stat(full)
if (st && st.isDirectory) {
visit(full, "")
}
} else if (res.mount.type == 'qop') {
var all = res.mount.handle.list()
var prefix = res.path ? res.path + "/" : ""
var prefix_len = prefix.length
for (var p of all) {
if (p.startsWith(prefix)) {
var rel = p.substring(prefix_len)
if (rel.length == 0) continue
if (!check_neg(rel) && check_pos(rel)) {
results.push(rel)
}
}
}
}
return results
}
// Exports
cellfs.mount = mount
cellfs.mount_package = mount_package
cellfs.unmount = unmount
cellfs.slurp = slurp
cellfs.slurpwrite = slurpwrite
cellfs.exists = exists
cellfs.is_directory = is_directory
cellfs.stat = stat
cellfs.searchpath = searchpath
cellfs.match = match
cellfs.enumerate = enumerate
cellfs.globfs = globfs
cellfs.rm = rm
cellfs.mkdir = mkdir
cellfs.writepath = set_writepath
cellfs.basedir = basedir
cellfs.prefdir = prefdir
cellfs.realdir = realdir
cellfs.mount('.')
return cellfs

26
clean.ce Normal file
View File

@@ -0,0 +1,26 @@
// cell clean - Remove build artifacts from global shop
var fd = use('fd')
var shop = use('internal/shop')
var build_dir = shop.get_shop_path() + '/build'
if (!fd.is_dir(build_dir)) {
log.console("No build directory found at " + build_dir)
$stop()
return
}
log.console("Cleaning build artifacts...")
// Remove the build directory
try {
fd.rm(build_dir)
log.console("Build directory removed: " + build_dir)
} catch (e) {
log.error(e)
}
log.console("Clean complete!")
$stop()

122
clone.ce Normal file
View File

@@ -0,0 +1,122 @@
// cell clone <origin> <path>
// Clones a cell package <origin> to the local <path>, and links it.
var shop = use('internal/shop')
var link = use('link')
var fd = use('fd')
var http = use('http')
var miniz = use('miniz')
if (args.length < 2) {
log.console("Usage: cell clone <origin> <path>")
log.console("Clones a cell package to a local path and links it.")
$stop()
return
}
var origin = args[0]
var target_path = args[1]
// Resolve target path to absolute
if (target_path == '.' || target_path.startsWith('./') || target_path.startsWith('../')) {
var resolved = fd.realpath(target_path)
if (resolved) {
target_path = resolved
} else {
// Path doesn't exist yet, resolve relative to cwd
var cwd = fd.realpath('.')
if (target_path == '.') {
target_path = cwd
} else if (target_path.startsWith('./')) {
target_path = cwd + target_path.substring(1)
} else if (target_path.startsWith('../')) {
// Go up one directory from cwd
var parent = cwd.substring(0, cwd.lastIndexOf('/'))
target_path = parent + target_path.substring(2)
}
}
}
// Check if target already exists
if (fd.is_dir(target_path)) {
log.console("Error: " + target_path + " already exists")
$stop()
return
}
log.console("Cloning " + origin + " to " + target_path + "...")
// Get the latest commit
var info = shop.resolve_package_info(origin)
if (!info || info == 'local') {
log.console("Error: " + origin + " is not a remote package")
$stop()
return
}
// Update to get the commit hash
var update_result = shop.update(origin)
if (!update_result) {
log.console("Error: Could not fetch " + origin)
$stop()
return
}
// Fetch and extract to the target path
var lock = shop.load_lock()
var entry = lock[origin]
if (!entry || !entry.commit) {
log.console("Error: No commit found for " + origin)
$stop()
return
}
var download_url = shop.get_download_url(origin, entry.commit)
log.console("Downloading from " + download_url)
try {
var zip_blob = http.fetch(download_url)
// Extract zip to target path
var zip = miniz.read(zip_blob)
if (!zip) {
log.console("Error: Failed to read zip archive")
$stop()
return
}
// Create target directory
fd.mkdir(target_path)
var count = zip.count()
for (var i = 0; i < count; i++) {
if (zip.is_directory(i)) continue
var filename = zip.get_filename(i)
var parts = filename.split('/')
if (parts.length <= 1) continue
// Skip the first directory (repo-commit prefix)
parts.shift()
var rel_path = parts.join('/')
var full_path = target_path + '/' + rel_path
var dir_path = full_path.substring(0, full_path.lastIndexOf('/'))
// Ensure directory exists
if (!fd.is_dir(dir_path)) {
fd.mkdir(dir_path)
}
fd.slurpwrite(full_path, zip.slurp(filename))
}
log.console("Extracted to " + target_path)
// Link the origin to the cloned path
link.add(origin, target_path, shop)
log.console("Linked " + origin + " -> " + target_path)
} catch (e) {
log.console("Error: " + e.message)
if (e.stack) log.console(e.stack)
}
$stop()

View File

@@ -1,9 +1,7 @@
// cell config - Manage system and actor configurations
var io = use('io')
var toml = use('toml')
var shop = use('shop')
var text = use('text')
var pkg = use('package')
function print_help() {
log.console("Usage: cell config <command> [options]")
@@ -81,7 +79,7 @@ function format_value(val) {
// Add underscores to large numbers
return val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '_')
}
return String(val)
return text(val)
}
// Print configuration tree recursively
@@ -90,25 +88,24 @@ function print_config(obj, prefix = '') {
var val = obj[key]
var full_key = prefix ? prefix + '.' + key : key
if (val && typeof val == 'object' && !Array.isArray(val)) {
if (isa(val, object))
print_config(val, full_key)
} else {
else
log.console(full_key + ' = ' + format_value(val))
}
}
}
// Main command handling
if (args.length == 0) {
print_help()
$_.stop()
$stop()
return
}
var config = shop.load_config()
var config = pkg.load_config()
if (!config) {
log.error("Failed to load .cell/cell.toml")
$_.stop()
log.error("Failed to load cell.toml")
$stop()
return
}
@@ -130,7 +127,7 @@ switch (command) {
case 'get':
if (args.length < 2) {
log.error("Usage: cell config get <key>")
$_.stop()
$stop()
return
}
var key = args[1]
@@ -139,7 +136,7 @@ switch (command) {
if (value == null) {
log.error("Key not found: " + key)
} else if (value && typeof value == 'object' && !Array.isArray(value)) {
} else if (isa(value, object)) {
// Print all nested values
print_config(value, key)
} else {
@@ -150,7 +147,7 @@ switch (command) {
case 'set':
if (args.length < 3) {
log.error("Usage: cell config set <key> <value>")
$_.stop()
$stop()
return
}
var key = args[1]
@@ -166,13 +163,13 @@ switch (command) {
]
if (!valid_system_keys.includes(path[1])) {
log.error("Invalid system key. Valid keys: " + valid_system_keys.join(', '))
$_.stop()
$stop()
return
}
}
set_nested(config, path, value)
shop.save_config(config)
pkg.save_config(config)
log.console("Set " + key + " = " + format_value(value))
break
@@ -180,7 +177,7 @@ switch (command) {
// Handle actor-specific configuration
if (args.length < 3) {
log.error("Usage: cell config actor <name> <command> [options]")
$_.stop()
$stop()
return
}
@@ -193,7 +190,7 @@ switch (command) {
switch (actor_cmd) {
case 'list':
if (Object.keys(config.actors[actor_name]).length == 0) {
if (array(config.actors[actor_name]).length == 0) {
log.console("No configuration for actor: " + actor_name)
} else {
log.console("# Configuration for actor: " + actor_name)
@@ -205,7 +202,7 @@ switch (command) {
case 'get':
if (args.length < 4) {
log.error("Usage: cell config actor <name> get <key>")
$_.stop()
$stop()
return
}
var key = args[3]
@@ -222,7 +219,7 @@ switch (command) {
case 'set':
if (args.length < 5) {
log.error("Usage: cell config actor <name> set <key> <value>")
$_.stop()
$stop()
return
}
var key = args[3]
@@ -231,7 +228,7 @@ switch (command) {
var value = parse_value(value_str)
set_nested(config.actors[actor_name], path, value)
shop.save_config(config)
pkg.save_config(config)
log.console("Set actors." + actor_name + "." + key + " = " + format_value(value))
break
@@ -246,4 +243,4 @@ switch (command) {
print_help()
}
$_.stop()
$stop()

246
crypto.c Normal file
View File

@@ -0,0 +1,246 @@
#include "cell.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "monocypher.h"
/*
Crypto Module Documentation
This module provides cryptographic functions using the Monocypher library.
All inputs and outputs are Blobs.
Functions:
- keypair() -> { public: Blob(256 bits), private: Blob(256 bits) }
Generates a new random X25519 keypair.
- shared(public_key, private_key) -> Blob(256 bits)
Computes a shared secret from your private key and another's public key (X25519).
Input keys must be 256 bits (32 bytes).
- blake2(data, [hash_size_bytes=32]) -> Blob
Computes the BLAKE2b hash of the data.
Default hash size is 32 bytes (256 bits). Supports 1-64 bytes.
- sign(secret_key, message) -> Blob(512 bits)
Signs a message using EdDSA.
secret_key must be 512 bits (64 bytes).
(Note: If you have a 32-byte seed, extend it first or use appropriate key generation).
Returns a 64-byte signature.
- verify(signature, public_key, message) -> bool
Verifies an EdDSA signature.
signature: 512 bits (64 bytes).
public_key: 256 bits (32 bytes).
Returns true if valid, false otherwise.
- lock(key, nonce, message, [ad]) -> Blob
Encrypts and authenticates a message using XChaCha20-Poly1305.
key: 256 bits (32 bytes).
nonce: 192 bits (24 bytes).
ad: Optional associated data (Blob).
Returns a blob containing the ciphertext followed by the 16-byte MAC.
- unlock(key, nonce, ciphertext_with_mac, [ad]) -> Blob or null
Decrypts and verifies a message.
key: 256 bits (32 bytes).
nonce: 192 bits (24 bytes).
ciphertext_with_mac: Must include the 16-byte MAC at the end.
ad: Optional associated data (Blob).
Returns the plaintext Blob if successful, or null if verification fails.
*/
// Helper to get blob data and check exact bit length
static void *get_blob_check_bits(JSContext *js, JSValue val, size_t expected_bits, const char *name) {
size_t bits;
void* result = js_get_blob_data_bits(js, &bits, val);
if (result == -1) {
return NULL; // Exception already thrown by js_get_blob_data_bits
}
if (bits != expected_bits) {
JS_ThrowTypeError(js, "%s: expected %zu bits, got %zu", name, expected_bits, bits);
return NULL;
}
return result;
}
// Helper to get any blob data (checking it is a stoned blob)
static void *get_blob_any(JSContext *js, JSValue val, size_t *out_bits, const char *name) {
void *result = js_get_blob_data_bits(js, out_bits, val);
if (result == -1)
return NULL;
return result;
}
JSValue js_crypto_shared(JSContext *js, JSValue self, int argc, JSValue *argv)
{
if (argc < 2) {
return JS_ThrowTypeError(js, "crypto.shared: expected public_key, private_key");
}
uint8_t *pub = get_blob_check_bits(js, argv[0], 256, "crypto.shared public_key");
if (!pub) return JS_EXCEPTION;
uint8_t *priv = get_blob_check_bits(js, argv[1], 256, "crypto.shared private_key");
if (!priv) return JS_EXCEPTION;
uint8_t shared[32];
crypto_x25519(shared, priv, pub);
return js_new_blob_stoned_copy(js, shared, 32);
}
JSValue js_crypto_blake2(JSContext *js, JSValue self, int argc, JSValue *argv)
{
if (argc < 1)
return JS_ThrowTypeError(js, "crypto.blake2: expected data blob");
size_t data_bits;
uint8_t *data = get_blob_any(js, argv[0], &data_bits, "crypto.blake2 data");
if (!data) return JS_EXCEPTION;
int32_t hash_len = 32;
if (argc > 1) {
if (JS_ToInt32(js, &hash_len, argv[1]))
return JS_EXCEPTION;
if (hash_len < 1 || hash_len > 64)
return JS_ThrowRangeError(js, "crypto.blake2: hash length must be between 1 and 64 bytes");
}
uint8_t hash[64];
// Use (bits + 7) / 8 to get byte length covering all bits
crypto_blake2b(hash, hash_len, data, (data_bits + 7) / 8);
return js_new_blob_stoned_copy(js, hash, hash_len);
}
JSValue js_crypto_sign(JSContext *js, JSValue self, int argc, JSValue *argv) {
if (argc < 2) return JS_ThrowTypeError(js, "crypto.sign: expected secret_key, message");
uint8_t *sk = get_blob_check_bits(js, argv[0], 512, "crypto.sign secret_key");
if (!sk) return JS_EXCEPTION;
size_t msg_bits;
uint8_t *msg = get_blob_any(js, argv[1], &msg_bits, "crypto.sign message");
if (!msg) return JS_EXCEPTION;
uint8_t sig[64];
crypto_eddsa_sign(sig, sk, msg, (msg_bits + 7) / 8);
return js_new_blob_stoned_copy(js, sig, 64);
}
JSValue js_crypto_verify(JSContext *js, JSValue self, int argc, JSValue *argv) {
if (argc < 3) return JS_ThrowTypeError(js, "crypto.verify: expected signature, public_key, message");
uint8_t *sig = get_blob_check_bits(js, argv[0], 512, "crypto.verify signature");
if (!sig) return JS_EXCEPTION;
uint8_t *pk = get_blob_check_bits(js, argv[1], 256, "crypto.verify public_key");
if (!pk) return JS_EXCEPTION;
size_t msg_bits;
uint8_t *msg = get_blob_any(js, argv[2], &msg_bits, "crypto.verify message");
if (!msg) return JS_EXCEPTION;
int ret = crypto_eddsa_check(sig, pk, msg, (msg_bits + 7) / 8);
return JS_NewBool(js, ret == 0);
}
JSValue js_crypto_lock(JSContext *js, JSValue self, int argc, JSValue *argv) {
if (argc < 3) return JS_ThrowTypeError(js, "crypto.lock: expected key, nonce, message, [ad]");
uint8_t *key = get_blob_check_bits(js, argv[0], 256, "crypto.lock key");
if (!key) return JS_EXCEPTION;
uint8_t *nonce = get_blob_check_bits(js, argv[1], 192, "crypto.lock nonce");
if (!nonce) return JS_EXCEPTION;
size_t msg_bits;
uint8_t *msg = get_blob_any(js, argv[2], &msg_bits, "crypto.lock message");
if (!msg) return JS_EXCEPTION;
size_t msg_len = (msg_bits + 7) / 8;
size_t ad_len = 0;
uint8_t *ad = NULL;
if (argc > 3 && !JS_IsNull(argv[3])) {
size_t ad_bits;
ad = get_blob_any(js, argv[3], &ad_bits, "crypto.lock ad");
if (!ad) return JS_EXCEPTION;
ad_len = (ad_bits + 7) / 8;
}
size_t out_len = msg_len + 16;
uint8_t *out = malloc(out_len);
if (!out) return JS_ThrowOutOfMemory(js);
// Output: [Ciphertext (msg_len)] [MAC (16)]
crypto_aead_lock(out, out + msg_len, key, nonce, ad, ad_len, msg, msg_len);
JSValue ret = js_new_blob_stoned_copy(js, out, out_len);
free(out);
return ret;
}
JSValue js_crypto_unlock(JSContext *js, JSValue self, int argc, JSValue *argv) {
if (argc < 3) return JS_ThrowTypeError(js, "crypto.unlock: expected key, nonce, ciphertext, [ad]");
uint8_t *key = get_blob_check_bits(js, argv[0], 256, "crypto.unlock key");
if (!key) return JS_EXCEPTION;
uint8_t *nonce = get_blob_check_bits(js, argv[1], 192, "crypto.unlock nonce");
if (!nonce) return JS_EXCEPTION;
size_t cipher_bits;
uint8_t *cipher = get_blob_any(js, argv[2], &cipher_bits, "crypto.unlock ciphertext");
if (!cipher) return JS_EXCEPTION;
size_t cipher_len = (cipher_bits + 7) / 8;
if (cipher_len < 16) return JS_ThrowTypeError(js, "crypto.unlock: ciphertext too short (min 16 bytes)");
size_t msg_len = cipher_len - 16;
size_t ad_len = 0;
uint8_t *ad = NULL;
if (argc > 3 && !JS_IsNull(argv[3])) {
size_t ad_bits;
ad = get_blob_any(js, argv[3], &ad_bits, "crypto.unlock ad");
if (!ad) return JS_EXCEPTION;
ad_len = (ad_bits + 7) / 8;
}
uint8_t *out = malloc(msg_len > 0 ? msg_len : 1);
if (!out) return JS_ThrowOutOfMemory(js);
// MAC is at cipher + msg_len
const uint8_t *mac = cipher + msg_len;
if (crypto_aead_unlock(out, mac, key, nonce, ad, ad_len, cipher, msg_len) != 0) {
free(out);
return JS_NULL;
}
JSValue ret = js_new_blob_stoned_copy(js, out, msg_len);
free(out);
return ret;
}
static const JSCFunctionListEntry js_crypto_funcs[] = {
JS_CFUNC_DEF("shared", 2, js_crypto_shared),
JS_CFUNC_DEF("blake2", 1, js_crypto_blake2),
JS_CFUNC_DEF("sign", 2, js_crypto_sign),
JS_CFUNC_DEF("verify", 3, js_crypto_verify),
JS_CFUNC_DEF("lock", 3, js_crypto_lock),
JS_CFUNC_DEF("unlock", 3, js_crypto_unlock),
};
JSValue js_crypto_use(JSContext *js)
{
JSValue obj = JS_NewObject(js);
JS_SetPropertyFunctionList(js, obj, js_crypto_funcs, sizeof(js_crypto_funcs)/sizeof(js_crypto_funcs[0]));
return obj;
}

View File

@@ -1,18 +1,33 @@
#include "qjs_debug.h"
#include "qjs_macros.h"
#include "jsffi.h"
#include "cell.h"
// Return the current stack depth.
JSC_CCALL(debug_stack_depth, return number2js(js,js_debugger_stack_depth(js)))
// Return a backtrace of the current call stack.
JSC_CCALL(debug_build_backtrace, return js_debugger_build_backtrace(js,NULL))
// Return the closure variables for a given function.
JSC_CCALL(debug_closure_vars, return js_debugger_closure_variables(js,argv[0]))
JSC_CCALL(debug_set_closure_var,
js_debugger_set_closure_variable(js,argv[0],argv[1],argv[2]);
return JS_NULL;
)
// Return the local variables for a specific stack frame.
JSC_CCALL(debug_local_vars, return js_debugger_local_variables(js, js2number(js,argv[0])))
// Return metadata about a given function.
JSC_CCALL(debug_fn_info, return js_debugger_fn_info(js, argv[0]))
// Return an array of functions in the current backtrace.
JSC_CCALL(debug_backtrace_fns, return js_debugger_backtrace_fns(js,NULL))
static const JSCFunctionListEntry js_debug_funcs[] = {
MIST_FUNC_DEF(debug, stack_depth, 0),
MIST_FUNC_DEF(debug, build_backtrace, 0),
MIST_FUNC_DEF(debug, closure_vars, 1),
MIST_FUNC_DEF(debug, set_closure_var, 3),
MIST_FUNC_DEF(debug, local_vars, 1),
MIST_FUNC_DEF(debug, fn_info, 1),
MIST_FUNC_DEF(debug, backtrace_fns,0),

View File

@@ -1,11 +1,11 @@
#include "qjs_js.h"
#include "jsffi.h"
#include "cell.h"
JSC_CCALL(os_gc, JS_RunGC(JS_GetRuntime(js)) )
JSC_CCALL(os_mem_limit, JS_SetMemoryLimit(JS_GetRuntime(js), js2number(js,argv[0])))
JSC_CCALL(os_gc_threshold, JS_SetGCThreshold(JS_GetRuntime(js), js2number(js,argv[0])))
JSC_CCALL(os_max_stacksize, JS_SetMaxStackSize(JS_GetRuntime(js), js2number(js,argv[0])))
// Compute the approximate size of a single JS value in memory.
JSC_CCALL(os_calc_mem,
JSMemoryUsage mu;
JS_ComputeMemoryUsage(JS_GetRuntime(js),&mu);
@@ -38,25 +38,28 @@ JSC_CCALL(os_calc_mem,
JS_SetPropertyStr(js,ret,"binary_object_size",number2js(js,mu.binary_object_size));
)
// Evaluate a string of JavaScript code in the current QuickJS context.
JSC_SSCALL(os_eval,
if (!str2) return JS_ThrowReferenceError(js, "Second argument should be the script.");
if (!str) return JS_ThrowReferenceError(js, "First argument should be the name of the script.");
ret = JS_Eval(js,str2,strlen(str2),str, 0);
)
// Compile a string of JavaScript code into a function object.
JSC_SSCALL(js_compile,
ret = JS_Eval(js, str2, strlen(str2), str, JS_EVAL_FLAG_COMPILE_ONLY);
if (!str2) return JS_ThrowReferenceError(js, "Second argument should be the script.");
if (!str) return JS_ThrowReferenceError(js, "First argument should be the name of the script.");
ret = JS_Eval(js, str2, strlen(str2), str, JS_EVAL_FLAG_COMPILE_ONLY | JS_EVAL_FLAG_BACKTRACE_BARRIER);
)
// Evaluate a function object in the current QuickJS context.
JSC_CCALL(js_eval_compile,
JS_DupValue(js,argv[0]);
ret = JS_EvalFunction(js, argv[0]);
)
#include "qjs_blob.h"
// Compile a function object into a bytecode blob.
JSC_CCALL(js_compile_blob,
JSRuntime *rt = JS_GetRuntime(js);
// JS_SetStripInfo(rt, JS_STRIP_SOURCE);
// JS_SetStripInfo(rt, JS_STRIP_DEBUG);
size_t size;
uint8_t *data = JS_WriteObject(js, &size, argv[0], JS_WRITE_OBJ_BYTECODE);
if (!data) {
@@ -66,14 +69,26 @@ JSC_CCALL(js_compile_blob,
js_free(js, data);
)
// Compile a bytecode blob into a function object.
JSC_CCALL(js_compile_unblob,
size_t size;
void *data = js_get_blob_data(js, &size, argv[0]);
if (!data) return JS_ThrowReferenceError(js, "Must be a stoned blob.");
if (data == -1) return JS_EXCEPTION;
if (!data) return JS_ThrowReferenceError(js, "No data present in blob.");
return JS_ReadObject(js, data, size, JS_READ_OBJ_BYTECODE);
)
// Disassemble a function object into a string.
JSC_CCALL(js_disassemble,
return js_debugger_fn_bytecode(js, argv[0]);
)
// Return metadata about a given function.
JSC_CCALL(js_fn_info,
return js_debugger_fn_info(js, argv[0]);
)
static const JSCFunctionListEntry js_js_funcs[] = {
MIST_FUNC_DEF(os, calc_mem, 0),
MIST_FUNC_DEF(os, mem_limit, 1),
@@ -85,6 +100,8 @@ static const JSCFunctionListEntry js_js_funcs[] = {
MIST_FUNC_DEF(js, eval_compile, 1),
MIST_FUNC_DEF(js, compile_blob, 1),
MIST_FUNC_DEF(js, compile_unblob, 1),
MIST_FUNC_DEF(js, disassemble, 1),
MIST_FUNC_DEF(js, fn_info, 1),
};
JSValue js_js_use(JSContext *js) {

View File

@@ -1,12 +1,9 @@
nav:
- index.md
- tutorial.md
- cellscript.md
- actors.md
- rendering.md
- resources.md
- input.md
- exporting.md
- ...
- Appendix A - dull: dull
- Appendix B - api: api
- packages.md
- cli.md
- c-modules.md
- Standard Library: library

View File

@@ -1,77 +1,230 @@
# Programs: Programs and Modules
# Actors and Modules
Prosperon organizes your code into two broad categories: **modules** and **programs**. Modules are used to extend programs with new functionality, while programs are used to spawn actors.
Cell organizes code into two types of scripts: **modules** (`.cm`) and **actors** (`.ce`).
## Modules
## The Actor Model
A **module** is any file that returns a single value. This return value is commonly an object, but it can be any data type (string, number, function, etc.). Once a module returns its value, Prosperon **freezes** that value, preventing accidental modification. The module is then cached so that subsequent imports of the same module dont re-run the file—they reuse the cached result.
Cell is built on the actor model of computation. Each actor:
### Importing a Module
- Has its own **isolated memory** — actors never share state
- Runs to completion each **turn** — no preemption
- Performs its own **garbage collection**
- Communicates only through **message passing**
Use the built-in `use` function to import a module by file path (or by name if resolvable via Prosperons path settings). For example:
This isolation makes concurrent programming safer and more predictable.
```
var myModule = use('scripts/modules/myModule')
## Modules (.cm)
A module is a script that **returns a value**. The returned value is cached and frozen (made stone).
```javascript
// math_utils.cm
var math = use('math/radians')
function distance(x1, y1, x2, y2) {
var dx = x2 - x1
var dy = y2 - y1
return math.sqrt(dx * dx + dy * dy)
}
function midpoint(x1, y1, x2, y2) {
return {
x: (x1 + x2) / 2,
y: (y1 + y2) / 2
}
}
return {
distance: distance,
midpoint: midpoint
}
```
`use('module')` returns the **exact** same object if called multiple times, since modules are cached and not re-run.
**Key properties:**
Dull based modules are resolved by searching for them from the `prosperon.PATH` array. Engine modules are stored under `scripts/modules`, which is already added to the PATH for you.
- **Must return a value** — it's an error not to
- **Executed once per actor** — subsequent `use()` calls return the cached value
- **Return value is stone** — immutable, safe to share
- Modules can import other modules with `use()`
Prosperon can also load C based modules. If two modules have the same path resolution, the C based library will be imported.
### Using Modules
## Programs
```javascript
var utils = use('math_utils')
var d = utils.distance(0, 0, 3, 4) // 5
```
An **program** is a file that **does not** return a value. Instead, the files contents run top to bottom as soon as the program is spawned. Programs are your games “live” scripts: each program can hold its own state and logic, spawn sub-programs, schedule timed tasks, and eventually **kill** itself (or be killed) when its done.
## Actors (.ce)
### Program Intrinsic Functions
An actor is a script that **does not return a value**. It runs as an independent unit of execution.
Certain functions are intrinsic to the program and cannot be overridden. Theyre assigned to each new program instance at spawn time:
```javascript
// worker.ce
log.console("Worker started")
1. **`spawn(script, config, callback)`**
Creates (spawns) a new program from another script file.
- **`script`**: Path to the program script (a file containing statements, not returning anything).
- **`config`**: Optional object of extra properties to assign to the new program.
- **`callback(underling, info)`**: Optional function invoked right after the program is instantiated but before it fully initializes.
$on_message = function(msg) {
log.console("Received:", msg)
// Process message...
}
```
The newly spawned program:
- Receives a reference to its parent (the `overling`) and can store child programs (the `underlings`).
- Automatically calls `awake()` if that function is defined, after basic setup completes.
- Registers any recognized event handlers (like `update`, `draw`, etc.) if they exist.
**Key properties:**
2. **`kill()`**
Destroys the program, all of its timers, and recursively kills any underling (child) programs. If the program has a parent, it is removed from the parents `underlings` set.
- **Must not return a value** — it's an error to return
- Has access to **actor intrinsics** (functions starting with `$`)
- Runs until explicitly stopped or crashes
3. **`delay(fn, seconds)`**
Runs the given function `fn` after `seconds`. This is implemented under the hood with a timer that automatically clears itself once it fires.
- **Example**:
```js
this.delay(_ => {
log.console("3 seconds later!")
}, 3)
```
## Actor Intrinsics
4. **`clear()`**
Recursively kills all child programs, clearing your immediate `underlings` set. This is not called automatically. You can use it to manually clean up all children without necessarily killing the program itself.
Actors have access to special functions prefixed with `$`:
### The program Lifecycle
### $me
Specific hooks can be set on a program when it is initialized.
Reference to the current actor.
- **Awake**: If the new program defines `awake()`, Prosperon calls it after the script finishes its top-level execution. This is a common place to do initialization.
- **Garbage**: When the program is killed, if it has a `garbage()` function, Prosperon calls it before final removal.
- **Then**: If the program has a `then()` function, Prosperon calls it at the very end of the kill process, allowing any final statements after your `garbage()` logic completes.
- **Registration**: In addition, if the object has **any** function named the same thing as a hook created with **prosperon.on**, that function will be registered with it after initialization.
```javascript
log.console($me) // actor reference
```
### Overlings and Underlings
### $stop()
Programs have access to its creator and other programs created underneath it, termed its overling and underlings.
Stop the current actor.
- **`this.overling`** is the parent program that spawned the current one.
- **`this.underlings`** is a set of child programs that the current program has spawned.
```javascript
$stop()
```
Killing a parent automatically kills all of its underlings, which in turn can kill their own underlings, and so on.
### $send(actor, message, callback)
## Program Documentation
Send a message to another actor.
Prosperon includes a module called `doc.js` which helps generate documentation for your modules and programs. Any function and value can be assigned a docstring, and prosperon will then be able to generate documentation for it via doc.js. Look under the module API for more info.
```javascript
$send(other_actor, {type: "ping", data: 42}, function(reply) {
log.console("Got reply:", reply)
})
```
Messages are automatically **splatted** — flattened to plain data without prototypes.
### $start(callback, program)
Start a new actor from a script.
```javascript
$start(function(new_actor) {
log.console("Started:", new_actor)
}, "worker")
```
### $delay(callback, seconds)
Schedule a callback after a delay.
```javascript
$delay(function() {
log.console("5 seconds later")
}, 5)
```
### $clock(callback)
Get called every frame/tick.
```javascript
$clock(function(dt) {
// Called each tick with delta time
})
```
### $receiver(callback)
Set up a message receiver.
```javascript
$receiver(function(message, reply) {
// Handle incoming message
reply({status: "ok"})
})
```
### $portal(callback, port)
Open a network port.
```javascript
$portal(function(connection) {
// Handle new connection
}, 8080)
```
### $contact(callback, record)
Connect to a remote address.
```javascript
$contact(function(connection) {
// Connected
}, {host: "example.com", port: 80})
```
### $time_limit(requestor, seconds)
Wrap a requestor with a timeout.
```javascript
$time_limit(my_requestor, 10) // 10 second timeout
```
## Module Resolution
When you call `use('name')`, Cell searches:
1. **Current package** — files relative to package root
2. **Dependencies** — packages declared in `cell.toml`
3. **Core** — built-in Cell modules
```javascript
// From within package 'myapp':
use('utils') // myapp/utils.cm
use('helper/math') // myapp/helper/math.cm
use('json') // core json module
use('otherlib/foo') // dependency 'otherlib', file foo.cm
```
Files starting with underscore (`_helper.cm`) are private to the package.
## Example: Simple Actor System
```javascript
// main.ce - Entry point
var config = use('config')
log.console("Starting application...")
$start(function(worker) {
$send(worker, {task: "process", data: [1, 2, 3]})
}, "worker")
$delay(function() {
log.console("Shutting down")
$stop()
}, 10)
```
```javascript
// worker.ce - Worker actor
$receiver(function(msg, reply) {
if (msg.task == "process") {
var result = array(msg.data, x => x * 2)
reply({result: result})
}
})
```
```javascript
// config.cm - Shared configuration
return {
debug: true,
timeout: 30
}
```

View File

@@ -1,11 +0,0 @@
# actor
### toString() <sub>function</sub>
### spawn(script, config, callback) <sub>function</sub>
### clear() <sub>function</sub>
### kill() <sub>function</sub>
### delay(fn, seconds) <sub>function</sub>

View File

@@ -1,37 +0,0 @@
# console
The console object provides various logging, debugging, and output methods.
### print() <sub>function</sub>
### spam(msg) <sub>function</sub>
Output a spam-level message for very verbose logging.
### debug(msg) <sub>function</sub>
Output a debug-level message.
### info(msg) <sub>function</sub>
Output info level message.
### warn(msg) <sub>function</sub>
Output warn level message.
### log(msg) <sub>function</sub>
Output directly to in game console.
### error(e) <sub>function</sub>
Output error level message, and print stacktrace.
### panic(e) <sub>function</sub>
Output a panic-level message and exit the program.
### assert(op, str = `assertion failed [value '${op}']`) <sub>function</sub>
If the condition is false, print an error and panic.

View File

@@ -1,5 +0,0 @@
# Appendix B - api
This is a complete list of accessible functions and parameters that are built into Prosperon. For the most part, developers will concern themselves with the modules, all of which can be imported with `use`.
Types document particular javascript objects with a specific object in their prototype chain, which can allow access to an underlying C data structure. A lot of these are used only internally by Prosperon, but brave developers can pick around in the module internals to see how they're used and do their own thing if they want!

View File

@@ -1,87 +0,0 @@
# actor
A set of utilities for iterating over a hierarchy of actor-like objects, as well
as managing tag-based lookups. Objects are assumed to have a "objects" property,
pointing to children or sub-objects, forming a tree.
### all_objects(fn, startobj) <sub>function</sub>
Iterate over each object (and its sub-objects) in the hierarchy, calling fn for each one.
**fn**: A callback function that receives each object. If it returns a truthy value, iteration stops and that value is returned.
**startobj**: The root object at which iteration begins, default is the global "world".
**Returns**: The first truthy value returned by fn, or undefined if none.
### find_object(fn, startobj) <sub>function</sub>
Intended to find a matching object within the hierarchy.
**fn**: A callback or criteria to locate a particular object.
**startobj**: The root object at which search begins, default "world".
**Returns**: Not yet implemented.
### tag_add(tag, obj) <sub>function</sub>
Associate the given object with the specified tag. Creates a new tag set if it does not exist.
**tag**: A string tag to associate with the object.
**obj**: The object to add under this tag.
**Returns**: None
### tag_rm(tag, obj) <sub>function</sub>
Remove the given object from the specified tags set, if it exists.
**tag**: The tag to remove the object from.
**obj**: The object to remove from the tag set.
**Returns**: None
### tag_clear_guid(obj) <sub>function</sub>
Remove the object from all tag sets.
**obj**: The object whose tags should be cleared.
**Returns**: None
### objects_with_tag(tag) <sub>function</sub>
Retrieve all objects currently tagged with the specified tag.
**tag**: A string tag to look up.
**Returns**: An array of objects associated with the given tag.

View File

@@ -1,46 +0,0 @@
# camera
### list() <sub>function</sub>
Return an array of available camera device IDs.
**Returns**: An array of camera IDs, or undefined if no cameras are available.
### open(id) <sub>function</sub>
Open a camera device with the given ID.
**id**: The camera ID to open.
**Returns**: A camera object on success, or throws an error if the camera cannot be opened.
### name(id) <sub>function</sub>
Return the name of the camera with the given ID.
**id**: The camera ID to query.
**Returns**: A string with the camera's name, or throws an error if the name cannot be retrieved.
### position(id) <sub>function</sub>
Return the physical position of the camera with the given ID.
**id**: The camera ID to query.
**Returns**: A string indicating the camera position ("unknown", "front", or "back").

View File

@@ -1,7 +0,0 @@
# cmd
### length <sub>number</sub>
### name <sub>string</sub>
### prototype <sub>object</sub>

View File

@@ -1,7 +0,0 @@
# color
### Color <sub>object</sub>
### esc <sub>object</sub>
### ColorMap <sub>object</sub>

View File

@@ -1,76 +0,0 @@
# debug
### stack_depth() <sub>function</sub>
Return the current stack depth.
**Returns**: A number representing the stack depth.
### build_backtrace() <sub>function</sub>
Build and return a backtrace of the current call stack.
**Returns**: An object representing the call stack backtrace.
### closure_vars(fn) <sub>function</sub>
Return the closure variables for a given function.
**fn**: The function object to inspect.
**Returns**: An object containing the closure variables.
### local_vars(depth) <sub>function</sub>
Return the local variables for a specific stack frame.
**depth**: The stack frame depth to inspect.
**Returns**: An object containing the local variables at the specified depth.
### fn_info(fn) <sub>function</sub>
Return metadata about a given function.
**fn**: The function object to inspect.
**Returns**: An object with metadata about the function.
### backtrace_fns() <sub>function</sub>
Return an array of functions in the current backtrace.
**Returns**: An array of function objects from the call stack.
### dump_obj(obj) <sub>function</sub>
Return a string representation of a given object.
**obj**: The object to dump.
**Returns**: A string describing the object's contents.

View File

@@ -1,39 +0,0 @@
# dmon
### watch() <sub>function</sub>
Start watching the root directory, recursively.
This function begins monitoring the specified directory and its subdirectories recursively for events such as file creation, deletion, modification, or movement. Events are queued and can be retrieved by calling poll.
:throws: An error if dmon is already watching.
**Returns**: None
### unwatch() <sub>function</sub>
Stop watching the currently monitored directory.
This function halts filesystem monitoring for the directory previously set by watch. It clears the watch state, allowing a new watch to be started.
:throws: An error if no directory is currently being watched.
**Returns**: None
### poll(callback) <sub>function</sub>
Retrieve and process queued filesystem events.
This function dequeues all pending filesystem events and invokes the provided callback for each one. The callback receives an event object with properties: 'action' (string: "create", "delete", "modify", or "move"), 'root' (string: watched directory), 'file' (string: affected file path), and 'old' (string: previous file path for move events, empty if not applicable).
**callback**: A function to call for each event, receiving an event object as its argument.
**Returns**: None

View File

@@ -1,38 +0,0 @@
# doc
Provides a consistent way to create documentation for prosperon elements. Objects are documented by adding docstrings directly to object-like things (functions, objects, ...), or to an object's own "doc object".
Docstrings are set to the symbol `cell.DOC`
```js
// Suppose we have a module that returns a function
function greet(name) { log.console("Hello, " + name) }
// We can attach a docstring
greet.doc = `
Greets the user by name.
`
// A single function is a valid return!
return greet
```
```js
// Another way is to add a docstring object to an object
var greet = {
hello() { log.console('hello!') }
}
greet[cell.DOC] = {}
greet[cell.DOC][cell.DOC] = 'An object full of different greeter functions'
greet[cell.DOC].hello = 'A greeter that says, "hello!"'
```
**name**: The name of the person to greet.
### writeDocFile(obj, title) <sub>function</sub>
Return a markdown string for a given obj, with an optional title.

View File

@@ -1,228 +0,0 @@
# draw2d
A collection of 2D drawing functions that operate in screen space. Provides primitives
for lines, rectangles, text, sprite drawing, etc.
### point(pos, size, color) <sub>function</sub>
**pos**: A 2D position ([x, y]) where the point should be drawn.
**size**: The size of the point (not currently affecting rendering).
**color**: The color of the point, defaults to Color.blue.
**Returns**: None
### line(points, color, thickness, pipeline) <sub>function</sub>
**points**: An array of 2D positions representing the line vertices.
**color**: The color of the line, default Color.white.
**thickness**: The line thickness, default 1.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### cross(pos, size, color, thickness, pipe) <sub>function</sub>
**pos**: The center of the cross as a 2D position ([x, y]).
**size**: Half the size of each cross arm.
**color**: The color of the cross, default Color.red.
**thickness**: The thickness of each line, default 1.
**pipe**: (Optional) A pipeline or rendering state object.
**Returns**: None
### arrow(start, end, color, wingspan, wingangle, pipe) <sub>function</sub>
**start**: The start position of the arrow ([x, y]).
**end**: The end (tip) position of the arrow ([x, y]).
**color**: The color, default Color.red.
**wingspan**: The length of each arrowhead 'wing', default 4.
**wingangle**: Wing rotation in degrees, default 10.
**pipe**: (Optional) A pipeline or rendering state object.
**Returns**: None
### rectangle(rect, color, pipeline) <sub>function</sub>
**rect**: A rectangle object with {x, y, width, height}.
**color**: The fill color, default Color.white.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### tile(image, rect, color, tile, pipeline) <sub>function</sub>
:raises Error: If no image is provided.
**image**: An image object or string path to a texture.
**rect**: A rectangle specifying draw location/size ({x, y, width, height}).
**color**: The color tint, default Color.white.
**tile**: A tiling definition ({repeat_x, repeat_y}), default tile_def.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### slice9(image, rect, slice, color, info, pipeline) <sub>function</sub>
:raises Error: If no image is provided.
**image**: An image object or string path to a texture.
**rect**: A rectangle specifying draw location/size, default [0, 0].
**slice**: The pixel inset or spacing for the 9-slice (number or object).
**color**: The color tint, default Color.white.
**info**: A slice9 info object controlling tiling of edges/corners.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### image(image, rect, rotation, color, pipeline) <sub>function</sub>
:raises Error: If no image is provided.
**image**: An image object or string path to a texture.
**rect**: A rectangle specifying draw location/size, default [0,0]; width/height default to image size.
**rotation**: Rotation in degrees (not currently used).
**color**: The color tint, default none.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: A sprite object that was created for this draw call.
### images(image, rects, config) <sub>function</sub>
:raises Error: If no image is provided.
**image**: An image object or string path to a texture.
**rects**: An array of rectangle objects ({x, y, width, height}) to draw.
**config**: (Unused) Additional config data if needed.
**Returns**: An array of sprite objects created and queued for rendering.
### sprites(sprites, sort, pipeline) <sub>function</sub>
**sprites**: An array of sprite objects to draw.
**sort**: Sorting mode or order, default 0.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### circle(pos, radius, color, inner_radius, pipeline) <sub>function</sub>
**pos**: Center of the circle ([x, y]).
**radius**: The circle radius.
**color**: The fill color of the circle, default none.
**inner_radius**: (Unused) Possibly ring thickness, default 1.
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None
### text(text, rect, font, size, color, wrap, pipeline) <sub>function</sub>
**text**: The string to draw.
**rect**: A rectangle specifying draw position (and possibly wrapping area).
**font**: A font object or string path, default sysfont.
**size**: (Unused) Possibly intended for scaling the font size.
**color**: The text color, default Color.white.
**wrap**: Pixel width for text wrapping, default 0 (no wrap).
**pipeline**: (Optional) A pipeline or rendering state object.
**Returns**: None

View File

@@ -1,45 +0,0 @@
# enet
### initialize() <sub>function</sub>
Initialize the ENet library. Must be called before using any ENet functionality.
Throws an error if initialization fails.
**Returns**: None
### deinitialize() <sub>function</sub>
Deinitialize the ENet library, cleaning up all resources. Call this when you no longer
need any ENet functionality.
**Returns**: None
### create_host(address) <sub>function</sub>
Create an ENet host for either a client-like unbound host or a server bound to a specific
address and port:
- If no argument is provided, creates an unbound "client-like" host with default settings
(maximum 32 peers, 2 channels, unlimited bandwidth).
- If you pass an "ip:port" string (e.g. "127.0.0.1:7777"), it creates a server bound to
that address. The server supports up to 32 peers, 2 channels, and unlimited bandwidth.
Throws an error if host creation fails for any reason.
omit to create an unbound client-like host.
**address**: (optional) A string in 'ip:port' format to bind the host (server), or
**Returns**: An ENetHost object.

View File

@@ -1,25 +0,0 @@
# event
### push_event(event) <sub>function</sub>
Push a custom user event into SDL's queue, passing a callback function.
**event**: A function to call when this event is consumed.
**Returns**: None
### engine_input(callback) <sub>function</sub>
Poll all system events (keyboard, mouse, etc.) and call the given function with each event object.
**callback**: A function that executes on each event consumed from the poll.
**Returns**: None

View File

@@ -1,221 +0,0 @@
# geometry
A collection of geometry-related functions for circles, spheres, boxes, polygons,
and rectangle utilities. Some functionality is implemented in C and exposed here.
### rect_intersection(a, b) <sub>function</sub>
Return the intersection of two rectangles. The result may be empty if no intersection.
**a**: The first rectangle as {x, y, w, h}.
**b**: The second rectangle as {x, y, w, h}.
**Returns**: A rectangle that is the intersection of the two. May have zero width/height if no overlap.
### rect_intersects(a, b) <sub>function</sub>
**a**: Rectangle {x,y,w,h}.
**b**: Rectangle {x,y,w,h}.
**Returns**: A boolean indicating whether the two rectangles overlap.
### rect_expand(a, b) <sub>function</sub>
Merge or combine two rectangles, returning their bounding rectangle.
**a**: Rectangle {x,y,w,h}.
**b**: Rectangle {x,y,w,h}.
**Returns**: A new rectangle that covers the bounds of both input rectangles.
### rect_inside(inner, outer) <sub>function</sub>
**inner**: A rectangle to test.
**outer**: A rectangle that may contain 'inner'.
**Returns**: True if 'inner' is completely inside 'outer', otherwise false.
### rect_random(rect) <sub>function</sub>
**rect**: A rectangle {x,y,w,h}.
**Returns**: A random point within the rectangle (uniform distribution).
### cwh2rect(center, wh) <sub>function</sub>
Helper: convert a center point and width/height vector to a rect object.
**center**: A 2D point [cx, cy].
**wh**: A 2D size [width, height].
**Returns**: A rectangle {x, y, w, h} with x,y set to center and w,h set to the given size.
### rect_point_inside(rect, point) <sub>function</sub>
**rect**: A rectangle {x,y,w,h}.
**point**: A 2D point [px, py].
**Returns**: True if the point lies inside the rectangle, otherwise false.
### rect_pos(rect) <sub>function</sub>
**rect**: A rectangle {x,y,w,h}.
**Returns**: A 2D vector [x,y] giving the rectangle's position.
### rect_move(rect, offset) <sub>function</sub>
**rect**: A rectangle {x,y,w,h}.
**offset**: A 2D vector to add to the rectangle's position.
**Returns**: A new rectangle with updated x,y offset.
### box(w, h) <sub>function</sub>
Construct a box centered at the origin with the given width and height. This overrides the box object above.
**w**: The width of the box.
**h**: The height of the box.
**Returns**: An array of four 2D points representing the corners of a rectangle centered at [0,0].
### sphere <sub>object</sub>
Sphere-related geometry functions:
- volume(r): Return the volume of a sphere with radius r.
- random(r, theta, phi): Return a random point on or inside a sphere.
### circle <sub>object</sub>
Circle-related geometry functions:
- area(r): Return the area of a circle with radius r.
- random(r, theta): Return a random 2D point on a circle; uses sphere.random internally and extracts x,z.
### ngon(radius, n) <sub>function</sub>
Generates a regular n-gon by calling geometry.arc with full 360 degrees.
**radius**: The radius of the n-gon from center to each vertex.
**n**: Number of sides/vertices.
**Returns**: An array of 2D points forming a regular n-gon.
### arc(radius, angle, n, start) <sub>function</sub>
Generate an arc (or partial circle) of n points, each angle spread equally over 'angle' degrees from 'start'.
**radius**: The distance from center to the arc points.
**angle**: The total angle (in degrees) over which points are generated, capped at 360.
**n**: Number of segments (if <=1, empty array is returned).
**start**: Starting angle (in degrees), default 0.
**Returns**: An array of 2D points along the arc.
### corners2points(ll, ur) <sub>function</sub>
Similar to box.points, but calculates differently.
**ll**: Lower-left 2D coordinate.
**ur**: Upper-right 2D coordinate (relative offset in x,y).
**Returns**: A four-point array of corners [ll, lower-right, upper-right, upper-left].
### sortpointsccw(points) <sub>function</sub>
Sort an array of points in CCW order based on their angles from the centroid.
**points**: An array of 2D points.
**Returns**: A new array of the same points, sorted counterclockwise around their centroid.
### points2cm(points) <sub>function</sub>
**points**: An array of 2D points.
**Returns**: The centroid (average x,y) of the given points.

View File

@@ -1,278 +0,0 @@
# graphics
Provides functionality for loading and managing images, fonts, textures, and sprite meshes.
Includes both JavaScript and C-implemented routines for creating geometry buffers, performing
rectangle packing, etc.
### make_sprite_mesh(sprites) <sub>function</sub>
:param oldMesh (optional): An existing mesh object to reuse/resize if possible.
Given an array of sprites, build a single geometry mesh for rendering them.
**sprites**: An array of sprite objects, each containing .rect (or transform), .src (UV region), .color, etc.
**Returns**: A GPU mesh object with pos, uv, color, and indices buffers for all sprites.
### make_sprite_queue(sprites, camera, pipeline, sort) <sub>function</sub>
Given an array of sprites, optionally sort them, then build a queue of pipeline commands.
Each group with a shared image becomes one command.
**sprites**: An array of sprite objects.
**camera**: (unused in the C code example) Typically a camera or transform for sorting?
**pipeline**: A pipeline object for rendering.
**sort**: An integer or boolean for whether to sort sprites; if truthy, sorts by layer & texture.
**Returns**: An array of pipeline commands: geometry with mesh references, grouped by image.
### make_text_buffer(text, rect, angle, color, wrap, font) <sub>function</sub>
Generate a GPU buffer mesh of text quads for rendering with a font, etc.
**text**: The string to render.
**rect**: A rectangle specifying position and possibly wrapping.
**angle**: Rotation angle (unused or optional).
**color**: A color for the text (could be a vec4).
**wrap**: The width in pixels to wrap text, or 0 for no wrap.
**font**: A font object created by graphics.make_font or graphics.get_font.
**Returns**: A geometry buffer mesh (pos, uv, color, indices) for rendering text.
### rectpack(width, height, sizes) <sub>function</sub>
Perform a rectangle packing using the stbrp library. Return positions for each rect.
**width**: The width of the area to pack into.
**height**: The height of the area to pack into.
**sizes**: An array of [w,h] pairs for the rectangles to pack.
**Returns**: An array of [x,y] coordinates placing each rect, or null if they don't fit.
### make_rtree() <sub>function</sub>
Create a new R-Tree for geometry queries.
**Returns**: An R-Tree object for quickly querying many rectangles or sprite bounds.
### make_texture(data) <sub>function</sub>
Convert raw image bytes into an SDL_Surface object.
**data**: Raw image bytes (PNG, JPG, etc.) as an ArrayBuffer.
**Returns**: An SDL_Surface object representing the decoded image in RAM, for use with GPU or software rendering.
### make_gif(data) <sub>function</sub>
Load a GIF, returning its frames. If it's a single-frame GIF, the result may have .surface only.
**data**: An ArrayBuffer containing GIF data.
**Returns**: An object with frames[], each frame having its own .surface. Some also have a .texture for GPU use.
### make_aseprite(data) <sub>function</sub>
Load an Aseprite/ASE file from an array of bytes, returning frames or animations.
**data**: An ArrayBuffer containing Aseprite (ASE) file data.
**Returns**: An object containing frames or animations, each with .surface. May also have top-level .surface for a single-layer case.
### cull_sprites(sprites, camera) <sub>function</sub>
Filter an array of sprites to only those visible in the provided cameras view.
**sprites**: An array of sprite objects (each has rect or transform).
**camera**: A camera or bounding rectangle defining the view area.
**Returns**: A new array of sprites that are visible in the camera's view.
### rects_to_sprites(rects, image) <sub>function</sub>
Convert an array of rect coords into sprite objects referencing a single image.
**rects**: An array of rect coords or objects.
**image**: An image object (with .texture).
**Returns**: An array of sprite objects referencing the 'image' and each rect for UV or position.
### make_surface(dimensions) <sub>function</sub>
Create a blank surface in RAM.
**dimensions**: The size object {width, height}, or an array [w,h].
**Returns**: A blank RGBA surface with the given dimensions, typically for software rendering or icons.
### make_cursor(opts) <sub>function</sub>
**opts**: An object with {surface, hotx, hoty} or similar.
**Returns**: An SDL_Cursor object referencing the given surface for a custom mouse cursor.
### make_font(data, size) <sub>function</sub>
Load a font from TTF/OTF data at the given size.
**data**: TTF/OTF file data as an ArrayBuffer.
**size**: Pixel size for rendering glyphs.
**Returns**: A font object with surface, texture, and glyph data, for text rendering with make_text_buffer.
### make_sprite() <sub>function</sub>
Create a new sprite object, storing default properties.
**Returns**: A new sprite object, which typically has .rect, .color, .layer, .image, etc.
### make_line_prim(points, thickness, startCap, endCap, color) <sub>function</sub>
Build a GPU mesh representing a thick polyline from an array of points, using parsl or a similar library under the hood.
**points**: An array of [x,y] points forming the line.
**thickness**: The thickness (width) of the polyline.
**startCap**: (Unused) Possibly the type of cap for the start.
**endCap**: (Unused) Possibly the type of cap for the end.
**color**: A color to apply to the line.
**Returns**: A geometry mesh object suitable for rendering the line via a pipeline command.
### is_image(obj) <sub>function</sub>
**obj**: An object to check.
**Returns**: True if 'obj' has a .texture and a .rect property, indicating it's an image object.
### texture(path) <sub>function</sub>
Load or retrieve a cached image, converting it into a GPU texture. If 'path' is already an object, its returned directly.
**path**: A string path to an image file or an already-loaded image object.
**Returns**: An image object with {surface, texture, frames?, etc.} depending on the format.
### tex_hotreload(file) <sub>function</sub>
Reload the image for the given file, updating the cached copy in memory and GPU.
**file**: The file path that was changed on disk.
**Returns**: None
### get_font(path, size) <sub>function</sub>
Load a font from file if not cached, or retrieve from cache if already loaded.
**path**: A string path to a font file, optionally with ".size" appended.
**size**: Pixel size of the font, if not included in 'path'.
**Returns**: A font object with .surface and .texture for rendering text.
### queue_sprite_mesh(queue) <sub>function</sub>
Builds a single geometry mesh for all sprite-type commands in the queue, storing first_index/num_indices
so they can be rendered in one draw call.
**queue**: An array of draw commands, some of which are {type:'sprite'} objects.
**Returns**: An array of references to GPU buffers [pos,uv,color,indices].

File diff suppressed because it is too large Load Diff

View File

@@ -1,68 +0,0 @@
# input
### mouse_show(show) <sub>function</sub>
Show or hide the mouse cursor. Pass true to show, false to hide.
**show**: Boolean. True to show, false to hide.
**Returns**: None
### mouse_lock(lock) <sub>function</sub>
Capture or release the mouse, confining it within the window if locked.
**lock**: Boolean. True to lock, false to unlock.
**Returns**: None
### cursor_set(cursor) <sub>function</sub>
Set the given cursor (created by os.make_cursor) as the active mouse cursor.
**cursor**: The cursor to set.
**Returns**: None
### keyname(keycode) <sub>function</sub>
Given a numeric keycode, return the corresponding key name (e.g., from SDL).
**keycode**: A numeric SDL keycode.
**Returns**: A string with the key name.
### keymod() <sub>function</sub>
Return an object describing the current modifier keys, e.g. {shift:true, ctrl:true}.
**Returns**: An object with boolean fields for each modifier key.
### mousestate() <sub>function</sub>
Return an object describing the current mouse state, including x,y coordinates
and booleans for pressed buttons (left, middle, right, x1, x2).
**Returns**: Object { x, y, left, middle, right, x1, x2 }

View File

@@ -1,243 +0,0 @@
# io
### rm(path) <sub>function</sub>
Remove the file or empty directory at the given path.
**path**: The file or empty directory to remove. Must be empty if a directory.
**Returns**: None
### mkdir(path) <sub>function</sub>
Create a directory at the given path.
**path**: The directory path to create.
**Returns**: None
### stat(path) <sub>function</sub>
Return an object describing file metadata for the given path. The object includes
filesize, modtime, createtime, and accesstime. Throw an error if the path does not exist.
**path**: The file or directory to retrieve metadata for.
**Returns**: An object with metadata (filesize, modtime, createtime, accesstime).
### globfs(patterns) <sub>function</sub>
Return an array of files that do not match any of the provided glob patterns. It
recursively enumerates the filesystem within PHYSFS. Each pattern is treated as an
"ignore" rule, similar to .gitignore usage.
**patterns**: An array of glob patterns to ignore. Any file matching one of these is skipped.
**Returns**: An array of matching file paths.
### match(pattern, string) <sub>function</sub>
Return boolean indicating whether the given wildcard pattern matches the provided
string. Dots must match dots. Case is not ignored.
Patterns can incorporate:
'?' - Matches exactly one character (except leading dots or slashes).
'*' - Matches zero or more characters (excluding path separators).
'**' - Matches zero or more characters, including path separators.
'[abc]' - A bracket expression; matches any single character from the set. Ranges like [a-z], [0-9] also work.
'[[:alpha:]]' - POSIX character classes can be used inside brackets.
'\' - Backslash escapes the next character.
'!' - If placed immediately inside brackets (like [!abc]), it negates the set.
**pattern**: The wildcard pattern to compare.
**string**: The string to test against the wildcard pattern.
**Returns**: True if matched, otherwise false.
### exists(path) <sub>function</sub>
Return a boolean indicating whether the file or directory at the given path exists.
**path**: The file or directory path to check.
**Returns**: True if the path exists, otherwise false.
### mount(archiveOrDir, mountPoint) <sub>function</sub>
Mount a directory or archive at the specified mount point. An undefined mount
point mounts to '/'. Throw on error.
**archiveOrDir**: The directory or archive to mount.
**mountPoint**: The path at which to mount. If omitted or undefined, '/' is used.
**Returns**: None
### unmount(path) <sub>function</sub>
Unmount a previously mounted directory or archive. Throw on error.
**path**: The directory or archive mount point to unmount.
**Returns**: None
### slurp(path) <sub>function</sub>
Read the entire file at the given path as a string. Throw on error.
**path**: The file path to read from.
**Returns**: A string with the files contents.
### slurpbytes(path) <sub>function</sub>
Read the entire file at the given path as a raw ArrayBuffer. Throw on error.
**path**: The file path to read from.
**Returns**: An ArrayBuffer containing the files raw bytes.
### slurpwrite(data, path) <sub>function</sub>
Write data (string or ArrayBuffer) to the given file path. Overwrite if it exists.
Throw on error.
**data**: The data to write (string or ArrayBuffer).
**path**: The file path to write to.
**Returns**: None
### writepath(path) <sub>function</sub>
Set the write directory. Subsequent writes will go here by default. Throw on error.
**path**: The directory path to set as writable.
**Returns**: None
### basedir() <sub>function</sub>
Return the application's base directory (where the executable is located).
**Returns**: A string with the base directory path.
### prefdir(org, app) <sub>function</sub>
Get the user-and-app-specific path where files can be written.
**org**: The name of your organization.
**app**: The name of your application.
**Returns**: A string with the user's directory path.
### realdir(path) <sub>function</sub>
Return the actual, real directory (on the host filesystem) that contains the given
file path. Return undefined if not found.
**path**: The file path whose real directory is requested.
**Returns**: A string with the real directory path, or undefined.
### open(path) <sub>function</sub>
Open a file for writing, returning a file object that can be used for further
operations. Throw on error.
**path**: The file path to open for writing.
**Returns**: A file object for subsequent write operations.
### searchpath() <sub>function</sub>
Return an array of all directories in the current paths.
**Returns**: An array of directory paths in the search path.
### enumerate(path, recurse) <sub>function</sub>
Return an array of files within the given directory, optionally recursing into
subdirectories.
**path**: The directory to list.
**recurse**: Whether to recursively include subdirectories (true or false).
**Returns**: An array of file (and directory) paths found.
### mount_core() <sub>function</sub>
### is_directory() <sub>function</sub>

View File

@@ -1,175 +0,0 @@
# js
Provides functions for introspecting and configuring the QuickJS runtime engine.
Includes debug info, memory usage, GC controls, code evaluation, etc.
### cycle_hook(callback) <sub>function</sub>
or undefined to remove the callback.
Register or remove a hook function that QuickJS calls once per execution cycle. If the callback
is set, it receives a single argument (an optional object/value describing the cycle). If callback
is undefined, the hook is removed.
**callback**: A function to call each time QuickJS completes a "cycle" (internal VM loop),
**Returns**: None
### dump_shapes() <sub>function</sub>
Use this for internal debugging of object shapes.
**Returns**: A debug string describing the internal shape hierarchy used by QuickJS.
### dump_atoms() <sub>function</sub>
known by QuickJS. Helpful for diagnosing memory usage or potential key collisions.
**Returns**: A debug string listing all currently registered atoms (internal property keys/symbols)
### dump_class() <sub>function</sub>
Shows how many objects of each class exist, useful for advanced memory or performance profiling.
**Returns**: A debug string describing the distribution of JS object classes in the QuickJS runtime.
### dump_objects() <sub>function</sub>
useful for debugging memory leaks or object lifetimes.
**Returns**: A debug string listing certain internal QuickJS objects and their references,
### dump_type_overheads() <sub>function</sub>
Displays memory usage breakdown for different internal object types.
**Returns**: A debug string describing the overheads for various JS object types in QuickJS.
### stack_info() <sub>function</sub>
Internal debugging utility to examine call stack details.
**Returns**: An object or string describing the runtime's current stack usage and capacity.
### calc_mem(value) <sub>function</sub>
Compute the approximate size of a single JS value in memory. This is a best-effort estimate.
**value**: A JavaScript value to analyze.
**Returns**: Approximate memory usage (in bytes) of that single value.
### mem() <sub>function</sub>
including total allocated bytes, object counts, and more.
Retrieve an overview of the runtimes memory usage.
**Returns**: An object containing a comprehensive snapshot of memory usage for the current QuickJS runtime,
### mem_limit(bytes) <sub>function</sub>
Set the upper memory limit for the QuickJS runtime. Exceeding this limit may cause operations to
fail or throw errors.
**bytes**: The maximum memory (in bytes) QuickJS is allowed to use.
**Returns**: None
### gc_threshold(bytes) <sub>function</sub>
Set the threshold (in bytes) for QuickJS to perform an automatic GC pass when memory usage surpasses it.
**bytes**: The threshold (in bytes) at which the engine triggers automatic garbage collection.
**Returns**: None
### max_stacksize(bytes) <sub>function</sub>
Set the maximum stack size for QuickJS. If exceeded, the runtime may throw a stack overflow error.
**bytes**: The maximum allowed stack size (in bytes) for QuickJS.
**Returns**: None
### memstate() <sub>function</sub>
Gives a quick overview of the memory usage, including malloc size and other allocations.
**Returns**: A simpler memory usage object (malloc sizes, etc.) for the QuickJS runtime.
### gc() <sub>function</sub>
Force an immediate, full garbage collection pass, reclaiming unreachable memory.
**Returns**: None
### eval(src, filename) <sub>function</sub>
Execute a string of JavaScript code in the current QuickJS context.
**src**: A string of JavaScript source code to evaluate.
**filename**: (Optional) A string for the filename or label, used in debugging or stack traces.
**Returns**: The result of evaluating the given source code.

View File

@@ -1,15 +0,0 @@
# json
### encode(val,space,replacer,whitelist) <sub>function</sub>
Produce a JSON text from a Javascript object. If a record value, at any level, contains a json() method, it will be called, and the value it returns (usually a simpler record) will be JSONified.
If the record does not have a json() method, and if whitelist is a record, then only the keys that are associated with true in the whitelist are included.
If the space input is true, then line breaks and extra whitespace will be included in the text.
### decode(text,reviver) <sub>function</sub>
The text text is parsed, and the resulting value (usually a record or an array) is returned.
The optional reviver input is a method that will be called for every key and value at every level of the result. Each value will be replaced by the result of the reviver function. This can be used to reform data-only records into method-bearing records, or to transform date strings into seconds.

View File

@@ -1,3 +0,0 @@
# loop
### step() <sub>function</sub>

View File

@@ -1,115 +0,0 @@
# math
### dot() <sub>function</sub>
Compute the dot product between two numeric arrays, returning a scalar. Extra elements are ignored.
### project() <sub>function</sub>
Project one vector onto another, returning a new array of the same dimension.
### rotate() <sub>function</sub>
Rotate a 2D point (or array of length 2) by the given angle (in turns) around an optional pivot.
### midpoint() <sub>function</sub>
Compute the midpoint of two arrays of numbers. Only the first two entries are used if 2D is intended.
### reflect() <sub>function</sub>
Reflect a vector across a plane normal. Both arguments must be numeric arrays.
### distance() <sub>function</sub>
Compute the Euclidean distance between two numeric arrays of matching length.
### direction() <sub>function</sub>
Compute the normalized direction vector from the first array to the second.
### angle() <sub>function</sub>
Given a 2D vector, return its angle from the X-axis in radians or some chosen units.
### norm() <sub>function</sub>
Return a normalized copy of the given numeric array. For 2D/3D/4D or arbitrary length.
### angle_between() <sub>function</sub>
Compute the angle between two vectors (2D/3D/4D).
### lerp() <sub>function</sub>
Linear interpolation between two numbers: lerp(a, b, t).
### gcd() <sub>function</sub>
Compute the greatest common divisor of two integers.
### lcm() <sub>function</sub>
Compute the least common multiple of two integers.
### clamp() <sub>function</sub>
Clamp a number between low and high. clamp(value, low, high).
### angledist() <sub>function</sub>
Compute the signed distance between two angles in 'turn' units, e.g. 0..1 range.
### jitter() <sub>function</sub>
Apply a random +/- percentage noise to a number. Example: jitter(100, 0.05) -> ~95..105.
### mean() <sub>function</sub>
Compute the arithmetic mean of an array of numbers.
### sum() <sub>function</sub>
Sum all elements of an array of numbers.
### sigma() <sub>function</sub>
Compute standard deviation of an array of numbers.
### median() <sub>function</sub>
Compute the median of an array of numbers.
### length() <sub>function</sub>
Return the length of a vector (i.e. sqrt of sum of squares).
### from_to() <sub>function</sub>
Return an array of points from a start to an end, spaced out by a certain distance.
### rand() <sub>function</sub>
Return a random float in [0,1).
### randi() <sub>function</sub>
Return a random 32-bit integer.
### srand() <sub>function</sub>
Seed the random number generator with the given integer, or with current time if none.
### TAU <sub>number</sub>
### deg2rad(deg) <sub>function</sub>
### rad2deg(rad) <sub>function</sub>
### turn2rad(x) <sub>function</sub>
### rad2turn(x) <sub>function</sub>
### turn2deg(x) <sub>function</sub>
### deg2turn(x) <sub>function</sub>

View File

@@ -1,27 +0,0 @@
# miniz
### read(data) <sub>function</sub>
Create a zip reader from the given ArrayBuffer containing an entire ZIP archive.
Return undefined if the data is invalid.
**data**: An ArrayBuffer with the entire ZIP file.
**Returns**: A 'zip reader' object with methods for reading from the archive (mod, exists, slurp).
### write(path) <sub>function</sub>
Create a zip writer that writes to the specified file path. Overwrites the file if
it already exists. Return undefined on error.
**path**: The file path where the ZIP archive will be written.
**Returns**: A 'zip writer' object with methods for adding files to the archive (add_file).

View File

@@ -1,30 +0,0 @@
# nota
### encode(value) <sub>function</sub>
Convert a JavaScript value into a NOTA-encoded ArrayBuffer.
This function serializes JavaScript values (such as numbers, strings, booleans, arrays, objects, or ArrayBuffers) into the NOTA binary format. The resulting ArrayBuffer can be stored or transmitted and later decoded back into a JavaScript value.
:throws: An error if no argument is provided.
**value**: The JavaScript value to encode (e.g., number, string, boolean, array, object, or ArrayBuffer).
**Returns**: An ArrayBuffer containing the NOTA-encoded data.
### decode(buffer) <sub>function</sub>
Decode a NOTA-encoded ArrayBuffer into a JavaScript value.
This function deserializes a NOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns undefined.
**buffer**: An ArrayBuffer containing NOTA-encoded data to decode.
**Returns**: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or undefined if no argument is provided.

View File

@@ -1,101 +0,0 @@
# os
### make_transform() <sub>function</sub>
Create a new transform object that can be used for 2D/3D positioning, scaling, and rotation.
### clean_transforms() <sub>function</sub>
Force an update on all transforms to remove dangling references or perform house-keeping.
### platform() <sub>function</sub>
Return a string with the underlying platform name, like 'Windows', 'Linux', or 'macOS'.
### arch() <sub>function</sub>
Return the CPU architecture string for this system (e.g. 'x64', 'arm64').
### totalmem() <sub>function</sub>
Return the total system RAM in bytes.
### freemem() <sub>function</sub>
Return the amount of free system RAM in bytes, if known.
### hostname() <sub>function</sub>
Return the system's hostname, or an empty string if not available.
### version() <sub>function</sub>
Return the OS or kernel version string, if the platform provides it.
### kill() <sub>function</sub>
Send a signal (e.g., 'SIGINT', 'SIGTERM', etc.) to the current process.
### exit() <sub>function</sub>
Exit the application with the specified exit code.
### now() <sub>function</sub>
Return current time (in seconds as a float) with high resolution.
### openurl() <sub>function</sub>
Open the provided URL in the default web browser, if possible.
### make_timer() <sub>function</sub>
Create a new timer object that will call a specified function after a certain delay.
### update_timers() <sub>function</sub>
Advance all timers by the provided time delta (in seconds).
### sleep() <sub>function</sub>
Block execution for the specified number of seconds.
### battery_pct() <sub>function</sub>
Return the battery level (percentage) or negative if unknown.
### battery_voltage() <sub>function</sub>
Return the current battery voltage in volts, if available.
### battery_seconds() <sub>function</sub>
Return the estimated remaining battery time in seconds, or negative if unknown.
### power_state() <sub>function</sub>
Return a string describing power status: 'on battery', 'charging', 'charged', etc.
### on() <sub>function</sub>
Register a global callback for certain engine-wide or system-level events.
### rt_info() <sub>function</sub>
Return internal QuickJS runtime info, such as object counts.
### rusage() <sub>function</sub>
Return resource usage stats for this process, if the platform supports it.
### mallinfo() <sub>function</sub>
Return detailed memory allocation info (arena size, free blocks, etc.) on some platforms.
### env() <sub>function</sub>
Fetch the value of a given environment variable, or undefined if it doesn't exist.
### system() <sub>function</sub>
Execute a shell command using the system() call. Returns the command's exit code.

View File

@@ -1,44 +0,0 @@
# packer
### getAllFiles(dir) <sub>function</sub>
Return a list of all files in the given directory that are not matched by .prosperonignore,
skipping directories.
**dir**: The directory to search.
**Returns**: An array of file paths found.
### gatherStats(filePaths) <sub>function</sub>
Analyze a list of files and categorize them as modules, programs, images, or other.
**filePaths**: An array of file paths to analyze.
**Returns**: An object { modules, programs, images, other, total } with counts.
### pack(dir, outPath) <sub>function</sub>
Create a ZIP archive of all files (skipping those matched by .prosperonignore) in the
specified directory and write it to outPath. This uses the miniz module.
**dir**: The directory to zip.
**outPath**: The path (including filename) for the resulting ZIP file.
**Returns**: None (synchronous). Throws an Error if the directory does not exist.

View File

@@ -1,96 +0,0 @@
# render
### _main <sub>object</sub>
A handle for low-level GPU operations via SDL GPU. Freed on GC.
### device <sub>object</sub>
### stencil_writer(...args) <sub>function</sub>
### fillmask(ref) <sub>function</sub>
Draw a fullscreen shape using a 'screenfill' shader to populate the stencil buffer with a given reference.
**ref**: The stencil reference value to write.
**Returns**: None
### mask(image, pos, scale, rotation, ref) <sub>function</sub>
Draw an image to the stencil buffer, marking its area with a specified reference value.
**image**: A texture or string path (which is converted to a texture).
**pos**: The translation (x, y) for the image placement.
**scale**: Optional scaling applied to the texture.
**rotation**: Optional rotation in radians (unused by default).
**ref**: The stencil reference value to write.
**Returns**: None
### viewport(rect) <sub>function</sub>
Set the GPU viewport to the specified rectangle.
**rect**: A rectangle [x, y, width, height].
**Returns**: None
### scissor(rect) <sub>function</sub>
Set the GPU scissor region to the specified rectangle (alias of render.viewport).
**rect**: A rectangle [x, y, width, height].
**Returns**: None
### queue(cmd) <sub>function</sub>
Enqueue one or more draw commands. These commands are batched until render_camera is called.
**cmd**: Either a single command object or an array of command objects.
**Returns**: None
### setup_draw() <sub>function</sub>
Switch the current queue to the primary scene render queue, then invoke 'prosperon.draw' if defined.
**Returns**: None
### setup_hud() <sub>function</sub>
Switch the current queue to the HUD render queue, then invoke 'prosperon.hud' if defined.
**Returns**: None

View File

@@ -1,68 +0,0 @@
# resources
### scripts <sub>object</sub>
### images <sub>object</sub>
### sounds <sub>object</sub>
### fonts <sub>object</sub>
### lib <sub>object</sub>
### canonical(file) <sub>function</sub>
### find_image(...args) <sub>function</sub>
### find_sound(...args) <sub>function</sub>
### find_script(...args) <sub>function</sub>
### find_font(...args) <sub>function</sub>
### getAllFiles(dir) <sub>function</sub>
Return a list of recognized files in the given directory that are not matched by
.prosperonignore, skipping directories. Recognized extensions include scripts,
images, sounds, fonts, and libs.
**dir**: The directory to search.
**Returns**: An array of recognized file paths.
### gatherStats(filePaths) <sub>function</sub>
Analyze a list of recognized files and categorize them by scripts, images, sounds,
fonts, libs, or other. Return a stats object with these counts and the total.
**filePaths**: An array of file paths to analyze.
**Returns**: { scripts, images, sounds, fonts, lib, other, total }
### pack(dir, outPath) <sub>function</sub>
Create a ZIP archive of all recognized files (skipping those matched by .prosperonignore)
in the specified directory and write it to outPath. Recognized extensions are scripts,
images, sounds, fonts, or libs.
:raises Error: If the directory does not exist.
**dir**: The directory to zip.
**outPath**: The path (including filename) for the resulting ZIP file.
**Returns**: None

View File

@@ -1,11 +0,0 @@
# sound
### undefined <sub>string</sub>
### pcm(file) <sub>function</sub>
### play(file) <sub>function</sub>
### cry(file) <sub>function</sub>
### music(file, fade = 0.5) <sub>function</sub>

View File

@@ -1,9 +0,0 @@
# spline
### catmull() <sub>function</sub>
Perform Catmull-Rom spline sampling on an array of 2D points, returning an array of samples.
### bezier() <sub>function</sub>
Perform a Bezier spline (or catmull) sampling on 2D points, returning an array of sampled points.

View File

@@ -1,103 +0,0 @@
# time
The main time object, handling date/time utilities in earth-seconds.
### now() <sub>function</sub>
Return the current system time in seconds (implemented in C extension).
### computer_dst() <sub>function</sub>
Return true if local system time is currently in DST (implemented in C extension).
### computer_zone() <sub>function</sub>
Return local time zone offset from UTC in hours (implemented in C extension).
### second <sub>number</sub>
Number of seconds in a (real) second (always 1).
### minute <sub>number</sub>
Number of seconds in a minute (60).
### hour <sub>number</sub>
Number of seconds in an hour (3600).
### day <sub>number</sub>
Number of seconds in a day (86400).
### week <sub>number</sub>
Number of seconds in a week (604800).
### weekdays <sub>object</sub>
Names of the days of the week, Sunday through Saturday.
### monthstr <sub>object</sub>
Full names of the months of the year, January through December.
### epoch <sub>number</sub>
Base epoch year, from which day 0 is calculated (default 1970).
### hour2minute() <sub>function</sub>
Return the ratio of hour to minute in seconds, e.g. 3600 / 60 => 60.
### day2hour() <sub>function</sub>
Return the ratio of day to hour in seconds, e.g. 86400 / 3600 => 24.
### minute2second() <sub>function</sub>
Return the ratio of minute to second in seconds, e.g. 60 / 1 => 60.
### week2day() <sub>function</sub>
Return the ratio of week to day in seconds, e.g. 604800 / 86400 => 7.
### strparse <sub>object</sub>
Mapping of format tokens (yyyy, mm, dd, etc.) to time fields (year, month, day...).
### isleap(year) <sub>function</sub>
Return true if a given year is leap, based on whether it has 366 days.
### yearsize(y) <sub>function</sub>
Given a year, return 365 or 366 depending on leap-year rules.
### timecode(t, fps = 24) <sub>function</sub>
Convert seconds into a "S:frames" timecode string, with optional FPS (default 24).
### monthdays <sub>object</sub>
An array of days in each month for a non-leap year.
### zones <sub>object</sub>
Table of recognized time zone abbreviations, with offsets (e.g., "-12" -> "IDLW").
### record(num, zone = this.computer_zone() <sub>function</sub>
Convert a timestamp (in seconds) into a record with fields like day, month, year, etc.
### number(rec) <sub>function</sub>
Convert a record back into a numeric timestamp (seconds).
### fmt <sub>string</sub>
Default format string for time.text(), containing tokens like 'yyyy', 'dd', 'hh', etc.
### text(num, fmt = this.fmt, zone) <sub>function</sub>
Format a numeric or record time into a string using a format pattern, e.g. 'hh:nn:ss'.

View File

@@ -1,58 +0,0 @@
# tween
### Tween <sub>object</sub>
An object providing methods to create and control tweens with additional features
like looping, custom easing, multiple stages, etc.
Properties:
- default: A template object with loop/time/ease/whole/cb properties.
Methods:
- start(obj, target, tvals, options): Create a tween over multiple target values.
- make: Alias of start.
### Ease <sub>object</sub>
This object provides multiple easing functions that remap a 0..1 input to produce
a smoothed or non-linear output. They can be used standalone or inside tweens.
Available functions:
- linear(t)
- in(t), out(t), inout(t)
- quad.in, quad.out, quad.inout
- cubic.in, cubic.out, cubic.inout
- quart.in, quart.out, quart.inout
- quint.in, quint.out, quint.inout
- expo.in, expo.out, expo.inout
- bounce.in, bounce.out, bounce.inout
- sine.in, sine.out, sine.inout
- elastic.in, elastic.out, elastic.inout
All easing functions expect t in [0..1] and return a remapped value in [0..1].
### tween(from, to, time, fn, cb) <sub>function</sub>
Creates a simple tween that linearly interpolates from "from" to "to" over "time"
and calls "fn" with each interpolated value. Once finished, "fn" is called with "to",
then "cb" is invoked if provided, and the tween is cleaned up.
**from**: The starting object or value to interpolate from.
**to**: The ending object or value to interpolate to.
**time**: The total duration of the tween in milliseconds or some time unit.
**fn**: A callback function that receives the interpolated value at each update.
**cb**: (Optional) A callback invoked once the tween completes.
**Returns**: A function that, when called, cleans up and stops the tween.

View File

@@ -1,192 +0,0 @@
# util
A collection of general-purpose utility functions for object manipulation, merging,
deep copying, safe property access, etc.
### guid() <sub>function</sub>
Return a random 32-character hexadecimal UUID-like string (not guaranteed RFC4122-compliant).
**Returns**: A random 32-character string (hex).
### insertion_sort(arr, cmp) <sub>function</sub>
In-place insertion sort of an array using cmp(a,b)->Number for ordering.
**arr**: The array to be sorted in-place.
**cmp**: Comparison function cmp(a,b)->Number.
**Returns**: The same array, sorted in-place.
### deepfreeze(obj) <sub>function</sub>
Recursively freeze an object and all of its nested objects so they cannot be modified.
**obj**: The object to recursively freeze.
**Returns**: None
### dainty_assign(target, source) <sub>function</sub>
Copy non-function properties from source into matching keys of target without overwriting
keys that don't exist in target. Arrays are deep-copied, and objects are recursively assigned.
**target**: The target object whose keys may be updated.
**source**: The source object containing new values.
**Returns**: None
### get(obj, path, defValue) <sub>function</sub>
Safely retrieve a nested property from obj at path (array or dot-string).
Returns defValue if the property is undefined.
**obj**: The object to traverse.
**path**: A string like "a.b.c" or an array of path segments.
**defValue**: The default value if the property is undefined.
**Returns**: The nested property or defValue.
### isEmpty(o) <sub>function</sub>
Return true if the object has no own properties, otherwise false.
**o**: The object to check.
**Returns**: Boolean indicating if the object is empty.
### dig(obj, path, def) <sub>function</sub>
Ensure a nested path of objects exists inside obj; create objects if missing, and set
the final path component to def.
**obj**: The root object to modify.
**path**: A dot-string specifying nested objects to create.
**def**: The value to store in the final path component, default {}.
**Returns**: The assigned final value.
### access(obj, name) <sub>function</sub>
Traverse obj by dot-separated path name, returning the final value or undefined
if any step is missing.
**obj**: The object to traverse.
**name**: A dot-string path (e.g. "foo.bar.baz").
**Returns**: The value at that path, or undefined if missing.
### mergekey(o1, o2, k) <sub>function</sub>
Helper for merge, updating key k from o2 into o1. Arrays are deep-copied and objects are
recursively merged.
**o1**: The target object.
**o2**: The source object.
**k**: The key to merge.
**Returns**: None
### merge(target, objs) <sub>function</sub>
Merge all passed objects into target, copying or merging each key as needed.
Arrays are deep-copied, objects are recursively merged, etc.
**target**: The target object.
**objs**: One or more objects to merge into target.
**Returns**: The updated target object.
### copy(proto, objs) <sub>function</sub>
Create a new object with proto as its prototype, then mix in additional objects properties.
**proto**: The prototype object for the new object.
**objs**: One or more objects whose properties will be mixed in.
**Returns**: The newly created object.
### obj_lerp(a, b, t) <sub>function</sub>
Linearly interpolate between two objects a and b by factor t, assuming each property
supports .lerp().
**a**: The start object (its properties must have .lerp()).
**b**: The end object (matching properties).
**t**: Interpolation factor (0..1).
**Returns**: A new object with interpolated properties.
### normalizeSpacing(spacing) <sub>function</sub>
Normalize any spacing input into a {l, r, t, b} object.
**spacing**: A number, an array of length 2 or 4, or an object with l/r/t/b.
**Returns**: An object {l, r, t, b}.

View File

@@ -1,5 +0,0 @@
# video
### make_video() <sub>function</sub>
Decode a video file (MPEG, etc.) from an ArrayBuffer, returning a datastream object.

View File

@@ -1,35 +0,0 @@
# prosperon
### c_types <sub>object</sub>
### argv <sub>object</sub>
### version <sub>string</sub>
### revision <sub>string</sub>
### engine_start() <sub>function</sub>
### DOC <sub>symbol</sub>
### on(type, callback) <sub>function</sub>
### dispatch(type, data) <sub>function</sub>
### PATH <sub>object</sub>
### appupdate(...args) <sub>function</sub>
### update(...args) <sub>function</sub>
### physupdate(...args) <sub>function</sub>
### gui(...args) <sub>function</sub>
### hud(...args) <sub>function</sub>
### draw(...args) <sub>function</sub>
### imgui(...args) <sub>function</sub>
### app(...args) <sub>function</sub>

View File

@@ -1,55 +0,0 @@
# PHYSFS_File
A file handle opened via PhysFS for writing or reading. Freed automatically when references go away.
### close() <sub>function</sub>
Close this file handle. Throws on error.
**Returns**: None
### write(data) <sub>function</sub>
Write data (string or ArrayBuffer) to the file. Throws on error.
**data**: The data to write (string or ArrayBuffer).
**Returns**: None
### buffer(size) <sub>function</sub>
Enable an internal write buffer of the given size on this file.
**size**: Size in bytes of the buffer.
**Returns**: None
### tell() <sub>function</sub>
Return the current position in the file.
**Returns**: A numeric offset.
### eof() <sub>function</sub>
Return whether the file pointer is at end-of-file.
**Returns**: True if at EOF, false otherwise.

View File

@@ -1,27 +0,0 @@
# SDL_Camera
A handle to a physical camera device. Freed when references drop or camera is closed.
### frame() <sub>function</sub>
Acquire the latest camera frame (as an SDL_Surface). Returns undefined if no
new frame is available yet. Throws on error.
**Returns**: SDL_Surface or undefined.
### release_frame(surface) <sub>function</sub>
Release a frame surface previously acquired via camera.frame(). Must be
done for each acquired frame.
**surface**: The surface to release.
**Returns**: None

View File

@@ -1,4 +0,0 @@
# SDL_Cursor
An SDL cursor handle. Freed automatically on GC. No direct methods.

View File

@@ -1,3 +0,0 @@
# SDL_GPUBuffer
### name() <sub>function</sub>

View File

@@ -1,231 +0,0 @@
# SDL_GPUCommandBuffer
A command buffer that accumulates rendering, copy, and compute operations. Freed after submission or GC.
### render_pass(passDesc) <sub>function</sub>
Begin a render pass with color/depth attachments. Provide an object with
'color_targets' and optional 'depth_stencil'. Returns an SDL_GPURenderPass handle.
**passDesc**: {color_targets:[...], depth_stencil:...}
**Returns**: SDL_GPURenderPass
### compute_pass(storageTextures, storageBuffers) <sub>function</sub>
Begin a compute pass reading/writing given arrays of textures and buffers.
**storageTextures**: array of read/write textures
**storageBuffers**: array of read/write buffers
**Returns**: SDL_GPUComputePass
### swapchain_pass(clearColor) <sub>function</sub>
Begin a render pass that directly targets the swapchain (the window). Clears
with the specified color.
**clearColor**: [r,g,b,a]
**Returns**: SDL_GPURenderPass
### acquire_swapchain() <sub>function</sub>
Acquire the current swapchain texture from the window. Internal usage.
**Returns**: SDL_GPUTexture handle
### bind_vertex_buffer(slot, buffer) <sub>function</sub>
Bind a GPU buffer as the vertex buffer at a given slot.
**slot**: Integer slot index.
**buffer**: The SDL_GPUBuffer.
**Returns**: None
### bind_index_buffer(buffer, offset) <sub>function</sub>
Bind a GPU buffer as the index buffer (16-bit or 32-bit).
**buffer**: The SDL_GPUBuffer.
**offset**: Optional offset in bytes.
**Returns**: None
### bind_fragment_sampler(slot, texture, sampler) <sub>function</sub>
Bind a texture+sampler pair to a particular fragment shader slot.
**slot**: Index of the sampler binding.
**texture**: The SDL_GPUTexture
**sampler**: The SDL_GPUSampler
**Returns**: None
### push_vertex_uniform_data(slot, data) <sub>function</sub>
Push raw data to a vertex shader uniform block.
**slot**: The uniform buffer slot.
**data**: An ArrayBuffer with the data to upload.
**Returns**: None
### push_fragment_uniform_data(slot, data) <sub>function</sub>
Push raw data to a fragment shader uniform block.
**slot**: The uniform buffer slot index.
**data**: An ArrayBuffer with uniform data.
**Returns**: None
### push_compute_uniform_data(slot, data) <sub>function</sub>
Push raw data to a compute shader uniform buffer.
**slot**: The uniform buffer slot.
**data**: An ArrayBuffer with the data.
**Returns**: None
### submit() <sub>function</sub>
Submit this command buffer to the GPU and return a fence for synchronization.
**Returns**: An SDL_GPUFence
### cancel() <sub>function</sub>
Cancel (discard) this command buffer without submitting.
**Returns**: None
### camera(cameraTransform, uniformSlot) <sub>function</sub>
Write a camera transform (projection/view) to a uniform slot for 3D or 2D usage.
**cameraTransform**: A camera object or transform with .pos, fov, etc.
**uniformSlot**: The integer uniform buffer slot to which data is pushed.
**Returns**: None
### hud(sizeVec2, uniformSlot) <sub>function</sub>
Write an orthographic full-screen "HUD" matrix to a uniform slot. Typically used
for 2D overlays.
**sizeVec2**: [width, height] of the viewport area.
**uniformSlot**: The integer uniform buffer slot.
**Returns**: None
### push_debug_group(name) <sub>function</sub>
Push a named debug group marker onto the GPU command list (for debuggers/profilers).
**name**: The debug label string.
**Returns**: None
### pop_debug_group() <sub>function</sub>
Pop the most recent debug group marker.
**Returns**: None
### debug_label(label) <sub>function</sub>
Insert a one-off debug label at the current spot in the command list.
**label**: The debug label string
**Returns**: None
### blit(blitDesc) <sub>function</sub>
Blit one GPU texture to another with optional flip mode, filter, and clear operations.
**blitDesc**: { src:{texture,mip_level, etc}, dst:{texture,...}, load_op, flip, filter, clear_color:[r,g,b,a] }
**Returns**: None

View File

@@ -1,83 +0,0 @@
# SDL_GPUComputePass
A compute pass for dispatching compute pipelines. Freed after end() or GC.
### dispatch(x, y, z) <sub>function</sub>
Dispatch the compute pipeline with the specified threadgroup counts.
**x**: Number of groups in X dimension
**y**: Number of groups in Y dimension
**z**: Number of groups in Z dimension
**Returns**: None
### end() <sub>function</sub>
End this compute pass.
**Returns**: None
### pipeline(computePipeline) <sub>function</sub>
Bind a compute pipeline in this pass.
**computePipeline**: The SDL_GPUComputePipeline
**Returns**: None
### samplers(arrayOfSamplerBindings, firstSlot) <sub>function</sub>
Bind a set of texture/sampler pairs for compute usage.
**arrayOfSamplerBindings**: e.g. [ {texture, sampler}, ...]
**firstSlot**: The starting sampler slot.
**Returns**: None
### storage_buffers(arrayOfBuffers, firstSlot) <sub>function</sub>
Bind an array of storage buffers for the compute shader.
**arrayOfBuffers**: The buffers
**firstSlot**: Starting binding slot.
**Returns**: None
### storage_textures(arrayOfTextures, firstSlot) <sub>function</sub>
Bind an array of storage textures for the compute shader.
**arrayOfTextures**: The textures
**firstSlot**: Starting binding slot
**Returns**: None

View File

@@ -1,5 +0,0 @@
# SDL_GPUComputePipeline
Encapsulates a compute shader program plus associated resource layouts.
Created via device.compute_pipeline(...).

View File

@@ -1,4 +0,0 @@
# SDL_GPUCopyPass
A pass for CPU<->GPU or GPU<->GPU copy operations. No direct JS API besides internal usage.

View File

@@ -1,236 +0,0 @@
# SDL_GPUDevice
A handle for low-level GPU operations via SDL GPU. Freed on GC.
### claim_window(window) <sub>function</sub>
Claim an existing SDL_Window so this GPU device can render to it.
**window**: The SDL_Window to attach.
**Returns**: None
### make_pipeline(pipelineDesc) <sub>function</sub>
Create a new graphics pipeline from a descriptor object specifying shaders,
blend states, vertex format, etc.
**pipelineDesc**: An object containing pipeline fields (vertexShader, blend, etc.).
**Returns**: A SDL_GPUGraphicsPipeline handle.
### compute_pipeline(desc) <sub>function</sub>
Create a compute pipeline from a descriptor (shader code, threadgroup sizes, etc.).
**desc**: An object with shader code, thread counts, etc.
**Returns**: SDL_GPUComputePipeline handle.
### set_swapchain(composition, presentMode) <sub>function</sub>
Specify how the swapchain (final rendered image) is composed, e.g. 'sdr', 'hdr',
and present mode like 'vsync' or 'immediate'.
**composition**: E.g. 'sdr', 'linear', or 'hdr'.
**presentMode**: E.g. 'vsync', 'immediate', 'mailbox'.
**Returns**: None
### sort_sprite(a, b) <sub>function</sub>
A comparator function used for sorting sprite objects by layer, y, and texture.
Usually used internally.
**a**: A sprite object.
**b**: Another sprite object.
**Returns**: <0, 0, or >0 for sort ordering.
### make_sampler(samplerDesc) <sub>function</sub>
Create a sampler object specifying filtering, wrapping, anisotropy, etc.
**samplerDesc**: An object with min_filter, mag_filter, etc.
**Returns**: SDL_GPUSampler handle.
### load_texture(surface, compressionLevel) <sub>function</sub>
Upload an SDL_Surface into a GPU texture, optionally compressing with DXT. Freed automatically.
**surface**: An SDL_Surface.
**compressionLevel**: 0=none, 1=DXT1 or DXT5, 2=high quality, etc.
**Returns**: SDL_GPUTexture
### texture(desc) <sub>function</sub>
Create a GPU texture with the specified format usage.
**desc**: Object with {width, height, layers, type, format, usage, etc.}
**Returns**: SDL_GPUTexture
### make_quad() <sub>function</sub>
Return a simple 2-triangle quad geometry covering [0,1]x[0,1].
Useful for post-processing passes.
**Returns**: A mesh {pos, uv, color, indices}.
### driver() <sub>function</sub>
Return the name of the underlying GPU driver in use (e.g. 'OpenGL').
**Returns**: A string with driver name.
### make_shader(desc) <sub>function</sub>
Compile raw shader code (vertex or fragment) in e.g. SPIR-V, MSL, or DXIL format.
**desc**: {code:ArrayBuffer, stage:'vertex'|'fragment', format:'spv'|..., entrypoint:'main', ...}
**Returns**: SDL_GPUShader object
### acquire_cmd_buffer() <sub>function</sub>
Obtain a new command buffer for recording GPU commands. Must be submitted or canceled.
**Returns**: SDL_GPUCommandBuffer handle
### upload(cmdBuffer, buffers, transferBuffer) <sub>function</sub>
Upload CPU data into a list of GPU buffers, optionally reusing or returning a
transfer buffer. Typically you provide (cmdBuf, arrayOfTypedArrays, [transferBuffer]).
**cmdBuffer**: The command buffer in which to record copy commands.
**buffers**: An array of typed-array data to upload, each must have a 'gpu' property or so.
**transferBuffer**: Optional existing GPU transfer buffer to reuse.
**Returns**: The transfer buffer used or newly created.
### wait_for_fences(fences, waitAll) <sub>function</sub>
Wait on an array of GPU fence objects, optionally requiring all or any.
**fences**: An array of SDL_GPUFence objects.
**waitAll**: Boolean, true to wait for all fences, false for any.
**Returns**: True if fences signaled, false on timeout or error.
### query_fence(fence) <sub>function</sub>
Check if the given fence has been signaled yet. Non-blocking.
**fence**: SDL_GPUFence handle
**Returns**: True if signaled, false if still pending
### shader_format() <sub>function</sub>
Return an array of supported GPU shader binary formats (like 'spv', 'dxbc', etc.).
**Returns**: Array of strings naming supported formats.
### slice9(texture, dstRect, edges) <sub>function</sub>
Generate a 9-slice tiling geometry in one shot. For advanced usage with GPU pipeline.
**texture**: An SDL_GPUTexture
**dstRect**: The rectangle {x, y, w, h}
**edges**: {l, r, t, b} edge sizes
**Returns**: A mesh object
### tile(texture, srcRect, dstRect, tileInfo) <sub>function</sub>
Generate geometry to tile a texture portion inside a dest rect.
Often used for repeating backgrounds.
**texture**: The SDL_GPUTexture
**srcRect**: The portion to tile in pixels
**dstRect**: Where to fill
**tileInfo**: e.g. {repeat_x:true, repeat_y:true}
**Returns**: A mesh object

View File

@@ -1,5 +0,0 @@
# SDL_GPUFence
A GPU fence for synchronization. Created upon commandBuffer.submit().
Wait or query it with device.wait_for_fences or device.query_fence.

View File

@@ -1,5 +0,0 @@
# SDL_GPUGraphicsPipeline
Encapsulates vertex+fragment shaders, blend/cull states, and vertex attribute layouts.
Created via device.make_pipeline(...).

View File

@@ -1,159 +0,0 @@
# SDL_GPURenderPass
A single pass of drawing commands with color/depth attachments. Freed after end() or GC.
### bind_pipeline(pipeline) <sub>function</sub>
Bind a previously created graphics pipeline (shaders, states, vertex layouts, etc.).
**pipeline**: The SDL_GPUGraphicsPipeline
**Returns**: None
### viewport(rect) <sub>function</sub>
Set the viewport for clipping or scaling draws, in pass-local coordinates.
**rect**: {x,y,w,h}
**Returns**: None
### scissor(rect) <sub>function</sub>
Set a scissor rectangle for discarding pixels outside it.
**rect**: {x,y,w,h}
**Returns**: None
### draw(primitiveType, baseVertex, firstVertex, vertexCount) <sub>function</sub>
Issue a non-indexed draw call.
**primitiveType**: e.g. SDL_GPU_PRIMITIVETYPE_TRIANGLELIST
**baseVertex**: Starting vertex offset.
**firstVertex**: The first vertex to draw.
**vertexCount**: How many vertices to draw.
**Returns**: None
### draw_indexed(primitiveType, baseVertex, firstIndex, indexCount, instanceCount) <sub>function</sub>
Issue an indexed draw call from the bound index buffer.
**primitiveType**: The primitive type constant.
**baseVertex**: Offset in the vertex buffer.
**firstIndex**: Which index to start from.
**indexCount**: Number of indices to draw.
**instanceCount**: For instanced drawing, or 1 if normal.
**Returns**: None
### end() <sub>function</sub>
End this render pass, finalizing the draw operations.
**Returns**: None
### bind_index_buffer(buffer, elementSize16bit) <sub>function</sub>
Bind an index buffer inside this pass, possibly overriding the global one.
**buffer**: The SDL_GPUBuffer
**elementSize16bit**: If 2, uses 16-bit indices; if 4, uses 32-bit indices
**Returns**: None
### bind_buffers(firstSlot, arrayOfBuffers) <sub>function</sub>
Bind multiple vertex buffers at consecutive slots.
**firstSlot**: The starting vertex buffer slot.
**arrayOfBuffers**: An array of GPUBuffer objects
**Returns**: None
### bind_samplers(vertexOrFragment, firstSlot, samplerBindings) <sub>function</sub>
Bind multiple texture/sampler pairs to either vertex or fragment slots.
**vertexOrFragment**: Boolean, true for vertex stage, false for fragment.
**firstSlot**: The first sampler slot to bind.
**samplerBindings**: An array of {texture, sampler}.
**Returns**: None
### bind_storage_buffers(firstSlot, buffers) <sub>function</sub>
Bind one or more storage buffers for read/write in the pipeline.
**firstSlot**: Starting buffer slot index.
**buffers**: An array of SDL_GPUBuffer objects.
**Returns**: None
### bind_storage_textures(firstSlot, textures) <sub>function</sub>
Bind one or more storage textures for read/write in the pipeline.
**firstSlot**: Starting texture slot index.
**textures**: An array of SDL_GPUTexture objects.
**Returns**: None

View File

@@ -1,4 +0,0 @@
# SDL_GPUSampler
Defines how a texture is sampled (filter mode, address mode, anisotropy, compare op, etc.).

View File

@@ -1,5 +0,0 @@
# SDL_GPUShader
A single compiled shader (vertex or fragment) in a GPU-friendly format
(e.g., SPIR-V, MSL). Combined into a pipeline for drawing.

View File

@@ -1,3 +0,0 @@
# SDL_GPUTexture
### name() <sub>function</sub>

View File

@@ -1,5 +0,0 @@
# SDL_GPUTransferBuffer
A staging buffer used for copying data to or from GPU buffers/textures. Typically
allocated/used internally by device.upload(...).

View File

@@ -1,333 +0,0 @@
# SDL_Renderer
A 2D rendering context using the SDL renderer API. Freed automatically.
### draw_color(color) <sub>function</sub>
Set the render draw color for subsequent primitive calls (rect, line, etc.).
**color**: [r, g, b, a] in 0..1.
**Returns**: None
### present() <sub>function</sub>
Display whatever has been rendered (swap buffers). Must be called each frame.
**Returns**: None
### clear() <sub>function</sub>
Clear the current render target with the renderer's draw color.
**Returns**: None
### rect(rectOrArray, color) <sub>function</sub>
Draw one or more outlines of rectangles.
**rectOrArray**: A single rect {x,y,w,h} or an array of rects.
**color**: Optional [r,g,b,a]. If provided, overrides current draw color.
**Returns**: None
### fillrect(rectOrArray, color) <sub>function</sub>
Fill one or more rectangles with the renderer's current color or an optional override.
**rectOrArray**: A single rect {x,y,w,h} or an array of rects.
**color**: Optional [r,g,b,a].
**Returns**: None
### line(points, color) <sub>function</sub>
Draw a sequence of lines connecting points in an array.
**points**: An array of [x,y] points. Lines connect consecutive points.
**color**: Optional [r,g,b,a].
**Returns**: None
### point(points, color) <sub>function</sub>
Draw a list of points (pixels).
**points**: An array of [x,y] positions.
**color**: Optional [r,g,b,a].
**Returns**: None
### load_texture(surface) <sub>function</sub>
Create an SDL_Texture from a given SDL_Surface for use with this renderer.
**surface**: An SDL_Surface.
**Returns**: An SDL_Texture object.
### texture(tex, dstRect, srcRect, color) <sub>function</sub>
Draw a texture onto the render target.
**tex**: The SDL_Texture to draw.
**dstRect**: The destination rect {x, y, w, h}.
**srcRect**: Optional portion of the texture to draw {x, y, w, h}.
**color**: Optional color mod [r,g,b,a].
**Returns**: None
### slice9(tex, dstRect, edges, srcRect) <sub>function</sub>
Draw a texture with 9-slice scaling. The argument includes edges {l, r, t, b}
for the corners/borders that remain unscaled. The rest is tiled or stretched.
**tex**: The SDL_Texture.
**dstRect**: Destination region {x, y, w, h}.
**edges**: {l, r, t, b} for corner sizes in pixels.
**srcRect**: Optional portion in the texture.
**Returns**: None
### tile(tex, dstRect, srcRect, scale) <sub>function</sub>
Tile a texture repeatedly within the specified region. Optionally use a srcRect.
**tex**: The SDL_Texture to tile.
**dstRect**: The region to fill {x, y, w, h}.
**srcRect**: Optional portion of texture.
**scale**: A float scale factor for each tile.
**Returns**: None
### get_image(rect) <sub>function</sub>
Read back the rendered pixels into a new SDL_Surface. If rect is undefined, capture entire output.
**rect**: Optional {x,y,w,h}.
**Returns**: An SDL_Surface with the requested region's pixels.
### fasttext(text, pos, color) <sub>function</sub>
Draw debug text using an internal fast path. Typically used for quick debugging overlays.
**text**: The string to draw.
**pos**: The [x, y] position to draw text.
**color**: Optional [r,g,b,a].
**Returns**: None
### geometry(texture, meshObject) <sub>function</sub>
Render custom geometry from a mesh object {pos, uv, color, indices, count} with an optional texture.
**texture**: The SDL_Texture or undefined.
**meshObject**: The geometry data with typed arrays.
**Returns**: None
### scale(scaleVec2) <sub>function</sub>
Set a scaling factor for all subsequent rendering on this renderer.
**scaleVec2**: [sx, sy] scaling factors.
**Returns**: None
### logical_size(size) <sub>function</sub>
Set a "logical" size that the renderer will scale to.
For example, (320, 240) can auto-scale up to the window resolution.
**size**: [width, height].
**Returns**: None
### viewport(rect) <sub>function</sub>
Set the clipping viewport for rendering. Pass undefined to use the full render target.
**rect**: {x, y, w, h}, or undefined.
**Returns**: None
### clip(rect) <sub>function</sub>
Set or clear the clipping rectangle for drawing. Pass undefined to clear.
**rect**: {x, y, w, h} or undefined.
**Returns**: None
### vsync(flag) <sub>function</sub>
Enable or disable vertical sync. This may have no effect depending on the driver.
**flag**: True or false.
**Returns**: None
### coords(pos) <sub>function</sub>
Convert window coordinates to this renderer's coordinate space.
**pos**: [x, y] in window space.
**Returns**: [x, y] in renderer coordinate space.
### camera(cameraTransform, centered) <sub>function</sub>
Set up a basic 2D camera matrix from a given transform. If 'centered' is true,
the origin is the center of the viewport, else top-left.
**cameraTransform**: The transform whose pos is used.
**centered**: Boolean true or false.
**Returns**: None
### get_viewport() <sub>function</sub>
Return the current viewport rect.
**Returns**: {x, y, w, h}
### screen2world(pos) <sub>function</sub>
Convert a screen coordinate to world space based on the current camera transform.
**pos**: [x, y] screen coords
**Returns**: [wx, wy] in world space
### target(texture) <sub>function</sub>
Set or clear the current render target texture. Pass undefined to reset to the default/window.
**texture**: An SDL_Texture or undefined
**Returns**: None
### make_sprite_mesh(sprites) <sub>function</sub>
Generate a mesh from an array of sprite objects, combining their positions, UVs,
and colors into a single geometry block.
**sprites**: An array of sprite-like objects.
**Returns**: A 'mesh' object with pos, uv, color, indices, etc.

View File

@@ -1,68 +0,0 @@
# SDL_Surface
A software (CPU) image in memory. Freed when references vanish. Typically converted
to SDL_Texture for drawing, or used as raw pixel data.
### blit(dstRect, srcSurface, srcRect) <sub>function</sub>
Blit (copy) another surface onto this surface, scaling if needed.
**dstRect**: Destination {x, y, w, h}
**srcSurface**: The source SDL_Surface
**srcRect**: {x, y, w, h} portion from source
**Returns**: None
### scale(newSize) <sub>function</sub>
Return a new SDL_Surface scaled to [width, height] using linear filtering.
**newSize**: [width, height]
**Returns**: A new SDL_Surface with the scaled result.
### fill(color) <sub>function</sub>
Fill the entire surface with a single color.
**color**: [r, g, b, a] in 0..1
**Returns**: None
### rect(rect, color) <sub>function</sub>
Fill a sub-rectangle of the surface with a color.
**rect**: {x, y, w, h}
**color**: [r, g, b, a]
**Returns**: None
### dup() <sub>function</sub>
Make a copy of this surface in RGBA format.
**Returns**: A new SDL_Surface copy.

View File

@@ -1,16 +0,0 @@
# SDL_Texture
A 2D GPU-accelerated texture for rendering with SDL_Renderer. Freed automatically.
### mode(mode) <sub>function</sub>
Set texture scale mode or filtering mode (nearest/linear).
**mode**: A string or numeric mode to set (e.g., 'linear').
**Returns**: None

View File

@@ -1,15 +0,0 @@
# SDL_Thread
A handle to an SDL-created thread. Freed on GC after join.
Note: The engine generally doesn't expose custom usage for threads.
### wait() <sub>function</sub>
Block until this thread terminates.
**Returns**: None

View File

@@ -1,126 +0,0 @@
# SDL_Window
An application window, created via prosperon.engine_start or SDL calls. Freed on GC.
### fullscreen() <sub>function</sub>
Toggle fullscreen mode for this window (SDL_WINDOW_FULLSCREEN).
**Returns**: None
### make_renderer(name) <sub>function</sub>
Create an SDL_Renderer for 2D rendering tied to this window.
**name**: The renderer driver name, e.g. "opengl" (may be optional).
**Returns**: An SDL_Renderer object.
### make_gpu(debug, driverName) <sub>function</sub>
Create an SDL_GPUDevice for low-level GPU rendering on this window.
**debug**: If true, enable debugging in the GPU device.
**driverName**: The GPU back-end driver, e.g. "opengl".
**Returns**: An SDL_GPUDevice.
### keyboard_shown() <sub>function</sub>
Return whether the on-screen keyboard is visible (mobile/tablet).
**Returns**: True if shown, false otherwise.
### theme() <sub>function</sub>
Currently returns undefined. Placeholder for retrieving OS window theme info.
**Returns**: undefined
### safe_area() <sub>function</sub>
Return a rect describing any OS-specific "safe" region for UI, e.g. on iPhone with a notch.
**Returns**: A rect object {x, y, w, h}.
### bordered(flag) <sub>function</sub>
Enable or disable window borders.
**flag**: True to show borders, false to hide.
**Returns**: None
### set_icon(surface) <sub>function</sub>
Set the window's icon from an SDL_Surface.
**surface**: An SDL_Surface holding the icon.
**Returns**: None
### title <sub>accessor</sub>
Get or set the window's title text in the title bar.
**newTitle**: (when setting) A string title.
**Returns**: The current title if getting, or None if setting.
### size <sub>accessor</sub>
Get or set the window's size as [width, height].
**newSize**: (when setting) e.g. [640, 480]
**Returns**: The current [width, height] or None if setting.
### mouse_grab(flag) <sub>function</sub>
Grab or ungrab the mouse for this window (so the pointer won't leave).
**flag**: True to grab mouse input, false to release.
**Returns**: None

View File

@@ -1,67 +0,0 @@
# datastream
A streaming media handle, typically for MPEG video. Freed automatically.
### time() <sub>function</sub>
Return the current playback time in seconds.
**Returns**: Current time as a float in seconds.
### seek(seconds) <sub>function</sub>
Seek to the specified time (in seconds).
**seconds**: The time to jump to in the stream.
**Returns**: None
### advance(seconds) <sub>function</sub>
Advance by a certain number of seconds, decoding video as needed.
**seconds**: The amount of time to skip forward.
**Returns**: None
### duration() <sub>function</sub>
Return the total duration of the video stream, in seconds, if known.
**Returns**: Float seconds duration, or 0 if unknown.
### framerate() <sub>function</sub>
Return the framerate (FPS) of the stream if known.
**Returns**: Float frames per second, or 0 if unknown.
### callback <sub>accessor</sub>
A function to call whenever a new frame is decoded. If not set, no callback is invoked.
**fn**: (when setting) A function that receives (surface).
**Returns**: The existing function or undefined if none.

View File

@@ -1,66 +0,0 @@
# enet_host
### service(callback, timeout) <sub>function</sub>
Poll for and process any available network events (connect, receive, disconnect, or none)
from this host, calling the provided callback for each event. This function loops until
no more events are available in the current timeframe.
Event object properties:
- type: String, one of "connect", "receive", "disconnect", or "none".
- peer: (present if type = "connect") The ENetPeer object for the new connection.
- channelID: (present if type = "receive") The channel on which the data was received.
- data: (present if type = "receive") The received data as a *plain JavaScript object*.
If the JSON parse fails or the data isn't an object, a JavaScript error is thrown.
object as its single argument.
**callback**: A function called once for each available event, receiving an event
**timeout**: (optional) Timeout in milliseconds. Defaults to 0 (non-blocking).
**Returns**: None
### connect(host, port) <sub>function</sub>
Initiate a connection from this host to a remote server. Throws an error if the
connection cannot be started.
**host**: The hostname or IP address of the remote server (e.g. "example.com" or "127.0.0.1").
**port**: The port number to connect to.
**Returns**: An ENetPeer object representing the connection.
### flush() <sub>function</sub>
Flush all pending outgoing packets for this host immediately.
**Returns**: None
### broadcast(data) <sub>function</sub>
Broadcast a JavaScript object to all connected peers on channel 0. The object is
serialized to JSON, and the packet is sent reliably. Throws an error if serialization fails.
**data**: A JavaScript object to broadcast to all peers.
**Returns**: None

Some files were not shown because too many files have changed in this diff Show More