Spaces:
Running
Running
File size: 1,106 Bytes
794cf6c 66ed511 794cf6c dd99b77 794cf6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import { writable } from "svelte/store";
export interface EditorState {
content: string;
language: string;
theme: string;
}
const DEFAULT_CONTENT = `<world canvas="#game-canvas" sky="#87ceeb">
<!-- Ground -->
<static-part pos="0 -0.5 0" shape="box" size="20 1 20" color="#90ee90"></static-part>
<!-- Ball -->
<dynamic-part pos="-2 4 -3" shape="sphere" size="1" color="#ff4500"></dynamic-part>
</world>
<script>
console.log("Game script loaded!");
</script>`;
function createEditorStore() {
const { subscribe, set, update } = writable<EditorState>({
content: DEFAULT_CONTENT,
language: "html",
theme: "vs-dark",
});
return {
subscribe,
setContent: (content: string) => update((state) => ({ ...state, content })),
setLanguage: (language: string) =>
update((state) => ({ ...state, language })),
setTheme: (theme: string) => update((state) => ({ ...state, theme })),
reset: () =>
set({
content: DEFAULT_CONTENT,
language: "html",
theme: "vs-dark",
}),
};
}
export const editorStore = createEditorStore();
|