@unhead/vue 2.0.0-alpha.0 → 2.0.0-alpha.10

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 (42) hide show
  1. package/README.md +13 -0
  2. package/dist/client.d.mts +4 -7
  3. package/dist/client.d.ts +4 -7
  4. package/dist/client.mjs +8 -10
  5. package/dist/components.mjs +3 -2
  6. package/dist/index.d.mts +8 -18
  7. package/dist/index.d.ts +8 -18
  8. package/dist/index.mjs +7 -49
  9. package/dist/legacy.d.mts +25 -23
  10. package/dist/legacy.d.ts +25 -23
  11. package/dist/legacy.mjs +86 -35
  12. package/dist/server.d.mts +4 -7
  13. package/dist/server.d.ts +4 -7
  14. package/dist/server.mjs +6 -10
  15. package/dist/shared/vue.0vTsLwbU.mjs +87 -0
  16. package/dist/shared/{vue.O-w7-AFg.mjs → vue.BOii_fac.mjs} +1 -1
  17. package/dist/{shared/vue.B8gXlHM7.d.cts → types.d.mts} +32 -39
  18. package/dist/{shared/vue.B8gXlHM7.d.mts → types.d.ts} +32 -39
  19. package/dist/types.mjs +1 -0
  20. package/legacy.d.ts +1 -0
  21. package/package.json +30 -15
  22. package/types.d.ts +1 -0
  23. package/dist/client.cjs +0 -37
  24. package/dist/client.d.cts +0 -11
  25. package/dist/components.cjs +0 -65
  26. package/dist/components.d.cts +0 -5
  27. package/dist/index.cjs +0 -67
  28. package/dist/index.d.cts +0 -33
  29. package/dist/legacy.cjs +0 -168
  30. package/dist/legacy.d.cts +0 -51
  31. package/dist/server.cjs +0 -34
  32. package/dist/server.d.cts +0 -11
  33. package/dist/shared/vue.3OjaFlxQ.cjs +0 -20
  34. package/dist/shared/vue.B6jdKgLD.mjs +0 -13
  35. package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
  36. package/dist/shared/vue.BwEnMiRq.cjs +0 -91
  37. package/dist/shared/vue.DIPZN3-d.cjs +0 -15
  38. package/dist/shared/vue.DShwsPiO.d.cts +0 -194
  39. package/dist/shared/vue.DShwsPiO.d.mts +0 -194
  40. package/dist/shared/vue.DShwsPiO.d.ts +0 -194
  41. package/dist/shared/vue.DnywREVF.d.cts +0 -5
  42. package/dist/shared/vue.Sg4YunmP.mjs +0 -85
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/dist/client.d.mts CHANGED
@@ -1,11 +1,8 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.DShwsPiO.mjs';
1
+ import { VueHeadClient } from '@unhead/vue';
2
+ import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
3
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';
4
+ export { renderDOMHead } from 'unhead/client';
8
5
 
9
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
6
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
10
7
 
11
8
  export { createHead };
package/dist/client.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.DShwsPiO.js';
1
+ import { VueHeadClient } from '@unhead/vue';
2
+ import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
3
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';
4
+ export { renderDOMHead } from 'unhead/client';
8
5
 
9
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
6
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
10
7
 
11
8
  export { createHead };
package/dist/client.mjs CHANGED
@@ -1,21 +1,19 @@
1
- import { createHead as createHead$1 } from 'unhead/client';
2
- export * from 'unhead/client';
1
+ import { createHead as createHead$1, createDebouncedFn, renderDOMHead } from 'unhead/client';
2
+ export { renderDOMHead } from 'unhead/client';
3
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';
4
+ import { v as vueInstall } from './shared/vue.0vTsLwbU.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.BOii_fac.mjs';
6
+ import 'unhead/plugins';
7
+ import 'unhead/utils';
9
8
 
