(
zoneId: string,
fileName: string,
offset?: number
)
| 446 | |
| 447 | // when file is not found, returns {data: null, fileInfo: null} |
| 448 | async function fetchWaveFile( |
| 449 | zoneId: string, |
| 450 | fileName: string, |
| 451 | offset?: number |
| 452 | ): Promise<{ data: Uint8Array; fileInfo: WaveFile }> { |
| 453 | const usp = new URLSearchParams(); |
| 454 | usp.set("zoneid", zoneId); |
| 455 | usp.set("name", fileName); |
| 456 | if (offset != null) { |
| 457 | usp.set("offset", offset.toString()); |
| 458 | } |
| 459 | const resp = await fetch(getWebServerEndpoint() + "/wave/file?" + usp.toString()); |
| 460 | if (!resp.ok) { |
| 461 | if (resp.status === 404) { |
| 462 | return { data: null, fileInfo: null }; |
| 463 | } |
| 464 | throw new Error("error getting wave file: " + resp.statusText); |
| 465 | } |
| 466 | if (resp.status == 204) { |
| 467 | return { data: null, fileInfo: null }; |
| 468 | } |
| 469 | const fileInfo64 = resp.headers.get("X-ZoneFileInfo"); |
| 470 | if (fileInfo64 == null) { |
| 471 | throw new Error(`missing zone file info for ${zoneId}:${fileName}`); |
| 472 | } |
| 473 | const fileInfo = JSON.parse(base64ToString(fileInfo64)); |
| 474 | const data = await resp.arrayBuffer(); |
| 475 | return { data: new Uint8Array(data), fileInfo }; |
| 476 | } |
| 477 | |
| 478 | function setNodeFocus(nodeId: string) { |
| 479 | const layoutModel = getLayoutModelForStaticTab(); |
no test coverage detected