@unhead/dom 1.3.2 → 1.3.4
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 +12 -7
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +12 -7
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -114,16 +114,21 @@ async function debouncedRenderDOMHead(head, options = {}) {
|
|
|
114
114
|
}));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
function
|
|
118
|
-
return shared.defineHeadPlugin({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
function DomPlugin(options) {
|
|
118
|
+
return shared.defineHeadPlugin((head) => {
|
|
119
|
+
const initialPayload = head.resolvedOptions.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
120
|
+
initialPayload && head.push(JSON.parse(initialPayload));
|
|
121
|
+
return {
|
|
122
|
+
mode: "client",
|
|
123
|
+
hooks: {
|
|
124
|
+
"entries:updated": function(head2) {
|
|
125
|
+
debouncedRenderDOMHead(head2, options);
|
|
126
|
+
}
|
|
122
127
|
}
|
|
123
|
-
}
|
|
128
|
+
};
|
|
124
129
|
});
|
|
125
130
|
}
|
|
126
131
|
|
|
127
|
-
exports.
|
|
132
|
+
exports.DomPlugin = DomPlugin;
|
|
128
133
|
exports.debouncedRenderDOMHead = debouncedRenderDOMHead;
|
|
129
134
|
exports.renderDOMHead = renderDOMHead;
|
package/dist/index.d.ts
CHANGED
|
@@ -12,10 +12,10 @@ interface RenderDomHeadOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
declare function renderDOMHead<T extends Unhead<any>>(head: T, options?: RenderDomHeadOptions): Promise<void>;
|
|
14
14
|
|
|
15
|
-
interface
|
|
15
|
+
interface DomPluginOptions extends RenderDomHeadOptions {
|
|
16
16
|
delayFn?: (fn: () => void) => void;
|
|
17
17
|
}
|
|
18
|
-
declare function
|
|
18
|
+
declare function DomPlugin(options?: DomPluginOptions): _unhead_schema.HeadPlugin;
|
|
19
19
|
|
|
20
20
|
interface DebouncedRenderDomHeadOptions extends RenderDomHeadOptions {
|
|
21
21
|
/**
|
|
@@ -28,4 +28,4 @@ interface DebouncedRenderDomHeadOptions extends RenderDomHeadOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
declare function debouncedRenderDOMHead<T extends Unhead<any>>(head: T, options?: DebouncedRenderDomHeadOptions): Promise<void>;
|
|
30
30
|
|
|
31
|
-
export { DebouncedRenderDomHeadOptions,
|
|
31
|
+
export { DebouncedRenderDomHeadOptions, DomPlugin, DomPluginOptions, RenderDomHeadOptions, debouncedRenderDOMHead, renderDOMHead };
|
package/dist/index.mjs
CHANGED
|
@@ -112,14 +112,19 @@ async function debouncedRenderDOMHead(head, options = {}) {
|
|
|
112
112
|
}));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
function
|
|
116
|
-
return defineHeadPlugin({
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
function DomPlugin(options) {
|
|
116
|
+
return defineHeadPlugin((head) => {
|
|
117
|
+
const initialPayload = head.resolvedOptions.document?.head.querySelector('script[id="unhead:payload"]')?.innerHTML || false;
|
|
118
|
+
initialPayload && head.push(JSON.parse(initialPayload));
|
|
119
|
+
return {
|
|
120
|
+
mode: "client",
|
|
121
|
+
hooks: {
|
|
122
|
+
"entries:updated": function(head2) {
|
|
123
|
+
debouncedRenderDOMHead(head2, options);
|
|
124
|
+
}
|
|
120
125
|
}
|
|
121
|
-
}
|
|
126
|
+
};
|
|
122
127
|
});
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
export {
|
|
130
|
+
export { DomPlugin, debouncedRenderDOMHead, renderDOMHead };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unhead/dom",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.3.
|
|
4
|
+
"version": "1.3.4",
|
|
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.3.
|
|
33
|
-
"@unhead/shared": "1.3.
|
|
32
|
+
"@unhead/schema": "1.3.4",
|
|
33
|
+
"@unhead/shared": "1.3.4"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "unbuild .",
|