@unhead/vue 2.0.0-alpha.8 → 2.0.0-beta.0

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 (56) hide show
  1. package/dist/client.d.mts +5 -4
  2. package/dist/client.d.ts +5 -4
  3. package/dist/client.mjs +9 -12
  4. package/dist/components.mjs +8 -6
  5. package/dist/index.d.mts +34 -15
  6. package/dist/index.d.ts +34 -15
  7. package/dist/index.mjs +13 -7
  8. package/dist/legacy.d.mts +27 -45
  9. package/dist/legacy.d.ts +27 -45
  10. package/dist/legacy.mjs +36 -93
  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/scripts.d.mts +32 -0
  15. package/dist/scripts.d.ts +32 -0
  16. package/dist/scripts.mjs +7 -0
  17. package/dist/server.d.mts +5 -4
  18. package/dist/server.d.ts +5 -4
  19. package/dist/server.mjs +7 -9
  20. package/dist/shared/vue.A6QPXQyg.d.ts +63 -0
  21. package/dist/shared/vue.BYLJNEcq.mjs +83 -0
  22. package/dist/shared/vue.C1egIkvG.d.mts +134 -0
  23. package/dist/shared/vue.C1egIkvG.d.ts +134 -0
  24. package/dist/shared/vue.Ds_C3mXu.d.mts +63 -0
  25. package/dist/shared/vue.N9zWjxoK.mjs +7 -0
  26. package/dist/shared/vue.cHBs6zvy.mjs +70 -0
  27. package/dist/shared/{vue.CNiRntV8.mjs → vue.nvpYXC6D.mjs} +1 -1
  28. package/dist/types.d.mts +14 -135
  29. package/dist/types.d.ts +14 -135
  30. package/dist/utils.d.mts +11 -0
  31. package/dist/utils.d.ts +11 -0
  32. package/dist/utils.mjs +10 -0
  33. package/package.json +34 -18
  34. package/plugins.d.ts +1 -0
  35. package/utils.d.ts +1 -0
  36. package/dist/client.cjs +0 -36
  37. package/dist/client.d.cts +0 -8
  38. package/dist/components.cjs +0 -65
  39. package/dist/components.d.cts +0 -5
  40. package/dist/index.cjs +0 -27
  41. package/dist/index.d.cts +0 -26
  42. package/dist/legacy.cjs +0 -186
  43. package/dist/legacy.d.cts +0 -52
  44. package/dist/server.cjs +0 -33
  45. package/dist/server.d.cts +0 -8
  46. package/dist/shared/vue.51u-UkLG.mjs +0 -13
  47. package/dist/shared/vue.BF-HCrO8.d.cts +0 -3
  48. package/dist/shared/vue.BF-HCrO8.d.mts +0 -3
  49. package/dist/shared/vue.BF-HCrO8.d.ts +0 -3
  50. package/dist/shared/vue.Btxz9wTa.cjs +0 -126
  51. package/dist/shared/vue.D2UzSD_b.mjs +0 -115
  52. package/dist/shared/vue.DFf1FJKf.cjs +0 -20
  53. package/dist/shared/vue.DnywREVF.d.cts +0 -5
  54. package/dist/shared/vue.rzkVHzqg.cjs +0 -15
  55. package/dist/types.cjs +0 -2
  56. package/dist/types.d.cts +0 -137
