From c6a1c8f07a0f48421b0af52cb2e4288fa1476fb0 Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Wed, 1 Jan 2025 12:39:02 -0600 Subject: [PATCH 1/1] minimal functional example --- .gitignore | 1 + Makefile | 8 +++++++ icon.png | Bin 0 -> 3675 bytes main.c | 33 ++++++++++++++++++++++++++++ manifest.json | 16 ++++++++++++++ shell.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ sw.js | 17 +++++++++++++++ 7 files changed, 134 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 icon.png create mode 100644 main.c create mode 100644 manifest.json create mode 100644 shell.html create mode 100644 sw.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bdb90ee --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/outdir/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1b460f3 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ + + +all: main.c shell.html + mkdir -p outdir + emcc main.c --shell-file shell.html -o outdir/index.html -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']" + cp manifest.json outdir + cp sw.js outdir + cp icon.png outdir diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6dfd1bd942270b1e334b152595581e5581a3e72d GIT binary patch literal 3675 zcmb_ed010d7C$!$NuY!P6)1})Y83>n5hy`4CV&VCBGMuX0itYz0+AhyoQIecbdpAUf2LhbF{o$c+};;6{r&^xPcuu$6 z=Y77peWQb^M%;;KC(he!*VNg2&vf2-yB~DCV>yWfEXzXHM?q&Bx$lEI_M-j?MIHjMvsoZvLMW|u+#1|LxmS3sus|{E> z|HNd*t0Q%h*)AWwx7H#o*kZhP%g$@}Zg12pF8WbxvsRtwrb|f+`>r)69xdLQU;J+M z6l1Z<{-CT^B?mKV7M)_-rls1L{!p_aRbjJC*SsW0Hd-gFTL01KLLE-jaw(Nj^ok}q z&|Un~k(2NHd3>lUE4Oa0qia4@@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p^Pc^(GIAn{IUoU?UgbTFP0jN)b?p5|37!3*fR9uHedfCWJ;kHHuZi zoR2tkSIPwzp>RD!$|-8mLmalN8lk`oIo84<0o>8JP}@&K9LGC)rCd!2xLuYtLLS@B z2K9OjS-yLJ^o17K1>#PFQ(6hlblB@6ayu(4;dxN7hK=rV$y3w?NWk3aYU6*64gI#g zcCti+-gPAGgL^xN7sKI{8%#pZoFV2?&J*H?A562sByBGt+GUOro5ynG|HqpD*o%Mm gQ2xgj|C8=RqqG3?w%m$I)C +#include +#include +#include + +int main() { + printf("hello, world!\ntell me something\n"); + return 0; +} + +void reverse(char* s) { + char* start = s; + char* end = s - 1+ strlen(s); + char tmp; + while(start < end) { + tmp = *start; + *start = *end; + *end = tmp; + start++; + end--; + } +} + +EMSCRIPTEN_KEEPALIVE char* do_this(char* in) { + char* out = strdup(in); + reverse(out); + return out; +} + + +#endif diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f84a778 --- /dev/null +++ b/manifest.json @@ -0,0 +1,16 @@ +{ + "background_color": "#8E5DCE", + "description": "minimal example", + "display": "fullscreen", + "icons": [ + { + "src": "icon.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "name": "min-ex", + "short_name": "min-ex", + "start_url": "." +} + diff --git a/shell.html b/shell.html new file mode 100644 index 0000000..39613a7 --- /dev/null +++ b/shell.html @@ -0,0 +1,59 @@ + + + + + + + + minmal example + + +
+
+ +
+ + {{{ SCRIPT }}} + + diff --git a/sw.js b/sw.js new file mode 100644 index 0000000..b00b84b --- /dev/null +++ b/sw.js @@ -0,0 +1,17 @@ +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open('minex').then((cache) => cache.addAll([ + './', + './index.html', + './icon.png', + './index.js', + './index.wasm', + ])) + )}); + +self.addEventListener('fetch', (event) => { + event.respondWith( + caches.match(event.request).then((response) => response || fetch(event.request)) + ); +}); + -- 2.39.2