unhead 1.3.1 → 1.3.3
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 -16
- package/dist/index.mjs +14 -16
- 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,8 @@ function createHeadCore(options = {}) {
|
|
|
276
272
|
input,
|
|
277
273
|
...entryOptions
|
|
278
274
|
};
|
|
279
|
-
const mode = activeEntry
|
|
280
|
-
if (mode)
|
|
281
|
-
activeEntry.mode = mode;
|
|
282
|
-
if (options.mode === "server" && ssr || options.mode === "client" && !ssr || !options.mode) {
|
|
275
|
+
const mode = activeEntry.mode;
|
|
276
|
+
if (!mode || mode === "server" && ssr || mode === "client" && !ssr) {
|
|
283
277
|
entries.push(activeEntry);
|
|
284
278
|
updated();
|
|
285
279
|
}
|
|
@@ -333,14 +327,18 @@ function HashHydrationPlugin() {
|
|
|
333
327
|
hooks: {
|
|
334
328
|
"init": function(_head) {
|
|
335
329
|
head = _head;
|
|
336
|
-
|
|
330
|
+
if (!head.ssr)
|
|
331
|
+
prevHash = head.resolvedOptions.document?.head.querySelector('meta[name="unhead:ssr"]')?.getAttribute("content") || false;
|
|
332
|
+
if (!prevHash)
|
|
333
|
+
dirty = true;
|
|
337
334
|
},
|
|
338
335
|
"tags:resolve": function({ tags }) {
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
336
|
+
const nonServerTags = tags.filter((tag) => {
|
|
337
|
+
const entry = head.headEntries().find((e) => e._i === tag._e);
|
|
338
|
+
return entry && entry.mode !== "server";
|
|
339
|
+
});
|
|
340
|
+
const hash = !nonServerTags.length ? false : shared.hashCode(
|
|
341
|
+
nonServerTags.map((tag) => shared.hashTag(tag)).join("")
|
|
344
342
|
);
|
|
345
343
|
if (prevHash !== hash && prevHash !== false)
|
|
346
344
|
dirty = true;
|
|
@@ -352,7 +350,7 @@ function HashHydrationPlugin() {
|
|
|
352
350
|
dirty = false;
|
|
353
351
|
},
|
|
354
352
|
"ssr:render": function({ tags }) {
|
|
355
|
-
tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
353
|
+
prevHash && tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
356
354
|
}
|
|
357
355
|
}
|
|
358
356
|
});
|
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,8 @@ function createHeadCore(options = {}) {
|
|
|
275
271
|
input,
|
|
276
272
|
...entryOptions
|
|
277
273
|
};
|
|
278
|
-
const mode = activeEntry
|
|
279
|
-
if (mode)
|
|
280
|
-
activeEntry.mode = mode;
|
|
281
|
-
if (options.mode === "server" && ssr || options.mode === "client" && !ssr || !options.mode) {
|
|
274
|
+
const mode = activeEntry.mode;
|
|
275
|
+
if (!mode || mode === "server" && ssr || mode === "client" && !ssr) {
|
|
282
276
|
entries.push(activeEntry);
|
|
283
277
|
updated();
|
|
284
278
|
}
|
|
@@ -332,14 +326,18 @@ function HashHydrationPlugin() {
|
|
|
332
326
|
hooks: {
|
|
333
327
|
"init": function(_head) {
|
|
334
328
|
head = _head;
|
|
335
|
-
|
|
329
|
+
if (!head.ssr)
|
|
330
|
+
prevHash = head.resolvedOptions.document?.head.querySelector('meta[name="unhead:ssr"]')?.getAttribute("content") || false;
|
|
331
|
+
if (!prevHash)
|
|
332
|
+
dirty = true;
|
|
336
333
|
},
|
|
337
334
|
"tags:resolve": function({ tags }) {
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
const nonServerTags = tags.filter((tag) => {
|
|
336
|
+
const entry = head.headEntries().find((e) => e._i === tag._e);
|
|
337
|
+
return entry && entry.mode !== "server";
|
|
338
|
+
});
|
|
339
|
+
const hash = !nonServerTags.length ? false : hashCode(
|
|
340
|
+
nonServerTags.map((tag) => hashTag(tag)).join("")
|
|
343
341
|
);
|
|
344
342
|
if (prevHash !== hash && prevHash !== false)
|
|
345
343
|
dirty = true;
|
|
@@ -351,7 +349,7 @@ function HashHydrationPlugin() {
|
|
|
351
349
|
dirty = false;
|
|
352
350
|
},
|
|
353
351
|
"ssr:render": function({ tags }) {
|
|
354
|
-
tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
352
|
+
prevHash && tags.push({ tag: "meta", props: { name: "unhead:ssr", content: String(prevHash) } });
|
|
355
353
|
}
|
|
356
354
|
}
|
|
357
355
|
});
|
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.3",
|
|
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.3",
|
|
34
|
+
"@unhead/schema": "1.3.3",
|
|
35
|
+
"@unhead/shared": "1.3.3"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "unbuild .",
|