usage-board 3.0.0 → 3.1.1
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.mjs +1 -1
- package/dist/public/_nuxt/{y3weNNd-.js → B6C9KBQ4.js} +2 -2
- package/dist/public/_nuxt/Bv6agYS5.js +119 -0
- package/dist/public/_nuxt/BvRyOET7.js +1 -0
- package/dist/public/_nuxt/CMWftE4h.js +1 -0
- package/dist/public/_nuxt/{Be3rizqy.js → COIbUy5w.js} +1 -1
- package/dist/public/_nuxt/CXLmM1yO.js +25 -0
- package/dist/public/_nuxt/DFqWEFN4.js +1 -0
- package/dist/public/_nuxt/DUoLvn3A.js +6 -0
- package/dist/public/_nuxt/D_W11Quh.js +21 -0
- package/dist/public/_nuxt/DgKrPjze.js +4 -0
- package/dist/public/_nuxt/DkxY2YMp.js +1 -0
- package/dist/public/_nuxt/{7Dy4NLP8.js → DtbPvE6R.js} +24 -24
- package/dist/public/_nuxt/HiqUua3-.js +1 -0
- package/dist/public/_nuxt/builds/latest.json +1 -1
- package/dist/public/_nuxt/builds/meta/6f98f1cb-266c-475e-a249-dad346a55f24.json +1 -0
- package/dist/public/_nuxt/entry.vHfFzkyD.css +1 -0
- package/dist/public/_nuxt/error-404.CFBEg71j.css +1 -0
- package/dist/public/_nuxt/error-500.BqCnH31G.css +1 -0
- package/dist/public/_nuxt/uHQwCIHg.js +1 -0
- package/dist/server/chunks/_/error-500.mjs +2 -20
- package/dist/server/chunks/build/client.precomputed.mjs +1 -1
- package/dist/server/chunks/nitro/nitro.mjs +2303 -3614
- package/dist/server/chunks/routes/api/analysis/agent/session.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/agent/token.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/cache.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/hot-project.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/model.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/overview-cards.json.mjs +24 -0
- package/dist/server/chunks/routes/api/analysis/session.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/token/daily.json.mjs +21 -0
- package/dist/server/chunks/routes/api/analysis/token.json.mjs +24 -0
- package/dist/server/chunks/routes/api/payload.json.mjs +9 -10
- package/dist/server/chunks/routes/api/projects/_project/modules.get.mjs +9 -10
- package/dist/server/chunks/routes/api/projects/catalog.get.mjs +9 -10
- package/dist/server/chunks/routes/renderer.mjs +17 -39183
- package/dist/server/chunks/routes/ws.mjs +9 -10
- package/dist/server/index.mjs +9 -10
- package/dist/server/node_modules/@babel/parser/lib/index.js +14582 -0
- package/dist/server/node_modules/@babel/parser/package.json +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/index.js +292 -0
- package/dist/server/node_modules/@iconify/utils/lib/colors/keywords.js +702 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/common.js +76 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/format.js +40 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icon.js +52 -0
- package/dist/server/node_modules/@iconify/utils/lib/css/icons.js +133 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/bool.js +20 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/defaults.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/flip.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/customisations/rotate.js +31 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/cleanup.js +80 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/convert.js +102 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/data.js +29 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/format.js +60 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/parse.js +50 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/base.js +204 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/create.js +35 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/numbers.js +134 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/similar.js +167 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/regex/tree.js +81 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/find.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/replace/replace.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/components.js +78 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/missing.js +68 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/name.js +47 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/parse.js +105 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/similar.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/tree.js +94 -0
- package/dist/server/node_modules/@iconify/utils/lib/emoji/test/variations.js +64 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/defaults.js +26 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/merge.js +18 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/name.js +58 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/square.js +34 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon/transformations.js +13 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/convert-info.js +126 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/expand.js +21 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icon.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/get-icons.js +38 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/minify.js +93 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/parse.js +48 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/tree.js +24 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate-basic.js +44 -0
- package/dist/server/node_modules/@iconify/utils/lib/icon-set/validate.js +125 -0
- package/dist/server/node_modules/@iconify/utils/lib/index.js +53 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/custom.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/loader.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/modern.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/loader/utils.js +63 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/objects.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/strings.js +27 -0
- package/dist/server/node_modules/@iconify/utils/lib/misc/title.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/build.js +115 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/defs.js +32 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/encode-svg-for-css.js +15 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/html.js +10 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/id.js +42 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/inner-html.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/parse.js +69 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/pretty.js +55 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/size.js +28 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/trim.js +8 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/url.js +23 -0
- package/dist/server/node_modules/@iconify/utils/lib/svg/viewbox.js +9 -0
- package/dist/server/node_modules/@iconify/utils/package.json +118 -0
- package/dist/server/node_modules/@lonewolfyx/utils/dist/index.mjs +63 -0
- package/dist/server/node_modules/@lonewolfyx/utils/package.json +64 -0
- package/dist/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6763 -0
- package/dist/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/dist/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
- package/dist/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/dist/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
- package/dist/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/dist/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1877 -0
- package/dist/server/node_modules/@vue/reactivity/package.json +55 -0
- package/dist/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6856 -0
- package/dist/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/dist/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1796 -0
- package/dist/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/dist/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +883 -0
- package/dist/server/node_modules/@vue/server-renderer/package.json +55 -0
- package/dist/server/{chunks/_/shared.cjs.prod.mjs → node_modules/@vue/shared/dist/shared.cjs.prod.js} +76 -81
- package/dist/server/node_modules/@vue/shared/package.json +47 -0
- package/dist/server/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- package/dist/server/node_modules/better-sqlite3/lib/database.js +90 -0
- package/dist/server/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/table.js +189 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/server/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/server/node_modules/better-sqlite3/lib/sqlite-error.js +20 -0
- package/dist/server/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/server/node_modules/better-sqlite3/package.json +59 -0
- package/dist/server/node_modules/bindings/bindings.js +221 -0
- package/dist/server/node_modules/bindings/package.json +28 -0
- package/dist/server/node_modules/chokidar/handler.js +632 -0
- package/dist/server/node_modules/chokidar/index.js +822 -0
- package/dist/server/node_modules/chokidar/package.json +63 -0
- package/dist/server/{chunks/_ → node_modules/consola/dist/chunks}/prompt.mjs +2 -1
- package/dist/server/node_modules/consola/dist/core.mjs +512 -0
- package/dist/server/node_modules/consola/dist/index.mjs +651 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/dist/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/dist/server/node_modules/consola/package.json +136 -0
- package/dist/server/node_modules/devalue/index.js +4 -0
- package/dist/server/node_modules/devalue/package.json +40 -0
- package/dist/server/node_modules/devalue/src/base64.js +60 -0
- package/dist/server/node_modules/devalue/src/constants.js +7 -0
- package/dist/server/node_modules/devalue/src/parse.js +268 -0
- package/dist/server/node_modules/devalue/src/stringify.js +335 -0
- package/dist/server/node_modules/devalue/src/uneval.js +552 -0
- package/dist/server/node_modules/devalue/src/utils.js +144 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/dist/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/dist/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/dist/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/dist/server/node_modules/entities/package.json +120 -0
- package/dist/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/dist/server/node_modules/estree-walker/package.json +37 -0
- package/dist/server/node_modules/file-uri-to-path/index.js +66 -0
- package/dist/server/node_modules/file-uri-to-path/package.json +32 -0
- package/dist/server/node_modules/glob/dist/esm/index.min.js +4 -0
- package/dist/server/node_modules/glob/dist/esm/package.json +3 -0
- package/dist/server/node_modules/glob/package.json +98 -0
- package/dist/server/node_modules/hookable/dist/index.mjs +257 -0
- package/dist/server/node_modules/hookable/package.json +53 -0
- package/dist/server/node_modules/md5-typescript/dist/bundles/bundle.umd.js +208 -0
- package/dist/server/node_modules/md5-typescript/package.json +31 -0
- package/dist/server/node_modules/path-type/index.js +42 -0
- package/dist/server/node_modules/path-type/package.json +51 -0
- package/dist/server/node_modules/readdirp/index.js +272 -0
- package/dist/server/node_modules/readdirp/package.json +66 -0
- package/dist/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/dist/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/dist/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/dist/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/dist/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/dist/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
- package/dist/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
- package/dist/server/node_modules/source-map-js/lib/source-node.js +413 -0
- package/dist/server/node_modules/source-map-js/lib/util.js +594 -0
- package/dist/server/node_modules/source-map-js/package.json +71 -0
- package/dist/server/node_modules/source-map-js/source-map.js +8 -0
- package/dist/server/node_modules/ufo/dist/index.mjs +645 -0
- package/dist/server/node_modules/ufo/package.json +48 -0
- package/dist/server/node_modules/unhead/dist/parser.mjs +508 -0
- package/dist/server/node_modules/unhead/dist/plugins.mjs +101 -0
- package/dist/server/node_modules/unhead/dist/server.mjs +180 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.B5FWS6X0.mjs +207 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.Ct24BOby.mjs +182 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
- package/dist/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
- package/dist/server/node_modules/unhead/dist/utils.mjs +5 -0
- package/dist/server/node_modules/unhead/package.json +105 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/dist/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/dist/server/node_modules/vue/index.js +7 -0
- package/dist/server/node_modules/vue/index.mjs +1 -0
- package/dist/server/node_modules/vue/package.json +112 -0
- package/dist/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/dist/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +301 -0
- package/dist/server/node_modules/vue-bundle-renderer/package.json +55 -0
- package/dist/server/package.json +37 -0
- package/package.json +3 -1
- package/dist/public/_nuxt/B-VlGWDb.js +0 -21
- package/dist/public/_nuxt/C0azgqnZ.js +0 -1
- package/dist/public/_nuxt/CMNdiQCa.js +0 -1
- package/dist/public/_nuxt/CPuXQJE_.js +0 -1
- package/dist/public/_nuxt/DenksPSi.js +0 -119
- package/dist/public/_nuxt/Dkya5WaL.js +0 -9
- package/dist/public/_nuxt/HN9OZyaQ.js +0 -25
- package/dist/public/_nuxt/JtK-nXxy.js +0 -1
- package/dist/public/_nuxt/builds/meta/37e8bb21-a086-45bf-93dc-47eeeada7299.json +0 -1
- package/dist/public/_nuxt/entry.r-q4oQC0.css +0 -1
- package/dist/public/_nuxt/error-404.B0EXnOcv.css +0 -1
- package/dist/public/_nuxt/error-500.CnSNZoEG.css +0 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { a as createUnhead } from './shared/unhead.Ct24BOby.mjs';
|
|
2
|
+
import { T as TagsWithInnerContent, S as SelfClosingTags } from './shared/unhead.yem5I2v_.mjs';
|
|
3
|
+
import { parseHtmlForUnheadExtraction, applyHeadToHtml, parseHtmlForIndexes } from './parser.mjs';
|
|
4
|
+
import 'hookable';
|
|
5
|
+
import './shared/unhead.B5FWS6X0.mjs';
|
|
6
|
+
import './shared/unhead.CbpEuj3y.mjs';
|
|
7
|
+
|
|
8
|
+
// @__NO_SIDE_EFFECTS__
|
|
9
|
+
function createHead(options = {}) {
|
|
10
|
+
const unhead = createUnhead({
|
|
11
|
+
...options,
|
|
12
|
+
// @ts-expect-error untyped
|
|
13
|
+
document: false,
|
|
14
|
+
propResolvers: [
|
|
15
|
+
...options.propResolvers || [],
|
|
16
|
+
(k, v) => {
|
|
17
|
+
if (k && k.startsWith("on") && typeof v === "function") {
|
|
18
|
+
return `this.dataset.${k}fired = true`;
|
|
19
|
+
}
|
|
20
|
+
return v;
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
init: [
|
|
24
|
+
options.disableDefaults ? void 0 : {
|
|
25
|
+
htmlAttrs: {
|
|
26
|
+
lang: "en"
|
|
27
|
+
},
|
|
28
|
+
meta: [
|
|
29
|
+
{
|
|
30
|
+
charset: "utf-8"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "viewport",
|
|
34
|
+
content: "width=device-width, initial-scale=1"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
...options.init || []
|
|
39
|
+
]
|
|
40
|
+
});
|
|
41
|
+
unhead._ssrPayload = {};
|
|
42
|
+
unhead.use({
|
|
43
|
+
key: "server",
|
|
44
|
+
hooks: {
|
|
45
|
+
"tags:resolve": function(ctx) {
|
|
46
|
+
const title = ctx.tagMap.get("title");
|
|
47
|
+
const titleTemplate = ctx.tagMap.get("titleTemplate");
|
|
48
|
+
let payload = {
|
|
49
|
+
title: title?.mode === "server" ? unhead._title : void 0,
|
|
50
|
+
titleTemplate: titleTemplate?.mode === "server" ? unhead._titleTemplate : void 0
|
|
51
|
+
};
|
|
52
|
+
if (Object.keys(unhead._ssrPayload || {}).length > 0) {
|
|
53
|
+
payload = {
|
|
54
|
+
...unhead._ssrPayload,
|
|
55
|
+
...payload
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (Object.values(payload).some(Boolean)) {
|
|
59
|
+
ctx.tags.push({
|
|
60
|
+
tag: "script",
|
|
61
|
+
innerHTML: JSON.stringify(payload),
|
|
62
|
+
props: { id: "unhead:payload", type: "application/json" }
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return unhead;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function extractUnheadInputFromHtml(html) {
|
|
72
|
+
return parseHtmlForUnheadExtraction(html);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function encodeAttribute(value) {
|
|
76
|
+
return String(value).replace(/"/g, """);
|
|
77
|
+
}
|
|
78
|
+
function propsToString(props) {
|
|
79
|
+
let attrs = "";
|
|
80
|
+
for (const key in props) {
|
|
81
|
+
if (!Object.hasOwn(props, key))
|
|
82
|
+
continue;
|
|
83
|
+
let value = props[key];
|
|
84
|
+
if ((key === "class" || key === "style") && typeof value !== "string") {
|
|
85
|
+
value = key === "class" ? Array.from(value).join(" ") : Array.from(value).map(([k, v]) => `${k}:${v}`).join(";");
|
|
86
|
+
}
|
|
87
|
+
if (value !== false && value !== null) {
|
|
88
|
+
attrs += value === true ? ` ${key}` : ` ${key}="${encodeAttribute(value)}"`;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return attrs;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function escapeHtml(str) {
|
|
95
|
+
return str.replace(/[&<>"'/]/g, (char) => {
|
|
96
|
+
switch (char) {
|
|
97
|
+
case "&":
|
|
98
|
+
return "&";
|
|
99
|
+
case "<":
|
|
100
|
+
return "<";
|
|
101
|
+
case ">":
|
|
102
|
+
return ">";
|
|
103
|
+
case '"':
|
|
104
|
+
return """;
|
|
105
|
+
case "'":
|
|
106
|
+
return "'";
|
|
107
|
+
case "/":
|
|
108
|
+
return "/";
|
|
109
|
+
default:
|
|
110
|
+
return char;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function tagToString(tag) {
|
|
115
|
+
const attrs = propsToString(tag.props);
|
|
116
|
+
const openTag = `<${tag.tag}${attrs}>`;
|
|
117
|
+
if (!TagsWithInnerContent.has(tag.tag))
|
|
118
|
+
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}</${tag.tag}>`;
|
|
119
|
+
let content = String(tag.textContent || tag.innerHTML || "");
|
|
120
|
+
content = tag.tag === "title" ? escapeHtml(content) : content.replace(new RegExp(`</${tag.tag}`, "gi"), `<\\/${tag.tag}`);
|
|
121
|
+
return SelfClosingTags.has(tag.tag) ? openTag : `${openTag}${content}</${tag.tag}>`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function ssrRenderTags(tags, options) {
|
|
125
|
+
const schema = { htmlAttrs: {}, bodyAttrs: {}, tags: { head: "", bodyClose: "", bodyOpen: "" } };
|
|
126
|
+
const lineBreaks = !options?.omitLineBreaks ? "\n" : "";
|
|
127
|
+
for (const tag of tags) {
|
|
128
|
+
if (tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs") {
|
|
129
|
+
Object.assign(schema[tag.tag], tag.props);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const s = tagToString(tag);
|
|
133
|
+
const tagPosition = tag.tagPosition || "head";
|
|
134
|
+
schema.tags[tagPosition] += schema.tags[tagPosition] ? `${lineBreaks}${s}` : s;
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
headTags: schema.tags.head,
|
|
138
|
+
bodyTags: schema.tags.bodyClose,
|
|
139
|
+
bodyTagsOpen: schema.tags.bodyOpen,
|
|
140
|
+
htmlAttrs: propsToString(schema.htmlAttrs),
|
|
141
|
+
bodyAttrs: propsToString(schema.bodyAttrs)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// @__NO_SIDE_EFFECTS__
|
|
146
|
+
async function renderSSRHead(head, options) {
|
|
147
|
+
const beforeRenderCtx = { shouldRender: true };
|
|
148
|
+
await head.hooks.callHook("ssr:beforeRender", beforeRenderCtx);
|
|
149
|
+
if (!beforeRenderCtx.shouldRender) {
|
|
150
|
+
return {
|
|
151
|
+
headTags: "",
|
|
152
|
+
bodyTags: "",
|
|
153
|
+
bodyTagsOpen: "",
|
|
154
|
+
htmlAttrs: "",
|
|
155
|
+
bodyAttrs: ""
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const ctx = { tags: options?.resolvedTags || await head.resolveTags() };
|
|
159
|
+
await head.hooks.callHook("ssr:render", ctx);
|
|
160
|
+
const html = ssrRenderTags(ctx.tags, options);
|
|
161
|
+
const renderCtx = { tags: ctx.tags, html };
|
|
162
|
+
await head.hooks.callHook("ssr:rendered", renderCtx);
|
|
163
|
+
return renderCtx.html;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// @__NO_SIDE_EFFECTS__
|
|
167
|
+
async function transformHtmlTemplate(head, html, options) {
|
|
168
|
+
const template = parseHtmlForUnheadExtraction(html);
|
|
169
|
+
head.push(template.input, { _index: 0 });
|
|
170
|
+
const headHtml = await renderSSRHead(head, options);
|
|
171
|
+
return applyHeadToHtml(template, headHtml);
|
|
172
|
+
}
|
|
173
|
+
// @__NO_SIDE_EFFECTS__
|
|
174
|
+
async function transformHtmlTemplateRaw(head, html, options) {
|
|
175
|
+
const headHtml = await renderSSRHead(head, options);
|
|
176
|
+
const template = parseHtmlForIndexes(html);
|
|
177
|
+
return applyHeadToHtml(template, headHtml);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { createHead, escapeHtml, extractUnheadInputFromHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString, transformHtmlTemplate, transformHtmlTemplateRaw };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { U as UniqueTags, T as TagsWithInnerContent, M as MetaTagsArrayable, H as HasElementTags, a as TagConfigKeys, D as DupeableTags } from './unhead.yem5I2v_.mjs';
|
|
2
|
+
|
|
3
|
+
const allowedMetaProperties = ["name", "property", "http-equiv"];
|
|
4
|
+
const StandardSingleMetaTags = /* @__PURE__ */ new Set([
|
|
5
|
+
"viewport",
|
|
6
|
+
"description",
|
|
7
|
+
"keywords",
|
|
8
|
+
"robots"
|
|
9
|
+
]);
|
|
10
|
+
function isMetaArrayDupeKey(v) {
|
|
11
|
+
const parts = v.split(":");
|
|
12
|
+
if (!parts.length)
|
|
13
|
+
return false;
|
|
14
|
+
return MetaTagsArrayable.has(parts[1]);
|
|
15
|
+
}
|
|
16
|
+
function dedupeKey(tag) {
|
|
17
|
+
const { props, tag: name } = tag;
|
|
18
|
+
if (UniqueTags.has(name))
|
|
19
|
+
return name;
|
|
20
|
+
if (name === "link" && props.rel === "canonical")
|
|
21
|
+
return "canonical";
|
|
22
|
+
if (name === "link" && props.rel === "alternate") {
|
|
23
|
+
const altKey = props.hreflang || props.type;
|
|
24
|
+
if (altKey) {
|
|
25
|
+
return `alternate:${altKey}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (props.charset)
|
|
29
|
+
return "charset";
|
|
30
|
+
if (tag.tag === "meta") {
|
|
31
|
+
for (const n of allowedMetaProperties) {
|
|
32
|
+
if (props[n] !== void 0) {
|
|
33
|
+
const propValue = props[n];
|
|
34
|
+
const isStructured = propValue && typeof propValue === "string" && propValue.includes(":");
|
|
35
|
+
const isStandardSingle = propValue && StandardSingleMetaTags.has(propValue);
|
|
36
|
+
const shouldAlwaysDedupe = isStructured || isStandardSingle;
|
|
37
|
+
const keyPart = !shouldAlwaysDedupe && tag.key ? `:key:${tag.key}` : "";
|
|
38
|
+
return `${name}:${propValue}${keyPart}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (tag.key) {
|
|
43
|
+
return `${name}:key:${tag.key}`;
|
|
44
|
+
}
|
|
45
|
+
if (props.id) {
|
|
46
|
+
return `${name}:id:${props.id}`;
|
|
47
|
+
}
|
|
48
|
+
if (name === "link" && props.rel === "alternate") {
|
|
49
|
+
return `alternate:${props.href || ""}`;
|
|
50
|
+
}
|
|
51
|
+
if (TagsWithInnerContent.has(name)) {
|
|
52
|
+
const v = tag.textContent || tag.innerHTML;
|
|
53
|
+
if (v) {
|
|
54
|
+
return `${name}:content:${v}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function hashTag(tag) {
|
|
59
|
+
const dedupe = tag._h || tag._d;
|
|
60
|
+
if (dedupe)
|
|
61
|
+
return dedupe;
|
|
62
|
+
const inner = tag.textContent || tag.innerHTML;
|
|
63
|
+
if (inner)
|
|
64
|
+
return inner;
|
|
65
|
+
return `${tag.tag}:${Object.entries(tag.props).map(([k, v]) => `${k}:${String(v)}`).join(",")}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function walkResolver(val, resolve, key) {
|
|
69
|
+
const type = typeof val;
|
|
70
|
+
if (type === "function") {
|
|
71
|
+
if (!key || key !== "titleTemplate" && !(key[0] === "o" && key[1] === "n")) {
|
|
72
|
+
val = val();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const v = resolve ? resolve(key, val) : val;
|
|
76
|
+
if (Array.isArray(v)) {
|
|
77
|
+
return v.map((r) => walkResolver(r, resolve));
|
|
78
|
+
}
|
|
79
|
+
if (v?.constructor === Object) {
|
|
80
|
+
const next = {};
|
|
81
|
+
for (const k of Object.keys(v)) {
|
|
82
|
+
next[k] = walkResolver(v[k], resolve, k);
|
|
83
|
+
}
|
|
84
|
+
return next;
|
|
85
|
+
}
|
|
86
|
+
return v;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function normalizeStyleClassProps(key, value) {
|
|
90
|
+
const store = key === "style" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ new Set();
|
|
91
|
+
function processValue(rawValue) {
|
|
92
|
+
if (rawValue == null || rawValue === void 0)
|
|
93
|
+
return;
|
|
94
|
+
const value2 = String(rawValue).trim();
|
|
95
|
+
if (!value2)
|
|
96
|
+
return;
|
|
97
|
+
if (key === "style") {
|
|
98
|
+
const [k, ...v] = value2.split(":").map((s) => s ? s.trim() : "");
|
|
99
|
+
if (k && v.length)
|
|
100
|
+
store.set(k, v.join(":"));
|
|
101
|
+
} else {
|
|
102
|
+
value2.split(" ").filter(Boolean).forEach((c) => store.add(c));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (typeof value === "string") {
|
|
106
|
+
key === "style" ? value.split(";").forEach(processValue) : processValue(value);
|
|
107
|
+
} else if (Array.isArray(value)) {
|
|
108
|
+
value.forEach((item) => processValue(item));
|
|
109
|
+
} else if (value && typeof value === "object") {
|
|
110
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
111
|
+
if (v && v !== "false") {
|
|
112
|
+
key === "style" ? store.set(String(k).trim(), String(v)) : processValue(k);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return store;
|
|
117
|
+
}
|
|
118
|
+
function normalizeProps(tag, input) {
|
|
119
|
+
tag.props = tag.props || {};
|
|
120
|
+
if (!input) {
|
|
121
|
+
return tag;
|
|
122
|
+
}
|
|
123
|
+
if (tag.tag === "templateParams") {
|
|
124
|
+
tag.props = input;
|
|
125
|
+
return tag;
|
|
126
|
+
}
|
|
127
|
+
const isHtmlTag = HasElementTags.has(tag.tag) || tag.tag === "htmlAttrs" || tag.tag === "bodyAttrs";
|
|
128
|
+
Object.entries(input).forEach(([prop, value]) => {
|
|
129
|
+
if (prop === "__proto__" || prop === "constructor" || prop === "prototype")
|
|
130
|
+
return;
|
|
131
|
+
if (value === null) {
|
|
132
|
+
tag.props[prop] = null;
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (prop === "class" || prop === "style") {
|
|
136
|
+
tag.props[prop] = normalizeStyleClassProps(prop, value);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (TagConfigKeys.has(prop)) {
|
|
140
|
+
if ((prop === "textContent" || prop === "innerHTML") && typeof value === "object") {
|
|
141
|
+
let type = input.type;
|
|
142
|
+
if (!input.type) {
|
|
143
|
+
type = "application/json";
|
|
144
|
+
}
|
|
145
|
+
if (!type?.endsWith("json") && type !== "speculationrules") {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
input.type = type;
|
|
149
|
+
tag.props.type = type;
|
|
150
|
+
tag[prop] = JSON.stringify(value);
|
|
151
|
+
} else {
|
|
152
|
+
tag[prop] = value;
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const isDataKey = prop.startsWith("data-");
|
|
157
|
+
const key = isHtmlTag && !isDataKey ? prop.toLowerCase() : prop;
|
|
158
|
+
const strValue = String(value);
|
|
159
|
+
const isMetaContentKey = tag.tag === "meta" && key === "content";
|
|
160
|
+
if (strValue === "true" || strValue === "") {
|
|
161
|
+
tag.props[key] = isDataKey || isMetaContentKey ? strValue : true;
|
|
162
|
+
} else if (!value && isDataKey && strValue === "false") {
|
|
163
|
+
tag.props[key] = "false";
|
|
164
|
+
} else if (value !== void 0) {
|
|
165
|
+
tag.props[key] = value;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
return tag;
|
|
169
|
+
}
|
|
170
|
+
function normalizeTag(tagName, _input) {
|
|
171
|
+
const input = typeof _input === "object" && typeof _input !== "function" ? _input : { [tagName === "script" || tagName === "noscript" || tagName === "style" ? "innerHTML" : "textContent"]: _input };
|
|
172
|
+
const tag = normalizeProps({ tag: tagName, props: {} }, input);
|
|
173
|
+
if (tag.key && DupeableTags.has(tag.tag)) {
|
|
174
|
+
tag.props["data-hid"] = tag._h = tag.key;
|
|
175
|
+
}
|
|
176
|
+
if (tag.tag === "script" && typeof tag.innerHTML === "object") {
|
|
177
|
+
tag.innerHTML = JSON.stringify(tag.innerHTML);
|
|
178
|
+
tag.props.type = tag.props.type || "application/json";
|
|
179
|
+
}
|
|
180
|
+
return Array.isArray(tag.props.content) ? tag.props.content.map((v) => ({ ...tag, props: { ...tag.props, content: v } })) : tag;
|
|
181
|
+
}
|
|
182
|
+
function normalizeEntryToTags(input, propResolvers) {
|
|
183
|
+
if (!input) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
if (typeof input === "function") {
|
|
187
|
+
input = input();
|
|
188
|
+
}
|
|
189
|
+
const resolvers = (key, val) => {
|
|
190
|
+
for (let i = 0; i < propResolvers.length; i++) {
|
|
191
|
+
val = propResolvers[i](key, val);
|
|
192
|
+
}
|
|
193
|
+
return val;
|
|
194
|
+
};
|
|
195
|
+
input = resolvers(void 0, input);
|
|
196
|
+
const tags = [];
|
|
197
|
+
input = walkResolver(input, resolvers);
|
|
198
|
+
Object.entries(input || {}).forEach(([key, value]) => {
|
|
199
|
+
if (value === void 0)
|
|
200
|
+
return;
|
|
201
|
+
for (const v of Array.isArray(value) ? value : [value])
|
|
202
|
+
tags.push(normalizeTag(key, v));
|
|
203
|
+
});
|
|
204
|
+
return tags.flat();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export { normalizeProps as a, dedupeKey as d, hashTag as h, isMetaArrayDupeKey as i, normalizeEntryToTags as n, walkResolver as w };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const SepSub = "%separator";
|
|
2
|
+
function sub(p, token, isJson = false) {
|
|
3
|
+
let val;
|
|
4
|
+
if (token === "s" || token === "pageTitle") {
|
|
5
|
+
val = p.pageTitle;
|
|
6
|
+
} else if (token.includes(".")) {
|
|
7
|
+
const dotIndex = token.indexOf(".");
|
|
8
|
+
val = p[token.substring(0, dotIndex)]?.[token.substring(dotIndex + 1)];
|
|
9
|
+
} else {
|
|
10
|
+
val = p[token];
|
|
11
|
+
}
|
|
12
|
+
if (val !== void 0) {
|
|
13
|
+
return isJson ? (val || "").replace(/\\/g, "\\\\").replace(/</g, "\\u003C").replace(/"/g, '\\"') : val || "";
|
|
14
|
+
}
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
function processTemplateParams(s, p, sep, isJson = false) {
|
|
18
|
+
if (typeof s !== "string" || !s.includes("%"))
|
|
19
|
+
return s;
|
|
20
|
+
let decoded = s;
|
|
21
|
+
try {
|
|
22
|
+
decoded = decodeURI(s);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
const tokens = decoded.match(/%\w+(?:\.\w+)?/g);
|
|
26
|
+
if (!tokens) {
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
const hasSepSub = s.includes(SepSub);
|
|
30
|
+
s = s.replace(/%\w+(?:\.\w+)?/g, (token) => {
|
|
31
|
+
if (token === SepSub || !tokens.includes(token)) {
|
|
32
|
+
return token;
|
|
33
|
+
}
|
|
34
|
+
const re = sub(p, token.slice(1), isJson);
|
|
35
|
+
return re !== void 0 ? re : token;
|
|
36
|
+
}).trim();
|
|
37
|
+
if (hasSepSub) {
|
|
38
|
+
s = s.split(SepSub).map((part) => part.trim()).filter((part) => part !== "").join(sep ? ` ${sep} ` : " ");
|
|
39
|
+
}
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { processTemplateParams as p };
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
const type = String(tag.props.type);
|
|
58
|
+
if (isTruthy(tag.props.async)) {
|
|
59
|
+
weight = weightMap.script.async;
|
|
60
|
+
} else if (tag.props.src && !isTruthy(tag.props.defer) && !isTruthy(tag.props.async) && type !== "module" && !type.endsWith("json") || tag.innerHTML && !type.endsWith("json")) {
|
|
61
|
+
weight = weightMap.script.sync;
|
|
62
|
+
} else if (isTruthy(tag.props.defer) && tag.props.src && !isTruthy(tag.props.async) || type === "module") {
|
|
63
|
+
weight = weightMap.script.defer;
|
|
64
|
+
}
|
|
65
|
+
} else if (tag.tag === "style") {
|
|
66
|
+
weight = tag.innerHTML && ImportStyleRe.test(tag.innerHTML) ? weightMap.style.imported : weightMap.style.sync;
|
|
67
|
+
}
|
|
68
|
+
return (weight || 100) + offset;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { sortTags as s, tagWeight as t };
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { createHooks } from 'hookable';
|
|
2
|
+
import { n as normalizeEntryToTags, d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey } from './unhead.B5FWS6X0.mjs';
|
|
3
|
+
import { t as tagWeight, s as sortTags } from './unhead.CbpEuj3y.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 = /* @__PURE__ */ new Set();
|
|
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.add(_i);
|
|
49
|
+
hooks.callHook("entries:updated", head);
|
|
50
|
+
},
|
|
51
|
+
dispose() {
|
|
52
|
+
if (entries.delete(_i)) {
|
|
53
|
+
head.invalidate();
|
|
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.size) {
|
|
76
|
+
const i = normalizeQueue.values().next().value;
|
|
77
|
+
normalizeQueue.delete(i);
|
|
78
|
+
const e = entries.get(i);
|
|
79
|
+
if (e) {
|
|
80
|
+
const normalizeCtx = {
|
|
81
|
+
tags: normalizeEntryToTags(e.input, resolvedOptions.propResolvers || []).map((t) => Object.assign(t, e.options)),
|
|
82
|
+
entry: e
|
|
83
|
+
};
|
|
84
|
+
await hooks.callHook("entries:normalize", normalizeCtx);
|
|
85
|
+
e._tags = normalizeCtx.tags.map((t, i2) => {
|
|
86
|
+
t._w = tagWeight(head, t);
|
|
87
|
+
t._p = (e._i << 10) + i2;
|
|
88
|
+
t._d = dedupeKey(t);
|
|
89
|
+
if (!t._d)
|
|
90
|
+
t._h = hashTag(t);
|
|
91
|
+
return t;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
let hasFlatMeta = false;
|
|
96
|
+
ctx.entries.flatMap((e) => (e._tags || []).map((t) => ({ ...t, props: { ...t.props } }))).sort(sortTags).reduce((acc, next) => {
|
|
97
|
+
const k = next._d || next._h;
|
|
98
|
+
if (!acc.has(k))
|
|
99
|
+
return acc.set(k, next);
|
|
100
|
+
const prev = acc.get(k);
|
|
101
|
+
const strategy = next?.tagDuplicateStrategy || (UsesMergeStrategy.has(next.tag) ? "merge" : null) || (next.key && next.key === prev.key ? "merge" : null);
|
|
102
|
+
if (strategy === "merge") {
|
|
103
|
+
const newProps = { ...prev.props };
|
|
104
|
+
Object.entries(next.props).forEach(([p, v]) => (
|
|
105
|
+
// @ts-expect-error untyped
|
|
106
|
+
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
|
|
107
|
+
));
|
|
108
|
+
acc.set(k, { ...next, props: newProps });
|
|
109
|
+
} else if (next._p >> 10 === prev._p >> 10 && next.tag === "meta" && isMetaArrayDupeKey(k)) {
|
|
110
|
+
acc.set(k, Object.assign([...Array.isArray(prev) ? prev : [prev], next], next));
|
|
111
|
+
hasFlatMeta = true;
|
|
112
|
+
} else if (next._w === prev._w ? next._p > prev._p : next?._w < prev?._w) {
|
|
113
|
+
acc.set(k, next);
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
}, ctx.tagMap);
|
|
117
|
+
const title = ctx.tagMap.get("title");
|
|
118
|
+
const titleTemplate = ctx.tagMap.get("titleTemplate");
|
|
119
|
+
head._title = title?.textContent;
|
|
120
|
+
if (titleTemplate) {
|
|
121
|
+
const titleTemplateFn = titleTemplate?.textContent;
|
|
122
|
+
head._titleTemplate = titleTemplateFn;
|
|
123
|
+
if (titleTemplateFn) {
|
|
124
|
+
let newTitle = typeof titleTemplateFn === "function" ? titleTemplateFn(title?.textContent) : titleTemplateFn;
|
|
125
|
+
if (typeof newTitle === "string" && !head.plugins.has("template-params")) {
|
|
126
|
+
newTitle = newTitle.replace("%s", title?.textContent || "");
|
|
127
|
+
}
|
|
128
|
+
if (title) {
|
|
129
|
+
newTitle === null ? ctx.tagMap.delete("title") : ctx.tagMap.set("title", { ...title, textContent: newTitle });
|
|
130
|
+
} else {
|
|
131
|
+
titleTemplate.tag = "title";
|
|
132
|
+
titleTemplate.textContent = newTitle;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
ctx.tags = Array.from(ctx.tagMap.values());
|
|
137
|
+
if (hasFlatMeta) {
|
|
138
|
+
ctx.tags = ctx.tags.flat().sort(sortTags);
|
|
139
|
+
}
|
|
140
|
+
await hooks.callHook("tags:beforeResolve", ctx);
|
|
141
|
+
await hooks.callHook("tags:resolve", ctx);
|
|
142
|
+
await hooks.callHook("tags:afterResolve", ctx);
|
|
143
|
+
const finalTags = [];
|
|
144
|
+
for (const t of ctx.tags) {
|
|
145
|
+
const { innerHTML, tag, props } = t;
|
|
146
|
+
if (!ValidHeadTags.has(tag)) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (Object.keys(props).length === 0 && !t.innerHTML && !t.textContent) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
if (tag === "meta" && !props.content && !props["http-equiv"] && !props.charset) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (tag === "script" && innerHTML) {
|
|
156
|
+
if (String(props.type).endsWith("json")) {
|
|
157
|
+
const v = typeof innerHTML === "string" ? innerHTML : JSON.stringify(innerHTML);
|
|
158
|
+
t.innerHTML = v.replace(/</g, "\\u003C");
|
|
159
|
+
} else if (typeof innerHTML === "string") {
|
|
160
|
+
t.innerHTML = innerHTML.replace(new RegExp(`</${tag}`, "g"), `<\\/${tag}`);
|
|
161
|
+
}
|
|
162
|
+
t._d = dedupeKey(t);
|
|
163
|
+
}
|
|
164
|
+
finalTags.push(t);
|
|
165
|
+
}
|
|
166
|
+
return finalTags;
|
|
167
|
+
},
|
|
168
|
+
invalidate() {
|
|
169
|
+
for (const entry of entries.values()) {
|
|
170
|
+
normalizeQueue.add(entry._i);
|
|
171
|
+
}
|
|
172
|
+
head.dirty = true;
|
|
173
|
+
hooks.callHook("entries:updated", head);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
(resolvedOptions?.plugins || []).forEach((p) => registerPlugin(head, p));
|
|
177
|
+
head.hooks.callHook("init", head);
|
|
178
|
+
resolvedOptions.init?.forEach((e) => e && head.push(e));
|
|
179
|
+
return head;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export { createUnhead as a, createHeadCore as c };
|