install.mjs 884 B

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