@unhead/vue 0.0.2 → 0.0.5

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.
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { MaybeComputedRef, MaybeRef } from '@vueuse/shared';
2
2
  import * as _unhead_schema from '@unhead/schema';
3
3
  import { Title as Title$1, TitleTemplate as TitleTemplate$1, EntryAugmentation, Base as Base$1, Link as Link$1, Meta as Meta$1, Style as Style$1, Script as Script$1, Noscript as Noscript$1, SchemaAugmentations, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr } from '@unhead/schema';
4
+ export { HeadTag, MergeHead } from '@unhead/schema';
4
5
  import { DataKeys, DefinedValueOrEmptyObject } from '@zhead/schema';
5
6
  import * as unhead from 'unhead';
6
- import { HeadEntryOptions, Arrayable, HeadClient } from 'unhead';
7
- import { InjectionKey, Plugin } from 'vue';
7
+ import { HeadEntryOptions, Arrayable, HeadClient, CreateHeadOptions } from 'unhead';
8
+ import { Plugin, InjectionKey } from 'vue';
9
+ export { debouncedRenderDOMHead, renderDOMHead } from 'unhead/client';
10
+ export { renderSSRHead } from 'unhead/server';
8
11
 
9
12
  declare type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
10
13
  [key in keyof T]?: MaybeComputedRef<T[key]>;
@@ -121,9 +124,11 @@ declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
121
124
  declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
122
125
 
123
126
  declare const Vue3: boolean;
124
- declare type VueHeadClient = HeadClient<ReactiveHead>;
127
+ declare type VueHeadClient = HeadClient<ReactiveHead> & Plugin;
125
128
  declare const headSymbol: InjectionKey<VueHeadClient>;
126
129
  declare function injectHead(): VueHeadClient;
127
- declare function createHead(): HeadClient<ReactiveHead> & Plugin;
130
+ declare function createHead<T>(options: CreateHeadOptions<T>): VueHeadClient;
128
131
 
129
- export { Base, BodyAttributes, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, Vue3, VueHeadClient, VueReactiveInputPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
132
+ declare const HeadVuePlugin: Plugin;
133
+
134
+ export { Base, BodyAttributes, HeadVuePlugin, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, Vue3, VueHeadClient, VueReactiveInputPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
package/dist/index.mjs CHANGED
@@ -2,6 +2,9 @@ import { resolveUnref } from '@vueuse/shared';
2
2
  import { unref, getCurrentInstance, ref, watchEffect, watch, nextTick, onBeforeUnmount, version, inject } from 'vue';
3
3
  import { defineHeadPlugin, asArray, getActiveHead, createHead as createHead$1, HydratesStatePlugin } from 'unhead';
4
4
  import { debouncedRenderDOMHead } from 'unhead/client';
5
+ export { debouncedRenderDOMHead, renderDOMHead } from 'unhead/client';
6
+ export { renderSSRHead } from 'unhead/server';
7
+ export { HeadTag, MergeHead } from '@unhead/schema';
5
8
 
6
9
  function resolveUnrefHeadInput(ref) {
7
10
  const root = resolveUnref(ref);
@@ -91,11 +94,13 @@ const headSymbol = Symbol("head");
91
94
  function injectHead() {
92
95
  return getCurrentInstance() && inject(headSymbol) || getActiveHead();
93
96
  }
94
- function createHead() {
97
+ function createHead(options) {
95
98
  const head = createHead$1({
99
+ ...options,
96
100
  plugins: [
97
101
  HydratesStatePlugin,
98
- VueReactiveInputPlugin
102
+ VueReactiveInputPlugin,
103
+ ...options.plugins || []
99
104
  ]
100
105
  });
101
106
  const vuePlugin = {
@@ -108,10 +113,10 @@ function createHead() {
108
113
  const instance = getCurrentInstance();
109
114
  if (!instance)
110
115
  return;
111
- const options = instance.type;
112
- if (!options || !("head" in options))
116
+ const options2 = instance.type;
117
+ if (!options2 || !("head" in options2))
113
118
  return;
114
- const source = typeof options.head === "function" ? () => options.head() : options.head;
119
+ const source = typeof options2.head === "function" ? () => options2.head() : options2.head;
115
120
  head.push(source);
116
121
  }
117
122
  });
@@ -120,4 +125,30 @@ function createHead() {
120
125
  return { ...vuePlugin, ...head };
121
126
  }
122
127
 
123
- export { Vue3, VueReactiveInputPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
128
+ const HeadVuePlugin = function(_Vue) {
129
+ _Vue.mixin({
130
+ beforeCreate() {
131
+ const options = this.$options;
132
+ if (options.head) {
133
+ const origProvide = options.provide;
134
+ options.provide = function() {
135
+ let origProvideResult;
136
+ if (typeof origProvide === "function")
137
+ origProvideResult = origProvide.call(this);
138
+ else
139
+ origProvideResult = origProvide || {};
140
+ return {
141
+ ...origProvideResult,
142
+ [headSymbol]: options.head
143
+ };
144
+ };
145
+ if (!this.$head)
146
+ this.$head = options.head;
147
+ } else if (!this.$head && options.parent && options.parent.$head) {
148
+ this.$head = options.parent.$head;
149
+ }
150
+ }
151
+ });
152
+ };
153
+
154
+ export { HeadVuePlugin, Vue3, VueReactiveInputPlugin, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "0.0.2",
4
+ "version": "0.0.5",
5
5
  "packageManager": "pnpm@7.14.0",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  "vue": ">=2.7 || >=3"
32
32
  },
33
33
  "dependencies": {
34
- "@unhead/schema": "0.0.2",
34
+ "@unhead/schema": "0.0.5",
35
35
  "@vueuse/shared": "latest",
36
36
  "@zhead/schema": "^1.0.0-beta.4",
37
- "unhead": "0.0.2"
37
+ "unhead": "0.0.5"
38
38
  },
39
39
  "devDependencies": {
40
40
  "vue": "latest"