chunk.5ITCQEWZ.js 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {
  2. library_default_default
  3. } from "./chunk.LZ6V34JJ.js";
  4. import {
  5. library_system_default
  6. } from "./chunk.73PEGQ4K.js";
  7. // src/components/icon/library.ts
  8. var registry = [library_default_default, library_system_default];
  9. var watchedIcons = [];
  10. function watchIcon(icon) {
  11. watchedIcons.push(icon);
  12. }
  13. function unwatchIcon(icon) {
  14. watchedIcons = watchedIcons.filter((el) => el !== icon);
  15. }
  16. function getIconLibrary(name) {
  17. return registry.filter((lib) => lib.name === name)[0];
  18. }
  19. function registerIconLibrary(name, options) {
  20. unregisterIconLibrary(name);
  21. registry.push({
  22. name,
  23. resolver: options.resolver,
  24. mutator: options.mutator
  25. });
  26. watchedIcons.map((icon) => {
  27. if (icon.library === name) {
  28. icon.redraw();
  29. }
  30. });
  31. }
  32. function unregisterIconLibrary(name) {
  33. registry = registry.filter((lib) => lib.name !== name);
  34. }
  35. export {
  36. watchIcon,
  37. unwatchIcon,
  38. getIconLibrary,
  39. registerIconLibrary,
  40. unregisterIconLibrary
  41. };