snipe/web/node_modules/@iconify/utils/lib/icon-set/validate-basic.js
pyr0ball 7a704441a6 feat(snipe): Vue 3 frontend scaffold + Docker web service
- web/: Vue 3 + Vite + UnoCSS + Pinia, dark tactical theme (amber/#0d1117)
- AppNav, ListingCard, SearchView with filters/sort, composables
  (useSnipeMode, useKonamiCode, useMotion), Pinia search store
- Steal shimmer, auction countdown, Snipe Mode easter egg all native in Vue
- docker/web/: nginx + multi-stage Dockerfile (node build → nginx serve)
- compose.yml: api (8510) + web (8509) services
- Dockerfile CMD updated to uvicorn for upcoming FastAPI layer
- Clean build: 0 TS errors, 380 modules
2026-03-25 15:11:35 -07:00

44 lines
No EOL
1.4 KiB
JavaScript

import { defaultExtendedIconProps, defaultIconDimensions } from "../icon/defaults.js";
/**
* Optional properties
*/
const optionalPropertyDefaults = {
provider: "",
aliases: {},
not_found: {},
...defaultIconDimensions
};
/**
* Check props
*/
function checkOptionalProps(item, defaults) {
for (const prop in defaults) if (prop in item && typeof item[prop] !== typeof defaults[prop]) return false;
return true;
}
/**
* Validate icon set, return it as IconifyJSON on success, null on failure
*
* Unlike validateIconSet(), this function is very basic.
* It does not throw exceptions, it does not check metadata, it does not fix stuff.
*/
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 || typeof icon.body !== "string" || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
}
const aliases = data.aliases || Object.create(null);
for (const name in aliases) {
const icon = aliases[name];
const parent = icon.parent;
if (!name || typeof parent !== "string" || !icons[parent] && !aliases[parent] || !checkOptionalProps(icon, defaultExtendedIconProps)) return null;
}
return data;
}
export { quicklyValidateIconSet };