Urara-Blog/node_modules/.pnpm-store/v3/files/cb/6b1c68cc0839a808cb4b01cb0671e6ab77a498ccfc53df18b96b09aa319d53bbfcdfe06b2bcd1a02dd9d9749734e566b93cd31134197bc97fc2e1f6c158696
2022-08-14 01:14:53 +08:00

48 lines
1.6 KiB
Text

import { iconToSVG } from '../svg/build.mjs';
import { getIconData } from '../icon-set/get-icon.mjs';
import { mergeIconProps } from './utils.mjs';
import createDebugger from 'debug';
import { defaults } from '../customisations/index.mjs';
import '../svg/size.mjs';
import '../icon/index.mjs';
import '../icon/merge.mjs';
const debug = createDebugger("@iconify-loader:icon");
async function searchForIcon(iconSet, collection, ids, options) {
let iconData;
const { customize } = options?.customizations ?? {};
for (const id of ids) {
iconData = getIconData(iconSet, id, true);
if (iconData) {
debug(`${collection}:${id}`);
let defaultCustomizations = { ...defaults };
if (typeof customize === "function")
defaultCustomizations = customize(defaultCustomizations);
const {
attributes: { width, height, ...restAttributes },
body
} = iconToSVG(iconData, defaultCustomizations);
const scale = options?.scale;
return await mergeIconProps(`<svg >${body}</svg>`, collection, id, options, () => {
return { ...restAttributes };
}, (props) => {
if (typeof props.width === "undefined" || props.width === null) {
if (typeof scale === "number") {
props.width = `${scale}em`;
} else {
props.width = width;
}
}
if (typeof props.height === "undefined" || props.height === null) {
if (typeof scale === "number") {
props.height = `${scale}em`;
} else {
props.height = height;
}
}
});
}
}
}
export { searchForIcon };