@pyreon/head 0.5.6 → 0.6.0
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/lib/analysis/index.js.html +1 -1
- package/lib/analysis/provider.js.html +1 -1
- package/lib/index.js +2 -4
- package/lib/index.js.map +1 -1
- package/lib/provider.js +2 -4
- package/lib/provider.js.map +1 -1
- package/lib/types/index.d.ts +206 -283
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/ssr.d.ts +28 -87
- package/lib/types/ssr.d.ts.map +1 -1
- package/lib/types/use-head.d.ts +126 -202
- package/lib/types/use-head.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/provider.ts +3 -7
package/lib/types/ssr.d.ts
CHANGED
|
@@ -1,90 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { renderToString } from "@pyreon/runtime-server";
|
|
1
|
+
import { VNode } from "@pyreon/core";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
cachedHtmlAttrs = htmlAttrs;
|
|
29
|
-
cachedBodyAttrs = bodyAttrs;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
add(id, entry) {
|
|
33
|
-
map.set(id, entry);
|
|
34
|
-
dirty = true;
|
|
35
|
-
},
|
|
36
|
-
remove(id) {
|
|
37
|
-
map.delete(id);
|
|
38
|
-
dirty = true;
|
|
39
|
-
},
|
|
40
|
-
resolve() {
|
|
41
|
-
rebuild();
|
|
42
|
-
return cachedTags;
|
|
43
|
-
},
|
|
44
|
-
resolveTitleTemplate() {
|
|
45
|
-
rebuild();
|
|
46
|
-
return cachedTitleTemplate;
|
|
47
|
-
},
|
|
48
|
-
resolveHtmlAttrs() {
|
|
49
|
-
rebuild();
|
|
50
|
-
return cachedHtmlAttrs;
|
|
51
|
-
},
|
|
52
|
-
resolveBodyAttrs() {
|
|
53
|
-
rebuild();
|
|
54
|
-
return cachedBodyAttrs;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
3
|
+
//#region src/ssr.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Render a Pyreon app to an HTML fragment + a serialized <head> string.
|
|
6
|
+
*
|
|
7
|
+
* The returned `head` string can be injected directly into your HTML template:
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const { html, head } = await renderWithHead(h(App, null))
|
|
11
|
+
* const page = `<!DOCTYPE html>
|
|
12
|
+
* <html>
|
|
13
|
+
* <head>
|
|
14
|
+
* <meta charset="UTF-8" />
|
|
15
|
+
* ${head}
|
|
16
|
+
* </head>
|
|
17
|
+
* <body><div id="app">${html}</div></body>
|
|
18
|
+
* </html>`
|
|
19
|
+
*/
|
|
20
|
+
interface RenderWithHeadResult {
|
|
21
|
+
html: string;
|
|
22
|
+
head: string;
|
|
23
|
+
/** Attributes to set on the <html> element */
|
|
24
|
+
htmlAttrs: Record<string, string>;
|
|
25
|
+
/** Attributes to set on the <body> element */
|
|
26
|
+
bodyAttrs: Record<string, string>;
|
|
57
27
|
}
|
|
58
|
-
|
|
59
|
-
const ctx = createHeadContext();
|
|
60
|
-
function HeadInjector() {
|
|
61
|
-
pushContext(new Map([[HeadContext.id, ctx]]));
|
|
62
|
-
return app;
|
|
63
|
-
}
|
|
64
|
-
const html = await renderToString(h(HeadInjector, null));
|
|
65
|
-
const titleTemplate = ctx.resolveTitleTemplate();
|
|
66
|
-
return {
|
|
67
|
-
html,
|
|
68
|
-
head: ctx.resolve().map(tag => serializeTag(tag, titleTemplate)).join("\n "),
|
|
69
|
-
htmlAttrs: ctx.resolveHtmlAttrs(),
|
|
70
|
-
bodyAttrs: ctx.resolveBodyAttrs()
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function serializeTag(tag, titleTemplate) {
|
|
74
|
-
if (tag.tag === "title") {
|
|
75
|
-
const raw = tag.children || "";
|
|
76
|
-
return `<title>${esc(titleTemplate ? typeof titleTemplate === "function" ? titleTemplate(raw) : titleTemplate.replace(/%s/g, raw) : raw)}</title>`;
|
|
77
|
-
}
|
|
78
|
-
const props = tag.props;
|
|
79
|
-
const attrs = props ? Object.entries(props).map(([k, v]) => `${k}="${esc(v)}"`).join(" ") : "";
|
|
80
|
-
const open = attrs ? `<${tag.tag} ${attrs}` : `<${tag.tag}`;
|
|
81
|
-
if (VOID_TAGS.has(tag.tag)) return `${open} />`;
|
|
82
|
-
return `${open}>${(tag.children || "").replace(/<\/(script|style|noscript)/gi, "<\\/$1").replace(/<!--/g, "<\\!--")}</${tag.tag}>`;
|
|
83
|
-
}
|
|
84
|
-
function esc(s) {
|
|
85
|
-
return ESC_RE.test(s) ? s.replace(ESC_RE, ch => ESC_MAP[ch]) : s;
|
|
86
|
-
}
|
|
87
|
-
|
|
28
|
+
declare function renderWithHead(app: VNode): Promise<RenderWithHeadResult>;
|
|
88
29
|
//#endregion
|
|
89
|
-
export { renderWithHead };
|
|
90
|
-
//# sourceMappingURL=
|
|
30
|
+
export { RenderWithHeadResult, renderWithHead };
|
|
31
|
+
//# sourceMappingURL=ssr2.d.ts.map
|
package/lib/types/ssr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"ssr2.d.ts","names":[],"sources":["../../../src/ssr.ts"],"mappings":";;;;;AAwBA;;;;;;;;;;;;AASA;;UATiB,oBAAA;EACf,IAAA;EACA,IAAA;EAOgD;EALhD,SAAA,EAAW,MAAA;EAK4C;EAHvD,SAAA,EAAW,MAAA;AAAA;AAAA,iBAGS,cAAA,CAAe,GAAA,EAAK,KAAA,GAAQ,OAAA,CAAQ,oBAAA"}
|
package/lib/types/use-head.d.ts
CHANGED
|
@@ -1,212 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
//#region src/context.d.ts
|
|
2
|
+
/** Standard `<meta>` tag attributes. Catches typos like `{ naem: "description" }`. */
|
|
3
|
+
interface MetaTag {
|
|
4
|
+
/** Standard meta name (e.g. "description", "viewport", "robots") */
|
|
5
|
+
name?: string;
|
|
6
|
+
/** Open Graph / social property (e.g. "og:title", "twitter:card") */
|
|
7
|
+
property?: string;
|
|
8
|
+
/** HTTP equivalent header (e.g. "refresh", "content-type") */
|
|
9
|
+
"http-equiv"?: string;
|
|
10
|
+
/** Value associated with name, property, or http-equiv */
|
|
11
|
+
content?: string;
|
|
12
|
+
/** Document character encoding (e.g. "utf-8") */
|
|
13
|
+
charset?: string;
|
|
14
|
+
/** Schema.org itemprop */
|
|
15
|
+
itemprop?: string;
|
|
16
|
+
/** Media condition for applicability (e.g. "(prefers-color-scheme: dark)") */
|
|
17
|
+
media?: string;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
/** Standard `<link>` tag attributes. */
|
|
20
|
+
interface LinkTag {
|
|
21
|
+
/** Relationship to the current document (e.g. "stylesheet", "icon", "canonical") */
|
|
22
|
+
rel?: string;
|
|
23
|
+
/** URL of the linked resource */
|
|
24
|
+
href?: string;
|
|
25
|
+
/** Resource type hint for preloading (e.g. "style", "script", "font") */
|
|
26
|
+
as?: string;
|
|
27
|
+
/** MIME type (e.g. "text/css", "image/png") */
|
|
28
|
+
type?: string;
|
|
29
|
+
/** Media query for conditional loading */
|
|
30
|
+
media?: string;
|
|
31
|
+
/** CORS mode */
|
|
32
|
+
crossorigin?: string;
|
|
33
|
+
/** Subresource integrity hash */
|
|
34
|
+
integrity?: string;
|
|
35
|
+
/** Icon sizes (e.g. "32x32", "any") */
|
|
36
|
+
sizes?: string;
|
|
37
|
+
/** Language of the linked resource */
|
|
38
|
+
hreflang?: string;
|
|
39
|
+
/** Title for the link (used for alternate stylesheets) */
|
|
40
|
+
title?: string;
|
|
41
|
+
/** Fetch priority hint */
|
|
42
|
+
fetchpriority?: "high" | "low" | "auto";
|
|
43
|
+
/** Referrer policy */
|
|
44
|
+
referrerpolicy?: string;
|
|
45
|
+
/** Image source set for preloading responsive images */
|
|
46
|
+
imagesrcset?: string;
|
|
47
|
+
/** Image sizes for preloading responsive images */
|
|
48
|
+
imagesizes?: string;
|
|
49
|
+
/** Disable the resource (for stylesheets) */
|
|
50
|
+
disabled?: string;
|
|
51
|
+
/** Color for mask-icon */
|
|
52
|
+
color?: string;
|
|
27
53
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const key = tag.key;
|
|
51
|
-
const found = managedElements.get(key);
|
|
52
|
-
if (found && found.tagName.toLowerCase() === tag.tag) patchExistingTag(found, tag, kept);else {
|
|
53
|
-
if (found) {
|
|
54
|
-
found.remove();
|
|
55
|
-
managedElements.delete(key);
|
|
56
|
-
}
|
|
57
|
-
createNewTag(tag);
|
|
58
|
-
kept.add(key);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
for (const [key, el] of managedElements) if (!kept.has(key)) {
|
|
62
|
-
el.remove();
|
|
63
|
-
managedElements.delete(key);
|
|
64
|
-
}
|
|
65
|
-
syncElementAttrs(document.documentElement, ctx.resolveHtmlAttrs());
|
|
66
|
-
syncElementAttrs(document.body, ctx.resolveBodyAttrs());
|
|
54
|
+
/** Standard `<script>` tag attributes. */
|
|
55
|
+
interface ScriptTag {
|
|
56
|
+
/** External script URL */
|
|
57
|
+
src?: string;
|
|
58
|
+
/** Script MIME type or module type (e.g. "module", "importmap") */
|
|
59
|
+
type?: string;
|
|
60
|
+
/** Load asynchronously */
|
|
61
|
+
async?: string;
|
|
62
|
+
/** Defer execution until document is parsed */
|
|
63
|
+
defer?: string;
|
|
64
|
+
/** CORS mode */
|
|
65
|
+
crossorigin?: string;
|
|
66
|
+
/** Subresource integrity hash */
|
|
67
|
+
integrity?: string;
|
|
68
|
+
/** Exclude from module-supporting browsers */
|
|
69
|
+
nomodule?: string;
|
|
70
|
+
/** Referrer policy */
|
|
71
|
+
referrerpolicy?: string;
|
|
72
|
+
/** Fetch priority hint */
|
|
73
|
+
fetchpriority?: string;
|
|
74
|
+
/** Inline script content */
|
|
75
|
+
children?: string;
|
|
67
76
|
}
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
/** Standard `<style>` tag attributes. */
|
|
78
|
+
interface StyleTag {
|
|
79
|
+
/** Inline CSS content (required) */
|
|
80
|
+
children: string;
|
|
81
|
+
/** Media query for conditional styles */
|
|
82
|
+
media?: string;
|
|
83
|
+
/** Nonce for CSP */
|
|
84
|
+
nonce?: string;
|
|
85
|
+
/** Title for alternate stylesheets */
|
|
86
|
+
title?: string;
|
|
87
|
+
/** Render-blocking behavior */
|
|
88
|
+
blocking?: string;
|
|
76
89
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
/** Standard `<base>` tag attributes. */
|
|
91
|
+
interface BaseTag {
|
|
92
|
+
/** Base URL for relative URLs in the document */
|
|
93
|
+
href?: string;
|
|
94
|
+
/** Default target for links and forms */
|
|
95
|
+
target?: "_blank" | "_self" | "_parent" | "_top";
|
|
81
96
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
interface UseHeadInput {
|
|
98
|
+
title?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Title template — use `%s` as a placeholder for the page title.
|
|
101
|
+
* Applied to the resolved title after deduplication.
|
|
102
|
+
* @example useHead({ titleTemplate: "%s | My App" })
|
|
103
|
+
*/
|
|
104
|
+
titleTemplate?: string | ((title: string) => string);
|
|
105
|
+
meta?: MetaTag[];
|
|
106
|
+
link?: LinkTag[];
|
|
107
|
+
script?: ScriptTag[];
|
|
108
|
+
style?: StyleTag[];
|
|
109
|
+
noscript?: {
|
|
110
|
+
children: string;
|
|
111
|
+
}[];
|
|
112
|
+
/** Convenience: emits a <script type="application/ld+json"> tag with JSON.stringify'd content */
|
|
113
|
+
jsonLd?: Record<string, unknown> | Record<string, unknown>[];
|
|
114
|
+
base?: BaseTag;
|
|
115
|
+
/** Attributes to set on the <html> element (e.g. { lang: "en", dir: "ltr" }) */
|
|
116
|
+
htmlAttrs?: Record<string, string>;
|
|
117
|
+
/** Attributes to set on the <body> element (e.g. { class: "dark" }) */
|
|
118
|
+
bodyAttrs?: Record<string, string>;
|
|
94
119
|
}
|
|
95
|
-
|
|
96
120
|
//#endregion
|
|
97
|
-
//#region src/use-head.ts
|
|
98
|
-
/** Cast a strict tag interface to the internal props format, stripping undefined values */
|
|
99
|
-
function toProps(obj) {
|
|
100
|
-
const result = {};
|
|
101
|
-
for (const [k, v] of Object.entries(obj)) if (v !== void 0) result[k] = v;
|
|
102
|
-
return result;
|
|
103
|
-
}
|
|
104
|
-
function buildEntry(o) {
|
|
105
|
-
const tags = [];
|
|
106
|
-
if (o.title != null) tags.push({
|
|
107
|
-
tag: "title",
|
|
108
|
-
key: "title",
|
|
109
|
-
children: o.title
|
|
110
|
-
});
|
|
111
|
-
o.meta?.forEach((m, i) => {
|
|
112
|
-
tags.push({
|
|
113
|
-
tag: "meta",
|
|
114
|
-
key: m.name ?? m.property ?? `meta-${i}`,
|
|
115
|
-
props: toProps(m)
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
o.link?.forEach((l, i) => {
|
|
119
|
-
tags.push({
|
|
120
|
-
tag: "link",
|
|
121
|
-
key: l.href ? `link-${l.rel || ""}-${l.href}` : l.rel ? `link-${l.rel}` : `link-${i}`,
|
|
122
|
-
props: toProps(l)
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
o.script?.forEach((s, i) => {
|
|
126
|
-
const {
|
|
127
|
-
children,
|
|
128
|
-
...rest
|
|
129
|
-
} = s;
|
|
130
|
-
tags.push({
|
|
131
|
-
tag: "script",
|
|
132
|
-
key: s.src ?? `script-${i}`,
|
|
133
|
-
props: toProps(rest),
|
|
134
|
-
...(children != null ? {
|
|
135
|
-
children
|
|
136
|
-
} : {})
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
o.style?.forEach((s, i) => {
|
|
140
|
-
const {
|
|
141
|
-
children,
|
|
142
|
-
...rest
|
|
143
|
-
} = s;
|
|
144
|
-
tags.push({
|
|
145
|
-
tag: "style",
|
|
146
|
-
key: `style-${i}`,
|
|
147
|
-
props: toProps(rest),
|
|
148
|
-
children
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
o.noscript?.forEach((ns, i) => {
|
|
152
|
-
tags.push({
|
|
153
|
-
tag: "noscript",
|
|
154
|
-
key: `noscript-${i}`,
|
|
155
|
-
children: ns.children
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
if (o.jsonLd) tags.push({
|
|
159
|
-
tag: "script",
|
|
160
|
-
key: "jsonld",
|
|
161
|
-
props: {
|
|
162
|
-
type: "application/ld+json"
|
|
163
|
-
},
|
|
164
|
-
children: JSON.stringify(o.jsonLd)
|
|
165
|
-
});
|
|
166
|
-
if (o.base) tags.push({
|
|
167
|
-
tag: "base",
|
|
168
|
-
key: "base",
|
|
169
|
-
props: toProps(o.base)
|
|
170
|
-
});
|
|
171
|
-
return {
|
|
172
|
-
tags,
|
|
173
|
-
titleTemplate: o.titleTemplate,
|
|
174
|
-
htmlAttrs: o.htmlAttrs,
|
|
175
|
-
bodyAttrs: o.bodyAttrs
|
|
176
|
-
};
|
|
177
|
-
}
|
|
121
|
+
//#region src/use-head.d.ts
|
|
178
122
|
/**
|
|
179
|
-
* Register head tags (title, meta, link, script, style, noscript, base, jsonLd)
|
|
180
|
-
* for the current component.
|
|
181
|
-
*
|
|
182
|
-
* Accepts a static object or a reactive getter:
|
|
183
|
-
* useHead({ title: "My Page", meta: [{ name: "description", content: "..." }] })
|
|
184
|
-
* useHead(() => ({ title: `${count()} items` })) // updates when signal changes
|
|
185
|
-
*
|
|
186
|
-
* Tags are deduplicated by key — innermost component wins.
|
|
187
|
-
* Requires a <HeadProvider> (CSR) or renderWithHead() (SSR) ancestor.
|
|
188
|
-
*/
|
|
189
|
-
function useHead(input)
|
|
190
|
-
const ctx = useContext(HeadContext);
|
|
191
|
-
if (!ctx) return;
|
|
192
|
-
const id = Symbol();
|
|
193
|
-
if (typeof input === "function") {
|
|
194
|
-
if (typeof document !== "undefined") effect(() => {
|
|
195
|
-
ctx.add(id, buildEntry(input()));
|
|
196
|
-
syncDom(ctx);
|
|
197
|
-
});else ctx.add(id, buildEntry(input()));
|
|
198
|
-
} else {
|
|
199
|
-
ctx.add(id, buildEntry(input));
|
|
200
|
-
onMount(() => {
|
|
201
|
-
syncDom(ctx);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
onUnmount(() => {
|
|
205
|
-
ctx.remove(id);
|
|
206
|
-
syncDom(ctx);
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
123
|
+
* Register head tags (title, meta, link, script, style, noscript, base, jsonLd)
|
|
124
|
+
* for the current component.
|
|
125
|
+
*
|
|
126
|
+
* Accepts a static object or a reactive getter:
|
|
127
|
+
* useHead({ title: "My Page", meta: [{ name: "description", content: "..." }] })
|
|
128
|
+
* useHead(() => ({ title: `${count()} items` })) // updates when signal changes
|
|
129
|
+
*
|
|
130
|
+
* Tags are deduplicated by key — innermost component wins.
|
|
131
|
+
* Requires a <HeadProvider> (CSR) or renderWithHead() (SSR) ancestor.
|
|
132
|
+
*/
|
|
133
|
+
declare function useHead(input: UseHeadInput | (() => UseHeadInput)): void;
|
|
210
134
|
//#endregion
|
|
211
135
|
export { useHead };
|
|
212
|
-
//# sourceMappingURL=use-
|
|
136
|
+
//# sourceMappingURL=use-head2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-
|
|
1
|
+
{"version":3,"file":"use-head2.d.ts","names":[],"sources":["../../../src/context.ts","../../../src/use-head.ts"],"mappings":";;UAsBiB,OAAA;EAkBA;EAhBf,IAAA;;EAEA,QAAA;EAgBA;EAdA,YAAA;EAkBA;EAhBA,OAAA;EAoBA;EAlBA,OAAA;EAsBA;EApBA,QAAA;EAwBA;EAtBA,KAAA;AAAA;;UAIe,OAAA;EA4Bf;EA1BA,GAAA;EA8BA;EA5BA,IAAA;EA4BK;EA1BL,EAAA;EA8BwB;EA5BxB,IAAA;EA4BwB;EA1BxB,KAAA;EA8BA;EA5BA,WAAA;EAgCA;EA9BA,SAAA;EAkCA;EAhCA,KAAA;EAoCA;EAlCA,QAAA;EAsCA;EApCA,KAAA;EAoCQ;EAlCR,aAAA;EAsCuB;EApCvB,cAAA;EAoCuB;EAlCvB,WAAA;EAsCA;EApCA,UAAA;EAwCA;EAtCA,QAAA;EAwCQ;EAtCR,KAAA;AAAA;;UAIe,SAAA;EAwCf;EAtCA,GAAA;EA2Ce;EAzCf,IAAA;;EAEA,KAAA;EAgDO;EA9CP,KAAA;EAgDQ;EA9CR,WAAA;EAiDmC;EA/CnC,SAAA;EAkDY;EAhDZ,QAAA;EAkDkB;EAhDlB,cAAA;EA8BA;EA5BA,aAAA;EAkC2B;EAhC3B,QAAA;AAAA;;UAIe,QAAA;EA+Bf;EA7BA,QAAA;EA8BA;EA5BA,KAAA;EA6BA;EA3BA,KAAA;EA6BA;EA3BA,KAAA;EA2BmC;EAzBnC,QAAA;AAAA;;UAIe,OAAA;EA0Bf;EAxBA,IAAA;EAwBkB;EAtBlB,MAAA;AAAA;AAAA,UAGe,YAAA;EACf,KAAA;ECpCc;;;;;ED0Cd,aAAA,cAA2B,KAAA;EAC3B,IAAA,GAAO,OAAA;EACP,IAAA,GAAO,OAAA;EACP,MAAA,GAAS,SAAA;EACT,KAAA,GAAQ,QAAA;EACR,QAAA;IAAa,QAAA;EAAA;;EAEb,MAAA,GAAS,MAAA,oBAA0B,MAAA;EACnC,IAAA,GAAO,OAAA;;EAEP,SAAA,GAAY,MAAA;;EAEZ,SAAA,GAAY,MAAA;AAAA;;;;;AAtHd;;;;;;;;;iBCgEgB,OAAA,CAAQ,KAAA,EAAO,YAAA,UAAsB,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/head",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Head tag management for Pyreon — works in SSR and CSR",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"prepublishOnly": "bun run build"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@pyreon/core": "^0.
|
|
58
|
-
"@pyreon/reactivity": "^0.
|
|
59
|
-
"@pyreon/runtime-server": "^0.
|
|
57
|
+
"@pyreon/core": "^0.6.0",
|
|
58
|
+
"@pyreon/reactivity": "^0.6.0",
|
|
59
|
+
"@pyreon/runtime-server": "^0.6.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@happy-dom/global-registrator": "*",
|
package/src/provider.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentFn, Props, VNodeChild } from "@pyreon/core"
|
|
2
|
-
import {
|
|
2
|
+
import { provide } from "@pyreon/core"
|
|
3
3
|
import type { HeadContextValue } from "./context"
|
|
4
4
|
import { createHeadContext, HeadContext } from "./context"
|
|
5
5
|
|
|
@@ -24,12 +24,8 @@ export interface HeadProviderProps extends Props {
|
|
|
24
24
|
*/
|
|
25
25
|
export const HeadProvider: ComponentFn<HeadProviderProps> = (props) => {
|
|
26
26
|
const ctx = props.context ?? createHeadContext()
|
|
27
|
-
|
|
28
|
-
// can read HeadContext via useContext(). Pop on unmount for correct cleanup.
|
|
29
|
-
const frame = new Map([[HeadContext.id, ctx]])
|
|
30
|
-
pushContext(frame)
|
|
31
|
-
onUnmount(() => popContext())
|
|
27
|
+
provide(HeadContext, ctx)
|
|
32
28
|
|
|
33
29
|
const ch = props.children
|
|
34
|
-
return
|
|
30
|
+
return typeof ch === "function" ? (ch as () => VNodeChild)() : ch
|
|
35
31
|
}
|