@adminide-stack/yantra-mobile 12.0.167-alpha.0 → 12.0.168-alpha.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 (134) hide show
  1. package/lib/assets/kinds/character.webp +0 -0
  2. package/lib/assets/kinds/image.webp +0 -0
  3. package/lib/assets/kinds/video.webp +0 -0
  4. package/lib/assets/kinds/website.webp +0 -0
  5. package/lib/bridge/handlers/NavigationBridgeHandler.js +3 -2
  6. package/lib/bridge/handlers/NavigationBridgeHandler.js.map +1 -1
  7. package/lib/components/CustomDrawer.js +6 -2
  8. package/lib/components/CustomDrawer.js.map +1 -1
  9. package/lib/features/agent-chat/NativeAgentChat.js +17 -3
  10. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  11. package/lib/features/chat/ApprovalCard.js +8 -2
  12. package/lib/features/chat/ApprovalCard.js.map +1 -1
  13. package/lib/features/chat/AskUserCard.js +5 -3
  14. package/lib/features/chat/AskUserCard.js.map +1 -1
  15. package/lib/features/chat/ComposerModeSwitch.js +147 -0
  16. package/lib/features/chat/ComposerModeSwitch.js.map +1 -0
  17. package/lib/features/templates/__tests__/buildKinds.test.ts +54 -0
  18. package/lib/features/templates/__tests__/buildTemplateCards.test.ts +58 -6
  19. package/lib/features/templates/__tests__/templateSuggestion.test.ts +30 -0
  20. package/lib/features/templates/buildKinds.js +114 -0
  21. package/lib/features/templates/buildKinds.js.map +1 -0
  22. package/lib/features/templates/buildKinds.ts +189 -0
  23. package/lib/features/templates/buildTemplateCards.js +63 -18
  24. package/lib/features/templates/buildTemplateCards.js.map +1 -1
  25. package/lib/features/templates/buildTemplateCards.ts +88 -18
  26. package/lib/features/templates/index.ts +2 -0
  27. package/lib/features/templates/templateSuggestion.js +34 -0
  28. package/lib/features/templates/templateSuggestion.js.map +1 -0
  29. package/lib/features/templates/templateSuggestion.ts +57 -0
  30. package/lib/features/webbuilder/WebBuilderExperience.js +188 -28
  31. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  32. package/lib/features/webbuilder/approvalsLink.js +6 -0
  33. package/lib/features/webbuilder/approvalsLink.js.map +1 -0
  34. package/lib/features/webbuilder/buildFragments.js +19 -4
  35. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  36. package/lib/features/webbuilder/components/CloudSheet.js +18 -5
  37. package/lib/features/webbuilder/components/CloudSheet.js.map +1 -1
  38. package/lib/features/webbuilder/components/CodeView.js +7 -3
  39. package/lib/features/webbuilder/components/CodeView.js.map +1 -1
  40. package/lib/features/webbuilder/components/DomainFinder.js +263 -0
  41. package/lib/features/webbuilder/components/DomainFinder.js.map +1 -0
  42. package/lib/features/webbuilder/components/DraftsSheet.js +298 -0
  43. package/lib/features/webbuilder/components/DraftsSheet.js.map +1 -0
  44. package/lib/features/webbuilder/components/ImageEditPanel.js +266 -0
  45. package/lib/features/webbuilder/components/ImageEditPanel.js.map +1 -0
  46. package/lib/features/webbuilder/components/MentionMenu.js +155 -0
  47. package/lib/features/webbuilder/components/MentionMenu.js.map +1 -0
  48. package/lib/features/webbuilder/components/NotesSheet.js +138 -0
  49. package/lib/features/webbuilder/components/NotesSheet.js.map +1 -0
  50. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  51. package/lib/features/webbuilder/components/ProjectChat.js +17 -3
  52. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  53. package/lib/features/webbuilder/components/PublishSheet.js +200 -15
  54. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  55. package/lib/features/webbuilder/components/ShareSheet.js +48 -6
  56. package/lib/features/webbuilder/components/ShareSheet.js.map +1 -1
  57. package/lib/features/webbuilder/components/SiteCopyProgress.js +169 -0
  58. package/lib/features/webbuilder/components/SiteCopyProgress.js.map +1 -0
  59. package/lib/features/webbuilder/components/SiteStatusSheet.js +145 -2
  60. package/lib/features/webbuilder/components/SiteStatusSheet.js.map +1 -1
  61. package/lib/features/webbuilder/drafts.js +167 -0
  62. package/lib/features/webbuilder/drafts.js.map +1 -0
  63. package/lib/features/webbuilder/maskPng.js +113 -0
  64. package/lib/features/webbuilder/maskPng.js.map +1 -0
  65. package/lib/features/webbuilder/previewProbe.js.map +1 -1
  66. package/lib/features/webbuilder/stepLabels.js +21 -1
  67. package/lib/features/webbuilder/stepLabels.js.map +1 -1
  68. package/lib/features/webbuilder/web/chat/mentions.js +106 -0
  69. package/lib/features/webbuilder/web/chat/mentions.js.map +1 -0
  70. package/lib/features/webbuilder/web/chat/siteCopy.js +121 -0
  71. package/lib/features/webbuilder/web/chat/siteCopy.js.map +1 -0
  72. package/lib/features/webbuilder/web/code/imageEdit.js +30 -0
  73. package/lib/features/webbuilder/web/code/imageEdit.js.map +1 -0
  74. package/lib/features/webbuilder/web/design/linkedDesign.js +26 -0
  75. package/lib/features/webbuilder/web/design/linkedDesign.js.map +1 -0
  76. package/lib/features/webbuilder/web/project/buildLink.js +3 -0
  77. package/lib/features/webbuilder/web/project/buildLink.js.map +1 -0
  78. package/lib/features/webbuilder/web/project/drafts.js +57 -0
  79. package/lib/features/webbuilder/web/project/drafts.js.map +1 -0
  80. package/lib/features/webbuilder/web/project/navHistory.js +7 -0
  81. package/lib/features/webbuilder/web/project/navHistory.js.map +1 -0
  82. package/lib/features/webbuilder/web/project/serverSettings.js +15 -4
  83. package/lib/features/webbuilder/web/project/serverSettings.js.map +1 -1
  84. package/lib/features/webbuilder/web/publish/domainShop.js +79 -0
  85. package/lib/features/webbuilder/web/publish/domainShop.js.map +1 -0
  86. package/lib/features/webbuilder/web/publish/publishRequest.js +11 -0
  87. package/lib/features/webbuilder/web/publish/publishRequest.js.map +1 -0
  88. package/lib/features/webbuilder/web/publish/review/freshness.js +13 -0
  89. package/lib/features/webbuilder/web/publish/review/freshness.js.map +1 -0
  90. package/lib/features/webbuilder/web/publish/review/ignores.js +94 -0
  91. package/lib/features/webbuilder/web/publish/review/ignores.js.map +1 -0
  92. package/lib/features/webbuilder/web/publish/review/seo.js +230 -0
  93. package/lib/features/webbuilder/web/publish/review/seo.js.map +1 -0
  94. package/lib/features/webbuilder/web/publish/siteHealth.js +27 -3
  95. package/lib/features/webbuilder/web/publish/siteHealth.js.map +1 -1
  96. package/lib/features/webbuilder/web/publish/siteInsights.js +120 -3
  97. package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -1
  98. package/lib/features/webbuilder/web/sharing/shareLink.js +9 -0
  99. package/lib/features/webbuilder/web/sharing/shareLink.js.map +1 -0
  100. package/lib/features/webbuilder/web/webServices.js +1 -1
  101. package/lib/features/webbuilder/web/webServices.js.map +1 -1
  102. package/lib/hooks/useMarketplaceTemplateCards.js +3 -4
  103. package/lib/hooks/useMarketplaceTemplateCards.js.map +1 -1
  104. package/lib/hooks/useMarketplaceTemplateGroups.js +12 -5
  105. package/lib/hooks/useMarketplaceTemplateGroups.js.map +1 -1
  106. package/lib/hooks/useTemplatesResourceUri.js +12 -0
  107. package/lib/hooks/useTemplatesResourceUri.js.map +1 -0
  108. package/lib/screens/Chat/index.js +4 -22
  109. package/lib/screens/Chat/index.js.map +1 -1
  110. package/lib/screens/Home/HomeScreen.js +165 -179
  111. package/lib/screens/Home/HomeScreen.js.map +1 -1
  112. package/lib/screens/Home/components/BuildKindPicker.js +248 -0
  113. package/lib/screens/Home/components/BuildKindPicker.js.map +1 -0
  114. package/lib/screens/Home/components/BuildTemplatesSection.js +556 -117
  115. package/lib/screens/Home/components/BuildTemplatesSection.js.map +1 -1
  116. package/lib/screens/Home/components/KindThumb.js +444 -0
  117. package/lib/screens/Home/components/KindThumb.js.map +1 -0
  118. package/lib/screens/Home/components/TemplateSuggestionBanner.js +73 -0
  119. package/lib/screens/Home/components/TemplateSuggestionBanner.js.map +1 -0
  120. package/lib/screens/Home/components/buildTheme.js +68 -0
  121. package/lib/screens/Home/components/buildTheme.js.map +1 -0
  122. package/lib/screens/WebBuilder/index.js +11 -1
  123. package/lib/screens/WebBuilder/index.js.map +1 -1
  124. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +55 -0
  125. package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -0
  126. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +4 -0
  127. package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -1
  128. package/lib/screens/WebBuilderNative/index.js +31 -4
  129. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  130. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +1 -0
  131. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  132. package/lib/screens/WebBuilderNative/webbuilderTransport.js +5 -5
  133. package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
  134. package/package.json +3 -3
@@ -0,0 +1,230 @@
1
+ const decodeEntities = (s) => s.replace(/&nbsp;/gi, " ").replace(/&quot;/gi, '"').replace(/&#39;|&apos;/gi, "'").replace(/&#(\d+);/g, (_, n) => String.fromCodePoint(Number(n))).replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&amp;/gi, "&");
2
+ function parseAttrs(tag) {
3
+ var _a, _b, _c;
4
+ const out = {};
5
+ const re = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}|([^\s"'=<>`{}]+)))?/g;
6
+ const body = tag.replace(/^<\s*[a-zA-Z][-a-zA-Z0-9]*/, "").replace(/\/?>$/, "");
7
+ for (const m of body.matchAll(re)) {
8
+ const name = m[1].toLowerCase();
9
+ if (name in out) continue;
10
+ const raw = (_c = (_b = (_a = m[2]) != null ? _a : m[3]) != null ? _b : m[5]) != null ? _c : m[4] !== void 0 ? `{${m[4]}}` : "";
11
+ out[name] = decodeEntities(raw).trim();
12
+ }
13
+ return out;
14
+ }
15
+ const clean = (s) => {
16
+ const t = (s || "").replace(/\s+/g, " ").trim();
17
+ return t || void 0;
18
+ };
19
+ function parseSeoHtml(html) {
20
+ const src = String(html || "");
21
+ const page = {
22
+ og: {},
23
+ twitter: {},
24
+ h1Count: 0,
25
+ hasJsonLd: false,
26
+ images: []
27
+ };
28
+ const htmlTag = src.match(/<html\b[^>]*>/i);
29
+ if (htmlTag) page.lang = clean(parseAttrs(htmlTag[0]).lang);
30
+ const title = src.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
31
+ if (title) page.title = clean(decodeEntities(title[1]));
32
+ for (const m of src.matchAll(/<meta\b[^>]*>/gi)) {
33
+ const a = parseAttrs(m[0]);
34
+ const key = (a.name || a.property || "").toLowerCase();
35
+ const content = clean(a.content);
36
+ if (!key || !content) continue;
37
+ const set = (obj, k) => {
38
+ if (!obj[k]) obj[k] = content;
39
+ };
40
+ if (key === "description") set(page, "description");
41
+ else if (key === "robots") set(page, "robotsMeta");
42
+ else if (key === "og:title") set(page.og, "title");
43
+ else if (key === "og:description") set(page.og, "description");
44
+ else if (key === "og:image" || key === "og:image:url" || key === "og:image:secure_url") set(page.og, "image");
45
+ else if (key === "og:url") set(page.og, "url");
46
+ else if (key === "og:site_name") set(page.og, "siteName");
47
+ else if (key === "og:type") set(page.og, "type");
48
+ else if (key === "twitter:card") set(page.twitter, "card");
49
+ else if (key === "twitter:title") set(page.twitter, "title");
50
+ else if (key === "twitter:description") set(page.twitter, "description");
51
+ else if (key === "twitter:image" || key === "twitter:image:src") set(page.twitter, "image");
52
+ else if (key === "twitter:site") set(page.twitter, "site");
53
+ }
54
+ for (const m of src.matchAll(/<link\b[^>]*>/gi)) {
55
+ const a = parseAttrs(m[0]);
56
+ const rel = (a.rel || "").toLowerCase().split(/\s+/);
57
+ if (!page.canonical && rel.includes("canonical") && a.href) page.canonical = a.href;
58
+ if (!page.favicon && a.href && (rel.includes("icon") || rel.includes("apple-touch-icon"))) {
59
+ page.favicon = a.href;
60
+ }
61
+ }
62
+ page.h1Count = (src.match(/<h1[\s>]/gi) || []).length;
63
+ page.hasJsonLd = /<script\b[^>]*type\s*=\s*["']application\/ld\+json["']/i.test(src);
64
+ for (const m of src.matchAll(/<img\b[^>]*>/gi)) {
65
+ const a = parseAttrs(m[0]);
66
+ page.images.push({
67
+ src: a.src || "",
68
+ alt: "alt" in a ? a.alt : null,
69
+ where: "page"
70
+ });
71
+ if (page.images.length >= 100) break;
72
+ }
73
+ return page;
74
+ }
75
+ const MARK = "__WB_SEO_";
76
+ const HTML_LIMIT = 6e4;
77
+ function buildSeoProbeCommand() {
78
+ const fileCheck = (name, sources) => [`S=missing; for f in ${sources}; do if [ -e "$f" ]; then S=ok; fi; done`, `if [ "$S" = missing ]; then T=$(curl -s -m 5 -o /tmp/wb-seo-${name} -w '%{http_code} %{content_type}' http://localhost:$P/${name} 2>/dev/null || true)`, ` case "$T" in 200\\ text/html*) ;; 200*) S=ok ;; 000*|"") S=unknown ;; esac`, "fi", `echo "${MARK}${name.toUpperCase().replace(".", "_")}__:$S"`].join("\n");
79
+ return [
80
+ // The dev server's port as a variable: the deploy guard refuses bundles with a literal localhost:<port>.
81
+ "P=3000",
82
+ `H=$(curl -s -m 10 http://localhost:$P/ 2>/dev/null | head -c ${HTML_LIMIT})`,
83
+ `if [ -z "$H" ] && [ -f index.html ]; then H=$(head -c ${HTML_LIMIT} index.html); fi`,
84
+ `echo "${MARK}HTML_BEGIN__"`,
85
+ 'printf "%s\\n" "$H"',
86
+ `echo "${MARK}HTML_END__"`,
87
+ fileCheck("robots.txt", "public/robots.txt static/robots.txt app/robots.ts app/robots.js src/app/robots.ts"),
88
+ fileCheck("sitemap.xml", "public/sitemap.xml static/sitemap.xml app/sitemap.ts app/sitemap.js src/app/sitemap.ts"),
89
+ `R=""; for f in public/robots.txt static/robots.txt /tmp/wb-seo-robots.txt; do if [ -f "$f" ]; then R="$f"; break; fi; done`,
90
+ `if [ -n "$R" ]; then echo "${MARK}ROBOTS_BEGIN__"; head -c 4000 "$R"; echo; echo "${MARK}ROBOTS_END__"; fi`,
91
+ `echo "${MARK}IMG_BEGIN__"`,
92
+ `D=''; for d in src app pages components; do if [ -d "$d" ]; then D="$D $d"; fi; done`,
93
+ `if [ -n "$D" ]; then grep -rnoE --exclude-dir=node_modules '<img[^>]*>' $D 2>/dev/null | cut -c1-400 | head -n 150; fi`,
94
+ `echo "${MARK}IMG_END__"`,
95
+ // Growth ideas: does the source have these at all (1/0), and how many page routes does it declare.
96
+ 'has() { if grep -rqiE --exclude-dir=node_modules "$1" $D index.html 2>/dev/null; then echo 1; else echo 0; fi; }',
97
+ 'if [ -n "$D" ]; then',
98
+ ` echo "${MARK}FACT__:structuredData=$(has 'application/ld\\+json')"`,
99
+ ` echo "${MARK}FACT__:faq=$(has 'faq|frequently asked')"`,
100
+ ` echo "${MARK}FACT__:blog=$(has '["/](blog|articles|guides|news)["/]')"`,
101
+ ` echo "${MARK}FACT__:contact=$(has 'mailto:|tel:')"`,
102
+ ` echo "${MARK}FACT__:testimonials=$(has 'testimonial|what (our )?(customers|clients) say')"`,
103
+ ` N=$(grep -rhoE --exclude-dir=node_modules "path(=|: ?)[\\"'][^\\"'*]+[\\"']" $D 2>/dev/null | sed -E "s/^path(=|: ?)//; s/[\\"']//g" | sort -u | wc -l | tr -d ' ')`,
104
+ ' if [ -d app ] || [ -d src/app ]; then A=$(find app src/app -name "page.*" 2>/dev/null | wc -l | tr -d " "); if [ "$A" -gt "$N" ]; then N=$A; fi; fi',
105
+ ` echo "${MARK}FACT__:pageCount=$N"`,
106
+ "fi",
107
+ "exit 0"
108
+ ].join("\n");
109
+ }
110
+ const between = (text, name) => {
111
+ const begin = text.indexOf(`${MARK}${name}_BEGIN__`);
112
+ if (begin < 0) return null;
113
+ const start = text.indexOf("\n", begin);
114
+ const end = text.indexOf(`${MARK}${name}_END__`, start);
115
+ return text.slice(start + 1, end < 0 ? void 0 : end);
116
+ };
117
+ const fileState = (text, name) => {
118
+ const m = text.match(new RegExp(`${MARK}${name}__:(ok|missing|unknown)`));
119
+ return (m == null ? void 0 : m[1]) || "unknown";
120
+ };
121
+ function parseSeoProbeOutput(stdout) {
122
+ const text = String(stdout || "");
123
+ const html = between(text, "HTML");
124
+ const robotsText = between(text, "ROBOTS");
125
+ const files = {
126
+ robots: fileState(text, "ROBOTS_TXT"),
127
+ sitemap: fileState(text, "SITEMAP_XML")
128
+ };
129
+ if (robotsText !== null) {
130
+ let star = false;
131
+ let blocksAll = false;
132
+ for (const raw of robotsText.split("\n")) {
133
+ const line = raw.replace(/#.*/, "").trim();
134
+ const ua = line.match(/^user-agent:\s*(.+)$/i);
135
+ if (ua) star = ua[1].trim() === "*";
136
+ else if (star && /^disallow:\s*\/\s*$/i.test(line)) blocksAll = true;
137
+ }
138
+ files.robotsBlocksAll = blocksAll;
139
+ files.robotsListsSitemap = /^\s*sitemap:\s*\S+/im.test(robotsText);
140
+ }
141
+ const sourceImages = [];
142
+ for (const line of (between(text, "IMG") || "").split("\n")) {
143
+ const m = line.match(/^(.+?):(\d+):(<img[\s\S]*)$/i);
144
+ if (!m) continue;
145
+ const a = parseAttrs(m[3]);
146
+ sourceImages.push({
147
+ src: a.src || "",
148
+ alt: "alt" in a ? a.alt : null,
149
+ where: `${m[1]}:${m[2]}`
150
+ });
151
+ }
152
+ return {
153
+ html: html && html.trim() ? html : null,
154
+ files,
155
+ sourceImages,
156
+ facts: parseFacts(text)
157
+ };
158
+ }
159
+ function parseFacts(text) {
160
+ const raw = /* @__PURE__ */ new Map();
161
+ for (const m of text.matchAll(new RegExp(`${MARK}FACT__:([a-zA-Z]+)=(\\d+)`, "g"))) raw.set(m[1], m[2]);
162
+ const flag = (k) => raw.has(k) ? raw.get(k) === "1" : null;
163
+ const n = raw.has("pageCount") ? Number(raw.get("pageCount")) : NaN;
164
+ return {
165
+ structuredData: flag("structuredData"),
166
+ faq: flag("faq"),
167
+ blog: flag("blog"),
168
+ contact: flag("contact"),
169
+ testimonials: flag("testimonials"),
170
+ pageCount: Number.isFinite(n) && n >= 0 ? n : null
171
+ };
172
+ }
173
+ const KEEP_FACTS = "Use only facts already on the site; ask me for anything you do not have instead of inventing it.";
174
+ function seoOpportunities(page, facts) {
175
+ if (!facts) return [];
176
+ const out = [];
177
+ if (!(page == null ? void 0 : page.hasJsonLd) && facts.structuredData === false) {
178
+ out.push({
179
+ id: "structured-data",
180
+ title: "Help search engines show your business details",
181
+ why: "Structured data (name, logo, contact, opening hours) lets search engines show rich results beside your link.",
182
+ work: `Add JSON-LD structured data for this business (Organization or LocalBusiness: name, logo, url, contact details, and address and opening hours if the site shows them) to the page head. ${KEEP_FACTS}`
183
+ });
184
+ }
185
+ if (facts.pageCount !== null && facts.pageCount <= 2) {
186
+ out.push({
187
+ id: "pages",
188
+ title: "Give each service or product its own page",
189
+ why: "One page can only rank for a few searches. A page per offer can rank for each of them.",
190
+ work: `Create a dedicated page for each main service or product the site describes, each with its own title, meta description and heading, linked from the navigation and listed in the sitemap. ${KEEP_FACTS}`
191
+ });
192
+ }
193
+ if (facts.faq === false) {
194
+ out.push({
195
+ id: "faq",
196
+ title: "Answer the questions customers ask",
197
+ why: "People search in questions. An FAQ answers them on your site and can appear directly in search results.",
198
+ work: `Add an FAQ section with 5 to 8 questions and answers drawn from the site's own content, marked up with FAQPage structured data. ${KEEP_FACTS}`
199
+ });
200
+ }
201
+ if (facts.blog === false) {
202
+ out.push({
203
+ id: "blog",
204
+ title: "Start a blog or guides section",
205
+ why: "Helpful articles bring visitors from searches your main pages do not cover, and give people a reason to come back.",
206
+ work: `Add a blog (or guides) section: an index page and two starter articles on topics this site's customers search for, linked from the navigation and listed in the sitemap. ${KEEP_FACTS}`
207
+ });
208
+ }
209
+ if (facts.contact === false) {
210
+ out.push({
211
+ id: "contact",
212
+ title: "Make it easy to reach you",
213
+ why: "Visitors who cannot find a phone number or email leave. Search engines also trust sites that show how to reach them.",
214
+ work: `Add a contact section or page (email, phone and address if known), linked from the footer of every page. ${KEEP_FACTS}`
215
+ });
216
+ }
217
+ if (facts.testimonials === false) {
218
+ out.push({
219
+ id: "testimonials",
220
+ title: "Show what customers say",
221
+ why: "Reviews and quotes from real customers turn more visitors into customers.",
222
+ work: "Add a testimonials section designed for real customer quotes, with clearly marked placeholders for me to fill in. Never invent names or quotes presented as real."
223
+ });
224
+ }
225
+ return out;
226
+ }
227
+ function moreOpportunitiesText(siteUrl, known) {
228
+ const skip = known.length ? ` Leave out what is already on this list: ${known.map((o) => o.title).join("; ")}.` : "";
229
+ return `Look at my site${siteUrl ? ` (${siteUrl})` : ""} and its pages, and suggest 3 to 5 specific changes most likely to bring more visitors from search or turn more of them into customers. For each, say what to change on which page and why.${skip} Suggest only; do not change the site yet. Then ask me which ones to work on.`;
230
+ }export{buildSeoProbeCommand,moreOpportunitiesText,parseAttrs,parseSeoHtml,parseSeoProbeOutput,seoOpportunities};//# sourceMappingURL=seo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seo.js","sources":["../../../../../../src/features/webbuilder/web/publish/review/seo.ts"],"sourcesContent":["/** SEO review: read the site's HTML head, check it, and build the search and social card previews. Pure. */\nimport { BUILDER_DEFAULT_TITLE_RE } from '../../import/foreignBuilderMarkers';\n\nexport type ReviewSeverity = 'critical' | 'warning' | 'info';\n\nexport interface SeoImage {\n src: string;\n /** null: the tag has no alt attribute at all (alt=\"\" is a valid decorative image). */\n alt: string | null;\n /** Where the tag was found: the page, or a source file (path:line). */\n where?: string;\n}\n\nexport interface SeoPage {\n title?: string;\n description?: string;\n canonical?: string;\n lang?: string;\n robotsMeta?: string;\n favicon?: string;\n og: { title?: string; description?: string; image?: string; url?: string; siteName?: string; type?: string };\n twitter: { card?: string; title?: string; description?: string; image?: string; site?: string };\n h1Count: number;\n hasJsonLd: boolean;\n images: SeoImage[];\n}\n\nexport type FileState = 'ok' | 'missing' | 'unknown';\n\nexport interface SeoSiteFiles {\n robots: FileState;\n sitemap: FileState;\n /** robots.txt has `Disallow: /` for every crawler. */\n robotsBlocksAll?: boolean;\n robotsListsSitemap?: boolean;\n}\n\n/** What the site's source has, for growth ideas (null: not checked, e.g. no source folder). */\nexport interface SeoSiteFacts {\n structuredData: boolean | null;\n faq: boolean | null;\n blog: boolean | null;\n contact: boolean | null;\n testimonials: boolean | null;\n /** Distinct page routes declared in the source. */\n pageCount: number | null;\n}\n\nexport interface SeoProbe {\n html: string | null;\n files: SeoSiteFiles;\n /** `<img>` tags found in the source files (single-page apps render images at runtime). */\n sourceImages: SeoImage[];\n facts?: SeoSiteFacts;\n}\n\nexport interface SeoCheck {\n id: string;\n ok: boolean;\n severity: ReviewSeverity;\n title: string;\n detail?: string;\n why: string;\n /** The request \"Fix with AI\" sends; absent when there is nothing to fix. */\n fix?: string;\n}\n\nexport const SEO_LIMITS = {\n title: 60,\n titleMin: 15,\n description: 160,\n descriptionMin: 50,\n socialTitle: 70,\n socialDescription: 200,\n} as const;\n\nconst decodeEntities = (s: string): string =>\n s\n .replace(/&nbsp;/gi, ' ')\n .replace(/&quot;/gi, '\"')\n .replace(/&#39;|&apos;/gi, \"'\")\n .replace(/&#(\\d+);/g, (_, n) => String.fromCodePoint(Number(n)))\n .replace(/&lt;/gi, '<')\n .replace(/&gt;/gi, '>')\n .replace(/&amp;/gi, '&');\n\n/** Attributes of one tag (HTML or simple JSX: `alt={x}` counts as present). */\nexport function parseAttrs(tag: string): Record<string, string> {\n const out: Record<string, string> = {};\n const re = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|\\{([^}]*)\\}|([^\\s\"'=<>`{}]+)))?/g;\n const body = tag.replace(/^<\\s*[a-zA-Z][-a-zA-Z0-9]*/, '').replace(/\\/?>$/, '');\n for (const m of body.matchAll(re)) {\n const name = m[1].toLowerCase();\n if (name in out) continue;\n const raw = m[2] ?? m[3] ?? m[5] ?? (m[4] !== undefined ? `{${m[4]}}` : '');\n out[name] = decodeEntities(raw).trim();\n }\n return out;\n}\n\nconst clean = (s: string | undefined): string | undefined => {\n const t = (s || '').replace(/\\s+/g, ' ').trim();\n return t || undefined;\n};\n\nexport function parseSeoHtml(html: string): SeoPage {\n const src = String(html || '');\n const page: SeoPage = { og: {}, twitter: {}, h1Count: 0, hasJsonLd: false, images: [] };\n const htmlTag = src.match(/<html\\b[^>]*>/i);\n if (htmlTag) page.lang = clean(parseAttrs(htmlTag[0]).lang);\n const title = src.match(/<title\\b[^>]*>([\\s\\S]*?)<\\/title>/i);\n if (title) page.title = clean(decodeEntities(title[1]));\n for (const m of src.matchAll(/<meta\\b[^>]*>/gi)) {\n const a = parseAttrs(m[0]);\n const key = (a.name || a.property || '').toLowerCase();\n const content = clean(a.content);\n if (!key || !content) continue;\n const set = <T extends object>(obj: T, k: keyof T) => {\n if (!obj[k]) (obj as Record<keyof T, string>)[k] = content;\n };\n if (key === 'description') set(page, 'description');\n else if (key === 'robots') set(page, 'robotsMeta');\n else if (key === 'og:title') set(page.og, 'title');\n else if (key === 'og:description') set(page.og, 'description');\n else if (key === 'og:image' || key === 'og:image:url' || key === 'og:image:secure_url') set(page.og, 'image');\n else if (key === 'og:url') set(page.og, 'url');\n else if (key === 'og:site_name') set(page.og, 'siteName');\n else if (key === 'og:type') set(page.og, 'type');\n else if (key === 'twitter:card') set(page.twitter, 'card');\n else if (key === 'twitter:title') set(page.twitter, 'title');\n else if (key === 'twitter:description') set(page.twitter, 'description');\n else if (key === 'twitter:image' || key === 'twitter:image:src') set(page.twitter, 'image');\n else if (key === 'twitter:site') set(page.twitter, 'site');\n }\n for (const m of src.matchAll(/<link\\b[^>]*>/gi)) {\n const a = parseAttrs(m[0]);\n const rel = (a.rel || '').toLowerCase().split(/\\s+/);\n if (!page.canonical && rel.includes('canonical') && a.href) page.canonical = a.href;\n if (!page.favicon && a.href && (rel.includes('icon') || rel.includes('apple-touch-icon'))) {\n page.favicon = a.href;\n }\n }\n page.h1Count = (src.match(/<h1[\\s>]/gi) || []).length;\n page.hasJsonLd = /<script\\b[^>]*type\\s*=\\s*[\"']application\\/ld\\+json[\"']/i.test(src);\n for (const m of src.matchAll(/<img\\b[^>]*>/gi)) {\n const a = parseAttrs(m[0]);\n page.images.push({ src: a.src || '', alt: 'alt' in a ? a.alt : null, where: 'page' });\n if (page.images.length >= 100) break;\n }\n return page;\n}\n\n// ---------------------------------------------------------------- the sandbox probe\n\nconst MARK = '__WB_SEO_';\nconst HTML_LIMIT = 60_000;\n\n/** RUN_COMMAND script: the served home page, robots.txt / sitemap.xml (an SPA answers HTML for any path) and source `<img>` tags. */\nexport function buildSeoProbeCommand(): string {\n const fileCheck = (name: string, sources: string) =>\n [\n `S=missing; for f in ${sources}; do if [ -e \"$f\" ]; then S=ok; fi; done`,\n `if [ \"$S\" = missing ]; then T=$(curl -s -m 5 -o /tmp/wb-seo-${name} -w '%{http_code} %{content_type}' http://localhost:$P/${name} 2>/dev/null || true)`,\n ` case \"$T\" in 200\\\\ text/html*) ;; 200*) S=ok ;; 000*|\"\") S=unknown ;; esac`,\n 'fi',\n `echo \"${MARK}${name.toUpperCase().replace('.', '_')}__:$S\"`,\n ].join('\\n');\n return [\n // The dev server's port as a variable: the deploy guard refuses bundles with a literal localhost:<port>.\n 'P=3000',\n `H=$(curl -s -m 10 http://localhost:$P/ 2>/dev/null | head -c ${HTML_LIMIT})`,\n `if [ -z \"$H\" ] && [ -f index.html ]; then H=$(head -c ${HTML_LIMIT} index.html); fi`,\n `echo \"${MARK}HTML_BEGIN__\"`,\n 'printf \"%s\\\\n\" \"$H\"',\n `echo \"${MARK}HTML_END__\"`,\n fileCheck('robots.txt', 'public/robots.txt static/robots.txt app/robots.ts app/robots.js src/app/robots.ts'),\n fileCheck(\n 'sitemap.xml',\n 'public/sitemap.xml static/sitemap.xml app/sitemap.ts app/sitemap.js src/app/sitemap.ts',\n ),\n `R=\"\"; for f in public/robots.txt static/robots.txt /tmp/wb-seo-robots.txt; do if [ -f \"$f\" ]; then R=\"$f\"; break; fi; done`,\n `if [ -n \"$R\" ]; then echo \"${MARK}ROBOTS_BEGIN__\"; head -c 4000 \"$R\"; echo; echo \"${MARK}ROBOTS_END__\"; fi`,\n `echo \"${MARK}IMG_BEGIN__\"`,\n 'D=\\'\\'; for d in src app pages components; do if [ -d \"$d\" ]; then D=\"$D $d\"; fi; done',\n `if [ -n \"$D\" ]; then grep -rnoE --exclude-dir=node_modules '<img[^>]*>' $D 2>/dev/null | cut -c1-400 | head -n 150; fi`,\n `echo \"${MARK}IMG_END__\"`,\n // Growth ideas: does the source have these at all (1/0), and how many page routes does it declare.\n 'has() { if grep -rqiE --exclude-dir=node_modules \"$1\" $D index.html 2>/dev/null; then echo 1; else echo 0; fi; }',\n 'if [ -n \"$D\" ]; then',\n ` echo \"${MARK}FACT__:structuredData=$(has 'application/ld\\\\+json')\"`,\n ` echo \"${MARK}FACT__:faq=$(has 'faq|frequently asked')\"`,\n ` echo \"${MARK}FACT__:blog=$(has '[\"/](blog|articles|guides|news)[\"/]')\"`,\n ` echo \"${MARK}FACT__:contact=$(has 'mailto:|tel:')\"`,\n ` echo \"${MARK}FACT__:testimonials=$(has 'testimonial|what (our )?(customers|clients) say')\"`,\n ` N=$(grep -rhoE --exclude-dir=node_modules \"path(=|: ?)[\\\\\"'][^\\\\\"'*]+[\\\\\"']\" $D 2>/dev/null | sed -E \"s/^path(=|: ?)//; s/[\\\\\"']//g\" | sort -u | wc -l | tr -d ' ')`,\n ' if [ -d app ] || [ -d src/app ]; then A=$(find app src/app -name \"page.*\" 2>/dev/null | wc -l | tr -d \" \"); if [ \"$A\" -gt \"$N\" ]; then N=$A; fi; fi',\n ` echo \"${MARK}FACT__:pageCount=$N\"`,\n 'fi',\n 'exit 0',\n ].join('\\n');\n}\n\nconst between = (text: string, name: string): string | null => {\n const begin = text.indexOf(`${MARK}${name}_BEGIN__`);\n if (begin < 0) return null;\n const start = text.indexOf('\\n', begin);\n const end = text.indexOf(`${MARK}${name}_END__`, start);\n return text.slice(start + 1, end < 0 ? undefined : end);\n};\n\nconst fileState = (text: string, name: string): FileState => {\n const m = text.match(new RegExp(`${MARK}${name}__:(ok|missing|unknown)`));\n return (m?.[1] as FileState) || 'unknown';\n};\n\nexport function parseSeoProbeOutput(stdout: string): SeoProbe {\n const text = String(stdout || '');\n const html = between(text, 'HTML');\n const robotsText = between(text, 'ROBOTS');\n const files: SeoSiteFiles = { robots: fileState(text, 'ROBOTS_TXT'), sitemap: fileState(text, 'SITEMAP_XML') };\n if (robotsText !== null) {\n let star = false;\n let blocksAll = false;\n for (const raw of robotsText.split('\\n')) {\n const line = raw.replace(/#.*/, '').trim();\n const ua = line.match(/^user-agent:\\s*(.+)$/i);\n if (ua) star = ua[1].trim() === '*';\n else if (star && /^disallow:\\s*\\/\\s*$/i.test(line)) blocksAll = true;\n }\n files.robotsBlocksAll = blocksAll;\n files.robotsListsSitemap = /^\\s*sitemap:\\s*\\S+/im.test(robotsText);\n }\n const sourceImages: SeoImage[] = [];\n for (const line of (between(text, 'IMG') || '').split('\\n')) {\n const m = line.match(/^(.+?):(\\d+):(<img[\\s\\S]*)$/i);\n if (!m) continue;\n const a = parseAttrs(m[3]);\n sourceImages.push({ src: a.src || '', alt: 'alt' in a ? a.alt : null, where: `${m[1]}:${m[2]}` });\n }\n return { html: html && html.trim() ? html : null, files, sourceImages, facts: parseFacts(text) };\n}\n\nfunction parseFacts(text: string): SeoSiteFacts {\n const raw = new Map<string, string>();\n for (const m of text.matchAll(new RegExp(`${MARK}FACT__:([a-zA-Z]+)=(\\\\d+)`, 'g'))) raw.set(m[1], m[2]);\n const flag = (k: string): boolean | null => (raw.has(k) ? raw.get(k) === '1' : null);\n const n = raw.has('pageCount') ? Number(raw.get('pageCount')) : NaN;\n return {\n structuredData: flag('structuredData'),\n faq: flag('faq'),\n blog: flag('blog'),\n contact: flag('contact'),\n testimonials: flag('testimonials'),\n pageCount: Number.isFinite(n) && n >= 0 ? n : null,\n };\n}\n\n// ---------------------------------------------------------------- growth ideas\n\nexport interface SeoOpportunity {\n /** \"structured-data\", \"faq\"...; set aside as `opp:<id>`. */\n id: string;\n title: string;\n why: string;\n /** The Build turn behind \"Work on this\". */\n work: string;\n}\n\nconst KEEP_FACTS = 'Use only facts already on the site; ask me for anything you do not have instead of inventing it.';\n\n/** Ideas that bring more people from search and turn more of them into customers, from what the site lacks. */\nexport function seoOpportunities(page: SeoPage | null, facts: SeoSiteFacts | null | undefined): SeoOpportunity[] {\n if (!facts) return [];\n const out: SeoOpportunity[] = [];\n if (!page?.hasJsonLd && facts.structuredData === false) {\n out.push({\n id: 'structured-data',\n title: 'Help search engines show your business details',\n why: 'Structured data (name, logo, contact, opening hours) lets search engines show rich results beside your link.',\n work: `Add JSON-LD structured data for this business (Organization or LocalBusiness: name, logo, url, contact details, and address and opening hours if the site shows them) to the page head. ${KEEP_FACTS}`,\n });\n }\n if (facts.pageCount !== null && facts.pageCount <= 2) {\n out.push({\n id: 'pages',\n title: 'Give each service or product its own page',\n why: 'One page can only rank for a few searches. A page per offer can rank for each of them.',\n work: `Create a dedicated page for each main service or product the site describes, each with its own title, meta description and heading, linked from the navigation and listed in the sitemap. ${KEEP_FACTS}`,\n });\n }\n if (facts.faq === false) {\n out.push({\n id: 'faq',\n title: 'Answer the questions customers ask',\n why: 'People search in questions. An FAQ answers them on your site and can appear directly in search results.',\n work: `Add an FAQ section with 5 to 8 questions and answers drawn from the site's own content, marked up with FAQPage structured data. ${KEEP_FACTS}`,\n });\n }\n if (facts.blog === false) {\n out.push({\n id: 'blog',\n title: 'Start a blog or guides section',\n why: 'Helpful articles bring visitors from searches your main pages do not cover, and give people a reason to come back.',\n work: `Add a blog (or guides) section: an index page and two starter articles on topics this site's customers search for, linked from the navigation and listed in the sitemap. ${KEEP_FACTS}`,\n });\n }\n if (facts.contact === false) {\n out.push({\n id: 'contact',\n title: 'Make it easy to reach you',\n why: 'Visitors who cannot find a phone number or email leave. Search engines also trust sites that show how to reach them.',\n work: `Add a contact section or page (email, phone and address if known), linked from the footer of every page. ${KEEP_FACTS}`,\n });\n }\n if (facts.testimonials === false) {\n out.push({\n id: 'testimonials',\n title: 'Show what customers say',\n why: 'Reviews and quotes from real customers turn more visitors into customers.',\n work: 'Add a testimonials section designed for real customer quotes, with clearly marked placeholders for me to fill in. Never invent names or quotes presented as real.',\n });\n }\n return out;\n}\n\n/** \"Find more ideas with AI\": a Chat-mode question, advice only. */\nexport function moreOpportunitiesText(\n siteUrl: string | null,\n known: ReadonlyArray<Pick<SeoOpportunity, 'title'>>,\n): string {\n const skip = known.length\n ? ` Leave out what is already on this list: ${known.map((o) => o.title).join('; ')}.`\n : '';\n return `Look at my site${siteUrl ? ` (${siteUrl})` : ''} and its pages, and suggest 3 to 5 specific changes most likely to bring more visitors from search or turn more of them into customers. For each, say what to change on which page and why.${skip} Suggest only; do not change the site yet. Then ask me which ones to work on.`;\n}\n\n// ---------------------------------------------------------------- checks\n\nconst TEMPLATE_TITLE_RE = /^(vite \\+ react(?: \\+ ts)?|vite app|react app|create next app|untitled|document|my app)$/i;\nconst isTemplateTitle = (title: string) => TEMPLATE_TITLE_RE.test(title) || BUILDER_DEFAULT_TITLE_RE.test(title);\n\nconst quote = (s: string, max = 90) => `\"${s.length > max ? `${s.slice(0, max - 1)}…` : s}\"`;\n\nconst INDEX_FILE = 'the page head (index.html, or the root layout metadata in a Next.js app)';\n\nexport function seoChecks(page: SeoPage, files: SeoSiteFiles, sourceImages: SeoImage[] = []): SeoCheck[] {\n const checks: SeoCheck[] = [];\n const add = (c: SeoCheck) => checks.push(c);\n\n const whyTitle = 'The title is the blue headline in Google results and the name on browser tabs.';\n if (!page.title) {\n add({\n id: 'title',\n ok: false,\n severity: 'warning',\n title: 'The page has no title',\n why: whyTitle,\n fix: `Add a descriptive <title> (the site name and what it offers, under ${SEO_LIMITS.title} characters) to ${INDEX_FILE}.`,\n });\n } else if (isTemplateTitle(page.title)) {\n add({\n id: 'title',\n ok: false,\n severity: 'warning',\n title: 'The title is still the template default',\n detail: quote(page.title),\n why: whyTitle,\n fix: `Replace the template <title> with the name of this site and what it offers (under ${SEO_LIMITS.title} characters).`,\n });\n } else if (page.title.length > SEO_LIMITS.title) {\n add({\n id: 'title',\n ok: false,\n severity: 'info',\n title: `The title is too long (${page.title.length} characters)`,\n detail: `Google cuts titles after about ${SEO_LIMITS.title} characters. ${quote(page.title)}`,\n why: whyTitle,\n fix: `Shorten the page <title> to under ${SEO_LIMITS.title} characters, keeping the site name and main keyword. Current title: ${quote(page.title, 200)}`,\n });\n } else if (page.title.length < SEO_LIMITS.titleMin) {\n add({\n id: 'title',\n ok: false,\n severity: 'info',\n title: 'The title is very short',\n detail: quote(page.title),\n why: whyTitle,\n fix: `Make the page <title> more descriptive: the site name plus what it offers (${SEO_LIMITS.titleMin}–${SEO_LIMITS.title} characters).`,\n });\n } else {\n add({ id: 'title', ok: true, severity: 'info', title: 'Page title', detail: quote(page.title), why: whyTitle });\n }\n\n const whyDesc = 'Google shows the description under your title. A clear one gets more people to click.';\n if (!page.description) {\n add({\n id: 'description',\n ok: false,\n severity: 'warning',\n title: 'No search description',\n why: whyDesc,\n fix: `Add <meta name=\"description\" content=\"…\"> with one or two sentences about the site (${SEO_LIMITS.descriptionMin}–${SEO_LIMITS.description} characters) to ${INDEX_FILE}.`,\n });\n } else if (page.description.length > SEO_LIMITS.description) {\n add({\n id: 'description',\n ok: false,\n severity: 'info',\n title: `The search description is too long (${page.description.length} characters)`,\n detail: `Google cuts it after about ${SEO_LIMITS.description} characters.`,\n why: whyDesc,\n fix: `Shorten the meta description to under ${SEO_LIMITS.description} characters, keeping the most important point first.`,\n });\n } else if (page.description.length < SEO_LIMITS.descriptionMin) {\n add({\n id: 'description',\n ok: false,\n severity: 'info',\n title: 'The search description is very short',\n detail: quote(page.description),\n why: whyDesc,\n fix: `Expand the meta description to one or two full sentences (${SEO_LIMITS.descriptionMin}–${SEO_LIMITS.description} characters) about what the site offers.`,\n });\n } else {\n add({ id: 'description', ok: true, severity: 'info', title: 'Search description', why: whyDesc });\n }\n\n const whyShare = 'Links shared on X, LinkedIn, Facebook and in chats use these tags for the card.';\n const ogMissing = (['title', 'description', 'image'] as const).filter((k) => !page.og[k]);\n if (ogMissing.length) {\n add({\n id: 'og',\n ok: false,\n severity: ogMissing.includes('image') ? 'warning' : 'info',\n title: ogMissing.includes('image') ? 'No image for shared links' : 'Social share tags are incomplete',\n detail: `Missing: ${ogMissing.map((k) => `og:${k}`).join(', ')}.`,\n why: whyShare,\n fix: `Add the missing Open Graph tags (${ogMissing.map((k) => `og:${k}`).join(', ')}) to ${INDEX_FILE}. og:image must be an absolute https URL of a 1200×630 image that represents the site.`,\n });\n } else if (!/^https?:\\/\\//i.test(page.og.image || '')) {\n add({\n id: 'og',\n ok: false,\n severity: 'warning',\n title: 'The share image address is not a full URL',\n detail: quote(page.og.image || ''),\n why: 'Social sites only load share images from a full https:// address.',\n fix: 'Make og:image (and twitter:image) an absolute https:// URL, using the published site address.',\n });\n } else {\n add({ id: 'og', ok: true, severity: 'info', title: 'Social share tags', why: whyShare });\n }\n\n const longSocial =\n (page.og.title && page.og.title.length > SEO_LIMITS.socialTitle) ||\n (page.og.description && page.og.description.length > SEO_LIMITS.socialDescription);\n if (longSocial) {\n add({\n id: 'og-length',\n ok: false,\n severity: 'info',\n title: 'Share title or description gets cut off',\n detail: `Keep og:title under ${SEO_LIMITS.socialTitle} and og:description under ${SEO_LIMITS.socialDescription} characters.`,\n why: whyShare,\n fix: `Shorten og:title to under ${SEO_LIMITS.socialTitle} characters and og:description to under ${SEO_LIMITS.socialDescription} characters.`,\n });\n }\n\n const whyTwitter = 'X uses twitter:card to decide between a large image card and a small link.';\n if (!page.twitter.card) {\n add({\n id: 'twitter',\n ok: false,\n severity: 'info',\n title: 'No X (Twitter) card tag',\n why: whyTwitter,\n fix: `Add <meta name=\"twitter:card\" content=\"summary_large_image\"> (plus twitter:title, twitter:description and twitter:image) to ${INDEX_FILE}.`,\n });\n } else {\n add({ id: 'twitter', ok: true, severity: 'info', title: 'X (Twitter) card', why: whyTwitter });\n }\n\n const whyIcon = 'The icon shows on tabs, bookmarks and next to your site in Google results.';\n if (!page.favicon) {\n add({\n id: 'favicon',\n ok: false,\n severity: 'warning',\n title: 'No browser tab icon',\n why: whyIcon,\n fix: 'Add a favicon for this site (for example public/favicon.svg) and <link rel=\"icon\" href=\"/favicon.svg\"> in the page head.',\n });\n } else if (/(^|\\/)vite\\.svg$/i.test(page.favicon)) {\n add({\n id: 'favicon',\n ok: false,\n severity: 'warning',\n title: 'The tab icon is still the Vite logo',\n why: whyIcon,\n fix: 'Replace /vite.svg with an icon made for this site and update <link rel=\"icon\">.',\n });\n } else {\n add({ id: 'favicon', ok: true, severity: 'info', title: 'Browser tab icon', why: whyIcon });\n }\n\n const whyLang =\n 'The page language helps search engines and screen readers. Without it, voices can read the wrong language.';\n add(\n page.lang\n ? { id: 'lang', ok: true, severity: 'info', title: `Page language: ${page.lang}`, why: whyLang }\n : {\n id: 'lang',\n ok: false,\n severity: 'info',\n title: 'The page language is not set',\n why: whyLang,\n fix: 'Set the lang attribute on the <html> element (for example <html lang=\"en\">) to the language of the site.',\n },\n );\n\n const whyCanonical = 'A canonical link tells Google which address is the real one, so duplicates do not compete.';\n add(\n page.canonical\n ? { id: 'canonical', ok: true, severity: 'info', title: 'Canonical link', why: whyCanonical }\n : {\n id: 'canonical',\n ok: false,\n severity: 'info',\n title: 'No canonical link',\n why: whyCanonical,\n fix: 'Add <link rel=\"canonical\" href=\"…\"> with the published address of each page.',\n },\n );\n\n const whyRobots = 'robots.txt tells search engines what they may crawl and where the sitemap is.';\n if (files.robots === 'missing') {\n add({\n id: 'robots',\n ok: false,\n severity: 'info',\n title: 'No robots.txt',\n why: whyRobots,\n fix: 'Add a robots.txt (public/robots.txt) that allows crawling and lists the sitemap: \"User-agent: *\", \"Allow: /\" and \"Sitemap: https://<site>/sitemap.xml\".',\n });\n } else if (files.robotsBlocksAll || /noindex/i.test(page.robotsMeta || '')) {\n add({\n id: 'robots',\n ok: false,\n severity: 'warning',\n title: 'Search engines are told not to index the site',\n detail: files.robotsBlocksAll ? 'robots.txt disallows everything.' : `robots meta: ${page.robotsMeta}`,\n why: 'The site will not show up in Google while this is set.',\n fix: 'Allow search engines to index the site: remove \"Disallow: /\" for all user agents from robots.txt and any noindex robots meta tag, unless the site is meant to stay private.',\n });\n } else if (files.robots === 'ok') {\n add({ id: 'robots', ok: true, severity: 'info', title: 'robots.txt', why: whyRobots });\n }\n\n const whySitemap = 'A sitemap lists every page so search engines find them all quickly.';\n if (files.sitemap === 'missing') {\n add({\n id: 'sitemap',\n ok: false,\n severity: 'info',\n title: 'No sitemap.xml',\n why: whySitemap,\n fix: 'Add a sitemap.xml that lists every page of the site with its published URL, and reference it from robots.txt.',\n });\n } else if (files.sitemap === 'ok') {\n add({ id: 'sitemap', ok: true, severity: 'info', title: 'sitemap.xml', why: whySitemap });\n }\n\n const images = [...page.images, ...sourceImages];\n const noAlt = images.filter((i) => i.alt === null);\n const whyAlt = 'Alt text describes images to blind visitors and to search engines.';\n if (noAlt.length) {\n const where = noAlt\n .slice(0, 5)\n .map((i) => (i.where && i.where !== 'page' ? i.where : i.src || 'an image'))\n .join(', ');\n add({\n id: 'alt',\n ok: false,\n severity: 'warning',\n title: `${noAlt.length} image${noAlt.length === 1 ? ' has' : 's have'} no alt text`,\n detail: `${where}${noAlt.length > 5 ? ', …' : ''}`,\n why: whyAlt,\n fix: 'Add a short, descriptive alt attribute to every <img> that has none (alt=\"\" only for purely decorative images).',\n });\n } else if (images.length) {\n add({ id: 'alt', ok: true, severity: 'info', title: 'Images have alt text', why: whyAlt });\n }\n\n return checks;\n}\n\n/** The edit turn \"Fix with AI\" sends for one SEO issue. */\nexport function seoFixText(check: SeoCheck): string {\n return [`Improve the site's SEO before I publish: ${check.title}.`, check.fix || ''].filter(Boolean).join('\\n');\n}\n\n/** One request for every open SEO issue. */\nexport function seoFixAllText(checks: SeoCheck[]): string | null {\n const open = checks.filter((c) => !c.ok && c.fix);\n if (!open.length) return null;\n return [\"Improve the site's SEO before I publish. Fix each of these:\", ...open.map((c) => `- ${c.fix}`)].join('\\n');\n}\n\n// ---------------------------------------------------------------- previews\n\nexport interface CardPreview {\n host: string;\n /** Breadcrumb-style address under the site name (Google). */\n path: string;\n siteName: string;\n title: string;\n description: string;\n image?: string;\n favicon?: string;\n /** The title or description is longer than this card shows. */\n cut: boolean;\n /** Nothing in the page names it: the card falls back to the address. */\n fallback: boolean;\n}\n\nexport type CardKind = 'google' | 'x' | 'facebook';\n\nconst CARD_LIMITS: Record<CardKind, { title: number; description: number }> = {\n google: { title: SEO_LIMITS.title, description: SEO_LIMITS.description },\n x: { title: SEO_LIMITS.socialTitle, description: SEO_LIMITS.socialDescription },\n facebook: { title: 88, description: SEO_LIMITS.socialDescription },\n};\n\nexport function truncate(s: string, max: number): string {\n if (s.length <= max) return s;\n const cut = s.slice(0, max - 1);\n const space = cut.lastIndexOf(' ');\n return `${(space > max * 0.6 ? cut.slice(0, space) : cut).trimEnd()}…`;\n}\n\nexport function absoluteUrl(raw: string | undefined, base: string | null | undefined): string | undefined {\n if (!raw) return undefined;\n try {\n const u = new URL(raw, base || undefined);\n return /^https?:$/.test(u.protocol) ? u.toString() : undefined;\n } catch {\n return undefined;\n }\n}\n\nfunction hostOf(url: string | null | undefined): string {\n try {\n return url ? new URL(url).host.replace(/^www\\./, '') : '';\n } catch {\n return '';\n }\n}\n\nexport function cardPreview(kind: CardKind, page: SeoPage, siteUrl: string | null | undefined): CardPreview {\n const host = hostOf(page.canonical) || hostOf(page.og.url) || hostOf(siteUrl) || 'your-site.yarntra.com';\n const social = kind !== 'google';\n const rawTitle =\n (social ? (kind === 'x' ? page.twitter.title : undefined) || page.og.title : undefined) || page.title || '';\n const rawDesc =\n (social ? (kind === 'x' ? page.twitter.description : undefined) || page.og.description : undefined) ||\n page.description ||\n '';\n const limits = CARD_LIMITS[kind];\n const imageRaw = social ? (kind === 'x' ? page.twitter.image || page.og.image : page.og.image) : undefined;\n let path = host;\n try {\n const p = new URL(page.canonical || siteUrl || `https://${host}`).pathname.replace(/\\/$/, '');\n if (p) path = `${host} › ${p.split('/').filter(Boolean).join(' › ')}`;\n } catch {\n /* keep the host */\n }\n return {\n host,\n path,\n siteName: page.og.siteName || page.title?.split(/\\s[|–—-]\\s/)[0] || host,\n title: truncate(rawTitle || host, limits.title),\n description: truncate(rawDesc, limits.description),\n image: absoluteUrl(imageRaw, siteUrl),\n favicon: absoluteUrl(page.favicon, siteUrl),\n cut: rawTitle.length > limits.title || rawDesc.length > limits.description,\n fallback: !rawTitle,\n };\n}\n"],"names":[],"mappings":"AAgFA,MAAM,iBAAiB,CAAC,CAAA,KAAsB,CAAE,CAAA,OAAA,CAAQ,YAAY,GAAG,CAAA,CAAE,OAAQ,CAAA,UAAA,EAAY,GAAG,CAAE,CAAA,OAAA,CAAQ,kBAAkB,GAAG,CAAA,CAAE,QAAQ,WAAa,EAAA,CAAC,CAAG,EAAA,CAAA,KAAM,OAAO,aAAc,CAAA,MAAA,CAAO,CAAC,CAAC,CAAC,CAAE,CAAA,OAAA,CAAQ,QAAU,EAAA,GAAG,EAAE,OAAQ,CAAA,QAAA,EAAU,GAAG,CAAE,CAAA,OAAA,CAAQ,WAAW,GAAG,CAAA;AAG9P,SAAS,WAAW,GAAqC,EAAA;AAnFhE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAoFE,EAAA,MAAM,MAA8B,EAAC;AACrC,EAAA,MAAM,EAAK,GAAA,+FAAA;AACX,EAAM,MAAA,IAAA,GAAO,IAAI,OAAQ,CAAA,4BAAA,EAA8B,EAAE,CAAE,CAAA,OAAA,CAAQ,SAAS,EAAE,CAAA;AAC9E,EAAA,KAAA,MAAW,CAAK,IAAA,IAAA,CAAK,QAAS,CAAA,EAAE,CAAG,EAAA;AACjC,IAAA,MAAM,IAAO,GAAA,CAAA,CAAE,CAAC,CAAA,CAAE,WAAY,EAAA;AAC9B,IAAA,IAAI,QAAQ,GAAK,EAAA;AACjB,IAAM,MAAA,GAAA,GAAA,CAAM,mBAAE,CAAC,CAAA,KAAH,YAAQ,CAAE,CAAA,CAAC,MAAX,IAAgB,GAAA,EAAA,GAAA,CAAA,CAAE,CAAC,CAAnB,KAAA,IAAA,GAAA,EAAA,GAAyB,EAAE,CAAC,CA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8L,IAAI,CAAA,6EAAA,CAAA;AAC3P"}
@@ -29,14 +29,37 @@ const time = (v) => {
29
29
  return s && !Number.isNaN(Date.parse(s)) ? s : void 0;
30
30
  };
31
31
  const list = (v) => Array.isArray(v) ? v.map(rec) : [];
32
- const ALERT_KINDS = ["down", "recovered", "cert", "errors", "perf"];
32
+ const ALERT_KINDS = ["down", "recovered", "cert", "errors", "perf", "security"];
33
33
  const ALERT_LABELS = {
34
34
  down: "Site goes down",
35
35
  recovered: "Site is back up",
36
36
  cert: "Certificate about to expire",
37
37
  errors: "New or spiking errors",
38
- perf: "Performance drops"
38
+ perf: "Performance drops",
39
+ security: "A secret key shows on the live site"
39
40
  };
41
+ function parseSiteSecurity(raw) {
42
+ var _a, _b;
43
+ const r = rec(raw);
44
+ const checkedAt = time(r.checkedAt);
45
+ if (!checkedAt) return null;
46
+ const findings = list(r.findings).map((f) => ({
47
+ kind: str(f.kind, 60) || "",
48
+ file: str(f.file, 200) || "/",
49
+ masked: str(f.masked, 40) || ""
50
+ })).filter((f) => f.kind && f.masked).slice(0, 20);
51
+ return {
52
+ checkedAt,
53
+ findings,
54
+ scanned: Math.max(0, Math.round((_a = num(r.scanned)) != null ? _a : 0)),
55
+ error: (_b = str(r.error, 200)) != null ? _b : null
56
+ };
57
+ }
58
+ function exposedKeysFixText(findings) {
59
+ if (!findings.length) return null;
60
+ const where = findings.map((f) => `${f.kind} in ${f.file} (starts ${f.masked})`).join("; ");
61
+ return `Visitors can read these secret keys in the published site's code: ${where}. Remove each from the client code and move whatever uses it to a server-side function that reads the key from the app secrets. Then tell me which keys to replace with their provider, since they were public. Do not publish yet.`;
62
+ }
40
63
  function parseAlertSettings(raw) {
41
64
  const r = rec(raw);
42
65
  const kinds = rec(r.kinds);
@@ -187,6 +210,7 @@ function parseHealth(r) {
187
210
  }), str(cert.issuer, 200) ? {
188
211
  issuer: str(cert.issuer, 200)
189
212
  } : {}) : null,
213
+ security: parseSiteSecurity(r.security),
190
214
  alerts: parseAlertSettings(r.alerts),
191
215
  monitoringActive: r.monitoringActive !== false
192
216
  };
@@ -494,4 +518,4 @@ ${clip(fix.message, 1500)}`;
494
518
 
495
519
  [Error stack]
496
520
  ${clip(fix.stack, 2e3)}` : text;
497
- }export{ALERT_KINDS,ALERT_LABELS,ERROR_GROUP_RESOLVE_MUTATION,RATING_LABELS,SITE_HEALTH_QUERY,SITE_HEALTH_SETTINGS_MUTATION,VITAL_THRESHOLDS,certView,createSiteHealthService,downBannerText,errorRows,fixErrorFromGroup,fixTurnText,formatDuration,formatUptime,formatVital,healthPill,hostOf,incidentLine,loadSiteHealth,parseAlertSettings,parseHealth,parseSiteHealth,relativeTime,uptimeCards,uptimeTone,vitalPlain,vitalRating,withAlert};//# sourceMappingURL=siteHealth.js.map
521
+ }export{ALERT_KINDS,ALERT_LABELS,ERROR_GROUP_RESOLVE_MUTATION,RATING_LABELS,SITE_HEALTH_QUERY,SITE_HEALTH_SETTINGS_MUTATION,VITAL_THRESHOLDS,certView,createSiteHealthService,downBannerText,errorRows,exposedKeysFixText,fixErrorFromGroup,fixTurnText,formatDuration,formatUptime,formatVital,healthPill,hostOf,incidentLine,loadSiteHealth,parseAlertSettings,parseHealth,parseSiteHealth,parseSiteSecurity,relativeTime,uptimeCards,uptimeTone,vitalPlain,vitalRating,withAlert};//# sourceMappingURL=siteHealth.js.map