|
11 | 11 | const { login } = getContext('app'); |
12 | 12 |
|
13 | 13 | export let user; |
| 14 | +
|
| 15 | + /** @type {import('@sveltejs/repl').default} */ |
14 | 16 | export let repl; |
15 | 17 | export let gist; |
16 | 18 | export let name; |
|
38 | 40 | async function fork(intentWasSave) { |
39 | 41 | saving = true; |
40 | 42 |
|
41 | | - const { components } = repl.toJSON(); |
| 43 | + const { files } = repl.toJSON(); |
42 | 44 |
|
43 | 45 | try { |
44 | 46 | const r = await fetch(`/repl/create.json`, { |
|
49 | 51 | }, |
50 | 52 | body: JSON.stringify({ |
51 | 53 | name, |
52 | | - files: components.map((component) => ({ |
53 | | - name: `${component.name}.${component.type}`, |
54 | | - source: component.source |
| 54 | + files: files.map((file) => ({ |
| 55 | + name: `${file.name}.${file.type}`, |
| 56 | + source: file.source |
55 | 57 | })) |
56 | 58 | }) |
57 | 59 | }); |
|
104 | 106 | try { |
105 | 107 | // Send all files back to API |
106 | 108 | // ~> Any missing files are considered deleted! |
107 | | - const { components } = repl.toJSON(); |
| 109 | + const { files } = repl.toJSON(); |
108 | 110 |
|
109 | 111 | const r = await fetch(`/repl/save/${gist.id}.json`, { |
110 | 112 | method: 'PUT', |
|
114 | 116 | }, |
115 | 117 | body: JSON.stringify({ |
116 | 118 | name, |
117 | | - files: components.map((component) => ({ |
118 | | - name: `${component.name}.${component.type}`, |
119 | | - source: component.source |
| 119 | + files: files.map((file) => ({ |
| 120 | + name: `${file.name}.${file.type}`, |
| 121 | + source: file.source |
120 | 122 | })) |
121 | 123 | }) |
122 | 124 | }); |
|
145 | 147 | async function download() { |
146 | 148 | downloading = true; |
147 | 149 |
|
148 | | - const { components, imports } = repl.toJSON(); |
| 150 | + const { files: components, imports } = repl.toJSON(); |
149 | 151 |
|
150 | 152 | const files = await (await fetch('/svelte-app.json')).json(); |
151 | 153 |
|
|
0 commit comments