diff --git a/apps/svelte.dev/package.json b/apps/svelte.dev/package.json index 74b90edc89..292812aa5c 100644 --- a/apps/svelte.dev/package.json +++ b/apps/svelte.dev/package.json @@ -16,23 +16,11 @@ "sync-docs": "tsx scripts/sync-docs/index.ts" }, "dependencies": { - "@codemirror/autocomplete": "^6.9.0", - "@codemirror/commands": "^6.2.5", - "@codemirror/lang-css": "^6.2.1", - "@codemirror/lang-html": "^6.4.6", - "@codemirror/lang-javascript": "^6.2.1", - "@codemirror/language": "^6.9.0", - "@codemirror/lint": "^6.4.1", - "@codemirror/search": "^6.5.2", - "@codemirror/state": "^6.2.1", - "@codemirror/view": "^6.17.1", "@jridgewell/sourcemap-codec": "^1.4.15", "@lezer/common": "^1.0.4", "@lezer/highlight": "^1.1.6", "@lezer/javascript": "^1.4.7", "@lezer/lr": "^1.3.10", - "@replit/codemirror-lang-svelte": "^6.0.0", - "@replit/codemirror-vim": "^6.0.14", "@rich_harris/svelte-split-pane": "^1.1.3", "@shikijs/twoslash": "^1.22.0", "@sveltejs/amp": "^1.1.3", @@ -46,10 +34,10 @@ "adm-zip": "^0.5.10", "ansi-to-html": "^0.7.2", "base64-js": "^1.5.1", - "codemirror": "^6.0.1", "cookie": "^0.7.0", "d3-geo": "^3.1.0", "d3-geo-projection": "^4.0.0", + "editor": "workspace:*", "flexsearch": "^0.7.43", "flru": "^1.0.2", "port-authority": "^2.0.1", diff --git a/apps/svelte.dev/src/lib/tutorial/adapters/rollup/index.svelte.ts b/apps/svelte.dev/src/lib/tutorial/adapters/rollup/index.svelte.ts index 3c56d9a145..7daf5dccd5 100644 --- a/apps/svelte.dev/src/lib/tutorial/adapters/rollup/index.svelte.ts +++ b/apps/svelte.dev/src/lib/tutorial/adapters/rollup/index.svelte.ts @@ -1,4 +1,5 @@ -import type { Adapter, FileStub, Stub, Warning } from '$lib/tutorial'; +import type { Adapter, Warning } from '$lib/tutorial'; +import type { File, Item } from 'editor'; import Bundler from '@sveltejs/repl/bundler'; // @ts-ignore package exports don't have types import * as yootils from 'yootils'; @@ -43,7 +44,7 @@ export async function create(): Promise { const result = await bundler.bundle( [...current_stubs.values()] // TODO we can probably remove all the SvelteKit specific stuff from the tutorial content once this settles down - .filter((f): f is FileStub => f.name.startsWith('/src/lib/') && f.type === 'file') + .filter((f): f is File => f.name.startsWith('/src/lib/') && f.type === 'file') .map((f) => ({ name: f.name.slice(9).split('.').slice(0, -1).join('.'), source: f.contents, @@ -85,7 +86,7 @@ export async function create(): Promise { }; } -function stubs_to_map(files: Stub[], map = new Map()) { +function stubs_to_map(files: Item[], map = new Map()) { for (const file of files) { map.set(file.name, file); } diff --git a/apps/svelte.dev/src/lib/tutorial/adapters/webcontainer/index.svelte.ts b/apps/svelte.dev/src/lib/tutorial/adapters/webcontainer/index.svelte.ts index 4c2f3f2755..31f0b712dc 100644 --- a/apps/svelte.dev/src/lib/tutorial/adapters/webcontainer/index.svelte.ts +++ b/apps/svelte.dev/src/lib/tutorial/adapters/webcontainer/index.svelte.ts @@ -6,7 +6,8 @@ import * as yootils from 'yootils'; import { get_depth } from '../../../utils/path.js'; import { escape_html } from '../../../utils/escape.js'; import { ready } from '../common/index.js'; -import type { Adapter, FileStub, Stub, Warning } from '$lib/tutorial'; +import type { Adapter, Warning } from '$lib/tutorial'; +import type { Item, File } from 'editor'; const converter = new AnsiToHtml({ fg: 'var(--sk-text-3)' @@ -27,7 +28,7 @@ export async function create(): Promise { state.progress = { value: 0, text: 'loading files' }; const q = yootils.queue(1); - const q_per_file = new Map>(); + const q_per_file = new Map>(); /** Paths and contents of the currently loaded file stubs */ let current_stubs = stubs_to_map([]); @@ -138,7 +139,7 @@ export async function create(): Promise { return { reset: (stubs) => { return q.add(async () => { - const to_write: Stub[] = []; + const to_write: Item[] = []; const force_delete = []; @@ -151,7 +152,7 @@ export async function create(): Promise { continue; } - const current = current_stubs.get(stub.name) as FileStub; + const current = current_stubs.get(stub.name) as File; if (current?.contents !== stub.contents) { to_write.push(stub); @@ -272,7 +273,7 @@ export async function create(): Promise { }; } -function is_config(file: Stub) { +function is_config(file: Item) { return file.type === 'file' && is_config_path(file.name); } @@ -299,7 +300,7 @@ function wait_for_restart_vite() { }); } -function convert_stubs_to_tree(stubs: Stub[], depth = 1) { +function convert_stubs_to_tree(stubs: Item[], depth = 1) { const tree: FileSystemTree = {}; for (const stub of stubs) { @@ -319,7 +320,7 @@ function convert_stubs_to_tree(stubs: Stub[], depth = 1) { return tree; } -function to_file(file: FileStub) { +function to_file(file: File) { // special case if (file.name === '/src/app.html' || file.name === '/src/error.html') { const contents = file.contents + ''; @@ -336,7 +337,7 @@ function to_file(file: FileStub) { }; } -function stubs_to_map(files: Stub[], map = new Map()) { +function stubs_to_map(files: Item[], map = new Map()) { for (const file of files) { map.set(file.name, file); } diff --git a/apps/svelte.dev/src/lib/tutorial/index.d.ts b/apps/svelte.dev/src/lib/tutorial/index.d.ts index 20b8f8fde2..900356b80b 100644 --- a/apps/svelte.dev/src/lib/tutorial/index.d.ts +++ b/apps/svelte.dev/src/lib/tutorial/index.d.ts @@ -1,25 +1,10 @@ import type { Writable } from 'svelte/store'; - -export interface FileStub { - type: 'file'; - name: string; - basename: string; - contents: string; - text: boolean; -} - -export interface DirectoryStub { - type: 'directory'; - name: string; - basename: string; -} - -export type Stub = FileStub | DirectoryStub; +import type { File, Directory, Item } from 'editor'; export interface Adapter { /** Returns `false` if the reset was in such a way that a reload of the iframe isn't needed */ - reset(files: Array): Promise; - update(file: FileStub): Promise; + reset(files: Array): Promise; + update(file: File): Promise; } export interface Scope { diff --git a/apps/svelte.dev/src/routes/tutorial/[...slug]/+page.svelte b/apps/svelte.dev/src/routes/tutorial/[...slug]/+page.svelte index dc96f3c80c..42cb7c3bf8 100644 --- a/apps/svelte.dev/src/routes/tutorial/[...slug]/+page.svelte +++ b/apps/svelte.dev/src/routes/tutorial/[...slug]/+page.svelte @@ -1,21 +1,21 @@