| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 'use strict';
- const icon_defaults = require('../icon/defaults.cjs');
- const optionalPropertyDefaults = {
- provider: "",
- aliases: {},
- not_found: {},
- ...icon_defaults.defaultIconDimensions
- };
- function checkOptionalProps(item, defaults) {
- for (const prop in defaults) {
- if (prop in item && typeof item[prop] !== typeof defaults[prop]) {
- return false;
- }
- }
- return true;
- }
- function quicklyValidateIconSet(obj) {
- if (typeof obj !== "object" || obj === null) {
- return null;
- }
- const data = obj;
- if (typeof data.prefix !== "string" || !obj.icons || typeof obj.icons !== "object") {
- return null;
- }
- if (!checkOptionalProps(obj, optionalPropertyDefaults)) {
- return null;
- }
- const icons = data.icons;
- for (const name in icons) {
- const icon = icons[name];
- if (
- // Name cannot be empty
- !name || // Must have body
- typeof icon.body !== "string" || // Check other props
- !checkOptionalProps(
- icon,
- icon_defaults.defaultExtendedIconProps
- )
- ) {
- return null;
- }
- }
- const aliases = data.aliases || /* @__PURE__ */ Object.create(null);
- for (const name in aliases) {
- const icon = aliases[name];
- const parent = icon.parent;
- if (
- // Name cannot be empty
- !name || // Parent must be set and point to existing icon
- typeof parent !== "string" || !icons[parent] && !aliases[parent] || // Check other props
- !checkOptionalProps(
- icon,
- icon_defaults.defaultExtendedIconProps
- )
- ) {
- return null;
- }
- }
- return data;
- }
- exports.quicklyValidateIconSet = quicklyValidateIconSet;
|