package/dist/client.d.mts CHANGED
@@ -1,8 +1,9 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { VueHeadClient } from '@unhead/vue';
1
+ import { CreateClientHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
4
- export * from 'unhead/client';
3
+ export { renderDOMHead } from 'unhead/client';
4
+ import { V as VueHeadClient } from './shared/vue.C1egIkvG.mjs';
5
+ import 'vue';
5
6
 
6
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
7
+ declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
7
8
 
8
9
  export { createHead };
package/dist/client.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
2
- import { VueHeadClient } from '@unhead/vue';
1
+ import { CreateClientHeadOptions } from 'unhead/types';
3
2
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
4
- export * from 'unhead/client';
3
+ export { renderDOMHead } from 'unhead/client';
4
+ import { V as VueHeadClient } from './shared/vue.C1egIkvG.js';
5
+ import 'vue';
5
6
 
6
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
7
+ declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
7
8
 
8
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.D2UzSD_b.mjs';
5
- import { V as VueReactivityPlugin } from './shared/vue.51u-UkLG.mjs';
6
- export { V as VueHeadMixin } from './shared/vue.CNiRntV8.mjs';
7
- import '@unhead/shared';
4
+ import { v as vueInstall } from './shared/vue.BYLJNEcq.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.nvpYXC6D.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,6 +1,8 @@
1
1
  import { defineComponent, ref, onBeforeUnmount, watchEffect } from 'vue';
2
- import { u as useHead } from './shared/vue.D2UzSD_b.mjs';
3
- import '@unhead/shared';
2
+ import { u as useHead } from './shared/vue.BYLJNEcq.mjs';
3
+ import 'unhead/plugins';
4
+ import 'unhead/utils';
5
+ import './shared/vue.N9zWjxoK.mjs';
4
6
 
5
7
  function addVNodeToHeadObj(node, obj) {
6
8
  const nodeType = node.type;
@@ -21,10 +23,10 @@ function addVNodeToHeadObj(node, obj) {
21
23
  }
22
24
  function vnodesToHeadObj(nodes) {
23
25
  const obj = {
24
- title: undefined,
25
- htmlAttrs: undefined,
26
- bodyAttrs: undefined,
27
- base: undefined,
26
+ title: void 0,
27
+ htmlAttrs: void 0,
28
+ bodyAttrs: void 0,
29
+ base: void 0,
28
30
  meta: [],
29
31
  link: [],
30
32
  style: [],
package/dist/index.d.mts CHANGED
@@ -1,26 +1,45 @@
1
- export { createHeadCore } from 'unhead';
2
- export { r as resolveUnrefHeadInput } from './shared/vue.BF-HCrO8.mjs';
3
- import { MergeHead, ActiveHeadEntry } from '@unhead/schema';
4
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from '@unhead/schema';
5
- import { VueHeadClient, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from './types.mjs';
6
- export { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate } from './types.mjs';
1
+ import { createUnhead } from 'unhead';
2
+ export { createUnhead } from 'unhead';
3
+ import { ActiveHeadEntry } from 'unhead/types';
4
+ export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
5
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C1egIkvG.mjs';
6
+ export { B as BodyAttr, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, m as ResolvableValue } from './shared/vue.C1egIkvG.mjs';
7
+ import { U as UseHeadSafeInput } from './shared/vue.Ds_C3mXu.mjs';
8
+ export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/vue.Ds_C3mXu.mjs';
9
+ export { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style } from './types.mjs';
10
+ export { resolveUnrefHeadInput } from './utils.mjs';
7
11
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.mjs';
12
+ export { useScript } from './scripts.mjs';
8
13
  import 'vue';
14
+ import 'unhead/utils';
15
+ import 'unhead/scripts';
9
16
 
10
17
  declare const unheadVueComposablesImports: {
11
18
  '@unhead/vue': string[];
12
19
  };
13
20
 
14
- declare function injectHead(): VueHeadClient<MergeHead>;
15
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
16
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
17
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
18
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
19
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
20
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
21
+ declare function injectHead(): VueHeadClient;
22
+ declare function useHead<I = UseHeadInput>(input?: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<I>;
23
+ declare function useHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput>;
24
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
25
+ /**
26
+ * @deprecated use `useHead` instead.Advanced use cases should tree shake using import.meta.* if statements.
27
+ */
28
+ declare function useServerHead<I = UseHeadInput>(input?: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<I>;
29
+ /**
30
+ * @deprecated use `useHeadSafe` instead.Advanced use cases should tree shake using import.meta.* if statements.
31
+ */
32
+ declare function useServerHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput>;
33
+ /**
34
+ * @deprecated use `useSeoMeta` instead.Advanced use cases should tree shake using import.meta.* if statements.
35
+ */
36
+ declare function useServerSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
21
37
 
22
38
  declare const headSymbol = "usehead";
23
39
 
24
- declare const CapoPlugin: () => {};
40
+ /**
41
+ * @deprecated Use createUnhead
42
+ */
43
+ declare const createCoreHead: typeof createUnhead;
25
44
 
26
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
45
+ export { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, createCoreHead, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.d.ts CHANGED
@@ -1,26 +1,45 @@
1
- export { createHeadCore } from 'unhead';
2
- export { r as resolveUnrefHeadInput } from './shared/vue.BF-HCrO8.js';
3
- import { MergeHead, ActiveHeadEntry } from '@unhead/schema';
4
- export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, ResolvedHead, Unhead } from '@unhead/schema';
5
- import { VueHeadClient, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput } from './types.js';
6
- export { Base, BodyAttr, BodyAttributes, HeadSafe, HtmlAttr, HtmlAttributes, Link, MaybeComputedRef, Meta, Noscript, ReactiveHead, ResolvableArray, ResolvableProperties, Script, Style, Title, TitleTemplate } from './types.js';
1
+ import { createUnhead } from 'unhead';
2
+ export { createUnhead } from 'unhead';
3
+ import { ActiveHeadEntry } from 'unhead/types';
4
+ export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
5
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C1egIkvG.js';
6
+ export { B as BodyAttr, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, m as ResolvableValue } from './shared/vue.C1egIkvG.js';
7
+ import { U as UseHeadSafeInput } from './shared/vue.A6QPXQyg.js';
8
+ export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle } from './shared/vue.A6QPXQyg.js';
9
+ export { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style } from './types.js';
10
+ export { resolveUnrefHeadInput } from './utils.js';
7
11
  export { V as VueHeadMixin } from './shared/vue.DnywREVF.js';
12
+ export { useScript } from './scripts.js';
8
13
  import 'vue';
14
+ import 'unhead/utils';
15
+ import 'unhead/scripts';
9
16
 
10
17
  declare const unheadVueComposablesImports: {
11
18
  '@unhead/vue': string[];
12
19
  };
13
20
 
14
- declare function injectHead(): VueHeadClient<MergeHead>;
15
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
16
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
17
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
18
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any>;
19
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
20
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
21
+ declare function injectHead(): VueHeadClient;
22
+ declare function useHead<I = UseHeadInput>(input?: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<I>;
23
+ declare function useHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput>;
24
+ declare function useSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
25
+ /**
26
+ * @deprecated use `useHead` instead.Advanced use cases should tree shake using import.meta.* if statements.
27
+ */
28
+ declare function useServerHead<I = UseHeadInput>(input?: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<I>;
29
+ /**
30
+ * @deprecated use `useHeadSafe` instead.Advanced use cases should tree shake using import.meta.* if statements.
31
+ */
32
+ declare function useServerHeadSafe(input?: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput>;
33
+ /**
34
+ * @deprecated use `useSeoMeta` instead.Advanced use cases should tree shake using import.meta.* if statements.
35
+ */
36
+ declare function useServerSeoMeta(input?: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<UseSeoMetaInput>;
21
37
 
22
38
  declare const headSymbol = "usehead";
23
39
 
24
- declare const CapoPlugin: () => {};
40
+ /**
41
+ * @deprecated Use createUnhead
42
+ */
43
+ declare const createCoreHead: typeof createUnhead;
25
44
 
26
- export { CapoPlugin, UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
45
+ export { UseHeadInput, UseHeadOptions, UseHeadSafeInput, UseSeoMetaInput, VueHeadClient, createCoreHead, headSymbol, injectHead, unheadVueComposablesImports, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/index.mjs CHANGED
@@ -1,13 +1,19 @@
1
- export { createHeadCore } from 'unhead';
2
- export { h as headSymbol, i as injectHead, r as resolveUnrefHeadInput, u as useHead, a as useHeadSafe, b as useSeoMeta, c as useServerHead, d as useServerHeadSafe, e as useServerSeoMeta } from './shared/vue.D2UzSD_b.mjs';
3
- import { composableNames } from '@unhead/shared';
4
- export { V as VueHeadMixin } from './shared/vue.CNiRntV8.mjs';
1
+ import { createUnhead } from 'unhead';
2
+ export { createUnhead } from 'unhead';
3
+ 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.BYLJNEcq.mjs';
4
+ export { resolveUnrefHeadInput } from './utils.mjs';
5
+ export { V as VueHeadMixin } from './shared/vue.nvpYXC6D.mjs';
6
+ export { u as useScript } from './shared/vue.cHBs6zvy.mjs';
7
+ import 'unhead/plugins';
8
+ import 'unhead/utils';
5
9
  import 'vue';
10
+ import './shared/vue.N9zWjxoK.mjs';
11
+ import 'unhead/scripts';
6
12
 
7
13
  const unheadVueComposablesImports = {
8
- "@unhead/vue": ["injectHead", ...composableNames]
14
+ "@unhead/vue": ["injectHead", "useHead", "useSeoMeta", "useHeadSafe", "useServerHead", "useServerSeoMeta", "useServerHeadSafe"]
9
15
  };
10
16
 
11
- const CapoPlugin = () => ({});
17
+ const createCoreHead = createUnhead;
12
18
 
13
- export { CapoPlugin, unheadVueComposablesImports };
19
+ export { createCoreHead, unheadVueComposablesImports };
package/dist/legacy.d.mts CHANGED
@@ -1,52 +1,34 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, MergeHead, CreateClientHeadOptions, ActiveHeadEntry } from '@unhead/schema';
3
- export { createHeadCore } from 'unhead';
4
- export { r as resolveUnrefHeadInput } from './shared/vue.BF-HCrO8.mjs';
5
- import { ResolvableProperties, UseHeadOptions } from '@unhead/vue';
6
- import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
7
- export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
8
- import { Ref } from 'vue';
9
- import { VueHeadClient, UseHeadInput, UseHeadOptions as UseHeadOptions$1, UseHeadSafeInput, UseSeoMetaInput } from './types.mjs';
1
+ import * as unhead_types from 'unhead/types';
2
+ import { CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
3
+ import { createUnhead } from 'unhead';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C1egIkvG.mjs';
5
+ import { U as UseHeadSafeInput } from './shared/vue.Ds_C3mXu.mjs';
6
+ import 'vue';
10
7
 
11
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
12
- status: Ref<UseScriptStatus>;
13
- }
14
- type UseScriptInput = string | (ResolvableProperties<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
15
- src: string;
16
- });
17
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends Omit<HeadEntryOptions, 'head'>, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
18
- /**
19
- * The trigger to load the script:
20
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
21
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
22
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
23
- * - `Function` - Register a callback function to load the script, exists only on the client.
24
- * - `server` - Have the script injected on the server.
25
- * - `ref` - Load the script when the ref is true.
26
- */
27
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
28
- /**
29
- * The Unhead instance to use.
30
- */
31
- head?: UseHeadOptions['head'];
32
- }
33
- type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
34
- type UseScriptReturn<T extends Record<symbol | string, any>> = UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
35
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
36
-
37
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
38
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
- declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
8
+ declare const createHeadCore: typeof createUnhead;
9
+ declare function resolveUnrefHeadInput(input: any): any;
10
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
11
+ declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
12
+ declare function createServerHead(options?: CreateClientHeadOptions): VueHeadClient;
40
13
  /**
41
14
  * @deprecated Please switch to non-legacy version
42
15
  */
43
16
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
44
17
  declare function injectHead(): VueHeadClient<any> | undefined;
45
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadInput<T>> | void;
46
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadSafeInput> | void;
47
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
48
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
49
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
18
+ declare function useHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput> | void;
19
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
20
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
21
+ /**
22
+ * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
23
+ */
24
+ declare function useServerHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
25
+ /**
26
+ * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
27
+ */
28
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
29
+ /**
30
+ * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
31
+ */
32
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
51
33
 
52
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptReturn, type VueScriptInstance, createHead, createServerHead, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
34
+ export { CapoPlugin, createHead, createHeadCore, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.d.ts CHANGED
@@ -1,52 +1,34 @@
1
- import * as _unhead_schema from '@unhead/schema';
2
- import { ScriptBase, DataKeys, SchemaAugmentations, HeadEntryOptions, MergeHead, CreateClientHeadOptions, ActiveHeadEntry } from '@unhead/schema';
3
- export { createHeadCore } from 'unhead';
4
- export { r as resolveUnrefHeadInput } from './shared/vue.BF-HCrO8.js';
5
- import { ResolvableProperties, UseHeadOptions } from '@unhead/vue';
6
- import { ScriptInstance, UseScriptStatus, UseScriptOptions as UseScriptOptions$1, UseFunctionType } from 'unhead/legacy';
7
- export { UseFunctionType, resolveScriptKey } from 'unhead/legacy';
8
- import { Ref } from 'vue';
9
- import { VueHeadClient, UseHeadInput, UseHeadOptions as UseHeadOptions$1, UseHeadSafeInput, UseSeoMetaInput } from './types.js';
1
+ import * as unhead_types from 'unhead/types';
2
+ import { CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
3
+ import { createUnhead } from 'unhead';
4
+ import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.C1egIkvG.js';
5
+ import { U as UseHeadSafeInput } from './shared/vue.A6QPXQyg.js';
6
+ import 'vue';
10
7
 
11
- interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
12
- status: Ref<UseScriptStatus>;
13
- }
14
- type UseScriptInput = string | (ResolvableProperties<Omit<ScriptBase & DataKeys & SchemaAugmentations['script'], 'src'>> & {
15
- src: string;
16
- });
17
- interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends Omit<HeadEntryOptions, 'head'>, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
18
- /**
19
- * The trigger to load the script:
20
- * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
21
- * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
22
- * - `Promise` - Load the script when the promise resolves, exists only on the client.
23
- * - `Function` - Register a callback function to load the script, exists only on the client.
24
- * - `server` - Have the script injected on the server.
25
- * - `ref` - Load the script when the ref is true.
26
- */
27
- trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
28
- /**
29
- * The Unhead instance to use.
30
- */
31
- head?: UseHeadOptions['head'];
32
- }
33
- type UseScriptContext<T extends Record<symbol | string, any>> = Promise<T> & VueScriptInstance<T>;
34
- type UseScriptReturn<T extends Record<symbol | string, any>> = UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
35
- declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
36
-
37
- declare const CapoPlugin: () => _unhead_schema.HeadPluginInput;
38
- declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
39
- declare function createServerHead<T extends MergeHead>(options?: CreateClientHeadOptions): VueHeadClient<T>;
8
+ declare const createHeadCore: typeof createUnhead;
9
+ declare function resolveUnrefHeadInput(input: any): any;
10
+ declare function CapoPlugin(): unhead_types.HeadPluginInput;
11
+ declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
12
+ declare function createServerHead(options?: CreateClientHeadOptions): VueHeadClient;
40
13
  /**
41
14
  * @deprecated Please switch to non-legacy version
42
15
  */
43
16
  declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
44
17
  declare function injectHead(): VueHeadClient<any> | undefined;
45
- declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadInput<T>> | void;
46
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<UseHeadSafeInput> | void;
47
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
48
- declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
49
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
50
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions$1): ActiveHeadEntry<any> | void;
18
+ declare function useHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput> | void;
19
+ declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
20
+ declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
21
+ /**
22
+ * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
23
+ */
24
+ declare function useServerHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
25
+ /**
26
+ * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
27
+ */
28
+ declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
29
+ /**
30
+ * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
31
+ */
32
+ declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
51
33
 
52
- export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptReturn, type VueScriptInstance, createHead, createServerHead, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
34
+ export { CapoPlugin, createHead, createHeadCore, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.mjs CHANGED
@@ -1,83 +1,24 @@
1
- import { defineHeadPlugin, whitelistSafeInput, unpackMeta } from '@unhead/shared';
2
- export { createHeadCore } from 'unhead';
3
- import { DeprecationsPlugin, PromisesPlugin } from 'unhead/plugins';
4
- import { getCurrentInstance, onMounted, isRef, watch, onScopeDispose, ref, inject, watchEffect, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
1
+ import { createUnhead } from 'unhead';
2
+ import { inject, ref, watchEffect, unref, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
5
3
  import { createHead as createHead$1 } from './client.mjs';
6
- import { h as headSymbol, r as resolveUnrefHeadInput } from './shared/vue.D2UzSD_b.mjs';
4
+ import { h as headSymbol } from './shared/vue.BYLJNEcq.mjs';
5
+ import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
7
6
  import { createHead as createHead$2 } from './server.mjs';
8
- import { useScript as useScript$1 } from 'unhead/legacy';
9
- export { resolveScriptKey } from 'unhead/legacy';
7
+ import { walkResolver } from 'unhead/utils';
8
+ import { defineHeadPlugin, DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin, SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
10
9
  import 'unhead/client';
11
- import './shared/vue.51u-UkLG.mjs';
12
- import './shared/vue.CNiRntV8.mjs';
10
+ import './shared/vue.nvpYXC6D.mjs';
13
11
  import 'unhead/server';
14
12
 
15
- function registerVueScopeHandlers(script, scope) {
16
- if (!scope) {
17
- return;
18
- }
19
- const _registerCb = (key, cb) => {
20
- if (!script._cbs[key]) {
21
- cb(script.instance);
22
- return () => {
23
- };
24
- }
25
- let i = script._cbs[key].push(cb);
26
- const destroy = () => {
27
- if (i) {
28
- script._cbs[key]?.splice(i - 1, 1);
29
- i = null;
30
- }
31
- };
32
- onScopeDispose(destroy);
33
- return destroy;
34
- };
35
- script.onLoaded = (cb) => _registerCb("loaded", cb);
36
- script.onError = (cb) => _registerCb("error", cb);
37
- onScopeDispose(() => {
38
- script._triggerAbortController?.abort();
39
- });
13
+ const createHeadCore = createUnhead;
14
+ function resolveUnrefHeadInput(input) {
15
+ return walkResolver(input, VueResolver);
40
16
  }
41
- function useScript(_input, _options) {
42
- const input = typeof _input === "string" ? { src: _input } : _input;
43
- const options = _options || {};
44
- const head = options?.head || injectHead();
45
- options.head = head;
46
- const scope = getCurrentInstance();
47
- options.eventContext = scope;
48
- if (scope && typeof options.trigger === "undefined") {
49
- options.trigger = onMounted;
50
- } else if (isRef(options.trigger)) {
51
- const refTrigger = options.trigger;
52
- let off;
53
- options.trigger = new Promise((resolve) => {
54
- off = watch(refTrigger, (val) => {
55
- if (val) {
56
- resolve(true);
57
- }
58
- }, {
59
- immediate: true
60
- });
61
- onScopeDispose(() => resolve(false), true);
62
- }).then((val) => {
63
- off?.();
64
- return val;
65
- });
66
- }
67
- head._scriptStatusWatcher = head._scriptStatusWatcher || head.hooks.hook("script:updated", ({ script: s }) => {
68
- s._statusRef.value = s.status;
69
- });
70
- const script = useScript$1(input, options);
71
- script._statusRef = script._statusRef || ref(script.status);
72
- registerVueScopeHandlers(script, scope);
73
- return new Proxy(script, {
74
- get(_, key, a) {
75
- return Reflect.get(_, key === "status" ? "_statusRef" : key, a);
76
- }
17
+ function CapoPlugin() {
18
+ return defineHeadPlugin({
19
+ key: "capo"
77
20
  });
78
21
  }
79
-
80
- const CapoPlugin = () => defineHeadPlugin({});
81
22
  function createHead(options = {}) {
82
23
  return createHead$1({
83
24
  disableCapoSorting: true,
@@ -85,6 +26,8 @@ function createHead(options = {}) {
85
26
  plugins: [
86
27
  DeprecationsPlugin,
87
28
  PromisesPlugin,
29
+ TemplateParamsPlugin,
30
+ AliasSortingPlugin,
88
31
  ...options.plugins || []
89
32
  ]
90
33
  });
@@ -96,6 +39,8 @@ function createServerHead(options = {}) {
96
39
  plugins: [
97
40
  DeprecationsPlugin,
98
41
  PromisesPlugin,
42
+ TemplateParamsPlugin,
43
+ AliasSortingPlugin,
99
44
  ...options.plugins || []
100
45
  ]
101
46
  });
@@ -115,7 +60,7 @@ function clientUseHead(head, input, options = {}) {
115
60
  const deactivated = ref(false);
116
61
  const resolvedInput = ref({});
117
62
  watchEffect(() => {
118
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
63
+ resolvedInput.value = deactivated.value ? {} : walkResolver(input, (v) => unref(v));
119
64
  });
120
65
  const entry = head.push(resolvedInput.value, options);
121
66
  watch(resolvedInput, (e) => {
@@ -136,27 +81,25 @@ function clientUseHead(head, input, options = {}) {
136
81
  return entry;
137
82
  }
138
83
  function useHeadSafe(input, options = {}) {
139
- return useHead(input, { ...options, transform: whitelistSafeInput });
84
+ const head = options.head || injectHead();
85
+ if (head) {
86
+ head.use(SafeInputPlugin);
87
+ options._safe = true;
88
+ return useHead(input, options);
89
+ }
140
90
  }
141
91
  function useSeoMeta(input, options) {
142
- const { title, titleTemplate, ...meta } = input;
143
- return useHead({
144
- title,
145
- titleTemplate,
146
- // @ts-expect-error runtime type
147
- _flatMeta: meta
148
- }, {
149
- ...options,
150
- transform(t) {
151
- const meta2 = unpackMeta({ ...t._flatMeta });
152
- delete t._flatMeta;
153
- return {
154
- // @ts-expect-error runtime type
155
- ...t,
156
- meta: meta2
157
- };
158
- }
159
- });
92
+ const head = options?.head || injectHead();
93
+ if (head) {
94
+ head.use(FlatMetaPlugin);
95
+ const { title, titleTemplate, ...meta } = input;
96
+ return useHead({
97
+ title,
98
+ titleTemplate,
99
+ // @ts-expect-error runtime type
100
+ _flatMeta: meta
101
+ }, options);
102
+ }
160
103
  }
161
104
  function useServerHead(input, options = {}) {
162
105
  return useHead(input, { ...options, mode: "server" });
@@ -168,4 +111,4 @@ function useServerSeoMeta(input, options) {
168
111
  return useSeoMeta(input, { ...options, mode: "server" });
169
112
  }
170
113
 
171
- export { CapoPlugin, createHead, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
114
+ export { CapoPlugin, createHead, createHeadCore, 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';
@@ -0,0 +1,32 @@
1
+ import { UseScriptOptions as UseScriptOptions$1, ScriptInstance, UseScriptStatus, UseFunctionType } from 'unhead/scripts';
2
+ import { ScriptWithoutEvents, DataKeys, SchemaAugmentations, HeadEntryOptions } from 'unhead/types';
3
+ import { Ref } from 'vue';
4
+ import { o as ResolvableProperties, V as VueHeadClient } from './shared/vue.C1egIkvG.mjs';
5
+
6
+ interface VueScriptInstance<T extends Record<symbol | string, any>> extends Omit<ScriptInstance<T>, 'status'> {
7
+ status: Ref<UseScriptStatus>;
8
+ }
9
+ type UseScriptInput = string | (ResolvableProperties<Omit<ScriptWithoutEvents & DataKeys & SchemaAugmentations['script'], 'src'>> & {
10
+ src: string;
11
+ });
12
+ interface UseScriptOptions<T extends Record<symbol | string, any> = Record<string, any>> extends Omit<HeadEntryOptions, 'head'>, Pick<UseScriptOptions$1<T>, 'use' | 'eventContext' | 'beforeInit'> {
13
+ /**
14
+ * The trigger to load the script:
15
+ * - `undefined` | `client` - (Default) Load the script on the client when this js is loaded.
16
+ * - `manual` - Load the script manually by calling `$script.load()`, exists only on the client.
17
+ * - `Promise` - Load the script when the promise resolves, exists only on the client.
18
+ * - `Function` - Register a callback function to load the script, exists only on the client.
19
+ * - `server` - Have the script injected on the server.
20
+ * - `ref` - Load the script when the ref is true.
21
+ */
22
+ trigger?: UseScriptOptions$1['trigger'] | Ref<boolean>;
23
+ /**
24
+ * Unhead instance.
25
+ */
26
+ head?: VueHeadClient<any>;
27
+ }
28
+ type UseScriptContext<T extends Record<symbol | string, any>> = VueScriptInstance<T>;
29
+ type UseScriptReturn<T extends Record<symbol | string, any>> = UseScriptContext<UseFunctionType<UseScriptOptions<T>, T>>;
30
+ declare function useScript<T extends Record<symbol | string, any> = Record<symbol | string, any>>(_input: UseScriptInput, _options?: UseScriptOptions<T>): UseScriptReturn<T>;
31
+
32
+ export { type UseScriptContext, type UseScriptInput, type UseScriptOptions, type UseScriptReturn, type VueScriptInstance, useScript };