(url: string)
| 74 | } |
| 75 | |
| 76 | export async function loadRemoteAddOn(url: string): Promise<AddOn> { |
| 77 | const response = await fetch(url) |
| 78 | const jsonContent = await response.json() |
| 79 | const checked = AddOnCompiledSchema.safeParse(jsonContent) |
| 80 | |
| 81 | if (!checked.success) { |
| 82 | throw new Error(`Invalid add-on: ${url}`) |
| 83 | } |
| 84 | |
| 85 | const addOn = { |
| 86 | ...checked.data, |
| 87 | id: url, |
| 88 | } |
| 89 | |
| 90 | return { |
| 91 | ...addOn, |
| 92 | getFiles: () => Promise.resolve(Object.keys(addOn.files)), |
| 93 | getFileContents: (path: string) => Promise.resolve(addOn.files[path]), |
| 94 | getDeletedFiles: () => Promise.resolve(addOn.deletedFiles), |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | function findClosestAddOn( |
| 99 | input: string, |
no test coverage detected