@unhead/vue 0.0.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -13
- package/dist/index.mjs +20 -74
- package/dist/runtime/server/useHead.d.ts +1 -1
- package/dist/runtime/server/useServerHead.d.ts +1 -1
- package/dist/runtimes/client/useHead.d.ts +1 -1
- package/dist/runtimes/client/useHead.mjs +1 -1
- package/dist/runtimes/client/useServerHead.d.ts +1 -1
- package/package.json +6 -5
- package/dist/runtime/alias/composables.d.ts +0 -14
- package/dist/runtime/alias/composables.mjs +0 -14
- package/dist/runtime/alias/index.d.ts +0 -1
- package/dist/runtime/alias/index.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import { MaybeComputedRef, MaybeRef } from '@vueuse/shared';
|
|
2
2
|
import * as _unhead_schema from '@unhead/schema';
|
|
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';
|
|
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, DataKeys, SchemaAugmentations, DefinedValueOrEmptyObject, MergeHead, BaseHtmlAttr, MaybeArray, BaseBodyAttr, HeadEntryOptions, HeadClient, CreateHeadOptions } from '@unhead/schema';
|
|
4
4
|
export { HeadTag, MergeHead } from '@unhead/schema';
|
|
5
|
-
import { DataKeys, DefinedValueOrEmptyObject } from '@zhead/schema';
|
|
6
|
-
import * as unhead from 'unhead';
|
|
7
|
-
import { HeadEntryOptions, Arrayable, HeadClient, CreateHeadOptions } from 'unhead';
|
|
8
|
-
import * as vue from 'vue';
|
|
9
5
|
import { Plugin, InjectionKey } from 'vue';
|
|
10
|
-
export
|
|
11
|
-
export { renderSSRHead } from 'unhead/server';
|
|
6
|
+
export * from '@unhead/dom';
|
|
12
7
|
|
|
13
8
|
declare type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
|
|
14
9
|
[key in keyof T]?: MaybeComputedRef<T[key]>;
|
|
15
10
|
};
|
|
11
|
+
declare type Arrayable<T> = T | Array<T>;
|
|
16
12
|
|
|
17
13
|
interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
|
|
18
14
|
/**
|
|
@@ -109,8 +105,9 @@ interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
|
109
105
|
declare type UseHeadInput = MaybeComputedRef<ReactiveHead>;
|
|
110
106
|
|
|
111
107
|
declare function resolveUnrefHeadInput(ref: any): any;
|
|
108
|
+
declare function asArray<T>(value: Arrayable<T>): T[];
|
|
112
109
|
|
|
113
|
-
declare const VueReactiveInputPlugin:
|
|
110
|
+
declare const VueReactiveInputPlugin: () => _unhead_schema.HeadPlugin;
|
|
114
111
|
|
|
115
112
|
declare function useServerHead(input: ReactiveHead, options?: HeadEntryOptions): void;
|
|
116
113
|
declare function useHead(input: UseHeadInput, options?: HeadEntryOptions): void;
|
|
@@ -125,14 +122,11 @@ declare const useBase: (base: ReactiveHead['base']) => void;
|
|
|
125
122
|
declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => void;
|
|
126
123
|
declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => void;
|
|
127
124
|
|
|
128
|
-
declare type Props = Readonly<Record<string, any>>;
|
|
129
|
-
declare const Head: vue.DefineComponent<{}, () => null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<vue.ExtractPropTypes<{}>>, {}>;
|
|
130
|
-
|
|
131
125
|
declare type VueHeadClient = HeadClient<UseHeadInput> & Plugin;
|
|
132
126
|
declare const headSymbol: InjectionKey<VueHeadClient>;
|
|
133
127
|
declare function injectHead(): VueHeadClient;
|
|
134
|
-
declare function createHead
|
|
128
|
+
declare function createHead(options?: CreateHeadOptions): VueHeadClient;
|
|
135
129
|
|
|
136
130
|
declare const HeadVuePlugin: Plugin;
|
|
137
131
|
|
|
138
|
-
export { Base, BodyAttributes,
|
|
132
|
+
export { Arrayable, Base, BodyAttributes, HeadVuePlugin, HtmlAttributes, Link, MaybeComputedRefEntries, Meta, Noscript, ReactiveHead, Script, Style, Title, TitleTemplate, UseHeadInput, VueHeadClient, VueReactiveInputPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { resolveUnref } from '@vueuse/shared';
|
|
2
|
-
import { unref, version, getCurrentInstance, ref, watchEffect, watch, nextTick, onBeforeUnmount,
|
|
3
|
-
import { defineHeadPlugin,
|
|
4
|
-
import { debouncedRenderDOMHead } from 'unhead/
|
|
5
|
-
export
|
|
6
|
-
export { renderSSRHead } from 'unhead/server';
|
|
7
|
-
export { HeadTag, MergeHead } from '@unhead/schema';
|
|
2
|
+
import { unref, version, getCurrentInstance, ref, watchEffect, watch, nextTick, onBeforeUnmount, inject } from 'vue';
|
|
3
|
+
import { defineHeadPlugin, getActiveHead, createHead as createHead$1, HydratesStatePlugin } from 'unhead';
|
|
4
|
+
import { debouncedRenderDOMHead } from '@unhead/dom';
|
|
5
|
+
export * from '@unhead/dom';
|
|
8
6
|
|
|
9
7
|
function resolveUnrefHeadInput(ref) {
|
|
10
8
|
const root = resolveUnref(ref);
|
|
@@ -23,18 +21,23 @@ function resolveUnrefHeadInput(ref) {
|
|
|
23
21
|
}
|
|
24
22
|
return root;
|
|
25
23
|
}
|
|
24
|
+
function asArray(value) {
|
|
25
|
+
return Array.isArray(value) ? value : [value];
|
|
26
|
+
}
|
|
26
27
|
|
|
27
|
-
const VueReactiveInputPlugin =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
entry
|
|
28
|
+
const VueReactiveInputPlugin = () => {
|
|
29
|
+
return defineHeadPlugin({
|
|
30
|
+
hooks: {
|
|
31
|
+
"entries:resolve": function(ctx) {
|
|
32
|
+
for (const entry of ctx.entries)
|
|
33
|
+
entry.input = resolveUnrefHeadInput(entry.input);
|
|
34
|
+
}
|
|
32
35
|
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
35
38
|
|
|
36
39
|
const Vue3 = version.startsWith("3");
|
|
37
|
-
|
|
40
|
+
version.startsWith("2.");
|
|
38
41
|
const IsClient = typeof window !== "undefined";
|
|
39
42
|
|
|
40
43
|
function useHead$2(input, options = {}) {
|
|
@@ -91,63 +94,6 @@ const useBase = (base) => useHead({ base });
|
|
|
91
94
|
const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
92
95
|
const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
93
96
|
|
|
94
|
-
const addVNodeToHeadObj = (node, obj) => {
|
|
95
|
-
const nodeType = Vue2 ? node.tag : node.type;
|
|
96
|
-
const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
|
|
97
|
-
if (typeof type !== "string" || !(type in obj))
|
|
98
|
-
return;
|
|
99
|
-
const nodeData = Vue2 ? node.data : node;
|
|
100
|
-
const props = (Vue2 ? nodeData.attrs : node.props) || {};
|
|
101
|
-
if (Vue2) {
|
|
102
|
-
if (nodeData.staticClass)
|
|
103
|
-
props.class = nodeData.staticClass;
|
|
104
|
-
if (nodeData.staticStyle)
|
|
105
|
-
props.style = Object.entries(nodeData.staticStyle).map(([key, value]) => `${key}:${value}`).join(";");
|
|
106
|
-
}
|
|
107
|
-
if (node.children) {
|
|
108
|
-
const childrenAttr = Vue2 ? "text" : "children";
|
|
109
|
-
props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
|
|
110
|
-
}
|
|
111
|
-
if (Array.isArray(obj[type])) {
|
|
112
|
-
obj[type].push(props);
|
|
113
|
-
} else if (type === "title") {
|
|
114
|
-
obj.title = props.children;
|
|
115
|
-
} else {
|
|
116
|
-
obj[type] = props;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const vnodesToHeadObj = (nodes) => {
|
|
120
|
-
const obj = {
|
|
121
|
-
title: void 0,
|
|
122
|
-
htmlAttrs: void 0,
|
|
123
|
-
bodyAttrs: void 0,
|
|
124
|
-
base: void 0,
|
|
125
|
-
meta: [],
|
|
126
|
-
link: [],
|
|
127
|
-
style: [],
|
|
128
|
-
script: [],
|
|
129
|
-
noscript: []
|
|
130
|
-
};
|
|
131
|
-
for (const node of nodes) {
|
|
132
|
-
if (typeof node.type === "symbol" && Array.isArray(node.children)) {
|
|
133
|
-
for (const childNode of node.children)
|
|
134
|
-
addVNodeToHeadObj(childNode, obj);
|
|
135
|
-
} else {
|
|
136
|
-
addVNodeToHeadObj(node, obj);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return obj;
|
|
140
|
-
};
|
|
141
|
-
const Head = /* @__PURE__ */ defineComponent({
|
|
142
|
-
name: "Head",
|
|
143
|
-
setup(_, { slots }) {
|
|
144
|
-
return () => {
|
|
145
|
-
useHead(() => vnodesToHeadObj(slots.default()));
|
|
146
|
-
return null;
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
|
|
151
97
|
const headSymbol = Symbol("head");
|
|
152
98
|
function injectHead() {
|
|
153
99
|
return getCurrentInstance() && inject(headSymbol) || getActiveHead();
|
|
@@ -156,8 +102,8 @@ function createHead(options = {}) {
|
|
|
156
102
|
const head = createHead$1({
|
|
157
103
|
...options,
|
|
158
104
|
plugins: [
|
|
159
|
-
HydratesStatePlugin,
|
|
160
|
-
VueReactiveInputPlugin,
|
|
105
|
+
HydratesStatePlugin(),
|
|
106
|
+
VueReactiveInputPlugin(),
|
|
161
107
|
...options?.plugins || []
|
|
162
108
|
]
|
|
163
109
|
});
|
|
@@ -209,4 +155,4 @@ const HeadVuePlugin = function(_Vue) {
|
|
|
209
155
|
});
|
|
210
156
|
};
|
|
211
157
|
|
|
212
|
-
export {
|
|
158
|
+
export { HeadVuePlugin, VueReactiveInputPlugin, asArray, createHead, headSymbol, injectHead, resolveUnrefHeadInput, useBase, useBodyAttrs, useHead, useHtmlAttrs, useLink, useMeta, useNoscript, useScript, useServerHead, useStyle, useTitle, useTitleTemplate };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCurrentInstance, nextTick, onBeforeUnmount, ref, watch, watchEffect } from "vue";
|
|
2
|
-
import { debouncedRenderDOMHead } from "unhead/
|
|
2
|
+
import { debouncedRenderDOMHead } from "@unhead/dom";
|
|
3
3
|
import { injectHead, resolveUnrefHeadInput } from "../../index";
|
|
4
4
|
export function useHead(input, options = {}) {
|
|
5
5
|
const head = injectHead();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"packageManager": "pnpm@7.14.0",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,16 +31,17 @@
|
|
|
31
31
|
"vue": ">=2.7 || >=3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@unhead/
|
|
34
|
+
"@unhead/dom": "0.1.1",
|
|
35
|
+
"@unhead/schema": "0.1.1",
|
|
35
36
|
"@vueuse/shared": "latest",
|
|
36
|
-
"
|
|
37
|
-
"unhead": "0.0.7"
|
|
37
|
+
"unhead": "0.1.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"vue": "latest"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "unbuild .",
|
|
44
|
-
"stub": "unbuild . --stub"
|
|
44
|
+
"stub": "unbuild . --stub",
|
|
45
|
+
"export:sizes": "npx export-size . -r"
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Arrayable, HeadEntryOptions } from 'unhead';
|
|
2
|
-
import type { Link, Meta, Noscript, ReactiveHead, Script, Style, UseHeadInput } from '../../types';
|
|
3
|
-
export declare const useServerHead: (input: UseHeadInput, options?: HeadEntryOptions) => any;
|
|
4
|
-
export declare const useHead: (input: UseHeadInput, options?: HeadEntryOptions) => any;
|
|
5
|
-
export declare const useTitle: (title: ReactiveHead['title']) => any;
|
|
6
|
-
export declare const useTitleTemplate: (titleTemplate: ReactiveHead['titleTemplate']) => any;
|
|
7
|
-
export declare const useMeta: (meta: Arrayable<Meta>) => any;
|
|
8
|
-
export declare const useLink: (link: Arrayable<Link>) => any;
|
|
9
|
-
export declare const useScript: (script: Arrayable<Script>) => any;
|
|
10
|
-
export declare const useStyle: (style: Arrayable<Style>) => any;
|
|
11
|
-
export declare const useNoscript: (noscript: Arrayable<Noscript>) => any;
|
|
12
|
-
export declare const useBase: (base: ReactiveHead['base']) => any;
|
|
13
|
-
export declare const useHtmlAttrs: (attrs: ReactiveHead['htmlAttrs']) => any;
|
|
14
|
-
export declare const useBodyAttrs: (attrs: ReactiveHead['bodyAttrs']) => any;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { asArray } from "unhead";
|
|
2
|
-
import { useHead as _useHead, useServerHead as _useServerHead } from "#head-runtime";
|
|
3
|
-
export const useServerHead = (input, options = {}) => _useServerHead(input, options);
|
|
4
|
-
export const useHead = (input, options = {}) => _useHead(input, options);
|
|
5
|
-
export const useTitle = (title) => useHead({ title });
|
|
6
|
-
export const useTitleTemplate = (titleTemplate) => useHead({ titleTemplate });
|
|
7
|
-
export const useMeta = (meta) => useHead({ meta: asArray(meta) });
|
|
8
|
-
export const useLink = (link) => useHead({ link: asArray(link) });
|
|
9
|
-
export const useScript = (script) => useHead({ script: asArray(script) });
|
|
10
|
-
export const useStyle = (style) => useHead({ style: asArray(style) });
|
|
11
|
-
export const useNoscript = (noscript) => useHead({ noscript: asArray(noscript) });
|
|
12
|
-
export const useBase = (base) => useHead({ base });
|
|
13
|
-
export const useHtmlAttrs = (attrs) => useHead({ htmlAttrs: attrs });
|
|
14
|
-
export const useBodyAttrs = (attrs) => useHead({ bodyAttrs: attrs });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './composables';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./composables.mjs";
|