web-flasher-ng/composables/useManifest.ts

29 lines
730 B
TypeScript
Raw Normal View History

2024-12-07 16:48:13 +00:00
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
};
};