diff --git a/.gitignore b/.gitignore index 14b30d0..2aa490a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ bundle .storybook/explorer.js -src/_aqua \ No newline at end of file +src/_aqua diff --git a/compile-aqua.mjs b/compile-aqua.mjs new file mode 100644 index 0000000..f0b6d02 --- /dev/null +++ b/compile-aqua.mjs @@ -0,0 +1,46 @@ +// @ts-check + +import { join } from 'path'; +import { AquaConfig, Aqua, Path } from './node_modules/@fluencelabs/aqua-api/aqua-api.js'; +import { mkdir, writeFile } from 'fs/promises'; + +function getConfig({ + constants = [], + logLevel = 'info', + noRelay = false, + noXor = false, + targetType = 'air', + tracing = false, +}) { + return new AquaConfig( + logLevel, + constants, + noXor, + noRelay, + { + ts: 'typescript', + js: 'javascript', + air: 'air', + }[targetType], + tracing, + ); +} + +function compileFromPath({ filePath, ...commonArgs }) { + const config = getConfig(commonArgs); + const { imports = [] } = commonArgs; + return Aqua.compile(new Path(filePath), imports, config); +} + +const { generatedSources } = await compileFromPath({ + targetType: 'js', + filePath: join('aqua', 'app.aqua'), + imports: ['node_modules'], +}); + +const targetDir = join('src', '_aqua'); + +await mkdir(targetDir, { recursive: true }); + +// @ts-ignore +await writeFile(join(targetDir, 'app.js'), generatedSources[0].jsSource, { encoding: 'utf8' }); diff --git a/index.html b/index.html index df2fe05..2923bcb 100644 --- a/index.html +++ b/index.html @@ -1,35 +1,40 @@ +
+ + + - - - - - - - - - - - -