@unhead/vue 3.0.0-beta.2 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/client.d.mts +1 -1
  2. package/dist/client.d.ts +1 -1
  3. package/dist/client.mjs +7 -9
  4. package/dist/components.mjs +1 -1
  5. package/dist/index.d.mts +8 -29
  6. package/dist/index.d.ts +8 -29
  7. package/dist/index.mjs +5 -9
  8. package/dist/scripts.d.mts +2 -2
  9. package/dist/scripts.d.ts +2 -2
  10. package/dist/scripts.mjs +3 -3
  11. package/dist/server.d.mts +2 -2
  12. package/dist/server.d.ts +2 -2
  13. package/dist/server.mjs +3 -3
  14. package/dist/shared/{vue.Bm-NbY4b.mjs → vue.BAVPDCHt.mjs} +1 -10
  15. package/dist/shared/{vue.DoxLTFJk.d.mts → vue.BW2vTlaC.d.mts} +3 -3
  16. package/dist/shared/{vue.DoxLTFJk.d.ts → vue.BW2vTlaC.d.ts} +3 -3
  17. package/dist/shared/{vue.BVUAdATk.mjs → vue.C-c0vimW.mjs} +1 -1
  18. package/dist/shared/{vue.CeCEzk2b.mjs → vue.CQPP9sR4.mjs} +1 -1
  19. package/dist/stream/client.d.mts +17 -0
  20. package/dist/stream/client.d.ts +17 -0
  21. package/dist/stream/client.mjs +27 -0
  22. package/dist/stream/server.d.mts +50 -0
  23. package/dist/stream/server.d.ts +50 -0
  24. package/dist/stream/server.mjs +43 -0
  25. package/dist/stream/vite.d.mts +27 -0
  26. package/dist/stream/vite.d.ts +27 -0
  27. package/dist/stream/vite.mjs +51 -0
  28. package/dist/types.d.mts +68 -5
  29. package/dist/types.d.ts +68 -5
  30. package/dist/utils.d.mts +1 -6
  31. package/dist/utils.d.ts +1 -6
  32. package/dist/utils.mjs +1 -9
  33. package/package.json +35 -12
  34. package/dist/legacy.d.mts +0 -34
  35. package/dist/legacy.d.ts +0 -34
  36. package/dist/legacy.mjs +0 -114
  37. package/dist/shared/vue.CzjZUNjB.d.ts +0 -63
  38. package/dist/shared/vue.DMlT7xkj.d.mts +0 -63
  39. package/legacy.d.ts +0 -1
