(options: NativeAssetOptions = {})
| 216 | } |
| 217 | |
| 218 | export function ensureNativeAssetTree(options: NativeAssetOptions = {}): string | null { |
| 219 | const source = options.source ?? getSeaAssetSource(); |
| 220 | if (source === null) return null; |
| 221 | |
| 222 | const manifest = |
| 223 | options.manifest ?? getEmbeddedNativeAssetManifest(source, currentTarget()); |
| 224 | if (manifest === null) return null; |
| 225 | |
| 226 | const cacheRoot = getNativeAssetCacheRoot(manifest, options); |
| 227 | for (const pkg of manifest.packages) { |
| 228 | for (const file of pkg.files) { |
| 229 | const bytes = toBuffer(source.getRawAsset(file.assetKey)); |
| 230 | const actualSha256 = sha256(bytes); |
| 231 | if (actualSha256 !== file.sha256) { |
| 232 | throw new Error( |
| 233 | `Native asset checksum mismatch for ${file.assetKey}: ${actualSha256} !== ${file.sha256}`, |
| 234 | ); |
| 235 | } |
| 236 | ensureFile(join(cacheRoot, file.relativePath), bytes, file.sha256, file.mode); |
| 237 | } |
| 238 | } |
| 239 | ensureEntryFile(cacheRoot); |
| 240 | return cacheRoot; |
| 241 | } |
| 242 | |
| 243 | export function getNativePackageRoot( |
| 244 | packageName: string, |
no test coverage detected