41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||
|
});
|
||
|
};
|
||
|
import * as yaml from 'yaml';
|
||
|
export function Manifest(manifestPath) {
|
||
|
return __awaiter(this, void 0, void 0, function* () {
|
||
|
try {
|
||
|
const response = yield fetch(manifestPath);
|
||
|
console.log(response);
|
||
|
const data = yield response.text();
|
||
|
console.log(`Parsing: `, data);
|
||
|
const manifest = yaml.parse(data);
|
||
|
return manifest;
|
||
|
}
|
||
|
catch (error) {
|
||
|
alert(`Error occured: ${error.toString()}`);
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
export function CheckManifest(manifest) {
|
||
|
const prevManifestStr = localStorage.getItem('manifest');
|
||
|
if (!prevManifestStr) {
|
||
|
localStorage.setItem('manifest', JSON.stringify(manifest));
|
||
|
return false;
|
||
|
}
|
||
|
const prevManifest = JSON.parse(prevManifestStr);
|
||
|
if (prevManifest.version === manifest.version) {
|
||
|
return true;
|
||
|
}
|
||
|
else {
|
||
|
localStorage.setItem('manifest', manifest);
|
||
|
return false;
|
||
|
}
|
||
|
}
|