| 62 | } |
| 63 | |
| 64 | function createChunkRenderer(chunks: () => Array<ManifestTemplateModule>) { |
| 65 | return (template: string, context: TemplateRenderContext) => { |
| 66 | for (const chunk of chunks()) { |
| 67 | if (chunk.hasManifestTemplate && !chunk.hasManifestTemplate(template)) { |
| 68 | continue |
| 69 | } |
| 70 | |
| 71 | try { |
| 72 | return chunk.renderManifestTemplate(template, context) |
| 73 | } catch (error) { |
| 74 | if (chunk.hasManifestTemplate) { |
| 75 | throw error |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | throw new Error('Template was not loaded by the worker manifest provider') |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | export type WorkerCreateAPI = { |
| 85 | getFrameworks: () => Promise<Array<Framework>> |