@unhead/vue 2.0.0-alpha.1 → 2.0.0-alpha.11
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/client.d.mts +4 -7
- package/dist/client.d.ts +4 -7
- package/dist/client.mjs +8 -10
- package/dist/components.mjs +3 -2
- package/dist/index.d.mts +8 -18
- package/dist/index.d.ts +8 -18
- package/dist/index.mjs +7 -49
- package/dist/legacy.d.mts +25 -23
- package/dist/legacy.d.ts +25 -23
- package/dist/legacy.mjs +86 -35
- package/dist/server.d.mts +4 -7
- package/dist/server.d.ts +4 -7
- package/dist/server.mjs +6 -10
- package/dist/shared/vue.0vTsLwbU.mjs +87 -0
- package/dist/shared/{vue.O-w7-AFg.mjs → vue.BOii_fac.mjs} +1 -1
- package/dist/{shared/vue.B8gXlHM7.d.cts → types.d.mts} +32 -39
- package/dist/{shared/vue.B8gXlHM7.d.mts → types.d.ts} +32 -39
- package/dist/types.mjs +1 -0
- package/legacy.d.ts +1 -0
- package/package.json +29 -15
- package/types.d.ts +1 -0
- package/dist/client.cjs +0 -37
- package/dist/client.d.cts +0 -11
- package/dist/components.cjs +0 -65
- package/dist/components.d.cts +0 -5
- package/dist/index.cjs +0 -67
- package/dist/index.d.cts +0 -33
- package/dist/legacy.cjs +0 -168
- package/dist/legacy.d.cts +0 -51
- package/dist/server.cjs +0 -34
- package/dist/server.d.cts +0 -11
- package/dist/shared/vue.3OjaFlxQ.cjs +0 -20
- package/dist/shared/vue.B6jdKgLD.mjs +0 -13
- package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
- package/dist/shared/vue.BwEnMiRq.cjs +0 -91
- package/dist/shared/vue.DIPZN3-d.cjs +0 -15
- package/dist/shared/vue.DShwsPiO.d.cts +0 -194
- package/dist/shared/vue.DShwsPiO.d.mts +0 -194
- package/dist/shared/vue.DShwsPiO.d.ts +0 -194
- package/dist/shared/vue.DnywREVF.d.cts +0 -5
- package/dist/shared/vue.Sg4YunmP.mjs +0 -85
package/dist/index.cjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const shared = require('@unhead/shared');
|
|
4
|
-
const unhead = require('unhead');
|
|
5
|
-
const useHead = require('./shared/vue.BwEnMiRq.cjs');
|
|
6
|
-
const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
|
|
7
|
-
require('vue');
|
|
8
|
-
|
|
9
|
-
const coreComposableNames = [
|
|
10
|
-
"injectHead"
|
|
11
|
-
];
|
|
12
|
-
const unheadVueComposablesImports = {
|
|
13
|
-
"@unhead/vue": [...coreComposableNames, ...shared.composableNames]
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function useHeadSafe(input, options = {}) {
|
|
17
|
-
return useHead.useHead(input, { ...options, transform: shared.whitelistSafeInput });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function useSeoMeta(input, options) {
|
|
21
|
-
const { title, titleTemplate, ...meta } = input;
|
|
22
|
-
return useHead.useHead({
|
|
23
|
-
title,
|
|
24
|
-
titleTemplate,
|
|
25
|
-
// @ts-expect-error runtime type
|
|
26
|
-
_flatMeta: meta
|
|
27
|
-
}, {
|
|
28
|
-
...options,
|
|
29
|
-
transform(t) {
|
|
30
|
-
const meta2 = shared.unpackMeta({ ...t._flatMeta });
|
|
31
|
-
delete t._flatMeta;
|
|
32
|
-
return {
|
|
33
|
-
// @ts-expect-error runtime type
|
|
34
|
-
...t,
|
|
35
|
-
meta: meta2
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function useServerHead(input, options = {}) {
|
|
42
|
-
return useHead.useHead(input, { ...options, mode: "server" });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function useServerHeadSafe(input, options = {}) {
|
|
46
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function useServerSeoMeta(input, options) {
|
|
50
|
-
return useSeoMeta(input, { ...options, mode: "server" });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const CapoPlugin = () => shared.defineHeadPlugin({});
|
|
54
|
-
|
|
55
|
-
exports.createHeadCore = unhead.createHeadCore;
|
|
56
|
-
exports.unheadCtx = unhead.unheadCtx;
|
|
57
|
-
exports.injectHead = useHead.injectHead;
|
|
58
|
-
exports.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
|
|
59
|
-
exports.useHead = useHead.useHead;
|
|
60
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
61
|
-
exports.CapoPlugin = CapoPlugin;
|
|
62
|
-
exports.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
63
|
-
exports.useHeadSafe = useHeadSafe;
|
|
64
|
-
exports.useSeoMeta = useSeoMeta;
|
|
65
|
-
exports.useServerHead = useServerHead;
|
|
66
|
-
exports.useServerHeadSafe = useServerHeadSafe;
|
|
67
|
-
exports.useServerSeoMeta = useServerSeoMeta;
|
package/dist/index.d.cts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as _unhead_schema from '@unhead/schema';
|
|
2
|
-
import { Unhead, MergeHead, ActiveHeadEntry } from '@unhead/schema';
|
|
3
|
-
export { ActiveHeadEntry, Head, HeadEntryOptions, HeadTag, MergeHead, Unhead } from '@unhead/schema';
|
|
4
|
-
export { createHeadCore, unheadCtx } from 'unhead';
|
|
5
|
-
import { U as UseHeadInput, a as UseHeadOptions, b as UseHeadSafeInput, c as UseSeoMetaInput } from './shared/vue.B8gXlHM7.cjs';
|
|
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.cjs';
|
|
7
|
-
export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
|
|
8
|
-
import 'vue';
|
|
9
|
-
|
|
10
|
-
declare const unheadVueComposablesImports: {
|
|
11
|
-
'@unhead/vue': string[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
declare function injectHead(): Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | Unhead<_unhead_schema.Head<_unhead_schema.MergeHead>>;
|
|
15
|
-
|
|
16
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>>;
|
|
17
|
-
|
|
18
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any>;
|
|
19
|
-
|
|
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 };
|
package/dist/legacy.cjs
DELETED
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const shared = require('@unhead/shared');
|
|
4
|
-
const unhead = require('unhead');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const client = require('./client.cjs');
|
|
7
|
-
const useHead$1 = require('./shared/vue.BwEnMiRq.cjs');
|
|
8
|
-
const server = require('./server.cjs');
|
|
9
|
-
const legacy = require('unhead/legacy');
|
|
10
|
-
require('unhead/client');
|
|
11
|
-
require('./shared/vue.DIPZN3-d.cjs');
|
|
12
|
-
require('./shared/vue.3OjaFlxQ.cjs');
|
|
13
|
-
require('unhead/server');
|
|
14
|
-
|
|
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
|
-
vue.onScopeDispose(destroy);
|
|
33
|
-
return destroy;
|
|
34
|
-
};
|
|
35
|
-
script.onLoaded = (cb) => _registerCb("loaded", cb);
|
|
36
|
-
script.onError = (cb) => _registerCb("error", cb);
|
|
37
|
-
vue.onScopeDispose(() => {
|
|
38
|
-
script._triggerAbortController?.abort();
|
|
39
|
-
});
|
|
40
|
-
}
|
|
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 = vue.getCurrentInstance();
|
|
47
|
-
options.eventContext = scope;
|
|
48
|
-
if (scope && typeof options.trigger === "undefined") {
|
|
49
|
-
options.trigger = vue.onMounted;
|
|
50
|
-
} else if (vue.isRef(options.trigger)) {
|
|
51
|
-
const refTrigger = options.trigger;
|
|
52
|
-
let off;
|
|
53
|
-
options.trigger = new Promise((resolve) => {
|
|
54
|
-
off = vue.watch(refTrigger, (val) => {
|
|
55
|
-
if (val) {
|
|
56
|
-
resolve(true);
|
|
57
|
-
}
|
|
58
|
-
}, {
|
|
59
|
-
immediate: true
|
|
60
|
-
});
|
|
61
|
-
vue.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 = legacy.useScript(input, options);
|
|
71
|
-
script._statusRef = script._statusRef || vue.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
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const CapoPlugin = () => shared.defineHeadPlugin({});
|
|
81
|
-
function setHeadInjectionHandler(handler) {
|
|
82
|
-
unhead.unheadCtx.set(handler(), true);
|
|
83
|
-
}
|
|
84
|
-
function injectHead() {
|
|
85
|
-
const ctx = unhead.tryUseUnhead();
|
|
86
|
-
if (ctx) {
|
|
87
|
-
return ctx;
|
|
88
|
-
}
|
|
89
|
-
return vue.inject(useHead$1.headSymbol);
|
|
90
|
-
}
|
|
91
|
-
function useHead(input, options = {}) {
|
|
92
|
-
const head = options.head || injectHead();
|
|
93
|
-
if (head) {
|
|
94
|
-
return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function clientUseHead(head, input, options = {}) {
|
|
98
|
-
const deactivated = vue.ref(false);
|
|
99
|
-
const resolvedInput = vue.ref({});
|
|
100
|
-
vue.watchEffect(() => {
|
|
101
|
-
resolvedInput.value = deactivated.value ? {} : useHead$1.resolveUnrefHeadInput(input);
|
|
102
|
-
});
|
|
103
|
-
const entry = head.push(resolvedInput.value, options);
|
|
104
|
-
vue.watch(resolvedInput, (e) => {
|
|
105
|
-
entry.patch(e);
|
|
106
|
-
});
|
|
107
|
-
const vm = vue.getCurrentInstance();
|
|
108
|
-
if (vm) {
|
|
109
|
-
vue.onBeforeUnmount(() => {
|
|
110
|
-
entry.dispose();
|
|
111
|
-
});
|
|
112
|
-
vue.onDeactivated(() => {
|
|
113
|
-
deactivated.value = true;
|
|
114
|
-
});
|
|
115
|
-
vue.onActivated(() => {
|
|
116
|
-
deactivated.value = false;
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
return entry;
|
|
120
|
-
}
|
|
121
|
-
function useHeadSafe(input, options = {}) {
|
|
122
|
-
return useHead(input, { ...options, transform: shared.whitelistSafeInput });
|
|
123
|
-
}
|
|
124
|
-
function useSeoMeta(input, options) {
|
|
125
|
-
const { title, titleTemplate, ...meta } = input;
|
|
126
|
-
return useHead({
|
|
127
|
-
title,
|
|
128
|
-
titleTemplate,
|
|
129
|
-
// @ts-expect-error runtime type
|
|
130
|
-
_flatMeta: meta
|
|
131
|
-
}, {
|
|
132
|
-
...options,
|
|
133
|
-
transform(t) {
|
|
134
|
-
const meta2 = shared.unpackMeta({ ...t._flatMeta });
|
|
135
|
-
delete t._flatMeta;
|
|
136
|
-
return {
|
|
137
|
-
// @ts-expect-error runtime type
|
|
138
|
-
...t,
|
|
139
|
-
meta: meta2
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
function useServerHead(input, options = {}) {
|
|
145
|
-
return useHead(input, { ...options, mode: "server" });
|
|
146
|
-
}
|
|
147
|
-
function useServerHeadSafe(input, options = {}) {
|
|
148
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
149
|
-
}
|
|
150
|
-
function useServerSeoMeta(input, options) {
|
|
151
|
-
return useSeoMeta(input, { ...options, mode: "server" });
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
exports.createHeadCore = unhead.createHeadCore;
|
|
155
|
-
exports.createHead = client.createHead;
|
|
156
|
-
exports.resolveUnrefHeadInput = useHead$1.resolveUnrefHeadInput;
|
|
157
|
-
exports.createServerHead = server.createHead;
|
|
158
|
-
exports.resolveScriptKey = legacy.resolveScriptKey;
|
|
159
|
-
exports.CapoPlugin = CapoPlugin;
|
|
160
|
-
exports.injectHead = injectHead;
|
|
161
|
-
exports.setHeadInjectionHandler = setHeadInjectionHandler;
|
|
162
|
-
exports.useHead = useHead;
|
|
163
|
-
exports.useHeadSafe = useHeadSafe;
|
|
164
|
-
exports.useScript = useScript;
|
|
165
|
-
exports.useSeoMeta = useSeoMeta;
|
|
166
|
-
exports.useServerHead = useServerHead;
|
|
167
|
-
exports.useServerHeadSafe = useServerHeadSafe;
|
|
168
|
-
exports.useServerSeoMeta = useServerSeoMeta;
|
package/dist/legacy.d.cts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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.cjs';
|
|
4
|
-
export { r as resolveUnrefHeadInput } from './shared/vue.B8gXlHM7.cjs';
|
|
5
|
-
export { createHeadCore } from 'unhead';
|
|
6
|
-
export { createHead } from './client.cjs';
|
|
7
|
-
export { createHead as createServerHead } from './server.cjs';
|
|
8
|
-
import { d as distExports } from './shared/vue.DShwsPiO.cjs';
|
|
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.cjs';
|
|
13
|
-
import 'unhead/client';
|
|
14
|
-
import 'unhead/server';
|
|
15
|
-
import '@unhead/shared';
|
|
16
|
-
|
|
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;
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated Please switch to non-legacy version
|
|
41
|
-
*/
|
|
42
|
-
declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
|
|
43
|
-
declare function injectHead(): Unhead<_unhead_schema.Head<MergeHead>> | Unhead<_unhead_schema.Head<_unhead_schema.SchemaAugmentations>> | undefined;
|
|
44
|
-
declare function useHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput<T>> | void;
|
|
45
|
-
declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadSafeInput> | void;
|
|
46
|
-
declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
47
|
-
declare function useServerHead<T extends MergeHead>(input: UseHeadInput<T>, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
48
|
-
declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
49
|
-
declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
|
|
50
|
-
|
|
51
|
-
export { CapoPlugin, type UseScriptContext, type UseScriptInput, type UseScriptOptions, type VueScriptInstance, injectHead, setHeadInjectionHandler, useHead, useHeadSafe, useScript, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
|
package/dist/server.cjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const server = require('unhead/server');
|
|
4
|
-
const useHead = require('./shared/vue.BwEnMiRq.cjs');
|
|
5
|
-
const VueReactivityPlugin = require('./shared/vue.DIPZN3-d.cjs');
|
|
6
|
-
const VueHeadMixin = require('./shared/vue.3OjaFlxQ.cjs');
|
|
7
|
-
require('vue');
|
|
8
|
-
require('unhead');
|
|
9
|
-
require('@unhead/shared');
|
|
10
|
-
|
|
11
|
-
function createHead(options = {}) {
|
|
12
|
-
const head = server.createHead({
|
|
13
|
-
...options,
|
|
14
|
-
plugins: [
|
|
15
|
-
...options.plugins || [],
|
|
16
|
-
VueReactivityPlugin.VueReactivityPlugin
|
|
17
|
-
]
|
|
18
|
-
});
|
|
19
|
-
head.install = useHead.vueInstall(head);
|
|
20
|
-
return head;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
24
|
-
exports.createHead = createHead;
|
|
25
|
-
Object.prototype.hasOwnProperty.call(server, '__proto__') &&
|
|
26
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
27
|
-
Object.defineProperty(exports, '__proto__', {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
value: server['__proto__']
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
Object.keys(server).forEach(function (k) {
|
|
33
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = server[k];
|
|
34
|
-
});
|
package/dist/server.d.cts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MergeHead, CreateHeadOptions } from '@unhead/schema';
|
|
2
|
-
import { d as distExports } from './shared/vue.DShwsPiO.cjs';
|
|
3
|
-
export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
|
|
4
|
-
export * from 'unhead/server';
|
|
5
|
-
import '@unhead/shared';
|
|
6
|
-
import 'unhead';
|
|
7
|
-
import 'vue';
|
|
8
|
-
|
|
9
|
-
declare function createHead<T extends MergeHead>(options?: Omit<CreateHeadOptions, 'domDelayFn' | 'document'>): distExports.VueHeadClient<T>;
|
|
10
|
-
|
|
11
|
-
export { createHead };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const useHead = require('./vue.BwEnMiRq.cjs');
|
|
5
|
-
|
|
6
|
-
const VueHeadMixin = {
|
|
7
|
-
created() {
|
|
8
|
-
let source = false;
|
|
9
|
-
const instance = vue.getCurrentInstance();
|
|
10
|
-
if (!instance)
|
|
11
|
-
return;
|
|
12
|
-
const options = instance.type;
|
|
13
|
-
if (!options || !("head" in options))
|
|
14
|
-
return;
|
|
15
|
-
source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
|
|
16
|
-
source && useHead.useHead(source);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
exports.VueHeadMixin = VueHeadMixin;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineHeadPlugin } from '@unhead/shared';
|
|
2
|
-
import { r as resolveUnrefHeadInput } from './vue.Sg4YunmP.mjs';
|
|
3
|
-
|
|
4
|
-
const VueReactivityPlugin = defineHeadPlugin({
|
|
5
|
-
hooks: {
|
|
6
|
-
"entries:resolve": (ctx) => {
|
|
7
|
-
for (const entry of ctx.entries)
|
|
8
|
-
entry.resolvedInput = resolveUnrefHeadInput(entry.input);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export { VueReactivityPlugin as V };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { BaseHtmlAttr, MaybeArray, BaseBodyAttr, 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, MaybeEventFnHandlers, BodyEvents, MergeHead, HeadEntryOptions, MetaFlatInput, Unhead, SafeMeta, SafeLink, SafeNoscript, SafeScript, SafeHtmlAttr, SafeBodyAttr } from '@unhead/schema';
|
|
2
|
-
import { ComputedRef, Ref, Plugin } from 'vue';
|
|
3
|
-
|
|
4
|
-
declare function resolveUnrefHeadInput(ref: any): any;
|
|
5
|
-
|
|
6
|
-
type MaybeReadonlyRef<T> = ComputedRef<T>;
|
|
7
|
-
type MaybeComputedRef<T> = T | MaybeReadonlyRef<T> | Ref<T>;
|
|
8
|
-
type MaybeComputedRefOrFalsy<T> = T | MaybeReadonlyRef<T> | Ref<T>;
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated Use MaybeComputedRefOrFalsy
|
|
11
|
-
*/
|
|
12
|
-
type MaybeComputedRefOrPromise<T> = MaybeComputedRefOrFalsy<T>;
|
|
13
|
-
type MaybeComputedRefEntries<T> = MaybeComputedRef<T> | {
|
|
14
|
-
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
|
|
15
|
-
};
|
|
16
|
-
type MaybeComputedRefEntriesOnly<T> = {
|
|
17
|
-
[key in keyof T]?: MaybeComputedRefOrFalsy<T[key]>;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
interface HtmlAttr extends Omit<BaseHtmlAttr, 'class'> {
|
|
21
|
-
/**
|
|
22
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
23
|
-
*
|
|
24
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
25
|
-
*/
|
|
26
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
27
|
-
}
|
|
28
|
-
interface BodyAttr extends Omit<BaseBodyAttr, 'class' | 'style'> {
|
|
29
|
-
/**
|
|
30
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
31
|
-
*
|
|
32
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
33
|
-
*/
|
|
34
|
-
class?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<boolean>>;
|
|
35
|
-
/**
|
|
36
|
-
* The class global attribute is a space-separated list of the case-sensitive classes of the element.
|
|
37
|
-
*
|
|
38
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class
|
|
39
|
-
*/
|
|
40
|
-
style?: MaybeArray<MaybeComputedRef<string>> | Record<string, MaybeComputedRef<string | boolean>>;
|
|
41
|
-
}
|
|
42
|
-
type Title = MaybeComputedRef<Title$1>;
|
|
43
|
-
type TitleTemplate = TitleTemplate$1 | Ref<TitleTemplate$1> | ((title?: string) => TitleTemplate$1);
|
|
44
|
-
type Base<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<Base$1<E>>>;
|
|
45
|
-
type Link<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Link$1<E>>;
|
|
46
|
-
type Meta<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Meta$1<E>>;
|
|
47
|
-
type Style<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Style$1<E>>;
|
|
48
|
-
type Script<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Script$1<E>>;
|
|
49
|
-
type Noscript<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRefEntries<Noscript$1<E>>;
|
|
50
|
-
type HtmlAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<HtmlAttr & DataKeys & SchemaAugmentations['htmlAttrs'] & DefinedValueOrEmptyObject<E>>>;
|
|
51
|
-
type BodyAttributes<E extends EntryAugmentation = Record<string, any>> = MaybeComputedRef<MaybeComputedRefEntries<BodyAttr & DataKeys & SchemaAugmentations['bodyAttrs'] & DefinedValueOrEmptyObject<E>> & MaybeEventFnHandlers<BodyEvents>>;
|
|
52
|
-
interface ReactiveHead<E extends MergeHead = MergeHead> {
|
|
53
|
-
/**
|
|
54
|
-
* The `<title>` HTML element defines the document's title that is shown in a browser's title bar or a page's tab.
|
|
55
|
-
* It only contains text; tags within the element are ignored.
|
|
56
|
-
*
|
|
57
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/title
|
|
58
|
-
*/
|
|
59
|
-
title?: Title;
|
|
60
|
-
/**
|
|
61
|
-
* Generate the title from a template.
|
|
62
|
-
*/
|
|
63
|
-
titleTemplate?: TitleTemplate;
|
|
64
|
-
/**
|
|
65
|
-
* Variables used to substitute in the title and meta content.
|
|
66
|
-
*/
|
|
67
|
-
templateParams?: MaybeComputedRefEntries<{
|
|
68
|
-
separator?: '|' | '-' | '·' | string;
|
|
69
|
-
} & Record<string, null | string | MaybeComputedRefEntries<Record<string, null | string>>>>;
|
|
70
|
-
/**
|
|
71
|
-
* The `<base>` HTML element specifies the base URL to use for all relative URLs in a document.
|
|
72
|
-
* There can be only one <base> element in a document.
|
|
73
|
-
*
|
|
74
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
|
|
75
|
-
*/
|
|
76
|
-
base?: Base<E['base']>;
|
|
77
|
-
/**
|
|
78
|
-
* The `<link>` HTML element specifies relationships between the current document and an external resource.
|
|
79
|
-
* This element is most commonly used to link to stylesheets, but is also used to establish site icons
|
|
80
|
-
* (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
|
|
81
|
-
*
|
|
82
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
|
|
83
|
-
*/
|
|
84
|
-
link?: MaybeComputedRef<Link<E['link']>[]>;
|
|
85
|
-
/**
|
|
86
|
-
* The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
|
|
87
|
-
*
|
|
88
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
|
|
89
|
-
*/
|
|
90
|
-
meta?: MaybeComputedRef<Meta<E['meta']>[]>;
|
|
91
|
-
/**
|
|
92
|
-
* The `<style>` HTML element contains style information for a document, or part of a document.
|
|
93
|
-
* It contains CSS, which is applied to the contents of the document containing the `<style>` element.
|
|
94
|
-
*
|
|
95
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
|
|
96
|
-
*/
|
|
97
|
-
style?: MaybeComputedRef<(Style<E['style']> | string)[]>;
|
|
98
|
-
/**
|
|
99
|
-
* The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
|
|
100
|
-
*
|
|
101
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
|
|
102
|
-
*/
|
|
103
|
-
script?: MaybeComputedRef<(Script<E['script']> | string)[]>;
|
|
104
|
-
/**
|
|
105
|
-
* The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
|
|
106
|
-
* or if scripting is currently turned off in the browser.
|
|
107
|
-
*
|
|
108
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
|
|
109
|
-
*/
|
|
110
|
-
noscript?: MaybeComputedRef<(Noscript<E['noscript']> | string)[]>;
|
|
111
|
-
/**
|
|
112
|
-
* Attributes for the `<html>` HTML element.
|
|
113
|
-
*
|
|
114
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
|
|
115
|
-
*/
|
|
116
|
-
htmlAttrs?: HtmlAttributes<E['htmlAttrs']>;
|
|
117
|
-
/**
|
|
118
|
-
* Attributes for the `<body>` HTML element.
|
|
119
|
-
*
|
|
120
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
|
|
121
|
-
*/
|
|
122
|
-
bodyAttrs?: BodyAttributes<E['bodyAttrs']>;
|
|
123
|
-
}
|
|
124
|
-
type UseHeadOptions = Omit<HeadEntryOptions, 'head'> & {
|
|
125
|
-
head?: VueHeadClient<any>;
|
|
126
|
-
};
|
|
127
|
-
type UseHeadInput<T extends MergeHead = Record<string, any>> = MaybeComputedRef<ReactiveHead<T>>;
|
|
128
|
-
type UseSeoMetaInput = MaybeComputedRefEntriesOnly<MetaFlatInput> & {
|
|
129
|
-
title?: ReactiveHead['title'];
|
|
130
|
-
titleTemplate?: ReactiveHead['titleTemplate'];
|
|
131
|
-
};
|
|
132
|
-
type VueHeadClient<T extends MergeHead> = Unhead<MaybeComputedRef<ReactiveHead<T>>> & Plugin;
|
|
133
|
-
|
|
134
|
-
interface HeadSafe extends Pick<ReactiveHead, 'title' | 'titleTemplate' | 'templateParams'> {
|
|
135
|
-
meta?: MaybeComputedRefEntries<SafeMeta>[];
|
|
136
|
-
link?: MaybeComputedRefEntries<SafeLink>[];
|
|
137
|
-
noscript?: MaybeComputedRefEntries<SafeNoscript>[];
|
|
138
|
-
script?: MaybeComputedRefEntries<SafeScript>[];
|
|
139
|
-
htmlAttrs?: MaybeComputedRefEntries<SafeHtmlAttr>;
|
|
140
|
-
bodyAttrs?: MaybeComputedRefEntries<SafeBodyAttr>;
|
|
141
|
-
}
|
|
142
|
-
type UseHeadSafeInput = MaybeComputedRef<HeadSafe>;
|
|
143
|
-
|
|
144
|
-
export { type BodyAttr as B, type HeadSafe as H, type Link as L, type Meta as M, type Noscript as N, type ReactiveHead as R, type Style as S, type Title as T, type UseHeadInput as U, type VueHeadClient as V, type UseHeadOptions as a, type UseHeadSafeInput as b, type UseSeoMetaInput as c, type HtmlAttr as d, type TitleTemplate as e, type Base as f, type Script as g, type HtmlAttributes as h, type BodyAttributes as i, type MaybeReadonlyRef as j, type MaybeComputedRef as k, type MaybeComputedRefOrFalsy as l, type MaybeComputedRefOrPromise as m, type MaybeComputedRefEntries as n, type MaybeComputedRefEntriesOnly as o, resolveUnrefHeadInput as r };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const unhead = require('unhead');
|
|
5
|
-
|
|
6
|
-
function resolveUnref(r) {
|
|
7
|
-
return typeof r === "function" ? r() : vue.unref(r);
|
|
8
|
-
}
|
|
9
|
-
function resolveUnrefHeadInput(ref) {
|
|
10
|
-
if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
|
|
11
|
-
return ref;
|
|
12
|
-
const root = resolveUnref(ref);
|
|
13
|
-
if (!ref || !root)
|
|
14
|
-
return root;
|
|
15
|
-
if (Array.isArray(root))
|
|
16
|
-
return root.map((r) => resolveUnrefHeadInput(r));
|
|
17
|
-
if (typeof root === "object") {
|
|
18
|
-
const resolved = {};
|
|
19
|
-
for (const k in root) {
|
|
20
|
-
if (!Object.prototype.hasOwnProperty.call(root, k)) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
|
|
24
|
-
resolved[k] = vue.unref(root[k]);
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
resolved[k] = resolveUnrefHeadInput(root[k]);
|
|
28
|
-
}
|
|
29
|
-
return resolved;
|
|
30
|
-
}
|
|
31
|
-
return root;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const headSymbol = "usehead";
|
|
35
|
-
function vueInstall(head) {
|
|
36
|
-
const plugin = {
|
|
37
|
-
install(app) {
|
|
38
|
-
app.config.globalProperties.$unhead = head;
|
|
39
|
-
app.config.globalProperties.$head = head;
|
|
40
|
-
app.provide(headSymbol, head);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
return plugin.install;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function injectHead() {
|
|
47
|
-
const ctx = unhead.tryUseUnhead();
|
|
48
|
-
if (ctx) {
|
|
49
|
-
return ctx;
|
|
50
|
-
}
|
|
51
|
-
const instance = vue.inject(headSymbol);
|
|
52
|
-
if (!instance) {
|
|
53
|
-
throw new Error("useHead() was called without provide context, ensure you call it through the setup() function.");
|
|
54
|
-
}
|
|
55
|
-
return instance;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function useHead(input, options = {}) {
|
|
59
|
-
const head = options.head || injectHead();
|
|
60
|
-
return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
|
|
61
|
-
}
|
|
62
|
-
function clientUseHead(head, input, options = {}) {
|
|
63
|
-
const deactivated = vue.ref(false);
|
|
64
|
-
const resolvedInput = vue.ref({});
|
|
65
|
-
vue.watchEffect(() => {
|
|
66
|
-
resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
|
|
67
|
-
});
|
|
68
|
-
const entry = head.push(resolvedInput.value, options);
|
|
69
|
-
vue.watch(resolvedInput, (e) => {
|
|
70
|
-
entry.patch(e);
|
|
71
|
-
});
|
|
72
|
-
const vm = vue.getCurrentInstance();
|
|
73
|
-
if (vm) {
|
|
74
|
-
vue.onBeforeUnmount(() => {
|
|
75
|
-
entry.dispose();
|
|
76
|
-
});
|
|
77
|
-
vue.onDeactivated(() => {
|
|
78
|
-
deactivated.value = true;
|
|
79
|
-
});
|
|
80
|
-
vue.onActivated(() => {
|
|
81
|
-
deactivated.value = false;
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return entry;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
exports.headSymbol = headSymbol;
|
|
88
|
-
exports.injectHead = injectHead;
|
|
89
|
-
exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
|
|
90
|
-
exports.useHead = useHead;
|
|
91
|
-
exports.vueInstall = vueInstall;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const shared = require('@unhead/shared');
|
|
4
|
-
const useHead = require('./vue.BwEnMiRq.cjs');
|
|
5
|
-
|
|
6
|
-
const VueReactivityPlugin = shared.defineHeadPlugin({
|
|
7
|
-
hooks: {
|
|
8
|
-
"entries:resolve": (ctx) => {
|
|
9
|
-
for (const entry of ctx.entries)
|
|
10
|
-
entry.resolvedInput = useHead.resolveUnrefHeadInput(entry.input);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
exports.VueReactivityPlugin = VueReactivityPlugin;
|