@fluixi/head 1.0.0-alpha.49 → 1.0.0-alpha.51

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.
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/jsonld.ts
21
+ var jsonld_exports = {};
22
+ __export(jsonld_exports, {
23
+ article: () => article,
24
+ blogPosting: () => blogPosting,
25
+ breadcrumb: () => breadcrumb,
26
+ custom: () => custom,
27
+ event: () => event,
28
+ faq: () => faq,
29
+ jsonld: () => jsonld,
30
+ localBusiness: () => localBusiness,
31
+ organization: () => organization,
32
+ person: () => person,
33
+ product: () => product,
34
+ searchAction: () => searchAction,
35
+ softwareApplication: () => softwareApplication,
36
+ videoObject: () => videoObject,
37
+ webPage: () => webPage,
38
+ website: () => website
39
+ });
40
+ module.exports = __toCommonJS(jsonld_exports);
41
+ var CTX = "https://schema.org";
42
+ var clean = (o) => {
43
+ const out = {};
44
+ for (const [k, v] of Object.entries(o)) if (v !== void 0) out[k] = v;
45
+ return out;
46
+ };
47
+ var custom = (type, data = {}) => clean({ "@context": CTX, "@type": type, ...data });
48
+ var organization = (d) => custom("Organization", d);
49
+ var person = (d) => custom("Person", d);
50
+ var website = (d) => {
51
+ const { searchUrl, ...rest } = d;
52
+ return custom("WebSite", {
53
+ ...rest,
54
+ ...searchUrl ? {
55
+ potentialAction: {
56
+ "@type": "SearchAction",
57
+ target: { "@type": "EntryPoint", urlTemplate: `${searchUrl}{search_term_string}` },
58
+ "query-input": "required name=search_term_string"
59
+ }
60
+ } : {}
61
+ });
62
+ };
63
+ var webPage = (d) => custom("WebPage", d);
64
+ var searchAction = (d) => clean({ "@type": "SearchAction", target: { "@type": "EntryPoint", urlTemplate: d.target }, "query-input": d.queryInput ?? "required name=search_term_string" });
65
+ var article = (d) => custom("Article", { ...d, author: typeof d.author === "string" ? { "@type": "Person", name: d.author } : d.author });
66
+ var blogPosting = (d) => ({ ...article(d), "@type": "BlogPosting" });
67
+ var faq = (items) => custom("FAQPage", {
68
+ mainEntity: items.map((i) => ({ "@type": "Question", name: i.question, acceptedAnswer: { "@type": "Answer", text: i.answer } }))
69
+ });
70
+ var product = (d) => custom("Product", { ...d, brand: typeof d.brand === "string" ? { "@type": "Brand", name: d.brand } : d.brand });
71
+ var breadcrumb = (items) => custom("BreadcrumbList", {
72
+ itemListElement: items.map((it, i) => ({ "@type": "ListItem", position: i + 1, name: it.name, item: it.url }))
73
+ });
74
+ var videoObject = (d) => custom("VideoObject", d);
75
+ var event = (d) => custom("Event", { ...d, location: typeof d.location === "string" ? { "@type": "Place", name: d.location } : d.location });
76
+ var localBusiness = (d) => custom("LocalBusiness", d);
77
+ var softwareApplication = (d) => custom("SoftwareApplication", d);
78
+ var jsonld = {
79
+ custom,
80
+ organization,
81
+ person,
82
+ website,
83
+ webPage,
84
+ searchAction,
85
+ article,
86
+ blogPosting,
87
+ faq,
88
+ product,
89
+ breadcrumb,
90
+ videoObject,
91
+ event,
92
+ localBusiness,
93
+ softwareApplication
94
+ };
@@ -0,0 +1,73 @@
1
+ // src/jsonld.ts
2
+ var CTX = "https://schema.org";
3
+ var clean = (o) => {
4
+ const out = {};
5
+ for (const [k, v] of Object.entries(o)) if (v !== void 0) out[k] = v;
6
+ return out;
7
+ };
8
+ var custom = (type, data = {}) => clean({ "@context": CTX, "@type": type, ...data });
9
+ var organization = (d) => custom("Organization", d);
10
+ var person = (d) => custom("Person", d);
11
+ var website = (d) => {
12
+ const { searchUrl, ...rest } = d;
13
+ return custom("WebSite", {
14
+ ...rest,
15
+ ...searchUrl ? {
16
+ potentialAction: {
17
+ "@type": "SearchAction",
18
+ target: { "@type": "EntryPoint", urlTemplate: `${searchUrl}{search_term_string}` },
19
+ "query-input": "required name=search_term_string"
20
+ }
21
+ } : {}
22
+ });
23
+ };
24
+ var webPage = (d) => custom("WebPage", d);
25
+ var searchAction = (d) => clean({ "@type": "SearchAction", target: { "@type": "EntryPoint", urlTemplate: d.target }, "query-input": d.queryInput ?? "required name=search_term_string" });
26
+ var article = (d) => custom("Article", { ...d, author: typeof d.author === "string" ? { "@type": "Person", name: d.author } : d.author });
27
+ var blogPosting = (d) => ({ ...article(d), "@type": "BlogPosting" });
28
+ var faq = (items) => custom("FAQPage", {
29
+ mainEntity: items.map((i) => ({ "@type": "Question", name: i.question, acceptedAnswer: { "@type": "Answer", text: i.answer } }))
30
+ });
31
+ var product = (d) => custom("Product", { ...d, brand: typeof d.brand === "string" ? { "@type": "Brand", name: d.brand } : d.brand });
32
+ var breadcrumb = (items) => custom("BreadcrumbList", {
33
+ itemListElement: items.map((it, i) => ({ "@type": "ListItem", position: i + 1, name: it.name, item: it.url }))
34
+ });
35
+ var videoObject = (d) => custom("VideoObject", d);
36
+ var event = (d) => custom("Event", { ...d, location: typeof d.location === "string" ? { "@type": "Place", name: d.location } : d.location });
37
+ var localBusiness = (d) => custom("LocalBusiness", d);
38
+ var softwareApplication = (d) => custom("SoftwareApplication", d);
39
+ var jsonld = {
40
+ custom,
41
+ organization,
42
+ person,
43
+ website,
44
+ webPage,
45
+ searchAction,
46
+ article,
47
+ blogPosting,
48
+ faq,
49
+ product,
50
+ breadcrumb,
51
+ videoObject,
52
+ event,
53
+ localBusiness,
54
+ softwareApplication
55
+ };
56
+ export {
57
+ article,
58
+ blogPosting,
59
+ breadcrumb,
60
+ custom,
61
+ event,
62
+ faq,
63
+ jsonld,
64
+ localBusiness,
65
+ organization,
66
+ person,
67
+ product,
68
+ searchAction,
69
+ softwareApplication,
70
+ videoObject,
71
+ webPage,
72
+ website
73
+ };
@@ -0,0 +1,309 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/reconcile.ts
21
+ var reconcile_exports = {};
22
+ __export(reconcile_exports, {
23
+ mountHead: () => mountHead
24
+ });
25
+ module.exports = __toCommonJS(reconcile_exports);
26
+ var import_signal2 = require("@fluixi/reactive/signal");
27
+
28
+ // src/core.ts
29
+ var import_signal = require("@fluixi/reactive/signal");
30
+ function val(v) {
31
+ return typeof v === "function" ? v() : v;
32
+ }
33
+ function robotsToString(r) {
34
+ if (typeof r === "string") return r;
35
+ const out = [];
36
+ out.push(r.index === false ? "noindex" : "index");
37
+ out.push(r.follow === false ? "nofollow" : "follow");
38
+ if (r.noarchive) out.push("noarchive");
39
+ if (r.nosnippet) out.push("nosnippet");
40
+ if (r.noimageindex) out.push("noimageindex");
41
+ if (r.maxSnippet != null) out.push(`max-snippet:${r.maxSnippet}`);
42
+ if (r.maxImagePreview) out.push(`max-image-preview:${r.maxImagePreview}`);
43
+ if (r.maxVideoPreview != null) out.push(`max-video-preview:${r.maxVideoPreview}`);
44
+ return out.join(", ");
45
+ }
46
+ function djb2(s) {
47
+ let h = 5381;
48
+ for (let i = 0; i < s.length; i++) h = h * 33 ^ s.charCodeAt(i);
49
+ return (h >>> 0).toString(36);
50
+ }
51
+ function metaKey(a) {
52
+ if (a.charset != null) return "meta:charset";
53
+ if (a.property) return "meta:property:" + a.property;
54
+ if (a.name) return "meta:name:" + a.name;
55
+ if (a["http-equiv"]) return "meta:http-equiv:" + a["http-equiv"];
56
+ return "meta:" + djb2(JSON.stringify(a));
57
+ }
58
+ function pushImage(out, img) {
59
+ const o = typeof img === "string" ? { url: img } : img;
60
+ out.push({ tag: "meta", key: "meta:property:og:image:" + o.url, attrs: { property: "og:image", content: o.url } });
61
+ if (o.secureUrl) out.push({ tag: "meta", key: "meta:property:og:image:secure:" + o.url, attrs: { property: "og:image:secure_url", content: o.secureUrl } });
62
+ if (o.type) out.push({ tag: "meta", key: "meta:property:og:image:type:" + o.url, attrs: { property: "og:image:type", content: o.type } });
63
+ if (o.width != null) out.push({ tag: "meta", key: "meta:property:og:image:width:" + o.url, attrs: { property: "og:image:width", content: String(o.width) } });
64
+ if (o.height != null) out.push({ tag: "meta", key: "meta:property:og:image:height:" + o.url, attrs: { property: "og:image:height", content: String(o.height) } });
65
+ if (o.alt) out.push({ tag: "meta", key: "meta:property:og:image:alt:" + o.url, attrs: { property: "og:image:alt", content: o.alt } });
66
+ }
67
+ function expandOG(og, out) {
68
+ const m = (p, c) => {
69
+ if (c != null) out.push({ tag: "meta", key: "meta:property:og:" + p, attrs: { property: "og:" + p, content: c } });
70
+ };
71
+ m("title", og.title);
72
+ m("description", og.description);
73
+ m("type", og.type);
74
+ m("url", og.url);
75
+ m("site_name", og.siteName);
76
+ m("locale", og.locale);
77
+ for (const l of og.localeAlternate ?? []) out.push({ tag: "meta", key: "meta:property:og:locale:alt:" + l, attrs: { property: "og:locale:alternate", content: l } });
78
+ if (og.image != null) {
79
+ const imgs = Array.isArray(og.image) ? og.image : [og.image];
80
+ for (const i of imgs) pushImage(out, i);
81
+ }
82
+ if (og.video) {
83
+ const v = typeof og.video === "string" ? { url: og.video } : og.video;
84
+ m("video", v.url);
85
+ if ("type" in v && v.type) m("video:type", v.type);
86
+ if ("width" in v && v.width != null) m("video:width", String(v.width));
87
+ if ("height" in v && v.height != null) m("video:height", String(v.height));
88
+ }
89
+ if (og.audio) {
90
+ const a = typeof og.audio === "string" ? { url: og.audio } : og.audio;
91
+ m("audio", a.url);
92
+ if ("type" in a && a.type) m("audio:type", a.type);
93
+ }
94
+ if (og.article) {
95
+ const ar = og.article;
96
+ m("article:published_time", ar.publishedTime);
97
+ m("article:modified_time", ar.modifiedTime);
98
+ m("article:expiration_time", ar.expirationTime);
99
+ m("article:section", ar.section);
100
+ for (const au of [].concat(ar.author ?? [])) out.push({ tag: "meta", key: "meta:property:og:article:author:" + au, attrs: { property: "article:author", content: au } });
101
+ for (const t of [].concat(ar.tag ?? [])) out.push({ tag: "meta", key: "meta:property:og:article:tag:" + t, attrs: { property: "article:tag", content: t } });
102
+ }
103
+ if (og.book) {
104
+ const b = og.book;
105
+ m("book:isbn", b.isbn);
106
+ m("book:release_date", b.releaseDate);
107
+ for (const au of [].concat(b.author ?? [])) out.push({ tag: "meta", key: "meta:property:og:book:author:" + au, attrs: { property: "book:author", content: au } });
108
+ for (const t of [].concat(b.tag ?? [])) out.push({ tag: "meta", key: "meta:property:og:book:tag:" + t, attrs: { property: "book:tag", content: t } });
109
+ }
110
+ if (og.profile) {
111
+ const p = og.profile;
112
+ m("profile:first_name", p.firstName);
113
+ m("profile:last_name", p.lastName);
114
+ m("profile:username", p.username);
115
+ m("profile:gender", p.gender);
116
+ }
117
+ }
118
+ function expandTwitter(t, out) {
119
+ const m = (n, c) => {
120
+ if (c != null) out.push({ tag: "meta", key: "meta:name:twitter:" + n, attrs: { name: "twitter:" + n, content: c } });
121
+ };
122
+ m("card", t.card);
123
+ m("site", t.site);
124
+ m("creator", t.creator);
125
+ m("title", t.title);
126
+ m("description", t.description);
127
+ m("image", t.image);
128
+ m("image:alt", t.imageAlt);
129
+ m("player", t.player);
130
+ if (t.playerWidth != null) m("player:width", String(t.playerWidth));
131
+ if (t.playerHeight != null) m("player:height", String(t.playerHeight));
132
+ if (t.app) {
133
+ m("app:name:iphone", t.app.name);
134
+ m("app:id:iphone", t.app.idIphone);
135
+ m("app:id:ipad", t.app.idIpad);
136
+ m("app:id:googleplay", t.app.idGooglePlay);
137
+ }
138
+ }
139
+ function expandIcons(icons, out) {
140
+ const link = (key, attrs) => out.push({ tag: "link", key, attrs });
141
+ if (icons.icon != null) {
142
+ const arr = typeof icons.icon === "string" ? [{ url: icons.icon }] : icons.icon;
143
+ for (const i of arr) link("link:icon:" + i.url, { rel: "icon", href: i.url, ...i.type ? { type: i.type } : {}, ...i.sizes ? { sizes: i.sizes } : {} });
144
+ }
145
+ if (icons.apple != null) {
146
+ const arr = typeof icons.apple === "string" ? [{ url: icons.apple }] : icons.apple;
147
+ for (const i of arr) link("link:apple-touch-icon:" + i.url, { rel: "apple-touch-icon", href: i.url, ...i.sizes ? { sizes: i.sizes } : {} });
148
+ }
149
+ if (icons.mask) link("link:mask-icon", { rel: "mask-icon", href: icons.mask.url, ...icons.mask.color ? { color: icons.mask.color } : {} });
150
+ if (icons.shortcut) link("link:shortcut", { rel: "shortcut icon", href: icons.shortcut });
151
+ if (icons.msTileImage) out.push({ tag: "meta", key: "meta:name:msapplication-TileImage", attrs: { name: "msapplication-TileImage", content: icons.msTileImage } });
152
+ if (icons.msTileColor) out.push({ tag: "meta", key: "meta:name:msapplication-TileColor", attrs: { name: "msapplication-TileColor", content: icons.msTileColor } });
153
+ }
154
+ function expand(input, out, ts) {
155
+ const meta = (key, attrs) => out.push({ tag: "meta", key, attrs });
156
+ const title = val(input.title);
157
+ if (title !== void 0) ts.title = title;
158
+ if (input.titleTemplate !== void 0) ts.template = input.titleTemplate;
159
+ const lang = val(input.lang);
160
+ if (lang !== void 0) out.push({ tag: "htmlAttr", key: "html:lang", name: "lang", value: lang });
161
+ if (input.charset !== void 0) meta("meta:charset", { charset: input.charset });
162
+ if (input.viewport !== void 0) meta("meta:name:viewport", { name: "viewport", content: input.viewport });
163
+ const desc = val(input.description);
164
+ if (desc !== void 0) meta("meta:name:description", { name: "description", content: desc });
165
+ const kw = val(input.keywords);
166
+ if (kw !== void 0) meta("meta:name:keywords", { name: "keywords", content: Array.isArray(kw) ? kw.join(", ") : kw });
167
+ if (input.author !== void 0) meta("meta:name:author", { name: "author", content: input.author });
168
+ if (input.robots !== void 0) meta("meta:name:robots", { name: "robots", content: robotsToString(input.robots) });
169
+ if (input.generator !== void 0) meta("meta:name:generator", { name: "generator", content: input.generator });
170
+ if (input.applicationName !== void 0) meta("meta:name:application-name", { name: "application-name", content: input.applicationName });
171
+ if (input.referrer !== void 0) meta("meta:name:referrer", { name: "referrer", content: input.referrer });
172
+ if (input.colorScheme !== void 0) meta("meta:name:color-scheme", { name: "color-scheme", content: input.colorScheme });
173
+ const theme = val(input.themeColor);
174
+ if (theme !== void 0) meta("meta:name:theme-color", { name: "theme-color", content: theme });
175
+ const canonical = val(input.canonical);
176
+ if (canonical !== void 0) out.push({ tag: "link", key: "link:rel:canonical", attrs: { rel: "canonical", href: canonical } });
177
+ if (input.manifest !== void 0) out.push({ tag: "link", key: "link:rel:manifest", attrs: { rel: "manifest", href: input.manifest } });
178
+ if (input.base !== void 0) out.push({ tag: "base", key: "base", attrs: { href: input.base } });
179
+ if (input.verification) {
180
+ const map = { google: "google-site-verification", bing: "msvalidate.01", yandex: "yandex-verification", pinterest: "p:domain_verify" };
181
+ for (const [k, v] of Object.entries(input.verification)) {
182
+ if (v == null) continue;
183
+ const name = map[k] ?? k;
184
+ meta("meta:name:" + name, { name, content: v });
185
+ }
186
+ }
187
+ for (const a of input.alternates ?? []) out.push({ tag: "link", key: "link:alternate:hreflang:" + a.hreflang, attrs: { rel: "alternate", hreflang: a.hreflang, href: a.href } });
188
+ for (const f of input.feeds ?? []) out.push({ tag: "link", key: "link:alternate:feed:" + f.href, attrs: { rel: "alternate", type: f.type ?? "application/rss+xml", href: f.href, ...f.title ? { title: f.title } : {} } });
189
+ if (input.og) expandOG(input.og, out);
190
+ if (input.twitter) expandTwitter(input.twitter, out);
191
+ if (input.icons) expandIcons(input.icons, out);
192
+ const ld = val(input.jsonLd);
193
+ if (ld !== void 0) {
194
+ const arr = Array.isArray(ld) ? ld : [ld];
195
+ for (const obj of arr) {
196
+ const json = JSON.stringify(obj);
197
+ out.push({ tag: "script", key: "script:ldjson:" + djb2(json), attrs: { type: "application/ld+json" }, children: json });
198
+ }
199
+ }
200
+ for (const m of input.meta ?? []) {
201
+ const attrs = {};
202
+ for (const [k, v] of Object.entries(m)) if (v != null) attrs[k === "httpEquiv" ? "http-equiv" : k] = v;
203
+ out.push({ tag: "meta", key: metaKey(attrs), attrs });
204
+ }
205
+ for (const l of input.link ?? []) {
206
+ const attrs = {};
207
+ for (const [k, v] of Object.entries(l)) if (v != null) attrs[k] = v;
208
+ out.push({ tag: "link", key: "link:" + (attrs.rel ?? "") + ":" + (attrs.href ?? djb2(JSON.stringify(attrs))), attrs });
209
+ }
210
+ for (const s of input.script ?? []) {
211
+ const attrs = {};
212
+ let children;
213
+ for (const [k, v] of Object.entries(s)) {
214
+ if (v == null) continue;
215
+ if (k === "children") children = v;
216
+ else attrs[k] = v;
217
+ }
218
+ out.push({ tag: "script", key: "script:" + (attrs.src ?? djb2((children ?? "") + JSON.stringify(attrs))), attrs, children });
219
+ }
220
+ }
221
+ function applyTemplate(tpl, title) {
222
+ return typeof tpl === "function" ? tpl(title) : tpl.includes("%s") ? tpl.replace("%s", title) : tpl;
223
+ }
224
+ function resolveHead(head) {
225
+ const raw = [];
226
+ const ts = {};
227
+ for (const src of head.sources) {
228
+ const input = typeof src === "function" ? src() : src;
229
+ expand(input, raw, ts);
230
+ }
231
+ if (ts.title !== void 0) {
232
+ raw.push({ tag: "title", key: "title", children: ts.template ? applyTemplate(ts.template, ts.title) : ts.title });
233
+ }
234
+ const byKey = /* @__PURE__ */ new Map();
235
+ const htmlAttrs = {};
236
+ for (const t of raw) {
237
+ if (t.tag === "htmlAttr") {
238
+ htmlAttrs[t.name] = t.value;
239
+ continue;
240
+ }
241
+ byKey.set(t.key, t);
242
+ }
243
+ return { tags: [...byKey.values()], htmlAttrs };
244
+ }
245
+
246
+ // src/serialize.ts
247
+ var MANAGED_ATTR = "data-fh";
248
+ var KEY_ATTR = "data-fh-key";
249
+
250
+ // src/reconcile.ts
251
+ function setAttrs(el, attrs) {
252
+ for (const a of Array.from(el.attributes)) {
253
+ if (a.name === MANAGED_ATTR || a.name === KEY_ATTR) continue;
254
+ if (!(a.name in attrs)) el.removeAttribute(a.name);
255
+ }
256
+ for (const [k, v] of Object.entries(attrs)) if (el.getAttribute(k) !== v) el.setAttribute(k, v);
257
+ }
258
+ function createEl(t) {
259
+ const el = document.createElement(t.tag);
260
+ setAttrs(el, t.attrs);
261
+ el.setAttribute(MANAGED_ATTR, "");
262
+ el.setAttribute(KEY_ATTR, t.key);
263
+ if (t.tag === "script" && t.children != null) el.textContent = t.children;
264
+ return el;
265
+ }
266
+ function apply(tags, htmlAttrs) {
267
+ const head = document.head;
268
+ const existing = /* @__PURE__ */ new Map();
269
+ for (const el of Array.from(head.querySelectorAll(`[${MANAGED_ATTR}]`))) {
270
+ const key = el.getAttribute(KEY_ATTR);
271
+ if (el.tagName === "TITLE") continue;
272
+ if (key) existing.set(key, el);
273
+ }
274
+ let title = null;
275
+ const seen = /* @__PURE__ */ new Set();
276
+ for (const t of tags) {
277
+ if (t.tag === "title") {
278
+ title = t.children;
279
+ continue;
280
+ }
281
+ if (t.tag === "htmlAttr") continue;
282
+ seen.add(t.key);
283
+ const cur = existing.get(t.key);
284
+ if (cur && cur.tagName === t.tag.toUpperCase()) {
285
+ setAttrs(cur, t.attrs);
286
+ if (t.tag === "script" && (cur.textContent ?? "") !== (t.children ?? "")) cur.textContent = t.children ?? "";
287
+ } else {
288
+ if (cur) cur.remove();
289
+ head.appendChild(createEl(t));
290
+ }
291
+ }
292
+ for (const [key, el] of existing) if (!seen.has(key)) el.remove();
293
+ if (title != null && document.title !== title) document.title = title;
294
+ for (const [k, v] of Object.entries(htmlAttrs)) {
295
+ if (document.documentElement.getAttribute(k) !== v) document.documentElement.setAttribute(k, v);
296
+ }
297
+ }
298
+ function mountHead(head) {
299
+ return (0, import_signal2.createRoot)((dispose) => {
300
+ (0, import_signal2.createEffect)(() => {
301
+ head.version();
302
+ const { tags, htmlAttrs } = resolveHead(head);
303
+ apply(tags, htmlAttrs);
304
+ });
305
+ (0, import_signal2.onCleanup)(() => {
306
+ });
307
+ return dispose;
308
+ });
309
+ }