Skip to content

Commit

Permalink
organize js stuff into folders
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Jan 19, 2024
1 parent 9f7aaf4 commit a248681
Show file tree
Hide file tree
Showing 15 changed files with 950 additions and 183 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
"unpkg.com"
],
"files.readonlyInclude": {
"*/ts/*.js": true
"**/ts/gen/*": true,
"**/dist/*": true,
"**/aici-types.d.ts": true
}
}
6 changes: 6 additions & 0 deletions jsctrl/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
tsc --version > /dev/null 2>&1 || npm install -g typescript
set -e
tsc -p ts
node gen-dts.mjs

26 changes: 26 additions & 0 deletions jsctrl/gen-dts.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as fs from 'fs';

function gen() {
const ts = "./ts/"
const native = fs.readFileSync(ts + '/native.d.ts', 'utf8')
let aici = fs.readFileSync(ts + '/gen/aici.d.ts', 'utf8')
aici = aici.replace(/<reference path=".*/g, "")
aici = aici.replace(/ declare /g, " ")
aici = aici.replace(/^declare /mg, "")
aici = "declare module 'aici' {\n" + aici + "\n}\n"
aici = native + aici
fs.writeFileSync("./samples/aici-types.d.ts", aici)

let jssrc = fs.readFileSync("../pyaici/jssrc.py", 'utf8')
jssrc = jssrc.replace(/(aici_types_d_t = """)[^]*?"""/g, (_, pre) => pre + aici + '"""')

const tsconfig = fs.readFileSync("./samples/tsconfig.json", "utf-8")
jssrc = jssrc.replace(/(tsconfig_json = """)[^]*?"""/g, (_, pre) => pre + tsconfig + '"""')

const hello = fs.readFileSync("./samples/hello.js", "utf-8")
jssrc = jssrc.replace(/(hello_js = """)[^]*?"""/g, (_, pre) => pre + hello + '"""')

fs.writeFileSync("../pyaici/jssrc.py", jssrc)
}

gen()
Loading

0 comments on commit a248681

Please sign in to comment.