getCurrentInstance.mjs 923 B

123456789101112131415161718192021222324252627282930
  1. // Utilities
  2. import { getCurrentInstance as _getCurrentInstance } from 'vue';
  3. import { toKebabCase } from "./helpers.mjs"; // Types
  4. export function getCurrentInstance(name, message) {
  5. const vm = _getCurrentInstance();
  6. if (!vm) {
  7. throw new Error(`[Vuetify] ${name} ${message || 'must be called from inside a setup function'}`);
  8. }
  9. return vm;
  10. }
  11. export function getCurrentInstanceName() {
  12. let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'composables';
  13. const vm = getCurrentInstance(name).type;
  14. return toKebabCase(vm?.aliasName || vm?.name);
  15. }
  16. let _uid = 0;
  17. let _map = new WeakMap();
  18. export function getUid() {
  19. const vm = getCurrentInstance('getUid');
  20. if (_map.has(vm)) return _map.get(vm);else {
  21. const uid = _uid++;
  22. _map.set(vm, uid);
  23. return uid;
  24. }
  25. }
  26. getUid.reset = () => {
  27. _uid = 0;
  28. _map = new WeakMap();
  29. };
  30. //# sourceMappingURL=getCurrentInstance.mjs.map