Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const typeInfo: TypeInfo = member.type;
const code = getTypeCode(typeInfo.info);
if (code === SerializationTypeCode.UserDefined) {
template = templates.find(x => x.name === typeInfo.templateName);
if (template == null) {
// Unknown template.
return null;
}
} else if (LIST_TYPES.indexOf(code) !== -1) {
i++;
if (
getTypeCode(typeInfo.subTypes![0].info) ===
SerializationTypeCode.UserDefined
) {
const arrayTypeInfo = typeInfo.subTypes![0];
template = templates.find(x => x.name === arrayTypeInfo.templateName);
if (template == null) {
// Unknown template.
return null;
}
}
} else if (code === SerializationTypeCode.Dictionary) {
i++;
if (
getTypeCode(typeInfo.subTypes![1].info) ===
SerializationTypeCode.UserDefined
) {
const arrayTypeInfo = typeInfo.subTypes![1];
template = templates.find(x => x.name === arrayTypeInfo.templateName);
// any sub-templates.
for (let i = 0; i < subPath.length; i++) {
const part = subPath[i];
const member =
template.fields.find(x => x.name === part) ||
template.properties.find(x => x.name === part);
if (!member) {
break;
}
const typeInfo: TypeInfo = member.type;
const code = getTypeCode(typeInfo.info);
if (code === SerializationTypeCode.UserDefined) {
template = templates.find(x => x.name === typeInfo.templateName);
if (template == null) {
// Unknown template.
return null;
}
} else if (LIST_TYPES.indexOf(code) !== -1) {
i++;
if (
getTypeCode(typeInfo.subTypes![0].info) ===
SerializationTypeCode.UserDefined
) {
const arrayTypeInfo = typeInfo.subTypes![0];
template = templates.find(x => x.name === arrayTypeInfo.templateName);
if (template == null) {
// Unknown template.
if (template == null) {
return null;
}
const member =
template.fields.find(x => x.name === part) ||
template.properties.find(x => x.name === part);
if (!member) {
return null;
}
typeInfo = member.type;
const typeCode = getTypeCode(typeInfo.info);
if (typeCode === SerializationTypeCode.UserDefined) {
template = oniSave.templates.find(
x => x.name === member.type.templateName!
);
} else if (LIST_TYPES.indexOf(typeCode) !== -1) {
i++;
if (i === templatePath.length) {
// Targeting an array but no index yet.
break;
}
if (
getTypeCode(typeInfo.subTypes![0].info) ===
SerializationTypeCode.UserDefined
) {
typeInfo = typeInfo.subTypes![0];
template = oniSave.templates.find(
if (i === templatePath.length) {
// Targeting an index, but no key or value.
// Fake a value for the ui.
typeInfo = {
info: SerializationTypeInfo.Pair,
subTypes: typeInfo.subTypes
};
break;
}
let keyValueIndex = Number(templatePath[i]);
typeInfo = typeInfo.subTypes![keyValueIndex];
if (!typeInfo) {
break;
}
if (getTypeCode(typeInfo.info) === SerializationTypeCode.UserDefined) {
template = oniSave.templates.find(
x => x.name === typeInfo.templateName
);
}
} else {
return null;
}
}
return typeInfo;
}
);
return (props: EditorFieldProps) => (
);
case SerializationTypeCode.String:
return (props: EditorFieldProps) => ;
case SerializationTypeCode.UInt16:
return (props: EditorFieldProps) => (
);
case SerializationTypeCode.UInt32:
return (props: EditorFieldProps) => (
);
case SerializationTypeCode.UInt64:
return () => ;
case SerializationTypeCode.UserDefined:
return (props: EditorFieldProps) => (
[{typeInfo.templateName || "Edit Object"}]
);
case SerializationTypeCode.Vector2:
return Vector2Field;
case SerializationTypeCode.Vector2I:
return Vector2IField;
case SerializationTypeCode.Vector3:
return Vector3Field;
default:
return handleUnknownType(code);
}
}
const template = createSelector(oniSave, typeInfo, (oniSave, typeInfo) => {
if (!oniSave || !typeInfo) {
return null;
}
const typeCode = getTypeCode(typeInfo.info);
if (typeCode !== SerializationTypeCode.UserDefined) {
return null;
}
let template = oniSave.templates.find(x => x.name === typeInfo.templateName);
return template;
});