@@ -0,0 +1,51 @@
1
+ import MagicString from 'magic-string';
2
+ import { findStaticImports } from 'mlly';
3
+ import { createStreamingPlugin } from 'unhead/stream/vite';
4
+
5
+ function transform(code, id, isSSR, s) {
6
+ if (!code.includes("useHead") && !code.includes("useSeoMeta") && !code.includes("useHeadSafe"))
7
+ return false;
8
+ const templateMatch = code.match(/<template[^>]*>/);
9
+ if (!templateMatch)
10
+ return false;
11
+ const templateStart = templateMatch.index + templateMatch[0].length;
12
+ s.appendRight(templateStart, "<HeadStream />");
13
+ const importPath = `@unhead/vue/stream/${isSSR ? "server" : "client"}`;
14
+ const scriptMatch = code.match(/<script[^>]*>/i);
15
+ if (!scriptMatch)
16
+ return true;
17
+ const scriptEnd = scriptMatch.index + scriptMatch[0].length;
18
+ const imports = findStaticImports(code);
19
+ const existing = imports.find((i) => i.specifier === importPath);
20
+ if (existing) {
21
+ if (!existing.imports?.includes("HeadStream")) {
22
+ const inner = existing.imports?.replace(/^\{\s*|\s*\}\s*$/g, "").trim() || "";
23
+ const newImports = inner ? `${inner}, HeadStream` : "HeadStream";
24
+ s.overwrite(existing.start, existing.end, `import { ${newImports} } from '${importPath}'
25
+ `);
26
+ }
27
+ } else {
28
+ s.appendRight(scriptEnd, `
29
+ import { HeadStream } from '${importPath}'`);
30
+ }
31
+ return true;
32
+ }
33
+ function unheadVuePlugin(options) {
34
+ return createStreamingPlugin({
35
+ framework: "@unhead/vue",
36
+ mode: options?.mode,
37
+ transform(code, id, opts) {
38
+ if (!/\.vue$/.test(id))
39
+ return null;
40
+ const s = new MagicString(code);
41
+ if (!transform(code, id, opts?.ssr ?? false, s))
42
+ return null;
43
+ return {
44
+ code: s.toString(),
45
+ map: s.generateMap({ includeContent: true, source: id })
46
+ };
47
+ }
48
+ });
49
+ }
50
+
51
+ export { unheadVuePlugin as default, unheadVuePlugin };
package/dist/types.d.mts CHANGED
@@ -1,9 +1,71 @@
1
- import { RawInput } from 'unhead/types';
2
- export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
3
- export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle, U as UseHeadSafeInput } from './shared/vue.DMlT7xkj.mjs';
4
- export { B as BodyAttr, D as DeepResolvableProperties, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, p as ResolvableUnion, m as ResolvableValue, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.DoxLTFJk.mjs';
1
+ import { ResolvableHead, LinkWithoutEvents, DataKeys, SchemaAugmentations, MetaGeneric, Style as Style$1, ScriptWithoutEvents, TagPriority, TagPosition, ResolvesDuplicates, ProcessesTemplateParams, Noscript as Noscript$1, HtmlAttributes as HtmlAttributes$1, BodyAttributesWithoutEvents, RawInput } from 'unhead/types';
2
+ export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MetaFlat, MetaFlat as MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
3
+ import { R as ResolvableValue, a as ResolvableProperties } from './shared/vue.BW2vTlaC.mjs';
4
+ export { B as BodyAttr, D as DeepResolvableProperties, b as Head, H as HtmlAttr, M as MaybeFalsy, b as ReactiveHead, o as ResolvableArray, e as ResolvableBase, l as ResolvableBodyAttributes, k as ResolvableHtmlAttributes, f as ResolvableLink, g as ResolvableMeta, j as ResolvableNoscript, i as ResolvableScript, h as ResolvableStyle, c as ResolvableTitle, d as ResolvableTitleTemplate, p as ResolvableUnion, m as UseHeadInput, U as UseHeadOptions, n as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.BW2vTlaC.mjs';
5
5
  import 'vue';
6
6
 
7
+ type SafeBodyAttr = ResolvableProperties<Pick<BodyAttributesWithoutEvents, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
8
+ type SafeHtmlAttr = ResolvableProperties<Pick<HtmlAttributes$1, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
9
+ type SafeMeta = ResolvableProperties<Pick<MetaGeneric, 'id' | 'name' | 'property' | 'charset' | 'content' | 'media'> & DataKeys & SchemaAugmentations['meta']>;
10
+ type SafeLink = ResolvableProperties<Pick<LinkWithoutEvents, 'id' | 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesrcset' | 'imagesizes' | 'integrity' | 'media' | 'referrerpolicy' | 'rel' | 'sizes' | 'type'> & DataKeys & SchemaAugmentations['link']>;
11
+ type SafeScript = ResolvableProperties<Pick<ScriptWithoutEvents, 'id' | 'type' | 'nonce' | 'blocking'> & DataKeys & {
12
+ textContent?: string;
13
+ } & TagPriority & TagPosition & ResolvesDuplicates & ProcessesTemplateParams>;
14
+ type SafeNoscript = ResolvableProperties<Pick<Noscript$1, 'id'> & DataKeys & Omit<SchemaAugmentations['noscript'], 'innerHTML'>>;
15
+ type SafeStyle = ResolvableProperties<Pick<Style$1, 'id' | 'media' | 'nonce' | 'title' | 'blocking'> & DataKeys & Omit<SchemaAugmentations['style'], 'innerHTML'>>;
16
+ interface HeadSafe extends Pick<ResolvableHead, 'title' | 'titleTemplate' | 'templateParams'> {
17
+ /**
18
+ * The `<link>` HTML element specifies relationships between the current document and an external resource.
19
+ * This element is most commonly used to link to stylesheets, but is also used to establish site icons
20
+ * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
21
+ *
22
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
23
+ */
24
+ link?: ResolvableValue<ResolvableValue<SafeLink[]>>;
25
+ /**
26
+ * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
27
+ *
28
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
29
+ */
30
+ meta?: ResolvableValue<ResolvableValue<SafeMeta>[]>;
31
+ /**
32
+ * The `<style>` HTML element contains style information for a document, or part of a document.
33
+ * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
34
+ *
35
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
36
+ */
37
+ style?: ResolvableValue<ResolvableValue<(SafeStyle | string)>[]>;
38
+ /**
39
+ * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
40
+ *
41
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
42
+ */
43
+ script?: ResolvableValue<ResolvableValue<(SafeScript | string)>[]>;
44
+ /**
45
+ * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
46
+ * or if scripting is currently turned off in the browser.
47
+ *
48
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
49
+ */
50
+ noscript?: ResolvableValue<ResolvableValue<(SafeNoscript | string)>[]>;
51
+ /**
52
+ * Attributes for the `<html>` HTML element.
53
+ *
54
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
55
+ */
56
+ htmlAttrs?: ResolvableValue<SafeHtmlAttr>;
57
+ /**
58
+ * Attributes for the `<body>` HTML element.
59
+ *
60
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
61
+ */
62
+ bodyAttrs?: ResolvableValue<SafeBodyAttr>;
63
+ }
64
+ type UseHeadSafeInput = ResolvableValue<HeadSafe>;
65
+
66
+ /** @deprecated */
67
+ type MergeHead = object;
68
+
7
69
  type Base = RawInput<'base'>;
8
70
  type HtmlAttributes = RawInput<'htmlAttrs'>;
9
71
  type Noscript = RawInput<'noscript'>;
@@ -13,4 +75,5 @@ type Script = RawInput<'script'>;
13
75
  type Link = RawInput<'link'>;
14
76
  type BodyAttributes = RawInput<'bodyAttrs'>;
15
77
 
16
- export type { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style };
78
+ export { ResolvableProperties, ResolvableValue };
79
+ export type { Base, BodyAttributes, HeadSafe, HtmlAttributes, Link, MergeHead, Meta, Noscript, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SafeStyle, Script, Style, UseHeadSafeInput };
package/dist/types.d.ts CHANGED
@@ -1,9 +1,71 @@
1
- import { RawInput } from 'unhead/types';
2
- export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, Head, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MergeHead, MetaFlat, MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
3
- export { H as HeadSafe, S as SafeBodyAttr, a as SafeHtmlAttr, c as SafeLink, b as SafeMeta, e as SafeNoscript, d as SafeScript, f as SafeStyle, U as UseHeadSafeInput } from './shared/vue.CzjZUNjB.js';
4
- export { B as BodyAttr, D as DeepResolvableProperties, H as HtmlAttr, M as MaybeFalsy, l as ReactiveHead, n as ResolvableArray, d as ResolvableBase, k as ResolvableBodyAttributes, j as ResolvableHtmlAttributes, e as ResolvableLink, f as ResolvableMeta, i as ResolvableNoscript, o as ResolvableProperties, h as ResolvableScript, g as ResolvableStyle, R as ResolvableTitle, c as ResolvableTitleTemplate, p as ResolvableUnion, m as ResolvableValue, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.DoxLTFJk.js';
1
+ import { ResolvableHead, LinkWithoutEvents, DataKeys, SchemaAugmentations, MetaGeneric, Style as Style$1, ScriptWithoutEvents, TagPriority, TagPosition, ResolvesDuplicates, ProcessesTemplateParams, Noscript as Noscript$1, HtmlAttributes as HtmlAttributes$1, BodyAttributesWithoutEvents, RawInput } from 'unhead/types';
2
+ export { ActiveHeadEntry, AriaAttributes, BodyAttributesWithoutEvents, BodyEvents, DataKeys, GlobalAttributes, HeadEntryOptions, HeadTag, HttpEventAttributes, LinkWithoutEvents, MetaFlat, MetaFlat as MetaFlatInput, RawInput, RenderSSRHeadOptions, ResolvableHead, ScriptWithoutEvents, SerializableHead, SpeculationRules, Unhead } from 'unhead/types';
3
+ import { R as ResolvableValue, a as ResolvableProperties } from './shared/vue.BW2vTlaC.js';
4
+ export { B as BodyAttr, D as DeepResolvableProperties, b as Head, H as HtmlAttr, M as MaybeFalsy, b as ReactiveHead, o as ResolvableArray, e as ResolvableBase, l as ResolvableBodyAttributes, k as ResolvableHtmlAttributes, f as ResolvableLink, g as ResolvableMeta, j as ResolvableNoscript, i as ResolvableScript, h as ResolvableStyle, c as ResolvableTitle, d as ResolvableTitleTemplate, p as ResolvableUnion, m as UseHeadInput, U as UseHeadOptions, n as UseSeoMetaInput, V as VueHeadClient } from './shared/vue.BW2vTlaC.js';
5
5
  import 'vue';
6
6
 
7
+ type SafeBodyAttr = ResolvableProperties<Pick<BodyAttributesWithoutEvents, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
8
+ type SafeHtmlAttr = ResolvableProperties<Pick<HtmlAttributes$1, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
9
+ type SafeMeta = ResolvableProperties<Pick<MetaGeneric, 'id' | 'name' | 'property' | 'charset' | 'content' | 'media'> & DataKeys & SchemaAugmentations['meta']>;
10
+ type SafeLink = ResolvableProperties<Pick<LinkWithoutEvents, 'id' | 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesrcset' | 'imagesizes' | 'integrity' | 'media' | 'referrerpolicy' | 'rel' | 'sizes' | 'type'> & DataKeys & SchemaAugmentations['link']>;
11
+ type SafeScript = ResolvableProperties<Pick<ScriptWithoutEvents, 'id' | 'type' | 'nonce' | 'blocking'> & DataKeys & {
12
+ textContent?: string;
13
+ } & TagPriority & TagPosition & ResolvesDuplicates & ProcessesTemplateParams>;
14
+ type SafeNoscript = ResolvableProperties<Pick<Noscript$1, 'id'> & DataKeys & Omit<SchemaAugmentations['noscript'], 'innerHTML'>>;
15
+ type SafeStyle = ResolvableProperties<Pick<Style$1, 'id' | 'media' | 'nonce' | 'title' | 'blocking'> & DataKeys & Omit<SchemaAugmentations['style'], 'innerHTML'>>;
16
+ interface HeadSafe extends Pick<ResolvableHead, 'title' | 'titleTemplate' | 'templateParams'> {
17
+ /**
18
+ * The `<link>` HTML element specifies relationships between the current document and an external resource.
19
+ * This element is most commonly used to link to stylesheets, but is also used to establish site icons
20
+ * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
21
+ *
22
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
23
+ */
24
+ link?: ResolvableValue<ResolvableValue<SafeLink[]>>;
25
+ /**
26
+ * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
27
+ *
28
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
29
+ */
30
+ meta?: ResolvableValue<ResolvableValue<SafeMeta>[]>;
31
+ /**
32
+ * The `<style>` HTML element contains style information for a document, or part of a document.
33
+ * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
34
+ *
35
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
36
+ */
37
+ style?: ResolvableValue<ResolvableValue<(SafeStyle | string)>[]>;
38
+ /**
39
+ * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
40
+ *
41
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
42
+ */
43
+ script?: ResolvableValue<ResolvableValue<(SafeScript | string)>[]>;
44
+ /**
45
+ * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
46
+ * or if scripting is currently turned off in the browser.
47
+ *
48
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
49
+ */
50
+ noscript?: ResolvableValue<ResolvableValue<(SafeNoscript | string)>[]>;
51
+ /**
52
+ * Attributes for the `<html>` HTML element.
53
+ *
54
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
55
+ */
56
+ htmlAttrs?: ResolvableValue<SafeHtmlAttr>;
57
+ /**
58
+ * Attributes for the `<body>` HTML element.
59
+ *
60
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
61
+ */
62
+ bodyAttrs?: ResolvableValue<SafeBodyAttr>;
63
+ }
64
+ type UseHeadSafeInput = ResolvableValue<HeadSafe>;
65
+
66
+ /** @deprecated */
67
+ type MergeHead = object;
68
+
7
69
  type Base = RawInput<'base'>;
8
70
  type HtmlAttributes = RawInput<'htmlAttrs'>;
9
71
  type Noscript = RawInput<'noscript'>;
@@ -13,4 +75,5 @@ type Script = RawInput<'script'>;
13
75
  type Link = RawInput<'link'>;
14
76
  type BodyAttributes = RawInput<'bodyAttrs'>;
15
77
 
16
- export type { Base, BodyAttributes, HtmlAttributes, Link, Meta, Noscript, Script, Style };
78
+ export { ResolvableProperties, ResolvableValue };
79
+ export type { Base, BodyAttributes, HeadSafe, HtmlAttributes, Link, MergeHead, Meta, Noscript, SafeBodyAttr, SafeHtmlAttr, SafeLink, SafeMeta, SafeNoscript, SafeScript, SafeStyle, Script, Style, UseHeadSafeInput };
package/dist/utils.d.mts CHANGED
@@ -3,9 +3,4 @@ export * from 'unhead/utils';
3
3
 
4
4
  declare const VueResolver: PropResolver;
5
5
 
6
- /**
7
- * @deprecated Use head.resolveTags() instead
8
- */
9
- declare function resolveUnrefHeadInput<T extends Record<string, any>>(input: T): T;
10
-
11
- export { VueResolver, resolveUnrefHeadInput };
6
+ export { VueResolver };
package/dist/utils.d.ts CHANGED
@@ -3,9 +3,4 @@ export * from 'unhead/utils';
3
3
 
4
4
  declare const VueResolver: PropResolver;
5
5
 
6
- /**
7
- * @deprecated Use head.resolveTags() instead
8
- */
9
- declare function resolveUnrefHeadInput<T extends Record<string, any>>(input: T): T;
10
-
11
- export { VueResolver, resolveUnrefHeadInput };
6
+ export { VueResolver };
package/dist/utils.mjs CHANGED
@@ -1,11 +1,3 @@
1
- import { walkResolver } from 'unhead/utils';
1
+ export { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
2
2
  export * from 'unhead/utils';
3
- import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
4
3
  import 'vue';
5
-
6
- // @__NO_SIDE_EFFECTS__
7
- function resolveUnrefHeadInput(input) {
8
- return walkResolver(input, VueResolver);
9
- }
10
-
11
- export { VueResolver, resolveUnrefHeadInput };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/vue",
3
3
  "type": "module",
4
- "version": "3.0.0-beta.2",
4
+ "version": "3.0.0-beta.5",
5
5
  "description": "Full-stack <head> manager built for Vue.",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -37,14 +37,18 @@
37
37
  "types": "./dist/client.d.ts",
38
38
  "default": "./dist/client.mjs"
39
39
  },
40
+ "./stream/server": {
41
+ "types": "./dist/stream/server.d.ts",
42
+ "default": "./dist/stream/server.mjs"
43
+ },
44
+ "./stream/client": {
45
+ "types": "./dist/stream/client.d.ts",
46
+ "default": "./dist/stream/client.mjs"
47
+ },
40
48
  "./types": {
41
49
  "types": "./dist/types.d.ts",
42
50
  "default": "./dist/types.mjs"
43
51
  },
44
- "./legacy": {
45
- "types": "./dist/legacy.d.ts",
46
- "default": "./dist/legacy.mjs"
47
- },
48
52
  "./plugins": {
49
53
  "types": "./dist/plugins.d.ts",
50
54
  "default": "./dist/plugins.mjs"
@@ -56,6 +60,10 @@
56
60
  "./scripts": {
57
61
  "types": "./dist/scripts.d.ts",
58
62
  "default": "./dist/scripts.mjs"
63
+ },
64
+ "./stream/vite": {
65
+ "types": "./dist/stream/vite.d.ts",
66
+ "default": "./dist/stream/vite.mjs"
59
67
  }
60
68
  },
61
69
  "main": "dist/index.mjs",
@@ -72,12 +80,15 @@
72
80
  "client": [
73
81
  "dist/client"
74
82
  ],
83
+ "stream/server": [
84
+ "dist/stream/server"
85
+ ],
86
+ "stream/client": [
87
+ "dist/stream/client"
88
+ ],
75
89
  "types": [
76
90
  "dist/types"
77
91
  ],
78
- "legacy": [
79
- "dist/legacy"
80
- ],
81
92
  "plugins": [
82
93
  "dist/plugins"
83
94
  ],
@@ -86,6 +97,9 @@
86
97
  ],
87
98
  "scripts": [
88
99
  "dist/scripts"
100
+ ],
101
+ "stream/vite": [
102
+ "dist/stream/vite"
89
103
  ]
90
104
  }
91
105
  },
