@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
package/dist/client.d.mts CHANGED
@@ -1,11 +1,9 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.Bjx6RvLp.mjs';
1
+ import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
- export * from 'unhead/client';
5
- import '@unhead/shared';
6
- import 'unhead';
3
+ export { renderDOMHead } from 'unhead/client';
4
+ import { V as VueHeadClient } from './shared/vue.C97gXjQS.mjs';
7
5
  import 'vue';
8
6
 
9
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
7
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
10
8
 
11
9
  export { createHead };
package/dist/client.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.Bjx6RvLp.js';
1
+ import { MergeHead, CreateClientHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
- export * from 'unhead/client';
5
- import '@unhead/shared';
6
- import 'unhead';
3
+ export { renderDOMHead } from 'unhead/client';
4
+ import { V as VueHeadClient } from './shared/vue.C97gXjQS.js';
7
5
  import 'vue';
8
6
 
9
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
7
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
10
8
 
11
9
  export { createHead };
package/dist/client.mjs CHANGED
@@ -1,21 +1,18 @@
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.DUgB2y83.mjs';
5
- import { V as VueReactivityPlugin } from './shared/vue.BmaKl8wu.mjs';
6
- export { V as VueHeadMixin } from './shared/vue.BqrzivMs.mjs';
7
- import '@unhead/shared';
4
+ import { v as vueInstall } from './shared/vue.j4SPrdI5.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.DBXhY4KI.mjs';
6
+ import 'unhead/plugins';
7
+ import 'unhead/utils';
8
+ import './shared/vue.N9zWjxoK.mjs';
8
9
 
9
10
  function createHead(options = {}) {
10
11
  const head = createHead$1({
11
12
  domOptions: {
12
- delayFn: (fn) => nextTick(() => setTimeout(() => fn(), 0))
13
+ render: createDebouncedFn(() => renderDOMHead(head), nextTick)
13
14
  },
14
- ...options,
15
- plugins: [
16
- ...options.plugins || [],
17
- VueReactivityPlugin
18
- ]
15
+ ...options
19
16
  });
20
17
  head.install = vueInstall(head);
21
18
  return head;
@@ -1,5 +1,8 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { u as useHead } from './shared/vue.DUgB2y83.mjs';
2
+ import { u as useHead } from './shared/vue.j4SPrdI5.mjs';
3
+ import 'unhead/plugins';
4
+ import 'unhead/utils';
5
+ import './shared/vue.N9zWjxoK.mjs';
3
6
 
4
7
  function addVNodeToHeadObj(node, obj) {
5
8
  const nodeType = node.type;
@@ -20,10 +23,10 @@ function addVNodeToHeadObj(node, obj) {
20
23
  }
21
24
  function vnodesToHeadObj(nodes) {
22
25
  const obj = {
23
- title: undefined,
24
- htmlAttrs: undefined,
25
- bodyAttrs: undefined,
26
- base: undefined,
26
+ title: void 0,
27
+ htmlAttrs: void 0,
28
+ bodyAttrs: void 0,
29
+ base: void 0,
27
30
  meta: [],
28
31
  link: [],
29
32
  style: [],
package/dist/index.d.mts CHANGED
@@ -1,33 +1,29 @@
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
1
  export { createHeadCore } 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';
2
+ import { MergeHead, ActiveHeadEntry } from 'unhead/types';
3
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, RenderSSRHeadOptions, ResolvedBase, ResolvedBodyAttributes, ResolvedHead, ResolvedHtmlAttributes, ResolvedLink, ResolvedMeta, ResolvedNoscript, ResolvedScript, ResolvedStyle, ResolvedTitle, ResolvedTitleTemplate, Unhead } from 'unhead/types';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C97gXjQS.mjs';
5
+ export { d as Base, B as BodyAttr, g as BodyAttributes, H as HtmlAttr, f as HtmlAttributes, L as Link, h as MaybeFalsey, M as Meta, N as Noscript, R as ReactiveHead, j as ResolvableArray, k as ResolvableProperties, i as ResolvableValue, e as Script, S as Style, T as Title, c as TitleTemplate } from './shared/vue.C97gXjQS.mjs';
6
+ import { UseHeadSafeInput } from './types.mjs';
7
+ export { HeadSafe, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SafeStyle } from './types.mjs';
8
+ export { resolveUnrefHeadInput } from './utils.mjs';
7
9
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
8
10
  import 'vue';
11
+ import 'unhead/utils';
9
12
 
10
13
  declare const unheadVueComposablesImports: {
11
14
  '@unhead/vue': string[];
12
15
  };
13
16
 
14
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>>;
17
+ declare function injectHead(): VueHeadClient<MergeHead>;
18
+ declare function useHead<T extends MergeHead>(input?: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
19
+ declare function useHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
20
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
+ declare function useServerHead<T extends MergeHead>(input?: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
22
+ declare function useServerHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
+ declare function useServerSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
15
24
 
16
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
25
+ declare const headSymbol = "usehead";
17
26
 
18
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
27
+ declare const CapoPlugin: () => {};
19
28
 
20
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
-
22
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
-
24
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
25
-
26
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
27
-
28
- /**
29
- * @deprecated TODO remove
30
- */
31
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
32
-
33
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
29
+ export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,33 +1,29 @@
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
1
  export { createHeadCore } 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';
2
+ import { MergeHead, ActiveHeadEntry } from 'unhead/types';
3
+ export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, RenderSSRHeadOptions, ResolvedBase, ResolvedBodyAttributes, ResolvedHead, ResolvedHtmlAttributes, ResolvedLink, ResolvedMeta, ResolvedNoscript, ResolvedScript, ResolvedStyle, ResolvedTitle, ResolvedTitleTemplate, Unhead } from 'unhead/types';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C97gXjQS.js';
5
+ export { d as Base, B as BodyAttr, g as BodyAttributes, H as HtmlAttr, f as HtmlAttributes, L as Link, h as MaybeFalsey, M as Meta, N as Noscript, R as ReactiveHead, j as ResolvableArray, k as ResolvableProperties, i as ResolvableValue, e as Script, S as Style, T as Title, c as TitleTemplate } from './shared/vue.C97gXjQS.js';
6
+ import { UseHeadSafeInput } from './types.js';
7
+ export { HeadSafe, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SafeStyle } from './types.js';
8
+ export { resolveUnrefHeadInput } from './utils.js';
7
9
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
8
10
  import 'vue';
11
+ import 'unhead/utils';
9
12
 
10
13
  declare const unheadVueComposablesImports: {
11
14
  '@unhead/vue': string[];
12
15
  };
13
16
 
14
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>>;
17
+ declare function injectHead(): VueHeadClient<MergeHead>;
18
+ declare function useHead<T extends MergeHead>(input?: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
19
+ declare function useHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
20
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
+ declare function useServerHead<T extends MergeHead>(input?: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
22
+ declare function useServerHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
+ declare function useServerSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
15
24
 
16
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
25
+ declare const headSymbol = "usehead";
17
26
 
18
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
27
+ declare const CapoPlugin: () => {};
19
28
 
20
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
21
-
22
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
23
-
24
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
25
-
26
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
27
-
28
- /**
29
- * @deprecated TODO remove
30
- */
31
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
32
-
33
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
29
+ export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,54 +1,16 @@
1
- import { composableNames, whitelistSafeInput, unpackMeta, defineHeadPlugin } from '@unhead/shared';
2
1
  export { createHeadCore } from 'unhead';
3
- import { u as useHead } from './shared/vue.DUgB2y83.mjs';
4
- export { i as injectHead, r as resolveUnrefHeadInput } from './shared/vue.DUgB2y83.mjs';
5
- export { V as VueHeadMixin } from './shared/vue.BqrzivMs.mjs';
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.j4SPrdI5.mjs';
3
+ export { resolveUnrefHeadInput } from './utils.mjs';
4
+ export { V as VueHeadMixin } from './shared/vue.DBXhY4KI.mjs';
5
+ import 'unhead/plugins';
6
+ import 'unhead/utils';
6
7
  import 'vue';
8
+ import './shared/vue.N9zWjxoK.mjs';
7
9
 
8
- const coreComposableNames = [
9
- "injectHead"
10
- ];
11
10
  const unheadVueComposablesImports = {
12
- "@unhead/vue": [...coreComposableNames, ...composableNames]
11
+ "@unhead/vue": ["injectHead", "useHead", "useSeoMeta", "useHeadSafe", "useServerHead", "useServerSeoMeta", "useServerHeadSafe"]
13
12
  };
14
13
 
15
- function useHeadSafe(input, options = {}) {
16
- return useHead(input, { ...options, transform: whitelistSafeInput });
17
- }
14
+ const CapoPlugin = () => ({});
18
15
 
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 };
16
+ export { CapoPlugin, unheadVueComposablesImports };
package/dist/legacy.d.mts CHANGED
@@ -1,51 +1,24 @@
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 { 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.Bjx6RvLp.mjs';
9
- import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
10
- export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
11
- import { Ref } from 'vue';
12
- import './shared/vue.DnywREVF.mjs';
13
- import 'unhead/client';
14
- import 'unhead/server';
15
- import '@unhead/shared';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C97gXjQS.mjs';
5
+ import { UseHeadSafeInput } from './types.mjs';
6
+ import 'vue';
16
7
 
17
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
18
- status: Ref<UseScriptStatus>;
19
- }
20
- type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
21
- src: string;
22
- });
23
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
24
- /**
25
- * The trigger to load the script:
26
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
27
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
28
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
29
- * - `Function` - Register a callback function to load the script, exists only on the client.
30
- * - `server` - Have the script injected on the server.
31
- * - `ref` - Load the script when the ref is true.
32
- */
33
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
34
- }
35
- 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>>;
37
-
38
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
8
+ declare function resolveUnrefHeadInput(input: any): any;
9
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
10
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
11
+ declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
12
  /**
40
13
  * @deprecated Please switch to non-legacy version
41
14
  */
42
15
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
43
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
16
+ declare function injectHead(): VueHeadClient<any> | undefined;
44
17
  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;
18
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
46
19
  declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
47
20
  declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
48
21
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
49
22
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
50
23
 
51
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
24
+ export { CapoPlugin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.d.ts CHANGED
@@ -1,51 +1,24 @@
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 { 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.Bjx6RvLp.js';
9
- import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
10
- export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
11
- import { Ref } from 'vue';
12
- import './shared/vue.DnywREVF.js';
13
- import 'unhead/client';
14
- import 'unhead/server';
15
- import '@unhead/shared';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C97gXjQS.js';
5
+ import { UseHeadSafeInput } from './types.js';
6
+ import 'vue';
16
7
 
17
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
18
- status: Ref<UseScriptStatus>;
19
- }
20
- type UseScriptInput = string | (distExports.MaybeComputedRefEntriesOnly<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
21
- src: string;
22
- });
23
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends HeadEntryOptions, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
24
- /**
25
- * The trigger to load the script:
26
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
27
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
28
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
29
- * - `Function` - Register a callback function to load the script, exists only on the client.
30
- * - `server` - Have the script injected on the server.
31
- * - `ref` - Load the script when the ref is true.
32
- */
33
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
34
- }
35
- 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>>;
37
-
38
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
8
+ declare function resolveUnrefHeadInput(input: any): any;
9
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
10
+ declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
11
+ declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
12
  /**
40
13
  * @deprecated Please switch to non-legacy version
41
14
  */
42
15
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
43
- declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
16
+ declare function injectHead(): VueHeadClient<any> | undefined;
44
17
  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;
18
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
46
19
  declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
47
20
  declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
48
21
  declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
49
22
  declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
50
23
 
51
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
24
+ export { CapoPlugin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.mjs CHANGED
@@ -1,82 +1,49 @@
1
- import { defineHeadPlugin, whitelistSafeInput, unpackMeta } from '@unhead/shared';
2
1
  export { createHeadCore } from 'unhead';
3
- import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref, inject, watchEffect, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
4
- export { createHead } from './client.mjs';
5
- import { h as headSymbol, r as resolveUnrefHeadInput } from './shared/vue.DUgB2y83.mjs';
6
- export { createHead as createServerHead } from './server.mjs';
7
- import { useScript as useScript$1 } from 'unhead/legacy';
8
- export { resolveScriptKey } from 'unhead/legacy';
2
+ import { inject, ref, watchEffect, unref, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
3
+ import { createHead as createHead$1 } from './client.mjs';
4
+ import { h as headSymbol } from './shared/vue.j4SPrdI5.mjs';
5
+ import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
6
+ import { createHead as createHead$2 } from './server.mjs';
7
+ import { walkResolver } from 'unhead/utils';
8
+ import { defineHeadPlugin, DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin, SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
9
9
  import 'unhead/client';
10
- import './shared/vue.BmaKl8wu.mjs';
11
- import './shared/vue.BqrzivMs.mjs';
10
+ import './shared/vue.DBXhY4KI.mjs';
12
11
  import 'unhead/server';
13
12
 
14
- function registerVueScopeHandlers(script, scope) {
15
- if (!scope) {
16
- return;
17
- }
18
- const _registerCb = (key, cb) => {
19
- if (!script._cbs[key]) {
20
- cb(script.instance);
21
- return () => {
22
- };
23
- }
24
- let i = script._cbs[key].push(cb);
25
- const destroy = () => {
26
- if (i) {
27
- script._cbs[key]?.splice(i - 1, 1);
28
- i = null;
29
- }
30
- };
31
- onScopeDispose(destroy);
32
- return destroy;
33
- };
34
- script.onLoaded = (cb) => _registerCb("loaded", cb);
35
- script.onError = (cb) => _registerCb("error", cb);
36
- onScopeDispose(() => {
37
- script._triggerAbortController?.abort();
13
+ function resolveUnrefHeadInput(input) {
14
+ return walkResolver(input, VueResolver);
15
+ }
16
+ function CapoPlugin() {
17
+ return defineHeadPlugin({
18
+ key: "capo"
38
19
  });
39
20
  }
40
- function useScript(_input, _options) {
41
- const input = typeof _input === "string" ? { src: _input } : _input;
42
- const options = _options || {};
43
- const head = options?.head || injectHead();
44
- options.head = head;
45
- const scope = getCurrentInstance();
46
- options.eventContext = scope;
47
- if (scope && typeof options.trigger === "undefined") {
48
- options.trigger = onMounted;
49
- } else if (isRef(options.trigger)) {
50
- const refTrigger = options.trigger;
51
- let off;
52
- options.trigger = new Promise((resolve) => {
53
- off = watch(refTrigger, (val) => {
54
- if (val) {
55
- resolve(true);
56
- }
57
- }, {
58
- immediate: true
59
- });
60
- onScopeDispose(() => resolve(false), true);
61
- }).then((val) => {
62
- off?.();
63
- return val;
64
- });
65
- }
66
- head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
67
- s._statusRef.value = s.status;
21
+ function createHead(options = {}) {
22
+ return createHead$1({
23
+ disableCapoSorting: true,
24
+ ...options,
25
+ plugins: [
26
+ DeprecationsPlugin,
27
+ PromisesPlugin,
28
+ TemplateParamsPlugin,
29
+ AliasSortingPlugin,
30
+ ...options.plugins || []
31
+ ]
68
32
  });
69
- const script = useScript$1(input, options);
70
- script._statusRef = script._statusRef || ref(script.status);
71
- registerVueScopeHandlers(script, scope);
72
- return new Proxy(script, {
73
- get(_, key, a) {
74
- return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
75
- }
33
+ }
34
+ function createServerHead(options = {}) {
35
+ return createHead$2({
36
+ disableCapoSorting: true,
37
+ ...options,
38
+ plugins: [
39
+ DeprecationsPlugin,
40
+ PromisesPlugin,
41
+ TemplateParamsPlugin,
42
+ AliasSortingPlugin,
43
+ ...options.plugins || []
44
+ ]
76
45
  });
77
46
  }
78
-
79
- const CapoPlugin = () => defineHeadPlugin({});
80
47
  function setHeadInjectionHandler(handler) {
81
48
  }
82
49
  function injectHead() {
@@ -92,7 +59,7 @@ function clientUseHead(head, input, options = {}) {
92
59
  const deactivated = ref(false);
93
60
  const resolvedInput = ref({});
94
61
  watchEffect(() => {
95
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
62
+ resolvedInput.value = deactivated.value ? {} : walkResolver(input, (v) => unref(v));
96
63
  });
97
64
  const entry = head.push(resolvedInput.value, options);
98
65
  watch(resolvedInput, (e) => {
@@ -113,27 +80,25 @@ function clientUseHead(head, input, options = {}) {
113
80
  return entry;
114
81
  }
115
82
  function useHeadSafe(input, options = {}) {
116
- return useHead(input, { ...options, transform: whitelistSafeInput });
83
+ const head = options.head || injectHead();
84
+ if (head) {
85
+ head.use(SafeInputPlugin);
86
+ options._safe = true;
87
+ return useHead(input, options);
88
+ }
117
89
  }
118
90
  function useSeoMeta(input, options) {
119
- const { title, titleTemplate, ...meta } = input;
120
- return useHead({
121
- title,
122
- titleTemplate,
123
- // @ts-expect-error runtime type
124
- _flatMeta: meta
125
- }, {
126
- ...options,
127
- transform(t) {
128
- const meta2 = unpackMeta({ ...t._flatMeta });
129
- delete t._flatMeta;
130
- return {
131
- // @ts-expect-error runtime type
132
- ...t,
133
- meta: meta2
134
- };
135
- }
136
- });
91
+ const head = options?.head || injectHead();
92
+ if (head) {
93
+ head.use(FlatMetaPlugin);
94
+ const { title, titleTemplate, ...meta } = input;
95
+ return useHead({
96
+ title,
97
+ titleTemplate,
98
+ // @ts-expect-error runtime type
99
+ _flatMeta: meta
100
+ }, options);
101
+ }
137
102
  }
138
103
  function useServerHead(input, options = {}) {
139
104
  return useHead(input, { ...options, mode: "server" });
@@ -145,4 +110,4 @@ function useServerSeoMeta(input, options) {
145
110
  return useSeoMeta(input, { ...options, mode: "server" });
146
111
  }
147
112
 
148
- export { CapoPlugin, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
113
+ export { CapoPlugin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
@@ -0,0 +1 @@
1
+ export * from 'unhead/plugins';
package/dist/server.d.mts CHANGED
@@ -1,11 +1,9 @@
1
- import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.Bjx6RvLp.mjs';
1
+ import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
- export * from 'unhead/server';
5
- import '@unhead/shared';
6
- import 'unhead';
3
+ export { SSRHeadPayload, extractUnheadInputFromHtml, propsToString, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
4
+ import { V as VueHeadClient } from './shared/vue.C97gXjQS.mjs';
7
5
  import 'vue';
8
6
 
9
- declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
7
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propsResolver'>): VueHeadClient<T>;
10
8
 
11
9
  export { createHead };
package/dist/server.d.ts CHANGED
@@ -1,11 +1,9 @@
1
- import { MergeHead, CreateHeadOptions } from '@unhead/schema';
2
- import { d as distExports } from './shared/vue.Bjx6RvLp.js';
1
+ import { MergeHead, CreateServerHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
- export * from 'unhead/server';
5
- import '@unhead/shared';
6
- import 'unhead';
3
+ export { SSRHeadPayload, extractUnheadInputFromHtml, propsToString, renderSSRHead, transformHtmlTemplate } from 'unhead/server';
4
+ import { V as VueHeadClient } from './shared/vue.C97gXjQS.js';
7
5
  import 'vue';
8
6
 
9
- declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
7
+ declare function createHead<T extends MergeHead>(options?: Omit<CreateServerHeadOptions, 'propsResolver'>): VueHeadClient<T>;
10
8
 
11
9
  export { createHead };