fix(repl): components -> files

pull/8799/head
Puru Vijay 2 years ago
parent 7cbd36d6b2
commit 0b09e1f4d0

@ -11,6 +11,8 @@
const { login } = getContext('app'); const { login } = getContext('app');
export let user; export let user;
/** @type {import('@sveltejs/repl').default} */
export let repl; export let repl;
export let gist; export let gist;
export let name; export let name;
@ -38,7 +40,7 @@
async function fork(intentWasSave) { async function fork(intentWasSave) {
saving = true; saving = true;
const { components } = repl.toJSON(); const { files } = repl.toJSON();
try { try {
const r = await fetch(`/repl/create.json`, { const r = await fetch(`/repl/create.json`, {
@ -49,9 +51,9 @@
}, },
body: JSON.stringify({ body: JSON.stringify({
name, name,
files: components.map((component) => ({ files: files.map((file) => ({
name: `${component.name}.${component.type}`, name: `${file.name}.${file.type}`,
source: component.source source: file.source
})) }))
}) })
}); });
@ -104,7 +106,7 @@
try { try {
// Send all files back to API // Send all files back to API
// ~> Any missing files are considered deleted! // ~> Any missing files are considered deleted!
const { components } = repl.toJSON(); const { files } = repl.toJSON();
const r = await fetch(`/repl/save/${gist.id}.json`, { const r = await fetch(`/repl/save/${gist.id}.json`, {
method: 'PUT', method: 'PUT',
@ -114,9 +116,9 @@
}, },
body: JSON.stringify({ body: JSON.stringify({
name, name,
files: components.map((component) => ({ files: files.map((file) => ({
name: `${component.name}.${component.type}`, name: `${file.name}.${file.type}`,
source: component.source source: file.source
})) }))
}) })
}); });
@ -145,7 +147,7 @@
async function download() { async function download() {
downloading = true; downloading = true;
const { components, imports } = repl.toJSON(); const { files: components, imports } = repl.toJSON();
const files = await (await fetch('/svelte-app.json')).json(); const files = await (await fetch('/svelte-app.json')).json();

Loading…
Cancel
Save