10
9
  function createHead(options = {}) {
11
10
  const head = createHead$1({
12
11
  domOptions: {
13
- delayFn: (fn) => nextTick(() => setTimeout(() => fn(), 0))
12
+ render: createDebouncedFn(() => renderDOMHead(head), nextTick)
14
13
  },
15
14
  ...options,
16
15
  plugins: [
17
- ...options.plugins || [],
18
- VueReactivityPlugin
16
+ ...options.plugins || []
19
17
  ]
20
18
  });
21
19
  head.install = vueInstall(head);
@@ -1,6 +1,7 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { u as useHead } from './shared/vue.Sg4YunmP.mjs';
3
- import 'unhead';
2
+ import { u as useHead } from './shared/vue.0vTsLwbU.mjs';
3
+ import 'unhead/plugins';
4
+ import 'unhead/utils';
4
5
 
5
6
  function addVNodeToHeadObj(node, obj) {
6
7
  const nodeType = node.type;
package/dist/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
3
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
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';
1
+ export { createHeadCore } from 'unhead';
2
+ import { MergeHead, ActiveHeadEntry } from 'unhead/types';
3
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
4
+ import { VueHeadClient, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from './types.mjs';
5
+ export { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate } from './types.mjs';
7
6
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
8
7
  import 'vue';
9
8
 
@@ -11,23 +10,14 @@ declare const unheadVueComposablesImports: {
11
10
  '@unhead/vue': string[];
12
11
  };
13
12
 
14
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
15
-
13
+ declare function injectHead(): VueHeadClient<MergeHead>;
16
14
  declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
17
-
18
15
  declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
19
-
20
16
  declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
-
22
17
  declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
-
24
18
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
25
-
26
19
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
27
20
 
28
- /**
29
- * @deprecated TODO remove
30
- */
31
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
21
+ declare const headSymbol = "usehead";
32
22
 
33
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
23
+ export { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
3
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
4
- export { createHeadCore, unheadCtx } from 'unhead';
5
- import { U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.js';
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.js';
1
+ export { createHeadCore } from 'unhead';
2
+ import { MergeHead, ActiveHeadEntry } from 'unhead/types';
3
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from 'unhead/types';
4
+ import { VueHeadClient, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from './types.js';
5
+ export { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate } from './types.js';
7
6
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
8
7
  import 'vue';
9
8
 
@@ -11,23 +10,14 @@ declare const unheadVueComposablesImports: {
11
10
  '@unhead/vue': string[];
12
11
  };
13
12
 
14
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
15
-
13
+ declare function injectHead(): VueHeadClient<MergeHead>;
16
14
  declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
17
-
18
15
  declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
19
-
20
16
  declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
-
22
17
  declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
-
24
18
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
25
-
26
19
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
27
20
 
28
- /**
29
- * @deprecated TODO remove
30
- */
31
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
21
+ declare const headSymbol = "usehead";
32
22
 
33
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
23
+ export { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,54 +1,12 @@
1
- import { composableNames, whitelistSafeInput, unpackMeta, defineHeadPlugin } from '@unhead/shared';
2
- export { createHeadCore, unheadCtx } from 'unhead';
3
- import { u as useHead } from './shared/vue.Sg4YunmP.mjs';
4
- export { i as injectHead, r as resolveUnrefHeadInput } from './shared/vue.Sg4YunmP.mjs';
5
- export { V as VueHeadMixin } from './shared/vue.O-w7-AFg.mjs';
1
+ export { createHeadCore } from 'unhead';
2
+ export { h as headSymbol, i as injectHead, u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/vue.0vTsLwbU.mjs';
3
+ export { V as VueHeadMixin } from './shared/vue.BOii_fac.mjs';
4
+ import 'unhead/plugins';
5
+ import 'unhead/utils';
6
6
  import 'vue';
7
7
 
8
- const coreComposableNames = [
9
- "injectHead"
10
- ];
11
8
  const unheadVueComposablesImports = {
12
- "@unhead/vue": [...coreComposableNames, ...composableNames]
9
+ "@unhead/vue": ["injectHead", "useHead", "useSeoMeta", "useHeadSafe", "useServerHead", "useServerSeoMeta", "useServerHeadSafe"]
13
10
  };
14
11
 
15
- function useHeadSafe(input, options = {}) {
16
- return useHead(input, { ...options, transform: whitelistSafeInput });
17
- }
18
-
19
- function useSeoMeta(input, options) {
20
- const { title, titleTemplate, ...meta } = input;
21
- return useHead({
22
- title,
23
- titleTemplate,
24
- // @ts-expect-error runtime type
25
- _flatMeta: meta
26
- }, {
27
- ...options,
28
- transform(t) {
29
- const meta2 = unpackMeta({ ...t._flatMeta });
30
- delete t._flatMeta;
31
- return {
32
- // @ts-expect-error runtime type
33
- ...t,
34
- meta: meta2
35
- };
36
- }
37
- });
38
- }
39
-
40
- function useServerHead(input, options = {}) {
41
- return useHead(input, { ...options, mode: "server" });
42
- }
43
-
44
- function useServerHeadSafe(input, options = {}) {
45
- return useHeadSafe(input, { ...options, mode: "server" });
46
- }
47
-
48
- function useServerSeoMeta(input, options) {
49
- return useSeoMeta(input, { ...options, mode: "server" });
50
- }
51
-
52
- const CapoPlugin = () => defineHeadPlugin({});
53
-
54
- export { CapoPlugin, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
12
+ export { unheadVueComposablesImports };
package/dist/legacy.d.mts CHANGED
@@ -1,26 +1,21 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
3
- import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.mjs';
4
- export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.mjs';
1
+ import * as unhead_types from 'unhead/types';
2
+ import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, MergeHead, CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
5
3
  export { createHeadCore } from 'unhead';
6
- export { createHead } from './client.mjs';
7
- export { createHead as createServerHead } from './server.mjs';
8
- import { d as distExports } from './shared/vue.DShwsPiO.mjs';
4
+ import { ResolvableProperties, UseHeadOptions } from '@unhead/vue';
9
5
  import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
10
6
  export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
11
7
  import { Ref } from 'vue';
12
- import './shared/vue.DnywREVF.mjs';
13
- import 'unhead/client';
14
- import 'unhead/server';
15
- import '@unhead/shared';
8
+ import { VueHeadClient, UseHeadInput, UseHeadOptions as UseHeadOptions$1, UseHeadSafeInput, UseSeoMetaInput } from './types.mjs';
9
+
10
+ declare function resolveUnrefHeadInput(ref: any): any;
16
11
 
17
12
  interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
18
13
  status: Ref<UseScriptStatus>;
19
14
  }
20
- type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
15
+ type UseScriptInput = string | (ResolvableProperties<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
21
16
  src: string;
22
17
  });
23
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
18
+ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends Omit<HeadEntryOptions, 'head'>, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
24
19
  /**
25
20
  * The trigger to load the script:
26
21
  * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
@@ -31,21 +26,28 @@ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<strin
31
26
  * - `ref` - Load the script when the ref is true.
32
27
  */
33
28
  trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
29
+ /**
30
+ * The Unhead instance to use.
31
+ */
32
+ head?: UseHeadOptions['head'];
34
33
  }
35
34
  type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
36
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
35
+ type UseScriptReturn<T extends Record<symbol | string, any>> = UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
36
+ declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
37
37
 
38
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
38
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
39
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
40
+ declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
41
  /**
40
42
  * @deprecated Please switch to non-legacy version
41
43
  */
42
44
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
43
- declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
44
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
45
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
46
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
47
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
48
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
49
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
45
+ declare function injectHead(): VueHeadClient<any> | undefined;
46
+ declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadInput<T>> | void;
47
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
48
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
49
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
51
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
52
 
51
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
53
+ export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptReturn, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.d.ts CHANGED
@@ -1,26 +1,21 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
3
- import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.js';
4
- export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.js';
1
+ import * as unhead_types from 'unhead/types';
2
+ import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, MergeHead, CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
5
3
  export { createHeadCore } from 'unhead';
6
- export { createHead } from './client.js';
7
- export { createHead as createServerHead } from './server.js';
8
- import { d as distExports } from './shared/vue.DShwsPiO.js';
4
+ import { ResolvableProperties, UseHeadOptions } from '@unhead/vue';
9
5
  import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
10
6
  export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
11
7
  import { Ref } from 'vue';
12
- import './shared/vue.DnywREVF.js';
13
- import 'unhead/client';
14
- import 'unhead/server';
15
- import '@unhead/shared';
8
+ import { VueHeadClient, UseHeadInput, UseHeadOptions as UseHeadOptions$1, UseHeadSafeInput, UseSeoMetaInput } from './types.js';
9
+
10
+ declare function resolveUnrefHeadInput(ref: any): any;
16
11
 
17
12
  interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
18
13
  status: Ref<UseScriptStatus>;
19
14
  }
20
- type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
15
+ type UseScriptInput = string | (ResolvableProperties<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
21
16
  src: string;
22
17
  });
23
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
18
+ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends Omit<HeadEntryOptions, 'head'>, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
24
19
  /**
25
20
  * The trigger to load the script:
26
21
  * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
@@ -31,21 +26,28 @@ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<strin
31
26
  * - `ref` - Load the script when the ref is true.
32
27
  */
33
28
  trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
29
+ /**
30
+ * The Unhead instance to use.
31
+ */
32
+ head?: UseHeadOptions['head'];
34
33
  }
35
34
  type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
36
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
35
+ type UseScriptReturn<T extends Record<symbol | string, any>> = UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
36
+ declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
37
37
 
38
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
38
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
39
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
40
+ declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
41
  /**
40
42
  * @deprecated Please switch to non-legacy version
41
43
  */
42
44
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
43
- declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
44
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
45
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
46
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
47
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
48
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
49
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
45
+ declare function injectHead(): VueHeadClient<any> | undefined;
46
+ declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadInput<T>> | void;
47
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
48
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
49
+ declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
51
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
52
 
51
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
53
+ export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptReturn, type VueScriptInstance, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.mjs CHANGED
@@ -1,17 +1,45 @@
1
- import { defineHeadPlugin, whitelistSafeInput, unpackMeta } from '@unhead/shared';
2
- import { unheadCtx, tryUseUnhead } from 'unhead';
3
1
  export { createHeadCore } from 'unhead';
4
- import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref, inject, watchEffect, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
5
- export { createHead } from './client.mjs';
6
- import { h as headSymbol, r as resolveUnrefHeadInput } from './shared/vue.Sg4YunmP.mjs';
7
- export { createHead as createServerHead } from './server.mjs';
2
+ import { DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin, SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
3
+ import { defineHeadPlugin } from 'unhead/utils';
4
+ import { walkResolver } from 'unhead/utils/walkResolver';
5
+ import { unref, getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref, inject, watchEffect, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
6
+ import { createHead as createHead$1 } from './client.mjs';
7
+ import { h as headSymbol } from './shared/vue.0vTsLwbU.mjs';
8
+ import { createHead as createHead$2 } from './server.mjs';
8
9
  import { useScript as useScript$1 } from 'unhead/legacy';
9
10
  export { resolveScriptKey } from 'unhead/legacy';
10
11
  import 'unhead/client';
11
- import './shared/vue.B6jdKgLD.mjs';
12
- import './shared/vue.O-w7-AFg.mjs';
12
+ import './shared/vue.BOii_fac.mjs';
13
13
  import 'unhead/server';
14
14
 
15
+ function resolveUnref(r) {
16
+ return typeof r === "function" ? r() : 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] = unref(root[k]);
34
+ continue;
35
+ }
36
+ resolved[k] = resolveUnrefHeadInput(root[k]);
37
+ }
38
+ return resolved;
39
+ }
40
+ return root;
41
+ }
42
+
15
43
  function registerVueScopeHandlers(script, scope) {
16
44
  if (!scope) {
17
45
  return;
@@ -77,15 +105,40 @@ function useScript(_input, _options) {
77
105
  });
78
106
  }
79
107
 
80
- const CapoPlugin = () => defineHeadPlugin({});
108
+ function CapoPlugin() {
109
+ return defineHeadPlugin({
110
+ key: "capo"
111
+ });
112
+ }
113
+ function createHead(options = {}) {
114
+ return createHead$1({
115
+ disableCapoSorting: true,
116
+ ...options,
117
+ plugins: [
118
+ DeprecationsPlugin,
119
+ PromisesPlugin,
120
+ TemplateParamsPlugin,
121
+ AliasSortingPlugin,
122
+ ...options.plugins || []
123
+ ]
124
+ });
125
+ }
126
+ function createServerHead(options = {}) {
127
+ return createHead$2({
128
+ disableCapoSorting: true,
129
+ ...options,
130
+ plugins: [
131
+ DeprecationsPlugin,
132
+ PromisesPlugin,
133
+ TemplateParamsPlugin,
134
+ AliasSortingPlugin,
135
+ ...options.plugins || []
136
+ ]
137
+ });
138
+ }
81
139
  function setHeadInjectionHandler(handler) {
82
- unheadCtx.set(handler(), true);
83
140
  }
84
141
  function injectHead() {
85
- const ctx = tryUseUnhead();
86
- if (ctx) {
87
- return ctx;
88
- }
89
142
  return inject(headSymbol);
90
143
  }
91
144
  function useHead(input, options = {}) {
@@ -98,7 +151,7 @@ function clientUseHead(head, input, options = {}) {
98
151
  const deactivated = ref(false);
99
152
  const resolvedInput = ref({});
100
153
  watchEffect(() => {
101
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
154
+ resolvedInput.value = deactivated.value ? {} : walkResolver(input, (v) => unref(v));
102
155
  });
103
156
  const entry = head.push(resolvedInput.value, options);
104
157
  watch(resolvedInput, (e) => {
@@ -119,27 +172,25 @@ function clientUseHead(head, input, options = {}) {
119
172
  return entry;
120
173
  }
121
174
  function useHeadSafe(input, options = {}) {
122
- return useHead(input, { ...options, transform: whitelistSafeInput });
175
+ const head = options.head || injectHead();
176
+ if (head) {
177
+ head.use(SafeInputPlugin);
178
+ options._safe = true;
179
+ return useHead(input, options);
180
+ }
123
181
  }
124
182
  function useSeoMeta(input, options) {
125
- const { title, titleTemplate, ...meta } = input;
126
- return useHead({
127
- title,
128
- titleTemplate,
129
- // @ts-expect-error runtime type
130
- _flatMeta: meta
131
- }, {
132
- ...options,
133
- transform(t) {
134
- const meta2 = unpackMeta({ ...t._flatMeta });
135
- delete t._flatMeta;
136
- return {
137
- // @ts-expect-error runtime type
138
- ...t,
139
- meta: meta2
140
- };
141
- }
142
- });
183
+ const head = options?.head || injectHead();
184
+ if (head) {
185
+ head.use(FlatMetaPlugin);
186
+ const { title, titleTemplate, ...meta } = input;
187
+ return useHead({
188
+ title,
189
+ titleTemplate,
190
+ // @ts-expect-error runtime type
191
+ _flatMeta: meta
192
+ }, options);
193
+ }
143
194
  }
144
195
  function useServerHead(input, options = {}) {
145
196
  return useHead(input, { ...options, mode: "server" });
@@ -151,4 +202,4 @@ function useServerSeoMeta(input, options) {
151
202
  return useSeoMeta(input, { ...options, mode: "server" });
152
203
  }
153
204
 
154
- export { CapoPlugin, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
205
+ export { CapoPlugin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/server.d.mts CHANGED
@@ -1,11 +1,8 @@
1
- import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.DShwsPiO.mjs';
1
+ import { VueHeadClient } from '@unhead/vue';
2
+ import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
3
3
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
- export * from 'unhead/server';
5
- import '@unhead/shared';
6
- import 'unhead';
7
- import 'vue';
4
+ export { SSRHeadPayload, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
8
5
 
9
- declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
6
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propsResolver'>): VueHeadClient<T>;
10
7
 
11
8
  export { createHead };
package/dist/server.d.ts CHANGED
@@ -1,11 +1,8 @@
1
- import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.DShwsPiO.js';
1
+ import { VueHeadClient } from '@unhead/vue';
2
+ import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
3
3
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
- export * from 'unhead/server';
5
- import '@unhead/shared';
6
- import 'unhead';
7
- import 'vue';
4
+ export { SSRHeadPayload, extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
8
5
 
9
- declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
6
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propsResolver'>): VueHeadClient<T>;
10
7
 
11
8
  export { createHead };
package/dist/server.mjs CHANGED
@@ -1,19 +1,15 @@
1
1
  import { createHead as createHead$1 } from 'unhead/server';
2
- export * from 'unhead/server';
3
- import { v as vueInstall } from './shared/vue.Sg4YunmP.mjs';
4
- import { V as VueReactivityPlugin } from './shared/vue.B6jdKgLD.mjs';
5
- export { V as VueHeadMixin } from './shared/vue.O-w7-AFg.mjs';
2
+ export { extractUnheadInputFromHtml, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
3
+ import { V as VueResolver, v as vueInstall } from './shared/vue.0vTsLwbU.mjs';
4
+ export { V as VueHeadMixin } from './shared/vue.BOii_fac.mjs';
5
+ import 'unhead/plugins';
6
+ import 'unhead/utils';
6
7
  import 'vue';
7
- import 'unhead';
8
- import '@unhead/shared';
9
8
 
10
9
  function createHead(options = {}) {
11
10
  const head = createHead$1({
12
11
  ...options,
13
- plugins: [
14
- ...options.plugins || [],
15
- VueReactivityPlugin
16
- ]
12
+ propResolvers: [VueResolver]
17
13
  });
18
14
  head.install = vueInstall(head);
19
15
  return head;