diff --git a/bun.lockb b/bun.lockb index 97762e5..a89b87f 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index faea9a5..c770d44 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite dev", "build": "vite build", + "build:desktop": "VITE_DESKTOP=1 vite build --outDir out-desktop/", "preview": "vite preview", "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", @@ -30,6 +31,7 @@ "svelte-check": "^4.0.0", "tailwindcss": "^4.0.0-beta.9", "typescript": "^5.0.0", - "vite": "^5.4.11" + "vite": "^5.4.11", + "vite-plugin-wasm": "^3.4.1" } } diff --git a/src/lib/CodeEditor.svelte b/src/lib/CodeEditor.svelte index 8e50f54..791e1b3 100644 --- a/src/lib/CodeEditor.svelte +++ b/src/lib/CodeEditor.svelte @@ -5,7 +5,7 @@ import {} from 'sprig/web'; import { constrainedEditor } from 'constrained-editor-plugin'; import { parse } from '@babel/parser'; - import { buildProject } from './build'; + import { buildProject } from './build/esbuild'; let editorContainer: HTMLDivElement; let editor: import('monaco-editor').editor.IStandaloneCodeEditor; diff --git a/src/lib/build/index.ts b/src/lib/build/esbuild.ts similarity index 83% rename from src/lib/build/index.ts rename to src/lib/build/esbuild.ts index 474fa62..b083a69 100644 --- a/src/lib/build/index.ts +++ b/src/lib/build/esbuild.ts @@ -1,13 +1,13 @@ import { transform, initialize } from 'esbuild-wasm'; await initialize({ - wasmURL: (await import('esbuild-wasm/esbuild.wasm')).default + wasmURL: (await import('esbuild-wasm/esbuild.wasm?url')).default }); export async function buildProject(code: string, vanilla: boolean) { let template = ''; if (vanilla) { - template += `function game(api) { + template += `async function game(api) { ${code} } console.log("Made with Sprigsy") @@ -18,6 +18,6 @@ game({ addSprite, addText, afterInput, bitmap, clearInterval, clearText, clearTi } return await transform(template, { - loader: 'ts' + loader: 'ts', }); } diff --git a/src/lib/provider/Provider.ts b/src/lib/provider/Provider.ts new file mode 100644 index 0000000..cd3eb64 --- /dev/null +++ b/src/lib/provider/Provider.ts @@ -0,0 +1,30 @@ +import { buildProject } from "$lib/build/esbuild" + +enum Capability { + BuildToVite, + ProjectDB +} + +export default abstract class Provider { + constructor( + + ) { + + } + + abstract capabilities(): Capability[] + + /** + * Builds HTML project + */ + async buildHTML(input: string): Promise { + throw new TypeError("BuildToVite capability is not available") + } + + /** + * Build JS + */ + async buildJS(input: string): Promise { + return (await buildProject(input, true)).code + } +} \ No newline at end of file diff --git a/src/routes/+layout.ts b/src/routes/+layout.ts index 2223a9d..0a06f03 100644 --- a/src/routes/+layout.ts +++ b/src/routes/+layout.ts @@ -1 +1,2 @@ -export const csr = true; \ No newline at end of file +export const csr = true; +export const prerender = true; \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index bbf8c7d..8a4c5fd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,5 +2,8 @@ import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; export default defineConfig({ - plugins: [sveltekit()] + plugins: [sveltekit()], + build: { + target: ['es2022'] + } });