Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function create(state: any): Promise {
if (typeof state === "string") {
state = JSON.parse(state);
}
state = retrofit_114_serialization(state, Platform.version());
return requireWidget(state.__class).then((WidgetClass: any) => {
const widget = new WidgetClass();
if (state.__id && state.__id.indexOf(widget._idSeed) !== 0 && state.__id.indexOf("_pe") !== 0) {
widget._id = state.__id;
}
return deserializeFromObject(widget, state);
}).catch(function (e) {
console.log("Persist.create: ***exception***");
console.log(e);
});
}
generateTestPage() {
if (this._marshaller) {
const context = this;
const state = Persist.serialize(context, function (widget, publishItem) {
if (publishItem.id === "databomb" || publishItem.id === "ddlUrl") {
return true;
}
return false;
});
const databomb = this._marshaller.createDatabomb();
const page = tpl
.replace("{VERSION}", Platform.version())
.replace("{STATE}", state)
.replace("{DDL}", context._marshaller._json.replace("WUID", "databomb"))
.replace("{DATABOMB}", JSON.stringify(databomb))
;
Utility.downloadString("TEXT", page, "test");
}
}