@unhead/vue 2.0.0-alpha.2 → 2.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/client.d.mts +4 -6
  2. package/dist/client.d.ts +4 -6
  3. package/dist/client.mjs +9 -12
  4. package/dist/components.mjs +8 -5
  5. package/dist/index.d.mts +18 -22
  6. package/dist/index.d.ts +18 -22
  7. package/dist/index.mjs +9 -47
  8. package/dist/legacy.d.mts +12 -39
  9. package/dist/legacy.d.ts +12 -39
  10. package/dist/legacy.mjs +56 -91
  11. package/dist/plugins.d.mts +1 -0
  12. package/dist/plugins.d.ts +1 -0
  13. package/dist/plugins.mjs +1 -0
  14. package/dist/server.d.mts +4 -6
  15. package/dist/server.d.ts +4 -6
  16. package/dist/server.mjs +7 -9
  17. package/dist/shared/{vue.B8gXlHM7.d.cts → vue.C97gXjQS.d.mts} +39 -50
  18. package/dist/shared/{vue.B8gXlHM7.d.mts → vue.C97gXjQS.d.ts} +39 -50
  19. package/dist/shared/{vue.BqrzivMs.mjs → vue.DBXhY4KI.mjs} +1 -1
  20. package/dist/shared/vue.N9zWjxoK.mjs +7 -0
  21. package/dist/shared/vue.j4SPrdI5.mjs +84 -0
  22. package/dist/types.d.mts +66 -0
  23. package/dist/types.d.ts +66 -0
  24. package/dist/types.mjs +1 -0
  25. package/dist/utils.d.mts +11 -0
  26. package/dist/utils.d.ts +11 -0
  27. package/dist/utils.mjs +10 -0
  28. package/legacy.d.ts +1 -0
  29. package/package.json +41 -15
  30. package/plugins.d.ts +1 -0
  31. package/types.d.ts +1 -0
  32. package/utils.d.ts +1 -0
  33. package/dist/client.cjs +0 -36
  34. package/dist/client.d.cts +0 -11
  35. package/dist/components.cjs +0 -64
  36. package/dist/components.d.cts +0 -5
  37. package/dist/index.cjs +0 -66
  38. package/dist/index.d.cts +0 -33
  39. package/dist/legacy.cjs +0 -163
  40. package/dist/legacy.d.cts +0 -51
  41. package/dist/server.cjs +0 -33
  42. package/dist/server.d.cts +0 -11
  43. package/dist/shared/vue.Adq3bKYb.cjs +0 -89
  44. package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
  45. package/dist/shared/vue.BFi59n5j.cjs +0 -15
  46. package/dist/shared/vue.Bjx6RvLp.d.cts +0 -191
  47. package/dist/shared/vue.Bjx6RvLp.d.mts +0 -191
  48. package/dist/shared/vue.Bjx6RvLp.d.ts +0 -191
  49. package/dist/shared/vue.BmaKl8wu.mjs +0 -13
  50. package/dist/shared/vue.DTOQraae.cjs +0 -20
  51. package/dist/shared/vue.DUgB2y83.mjs +0 -83
  52. package/dist/shared/vue.DnywREVF.d.cts +0 -5
