@nostale/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/assets/docker-compose.server.yml +70 -0
  4. package/dist/commands/config/generation.js +23 -0
  5. package/dist/commands/config/providers.js +138 -0
  6. package/dist/commands/config/sources.js +145 -0
  7. package/dist/commands/config/templates.js +117 -0
  8. package/dist/commands/config/tokens.js +83 -0
  9. package/dist/commands/config.js +43 -0
  10. package/dist/commands/doctor.js +98 -0
  11. package/dist/commands/setup.js +5 -0
  12. package/dist/commands/start.js +23 -0
  13. package/dist/commands/status.js +17 -0
  14. package/dist/commands/stop.js +16 -0
  15. package/dist/index.js +23 -0
  16. package/dist/lib/api-config.js +21 -0
  17. package/dist/lib/env-writer.js +41 -0
  18. package/dist/lib/http.js +117 -0
  19. package/dist/lib/install-root.js +75 -0
  20. package/dist/lib/paths.js +12 -0
  21. package/dist/lib/ports.js +19 -0
  22. package/dist/lib/process-manager.js +151 -0
  23. package/dist/lib/repo-root.js +34 -0
  24. package/dist/lib/wizard.js +267 -0
  25. package/dist/tui/prompts.js +54 -0
  26. package/package.json +69 -0
  27. package/services/mcp-server/index.cjs +48326 -0
  28. package/services/migrations/001_init_rag_v1.sql +128 -0
  29. package/services/migrations/002_doc_lifecycle.sql +96 -0
  30. package/services/migrations/004_mcp_tokens.sql +11 -0
  31. package/services/migrations/005_settings.sql +28 -0
  32. package/services/migrations/006_document_sources.sql +14 -0
  33. package/services/migrations/007_generation_settings.sql +9 -0
  34. package/services/migrations/008_llm_provider_configs_unique.sql +5 -0
  35. package/services/wasm/tree-sitter-c.wasm +0 -0
  36. package/services/wasm/tree-sitter-c_sharp.wasm +0 -0
  37. package/services/wasm/tree-sitter-cpp.wasm +0 -0
  38. package/services/wasm/tree-sitter-dart.wasm +0 -0
  39. package/services/wasm/tree-sitter-go.wasm +0 -0
  40. package/services/wasm/tree-sitter-java.wasm +0 -0
  41. package/services/wasm/tree-sitter-javascript.wasm +0 -0
  42. package/services/wasm/tree-sitter-kotlin.wasm +0 -0
  43. package/services/wasm/tree-sitter-php.wasm +0 -0
  44. package/services/wasm/tree-sitter-python.wasm +0 -0
  45. package/services/wasm/tree-sitter-rust.wasm +0 -0
  46. package/services/wasm/tree-sitter-tsx.wasm +0 -0
  47. package/services/wasm/tree-sitter-typescript.wasm +0 -0
  48. package/services/wasm/tree-sitter.wasm +0 -0
  49. package/services/wiki-api/index.cjs +82370 -0
  50. package/services/wiki-web/.output/nitro.json +15 -0
  51. package/services/wiki-web/.output/public/_nuxt/68caad34b1e80fa12b3a.4Cpu5VkB.woff +0 -0
  52. package/services/wiki-web/.output/public/_nuxt/6b042d50787d4a81d659.D7JGeKLp.svg +1835 -0
  53. package/services/wiki-web/.output/public/_nuxt/9065bfe481020b04b68a.CMveUrS1.woff2 +0 -0
  54. package/services/wiki-web/.output/public/_nuxt/B5j-AdCY.js +1 -0
  55. package/services/wiki-web/.output/public/_nuxt/BAgZ2ZFT.js +1 -0
  56. package/services/wiki-web/.output/public/_nuxt/BcxnhBGC.js +1 -0
  57. package/services/wiki-web/.output/public/_nuxt/BeIDAJKt.js +1 -0
  58. package/services/wiki-web/.output/public/_nuxt/BebqDWPm.js +1 -0
  59. package/services/wiki-web/.output/public/_nuxt/CFx_Wb7e.js +1 -0
  60. package/services/wiki-web/.output/public/_nuxt/CSEkmdhK.js +1 -0
  61. package/services/wiki-web/.output/public/_nuxt/CXYMfke_.js +1 -0
  62. package/services/wiki-web/.output/public/_nuxt/Cap3hpB7.js +1 -0
  63. package/services/wiki-web/.output/public/_nuxt/Ckd7UvSj.js +3 -0
  64. package/services/wiki-web/.output/public/_nuxt/D0DJQL09.js +1 -0
  65. package/services/wiki-web/.output/public/_nuxt/DRDlUXmk.js +66 -0
  66. package/services/wiki-web/.output/public/_nuxt/DW42QLqA.js +1 -0
  67. package/services/wiki-web/.output/public/_nuxt/DdDtdYim.js +1 -0
  68. package/services/wiki-web/.output/public/_nuxt/Dm1y7TW1.js +1 -0
  69. package/services/wiki-web/.output/public/_nuxt/DptiLPkM.js +4 -0
  70. package/services/wiki-web/.output/public/_nuxt/QFl-TMXl.js +1 -0
  71. package/services/wiki-web/.output/public/_nuxt/_id_.JvKV2jiN.css +1 -0
  72. package/services/wiki-web/.output/public/_nuxt/a9c9056a643325579e2a.CCNAgZDa.ttf +0 -0
  73. package/services/wiki-web/.output/public/_nuxt/bojElwT6.js +1 -0
  74. package/services/wiki-web/.output/public/_nuxt/builds/latest.json +1 -0
  75. package/services/wiki-web/.output/public/_nuxt/builds/meta/f68e5546-2919-478b-b4ad-702826e8383c.json +1 -0
  76. package/services/wiki-web/.output/public/_nuxt/d495aba62101f856c80f.DJ4Lg1TH.eot +0 -0
  77. package/services/wiki-web/.output/public/_nuxt/entry.isoIPAS3.css +1 -0
  78. package/services/wiki-web/.output/public/_nuxt/f8QtLg7g.js +1 -0
  79. package/services/wiki-web/.output/public/_nuxt/nhMvlSQm.js +1 -0
  80. package/services/wiki-web/.output/public/_nuxt/pFBugkEL.js +1 -0
  81. package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-latin-ext-wght-normal.DmpS2jIq.woff2 +0 -0
  82. package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-latin-wght-normal.eXO_dkmS.woff2 +0 -0
  83. package/services/wiki-web/.output/public/_nuxt/plus-jakarta-sans-vietnamese-wght-normal.qRpaaN48.woff2 +0 -0
  84. package/services/wiki-web/.output/public/favicon.svg +6 -0
  85. package/services/wiki-web/.output/public/robots.txt +2 -0
  86. package/services/wiki-web/.output/server/chunks/_/error-500.mjs +19 -0
  87. package/services/wiki-web/.output/server/chunks/_/error-500.mjs.map +1 -0
  88. package/services/wiki-web/.output/server/chunks/build/client.precomputed.mjs +4 -0
  89. package/services/wiki-web/.output/server/chunks/build/client.precomputed.mjs.map +1 -0
  90. package/services/wiki-web/.output/server/chunks/nitro/nitro.mjs +5352 -0
  91. package/services/wiki-web/.output/server/chunks/nitro/nitro.mjs.map +1 -0
  92. package/services/wiki-web/.output/server/chunks/routes/api-proxy/_...path_.mjs +34 -0
  93. package/services/wiki-web/.output/server/chunks/routes/api-proxy/_...path_.mjs.map +1 -0
  94. package/services/wiki-web/.output/server/chunks/routes/renderer.mjs +369 -0
  95. package/services/wiki-web/.output/server/chunks/routes/renderer.mjs.map +1 -0
  96. package/services/wiki-web/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
  97. package/services/wiki-web/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
  98. package/services/wiki-web/.output/server/index.mjs +10 -0
  99. package/services/wiki-web/.output/server/index.mjs.map +1 -0
  100. package/services/wiki-web/.output/server/node_modules/@babel/parser/lib/index.js +14599 -0
  101. package/services/wiki-web/.output/server/node_modules/@babel/parser/package.json +50 -0
  102. package/services/wiki-web/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6759 -0
  103. package/services/wiki-web/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
  104. package/services/wiki-web/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +689 -0
  105. package/services/wiki-web/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
  106. package/services/wiki-web/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1413 -0
  107. package/services/wiki-web/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
  108. package/services/wiki-web/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1899 -0
  109. package/services/wiki-web/.output/server/node_modules/@vue/reactivity/package.json +55 -0
  110. package/services/wiki-web/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +6940 -0
  111. package/services/wiki-web/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
  112. package/services/wiki-web/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1822 -0
  113. package/services/wiki-web/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
  114. package/services/wiki-web/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +896 -0
  115. package/services/wiki-web/.output/server/node_modules/@vue/server-renderer/package.json +55 -0
  116. package/services/wiki-web/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +604 -0
  117. package/services/wiki-web/.output/server/node_modules/@vue/shared/package.json +47 -0
  118. package/services/wiki-web/.output/server/node_modules/devalue/index.js +4 -0
  119. package/services/wiki-web/.output/server/node_modules/devalue/package.json +40 -0
  120. package/services/wiki-web/.output/server/node_modules/devalue/src/base64.js +60 -0
  121. package/services/wiki-web/.output/server/node_modules/devalue/src/constants.js +12 -0
  122. package/services/wiki-web/.output/server/node_modules/devalue/src/parse.js +283 -0
  123. package/services/wiki-web/.output/server/node_modules/devalue/src/stringify.js +401 -0
  124. package/services/wiki-web/.output/server/node_modules/devalue/src/uneval.js +552 -0
  125. package/services/wiki-web/.output/server/node_modules/devalue/src/utils.js +160 -0
  126. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
  127. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
  128. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
  129. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
  130. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
  131. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
  132. package/services/wiki-web/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
  133. package/services/wiki-web/.output/server/node_modules/entities/package.json +120 -0
  134. package/services/wiki-web/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
  135. package/services/wiki-web/.output/server/node_modules/estree-walker/package.json +37 -0
  136. package/services/wiki-web/.output/server/node_modules/hookable/dist/index.mjs +257 -0
  137. package/services/wiki-web/.output/server/node_modules/hookable/package.json +53 -0
  138. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
  139. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
  140. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
  141. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
  142. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
  143. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/quick-sort.js +132 -0
  144. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1188 -0
  145. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-map-generator.js +444 -0
  146. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/source-node.js +413 -0
  147. package/services/wiki-web/.output/server/node_modules/source-map-js/lib/util.js +594 -0
  148. package/services/wiki-web/.output/server/node_modules/source-map-js/package.json +71 -0
  149. package/services/wiki-web/.output/server/node_modules/source-map-js/source-map.js +8 -0
  150. package/services/wiki-web/.output/server/node_modules/ufo/dist/index.mjs +645 -0
  151. package/services/wiki-web/.output/server/node_modules/ufo/package.json +48 -0
  152. package/services/wiki-web/.output/server/node_modules/unhead/dist/parser.mjs +508 -0
  153. package/services/wiki-web/.output/server/node_modules/unhead/dist/plugins.mjs +101 -0
  154. package/services/wiki-web/.output/server/node_modules/unhead/dist/server.mjs +180 -0
  155. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.B3VbJo7Y.mjs +207 -0
  156. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.BYvz9V1x.mjs +43 -0
  157. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.CaI5ZD4O.mjs +182 -0
  158. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.CbpEuj3y.mjs +71 -0
  159. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.D4vSFytZ.mjs +236 -0
  160. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.DQc16pHI.mjs +196 -0
  161. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.TxTMM7cM.mjs +166 -0
  162. package/services/wiki-web/.output/server/node_modules/unhead/dist/shared/unhead.yem5I2v_.mjs +38 -0
  163. package/services/wiki-web/.output/server/node_modules/unhead/dist/utils.mjs +5 -0
  164. package/services/wiki-web/.output/server/node_modules/unhead/package.json +105 -0
  165. package/services/wiki-web/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
  166. package/services/wiki-web/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
  167. package/services/wiki-web/.output/server/node_modules/vue/index.js +7 -0
  168. package/services/wiki-web/.output/server/node_modules/vue/index.mjs +1 -0
  169. package/services/wiki-web/.output/server/node_modules/vue/package.json +112 -0
  170. package/services/wiki-web/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
  171. package/services/wiki-web/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +249 -0
  172. package/services/wiki-web/.output/server/node_modules/vue-bundle-renderer/package.json +57 -0
  173. package/services/wiki-web/.output/server/package.json +26 -0
  174. package/services/wiki-worker/index.cjs +66661 -0
@@ -0,0 +1,180 @@
1
+ import { a as createUnhead } from './shared/unhead.CaI5ZD4O.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.B3VbJo7Y.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 "&amp;";
99
+ case "<":
100
+ return "&lt;";
101
+ case ">":
102
+ return "&gt;";
103
+ case '"':
104
+ return "&quot;";
105
+ case "'":
106
+ return "&#x27;";
107
+ case "/":
108
+ return "&#x2F;";
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
+ if (props.hreflang)
24
+ return `alternate:${props.hreflang}`;
25
+ if (props.type)
26
+ return `alternate:${props.type}:${props.href || ""}`;
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,182 @@
1
+ import { createHooks } from 'hookable';
2
+ import { n as normalizeEntryToTags, d as dedupeKey, h as hashTag, i as isMetaArrayDupeKey } from './unhead.B3VbJo7Y.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 };
@@ -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 };