( source: WebAssetSource | null = getSeaAssetSource(), target = currentTarget(), )
| 119 | } |
| 120 | |
| 121 | export function getEmbeddedWebAssetManifest( |
| 122 | source: WebAssetSource | null = getSeaAssetSource(), |
| 123 | target = currentTarget(), |
| 124 | ): WebAssetManifest | null { |
| 125 | if (source === null) return null; |
| 126 | const key = webAssetManifestKey(target); |
| 127 | if (!source.getAssetKeys().includes(key)) return null; |
| 128 | const raw = source.getRawAsset(key); |
| 129 | const manifest = JSON.parse(toBuffer(raw).toString('utf-8')) as RawWebAssetManifest; |
| 130 | if (manifest.version !== WEB_ASSET_MANIFEST_VERSION) { |
| 131 | throw new Error(`Unsupported web asset manifest version: ${manifest.version}`); |
| 132 | } |
| 133 | if (manifest.target !== target) { |
| 134 | throw new Error(`Web asset manifest target mismatch: ${manifest.target} !== ${target}`); |
| 135 | } |
| 136 | if (manifest.root !== 'dist-web') { |
| 137 | throw new Error(`Unsupported web asset root: ${manifest.root}`); |
| 138 | } |
| 139 | return manifest as WebAssetManifest; |
| 140 | } |
| 141 | |
| 142 | export function getWebAssetCacheRoot( |
| 143 | manifest: WebAssetManifest, |
no test coverage detected