@unhead/vue 2.0.0-alpha.2 → 2.0.0-alpha.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.mts +4 -6
- package/dist/client.d.ts +4 -6
- package/dist/client.mjs +9 -12
- package/dist/components.mjs +8 -5
- package/dist/index.d.mts +18 -22
- package/dist/index.d.ts +18 -22
- package/dist/index.mjs +9 -47
- package/dist/legacy.d.mts +12 -39
- package/dist/legacy.d.ts +12 -39
- package/dist/legacy.mjs +56 -91
- package/dist/plugins.d.mts +1 -0
- package/dist/plugins.d.ts +1 -0
- package/dist/plugins.mjs +1 -0
- package/dist/server.d.mts +4 -6
- package/dist/server.d.ts +4 -6
- package/dist/server.mjs +7 -9
- package/dist/shared/{vue.B8gXlHM7.d.cts → vue.C97gXjQS.d.mts} +39 -50
- package/dist/shared/{vue.B8gXlHM7.d.mts → vue.C97gXjQS.d.ts} +39 -50
- package/dist/shared/{vue.BqrzivMs.mjs → vue.DBXhY4KI.mjs} +1 -1
- package/dist/shared/vue.N9zWjxoK.mjs +7 -0
- package/dist/shared/vue.j4SPrdI5.mjs +84 -0
- package/dist/types.d.mts +66 -0
- package/dist/types.d.ts +66 -0
- package/dist/types.mjs +1 -0
- package/dist/utils.d.mts +11 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.mjs +10 -0
- package/legacy.d.ts +1 -0
- package/package.json +41 -15
- package/plugins.d.ts +1 -0
- package/types.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/dist/client.cjs +0 -36
- package/dist/client.d.cts +0 -11
- package/dist/components.cjs +0 -64
- package/dist/components.d.cts +0 -5
- package/dist/index.cjs +0 -66
- package/dist/index.d.cts +0 -33
- package/dist/legacy.cjs +0 -163
- package/dist/legacy.d.cts +0 -51
- package/dist/server.cjs +0 -33
- package/dist/server.d.cts +0 -11
- package/dist/shared/vue.Adq3bKYb.cjs +0 -89
- package/dist/shared/vue.B8gXlHM7.d.ts +0 -144
- package/dist/shared/vue.BFi59n5j.cjs +0 -15
- package/dist/shared/vue.Bjx6RvLp.d.cts +0 -191
- package/dist/shared/vue.Bjx6RvLp.d.mts +0 -191
- package/dist/shared/vue.Bjx6RvLp.d.ts +0 -191
- package/dist/shared/vue.BmaKl8wu.mjs +0 -13
- package/dist/shared/vue.DTOQraae.cjs +0 -20
- package/dist/shared/vue.DUgB2y83.mjs +0 -83
- package/dist/shared/vue.DnywREVF.d.cts +0 -5
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { walkResolver } from 'unhead/utils';
|
|
2
|
+
export * from 'unhead/utils';
|
|
3
|
+
import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
|
|
4
|
+
import 'vue';
|
|
5
|
+
|
|
6
|
+
function resolveUnrefHeadInput(input) {
|
|
7
|
+
return walkResolver(input, VueResolver);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { VueResolver, resolveUnrefHeadInput };
|
package/legacy.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/legacy'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-alpha.
|
|
4
|
+
"version": "2.0.0-alpha.21",
|
|
5
5
|
"description": "Full-stack <head> manager built for Vue.",
|
|
6
6
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -23,26 +23,38 @@
|
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"import": "./dist/index.mjs"
|
|
27
|
-
"require": "./dist/index.cjs"
|
|
26
|
+
"import": "./dist/index.mjs"
|
|
28
27
|
},
|
|
29
28
|
"./components": {
|
|
30
29
|
"types": "./dist/components.d.ts",
|
|
31
|
-
"import": "./dist/components.mjs"
|
|
32
|
-
"require": "./dist/components.cjs"
|
|
30
|
+
"import": "./dist/components.mjs"
|
|
33
31
|
},
|
|
34
32
|
"./server": {
|
|
35
33
|
"types": "./dist/server.d.ts",
|
|
36
|
-
"import": "./dist/server.mjs"
|
|
37
|
-
"require": "./dist/server.cjs"
|
|
34
|
+
"import": "./dist/server.mjs"
|
|
38
35
|
},
|
|
39
36
|
"./client": {
|
|
40
37
|
"types": "./dist/client.d.ts",
|
|
41
|
-
"import": "./dist/client.mjs"
|
|
42
|
-
|
|
38
|
+
"import": "./dist/client.mjs"
|
|
39
|
+
},
|
|
40
|
+
"./types": {
|
|
41
|
+
"types": "./dist/types.d.ts",
|
|
42
|
+
"import": "./dist/types.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./legacy": {
|
|
45
|
+
"types": "./dist/legacy.d.ts",
|
|
46
|
+
"import": "./dist/legacy.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./plugins": {
|
|
49
|
+
"types": "./dist/plugins.d.ts",
|
|
50
|
+
"import": "./dist/plugins.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./utils": {
|
|
53
|
+
"types": "./dist/utils.d.ts",
|
|
54
|
+
"import": "./dist/utils.mjs"
|
|
43
55
|
}
|
|
44
56
|
},
|
|
45
|
-
"main": "dist/index.
|
|
57
|
+
"main": "dist/index.mjs",
|
|
46
58
|
"module": "dist/index.mjs",
|
|
47
59
|
"types": "dist/index.d.ts",
|
|
48
60
|
"typesVersions": {
|
|
@@ -55,16 +67,32 @@
|
|
|
55
67
|
],
|
|
56
68
|
"client": [
|
|
57
69
|
"dist/client"
|
|
70
|
+
],
|
|
71
|
+
"types": [
|
|
72
|
+
"dist/types"
|
|
73
|
+
],
|
|
74
|
+
"legacy": [
|
|
75
|
+
"dist/legacy"
|
|
76
|
+
],
|
|
77
|
+
"plugins": [
|
|
78
|
+
"dist/plugins"
|
|
79
|
+
],
|
|
80
|
+
"utils": [
|
|
81
|
+
"dist/utils"
|
|
58
82
|
]
|
|
59
83
|
}
|
|
60
84
|
},
|
|
61
85
|
"files": [
|
|
62
86
|
"client.d.ts",
|
|
63
87
|
"dist",
|
|
64
|
-
"
|
|
88
|
+
"legacy.d.ts",
|
|
89
|
+
"plugins.d.ts",
|
|
90
|
+
"server.d.ts",
|
|
91
|
+
"types.d.ts",
|
|
92
|
+
"utils.d.ts"
|
|
65
93
|
],
|
|
66
94
|
"peerDependencies": {
|
|
67
|
-
"vue": ">=3"
|
|
95
|
+
"vue": ">=3.5.13"
|
|
68
96
|
},
|
|
69
97
|
"build": {
|
|
70
98
|
"external": [
|
|
@@ -73,9 +101,7 @@
|
|
|
73
101
|
},
|
|
74
102
|
"dependencies": {
|
|
75
103
|
"hookable": "^5.5.3",
|
|
76
|
-
"
|
|
77
|
-
"unhead": "2.0.0-alpha.2",
|
|
78
|
-
"@unhead/shared": "2.0.0-alpha.2"
|
|
104
|
+
"unhead": "2.0.0-alpha.21"
|
|
79
105
|
},
|
|
80
106
|
"scripts": {
|
|
81
107
|
"build": "unbuild .",
|
package/plugins.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/plugins'
|
package/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/types'
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/utils'
|
package/dist/client.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const client = require('unhead/client');
|
|
4
|
-
const vue = require('vue');
|
|
5
|
-
const useHead = require('./shared/vue.Adq3bKYb.cjs');
|
|
6
|
-
const VueReactivityPlugin = require('./shared/vue.BFi59n5j.cjs');
|
|
7
|
-
const VueHeadMixin = require('./shared/vue.DTOQraae.cjs');
|
|
8
|
-
require('@unhead/shared');
|
|
9
|
-
|
|
10
|
-
function createHead(options = {}) {
|
|
11
|
-
const head = client.createHead({
|
|
12
|
-
domOptions: {
|
|
13
|
-
delayFn: (fn) => vue.nextTick(() => setTimeout(() => fn(), 0))
|
|
14
|
-
},
|
|
15
|
-
...options,
|
|
16
|
-
plugins: [
|
|
17
|
-
...options.plugins || [],
|
|
18
|
-
VueReactivityPlugin.VueReactivityPlugin
|
|
19
|
-
]
|
|
20
|
-
});
|
|
21
|
-
head.install = useHead.vueInstall(head);
|
|
22
|
-
return head;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
26
|
-
exports.createHead = createHead;
|
|
27
|
-
Object.prototype.hasOwnProperty.call(client, '__proto__') &&
|
|
28
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
29
|
-
Object.defineProperty(exports, '__proto__', {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
value: client['__proto__']
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
Object.keys(client).forEach(function (k) {
|
|
35
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = client[k];
|
|
36
|
-
});
|
package/dist/client.d.cts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { MergeHead, CreateClientHeadOptions } from '@unhead/schema';
|
|
2
|
-
import { d as distExports } from './shared/vue.Bjx6RvLp.cjs';
|
|
3
|
-
export { V as VueHeadMixin } from './shared/vue.DnywREVF.cjs';
|
|
4
|
-
export * from 'unhead/client';
|
|
5
|
-
import '@unhead/shared';
|
|
6
|
-
import 'unhead';
|
|
7
|
-
import 'vue';
|
|
8
|
-
|
|
9
|
-
declare function createHead<T extends MergeHead>(options?: CreateClientHeadOptions): distExports.VueHeadClient<T>;
|
|
10
|
-
|
|
11
|
-
export { createHead };
|
package/dist/components.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
const useHead = require('./shared/vue.Adq3bKYb.cjs');
|
|
5
|
-
|
|
6
|
-
function addVNodeToHeadObj(node, obj) {
|
|
7
|
-
const nodeType = node.type;
|
|
8
|
-
const type = nodeType === "html" ? "htmlAttrs" : nodeType === "body" ? "bodyAttrs" : nodeType;
|
|
9
|
-
if (typeof type !== "string" || !(type in obj))
|
|
10
|
-
return;
|
|
11
|
-
const props = node.props || {};
|
|
12
|
-
if (node.children) {
|
|
13
|
-
const childrenAttr = "children";
|
|
14
|
-
props.children = Array.isArray(node.children) ? node.children[0][childrenAttr] : node[childrenAttr];
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(obj[type]))
|
|
17
|
-
obj[type].push(props);
|
|
18
|
-
else if (type === "title")
|
|
19
|
-
obj.title = props.children;
|
|
20
|
-
else
|
|
21
|
-
obj[type] = props;
|
|
22
|
-
}
|
|
23
|
-
function vnodesToHeadObj(nodes) {
|
|
24
|
-
const obj = {
|
|
25
|
-
title: undefined,
|
|
26
|
-
htmlAttrs: undefined,
|
|
27
|
-
bodyAttrs: undefined,
|
|
28
|
-
base: undefined,
|
|
29
|
-
meta: [],
|
|
30
|
-
link: [],
|
|
31
|
-
style: [],
|
|
32
|
-
script: [],
|
|
33
|
-
noscript: []
|
|
34
|
-
};
|
|
35
|
-
for (const node of nodes) {
|
|
36
|
-
if (typeof node.type === "symbol" && Array.isArray(node.children)) {
|
|
37
|
-
for (const childNode of node.children)
|
|
38
|
-
addVNodeToHeadObj(childNode, obj);
|
|
39
|
-
} else {
|
|
40
|
-
addVNodeToHeadObj(node, obj);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return obj;
|
|
44
|
-
}
|
|
45
|
-
const Head = /* @__PURE__ */ vue.defineComponent({
|
|
46
|
-
name: "Head",
|
|
47
|
-
setup(_, { slots }) {
|
|
48
|
-
const obj = vue.ref({});
|
|
49
|
-
const entry = useHead.useHead(obj);
|
|
50
|
-
vue.onBeforeUnmount(() => {
|
|
51
|
-
entry.dispose();
|
|
52
|
-
});
|
|
53
|
-
return () => {
|
|
54
|
-
vue.watchEffect(() => {
|
|
55
|
-
if (!slots.default)
|
|
56
|
-
return;
|
|
57
|
-
entry.patch(vnodesToHeadObj(slots.default()));
|
|
58
|
-
});
|
|
59
|
-
return null;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
exports.Head = Head;
|
package/dist/components.d.cts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const shared = require('@unhead/shared');
|
|
4
|
-
const unhead = require('unhead');
|
|
5
|
-
const useHead = require('./shared/vue.Adq3bKYb.cjs');
|
|
6
|
-
const VueHeadMixin = require('./shared/vue.DTOQraae.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.injectHead = useHead.injectHead;
|
|
57
|
-
exports.resolveUnrefHeadInput = useHead.resolveUnrefHeadInput;
|
|
58
|
-
exports.useHead = useHead.useHead;
|
|
59
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
60
|
-
exports.CapoPlugin = CapoPlugin;
|
|
61
|
-
exports.unheadVueComposablesImports = unheadVueComposablesImports;
|
|
62
|
-
exports.useHeadSafe = useHeadSafe;
|
|
63
|
-
exports.useSeoMeta = useSeoMeta;
|
|
64
|
-
exports.useServerHead = useServerHead;
|
|
65
|
-
exports.useServerHeadSafe = useServerHeadSafe;
|
|
66
|
-
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 } 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>>;
|
|
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,163 +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.Adq3bKYb.cjs');
|
|
8
|
-
const server = require('./server.cjs');
|
|
9
|
-
const legacy = require('unhead/legacy');
|
|
10
|
-
require('unhead/client');
|
|
11
|
-
require('./shared/vue.BFi59n5j.cjs');
|
|
12
|
-
require('./shared/vue.DTOQraae.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
|
-
}
|
|
83
|
-
function injectHead() {
|
|
84
|
-
return vue.inject(useHead$1.headSymbol);
|
|
85
|
-
}
|
|
86
|
-
function useHead(input, options = {}) {
|
|
87
|
-
const head = options.head || injectHead();
|
|
88
|
-
if (head) {
|
|
89
|
-
return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
function clientUseHead(head, input, options = {}) {
|
|
93
|
-
const deactivated = vue.ref(false);
|
|
94
|
-
const resolvedInput = vue.ref({});
|
|
95
|
-
vue.watchEffect(() => {
|
|
96
|
-
resolvedInput.value = deactivated.value ? {} : useHead$1.resolveUnrefHeadInput(input);
|
|
97
|
-
});
|
|
98
|
-
const entry = head.push(resolvedInput.value, options);
|
|
99
|
-
vue.watch(resolvedInput, (e) => {
|
|
100
|
-
entry.patch(e);
|
|
101
|
-
});
|
|
102
|
-
const vm = vue.getCurrentInstance();
|
|
103
|
-
if (vm) {
|
|
104
|
-
vue.onBeforeUnmount(() => {
|
|
105
|
-
entry.dispose();
|
|
106
|
-
});
|
|
107
|
-
vue.onDeactivated(() => {
|
|
108
|
-
deactivated.value = true;
|
|
109
|
-
});
|
|
110
|
-
vue.onActivated(() => {
|
|
111
|
-
deactivated.value = false;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
return entry;
|
|
115
|
-
}
|
|
116
|
-
function useHeadSafe(input, options = {}) {
|
|
117
|
-
return useHead(input, { ...options, transform: shared.whitelistSafeInput });
|
|
118
|
-
}
|
|
119
|
-
function useSeoMeta(input, options) {
|
|
120
|
-
const { title, titleTemplate, ...meta } = input;
|
|
121
|
-
return useHead({
|
|
122
|
-
title,
|
|
123
|
-
titleTemplate,
|
|
124
|
-
// @ts-expect-error runtime type
|
|
125
|
-
_flatMeta: meta
|
|
126
|
-
}, {
|
|
127
|
-
...options,
|
|
128
|
-
transform(t) {
|
|
129
|
-
const meta2 = shared.unpackMeta({ ...t._flatMeta });
|
|
130
|
-
delete t._flatMeta;
|
|
131
|
-
return {
|
|
132
|
-
// @ts-expect-error runtime type
|
|
133
|
-
...t,
|
|
134
|
-
meta: meta2
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function useServerHead(input, options = {}) {
|
|
140
|
-
return useHead(input, { ...options, mode: "server" });
|
|
141
|
-
}
|
|
142
|
-
function useServerHeadSafe(input, options = {}) {
|
|
143
|
-
return useHeadSafe(input, { ...options, mode: "server" });
|
|
144
|
-
}
|
|
145
|
-
function useServerSeoMeta(input, options) {
|
|
146
|
-
return useSeoMeta(input, { ...options, mode: "server" });
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
exports.createHeadCore = unhead.createHeadCore;
|
|
150
|
-
exports.createHead = client.createHead;
|
|
151
|
-
exports.resolveUnrefHeadInput = useHead$1.resolveUnrefHeadInput;
|
|
152
|
-
exports.createServerHead = server.createHead;
|
|
153
|
-
exports.resolveScriptKey = legacy.resolveScriptKey;
|
|
154
|
-
exports.CapoPlugin = CapoPlugin;
|
|
155
|
-
exports.injectHead = injectHead;
|
|
156
|
-
exports.setHeadInjectionHandler = setHeadInjectionHandler;
|
|
157
|
-
exports.useHead = useHead;
|
|
158
|
-
exports.useHeadSafe = useHeadSafe;
|
|
159
|
-
exports.useScript = useScript;
|
|
160
|
-
exports.useSeoMeta = useSeoMeta;
|
|
161
|
-
exports.useServerHead = useServerHead;
|
|
162
|
-
exports.useServerHeadSafe = useServerHeadSafe;
|
|
163
|
-
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.Bjx6RvLp.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<_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,33 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const server = require('unhead/server');
|
|
4
|
-
const useHead = require('./shared/vue.Adq3bKYb.cjs');
|
|
5
|
-
const VueReactivityPlugin = require('./shared/vue.BFi59n5j.cjs');
|
|
6
|
-
const VueHeadMixin = require('./shared/vue.DTOQraae.cjs');
|
|
7
|
-
require('vue');
|
|
8
|
-
require('@unhead/shared');
|
|
9
|
-
|
|
10
|
-
function createHead(options = {}) {
|
|
11
|
-
const head = server.createHead({
|
|
12
|
-
...options,
|
|
13
|
-
plugins: [
|
|
14
|
-
...options.plugins || [],
|
|
15
|
-
VueReactivityPlugin.VueReactivityPlugin
|
|
16
|
-
]
|
|
17
|
-
});
|
|
18
|
-
head.install = useHead.vueInstall(head);
|
|
19
|
-
return head;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
exports.VueHeadMixin = VueHeadMixin.VueHeadMixin;
|
|
23
|
-
exports.createHead = createHead;
|
|
24
|
-
Object.prototype.hasOwnProperty.call(server, '__proto__') &&
|
|
25
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
26
|
-
Object.defineProperty(exports, '__proto__', {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
value: server['__proto__']
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
Object.keys(server).forEach(function (k) {
|
|
32
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = server[k];
|
|
33
|
-
});
|
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.Bjx6RvLp.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 };
|