unhead 1.3.1 → 1.3.2
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 +14 -14
- package/dist/index.mjs +14 -14
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -236,11 +236,7 @@ function createHead(options = {}) {
|
|
|
236
236
|
return activeHead = head;
|
|
237
237
|
}
|
|
238
238
|
function createServerHead(options = {}) {
|
|
239
|
-
|
|
240
|
-
...options,
|
|
241
|
-
mode: "server"
|
|
242
|
-
});
|
|
243
|
-
return activeHead = head;
|
|
239
|
+
return activeHead = createHeadCore(options);
|
|
244
240
|
}
|
|
245
241
|
function createHeadCore(options = {}) {
|
|
246
242
|
const hooks = hookable.createHooks();
|
|
@@ -276,10 +272,10 @@ function createHeadCore(options = {}) {
|
|
|
276
272
|
input,
|
|
277
273
|
...entryOptions
|
|
278
274
|
};
|
|
279
|
-
const mode = activeEntry?.mode
|
|
275
|
+
const mode = activeEntry?.mode;
|
|
280
276
|
if (mode)
|
|
281
277
|
activeEntry.mode = mode;
|
|
282
|
-
if (
|
|
278
|
+
if (!mode || mode === "server" && ssr || mode === "client" && !ssr) {
|
|
283
279
|
entries.push(activeEntry);
|
|
284
280
|
updated();
|
|
285
281
|
}
|
|
@@ -333,14 +329,18 @@ function HashHydrationPlugin() {
|
|
|
333
329
|
hooks: {
|
|
334
330
|
"init": function(_head) {
|
|
335
331
|
head = _head;
|
|
336
|
-
|
|
332
|
+
if (!head.ssr)
|
|
333
|
+
prevHash = head.resolvedOptions.document?.head.querySelector('meta[name="unhead:ssr"]')?.getAttribute("content") || false;
|
|
334
|
+
if (!prevHash)
|
|
335
|
+
dirty = true;
|
|
337
336
|
},
|
|
338
337
|
"tags:resolve": function({ tags }) {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
338
|
+
const nonServerTags = tags.filter((tag) => {
|
|
339
|
+
const entry = head.headEntries().find((e) => e._i === tag._e);
|
|
340
|
+
return entry && entry.mode !== "server";
|
|
341
|
+
});
|
|
342
|
+
const hash = !nonServerTags.length ? false : shared.hashCode(
|
|
343
|
+
nonServerTags.map((tag) => shared.hashTag(tag)).join("")
|
|
344
344
|
);
|
|
345
345
|
if (prevHash !== hash && prevHash !== false)
|
|
346
346
|
dirty = true;
|
|
@@ -352,7 +352,7 @@ function HashHydrationPlugin() {
|
|
|
352
352
|
dirty = false;
|
|
353
353
|
},
|
|
354
354
|
"ssr:render": function({ tags }) {
|
|
355
|
-
tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
355
|
+
prevHash && tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -235,11 +235,7 @@ function createHead(options = {}) {
|
|
|
235
235
|
return activeHead = head;
|
|
236
236
|
}
|
|
237
237
|
function createServerHead(options = {}) {
|
|
238
|
-
|
|
239
|
-
...options,
|
|
240
|
-
mode: "server"
|
|
241
|
-
});
|
|
242
|
-
return activeHead = head;
|
|
238
|
+
return activeHead = createHeadCore(options);
|
|
243
239
|
}
|
|
244
240
|
function createHeadCore(options = {}) {
|
|
245
241
|
const hooks = createHooks();
|
|
@@ -275,10 +271,10 @@ function createHeadCore(options = {}) {
|
|
|
275
271
|
input,
|
|
276
272
|
...entryOptions
|
|
277
273
|
};
|
|
278
|
-
const mode = activeEntry?.mode
|
|
274
|
+
const mode = activeEntry?.mode;
|
|
279
275
|
if (mode)
|
|
280
276
|
activeEntry.mode = mode;
|
|
281
|
-
if (
|
|
277
|
+
if (!mode || mode === "server" && ssr || mode === "client" && !ssr) {
|
|
282
278
|
entries.push(activeEntry);
|
|
283
279
|
updated();
|
|
284
280
|
}
|
|
@@ -332,14 +328,18 @@ function HashHydrationPlugin() {
|
|
|
332
328
|
hooks: {
|
|
333
329
|
"init": function(_head) {
|
|
334
330
|
head = _head;
|
|
335
|
-
|
|
331
|
+
if (!head.ssr)
|
|
332
|
+
prevHash = head.resolvedOptions.document?.head.querySelector('meta[name="unhead:ssr"]')?.getAttribute("content") || false;
|
|
333
|
+
if (!prevHash)
|
|
334
|
+
dirty = true;
|
|
336
335
|
},
|
|
337
336
|
"tags:resolve": function({ tags }) {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
337
|
+
const nonServerTags = tags.filter((tag) => {
|
|
338
|
+
const entry = head.headEntries().find((e) => e._i === tag._e);
|
|
339
|
+
return entry && entry.mode !== "server";
|
|
340
|
+
});
|
|
341
|
+
const hash = !nonServerTags.length ? false : hashCode(
|
|
342
|
+
nonServerTags.map((tag) => hashTag(tag)).join("")
|
|
343
343
|
);
|
|
344
344
|
if (prevHash !== hash && prevHash !== false)
|
|
345
345
|
dirty = true;
|
|
@@ -351,7 +351,7 @@ function HashHydrationPlugin() {
|
|
|
351
351
|
dirty = false;
|
|
352
352
|
},
|
|
353
353
|
"ssr:render": function({ tags }) {
|
|
354
|
-
tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
354
|
+
prevHash && tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unhead",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.2",
|
|
5
5
|
"author": "Harlan Wilton <harlan@harlanzw.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/harlan-zw",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"hookable": "^5.5.3",
|
|
33
|
-
"@unhead/dom": "1.3.
|
|
34
|
-
"@unhead/schema": "1.3.
|
|
35
|
-
"@unhead/shared": "1.3.
|
|
33
|
+
"@unhead/dom": "1.3.2",
|
|
34
|
+
"@unhead/schema": "1.3.2",
|
|
35
|
+
"@unhead/shared": "1.3.2"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild .",
|