@unhead/vue 1.11.14 → 2.0.0-alpha.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 (54) hide show
  1. package/client.d.ts +1 -0
  2. package/dist/client.cjs +37 -0
  3. package/dist/client.d.cts +11 -0
  4. package/dist/client.d.mts +11 -0
  5. package/dist/client.d.ts +11 -0
  6. package/dist/client.mjs +25 -0
  7. package/dist/components.cjs +9 -18
  8. package/dist/components.mjs +9 -18
  9. package/dist/index.cjs +11 -123
  10. package/dist/index.d.cts +16 -61
  11. package/dist/index.d.mts +16 -61
  12. package/dist/index.d.ts +16 -61
  13. package/dist/index.mjs +9 -117
  14. package/dist/legacy.cjs +168 -0
  15. package/dist/legacy.d.cts +51 -0
  16. package/dist/legacy.d.mts +51 -0
  17. package/dist/legacy.d.ts +51 -0
  18. package/dist/legacy.mjs +154 -0
  19. package/dist/server.cjs +34 -0
  20. package/dist/server.d.cts +11 -0
  21. package/dist/server.d.mts +11 -0
  22. package/dist/server.d.ts +11 -0
  23. package/dist/server.mjs +22 -0
  24. package/dist/shared/vue.3OjaFlxQ.cjs +20 -0
  25. package/dist/shared/vue.B6jdKgLD.mjs +13 -0
  26. package/dist/shared/{vue.71760da0.d.cts → vue.B8gXlHM7.d.cts} +25 -13
  27. package/dist/shared/{vue.71760da0.d.mts → vue.B8gXlHM7.d.mts} +25 -13
  28. package/dist/shared/{vue.71760da0.d.ts → vue.B8gXlHM7.d.ts} +25 -13
  29. package/dist/shared/vue.BwEnMiRq.cjs +91 -0
  30. package/dist/shared/vue.DIPZN3-d.cjs +15 -0
  31. package/dist/shared/vue.DShwsPiO.d.cts +194 -0
  32. package/dist/shared/vue.DShwsPiO.d.mts +194 -0
  33. package/dist/shared/vue.DShwsPiO.d.ts +194 -0
  34. package/dist/shared/vue.DnywREVF.d.cts +5 -0
  35. package/dist/shared/vue.DnywREVF.d.mts +5 -0
  36. package/dist/shared/vue.DnywREVF.d.ts +5 -0
  37. package/dist/shared/vue.O-w7-AFg.mjs +18 -0
  38. package/dist/shared/vue.Sg4YunmP.mjs +85 -0
  39. package/package.json +23 -23
  40. package/server.d.ts +1 -0
  41. package/dist/polyfill.cjs +0 -30
  42. package/dist/polyfill.d.cts +0 -40
  43. package/dist/polyfill.d.mts +0 -40
  44. package/dist/polyfill.d.ts +0 -40
  45. package/dist/polyfill.mjs +0 -28
  46. package/dist/shared/vue.104c41b5.cjs +0 -39
  47. package/dist/shared/vue.6b1572ee.cjs +0 -94
  48. package/dist/shared/vue.8fc199ce.mjs +0 -37
  49. package/dist/shared/vue.f49591ad.mjs +0 -86
  50. package/dist/vue2.cjs +0 -61
  51. package/dist/vue2.d.cts +0 -5
  52. package/dist/vue2.d.mts +0 -5
  53. package/dist/vue2.d.ts +0 -5
  54. package/dist/vue2.mjs +0 -59
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "1.11.14",
4
+ "version": "2.0.0-alpha.0",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -21,20 +21,20 @@
21
21
  "import": "./dist/index.mjs",
22
22
  "require": "./dist/index.cjs"
23
23
  },
24
- "./polyfill": {
25
- "types": "./dist/polyfill.d.ts",
26
- "import": "./dist/polyfill.mjs",
27
- "require": "./dist/polyfill.cjs"
28
- },
29
- "./vue2": {
30
- "types": "./dist/vue2.d.ts",
31
- "import": "./dist/vue2.mjs",
32
- "require": "./dist/vue2.cjs"
33
- },
34
24
  "./components": {
35
25
  "types": "./dist/components.d.ts",
36
26
  "import": "./dist/components.mjs",
37
27
  "require": "./dist/components.cjs"
28
+ },
29
+ "./server": {
30
+ "types": "./dist/server.d.ts",
31
+ "import": "./dist/server.mjs",
32
+ "require": "./dist/server.cjs"
33
+ },
34
+ "./client": {
35
+ "types": "./dist/client.d.ts",
36
+ "import": "./dist/client.mjs",
37
+ "require": "./dist/client.cjs"
38
38
  }
