web-flasher-ng/composables/useManifest.ts
2024-12-07 17:48:13 +01:00

29 lines
No EOL
730 B
TypeScript

import type { FirmwareManifest } from '~/types/manifest';
export const useManifest = () => {
const getManifest = async(
deviceType: string,
customize: boolean,
hasFrontlight: boolean,
displayColors: string
): FirmwareManifest => {
const response = await fetch(`/${deviceType}.json`);
const baseManifest: FirmwareManifest = await response.json();
if (customize) {
// Add NVS partition based on settings
const nvsVariant = `${hasFrontlight ? 'frontlight_' : ''}${displayColors}`;
baseManifest.builds[0].parts.push({
path: `firmware_v3/nvs/${nvsVariant}.bin`,
offset: "0x9000"
});
}
return baseManifest;
};
return {
getManifest
};
};