@highstate/designer 0.7.0 → 0.7.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/.output/nitro.json +3 -3
- package/.output/public/_nuxt/1_b4y8eQ.js +1 -0
- package/.output/public/_nuxt/BjOhMR1f.js +242 -0
- package/.output/public/_nuxt/CPAAHz3G.js +1 -0
- package/.output/public/_nuxt/{TC7QuZux.js → CmGpyJTe.js} +1 -1
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/f777d22c-e958-4e7c-865d-11bb8a560858.json +1 -0
- package/.output/public/_nuxt/{entry.DpeBhKHh.css → entry.Vs8IncyG.css} +1 -1
- package/.output/server/index.mjs +1876 -3051
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@babel/parser/lib/index.js +129 -97
- package/.output/server/node_modules/@babel/parser/package.json +2 -2
- package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/fetchRequestHandler.mjs +74 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/fetch/index.mjs +1 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/incomingMessageToRequest.mjs +119 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/index.mjs +2 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +92 -0
- package/.output/server/node_modules/@trpc/server/dist/adapters/node-http/writeResponse.mjs +79 -0
- package/.output/server/node_modules/@trpc/server/dist/index.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/middleware.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/parser.mjs +4 -3
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/procedureBuilder.mjs +3 -0
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/router.mjs +1 -1
- package/.output/server/node_modules/@trpc/server/package.json +6 -6
- package/.output/server/node_modules/unhead/dist/plugins.mjs +94 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +220 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C13swrCa.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CApf5sj3.mjs +148 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Cp0iF6eN.mjs +177 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DZbvapt-.mjs +70 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DeCxexjU.mjs +166 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Txd0XTIP.mjs +172 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/.output/server/node_modules/unhead/package.json +66 -11
- package/.output/server/package.json +1 -1
- package/package.json +8 -8
- package/.output/public/_nuxt/B3Ns2-bM.js +0 -1
- package/.output/public/_nuxt/DToExo9V.js +0 -1
- package/.output/public/_nuxt/builds/meta/f64fe243-c5f1-4f5e-a593-05cf555884c2.json +0 -1
- package/.output/public/_nuxt/u3nCRAjk.js +0 -244
- package/.output/server/node_modules/@trpc/server/dist/http.mjs +0 -7
- package/.output/server/node_modules/@trpc/server/dist/unstable-core-do-not-import/http/contentTypeParsers.mjs +0 -12
- package/.output/server/node_modules/@unhead/dom/dist/index.mjs +0 -197
- package/.output/server/node_modules/@unhead/dom/package.json +0 -40
- package/.output/server/node_modules/@unhead/shared/dist/index.mjs +0 -641
- package/.output/server/node_modules/@unhead/shared/package.json +0 -45
- package/.output/server/node_modules/@unhead/ssr/dist/index.mjs +0 -95
- package/.output/server/node_modules/@unhead/ssr/package.json +0 -40
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +0 -1
- package/.output/server/node_modules/node-mock-http/package.json +0 -63
- package/.output/server/node_modules/packrup/dist/index.mjs +0 -108
- package/.output/server/node_modules/packrup/package.json +0 -58
- package/.output/server/node_modules/unhead/dist/index.mjs +0 -748
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { M as MetaTagsArrayable } from './unhead.yem5I2v_.mjs';
|
|
2
|
+
|
|
3
|
+
const NAMESPACES = {
|
|
4
|
+
META: /* @__PURE__ */ new Set(["twitter"]),
|
|
5
|
+
OG: /* @__PURE__ */ new Set(["og", "book", "article", "profile", "fb"]),
|
|
6
|
+
MEDIA: /* @__PURE__ */ new Set(["ogImage", "ogVideo", "ogAudio", "twitterImage"]),
|
|
7
|
+
HTTP_EQUIV: /* @__PURE__ */ new Set(["contentType", "defaultStyle", "xUaCompatible"])
|
|
8
|
+
};
|
|
9
|
+
const META_ALIASES = {
|
|
10
|
+
articleExpirationTime: "article:expiration_time",
|
|
11
|
+
articleModifiedTime: "article:modified_time",
|
|
12
|
+
articlePublishedTime: "article:published_time",
|
|
13
|
+
bookReleaseDate: "book:release_date",
|
|
14
|
+
fbAppId: "fb:app_id",
|
|
15
|
+
ogAudioSecureUrl: "og:audio:secure_url",
|
|
16
|
+
ogAudioUrl: "og:audio",
|
|
17
|
+
ogImageSecureUrl: "og:image:secure_url",
|
|
18
|
+
ogImageUrl: "og:image",
|
|
19
|
+
ogSiteName: "og:site_name",
|
|
20
|
+
ogVideoSecureUrl: "og:video:secure_url",
|
|
21
|
+
ogVideoUrl: "og:video",
|
|
22
|
+
profileFirstName: "profile:first_name",
|
|
23
|
+
profileLastName: "profile:last_name",
|
|
24
|
+
profileUsername: "profile:username",
|
|
25
|
+
msapplicationConfig: "msapplication-Config",
|
|
26
|
+
msapplicationTileColor: "msapplication-TileColor",
|
|
27
|
+
msapplicationTileImage: "msapplication-TileImage"
|
|
28
|
+
};
|
|
29
|
+
const MetaPackingSchema = {
|
|
30
|
+
appleItunesApp: {
|
|
31
|
+
unpack: {
|
|
32
|
+
entrySeparator: ", ",
|
|
33
|
+
// @ts-expect-error untyped
|
|
34
|
+
resolve: ({ key, value }) => `${fixKeyCase(key)}=${value}`
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
refresh: {
|
|
38
|
+
metaKey: "http-equiv",
|
|
39
|
+
unpack: {
|
|
40
|
+
entrySeparator: ";",
|
|
41
|
+
// @ts-expect-error untyped
|
|
42
|
+
resolve: ({ key, value }) => key === "seconds" ? `${value}` : void 0
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
robots: {
|
|
46
|
+
unpack: {
|
|
47
|
+
entrySeparator: ", ",
|
|
48
|
+
// @ts-expect-error untyped
|
|
49
|
+
resolve: ({ key, value }) => typeof value === "boolean" ? fixKeyCase(key) : `${fixKeyCase(key)}:${value}`
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
contentSecurityPolicy: {
|
|
53
|
+
metaKey: "http-equiv",
|
|
54
|
+
unpack: {
|
|
55
|
+
entrySeparator: "; ",
|
|
56
|
+
// @ts-expect-error untyped
|
|
57
|
+
resolve: ({ key, value }) => `${fixKeyCase(key)} ${value}`
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
charset: {}
|
|
61
|
+
};
|
|
62
|
+
function fixKeyCase(key) {
|
|
63
|
+
const updated = key.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
64
|
+
const prefixIndex = updated.indexOf("-");
|
|
65
|
+
return prefixIndex === -1 ? updated : NAMESPACES.META.has(updated.slice(0, prefixIndex)) || NAMESPACES.OG.has(updated.slice(0, prefixIndex)) ? key.replace(/([A-Z])/g, ":$1").toLowerCase() : updated;
|
|
66
|
+
}
|
|
67
|
+
function sanitizeObject(input) {
|
|
68
|
+
return Object.fromEntries(Object.entries(input).filter(([k, v]) => String(v) !== "false" && k));
|
|
69
|
+
}
|
|
70
|
+
function transformObject(obj) {
|
|
71
|
+
return Array.isArray(obj) ? obj.map(transformObject) : !obj || typeof obj !== "object" ? obj : Object.fromEntries(Object.entries(obj).map(([k, v]) => [fixKeyCase(k), transformObject(v)]));
|
|
72
|
+
}
|
|
73
|
+
function unpackToString(value, options = {}) {
|
|
74
|
+
const { entrySeparator = "", keyValueSeparator = "", wrapValue, resolve } = options;
|
|
75
|
+
return Object.entries(value).map(([key, val]) => {
|
|
76
|
+
if (resolve) {
|
|
77
|
+
const resolved = resolve({ key, value: val });
|
|
78
|
+
if (resolved !== void 0)
|
|
79
|
+
return resolved;
|
|
80
|
+
}
|
|
81
|
+
const processedVal = typeof val === "object" ? unpackToString(val, options) : typeof val === "number" ? val.toString() : typeof val === "string" && wrapValue ? `${wrapValue}${val.replace(new RegExp(wrapValue, "g"), `\\${wrapValue}`)}${wrapValue}` : val;
|
|
82
|
+
return `${key}${keyValueSeparator}${processedVal}`;
|
|
83
|
+
}).join(entrySeparator);
|
|
84
|
+
}
|
|
85
|
+
function handleObjectEntry(key, value) {
|
|
86
|
+
const sanitizedValue = sanitizeObject(value);
|
|
87
|
+
const fixedKey = fixKeyCase(key);
|
|
88
|
+
const attr = resolveMetaKeyType(fixedKey);
|
|
89
|
+
if (!MetaTagsArrayable.has(fixedKey)) {
|
|
90
|
+
return [{ [attr]: fixedKey, ...sanitizedValue }];
|
|
91
|
+
}
|
|
92
|
+
const input = Object.fromEntries(
|
|
93
|
+
Object.entries(sanitizedValue).map(([k, v]) => [`${key}${k === "url" ? "" : `${k[0].toUpperCase()}${k.slice(1)}`}`, v])
|
|
94
|
+
);
|
|
95
|
+
return unpackMeta(input || {}).sort((a, b) => (a[attr]?.length || 0) - (b[attr]?.length || 0));
|
|
96
|
+
}
|
|
97
|
+
function resolveMetaKeyType(key) {
|
|
98
|
+
if (MetaPackingSchema[key]?.metaKey === "http-equiv" || NAMESPACES.HTTP_EQUIV.has(key)) {
|
|
99
|
+
return "http-equiv";
|
|
100
|
+
}
|
|
101
|
+
const fixed = fixKeyCase(key);
|
|
102
|
+
const colonIndex = fixed.indexOf(":");
|
|
103
|
+
return colonIndex === -1 ? "name" : NAMESPACES.OG.has(fixed.slice(0, colonIndex)) ? "property" : "name";
|
|
104
|
+
}
|
|
105
|
+
function resolveMetaKeyValue(key) {
|
|
106
|
+
return META_ALIASES[key] || fixKeyCase(key);
|
|
107
|
+
}
|
|
108
|
+
function resolvePackedMetaObjectValue(value, key) {
|
|
109
|
+
if (key === "refresh")
|
|
110
|
+
return `${value.seconds};url=${value.url}`;
|
|
111
|
+
return unpackToString(transformObject(value), {
|
|
112
|
+
keyValueSeparator: "=",
|
|
113
|
+
entrySeparator: ", ",
|
|
114
|
+
resolve: ({ value: value2, key: key2 }) => value2 === null ? "" : typeof value2 === "boolean" ? key2 : void 0,
|
|
115
|
+
// @ts-expect-error untyped
|
|
116
|
+
...MetaPackingSchema[key]?.unpack
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function unpackMeta(input) {
|
|
120
|
+
const extras = [];
|
|
121
|
+
const primitives = {};
|
|
122
|
+
for (const [key, value] of Object.entries(input)) {
|
|
123
|
+
if (Array.isArray(value)) {
|
|
124
|
+
if (key === "themeColor") {
|
|
125
|
+
value.forEach((v) => {
|
|
126
|
+
if (typeof v === "object" && v !== null) {
|
|
127
|
+
extras.push({ name: "theme-color", ...v });
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
for (const v of value) {
|
|
133
|
+
if (typeof v === "object" && v !== null) {
|
|
134
|
+
const urlProps = [];
|
|
135
|
+
const otherProps = [];
|
|
136
|
+
for (const [propKey, propValue] of Object.entries(v)) {
|
|
137
|
+
const metaKey = `${key}${propKey === "url" ? "" : `:${propKey}`}`;
|
|
138
|
+
const meta2 = unpackMeta({ [metaKey]: propValue });
|
|
139
|
+
(propKey === "url" ? urlProps : otherProps).push(...meta2);
|
|
140
|
+
}
|
|
141
|
+
extras.push(...urlProps, ...otherProps);
|
|
142
|
+
} else {
|
|
143
|
+
extras.push(...typeof v === "string" ? unpackMeta({ [key]: v }) : handleObjectEntry(key, v));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (typeof value === "object" && value) {
|
|
149
|
+
if (NAMESPACES.MEDIA.has(key)) {
|
|
150
|
+
const prefix = key.startsWith("twitter") ? "twitter" : "og";
|
|
151
|
+
const type = key.replace(/^(og|twitter)/, "").toLowerCase();
|
|
152
|
+
const metaKey = prefix === "twitter" ? "name" : "property";
|
|
153
|
+
if (value.url) {
|
|
154
|
+
extras.push({
|
|
155
|
+
[metaKey]: `${prefix}:${type}`,
|
|
156
|
+
content: value.url
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (value.secureUrl) {
|
|
160
|
+
extras.push({
|
|
161
|
+
[metaKey]: `${prefix}:${type}:secure_url`,
|
|
162
|
+
content: value.secureUrl
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
for (const [propKey, propValue] of Object.entries(value)) {
|
|
166
|
+
if (propKey !== "url" && propKey !== "secureUrl") {
|
|
167
|
+
extras.push({
|
|
168
|
+
[metaKey]: `${prefix}:${type}:${propKey}`,
|
|
169
|
+
// @ts-expect-error untyped
|
|
170
|
+
content: propValue
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else if (MetaTagsArrayable.has(fixKeyCase(key))) {
|
|
175
|
+
extras.push(...handleObjectEntry(key, value));
|
|
176
|
+
} else {
|
|
177
|
+
primitives[key] = sanitizeObject(value);
|
|
178
|
+
}
|
|
179
|
+
} else {
|
|
180
|
+
primitives[key] = value;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const meta = Object.entries(primitives).map(([key, value]) => {
|
|
184
|
+
if (key === "charset")
|
|
185
|
+
return { charset: value === null ? "_null" : value };
|
|
186
|
+
const metaKey = resolveMetaKeyType(key);
|
|
187
|
+
const keyValue = resolveMetaKeyValue(key);
|
|
188
|
+
const processedValue = value === null ? "_null" : typeof value === "object" ? resolvePackedMetaObjectValue(value, key) : typeof value === "number" ? value.toString() : value;
|
|
189
|
+
return metaKey === "http-equiv" ? { "http-equiv": keyValue, "content": processedValue } : { [metaKey]: keyValue, content: processedValue };
|
|
190
|
+
});
|
|
191
|
+
return [...extras, ...meta].map(
|
|
192
|
+
(m) => !("content" in m) ? m : m.content === "_null" ? { ...m, content: null } : m
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export { resolveMetaKeyValue as a, resolvePackedMetaObjectValue as b, resolveMetaKeyType as r, unpackMeta as u };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
const sortTags = (a, b) => a._w === b._w ? a._p - b._p : a._w - b._w;
|
|
2
|
+
const TAG_WEIGHTS = {
|
|
3
|
+
base: -10,
|
|
4
|
+
title: 10
|
|
5
|
+
};
|
|
6
|
+
const TAG_ALIASES = {
|
|
7
|
+
critical: -8,
|
|
8
|
+
high: -1,
|
|
9
|
+
low: 2
|
|
10
|
+
};
|
|
11
|
+
const WEIGHT_MAP = {
|
|
12
|
+
meta: {
|
|
13
|
+
"content-security-policy": -30,
|
|
14
|
+
"charset": -20,
|
|
15
|
+
"viewport": -15
|
|
16
|
+
},
|
|
17
|
+
link: {
|
|
18
|
+
"preconnect": 20,
|
|
19
|
+
"stylesheet": 60,
|
|
20
|
+
"preload": 70,
|
|
21
|
+
"modulepreload": 70,
|
|
22
|
+
"prefetch": 90,
|
|
23
|
+
"dns-prefetch": 90,
|
|
24
|
+
"prerender": 90
|
|
25
|
+
},
|
|
26
|
+
script: {
|
|
27
|
+
async: 30,
|
|
28
|
+
defer: 80,
|
|
29
|
+
sync: 50
|
|
30
|
+
},
|
|
31
|
+
style: {
|
|
32
|
+
imported: 40,
|
|
33
|
+
sync: 60
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const ImportStyleRe = /@import/;
|
|
37
|
+
const isTruthy = (val) => val === "" || val === true;
|
|
38
|
+
function tagWeight(head, tag) {
|
|
39
|
+
if (typeof tag.tagPriority === "number")
|
|
40
|
+
return tag.tagPriority;
|
|
41
|
+
let weight = 100;
|
|
42
|
+
const offset = TAG_ALIASES[tag.tagPriority] || 0;
|
|
43
|
+
const weightMap = head.resolvedOptions.disableCapoSorting ? {
|
|
44
|
+
link: {},
|
|
45
|
+
script: {},
|
|
46
|
+
style: {}
|
|
47
|
+
} : WEIGHT_MAP;
|
|
48
|
+
if (tag.tag in TAG_WEIGHTS) {
|
|
49
|
+
weight = TAG_WEIGHTS[tag.tag];
|
|
50
|
+
} else if (tag.tag === "meta") {
|
|
51
|
+
const metaType = tag.props["http-equiv"] === "content-security-policy" ? "content-security-policy" : tag.props.charset ? "charset" : tag.props.name === "viewport" ? "viewport" : null;
|
|
52
|
+
if (metaType)
|
|
53
|
+
weight = WEIGHT_MAP.meta[metaType];
|
|
54
|
+
} else if (tag.tag === "link" && tag.props.rel) {
|
|
55
|
+
weight = weightMap.link[tag.props.rel];
|
|
56
|
+
} else if (tag.tag === "script") {
|
|
57
|
+
if (isTruthy(tag.props.async)) {
|
|
58
|
+
weight = weightMap.script.async;
|
|
59
|
+
} else if (tag.props.src && !isTruthy(tag.props.defer) && !isTruthy(tag.props.async) && tag.props.type !== "module" && !tag.props.type?.endsWith("json")) {
|
|
60
|
+
weight = weightMap.script.sync;
|
|
61
|
+
} else if (isTruthy(tag.props.defer) && tag.props.src && !isTruthy(tag.props.async)) {
|
|
62
|
+
weight = weightMap.script.defer;
|
|
63
|
+
}
|
|
64
|
+
} else if (tag.tag === "style") {
|
|
65
|
+
weight = tag.innerHTML && ImportStyleRe.test(tag.innerHTML) ? weightMap.style.imported : weightMap.style.sync;
|
|
66
|
+
}
|
|
67
|
+
return (weight || 100) + offset;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { sortTags as s, tagWeight as t };
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { d as defineHeadPlugin } from './unhead.CApf5sj3.mjs';
|
|
2
|
+
import { s as sortTags } from './unhead.DZbvapt-.mjs';
|
|
3
|
+
import { p as processTemplateParams } from './unhead.C13swrCa.mjs';
|
|
4
|
+
|
|
5
|
+
const formatKey = (k) => !k.includes(":key") ? k.split(":").join(":key:") : k;
|
|
6
|
+
const AliasSortingPlugin = defineHeadPlugin({
|
|
7
|
+
key: "aliasSorting",
|
|
8
|
+
hooks: {
|
|
9
|
+
"tags:resolve": (ctx) => {
|
|
10
|
+
let m = false;
|
|
11
|
+
for (const t of ctx.tags) {
|
|
12
|
+
const p = t.tagPriority;
|
|
13
|
+
if (!p)
|
|
14
|
+
continue;
|
|
15
|
+
const s = String(p);
|
|
16
|
+
if (s.startsWith("before:")) {
|
|
17
|
+
const k = formatKey(s.slice(7));
|
|
18
|
+
const l = ctx.tagMap.get(k);
|
|
19
|
+
if (l) {
|
|
20
|
+
if (typeof l.tagPriority === "number")
|
|
21
|
+
t.tagPriority = l.tagPriority;
|
|
22
|
+
t._p = l._p - 1;
|
|
23
|
+
m = true;
|
|
24
|
+
}
|
|
25
|
+
} else if (s.startsWith("after:")) {
|
|
26
|
+
const k = formatKey(s.slice(6));
|
|
27
|
+
const l = ctx.tagMap.get(k);
|
|
28
|
+
if (l) {
|
|
29
|
+
if (typeof l.tagPriority === "number")
|
|
30
|
+
t.tagPriority = l.tagPriority;
|
|
31
|
+
t._p = l._p + 1;
|
|
32
|
+
m = true;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (m)
|
|
37
|
+
ctx.tags = ctx.tags.sort(sortTags);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const DeprecationsPlugin = /* @__PURE__ */ defineHeadPlugin({
|
|
43
|
+
key: "deprecations",
|
|
44
|
+
hooks: {
|
|
45
|
+
"entries:normalize": ({ tags }) => {
|
|
46
|
+
for (const tag of tags) {
|
|
47
|
+
if (tag.props.children) {
|
|
48
|
+
tag.innerHTML = tag.props.children;
|
|
49
|
+
delete tag.props.children;
|
|
50
|
+
}
|
|
51
|
+
if (tag.props.hid) {
|
|
52
|
+
tag.key = tag.props.hid;
|
|
53
|
+
delete tag.props.hid;
|
|
54
|
+
}
|
|
55
|
+
if (tag.props.vmid) {
|
|
56
|
+
tag.key = tag.props.vmid;
|
|
57
|
+
delete tag.props.vmid;
|
|
58
|
+
}
|
|
59
|
+
if (tag.props.body) {
|
|
60
|
+
tag.tagPosition = "bodyClose";
|
|
61
|
+
delete tag.props.body;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
async function walkPromises(v) {
|
|
69
|
+
const type = typeof v;
|
|
70
|
+
if (type === "function") {
|
|
71
|
+
return v;
|
|
72
|
+
}
|
|
73
|
+
if (v instanceof Promise) {
|
|
74
|
+
return await v;
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(v)) {
|
|
77
|
+
return await Promise.all(v.map((r) => walkPromises(r)));
|
|
78
|
+
}
|
|
79
|
+
if (v?.constructor === Object) {
|
|
80
|
+
const next = {};
|
|
81
|
+
for (const key of Object.keys(v)) {
|
|
82
|
+
next[key] = await walkPromises(v[key]);
|
|
83
|
+
}
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
return v;
|
|
87
|
+
}
|
|
88
|
+
const PromisesPlugin = /* @__PURE__ */ defineHeadPlugin({
|
|
89
|
+
key: "promises",
|
|
90
|
+
hooks: {
|
|
91
|
+
"entries:resolve": async (ctx) => {
|
|
92
|
+
const promises = [];
|
|
93
|
+
for (const k in ctx.entries) {
|
|
94
|
+
if (!ctx.entries[k]._promisesProcessed) {
|
|
95
|
+
promises.push(
|
|
96
|
+
walkPromises(ctx.entries[k].input).then((val) => {
|
|
97
|
+
ctx.entries[k].input = val;
|
|
98
|
+
ctx.entries[k]._promisesProcessed = true;
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
await Promise.all(promises);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const SupportedAttrs = {
|
|
109
|
+
meta: "content",
|
|
110
|
+
link: "href",
|
|
111
|
+
htmlAttrs: "lang"
|
|
112
|
+
};
|
|
113
|
+
const contentAttrs = ["innerHTML", "textContent"];
|
|
114
|
+
const TemplateParamsPlugin = /* @__PURE__ */ defineHeadPlugin((head) => {
|
|
115
|
+
return {
|
|
116
|
+
key: "template-params",
|
|
117
|
+
hooks: {
|
|
118
|
+
"entries:normalize": (ctx) => {
|
|
119
|
+
const params = ctx.tags.filter((t) => t.tag === "templateParams" && t.mode === "server")?.[0]?.props || {};
|
|
120
|
+
if (Object.keys(params).length) {
|
|
121
|
+
head._ssrPayload = {
|
|
122
|
+
templateParams: {
|
|
123
|
+
...head._ssrPayload?.templateParams || {},
|
|
124
|
+
...params
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"tags:resolve": ({ tagMap, tags }) => {
|
|
130
|
+
const params = tagMap.get("templateParams")?.props || {};
|
|
131
|
+
const sep = params.separator || "|";
|
|
132
|
+
delete params.separator;
|
|
133
|
+
params.pageTitle = processTemplateParams(
|
|
134
|
+
// find templateParams
|
|
135
|
+
params.pageTitle || head._title || "",
|
|
136
|
+
params,
|
|
137
|
+
sep
|
|
138
|
+
);
|
|
139
|
+
for (const tag of tags) {
|
|
140
|
+
if (tag.processTemplateParams === false) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const v = SupportedAttrs[tag.tag];
|
|
144
|
+
if (v && typeof tag.props[v] === "string") {
|
|
145
|
+
tag.props[v] = processTemplateParams(tag.props[v], params, sep);
|
|
146
|
+
} else if (tag.processTemplateParams || tag.tag === "titleTemplate" || tag.tag === "title") {
|
|
147
|
+
for (const p of contentAttrs) {
|
|
148
|
+
if (typeof tag[p] === "string")
|
|
149
|
+
tag[p] = processTemplateParams(tag[p], params, sep, tag.tag === "script" && tag.props.type.endsWith("json"));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
head._templateParams = params;
|
|
154
|
+
head._separator = sep;
|
|
155
|
+
},
|
|
156
|
+
"tags:afterResolve": ({ tagMap }) => {
|
|
157
|
+
const title = tagMap.get("title");
|
|
158
|
+
if (title?.textContent && title.processTemplateParams !== false) {
|
|
159
|
+
title.textContent = processTemplateParams(title.textContent, head._templateParams, head._separator);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export { AliasSortingPlugin as A, DeprecationsPlugin as D, PromisesPlugin as P, TemplateParamsPlugin as T };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { createHooks } from 'hookable';
|
|
2
|
+
import { n as normalizeEntryToTags, d as dedupeKey, i as isMetaArrayDupeKey } from './unhead.Cp0iF6eN.mjs';
|
|
3
|
+
import { t as tagWeight, s as sortTags } from './unhead.DZbvapt-.mjs';
|
|
4
|
+
import { c as UsesMergeStrategy, V as ValidHeadTags } from './unhead.yem5I2v_.mjs';
|
|
5
|
+
|
|
6
|
+
function registerPlugin(head, p) {
|
|
7
|
+
const plugin = typeof p === "function" ? p(head) : p;
|
|
8
|
+
const key = plugin.key || String(head.plugins.size + 1);
|
|
9
|
+
const exists = head.plugins.get(key);
|
|
10
|
+
if (!exists) {
|
|
11
|
+
head.plugins.set(key, plugin);
|
|
12
|
+
head.hooks.addHooks(plugin.hooks || {});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// @__NO_SIDE_EFFECTS__
|
|
16
|
+
function createHeadCore(resolvedOptions = {}) {
|
|
17
|
+
return /* @__PURE__ */ createUnhead(resolvedOptions);
|
|
18
|
+
}
|
|
19
|
+
// @__NO_SIDE_EFFECTS__
|
|
20
|
+
function createUnhead(resolvedOptions = {}) {
|
|
21
|
+
const hooks = createHooks();
|
|
22
|
+
hooks.addHooks(resolvedOptions.hooks || {});
|
|
23
|
+
const ssr = !resolvedOptions.document;
|
|
24
|
+
const entries = /* @__PURE__ */ new Map();
|
|
25
|
+
const plugins = /* @__PURE__ */ new Map();
|
|
26
|
+
const normalizeQueue = [];
|
|
27
|
+
const head = {
|
|
28
|
+
_entryCount: 1,
|
|
29
|
+
// 0 is reserved for internal use
|
|
30
|
+
plugins,
|
|
31
|
+
dirty: false,
|
|
32
|
+
resolvedOptions,
|
|
33
|
+
hooks,
|
|
34
|
+
ssr,
|
|
35
|
+
entries,
|
|
36
|
+
headEntries() {
|
|
37
|
+
return [...entries.values()];
|
|
38
|
+
},
|
|
39
|
+
use: (p) => registerPlugin(head, p),
|
|
40
|
+
push(input, _options) {
|
|
41
|
+
const options = { ..._options || {} };
|
|
42
|
+
delete options.head;
|
|
43
|
+
const _i = options._index ?? head._entryCount++;
|
|
44
|
+
const inst = { _i, input, options };
|
|
45
|
+
const _ = {
|
|
46
|
+
_poll(rm = false) {
|
|
47
|
+
head.dirty = true;
|
|
48
|
+
!rm && normalizeQueue.push(_i);
|
|
49
|
+
hooks.callHook("entries:updated", head);
|
|
50
|
+
},
|
|
51
|
+
dispose() {
|
|
52
|
+
if (entries.delete(_i)) {
|
|
53
|
+
_._poll(true);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
// a patch is the same as creating a new entry, just a nice DX
|
|
57
|
+
patch(input2) {
|
|
58
|
+
if (!options.mode || options.mode === "server" && ssr || options.mode === "client" && !ssr) {
|
|
59
|
+
inst.input = input2;
|
|
60
|
+
entries.set(_i, inst);
|
|
61
|
+
_._poll();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
_.patch(input);
|
|
66
|
+
return _;
|
|
67
|
+
},
|
|
68
|
+
async resolveTags() {
|
|
69
|
+
const ctx = {
|
|
70
|
+
tagMap: /* @__PURE__ */ new Map(),
|
|
71
|
+
tags: [],
|
|
72
|
+
entries: [...head.entries.values()]
|
|
73
|
+
};
|
|
74
|
+
await hooks.callHook("entries:resolve", ctx);
|
|
75
|
+
while (normalizeQueue.length) {
|
|
76
|
+
const i = normalizeQueue.shift();
|
|
77
|
+
const e = entries.get(i);
|
|
78
|
+
if (e) {
|
|
79
|
+
const normalizeCtx = {
|
|
80
|
+
tags: normalizeEntryToTags(e.input, resolvedOptions.propResolvers || []).map((t) => Object.assign(t, e.options)),
|
|
81
|
+
entry: e
|
|
82
|
+
};
|
|
83
|
+
await hooks.callHook("entries:normalize", normalizeCtx);
|
|
84
|
+
e._tags = normalizeCtx.tags.map((t, i2) => {
|
|
85
|
+
t._w = tagWeight(head, t);
|
|
86
|
+
t._p = (e._i << 10) + i2;
|
|
87
|
+
t._d = dedupeKey(t);
|
|
88
|
+
return t;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let hasFlatMeta = false;
|
|
93
|
+
ctx.entries.flatMap((e) => (e._tags || []).map((t) => ({ ...t, props: { ...t.props } }))).sort(sortTags).reduce((acc, next) => {
|
|
94
|
+
const k = String(next._d || next._p);
|
|
95
|
+
if (!acc.has(k))
|
|
96
|
+
return acc.set(k, next);
|
|
97
|
+
const prev = acc.get(k);
|
|
98
|
+
const strategy = next?.tagDuplicateStrategy || (UsesMergeStrategy.has(next.tag) ? "merge" : null) || (next.key && next.key === prev.key ? "merge" : null);
|
|
99
|
+
if (strategy === "merge") {
|
|
100
|
+
const newProps = { ...prev.props };
|
|
101
|
+
Object.entries(next.props).forEach(([p, v]) => (
|
|
102
|
+
// @ts-expect-error untyped
|
|
103
|
+
newProps[p] = p === "style" ? new Map([...prev.props.style || /* @__PURE__ */ new Map(), ...v]) : p === "class" ? /* @__PURE__ */ new Set([...prev.props.class || /* @__PURE__ */ new Set(), ...v]) : v
|
|
104
|
+
));
|
|
105
|
+
acc.set(k, { ...next, props: newProps });
|
|
106
|
+
} else if (next._p >> 10 === prev._p >> 10 && isMetaArrayDupeKey(next._d)) {
|
|
107
|
+
acc.set(k, Object.assign([...Array.isArray(prev) ? prev : [prev], next], next));
|
|
108
|
+
hasFlatMeta = true;
|
|
109
|
+
} else if (next._w === prev._w ? next._p > prev._p : next?._w < prev?._w) {
|
|
110
|
+
acc.set(k, next);
|
|
111
|
+
}
|
|
112
|
+
return acc;
|
|
113
|
+
}, ctx.tagMap);
|
|
114
|
+
const title = ctx.tagMap.get("title");
|
|
115
|
+
const titleTemplate = ctx.tagMap.get("titleTemplate");
|
|
116
|
+
head._title = title?.textContent;
|
|
117
|
+
if (titleTemplate) {
|
|
118
|
+
const titleTemplateFn = titleTemplate?.textContent;
|
|
119
|
+
head._titleTemplate = typeof titleTemplateFn === "string" ? titleTemplateFn : void 0;
|
|
120
|
+
if (titleTemplateFn) {
|
|
121
|
+
let newTitle = typeof titleTemplateFn === "function" ? titleTemplateFn(title?.textContent) : titleTemplateFn;
|
|
122
|
+
if (typeof newTitle === "string" && !head.plugins.has("template-params")) {
|
|
123
|
+
newTitle = newTitle.replace("%s", title?.textContent || "");
|
|
124
|
+
}
|
|
125
|
+
if (title) {
|
|
126
|
+
newTitle === null ? ctx.tagMap.delete("title") : ctx.tagMap.set("title", { ...title, textContent: newTitle });
|
|
127
|
+
} else {
|
|
128
|
+
titleTemplate.tag = "title";
|
|
129
|
+
titleTemplate.textContent = newTitle;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
ctx.tags = Array.from(ctx.tagMap.values());
|
|
134
|
+
if (hasFlatMeta) {
|
|
135
|
+
ctx.tags = ctx.tags.flat().sort(sortTags);
|
|
136
|
+
}
|
|
137
|
+
await hooks.callHook("tags:beforeResolve", ctx);
|
|
138
|
+
await hooks.callHook("tags:resolve", ctx);
|
|
139
|
+
await hooks.callHook("tags:afterResolve", ctx);
|
|
140
|
+
const finalTags = [];
|
|
141
|
+
for (const t of ctx.tags) {
|
|
142
|
+
const { innerHTML, tag, props } = t;
|
|
143
|
+
if (!ValidHeadTags.has(tag)) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (Object.keys(props).length === 0 && !t.innerHTML && !t.textContent) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (tag === "meta" && !props.content && !props["http-equiv"] && !props.charset) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (tag === "script" && innerHTML) {
|
|
153
|
+
if (props.type?.endsWith("json")) {
|
|
154
|
+
const v = typeof innerHTML === "string" ? innerHTML : JSON.stringify(innerHTML);
|
|
155
|
+
t.innerHTML = v.replace(/</g, "\\u003C");
|
|
156
|
+
} else if (typeof innerHTML === "string") {
|
|
157
|
+
t.innerHTML = innerHTML.replace(new RegExp(`</${tag}`, "g"), `<\\/${tag}`);
|
|
158
|
+
}
|
|
159
|
+
t._d = dedupeKey(t);
|
|
160
|
+
}
|
|
161
|
+
finalTags.push(t);
|
|
162
|
+
}
|
|
163
|
+
return finalTags;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
(resolvedOptions?.plugins || []).forEach((p) => registerPlugin(head, p));
|
|
167
|
+
head.hooks.callHook("init", head);
|
|
168
|
+
resolvedOptions.init?.forEach((e) => e && head.push(e));
|
|
169
|
+
return head;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export { createUnhead as a, createHeadCore as c };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const SelfClosingTags = /* @__PURE__ */ new Set(["meta", "link", "base"]);
|
|
2
|
+
const DupeableTags = /* @__PURE__ */ new Set(["link", "style", "script", "noscript"]);
|
|
3
|
+
const TagsWithInnerContent = /* @__PURE__ */ new Set(["title", "titleTemplate", "script", "style", "noscript"]);
|
|
4
|
+
const HasElementTags = /* @__PURE__ */ new Set([
|
|
5
|
+
"base",
|
|
6
|
+
"meta",
|
|
7
|
+
"link",
|
|
8
|
+
"style",
|
|
9
|
+
"script",
|
|
10
|
+
"noscript"
|
|
11
|
+
]);
|
|
12
|
+
const ValidHeadTags = /* @__PURE__ */ new Set([
|
|
13
|
+
"title",
|
|
14
|
+
"base",
|
|
15
|
+
"htmlAttrs",
|
|
16
|
+
"bodyAttrs",
|
|
17
|
+
"meta",
|
|
18
|
+
"link",
|
|
19
|
+
"style",
|
|
20
|
+
"script",
|
|
21
|
+
"noscript"
|
|
22
|
+
]);
|
|
23
|
+
const UniqueTags = /* @__PURE__ */ new Set(["base", "title", "titleTemplate", "bodyAttrs", "htmlAttrs", "templateParams"]);
|
|
24
|
+
const TagConfigKeys = /* @__PURE__ */ new Set(["key", "tagPosition", "tagPriority", "tagDuplicateStrategy", "innerHTML", "textContent", "processTemplateParams"]);
|
|
25
|
+
const ScriptNetworkEvents = /* @__PURE__ */ new Set(["onload", "onerror"]);
|
|
26
|
+
const UsesMergeStrategy = /* @__PURE__ */ new Set(["templateParams", "htmlAttrs", "bodyAttrs"]);
|
|
27
|
+
const MetaTagsArrayable = /* @__PURE__ */ new Set([
|
|
28
|
+
"theme-color",
|
|
29
|
+
"google-site-verification",
|
|
30
|
+
"og",
|
|
31
|
+
"article",
|
|
32
|
+
"book",
|
|
33
|
+
"profile",
|
|
34
|
+
"twitter",
|
|
35
|
+
"author"
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
export { DupeableTags as D, HasElementTags as H, MetaTagsArrayable as M, SelfClosingTags as S, TagsWithInnerContent as T, UniqueTags as U, ValidHeadTags as V, TagConfigKeys as a, ScriptNetworkEvents as b, UsesMergeStrategy as c };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { D as DupeableTags, H as HasElementTags, M as MetaTagsArrayable, b as ScriptNetworkEvents, S as SelfClosingTags, a as TagConfigKeys, T as TagsWithInnerContent, U as UniqueTags, c as UsesMergeStrategy, V as ValidHeadTags } from './shared/unhead.yem5I2v_.mjs';
|
|
2
|
+
export { d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey, n as normalizeEntryToTags, a as normalizeProps, w as walkResolver } from './shared/unhead.Cp0iF6eN.mjs';
|
|
3
|
+
export { r as resolveMetaKeyType, a as resolveMetaKeyValue, b as resolvePackedMetaObjectValue, u as unpackMeta } from './shared/unhead.DQc16pHI.mjs';
|
|
4
|
+
export { s as sortTags, t as tagWeight } from './shared/unhead.DZbvapt-.mjs';
|
|
5
|
+
export { p as processTemplateParams } from './shared/unhead.C13swrCa.mjs';
|