39
39
  },
40
40
  "main": "dist/index.cjs",
@@ -45,19 +45,21 @@
45
45
  "components": [
46
46
  "dist/components"
47
47
  ],
48
- "vue2": [
49
- "dist/vue2"
48
+ "server": [
49
+ "dist/server"
50
50
  ],
51
- "polyfill": [
52
- "dist/polyfill"
51
+ "client": [
52
+ "dist/client"
53
53
  ]
54
54
  }
55
55
  },
56
56
  "files": [
57
- "dist"
57
+ "client.d.ts",
58
+ "dist",
59
+ "server.d.ts"
58
60
  ],
59
61
  "peerDependencies": {
60
- "vue": ">=2.7 || >=3"
62
+ "vue": ">=3"
61
63
  },
62
64
  "build": {
63
65
  "external": [
@@ -65,15 +67,13 @@
65
67
  ]
66
68
  },
67
69
  "dependencies": {
68
- "defu": "^6.1.4",
69
70
  "hookable": "^5.5.3",
70
- "@unhead/shared": "1.11.14",
71
- "@unhead/schema": "1.11.14",
72
- "unhead": "1.11.14"
71
+ "@unhead/schema": "2.0.0-alpha.0",
72
+ "unhead": "2.0.0-alpha.0",
73
+ "@unhead/shared": "2.0.0-alpha.0"
73
74
  },
74
75
  "scripts": {
75
76
  "build": "unbuild .",
76
- "stub": "unbuild . --stub",
77
- "export:sizes": "npx export-size . -r"
77
+ "stub": "unbuild . --stub"
78
78
  }
79
79
  }
