add /completion.js file to make it easy to use the server from js

This commit is contained in:
Tobias Lütke 2023-07-02 15:56:10 -04:00
parent 8e1b04d319
commit dd1df3f31c
No known key found for this signature in database
GPG key ID: 1FC0DBB14164709A
6 changed files with 793 additions and 694 deletions

View file

@ -4,11 +4,19 @@
# get the directory of this script file
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PUBLIC=$DIR/public
OUTPUT=$DIR/templats.hpp
echo "// Generated file, do not edit" > $OUTPUT
echo "" > $OUTPUT
echo "download js bundle files"
curl https://npm.reversehttp.com/@preact/signals-core,@preact/signals,htm/preact,preact,preact/hooks > $PUBLIC/index.js
echo >> $PUBLIC/index.js # add newline
echo "generate hpp files"
xxd -n index_html -i $PUBLIC/index.html > $DIR/index.html.hpp
xxd -n index_js -i $PUBLIC/index.js > $DIR/index.js.hpp
FILES=$(ls $PUBLIC)
for FILE in $FILES; do
func=$(echo $FILE | tr '.' '_')
echo "generate $FILE.hpp ($func)"
xxd -n $func -i $PUBLIC/$FILE > $DIR/$FILE.hpp
done