@unhead/ssr 1.10.3 → 1.11.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -19,6 +19,30 @@ function propsToString(props) {
19
19
  return attrs;
20
20
  }
21
21
 
22
+ function ssrRenderTags(tags, options) {
23
+ const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
24
+ const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
25
+ for (const tag of tags) {
26
+ if (Object.keys(tag.props).length === 0 && !tag.innerHTML && !tag.textContent) {
27
+ continue;
28
+ }
29
+ if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
30
+ Object.assign(schema[tag.tag], tag.props);
31
+ continue;
32
+ }
33
+ const s = tagToString(tag);
34
+ const tagPosition = tag.tagPosition || "head";
35
+ schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
36
+ }
37
+ return {
38
+ headTags: schema.tags.head,
39
+ bodyTags: schema.tags.bodyClose,
40
+ bodyTagsOpen: schema.tags.bodyOpen,
41
+ htmlAttrs: propsToString(schema.htmlAttrs),
42
+ bodyAttrs: propsToString(schema.bodyAttrs)
43
+ };
44
+ }
45
+
22
46
  function escapeHtml(str) {
23
47
  return str.replace(/[&<>"'/]/g, (char) => {
24
48
  switch (char) {
@@ -50,27 +74,6 @@ function tagToString(tag) {
50
74
  return shared.SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
51
75
  }
52
76
 
53
- function ssrRenderTags(tags, options) {
54
- const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
55
- const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
56
- for (const tag of tags) {
57
- if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
58
- Object.assign(schema[tag.tag], tag.props);
59
- continue;
60
- }
61
- const s = tagToString(tag);
62
- const tagPosition = tag.tagPosition || "head";
63
- schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
64
- }
65
- return {
66
- headTags: schema.tags.head,
67
- bodyTags: schema.tags.bodyClose,
68
- bodyTagsOpen: schema.tags.bodyOpen,
69
- htmlAttrs: propsToString(schema.htmlAttrs),
70
- bodyAttrs: propsToString(schema.bodyAttrs)
71
- };
72
- }
73
-
74
77
  async function renderSSRHead(head, options) {
75
78
  const beforeRenderCtx = { shouldRender: true };
76
79
  await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
package/dist/index.d.cts CHANGED
@@ -5,9 +5,6 @@ declare function renderSSRHead<T extends {}>(head: Unhead<T>, options?: RenderSS
5
5
 
6
6
  declare function propsToString(props: Record<string, any>): string;
7
7
 
8
- declare function escapeHtml(str: string): string;
9
- declare function tagToString<T extends HeadTag>(tag: T): string;
10
-
11
8
  declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSRHeadOptions): {
12
9
  headTags: string;
13
10
  bodyTags: string;
@@ -16,4 +13,7 @@ declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSR
16
13
  bodyAttrs: string;
17
14
  };
18
15
 
16
+ declare function escapeHtml(str: string): string;
17
+ declare function tagToString<T extends HeadTag>(tag: T): string;
18
+
19
19
  export { escapeHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString };
package/dist/index.d.mts CHANGED
@@ -5,9 +5,6 @@ declare function renderSSRHead<T extends {}>(head: Unhead<T>, options?: RenderSS
5
5
 
6
6
  declare function propsToString(props: Record<string, any>): string;
7
7
 
8
- declare function escapeHtml(str: string): string;
9
- declare function tagToString<T extends HeadTag>(tag: T): string;
10
-
11
8
  declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSRHeadOptions): {
12
9
  headTags: string;
13
10
  bodyTags: string;
@@ -16,4 +13,7 @@ declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSR
16
13
  bodyAttrs: string;
17
14
  };
18
15
 
16
+ declare function escapeHtml(str: string): string;
17
+ declare function tagToString<T extends HeadTag>(tag: T): string;
18
+
19
19
  export { escapeHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString };
package/dist/index.d.ts CHANGED
@@ -5,9 +5,6 @@ declare function renderSSRHead<T extends {}>(head: Unhead<T>, options?: RenderSS
5
5
 
6
6
  declare function propsToString(props: Record<string, any>): string;
7
7
 
8
- declare function escapeHtml(str: string): string;
9
- declare function tagToString<T extends HeadTag>(tag: T): string;
10
-
11
8
  declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSRHeadOptions): {
12
9
  headTags: string;
13
10
  bodyTags: string;
@@ -16,4 +13,7 @@ declare function ssrRenderTags<T extends HeadTag>(tags: T[], options?: RenderSSR
16
13
  bodyAttrs: string;
17
14
  };
18
15
 
16
+ declare function escapeHtml(str: string): string;
17
+ declare function tagToString<T extends HeadTag>(tag: T): string;
18
+
19
19
  export { escapeHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString };
package/dist/index.mjs CHANGED
@@ -17,6 +17,30 @@ function propsToString(props) {
17
17
  return attrs;
18
18
  }
19
19
 
20
+ function ssrRenderTags(tags, options) {
21
+ const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
22
+ const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
23
+ for (const tag of tags) {
24
+ if (Object.keys(tag.props).length === 0 && !tag.innerHTML && !tag.textContent) {
25
+ continue;
26
+ }
27
+ if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
28
+ Object.assign(schema[tag.tag], tag.props);
29
+ continue;
30
+ }
31
+ const s = tagToString(tag);
32
+ const tagPosition = tag.tagPosition || "head";
33
+ schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
34
+ }
35
+ return {
36
+ headTags: schema.tags.head,
37
+ bodyTags: schema.tags.bodyClose,
38
+ bodyTagsOpen: schema.tags.bodyOpen,
39
+ htmlAttrs: propsToString(schema.htmlAttrs),
40
+ bodyAttrs: propsToString(schema.bodyAttrs)
41
+ };
42
+ }
43
+
20
44
  function escapeHtml(str) {
21
45
  return str.replace(/[&<>"'/]/g, (char) => {
22
46
  switch (char) {
@@ -48,27 +72,6 @@ function tagToString(tag) {
48
72
  return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
49
73
  }
50
74
 
51
- function ssrRenderTags(tags, options) {
52
- const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
53
- const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
54
- for (const tag of tags) {
55
- if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
56
- Object.assign(schema[tag.tag], tag.props);
57
- continue;
58
- }
59
- const s = tagToString(tag);
60
- const tagPosition = tag.tagPosition || "head";
61
- schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
62
- }
63
- return {
64
- headTags: schema.tags.head,
65
- bodyTags: schema.tags.bodyClose,
66
- bodyTagsOpen: schema.tags.bodyOpen,
67
- htmlAttrs: propsToString(schema.htmlAttrs),
68
- bodyAttrs: propsToString(schema.bodyAttrs)
69
- };
70
- }
71
-
72
75
  async function renderSSRHead(head, options) {
73
76
  const beforeRenderCtx = { shouldRender: true };
74
77
  await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/ssr",
3
3
  "type": "module",
4
- "version": "1.10.3",
4
+ "version": "1.11.0-beta.1",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -29,8 +29,8 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@unhead/schema": "1.10.3",
33
- "@unhead/shared": "1.10.3"
32
+ "@unhead/schema": "1.11.0-beta.1",
33
+ "@unhead/shared": "1.11.0-beta.1"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "unbuild .",