install.mjs 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { NOOP } from '@vue/shared';
  2. const withInstall = (main, extra) => {
  3. ;
  4. main.install = (app) => {
  5. for (const comp of [main, ...Object.values(extra != null ? extra : {})]) {
  6. app.component(comp.name, comp);
  7. }
  8. };
  9. if (extra) {
  10. for (const [key, comp] of Object.entries(extra)) {
  11. ;
  12. main[key] = comp;
  13. }
  14. }
  15. return main;
  16. };
  17. const withInstallFunction = (fn, name) => {
  18. ;
  19. fn.install = (app) => {
  20. ;
  21. fn._context = app._context;
  22. app.config.globalProperties[name] = fn;
  23. };
  24. return fn;
  25. };
  26. const withInstallDirective = (directive, name) => {
  27. ;
  28. directive.install = (app) => {
  29. app.directive(name, directive);
  30. };
  31. return directive;
  32. };
  33. const withNoopInstall = (component) => {
  34. ;
  35. component.install = NOOP;
  36. return component;
  37. };
  38. export { withInstall, withInstallDirective, withInstallFunction, withNoopInstall };
  39. //# sourceMappingURL=install.mjs.map