diff --git a/README.md b/README.md index 3ea75f3..af774db 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Sprigsy editor - # planned for v1 - [ ] ability to play project - [ ] monaco code editor diff --git a/src/app.html b/src/app.html index 77a5ff5..5ea8657 100644 --- a/src/app.html +++ b/src/app.html @@ -3,7 +3,7 @@ - + %sveltekit.head% diff --git a/src/lib/Editor.svelte b/src/lib/CodeEditor.svelte similarity index 72% rename from src/lib/Editor.svelte rename to src/lib/CodeEditor.svelte index a7fcdfc..993fbff 100644 --- a/src/lib/Editor.svelte +++ b/src/lib/CodeEditor.svelte @@ -32,7 +32,6 @@ } }; - // Function to add global types async function addGlobalTypes() { const sprigTypeDef = (await import('./editorcontext/sprig.d.ts?raw')).default; monaco.languages.typescript.typescriptDefaults.addExtraLib( @@ -42,7 +41,7 @@ const globalTypeDef = (await import('./editorcontext/global.d.ts?raw')).default; monaco.languages.typescript.typescriptDefaults.addExtraLib( globalTypeDef, - 'context/global.d.ts' + 'global.d.ts' ); // IMPLEMENT ONCE v2 IS DONE! @@ -94,10 +93,10 @@ }); }); - // Function to set up the editor function setupEditor() { editor = monaco.editor.create(editorContainer, { - value: `function game(api: sprig.FullSprigAPI): void { + value: +`function game(api: sprig.FullSprigAPI): void { ${code} }`, language: 'typescript', @@ -107,57 +106,6 @@ }); const model = editor.getModel()!; - // Mark function declaration and closing brace as read-only - // editor.createDecorationsCollection( - // [ - // { - // range: new monaco.Range(1, 1, 1, 28), - // options: { - // className: 'read-only', - // isWholeLine: true - // } - // }, - // { - // range: new monaco.Range( - // model.getLineCount(), - // 1, - // model.getLineCount(), - // model.getLineMaxColumn(model.getLineCount()) - // ), - // options: { - // className: 'read-only', - // isWholeLine: true - // } - // } - // ] - // ); - - // Disable editing in read-only regions - // editor.onDidChangeModelContent((event) => { - // event.changes.forEach((change) => { - // const { range } = change; - - // if ( - // (range.startLineNumber === 1 && range.endLineNumber === 1) || - // (range.startLineNumber === model.getLineCount() && - // range.endLineNumber === model.getLineCount()) - // ) { - // editor.executeEdits('revert-read-only', [ - // { - // range: new monaco.Range( - // range.startLineNumber, - // range.startColumn, - // range.endLineNumber, - // range.endColumn - // ), - // text: '', - // forceMoveMarkers: true - // } - // ]); - // } - // }); - // }); - const constrainedInstance = constrainedEditor(monaco); constrainedInstance.initializeIn(editor); constrainedInstance.addRestrictionsTo(model, [ diff --git a/src/lib/editorcontext/global.d.ts b/src/lib/editorcontext/global.d.ts index d030abc..a7f242b 100644 --- a/src/lib/editorcontext/global.d.ts +++ b/src/lib/editorcontext/global.d.ts @@ -1,10 +1,11 @@ -import "./sprig" +// for some reason this doesn't work, I can't figure out why declare global { - var setTimeout: sprig.FullSprigAPI['setTimeout']; - var setInterval: sprig.FullSprigAPI['setInterval']; - var clearTimeout: sprig.FullSprigAPI['clearTimeout']; - var clearInterval: sprig.FullSprigAPI['clearInterval']; - - var tones: typeof sprig['tones'] + declare function tune(template: TemplateStringsArray, ...params: string[]): string + interface Window { + setTimeout: import('./sprig').sprig.FullSprigAPI['setTimeout']; + setInterval: sprig.FullSprigAPI['setInterval']; + clearTimeout: sprig.FullSprigAPI['clearTimeout']; + clearInterval: sprig.FullSprigAPI['clearInterval']; + } } \ No newline at end of file diff --git a/src/lib/editorcontext/sprig.d.ts b/src/lib/editorcontext/sprig.d.ts index aca9932..49772f3 100644 --- a/src/lib/editorcontext/sprig.d.ts +++ b/src/lib/editorcontext/sprig.d.ts @@ -1,3 +1,7 @@ +/** + * normal sprig api + * this is provided because your project type is + */ declare namespace sprig { export declare const VALID_INPUTS: readonly ["w", "s", "a", "d", "i", "j", "k", "l"]; export type InputKey = typeof VALID_INPUTS[number]; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 67a02a9..025a4a4 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,8 +1,8 @@
- +