@@ -1,191 +0,0 @@
1
- import require$$0$1 from '@unhead/shared';
2
- import require$$1 from 'unhead';
3
- import require$$0 from 'vue';
4
-
5
- var dist = {};
6
-
7
- var vue_Adq3bKYb = {};
8
-
9
- var hasRequiredVue_Adq3bKYb;
10
-
11
- function requireVue_Adq3bKYb () {
12
- if (hasRequiredVue_Adq3bKYb) return vue_Adq3bKYb;
13
- hasRequiredVue_Adq3bKYb = 1;
14
- const vue = require$$0;
15
- function resolveUnref(r) {
16
- return typeof r === "function" ? r() : vue.unref(r);
17
- }
18
- function resolveUnrefHeadInput(ref) {
19
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
20
- return ref;
21
- const root = resolveUnref(ref);
22
- if (!ref || !root)
23
- return root;
24
- if (Array.isArray(root))
25
- return root.map((r) => resolveUnrefHeadInput(r));
26
- if (typeof root === "object") {
27
- const resolved = {};
28
- for (const k in root) {
29
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
30
- continue;
31
- }
32
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
33
- resolved[k] = vue.unref(root[k]);
34
- continue;
35
- }
36
- resolved[k] = resolveUnrefHeadInput(root[k]);
37
- }
38
- return resolved;
39
- }
40
- return root;
41
- }
42
- const headSymbol = "usehead";
43
- function vueInstall(head) {
44
- const plugin = {
45
- install(app) {
46
- app.config.globalProperties.$unhead = head;
47
- app.config.globalProperties.$head = head;
48
- app.provide(headSymbol, head);
49
- }
50
- };
51
- return plugin.install;
52
- }
53
- function injectHead() {
54
- if (vue.hasInjectionContext()) {
55
- const instance = vue.inject(headSymbol);
56
- if (!instance) {
57
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
58
- }
59
- return instance;
60
- }
61
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
62
- }
63
- function useHead(input, options = {}) {
64
- const head = options.head || injectHead();
65
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
66
- }
67
- function clientUseHead(head, input, options = {}) {
68
- const deactivated = vue.ref(false);
69
- const resolvedInput = vue.ref({});
70
- vue.watchEffect(() => {
71
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
72
- });
73
- const entry = head.push(resolvedInput.value, options);
74
- vue.watch(resolvedInput, (e) => {
75
- entry.patch(e);
76
- });
77
- const vm = vue.getCurrentInstance();
78
- if (vm) {
79
- vue.onBeforeUnmount(() => {
80
- entry.dispose();
81
- });
82
- vue.onDeactivated(() => {
83
- deactivated.value = true;
84
- });
85
- vue.onActivated(() => {
86
- deactivated.value = false;
87
- });
88
- }
89
- return entry;
90
- }
91
- vue_Adq3bKYb.headSymbol = headSymbol;
92
- vue_Adq3bKYb.injectHead = injectHead;
93
- vue_Adq3bKYb.resolveUnrefHeadInput = resolveUnrefHeadInput;
94
- vue_Adq3bKYb.useHead = useHead;
95
- vue_Adq3bKYb.vueInstall = vueInstall;
96
- return vue_Adq3bKYb;
97
- }
98
-
99
- var vue_DTOQraae = {};
100
-
101
- var hasRequiredVue_DTOQraae;
102
-
103
- function requireVue_DTOQraae () {
104
- if (hasRequiredVue_DTOQraae) return vue_DTOQraae;
105
- hasRequiredVue_DTOQraae = 1;
106
- const vue = require$$0;
107
- const useHead = requireVue_Adq3bKYb();
108
- const VueHeadMixin = {
109
- created() {
110
- let source = false;
111
- const instance = vue.getCurrentInstance();
112
- if (!instance)
113
- return;
114
- const options = instance.type;
115
- if (!options || !("head" in options))
116
- return;
117
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
118
- source && useHead.useHead(source);
119
- }
120
- };
121
- vue_DTOQraae.VueHeadMixin = VueHeadMixin;
122
- return vue_DTOQraae;
123
- }
124
-
125
- var hasRequiredDist;
126
-
127
- function requireDist () {
128
- if (hasRequiredDist) return dist;
129
- hasRequiredDist = 1;
130
- const shared = require$$0$1;
131
- const unhead = require$$1;
132
- const useHead = requireVue_Adq3bKYb();
133
- const VueHeadMixin = requireVue_DTOQraae();
134
-
135
- const coreComposableNames = [
136
- "injectHead"
137
- ];
138
- const unheadVueComposablesImports = {
139
- "@unhead/vue": [...coreComposableNames, ...shared.composableNames]
140
- };
141
- function useHeadSafe(input, options = {}) {
142
- return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
143
- }
144
- function useSeoMeta(input, options) {
145
- const { title, titleTemplate, ...meta } = input;
146
- return useHead.useHead({
147
- title,
148
- titleTemplate,
149
- // @ts-expect-error runtime type
150
- _flatMeta: meta
151
- }, {
152
- ...options,
153
- transform(t) {
154
- const meta2 = shared.unpackMeta({ ...t._flatMeta });
155
- delete t._flatMeta;
156
- return {
157
- // @ts-expect-error runtime type
158
- ...t,
159
- meta: meta2
160
- };
161
- }
162
- });
163
- }
164
- function useServerHead(input, options = {}) {
165
- return useHead.useHead(input, { ...options, mode: "server" });
166
- }
167
- function useServerHeadSafe(input, options = {}) {
168
- return useHeadSafe(input, { ...options, mode: "server" });
169
- }
170
- function useServerSeoMeta(input, options) {
171
- return useSeoMeta(input, { ...options, mode: "server" });
172
- }
173
- const CapoPlugin = () => shared.defineHeadPlugin({});
174
- dist.createHeadCore = unhead.createHeadCore;
175
- dist.injectHead = useHead.injectHead;
176
- dist.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
177
- dist.useHead = useHead.useHead;
178
- dist.VueHeadMixin = VueHeadMixin.VueHeadMixin;
179
- dist.CapoPlugin = CapoPlugin;
180
- dist.unheadVueComposablesImports = unheadVueComposablesImports;
181
- dist.useHeadSafe = useHeadSafe;
182
- dist.useSeoMeta = useSeoMeta;
183
- dist.useServerHead = useServerHead;
184
- dist.useServerHeadSafe = useServerHeadSafe;
185
- dist.useServerSeoMeta = useServerSeoMeta;
186
- return dist;
187
- }
188
-
189
- var distExports = requireDist();
190
-
191
- export { distExports as d };
@@ -1,13 +0,0 @@
1
- import { defineHeadPlugin } from '@unhead/shared';
2
- import { r as resolveUnrefHeadInput } from './vue.DUgB2y83.mjs';
3
-
4
- const VueReactivityPlugin = defineHeadPlugin({
5
- hooks: {
6
- "entries:resolve": (ctx) => {
7
- for (const entry of ctx.entries)
8
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
9
- }
10
- }
11
- });
12
-
13
- export { VueReactivityPlugin as V };
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const useHead = require('./vue.Adq3bKYb.cjs');
5
-
6
- const VueHeadMixin = {
7
- created() {
8
- let source = false;
9
- const instance = vue.getCurrentInstance();
10
- if (!instance)
11
- return;
12
- const options = instance.type;
13
- if (!options || !("head" in options))
14
- return;
15
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
16
- source && useHead.useHead(source);
17
- }
18
- };
19
-
20
- exports.VueHeadMixin = VueHeadMixin;
@@ -1,83 +0,0 @@
1
- import { unref, hasInjectionContext, inject, ref, watchEffect, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
2
-
3
- function resolveUnref(r) {
4
- return typeof r === "function" ? r() : unref(r);
5
- }
6
- function resolveUnrefHeadInput(ref) {
7
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
8
- return ref;
9
- const root = resolveUnref(ref);
10
- if (!ref || !root)
11
- return root;
12
- if (Array.isArray(root))
13
- return root.map((r) => resolveUnrefHeadInput(r));
14
- if (typeof root === "object") {
15
- const resolved = {};
16
- for (const k in root) {
17
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
18
- continue;
19
- }
20
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
21
- resolved[k] = unref(root[k]);
22
- continue;
23
- }
24
- resolved[k] = resolveUnrefHeadInput(root[k]);
25
- }
26
- return resolved;
27
- }
28
- return root;
29
- }
30
-
31
- const headSymbol = "usehead";
32
- function vueInstall(head) {
33
- const plugin = {
34
- install(app) {
35
- app.config.globalProperties.$unhead = head;
36
- app.config.globalProperties.$head = head;
37
- app.provide(headSymbol, head);
38
- }
39
- };
40
- return plugin.install;
41
- }
42
-
43
- function injectHead() {
44
- if (hasInjectionContext()) {
45
- const instance = inject(headSymbol);
46
- if (!instance) {
47
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
48
- }
49
- return instance;
50
- }
51
- throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
52
- }
53
-
54
- function useHead(input, options = {}) {
55
- const head = options.head || injectHead();
56
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
57
- }
58
- function clientUseHead(head, input, options = {}) {
59
- const deactivated = ref(false);
60
- const resolvedInput = ref({});
61
- watchEffect(() => {
62
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
63
- });
64
- const entry = head.push(resolvedInput.value, options);
65
- watch(resolvedInput, (e) => {
66
- entry.patch(e);
67
- });
68
- const vm = getCurrentInstance();
69
- if (vm) {
70
- onBeforeUnmount(() => {
71
- entry.dispose();
72
- });
73
- onDeactivated(() => {
74
- deactivated.value = true;
75
- });
76
- onActivated(() => {
77
- deactivated.value = false;
78
- });
79
- }
80
- return entry;
81
- }
82
-
83
- export { headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, useHead as u, vueInstall as v };
@@ -1,5 +0,0 @@
1
- declare const VueHeadMixin: {
2
- created(): void;
3
- };
4
-
5
- export { VueHeadMixin as V };