@@ -94,20 +108,29 @@
94
108
  "dist"
95
109
  ],
96
110
  "peerDependencies": {
111
+ "vite": ">=6",
97
112
  "vue": ">=3.5.18"
98
113
  },
114
+ "peerDependenciesMeta": {
115
+ "vite": {
116
+ "optional": true
117
+ }
118
+ },
99
119
  "build": {
100
120
  "external": [
101
121
  "vue"
102
122
  ]
103
123
  },
104
124
  "dependencies": {
105
- "hookable": "^5.5.3",
106
- "unhead": "3.0.0-beta.2"
125
+ "hookable": "^6.0.1",
126
+ "magic-string": "^0.30.21",
127
+ "mlly": "^1.8.0",
128
+ "unhead": "3.0.0-beta.5"
107
129
  },
108
130
  "devDependencies": {
109
- "@vue/server-renderer": "^3.5.25",
110
- "vue": "^3.5.25"
131
+ "@vue/server-renderer": "^3.5.26",
132
+ "vite": "7.2.2",
133
+ "vue": "^3.5.26"
111
134
  },
112
135
  "scripts": {
113
136
  "build": "unbuild",
package/dist/legacy.d.mts DELETED
@@ -1,34 +0,0 @@
1
- import * as unhead_types from 'unhead/types';
2
- import { CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
3
- import { createUnhead } from 'unhead';
4
- import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.DoxLTFJk.mjs';
5
- import { U as UseHeadSafeInput } from './shared/vue.DMlT7xkj.mjs';
6
- import 'vue';
7
-
8
- declare const createHeadCore: typeof createUnhead;
9
- declare function resolveUnrefHeadInput(input: any): any;
10
- declare function CapoPlugin(): unhead_types.HeadPluginInput;
11
- declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
12
- declare function createServerHead(options?: CreateClientHeadOptions): VueHeadClient;
13
- /**
14
- * @deprecated Please switch to non-legacy version
15
- */
16
- declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
17
- declare function injectHead(): VueHeadClient<any> | undefined;
18
- declare function useHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput> | void;
19
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
20
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
21
- /**
22
- * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
23
- */
24
- declare function useServerHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
25
- /**
26
- * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
27
- */
28
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
29
- /**
30
- * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
31
- */
32
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
33
-
34
- export { CapoPlugin, createHead, createHeadCore, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import * as unhead_types from 'unhead/types';
2
- import { CreateClientHeadOptions, ActiveHeadEntry } from 'unhead/types';
3
- import { createUnhead } from 'unhead';
4
- import { V as VueHeadClient, U as UseHeadInput, a as UseHeadOptions, b as UseSeoMetaInput } from './shared/vue.DoxLTFJk.js';
5
- import { U as UseHeadSafeInput } from './shared/vue.CzjZUNjB.js';
6
- import 'vue';
7
-
8
- declare const createHeadCore: typeof createUnhead;
9
- declare function resolveUnrefHeadInput(input: any): any;
10
- declare function CapoPlugin(): unhead_types.HeadPluginInput;
11
- declare function createHead(options?: CreateClientHeadOptions): VueHeadClient;
12
- declare function createServerHead(options?: CreateClientHeadOptions): VueHeadClient;
13
- /**
14
- * @deprecated Please switch to non-legacy version
15
- */
16
- declare function setHeadInjectionHandler(handler: () => VueHeadClient<any> | undefined): void;
17
- declare function injectHead(): VueHeadClient<any> | undefined;
18
- declare function useHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<UseHeadInput> | void;
19
- declare function useHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
20
- declare function useSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
21
- /**
22
- * @deprecated use `useHead` instead. Advanced use cases should tree shake using import.meta.* if statements.
23
- */
24
- declare function useServerHead(input: UseHeadInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
25
- /**
26
- * @deprecated use `useHeadSafe` instead. Advanced use cases should tree shake using import.meta.* if statements.
27
- */
28
- declare function useServerHeadSafe(input: UseHeadSafeInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
29
- /**
30
- * @deprecated use `useSeoMeta` instead. Advanced use cases should tree shake using import.meta.* if statements.
31
- */
32
- declare function useServerSeoMeta(input: UseSeoMetaInput, options?: UseHeadOptions): ActiveHeadEntry<any> | void;
33
-
34
- export { CapoPlugin, createHead, createHeadCore, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
package/dist/legacy.mjs DELETED
@@ -1,114 +0,0 @@
1
- import { createUnhead } from 'unhead';
2
- import { inject, ref, watchEffect, unref, watch, getCurrentInstance, onBeforeUnmount, onDeactivated, onActivated } from 'vue';
3
- import { createHead as createHead$1 } from './client.mjs';
4
- import { h as headSymbol } from './shared/vue.Bm-NbY4b.mjs';
5
- import { V as VueResolver } from './shared/vue.N9zWjxoK.mjs';
6
- import { createHead as createHead$2 } from './server.mjs';
7
- import { walkResolver } from 'unhead/utils';
8
- import { defineHeadPlugin, DeprecationsPlugin, PromisesPlugin, TemplateParamsPlugin, AliasSortingPlugin, SafeInputPlugin, FlatMetaPlugin } from 'unhead/plugins';
9
- import 'unhead/client';
10
- import './shared/vue.BVUAdATk.mjs';
11
- import 'unhead/server';
12
-
13
- const createHeadCore = createUnhead;
14
- function resolveUnrefHeadInput(input) {
15
- return walkResolver(input, VueResolver);
16
- }
17
- function CapoPlugin() {
18
- return defineHeadPlugin({
19
- key: "capo"
20
- });
21
- }
22
- function createHead(options = {}) {
23
- return createHead$1({
24
- disableCapoSorting: true,
25
- ...options,
26
- plugins: [
27
- DeprecationsPlugin,
28
- PromisesPlugin,
29
- TemplateParamsPlugin,
30
- AliasSortingPlugin,
31
- ...options.plugins || []
32
- ]
33
- });
34
- }
35
- function createServerHead(options = {}) {
36
- return createHead$2({
37
- disableCapoSorting: true,
38
- ...options,
39
- plugins: [
40
- DeprecationsPlugin,
41
- PromisesPlugin,
42
- TemplateParamsPlugin,
43
- AliasSortingPlugin,
44
- ...options.plugins || []
45
- ]
46
- });
47
- }
48
- function setHeadInjectionHandler(handler) {
49
- }
50
- function injectHead() {
51
- return inject(headSymbol);
52
- }
53
- function useHead(input, options = {}) {
54
- const head = options.head || injectHead();
55
- if (head) {
56
- return head.ssr ? head.push(input, options) : clientUseHead(head, input, options);
57
- }
58
- }
59
- function clientUseHead(head, input, options = {}) {
60
- const deactivated = ref(false);
61
- const resolvedInput = ref({});
62
- watchEffect(() => {
63
- resolvedInput.value = deactivated.value ? {} : walkResolver(input, (v) => unref(v));
64
- });
65
- const entry = head.push(resolvedInput.value, options);
66
- watch(resolvedInput, (e) => {
67
- entry.patch(e);
68
- });
69
- const vm = getCurrentInstance();
70
- if (vm) {
71
- onBeforeUnmount(() => {
72
- entry.dispose();
73
- });
74
- onDeactivated(() => {
75
- deactivated.value = true;
76
- });
77
- onActivated(() => {
78
- deactivated.value = false;
79
- });
80
- }
81
- return entry;
82
- }
83
- function useHeadSafe(input, options = {}) {
84
- const head = options.head || injectHead();
85
- if (head) {
86
- head.use(SafeInputPlugin);
87
- options._safe = true;
88
- return useHead(input, options);
89
- }
90
- }
91
- function useSeoMeta(input, options) {
92
- const head = options?.head || injectHead();
93
- if (head) {
94
- head.use(FlatMetaPlugin);
95
- const { title, titleTemplate, ...meta } = input;
96
- return useHead({
97
- title,
98
- titleTemplate,
99
- // @ts-expect-error runtime type
100
- _flatMeta: meta
101
- }, options);
102
- }
103
- }
104
- function useServerHead(input, options = {}) {
105
- return useHead(input, { ...options, mode: "server" });
106
- }
107
- function useServerHeadSafe(input, options = {}) {
108
- return useHeadSafe(input, { ...options, mode: "server" });
109
- }
110
- function useServerSeoMeta(input, options) {
111
- return useSeoMeta(input, { ...options, mode: "server" });
112
- }
113
-
114
- export { CapoPlugin, createHead, createHeadCore, createServerHead, injectHead, resolveUnrefHeadInput, setHeadInjectionHandler, useHead, useHeadSafe, useSeoMeta, useServerHead, useServerHeadSafe, useServerSeoMeta };
@@ -1,63 +0,0 @@
1
- import { ResolvableHead, LinkWithoutEvents, DataKeys, SchemaAugmentations, UnheadMeta, Style, ScriptWithoutEvents, TagPriority, TagPosition, ResolvesDuplicates, ProcessesTemplateParams, Noscript, HtmlAttributes, BodyAttributesWithoutEvents } from 'unhead/types';
2
- import { m as ResolvableValue, o as ResolvableProperties } from './vue.DoxLTFJk.js';
3
-
4
- type SafeBodyAttr = ResolvableProperties<Pick<BodyAttributesWithoutEvents, 'id' | 'class' | 'style'> & DataKeys & SchemaAugmentations['bodyAttrs']>;
5
- type SafeHtmlAttr = ResolvableProperties<Pick<HtmlAttributes, 'id' | 'class' | 'style' | 'lang' | 'dir'> & DataKeys & SchemaAugmentations['htmlAttrs']>;
6
- type SafeMeta = ResolvableProperties<Pick<UnheadMeta, 'id' | 'name' | 'property' | 'charset' | 'content' | 'media'> & DataKeys & SchemaAugmentations['meta']>;
7
- type SafeLink = ResolvableProperties<Pick<LinkWithoutEvents, 'id' | 'color' | 'crossorigin' | 'fetchpriority' | 'href' | 'hreflang' | 'imagesrcset' | 'imagesizes' | 'integrity' | 'media' | 'referrerpolicy' | 'rel' | 'sizes' | 'type'> & DataKeys & SchemaAugmentations['link']>;
8
- type SafeScript = ResolvableProperties<Pick<ScriptWithoutEvents, 'id' | 'type' | 'nonce' | 'blocking'> & DataKeys & {
9
- textContent?: string;
10
- } & TagPriority & TagPosition & ResolvesDuplicates & ProcessesTemplateParams>;
11
- type SafeNoscript = ResolvableProperties<Pick<Noscript, 'id'> & DataKeys & Omit<SchemaAugmentations['noscript'], 'innerHTML'>>;
12
- type SafeStyle = ResolvableProperties<Pick<Style, 'id' | 'media' | 'nonce' | 'title' | 'blocking'> & DataKeys & Omit<SchemaAugmentations['style'], 'innerHTML'>>;
13
- interface HeadSafe extends Pick<ResolvableHead, 'title' | 'titleTemplate' | 'templateParams'> {
14
- /**
15
- * The `<link>` HTML element specifies relationships between the current document and an external resource.
16
- * This element is most commonly used to link to stylesheets, but is also used to establish site icons
17
- * (both "favicon" style icons and icons for the home screen and apps on mobile devices) among other things.
18
- *
19
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#attr-as
20
- */
21
- link?: ResolvableValue<ResolvableValue<SafeLink[]>>;
22
- /**
23
- * The `<meta>` element represents metadata that cannot be expressed in other HTML elements, like `<link>` or `<script>`.
24
- *
25
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta
26
- */
27
- meta?: ResolvableValue<ResolvableValue<SafeMeta>[]>;
28
- /**
29
- * The `<style>` HTML element contains style information for a document, or part of a document.
30
- * It contains CSS, which is applied to the contents of the document containing the `<style>` element.
31
- *
32
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style
33
- */
34
- style?: ResolvableValue<ResolvableValue<(SafeStyle | string)>[]>;
35
- /**
36
- * The `<script>` HTML element is used to embed executable code or data; this is typically used to embed or refer to JavaScript code.
37
- *
38
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
39
- */
40
- script?: ResolvableValue<ResolvableValue<(SafeScript | string)>[]>;
41
- /**
42
- * The `<noscript>` HTML element defines a section of HTML to be inserted if a script type on the page is unsupported
43
- * or if scripting is currently turned off in the browser.
44
- *
45
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/noscript
46
- */
47
- noscript?: ResolvableValue<ResolvableValue<(SafeNoscript | string)>[]>;
48
- /**
49
- * Attributes for the `<html>` HTML element.
50
- *
51
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/html
52
- */
53
- htmlAttrs?: ResolvableValue<SafeHtmlAttr>;
54
- /**
55
- * Attributes for the `<body>` HTML element.
56
- *
57
- * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/body
58
- */
59
- bodyAttrs?: ResolvableValue<SafeBodyAttr>;
60
- }
61
- type UseHeadSafeInput = ResolvableValue<HeadSafe>;
62
-
63
- export type { HeadSafe as H, SafeBodyAttr as S, UseHeadSafeInput as U, SafeHtmlAttr as a, SafeMeta as b, SafeLink as c, SafeScript as d, SafeNoscript as e, SafeStyle as f };