package/server.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/server'
package/dist/polyfill.cjs DELETED
@@ -1,30 +0,0 @@
1
- 'use strict';
2
-
3
- const useHead = require('./shared/vue.104c41b5.cjs');
4
- require('vue');
5
- require('./shared/vue.6b1572ee.cjs');
6
- require('unhead');
7
- require('@unhead/shared');
8
-
9
- function polyfillAsVueUseHead(head) {
10
- const polyfilled = head;
11
- polyfilled.headTags = head.resolveTags;
12
- polyfilled.addEntry = head.push;
13
- polyfilled.addHeadObjs = head.push;
14
- polyfilled.addReactiveEntry = (input, options) => {
15
- const api = useHead.useHead(input, options);
16
- if (api !== void 0)
17
- return api.dispose;
18
- return () => {
19
- };
20
- };
21
- polyfilled.removeHeadObjs = () => {
22
- };
23
- polyfilled.updateDOM = () => {
24
- head.hooks.callHook("entries:updated", head);
25
- };
26
- polyfilled.unhead = head;
27
- return polyfilled;
28
- }
29
-
30
- exports.polyfillAsVueUseHead = polyfillAsVueUseHead;
@@ -1,40 +0,0 @@
1
- import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.71760da0.cjs';
3
- import 'vue';
4
-
5
- type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
6
- /**
7
- * @deprecated use `resolveTags`
8
- */
9
- headTags: VueHeadClient<T>['resolveTags'];
10
- /**
11
- * @deprecated use `push`
12
- */
13
- addEntry: VueHeadClient<T>['push'];
14
- /**
15
- * @deprecated use `push`
16
- */
17
- addHeadObjs: VueHeadClient<T>['push'];
18
- /**
19
- * @deprecated use `useHead`
20
- */
21
- addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
22
- /**
23
- * @deprecated Use useHead API.
24
- */
25
- removeHeadObjs: () => void;
26
- /**
27
- * @deprecated Call hook `entries:resolve` or update an entry
28
- */
29
- updateDOM: () => void;
30
- /**
31
- * @deprecated Access unhead properties directly.
32
- */
33
- unhead: VueHeadClient<T>;
34
- };
35
- /**
36
- * @deprecated Will be removed in v2.
37
- */
38
- declare function polyfillAsVueUseHead<T extends MergeHead>(head: VueHeadClient<T>): VueHeadClientPollyFill<T>;
39
-
40
- export { type VueHeadClientPollyFill, polyfillAsVueUseHead };
@@ -1,40 +0,0 @@
1
- import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.71760da0.mjs';
3
- import 'vue';
4
-
5
- type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
6
- /**
7
- * @deprecated use `resolveTags`
8
- */
9
- headTags: VueHeadClient<T>['resolveTags'];
10
- /**
11
- * @deprecated use `push`
12
- */
13
- addEntry: VueHeadClient<T>['push'];
14
- /**
15
- * @deprecated use `push`
16
- */
17
- addHeadObjs: VueHeadClient<T>['push'];
18
- /**
19
- * @deprecated use `useHead`
20
- */
21
- addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
22
- /**
23
- * @deprecated Use useHead API.
24
- */
25
- removeHeadObjs: () => void;
26
- /**
27
- * @deprecated Call hook `entries:resolve` or update an entry
28
- */
29
- updateDOM: () => void;
30
- /**
31
- * @deprecated Access unhead properties directly.
32
- */
33
- unhead: VueHeadClient<T>;
34
- };
35
- /**
36
- * @deprecated Will be removed in v2.
37
- */
38
- declare function polyfillAsVueUseHead<T extends MergeHead>(head: VueHeadClient<T>): VueHeadClientPollyFill<T>;
39
-
40
- export { type VueHeadClientPollyFill, polyfillAsVueUseHead };
@@ -1,40 +0,0 @@
1
- import { MergeHead } from '@unhead/schema';
2
- import { V as VueHeadClient, U as UseHeadInput, b as UseHeadOptions } from './shared/vue.71760da0.js';
3
- import 'vue';
4
-
5
- type VueHeadClientPollyFill<T extends MergeHead> = VueHeadClient<T> & {
6
- /**
7
- * @deprecated use `resolveTags`
8
- */
9
- headTags: VueHeadClient<T>['resolveTags'];
10
- /**
11
- * @deprecated use `push`
12
- */
13
- addEntry: VueHeadClient<T>['push'];
14
- /**
15
- * @deprecated use `push`
16
- */
17
- addHeadObjs: VueHeadClient<T>['push'];
18
- /**
19
- * @deprecated use `useHead`
20
- */
21
- addReactiveEntry: (input: UseHeadInput<T>, options?: UseHeadOptions) => (() => void);
22
- /**
23
- * @deprecated Use useHead API.
24
- */
25
- removeHeadObjs: () => void;
26
- /**
27
- * @deprecated Call hook `entries:resolve` or update an entry
28
- */
29
- updateDOM: () => void;
30
- /**
31
- * @deprecated Access unhead properties directly.
32
- */
33
- unhead: VueHeadClient<T>;
34
- };
35
- /**
36
- * @deprecated Will be removed in v2.
37
- */
38
- declare function polyfillAsVueUseHead<T extends MergeHead>(head: VueHeadClient<T>): VueHeadClientPollyFill<T>;
39
-
40
- export { type VueHeadClientPollyFill, polyfillAsVueUseHead };
package/dist/polyfill.mjs DELETED
@@ -1,28 +0,0 @@
1
- import { u as useHead } from './shared/vue.8fc199ce.mjs';
2
- import 'vue';
3
- import './shared/vue.f49591ad.mjs';
4
- import 'unhead';
5
- import '@unhead/shared';
6
-
7
- function polyfillAsVueUseHead(head) {
8
- const polyfilled = head;
9
- polyfilled.headTags = head.resolveTags;
10
- polyfilled.addEntry = head.push;
11
- polyfilled.addHeadObjs = head.push;
12
- polyfilled.addReactiveEntry = (input, options) => {
13
- const api = useHead(input, options);
14
- if (api !== void 0)
15
- return api.dispose;
16
- return () => {
17
- };
18
- };
19
- polyfilled.removeHeadObjs = () => {
20
- };
21
- polyfilled.updateDOM = () => {
22
- head.hooks.callHook("entries:updated", head);
23
- };
24
- polyfilled.unhead = head;
25
- return polyfilled;
26
- }
27
-
28
- export { polyfillAsVueUseHead };
@@ -1,39 +0,0 @@
1
- 'use strict';
2
-
3
- const vue = require('vue');
4
- const injectHead = require('./vue.6b1572ee.cjs');
5
-
6
- function useHead(input, options = {}) {
7
- const head = options.head || injectHead.injectHead();
8
- if (head) {
9
- if (!head.ssr)
10
- return clientUseHead(head, input, options);
11
- return head.push(input, options);
12
- }
13
- }
14
- function clientUseHead(head, input, options = {}) {
15
- const deactivated = vue.ref(false);
16
- const resolvedInput = vue.ref({});
17
- vue.watchEffect(() => {
18
- resolvedInput.value = deactivated.value ? {} : injectHead.resolveUnrefHeadInput(input);
19
- });
20
- const entry = head.push(resolvedInput.value, options);
21
- vue.watch(resolvedInput, (e) => {
22
- entry.patch(e);
23
- });
24
- const vm = vue.getCurrentInstance();
25
- if (vm) {
26
- vue.onBeforeUnmount(() => {
27
- entry.dispose();
28
- });
29
- vue.onDeactivated(() => {
30
- deactivated.value = true;
31
- });
32
- vue.onActivated(() => {
33
- deactivated.value = false;
34
- });
35
- }
36
- return entry;
37
- }
38
-
39
- exports.useHead = useHead;
@@ -1,94 +0,0 @@
1
- 'use strict';
2
-
3
- const unhead = require('unhead');
4
- const vue = require('vue');
5
- const shared = require('@unhead/shared');
6
-
7
- const Vue3 = vue.version[0] === "3";
8
-
9
- function resolveUnref(r) {
10
- return typeof r === "function" ? r() : vue.unref(r);
11
- }
12
- function resolveUnrefHeadInput(ref) {
13
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
14
- return ref;
15
- const root = resolveUnref(ref);
16
- if (!ref || !root)
17
- return root;
18
- if (Array.isArray(root))
19
- return root.map((r) => resolveUnrefHeadInput(r));
20
- if (typeof root === "object") {
21
- const resolved = {};
22
- for (const k in root) {
23
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
24
- continue;
25
- }
26
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
27
- resolved[k] = vue.unref(root[k]);
28
- continue;
29
- }
30
- resolved[k] = resolveUnrefHeadInput(root[k]);
31
- }
32
- return resolved;
33
- }
34
- return root;
35
- }
36
-
37
- const VueReactivityPlugin = shared.defineHeadPlugin({
38
- hooks: {
39
- "entries:resolve": (ctx) => {
40
- for (const entry of ctx.entries)
41
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
42
- }
43
- }
44
- });
45
-
46
- const headSymbol = "usehead";
47
- function vueInstall(head) {
48
- const plugin = {
49
- install(app) {
50
- if (Vue3) {
51
- app.config.globalProperties.$unhead = head;
52
- app.config.globalProperties.$head = head;
53
- app.provide(headSymbol, head);
54
- }
55
- }
56
- };
57
- return plugin.install;
58
- }
59
- function createServerHead(options = {}) {
60
- const head = unhead.createServerHead(options);
61
- head.use(VueReactivityPlugin);
62
- head.install = vueInstall(head);
63
- return head;
64
- }
65
- function createHead(options = {}) {
66
- options.domDelayFn = options.domDelayFn || ((fn) => vue.nextTick(() => setTimeout(() => fn(), 0)));
67
- const head = unhead.createHead(options);
68
- head.use(VueReactivityPlugin);
69
- head.install = vueInstall(head);
70
- return head;
71
- }
72
-
73
- const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
74
- const globalKey = "__unhead_injection_handler__";
75
- function setHeadInjectionHandler(handler) {
76
- _global[globalKey] = handler;
77
- }
78
- function injectHead() {
79
- if (globalKey in _global) {
80
- return _global[globalKey]();
81
- }
82
- const head = vue.inject(headSymbol);
83
- if (!head && process.env.NODE_ENV !== "production")
84
- console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
85
- return head || unhead.getActiveHead();
86
- }
87
-
88
- exports.Vue3 = Vue3;
89
- exports.createHead = createHead;
90
- exports.createServerHead = createServerHead;
91
- exports.headSymbol = headSymbol;
92
- exports.injectHead = injectHead;
93
- exports.resolveUnrefHeadInput = resolveUnrefHeadInput;
94
- exports.setHeadInjectionHandler = setHeadInjectionHandler;
@@ -1,37 +0,0 @@
1
- import { ref, watchEffect, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
2
- import { i as injectHead, r as resolveUnrefHeadInput } from './vue.f49591ad.mjs';
3
-
4
- function useHead(input, options = {}) {
5
- const head = options.head || injectHead();
6
- if (head) {
7
- if (!head.ssr)
8
- return clientUseHead(head, input, options);
9
- return head.push(input, options);
10
- }
11
- }
12
- function clientUseHead(head, input, options = {}) {
13
- const deactivated = ref(false);
14
- const resolvedInput = ref({});
15
- watchEffect(() => {
16
- resolvedInput.value = deactivated.value ? {} : resolveUnrefHeadInput(input);
17
- });
18
- const entry = head.push(resolvedInput.value, options);
19
- watch(resolvedInput, (e) => {
20
- entry.patch(e);
21
- });
22
- const vm = getCurrentInstance();
23
- if (vm) {
24
- onBeforeUnmount(() => {
25
- entry.dispose();
26
- });
27
- onDeactivated(() => {
28
- deactivated.value = true;
29
- });
30
- onActivated(() => {
31
- deactivated.value = false;
32
- });
33
- }
34
- return entry;
35
- }
36
-
37
- export { useHead as u };
@@ -1,86 +0,0 @@
1
- import { createServerHead as createServerHead$1, createHead as createHead$1, getActiveHead } from 'unhead';
2
- import { version, unref, nextTick, inject } from 'vue';
3
- import { defineHeadPlugin } from '@unhead/shared';
4
-
5
- const Vue3 = version[0] === "3";
6
-
7
- function resolveUnref(r) {
8
- return typeof r === "function" ? r() : unref(r);
9
- }
10
- function resolveUnrefHeadInput(ref) {
11
- if (ref instanceof Promise || ref instanceof Date || ref instanceof RegExp)
12
- return ref;
13
- const root = resolveUnref(ref);
14
- if (!ref || !root)
15
- return root;
16
- if (Array.isArray(root))
17
- return root.map((r) => resolveUnrefHeadInput(r));
18
- if (typeof root === "object") {
19
- const resolved = {};
20
- for (const k in root) {
21
- if (!Object.prototype.hasOwnProperty.call(root, k)) {
22
- continue;
23
- }
24
- if (k === "titleTemplate" || k[0] === "o" && k[1] === "n") {
25
- resolved[k] = unref(root[k]);
26
- continue;
27
- }
28
- resolved[k] = resolveUnrefHeadInput(root[k]);
29
- }
30
- return resolved;
31
- }
32
- return root;
33
- }
34
-
35
- const VueReactivityPlugin = defineHeadPlugin({
36
- hooks: {
37
- "entries:resolve": (ctx) => {
38
- for (const entry of ctx.entries)
39
- entry.resolvedInput = resolveUnrefHeadInput(entry.input);
40
- }
41
- }
42
- });
43
-
44
- const headSymbol = "usehead";
45
- function vueInstall(head) {
46
- const plugin = {
47
- install(app) {
48
- if (Vue3) {
49
- app.config.globalProperties.$unhead = head;
50
- app.config.globalProperties.$head = head;
51
- app.provide(headSymbol, head);
52
- }
53
- }
54
- };
55
- return plugin.install;
56
- }
57
- function createServerHead(options = {}) {
58
- const head = createServerHead$1(options);
59
- head.use(VueReactivityPlugin);
60
- head.install = vueInstall(head);
61
- return head;
62
- }
63
- function createHead(options = {}) {
64
- options.domDelayFn = options.domDelayFn || ((fn) => nextTick(() => setTimeout(() => fn(), 0)));
65
- const head = createHead$1(options);
66
- head.use(VueReactivityPlugin);
67
- head.install = vueInstall(head);
68
- return head;
69
- }
70
-
71
- const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
72
- const globalKey = "__unhead_injection_handler__";
73
- function setHeadInjectionHandler(handler) {
74
- _global[globalKey] = handler;
75
- }
76
- function injectHead() {
77
- if (globalKey in _global) {
78
- return _global[globalKey]();
79
- }
80
- const head = inject(headSymbol);
81
- if (!head && process.env.NODE_ENV !== "production")
82
- console.warn("Unhead is missing Vue context, falling back to shared context. This may have unexpected results.");
83
- return head || getActiveHead();
84
- }
85
-
86
- export { Vue3 as V, createServerHead as a, createHead as c, headSymbol as h, injectHead as i, resolveUnrefHeadInput as r, setHeadInjectionHandler as s };
package/dist/vue2.cjs DELETED
@@ -1,61 +0,0 @@
1
- 'use strict';
2
-
3
- const defu = require('defu');
4
- const vue = require('vue');
5
- const useHead = require('./shared/vue.104c41b5.cjs');
6
- const injectHead = require('./shared/vue.6b1572ee.cjs');
7
- require('unhead');
8
- require('@unhead/shared');
9
-
10
- const UnheadPlugin = (_Vue) => {
11
- _Vue.config.optionMergeStrategies.head = function(toVal, fromVal, vm) {
12
- if (typeof toVal === "function") {
13
- toVal = toVal.call(vm || this || _Vue);
14
- }
15
- if (typeof fromVal === "function") {
16
- fromVal = fromVal.call(vm || this || _Vue);
17
- }
18
- return defu.defu(toVal, fromVal);
19
- };
20
- _Vue.mixin({
21
- created() {
22
- let source = false;
23
- if (injectHead.Vue3) {
24
- const instance = vue.getCurrentInstance();
25
- if (!instance)
26
- return;
27
- const options = instance.type;
28
- if (!options || !("head" in options))
29
- return;
30
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
31
- } else {
32
- const head = this.$options.head;
33
- if (head) {
34
- source = typeof head === "function" ? () => head.call(this) : head;
35
- }
36
- }
37
- if (source) {
38
- useHead.useHead(source);
39
- }
40
- },
41
- beforeCreate() {
42
- const options = this.$options;
43
- if (options.unhead) {
44
- const origProvide = options.provide;
45
- options.provide = function() {
46
- let origProvideResult;
47
- if (typeof origProvide === "function")
48
- origProvideResult = origProvide.call(this);
49
- else
50
- origProvideResult = origProvide || {};
51
- return {
52
- ...origProvideResult,
53
- [injectHead.headSymbol]: options.unhead
54
- };
55
- };
56
- }
57
- }
58
- });
59
- };
60
-
61
- exports.UnheadPlugin = UnheadPlugin;
package/dist/vue2.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { Plugin } from 'vue';
2
-
3
- declare const UnheadPlugin: Plugin;
4
-
5
- export { UnheadPlugin };
package/dist/vue2.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { Plugin } from 'vue';
2
-
3
- declare const UnheadPlugin: Plugin;
4
-
5
- export { UnheadPlugin };
package/dist/vue2.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Plugin } from 'vue';
2
-
3
- declare const UnheadPlugin: Plugin;
4
-
5
- export { UnheadPlugin };
package/dist/vue2.mjs DELETED
@@ -1,59 +0,0 @@
1
- import { defu } from 'defu';
2
- import { getCurrentInstance } from 'vue';
3
- import { u as useHead } from './shared/vue.8fc199ce.mjs';
4
- import { V as Vue3, h as headSymbol } from './shared/vue.f49591ad.mjs';
5
- import 'unhead';
6
- import '@unhead/shared';
7
-
8
- const UnheadPlugin = (_Vue) => {
9
- _Vue.config.optionMergeStrategies.head = function(toVal, fromVal, vm) {
10
- if (typeof toVal === "function") {
11
- toVal = toVal.call(vm || this || _Vue);
12
- }
13
- if (typeof fromVal === "function") {
14
- fromVal = fromVal.call(vm || this || _Vue);
15
- }
16
- return defu(toVal, fromVal);
17
- };
18
- _Vue.mixin({
19
- created() {
20
- let source = false;
21
- if (Vue3) {
22
- const instance = getCurrentInstance();
23
- if (!instance)
24
- return;
25
- const options = instance.type;
26
- if (!options || !("head" in options))
27
- return;
28
- source = typeof options.head === "function" ? () => options.head.call(instance.proxy) : options.head;
29
- } else {
30
- const head = this.$options.head;
31
- if (head) {
32
- source = typeof head === "function" ? () => head.call(this) : head;
33
- }
34
- }
35
- if (source) {
36
- useHead(source);
37
- }
38
- },
39
- beforeCreate() {
40
- const options = this.$options;
41
- if (options.unhead) {
42
- const origProvide = options.provide;
43
- options.provide = function() {
44
- let origProvideResult;
45
- if (typeof origProvide === "function")
46
- origProvideResult = origProvide.call(this);
47
- else
48
- origProvideResult = origProvide || {};
49
- return {
50
- ...origProvideResult,
51
- [headSymbol]: options.unhead
52
- };
53
- };
54
- }
55
- }
56
- });
57
- };
58
-
59
- export { UnheadPlugin };