index-C2merokO.js 978 B

12345678910111213141516171819202122232425262728293031323334
  1. import { ref, watchEffect, watch, getCurrentInstance } from "vue";
  2. import { i as injectHead, d as resolveUnrefHeadInput } from "../server.mjs";
  3. import { composableNames } from "@unhead/shared";
  4. function useHead(input, options = {}) {
  5. const head = options.head || injectHead();
  6. if (head) {
  7. if (!head.ssr)
  8. return clientUseHead(head, input, options);
  9. return head.push(input, options);
  10. }
  11. }
  12. function clientUseHead(head, input, options = {}) {
  13. const deactivated = ref(false);
  14. const resolvedInput = ref({});
  15. watchEffect(() => {
  16. resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
  17. });
  18. const entry = head.push(resolvedInput.value, options);
  19. watch(resolvedInput, (e) => {
  20. entry.patch(e);
  21. });
  22. getCurrentInstance();
  23. return entry;
  24. }
  25. const coreComposableNames = [
  26. "injectHead"
  27. ];
  28. ({
  29. "@unhead/vue": [...coreComposableNames, ...composableNames]
  30. });
  31. export {
  32. useHead as u
  33. };
  34. //# sourceMappingURL=index-C2merokO.js.map