@unhead/vue 1.11.15 → 2.0.0-alpha.1

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 (55) hide show
  1. package/README.md +13 -0
  2. package/client.d.ts +1 -0
  3. package/dist/client.cjs +37 -0
  4. package/dist/client.d.cts +11 -0
  5. package/dist/client.d.mts +11 -0
  6. package/dist/client.d.ts +11 -0
  7. package/dist/client.mjs +25 -0
  8. package/dist/components.cjs +9 -18
  9. package/dist/components.mjs +9 -18
  10. package/dist/index.cjs +11 -123
  11. package/dist/index.d.cts +16 -61
  12. package/dist/index.d.mts +16 -61
  13. package/dist/index.d.ts +16 -61
  14. package/dist/index.mjs +9 -117
  15. package/dist/legacy.cjs +168 -0
  16. package/dist/legacy.d.cts +51 -0
  17. package/dist/legacy.d.mts +51 -0
  18. package/dist/legacy.d.ts +51 -0
  19. package/dist/legacy.mjs +154 -0
  20. package/dist/server.cjs +34 -0
  21. package/dist/server.d.cts +11 -0
  22. package/dist/server.d.mts +11 -0
  23. package/dist/server.d.ts +11 -0
  24. package/dist/server.mjs +22 -0
  25. package/dist/shared/vue.3OjaFlxQ.cjs +20 -0
  26. package/dist/shared/vue.B6jdKgLD.mjs +13 -0
  27. package/dist/shared/{vue.fwis0K4Q.d.cts → vue.B8gXlHM7.d.cts} +25 -13
  28. package/dist/shared/{vue.fwis0K4Q.d.mts → vue.B8gXlHM7.d.mts} +25 -13
  29. package/dist/shared/{vue.fwis0K4Q.d.ts → vue.B8gXlHM7.d.ts} +25 -13
  30. package/dist/shared/vue.BwEnMiRq.cjs +91 -0
  31. package/dist/shared/vue.DIPZN3-d.cjs +15 -0
  32. package/dist/shared/vue.DShwsPiO.d.cts +194 -0
  33. package/dist/shared/vue.DShwsPiO.d.mts +194 -0
  34. package/dist/shared/vue.DShwsPiO.d.ts +194 -0
  35. package/dist/shared/vue.DnywREVF.d.cts +5 -0
  36. package/dist/shared/vue.DnywREVF.d.mts +5 -0
  37. package/dist/shared/vue.DnywREVF.d.ts +5 -0
  38. package/dist/shared/vue.O-w7-AFg.mjs +18 -0
  39. package/dist/shared/vue.Sg4YunmP.mjs +85 -0
  40. package/package.json +24 -22
  41. package/server.d.ts +1 -0
  42. package/dist/polyfill.cjs +0 -30
  43. package/dist/polyfill.d.cts +0 -40
  44. package/dist/polyfill.d.mts +0 -40
  45. package/dist/polyfill.d.ts +0 -40
  46. package/dist/polyfill.mjs +0 -28
  47. package/dist/shared/vue.-sixQ7xP.mjs +0 -37
  48. package/dist/shared/vue.BmMjB48i.cjs +0 -39
  49. package/dist/shared/vue.DWlmwWrc.cjs +0 -94
  50. package/dist/shared/vue.ziyDaVMR.mjs +0 -86
  51. package/dist/vue2.cjs +0 -46
  52. package/dist/vue2.d.cts +0 -5
  53. package/dist/vue2.d.mts +0 -5
  54. package/dist/vue2.d.ts +0 -5
  55. package/dist/vue2.mjs +0 -44
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # `@unhead/vue`
2
+
3
+ Visit the [documentation site](https://unhead.unjs.io/) for guides and API references.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i @unhead/vue
9
+ ```
10
+
11
+ ## License
12
+
13
+ MIT License © 2022-PRESENT [Harlan Wilton](https://github.com/harlan-zw)
package/client.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/client'
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const client = require('unhead/client');
4
+ const vue = require('vue');
5
+ const useHead = require('./shared/vue.BwEnMiRq.cjs');
6
+ const VueReactivityPlugin = require('./shared/vue.DIPZN3-d.cjs');
7
+ const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
8
+ require('unhead');
9
+ require('@unhead/shared');
10
+
11
+ function createHead(options = {}) {
12
+ const head = client.createHead({
13
+ domOptions: {
14
+ delayFn: (fn) => vue.nextTick(() => setTimeout(() => fn(), 0))
15
+ },
16
+ ...options,
17
+ plugins: [
18
+ ...options.plugins || [],
19
+ VueReactivityPlugin.VueReactivityPlugin
20
+ ]
21
+ });
22
+ head.install = useHead.vueInstall(head);
23
+ return head;
24
+ }
25
+
26
+ exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
27
+ exports.createHead = createHead;
28
+ Object.prototype.hasOwnProperty.call(client, '__proto__') &&
29
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
30
+ Object.defineProperty(exports, '__proto__', {
31
+ enumerable: true,
32
+ value: client['__proto__']
33
+ });
34
+
35
+ Object.keys(client).forEach(function (k) {
36
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = client[k];
37
+ });
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.cjs';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
4
+ export * from 'unhead/client';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.mjs';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
+ export * from 'unhead/client';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,11 @@
1
+ import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
+ import { d as distExports } from './shared/vue.DShwsPiO.js';
3
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
+ export * from 'unhead/client';
5
+ import '@unhead/shared';
6
+ import 'unhead';
7
+ import 'vue';
8
+
9
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
10
+
11
+ export { createHead };
@@ -0,0 +1,25 @@
1
+ import { createHead as createHead$1 } from 'unhead/client';
2
+ export * from 'unhead/client';
3
+ import { nextTick } from 'vue';
4
+ import { v as vueInstall } from './shared/vue.Sg4YunmP.mjs';
5
+ import { V as VueReactivityPlugin } from './shared/vue.B6jdKgLD.mjs';
6
+ export { V as VueHeadMixin } from './shared/vue.O-w7-AFg.mjs';
7
+ import 'unhead';
8
+ import '@unhead/shared';
9
+
10
+ function createHead(options = {}) {
11
+ const head = createHead$1({
12
+ domOptions: {
13
+ delayFn: (fn) => nextTick(() => setTimeout(() => fn(), 0))
14
+ },
15
+ ...options,
16
+ plugins: [
17
+ ...options.plugins || [],
18
+ VueReactivityPlugin
19
+ ]
20
+ });
21
+ head.install = vueInstall(head);
22
+ return head;
23
+ }
24
+
25
+ export { createHead };
@@ -1,25 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  const vue = require('vue');
4
- const injectHead = require('./shared/vue.DWlmwWrc.cjs');
4
+ const useHead = require('./shared/vue.BwEnMiRq.cjs');
5
5
  require('unhead');
6
- require('@unhead/shared');
7
6
 
8
7
  function addVNodeToHeadObj(node, obj) {
9
- const nodeType = !injectHead.Vue3 ? node.tag : node.type;
8
+ const nodeType = node.type;
10
9
  const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
11
10
  if (typeof type !== "string" || !(type in obj))
12
11
  return;
13
- const nodeData = !injectHead.Vue3 ? node.data : node;
14
- const props = (!injectHead.Vue3 ? nodeData.attrs : node.props) || {};
15
- if (!injectHead.Vue3) {
16
- if (nodeData.staticClass)
17
- props.class = nodeData.staticClass;
18
- if (nodeData.staticStyle)
19
- props.style = Object.entries(nodeData.staticStyle).map(([key, value]) => `${key}:${value}`).join(";");
20
- }
12
+ const props = node.props || {};
21
13
  if (node.children) {
22
- const childrenAttr = !injectHead.Vue3 ? "text" : "children";
14
+ const childrenAttr = "children";
23
15
  props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
24
16
  }
25
17
  if (Array.isArray(obj[type]))
@@ -31,10 +23,10 @@ function addVNodeToHeadObj(node, obj) {
31
23
  }
32
24
  function vnodesToHeadObj(nodes) {
33
25
  const obj = {
34
- title: void 0,
35
- htmlAttrs: void 0,
36
- bodyAttrs: void 0,
37
- base: void 0,
26
+ title: undefined,
27
+ htmlAttrs: undefined,
28
+ bodyAttrs: undefined,
29
+ base: undefined,
38
30
  meta: [],
39
31
  link: [],
40
32
  style: [],
@@ -54,9 +46,8 @@ function vnodesToHeadObj(nodes) {
54
46
  const Head = /* @__PURE__ */ vue.defineComponent({
55
47
  name: "Head",
56
48
  setup(_, { slots }) {
57
- const head = injectHead.injectHead();
58
49
  const obj = vue.ref({});
59
- const entry = head.push(obj);
50
+ const entry = useHead.useHead(obj);
60
51
  vue.onBeforeUnmount(() => {
61
52
  entry.dispose();
62
53
  });
@@ -1,23 +1,15 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { i as injectHead, V as Vue3 } from './shared/vue.ziyDaVMR.mjs';
2
+ import { u as useHead } from './shared/vue.Sg4YunmP.mjs';
3
3
  import 'unhead';
4
- import '@unhead/shared';
5
4
 
6
5
  function addVNodeToHeadObj(node, obj) {
7
- const nodeType = !Vue3 ? node.tag : node.type;
6
+ const nodeType = node.type;
8
7
  const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
9
8
  if (typeof type !== "string" || !(type in obj))
10
9
  return;
11
- const nodeData = !Vue3 ? node.data : node;
12
- const props = (!Vue3 ? nodeData.attrs : node.props) || {};
13
- if (!Vue3) {
14
- if (nodeData.staticClass)
15
- props.class = nodeData.staticClass;
16
- if (nodeData.staticStyle)
17
- props.style = Object.entries(nodeData.staticStyle).map(([key, value]) => `${key}:${value}`).join(";");
18
- }
10
+ const props = node.props || {};
19
11
  if (node.children) {
20
- const childrenAttr = !Vue3 ? "text" : "children";
12
+ const childrenAttr = "children";
21
13
  props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
22
14
  }
23
15
  if (Array.isArray(obj[type]))
@@ -29,10 +21,10 @@ function addVNodeToHeadObj(node, obj) {
29
21
  }
30
22
  function vnodesToHeadObj(nodes) {
31
23
  const obj = {
32
- title: void 0,
33
- htmlAttrs: void 0,
34
- bodyAttrs: void 0,
35
- base: void 0,
24
+ title: undefined,
25
+ htmlAttrs: undefined,
26
+ bodyAttrs: undefined,
27
+ base: undefined,
36
28
  meta: [],
37
29
  link: [],
38
30
  style: [],
@@ -52,9 +44,8 @@ function vnodesToHeadObj(nodes) {
52
44
  const Head = /* @__PURE__ */ defineComponent({
53
45
  name: "Head",
54
46
  setup(_, { slots }) {
55
- const head = injectHead();
56
47
  const obj = ref({});
57
- const entry = head.push(obj);
48
+ const entry = useHead(obj);
58
49
  onBeforeUnmount(() => {
59
50
  entry.dispose();
60
51
  });
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const unhead = require('unhead');
4
- const injectHead = require('./shared/vue.DWlmwWrc.cjs');
5
3
  const shared = require('@unhead/shared');
6
- const useHead = require('./shared/vue.BmMjB48i.cjs');
7
- const vue = require('vue');
4
+ const unhead = require('unhead');
5
+ const useHead = require('./shared/vue.BwEnMiRq.cjs');
6
+ const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
7
+ require('vue');
8
8
 
9
9
  const coreComposableNames = [
10
10
  "injectHead"
@@ -17,71 +17,6 @@ function useHeadSafe(input, options = {}) {
17
17
  return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
18
18
  }
19
19
 
20
- function registerVueScopeHandlers(script, scope) {
21
- if (!scope) {
22
- return;
23
- }
24
- const _registerCb = (key, cb) => {
25
- if (!script._cbs[key]) {
26
- cb(script.instance);
27
- return () => {
28
- };
29
- }
30
- let i = script._cbs[key].push(cb);
31
- const destroy = () => {
32
- if (i) {
33
- script._cbs[key]?.splice(i - 1, 1);
34
- i = null;
35
- }
36
- };
37
- vue.onScopeDispose(destroy);
38
- return destroy;
39
- };
40
- script.onLoaded = (cb) => _registerCb("loaded", cb);
41
- script.onError = (cb) => _registerCb("error", cb);
42
- vue.onScopeDispose(() => {
43
- script._triggerAbortController?.abort();
44
- });
45
- }
46
- function useScript(_input, _options) {
47
- const input = typeof _input === "string" ? { src: _input } : _input;
48
- const options = _options || {};
49
- const head = options?.head || injectHead.injectHead();
50
- options.head = head;
51
- const scope = vue.getCurrentInstance();
52
- options.eventContext = scope;
53
- if (scope && typeof options.trigger === "undefined") {
54
- options.trigger = vue.onMounted;
55
- } else if (vue.isRef(options.trigger)) {
56
- const refTrigger = options.trigger;
57
- let off;
58
- options.trigger = new Promise((resolve) => {
59
- off = vue.watch(refTrigger, (val) => {
60
- if (val) {
61
- resolve(true);
62
- }
63
- }, {
64
- immediate: true
65
- });
66
- vue.onScopeDispose(() => resolve(false), true);
67
- }).then((val) => {
68
- off?.();
69
- return val;
70
- });
71
- }
72
- head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
73
- s._statusRef.value = s.status;
74
- });
75
- const script = unhead.useScript(input, options);
76
- script._statusRef = script._statusRef || vue.ref(script.status);
77
- registerVueScopeHandlers(script, scope);
78
- return new Proxy(script, {
79
- get(_, key, a) {
80
- return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
81
- }
82
- });
83
- }
84
-
85
20
  function useSeoMeta(input, options) {
86
21
  const { title, titleTemplate, ...meta } = input;
87
22
  return useHead.useHead({
@@ -104,10 +39,7 @@ function useSeoMeta(input, options) {
104
39
  }
105
40
 
106
41
  function useServerHead(input, options = {}) {
107
- const head = options.head || injectHead.injectHead();
108
- delete options.head;
109
- if (head)
110
- return head.push(input, { ...options, mode: "server" });
42
+ return useHead.useHead(input, { ...options, mode: "server" });
111
43
  }
112
44
 
113
45
  function useServerHeadSafe(input, options = {}) {
@@ -118,61 +50,17 @@ function useServerSeoMeta(input, options) {
118
50
  return useSeoMeta(input, { ...options, mode: "server" });
119
51
  }
120
52
 
121
- const Vue2ProvideUnheadPlugin = (_Vue, head) => {
122
- _Vue.mixin({
123
- beforeCreate() {
124
- const options = this.$options;
125
- const origProvide = options.provide;
126
- options.provide = function() {
127
- let origProvideResult;
128
- if (typeof origProvide === "function")
129
- origProvideResult = origProvide.call(this);
130
- else
131
- origProvideResult = origProvide || {};
132
- return {
133
- ...origProvideResult,
134
- [injectHead.headSymbol]: head
135
- };
136
- };
137
- }
138
- });
139
- };
140
-
141
- const VueHeadMixin = {
142
- created() {
143
- let source = false;
144
- if (injectHead.Vue3) {
145
- const instance = vue.getCurrentInstance();
146
- if (!instance)
147
- return;
148
- const options = instance.type;
149
- if (!options || !("head" in options))
150
- return;
151
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
152
- } else {
153
- const head = this.$options.head;
154
- if (head) {
155
- source = typeof head === "function" ? () => head.call(this) : head;
156
- }
157
- }
158
- source && useHead.useHead(source);
159
- }
160
- };
53
+ const CapoPlugin = () => shared.defineHeadPlugin({});
161
54
 
162
- exports.CapoPlugin = unhead.CapoPlugin;
163
- exports.HashHydrationPlugin = unhead.HashHydrationPlugin;
164
55
  exports.createHeadCore = unhead.createHeadCore;
165
- exports.createHead = injectHead.createHead;
166
- exports.createServerHead = injectHead.createServerHead;
167
- exports.injectHead = injectHead.injectHead;
168
- exports.resolveUnrefHeadInput = injectHead.resolveUnrefHeadInput;
169
- exports.setHeadInjectionHandler = injectHead.setHeadInjectionHandler;
56
+ exports.unheadCtx = unhead.unheadCtx;
57
+ exports.injectHead = useHead.injectHead;
58
+ exports.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
170
59
  exports.useHead = useHead.useHead;
171
- exports.Vue2ProvideUnheadPlugin = Vue2ProvideUnheadPlugin;
172
- exports.VueHeadMixin = VueHeadMixin;
60
+ exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
61
+ exports.CapoPlugin = CapoPlugin;
173
62
  exports.unheadVueComposablesImports = unheadVueComposablesImports;
174
63
  exports.useHeadSafe = useHeadSafe;
175
- exports.useScript = useScript;
176
64
  exports.useSeoMeta = useSeoMeta;
177
65
  exports.useServerHead = useServerHead;
178
66
  exports.useServerHeadSafe = useServerHeadSafe;
package/dist/index.d.cts CHANGED
@@ -1,78 +1,33 @@
1
- export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
1
  import * as _unhead_schema from '@unhead/schema';
3
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, UseScriptOptions as UseScriptOptions$1, AsAsyncFunctionValues, UseFunctionType } from '@unhead/schema';
2
+ import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
4
3
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
- import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as MaybeComputedRefEntriesOnly, d as UseSeoMetaInput } from './shared/vue.fwis0K4Q.cjs';
6
- export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrFalsy, m as MaybeComputedRefOrPromise, k as MaybeReadonlyRef, g as Meta, N as Noscript, h as Script, S as Style, T as Title, e as TitleTemplate } from './shared/vue.fwis0K4Q.cjs';
7
- import { Ref, Plugin } from 'vue';
8
-
9
- interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
10
- meta?: MaybeComputedRefEntries<SafeMeta>[];
11
- link?: MaybeComputedRefEntries<SafeLink>[];
12
- noscript?: MaybeComputedRefEntries<SafeNoscript>[];
13
- script?: MaybeComputedRefEntries<SafeScript>[];
14
- htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
15
- bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
16
- }
17
- type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
18
-
19
- declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
- declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
21
-
22
- declare function resolveUnrefHeadInput(ref: any): any;
4
+ export { createHeadCore, unheadCtx } from 'unhead';
5
+ import { U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.cjs';
6
+ export { f as Base, B as BodyAttr, i as BodyAttributes, H as HeadSafe, d as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRef, n as MaybeComputedRefEntries, o as MaybeComputedRefEntriesOnly, l as MaybeComputedRefOrFalsy, m as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, M as Meta, N as Noscript, R as ReactiveHead, g as Script, S as Style, T as Title, e as TitleTemplate, V as VueHeadClient, r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.cjs';
7
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
8
+ import 'vue';
23
9
 
24
10
  declare const unheadVueComposablesImports: {
25
11
  '@unhead/vue': string[];
26
12
  };
27
13
 
28
- declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
29
- declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
14
+ declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
30
15
 
31
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
16
+ declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
32
17
 
33
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
18
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
34
19
 
35
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
36
- status: Ref<UseScriptStatus>;
37
- }
38
- type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
39
- src: string;
40
- });
41
- interface UseScriptOptions<T extends Record<symbol | string, any> = {}, U = {}> extends HeadEntryOptions, Pick<UseScriptOptions$1<T, U>, 'use' | 'stub' | 'eventContext' | 'beforeInit'> {
42
- /**
43
- * The trigger to load the script:
44
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
45
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
46
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
47
- * - `Function` - Register a callback function to load the script, exists only on the client.
48
- * - `server` - Have the script injected on the server.
49
- * - `ref` - Load the script when the ref is true.
50
- */
51
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
52
- }
53
- type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
54
- /**
55
- * @deprecated Use top-level functions instead.
56
- */
57
- $script: Promise<T> & VueScriptInstance<T>;
58
- };
59
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>, U = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T, U>): UseScriptContext<UseFunctionType<UseScriptOptions<T, U>, T>>;
20
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
60
21
 
61
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
22
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
62
23
 
63
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<any>>> | undefined;
24
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
64
25
 
65
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
66
-
67
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
26
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
68
27
 
69
28
  /**
70
- * @deprecated Import { UnheadPlugin } from `@unhead/vue/vue2` and use Vue.mixin(UnheadPlugin(head)) instead.
29
+ * @deprecated TODO remove
71
30
  */
72
- declare const Vue2ProvideUnheadPlugin: Plugin;
73
-
74
- declare const VueHeadMixin: {
75
- created(): void;
76
- };
31
+ declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
77
32
 
78
- export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
33
+ export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.mts CHANGED
@@ -1,78 +1,33 @@
1
- export { CapoPlugin, HashHydrationPlugin, createHeadCore } from 'unhead';
2
1
  import * as _unhead_schema from '@unhead/schema';
3
- import { SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr, MergeHead, CreateHeadOptions, ActiveHeadEntry, ScriptInstance, UseScriptStatus, ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, UseScriptOptions as UseScriptOptions$1, AsAsyncFunctionValues, UseFunctionType } from '@unhead/schema';
2
+ import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
4
3
  export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
5
- import { R as ReactiveHead, M as MaybeComputedRefEntries, a as MaybeComputedRef, V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions, c as MaybeComputedRefEntriesOnly, d as UseSeoMetaInput } from './shared/vue.fwis0K4Q.mjs';
6
- export { f as Base, B as BodyAttr, j as BodyAttributes, H as HtmlAttr, i as HtmlAttributes, L as Link, l as MaybeComputedRefOrFalsy, m as MaybeComputedRefOrPromise, k as MaybeReadonlyRef, g as Meta, N as Noscript, h as Script, S as Style, T as Title, e as TitleTemplate } from './shared/vue.fwis0K4Q.mjs';
7
- import { Ref, Plugin } from 'vue';
8
-
9
- interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
10
- meta?: MaybeComputedRefEntries<SafeMeta>[];
11
- link?: MaybeComputedRefEntries<SafeLink>[];
12
- noscript?: MaybeComputedRefEntries<SafeNoscript>[];
13
- script?: MaybeComputedRefEntries<SafeScript>[];
14
- htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
15
- bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
16
- }
17
- type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
18
-
19
- declare function createServerHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): VueHeadClient<T>;
20
- declare function createHead<T extends MergeHead>(options?: CreateHeadOptions): VueHeadClient<T>;
21
-
22
- declare function resolveUnrefHeadInput(ref: any): any;
4
+ export { createHeadCore, unheadCtx } from 'unhead';
5
+ import { U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.mjs';
6
+ export { f as Base, B as BodyAttr, i as BodyAttributes, H as HeadSafe, d as HtmlAttr, h as HtmlAttributes, L as Link, k as MaybeComputedRef, n as MaybeComputedRefEntries, o as MaybeComputedRefEntriesOnly, l as MaybeComputedRefOrFalsy, m as MaybeComputedRefOrPromise, j as MaybeReadonlyRef, M as Meta, N as Noscript, R as ReactiveHead, g as Script, S as Style, T as Title, e as TitleTemplate, V as VueHeadClient, r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.mjs';
7
+ export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
8
+ import 'vue';
23
9
 
24
10
  declare const unheadVueComposablesImports: {
25
11
  '@unhead/vue': string[];
26
12
  };
27
13
 
28
- declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
29
- declare function injectHead<T extends MergeHead>(): VueHeadClient<T>;
14
+ declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
30
15
 
31
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
16
+ declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
32
17
 
33
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
18
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
34
19
 
35
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
36
- status: Ref<UseScriptStatus>;
37
- }
38
- type UseScriptInput = string | (MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
39
- src: string;
40
- });
41
- interface UseScriptOptions<T extends Record<symbol | string, any> = {}, U = {}> extends HeadEntryOptions, Pick<UseScriptOptions$1<T, U>, 'use' | 'stub' | 'eventContext' | 'beforeInit'> {
42
- /**
43
- * The trigger to load the script:
44
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
45
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
46
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
47
- * - `Function` - Register a callback function to load the script, exists only on the client.
48
- * - `server` - Have the script injected on the server.
49
- * - `ref` - Load the script when the ref is true.
50
- */
51
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
52
- }
53
- type UseScriptContext<T extends Record<symbol | string, any>> = (Promise<T> & VueScriptInstance<T>) & AsAsyncFunctionValues<T> & {
54
- /**
55
- * @deprecated Use top-level functions instead.
56
- */
57
- $script: Promise<T> & VueScriptInstance<T>;
58
- };
59
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>, U = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T, U>): UseScriptContext<UseFunctionType<UseScriptOptions<T, U>, T>>;
20
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
60
21
 
61
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
22
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
62
23
 
63
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): _unhead_schema.ActiveHeadEntry<MaybeComputedRef<ReactiveHead<any>>> | undefined;
24
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
64
25
 
65
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): void | _unhead_schema.ActiveHeadEntry<UseHeadSafeInput>;
66
-
67
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
26
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
68
27
 
69
28
  /**
70
- * @deprecated Import { UnheadPlugin } from `@unhead/vue/vue2` and use Vue.mixin(UnheadPlugin(head)) instead.
29
+ * @deprecated TODO remove
71
30
  */
72
- declare const Vue2ProvideUnheadPlugin: Plugin;
73
-
74
- declare const VueHeadMixin: {
75
- created(): void;
76
- };
31
+ declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
77
32
 
78
- export { type HeadSafe, MaybeComputedRef, MaybeComputedRefEntries, MaybeComputedRefEntriesOnly, ReactiveHead, UseHeadInput, UseHeadOptions, type UseHeadSafeInput, type UseScriptContext, type UseScriptInput, type UseScriptOptions, UseSeoMetaInput, Vue2ProvideUnheadPlugin, VueHeadClient, VueHeadMixin, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, unheadVueComposablesImports, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
33
+ export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };