@adminide-stack/yantra-mobile 12.0.166 → 12.0.167
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/kinds/character.webp +0 -0
- package/lib/assets/kinds/image.webp +0 -0
- package/lib/assets/kinds/video.webp +0 -0
- package/lib/assets/kinds/website.webp +0 -0
- package/lib/bridge/handlers/NavigationBridgeHandler.js +3 -2
- package/lib/bridge/handlers/NavigationBridgeHandler.js.map +1 -1
- package/lib/components/CustomDrawer.js +6 -2
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +17 -3
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/chat/ApprovalCard.js +8 -2
- package/lib/features/chat/ApprovalCard.js.map +1 -1
- package/lib/features/chat/AskUserCard.js +5 -3
- package/lib/features/chat/AskUserCard.js.map +1 -1
- package/lib/features/chat/ComposerModeSwitch.js +147 -0
- package/lib/features/chat/ComposerModeSwitch.js.map +1 -0
- package/lib/features/templates/__tests__/buildKinds.test.ts +54 -0
- package/lib/features/templates/__tests__/buildTemplateCards.test.ts +58 -6
- package/lib/features/templates/__tests__/templateSuggestion.test.ts +30 -0
- package/lib/features/templates/buildKinds.js +114 -0
- package/lib/features/templates/buildKinds.js.map +1 -0
- package/lib/features/templates/buildKinds.ts +189 -0
- package/lib/features/templates/buildTemplateCards.js +63 -18
- package/lib/features/templates/buildTemplateCards.js.map +1 -1
- package/lib/features/templates/buildTemplateCards.ts +88 -18
- package/lib/features/templates/index.ts +2 -0
- package/lib/features/templates/templateSuggestion.js +34 -0
- package/lib/features/templates/templateSuggestion.js.map +1 -0
- package/lib/features/templates/templateSuggestion.ts +57 -0
- package/lib/features/webbuilder/WebBuilderExperience.js +188 -28
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/approvalsLink.js +6 -0
- package/lib/features/webbuilder/approvalsLink.js.map +1 -0
- package/lib/features/webbuilder/buildFragments.js +19 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/CloudSheet.js +18 -5
- package/lib/features/webbuilder/components/CloudSheet.js.map +1 -1
- package/lib/features/webbuilder/components/CodeView.js +7 -3
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/DomainFinder.js +263 -0
- package/lib/features/webbuilder/components/DomainFinder.js.map +1 -0
- package/lib/features/webbuilder/components/DraftsSheet.js +298 -0
- package/lib/features/webbuilder/components/DraftsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/ImageEditPanel.js +266 -0
- package/lib/features/webbuilder/components/ImageEditPanel.js.map +1 -0
- package/lib/features/webbuilder/components/MentionMenu.js +155 -0
- package/lib/features/webbuilder/components/MentionMenu.js.map +1 -0
- package/lib/features/webbuilder/components/NotesSheet.js +138 -0
- package/lib/features/webbuilder/components/NotesSheet.js.map +1 -0
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +17 -3
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +200 -15
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/ShareSheet.js +48 -6
- package/lib/features/webbuilder/components/ShareSheet.js.map +1 -1
- package/lib/features/webbuilder/components/SiteCopyProgress.js +169 -0
- package/lib/features/webbuilder/components/SiteCopyProgress.js.map +1 -0
- package/lib/features/webbuilder/components/SiteStatusSheet.js +145 -2
- package/lib/features/webbuilder/components/SiteStatusSheet.js.map +1 -1
- package/lib/features/webbuilder/drafts.js +167 -0
- package/lib/features/webbuilder/drafts.js.map +1 -0
- package/lib/features/webbuilder/maskPng.js +113 -0
- package/lib/features/webbuilder/maskPng.js.map +1 -0
- package/lib/features/webbuilder/previewProbe.js.map +1 -1
- package/lib/features/webbuilder/stepLabels.js +21 -1
- package/lib/features/webbuilder/stepLabels.js.map +1 -1
- package/lib/features/webbuilder/web/chat/mentions.js +106 -0
- package/lib/features/webbuilder/web/chat/mentions.js.map +1 -0
- package/lib/features/webbuilder/web/chat/siteCopy.js +121 -0
- package/lib/features/webbuilder/web/chat/siteCopy.js.map +1 -0
- package/lib/features/webbuilder/web/code/imageEdit.js +30 -0
- package/lib/features/webbuilder/web/code/imageEdit.js.map +1 -0
- package/lib/features/webbuilder/web/design/linkedDesign.js +26 -0
- package/lib/features/webbuilder/web/design/linkedDesign.js.map +1 -0
- package/lib/features/webbuilder/web/project/buildLink.js +3 -0
- package/lib/features/webbuilder/web/project/buildLink.js.map +1 -0
- package/lib/features/webbuilder/web/project/drafts.js +57 -0
- package/lib/features/webbuilder/web/project/drafts.js.map +1 -0
- package/lib/features/webbuilder/web/project/navHistory.js +7 -0
- package/lib/features/webbuilder/web/project/navHistory.js.map +1 -0
- package/lib/features/webbuilder/web/project/serverSettings.js +15 -4
- package/lib/features/webbuilder/web/project/serverSettings.js.map +1 -1
- package/lib/features/webbuilder/web/publish/domainShop.js +79 -0
- package/lib/features/webbuilder/web/publish/domainShop.js.map +1 -0
- package/lib/features/webbuilder/web/publish/publishRequest.js +11 -0
- package/lib/features/webbuilder/web/publish/publishRequest.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/freshness.js +13 -0
- package/lib/features/webbuilder/web/publish/review/freshness.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/ignores.js +94 -0
- package/lib/features/webbuilder/web/publish/review/ignores.js.map +1 -0
- package/lib/features/webbuilder/web/publish/review/seo.js +230 -0
- package/lib/features/webbuilder/web/publish/review/seo.js.map +1 -0
- package/lib/features/webbuilder/web/publish/siteHealth.js +27 -3
- package/lib/features/webbuilder/web/publish/siteHealth.js.map +1 -1
- package/lib/features/webbuilder/web/publish/siteInsights.js +120 -3
- package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -1
- package/lib/features/webbuilder/web/sharing/shareLink.js +9 -0
- package/lib/features/webbuilder/web/sharing/shareLink.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +1 -1
- package/lib/features/webbuilder/web/webServices.js.map +1 -1
- package/lib/hooks/useMarketplaceTemplateCards.js +3 -4
- package/lib/hooks/useMarketplaceTemplateCards.js.map +1 -1
- package/lib/hooks/useMarketplaceTemplateGroups.js +12 -5
- package/lib/hooks/useMarketplaceTemplateGroups.js.map +1 -1
- package/lib/hooks/useTemplatesResourceUri.js +12 -0
- package/lib/hooks/useTemplatesResourceUri.js.map +1 -0
- package/lib/screens/Chat/index.js +4 -22
- package/lib/screens/Chat/index.js.map +1 -1
- package/lib/screens/Home/HomeScreen.js +165 -179
- package/lib/screens/Home/HomeScreen.js.map +1 -1
- package/lib/screens/Home/components/BuildKindPicker.js +248 -0
- package/lib/screens/Home/components/BuildKindPicker.js.map +1 -0
- package/lib/screens/Home/components/BuildTemplatesSection.js +556 -117
- package/lib/screens/Home/components/BuildTemplatesSection.js.map +1 -1
- package/lib/screens/Home/components/KindThumb.js +444 -0
- package/lib/screens/Home/components/KindThumb.js.map +1 -0
- package/lib/screens/Home/components/TemplateSuggestionBanner.js +73 -0
- package/lib/screens/Home/components/TemplateSuggestionBanner.js.map +1 -0
- package/lib/screens/Home/components/buildTheme.js +68 -0
- package/lib/screens/Home/components/buildTheme.js.map +1 -0
- package/lib/screens/WebBuilder/index.js +11 -1
- package/lib/screens/WebBuilder/index.js.map +1 -1
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js +55 -0
- package/lib/screens/WebBuilder/nativeWebBuilderRedirect.js.map +1 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +4 -0
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +31 -4
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/screens/WebBuilderNative/webbuilderTransport.js +5 -5
- package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
- package/package.json +3 -3
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* without pulling in browser-only marketplace packages.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import { isKnownBuildGroup } from './buildKinds';
|
|
8
|
+
|
|
7
9
|
export type MarketplaceTemplateGroup = {
|
|
8
10
|
id: string;
|
|
9
11
|
label: string;
|
|
@@ -25,6 +27,15 @@ export type BuildTemplateCard = {
|
|
|
25
27
|
/** Stack hint (`vite-react` | `nextjs` | …) when present on the form/group. */
|
|
26
28
|
templateName?: string;
|
|
27
29
|
formTemplateId?: string;
|
|
30
|
+
/**
|
|
31
|
+
* `sandbox`: a live preview / deploy / snapshot to remix (the web's code-assistant grid).
|
|
32
|
+
* `prompt`: a form with only a brief (and maybe a cover) that seeds the composer - the web's
|
|
33
|
+
* example-prompt cards, which every design and generation group (Designs, Slides…) is made of.
|
|
34
|
+
*/
|
|
35
|
+
kind?: 'sandbox' | 'prompt';
|
|
36
|
+
figmaUrl?: string;
|
|
37
|
+
/** Agent skill hint: form first, template entry as the fallback. */
|
|
38
|
+
skill?: string;
|
|
28
39
|
};
|
|
29
40
|
|
|
30
41
|
function toNonEmptyString(value: unknown): string {
|
|
@@ -35,6 +46,9 @@ function isSettingsEntryDisabled(value: Record<string, unknown>): boolean {
|
|
|
35
46
|
return value.enabled === false || value.enabled === 'false' || value.enable === false || value.enable === 'false';
|
|
36
47
|
}
|
|
37
48
|
|
|
49
|
+
/** Groups whose name differs from their settings key (the web's useTemplates GROUP_LABELS). */
|
|
50
|
+
const GROUP_LABELS: Record<string, string> = { codeAssistant: 'Web Builder' };
|
|
51
|
+
|
|
38
52
|
function humanizeGroupKey(key: string): string {
|
|
39
53
|
const spaced = key
|
|
40
54
|
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
@@ -93,6 +107,10 @@ function payloadLooksLikeGroupContents(groupsMap: Record<string, unknown>): bool
|
|
|
93
107
|
value && typeof value === 'object' && !GRAFTED_NAMESPACE_KEYS.has(key) && key !== 'designSystems',
|
|
94
108
|
);
|
|
95
109
|
if (values.length === 0) return false;
|
|
110
|
+
// A map holding any group Build knows is the group map. Without this, a full-depth read of the
|
|
111
|
+
// same entry (useSkillTemplates) made marketplace groups look like templates, and Build kept
|
|
112
|
+
// only codeAssistant.
|
|
113
|
+
if (values.some(([key]) => isKnownBuildGroup(key))) return false;
|
|
96
114
|
const templateCount = values.filter(([, value]) => isTemplateShapedEntry(value as Record<string, unknown>)).length;
|
|
97
115
|
return templateCount > 0 && templateCount >= Math.ceil(values.length / 2);
|
|
98
116
|
}
|
|
@@ -108,10 +126,13 @@ export function extractMarketplaceTemplateGroups(payload: unknown): MarketplaceT
|
|
|
108
126
|
Object.entries(groupsMap).forEach(([groupKey, groupValue]) => {
|
|
109
127
|
if (!groupValue || typeof groupValue !== 'object') return;
|
|
110
128
|
if (groupKey === 'designSystems' || GRAFTED_NAMESPACE_KEYS.has(groupKey)) return;
|
|
111
|
-
|
|
129
|
+
// `aiTemplates` is the agent skill-template catalog (useSkillTemplates): no prompts or covers,
|
|
130
|
+
// so Build's gallery could only show it empty - the web's useTemplates leaves it out too.
|
|
131
|
+
if (groupKey === 'aiTemplates') return;
|
|
132
|
+
if (!isKnownBuildGroup(groupKey) && isTemplateShapedEntry(groupValue as Record<string, unknown>)) return;
|
|
112
133
|
groups.push({
|
|
113
134
|
id: groupKey,
|
|
114
|
-
label: humanizeGroupKey(groupKey),
|
|
135
|
+
label: GROUP_LABELS[groupKey] ?? humanizeGroupKey(groupKey),
|
|
115
136
|
description: toNonEmptyString((groupValue as Record<string, unknown>).description) || undefined,
|
|
116
137
|
category: 'Assistant',
|
|
117
138
|
});
|
|
@@ -161,7 +182,9 @@ function resolveCoverImageUrl(
|
|
|
161
182
|
}
|
|
162
183
|
|
|
163
184
|
function formHasOwnPreviewableUrl(form: Record<string, unknown>): boolean {
|
|
164
|
-
return Boolean(
|
|
185
|
+
return Boolean(
|
|
186
|
+
toNonEmptyString(form.previewUrl) || toNonEmptyString(form.deployUrl) || toNonEmptyString(form.figmaUrl),
|
|
187
|
+
);
|
|
165
188
|
}
|
|
166
189
|
|
|
167
190
|
function resolveSnapshotId(form: Record<string, unknown>, group?: Record<string, unknown>): string | undefined {
|
|
@@ -182,14 +205,20 @@ function resolveStackHint(form: Record<string, unknown>, group?: Record<string,
|
|
|
182
205
|
);
|
|
183
206
|
}
|
|
184
207
|
|
|
208
|
+
const sameText = (value?: string) => (value ?? '').trim().toLowerCase().replace(/\s+/g, ' ');
|
|
209
|
+
|
|
185
210
|
/**
|
|
186
|
-
* Map `marketplace.templates.<group>` →
|
|
211
|
+
* Map `marketplace.templates.<group>` → the gallery's cards, the web's two extractors merged
|
|
212
|
+
* (codeAssistantDefaultTemplates `extractGroupTemplateCards` + groupExamplePromptCards, then
|
|
213
|
+
* galleryTemplates `mergeGalleryTemplates`): sandbox cards first, each set by title; a prompt card
|
|
214
|
+
* published twice (same title and brief) once; tiles without a cover last.
|
|
187
215
|
*/
|
|
188
216
|
export function extractGroupTemplateCards(payload: unknown): BuildTemplateCard[] {
|
|
189
217
|
const groupObj = unwrapSettingsPayload(payload);
|
|
190
218
|
if (!groupObj) return [];
|
|
191
219
|
|
|
192
|
-
const
|
|
220
|
+
const sandbox: BuildTemplateCard[] = [];
|
|
221
|
+
const prompts: BuildTemplateCard[] = [];
|
|
193
222
|
|
|
194
223
|
Object.entries(groupObj).forEach(([templateKey, templateGroup]) => {
|
|
195
224
|
if (!templateGroup || typeof templateGroup !== 'object') return;
|
|
@@ -203,41 +232,82 @@ export function extractGroupTemplateCards(payload: unknown): BuildTemplateCard[]
|
|
|
203
232
|
if (!formRaw || typeof formRaw !== 'object') return;
|
|
204
233
|
const form = formRaw as Record<string, unknown>;
|
|
205
234
|
if (isSettingsEntryDisabled(form)) return;
|
|
206
|
-
if (!formHasOwnPreviewableUrl(form) && !resolveSnapshotId(form, group)) return;
|
|
207
235
|
|
|
208
236
|
const formTemplateId = toNonEmptyString(form.formTemplateId);
|
|
209
237
|
const ownTitle = toNonEmptyString(form.title);
|
|
210
238
|
const title = ownTitle || humanizeFormKey(formKey) || 'Untitled';
|
|
211
239
|
const id = formTemplateId || formKey;
|
|
240
|
+
const chatPrompt = toNonEmptyString(form.chatPrompt) || undefined;
|
|
241
|
+
const coverImageUrl = resolveCoverImageUrl(form, group);
|
|
242
|
+
const skill = toNonEmptyString(form.skill) || toNonEmptyString(group.skill) || undefined;
|
|
243
|
+
const snapshotId = resolveSnapshotId(form, group);
|
|
212
244
|
|
|
213
|
-
|
|
245
|
+
if (formHasOwnPreviewableUrl(form) || snapshotId) {
|
|
246
|
+
sandbox.push({
|
|
247
|
+
id,
|
|
248
|
+
title,
|
|
249
|
+
description: toNonEmptyString(form.description) || 'Yantra starter template',
|
|
250
|
+
category: toNonEmptyString(form.category) || undefined,
|
|
251
|
+
coverImageUrl,
|
|
252
|
+
previewUrl: resolveSettingsUrl(form, group, 'previewUrl'),
|
|
253
|
+
deployUrl: resolveSettingsUrl(form, group, 'deployUrl'),
|
|
254
|
+
figmaUrl: toNonEmptyString(form.figmaUrl) || undefined,
|
|
255
|
+
chatPrompt,
|
|
256
|
+
snapshotId,
|
|
257
|
+
templateKey,
|
|
258
|
+
templateName: resolveStackHint(form, group),
|
|
259
|
+
formTemplateId: formTemplateId || undefined,
|
|
260
|
+
kind: 'sandbox',
|
|
261
|
+
skill,
|
|
262
|
+
});
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// A prompt card needs at least a brief or a cover to be useful.
|
|
266
|
+
if (!chatPrompt && !coverImageUrl) return;
|
|
267
|
+
prompts.push({
|
|
214
268
|
id,
|
|
215
269
|
title,
|
|
216
|
-
description: toNonEmptyString(form.description)
|
|
270
|
+
description: toNonEmptyString(form.description),
|
|
217
271
|
category: toNonEmptyString(form.category) || undefined,
|
|
218
|
-
coverImageUrl
|
|
219
|
-
|
|
220
|
-
deployUrl: resolveSettingsUrl(form, group, 'deployUrl'),
|
|
221
|
-
chatPrompt: toNonEmptyString(form.chatPrompt) || undefined,
|
|
222
|
-
snapshotId: resolveSnapshotId(form, group),
|
|
272
|
+
coverImageUrl,
|
|
273
|
+
chatPrompt,
|
|
223
274
|
templateKey,
|
|
224
|
-
templateName: resolveStackHint(form, group),
|
|
225
275
|
formTemplateId: formTemplateId || undefined,
|
|
276
|
+
kind: 'prompt',
|
|
277
|
+
skill,
|
|
226
278
|
});
|
|
227
279
|
});
|
|
228
280
|
});
|
|
229
281
|
|
|
230
|
-
// Dedupe by preview/deploy URL
|
|
282
|
+
// Dedupe sandbox cards by preview/deploy URL - titled card wins.
|
|
231
283
|
const bestByUrl = new Map<string, BuildTemplateCard>();
|
|
232
|
-
for (const card of
|
|
233
|
-
const key = (card.previewUrl || card.deployUrl || card.snapshotId || card.id).toLowerCase();
|
|
284
|
+
for (const card of sandbox) {
|
|
285
|
+
const key = (card.previewUrl || card.deployUrl || card.figmaUrl || card.snapshotId || card.id).toLowerCase();
|
|
234
286
|
const existing = bestByUrl.get(key);
|
|
235
287
|
if (!existing || (card.title && card.title.length > (existing.title?.length ?? 0))) {
|
|
236
288
|
bestByUrl.set(key, card);
|
|
237
289
|
}
|
|
238
290
|
}
|
|
239
291
|
|
|
240
|
-
|
|
292
|
+
const byTitle = (a: BuildTemplateCard, b: BuildTemplateCard) => a.title.localeCompare(b.title);
|
|
293
|
+
const seen = new Set<string>();
|
|
294
|
+
const repeats = new Set<string>();
|
|
295
|
+
const merged: BuildTemplateCard[] = [];
|
|
296
|
+
for (const list of [[...bestByUrl.values()].sort(byTitle), prompts.sort(byTitle)]) {
|
|
297
|
+
for (const card of list) {
|
|
298
|
+
if (seen.has(card.id)) continue;
|
|
299
|
+
seen.add(card.id);
|
|
300
|
+
const repeat =
|
|
301
|
+
card.kind === 'prompt' && card.chatPrompt
|
|
302
|
+
? `${sameText(card.title)}\u0000${sameText(card.chatPrompt)}`
|
|
303
|
+
: null;
|
|
304
|
+
if (repeat && repeats.has(repeat)) continue;
|
|
305
|
+
if (repeat) repeats.add(repeat);
|
|
306
|
+
merged.push(card);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const pictured = (card: BuildTemplateCard) => Boolean(card.coverImageUrl);
|
|
310
|
+
return [...merged.filter(pictured), ...merged.filter((card) => !pictured(card))];
|
|
241
311
|
}
|
|
242
312
|
|
|
243
313
|
export function defaultCloneTemplateDescription(templateDetailTitle: string): string {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {CODE_ASSISTANT_GROUP}from'./buildKinds.js';const MIN_SCORE = 100;
|
|
2
|
+
const SUGGEST_MIN_QUERY = 5;
|
|
3
|
+
const SUGGEST_DEBOUNCE_MS = 500;
|
|
4
|
+
function suggestTemplateGroup(query, groups) {
|
|
5
|
+
var _a;
|
|
6
|
+
const normalized = query.toLowerCase().trim();
|
|
7
|
+
if (normalized.length < SUGGEST_MIN_QUERY || groups.length === 0) return null;
|
|
8
|
+
let best = null;
|
|
9
|
+
let bestConfidence = 0;
|
|
10
|
+
let bestScore = 0;
|
|
11
|
+
const consider = (group, confidence, score) => {
|
|
12
|
+
if (confidence > bestConfidence) {
|
|
13
|
+
bestConfidence = confidence;
|
|
14
|
+
bestScore = score;
|
|
15
|
+
best = group;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const words = normalized.split(/\s+/).filter((word) => word.length >= 3);
|
|
19
|
+
for (const group of groups) {
|
|
20
|
+
const name = group.id.toLowerCase();
|
|
21
|
+
if (name && normalized.includes(name)) {
|
|
22
|
+
const confidence = name.length / normalized.length;
|
|
23
|
+
consider(group, confidence, confidence * 1e3);
|
|
24
|
+
}
|
|
25
|
+
for (const word of words) {
|
|
26
|
+
if (name.includes(word)) {
|
|
27
|
+
const confidence = word.length / name.length * 0.5;
|
|
28
|
+
consider(group, confidence, confidence * 500);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (best && bestScore >= MIN_SCORE) return best;
|
|
33
|
+
return (_a = groups.find((group) => group.id === CODE_ASSISTANT_GROUP)) != null ? _a : groups[0];
|
|
34
|
+
}export{SUGGEST_DEBOUNCE_MS,SUGGEST_MIN_QUERY,suggestTemplateGroup};//# sourceMappingURL=templateSuggestion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templateSuggestion.js","sources":["../../../src/features/templates/templateSuggestion.ts"],"sourcesContent":["/**\n * Build mode's live template suggestion - the web's `matchQueryToTemplate` (utils/templateMatcher),\n * which the build machine runs 500ms after the draft stops changing, over the marketplace groups.\n * Groups carry no tags, so a group matches when the draft names it (\"…a web design for…\" reads\n * webDesign) or a word of the draft makes up enough of its key. Web's threshold (score 100) stands.\n *\n * When nothing matches, the web falls back to the first group the server lists, so \"create react app\"\n * read \"AI suggests: Audio Generation\" and was sent as an audio chat. Here the fallback is the Web\n * Builder (codeAssistant) when the workspace has it - what a plain build makes - else the first group.\n */\nimport type { MarketplaceTemplateGroup } from './buildTemplateCards';\nimport { CODE_ASSISTANT_GROUP } from './buildKinds';\n\nconst MIN_SCORE = 100;\n\n/** Drafts shorter than this are not analysed (the build machine's guard). */\nexport const SUGGEST_MIN_QUERY = 5;\n\n/** How long the draft must rest before it is analysed (the build machine's `after: 500`). */\nexport const SUGGEST_DEBOUNCE_MS = 500;\n\nexport function suggestTemplateGroup(\n query: string,\n groups: readonly MarketplaceTemplateGroup[],\n): MarketplaceTemplateGroup | null {\n const normalized = query.toLowerCase().trim();\n if (normalized.length < SUGGEST_MIN_QUERY || groups.length === 0) return null;\n\n let best: MarketplaceTemplateGroup | null = null;\n let bestConfidence = 0;\n let bestScore = 0;\n const consider = (group: MarketplaceTemplateGroup, confidence: number, score: number) => {\n if (confidence > bestConfidence) {\n bestConfidence = confidence;\n bestScore = score;\n best = group;\n }\n };\n\n const words = normalized.split(/\\s+/).filter((word) => word.length >= 3);\n for (const group of groups) {\n const name = group.id.toLowerCase();\n if (name && normalized.includes(name)) {\n const confidence = name.length / normalized.length;\n consider(group, confidence, confidence * 1000);\n }\n for (const word of words) {\n if (name.includes(word)) {\n const confidence = (word.length / name.length) * 0.5;\n consider(group, confidence, confidence * 500);\n }\n }\n }\n\n if (best && bestScore >= MIN_SCORE) return best;\n return groups.find((group) => group.id === CODE_ASSISTANT_GROUP) ?? groups[0];\n}\n"],"names":[],"mappings":"mDAYA,MAAM,SAAY,GAAA,GAAA;AAGX,MAAM,iBAAoB,GAAA;AAG1B,MAAM,mBAAsB,GAAA;AACnB,SAAA,oBAAA,CAAqB,OAAe,MAA8E,EAAA;AAnBlI,EAAA,IAAA,EAAA;AAoBE,EAAA,MAAM,UAAa,GAAA,KAAA,CAAM,WAAY,EAAA,CAAE,IAAK,EAAA;AAC5C,EAAA,IAAI,WAAW,MAAS,GAAA,iBAAA,IAAqB,MAAO,CAAA,MAAA,KAAW,GAAU,OAAA,IAAA;AACzE,EAAA,IAAI,IAAwC,GAAA,IAAA;AAC5C,EAAA,IAAI,cAAiB,GAAA,CAAA;AACrB,EAAA,IAAI,SAAY,GAAA,CAAA;AAChB,EAAA,MAAM,QAAW,GAAA,CAAC,KAAiC,EAAA,UAAA,EAAoB,KAAkB,KAAA;AACvF,IAAA,IAAI,aAAa,cAAgB,EAAA;AAC/B,MAAiB,cAAA,GAAA,UAAA;AACjB,MAAY,SAAA,GAAA,KAAA;AACZ,MAAO,IAAA,GAAA,KAAA;AAAA;AACT,GACF;AACA,EAAM,MAAA,KAAA,GAAQ,WAAW,KAAM,CAAA,KAAK,EAAE,MAAO,CAAA,CAAA,IAAA,KAAQ,IAAK,CAAA,MAAA,IAAU,CAAC,CAAA;AACrE,EAAA,KAAA,MAAW,SAAS,MAAQ,EAAA;AAC1B,IAAM,MAAA,IAAA,GAAO,KAAM,CAAA,EAAA,CAAG,WAAY,EAAA;AAClC,IAAA,IAAI,IAAQ,IAAA,UAAA,CAAW,QAAS,CAAA,IAAI,CAAG,EAAA;AACrC,MAAM,MAAA,UAAA,GAAa,IAAK,CAAA,MAAA,GAAS,UAAW,CAAA,MAAA;AAC5C,MAAS,QAAA,CAAA,KAAA,EAAO,UAAY,EAAA,UAAA,GAAa,GAAI,CAAA;AAAA;AAE/C,IAAA,KAAA,MAAW,QAAQ,KAAO,EAAA;AACxB,MAAI,IAAA,IAAA,CAAK,QAAS,CAAA,IAAI,CAAG,EAAA;AACvB,QAAA,MAAM,UAAa,GAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAK,MAAS,GAAA,GAAA;AAC/C,QAAS,QAAA,CAAA,KAAA,EAAO,UAAY,EAAA,UAAA,GAAa,GAAG,CAAA;AAAA;AAC9C;AACF;AAEF,EAAI,IAAA,IAAA,IAAQ,SAAa,IAAA,SAAA,EAAkB,OAAA,IAAA;AAC3C,EAAO,OAAA,CAAA,EAAA,GAAA,MAAA,CAAO,KAAK,CAAS,KAAA,KAAA,KAAA,CAAM,OAAO,oBAAoB,CAAA,KAAtD,IAA2D,GAAA,EAAA,GAAA,MAAA,CAAO,CAAC,CAAA;AAC5E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build mode's live template suggestion - the web's `matchQueryToTemplate` (utils/templateMatcher),
|
|
3
|
+
* which the build machine runs 500ms after the draft stops changing, over the marketplace groups.
|
|
4
|
+
* Groups carry no tags, so a group matches when the draft names it ("…a web design for…" reads
|
|
5
|
+
* webDesign) or a word of the draft makes up enough of its key. Web's threshold (score 100) stands.
|
|
6
|
+
*
|
|
7
|
+
* When nothing matches, the web falls back to the first group the server lists, so "create react app"
|
|
8
|
+
* read "AI suggests: Audio Generation" and was sent as an audio chat. Here the fallback is the Web
|
|
9
|
+
* Builder (codeAssistant) when the workspace has it - what a plain build makes - else the first group.
|
|
10
|
+
*/
|
|
11
|
+
import type { MarketplaceTemplateGroup } from './buildTemplateCards';
|
|
12
|
+
import { CODE_ASSISTANT_GROUP } from './buildKinds';
|
|
13
|
+
|
|
14
|
+
const MIN_SCORE = 100;
|
|
15
|
+
|
|
16
|
+
/** Drafts shorter than this are not analysed (the build machine's guard). */
|
|
17
|
+
export const SUGGEST_MIN_QUERY = 5;
|
|
18
|
+
|
|
19
|
+
/** How long the draft must rest before it is analysed (the build machine's `after: 500`). */
|
|
20
|
+
export const SUGGEST_DEBOUNCE_MS = 500;
|
|
21
|
+
|
|
22
|
+
export function suggestTemplateGroup(
|
|
23
|
+
query: string,
|
|
24
|
+
groups: readonly MarketplaceTemplateGroup[],
|
|
25
|
+
): MarketplaceTemplateGroup | null {
|
|
26
|
+
const normalized = query.toLowerCase().trim();
|
|
27
|
+
if (normalized.length < SUGGEST_MIN_QUERY || groups.length === 0) return null;
|
|
28
|
+
|
|
29
|
+
let best: MarketplaceTemplateGroup | null = null;
|
|
30
|
+
let bestConfidence = 0;
|
|
31
|
+
let bestScore = 0;
|
|
32
|
+
const consider = (group: MarketplaceTemplateGroup, confidence: number, score: number) => {
|
|
33
|
+
if (confidence > bestConfidence) {
|
|
34
|
+
bestConfidence = confidence;
|
|
35
|
+
bestScore = score;
|
|
36
|
+
best = group;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const words = normalized.split(/\s+/).filter((word) => word.length >= 3);
|
|
41
|
+
for (const group of groups) {
|
|
42
|
+
const name = group.id.toLowerCase();
|
|
43
|
+
if (name && normalized.includes(name)) {
|
|
44
|
+
const confidence = name.length / normalized.length;
|
|
45
|
+
consider(group, confidence, confidence * 1000);
|
|
46
|
+
}
|
|
47
|
+
for (const word of words) {
|
|
48
|
+
if (name.includes(word)) {
|
|
49
|
+
const confidence = (word.length / name.length) * 0.5;
|
|
50
|
+
consider(group, confidence, confidence * 500);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (best && bestScore >= MIN_SCORE) return best;
|
|
56
|
+
return groups.find((group) => group.id === CODE_ASSISTANT_GROUP) ?? groups[0];
|
|
57
|
+
}
|