@adminide-stack/yantra-mobile 12.0.148-alpha.0 → 12.0.149-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 (25) hide show
  1. package/lib/features/webbuilder/WebBuilderExperience.js +38 -56
  2. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  3. package/lib/features/webbuilder/buildFragments.js +4 -4
  4. package/lib/features/webbuilder/buildFragments.js.map +1 -1
  5. package/lib/features/webbuilder/components/PreviewScreen.js +28 -2
  6. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  7. package/lib/features/webbuilder/components/ProjectChat.js +190 -85
  8. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  9. package/lib/features/webbuilder/components/ProjectSheets.js +10 -4
  10. package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
  11. package/lib/features/webbuilder/components/PublishSheet.js +90 -14
  12. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  13. package/lib/features/webbuilder/components/ui.js +9 -2
  14. package/lib/features/webbuilder/components/ui.js.map +1 -1
  15. package/lib/features/webbuilder/followUps.js +19 -1
  16. package/lib/features/webbuilder/followUps.js.map +1 -1
  17. package/lib/features/webbuilder/webbuilderPrompts.js +3 -2
  18. package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
  19. package/lib/hooks/useChatApi.js +4 -3
  20. package/lib/hooks/useChatApi.js.map +1 -1
  21. package/lib/screens/WebBuilderNative/agentBusyRetry.js +24 -0
  22. package/lib/screens/WebBuilderNative/agentBusyRetry.js.map +1 -0
  23. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +166 -44
  24. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  25. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useState,useRef,useMemo,useEffect}from'react';import {StyleSheet,View,Text,ActivityIndicator,Image}from'react-native';import {WebView}from'react-native-webview';import {MaterialCommunityIcons}from'@expo/vector-icons';import {Tap,DIM}from'../../inbox/components/Tap.js';import {parseToolActivity}from'../../chat/toolActivity.js';import {friendlySteps}from'../stepLabels.js';import {publishEventText,withoutRestorePointLine,webbuilderAgentSuggestions}from'../webbuilderPrompts.js';import {sleepNoticeDue,minutesUntilSleep}from'../sleepNotice.js';import {followUpSuggestions}from'../followUps.js';import {AskUserCard}from'../../chat/AskUserCard.js';import {NativeAgentChat}from'../../agent-chat/NativeAgentChat.js';import {displayHost}from'../buildFragments.js';import {DESKTOP_VIEWPORT_SCRIPT}from'./PreviewFrame.js';import {PreviewPlaceholder}from'./PreviewPlaceholder.js';import {probePreview,mayFrame}from'../previewProbe.js';var __defProp = Object.defineProperty;
1
+ import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useState,useRef,useMemo,useEffect}from'react';import {StyleSheet,View,Text,ActivityIndicator,Image,Clipboard}from'react-native';import {WebView}from'react-native-webview';import {MaterialCommunityIcons}from'@expo/vector-icons';import {Tap,DIM}from'../../inbox/components/Tap.js';import {parseToolActivity}from'../../chat/toolActivity.js';import {friendlySteps}from'../stepLabels.js';import {withoutRestorePointLine,publishEventText,webbuilderAgentSuggestions}from'../webbuilderPrompts.js';import {sleepNoticeDue,minutesUntilSleep}from'../sleepNotice.js';import {followUpSuggestions,withoutNextSteps}from'../followUps.js';import {AskUserCard}from'../../chat/AskUserCard.js';import {NativeAgentChat}from'../../agent-chat/NativeAgentChat.js';import {displayHost}from'../buildFragments.js';import {DESKTOP_VIEWPORT_SCRIPT}from'./PreviewFrame.js';import {PreviewPlaceholder}from'./PreviewPlaceholder.js';import {probePreview,mayFrame}from'../previewProbe.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -49,11 +49,13 @@ function BuildingStatus({
49
49
  }], children: elapsedLabel(elapsed) }) : null
50
50
  ] });
51
51
  }
52
- function timeOf(ms) {
52
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
53
+ function dateOf(ms) {
53
54
  if (!ms) return "";
54
55
  const d = new Date(ms);
55
- return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
56
+ return `${MONTHS[d.getMonth()]} ${d.getDate()}`;
56
57
  }
58
+ const UNPUBLISHED_MARK = "#7cb35a";
57
59
  function SiteCard({
58
60
  build,
59
61
  title,
@@ -114,46 +116,71 @@ function SiteCard({
114
116
  live = false;
115
117
  };
116
118
  }, [url, cover, recheck]);
117
- const status = build.liveUrl ? `Live \xB7 ${displayHost(build.liveUrl)}` : `Not published \xB7 ${timeOf(build.updatedAt)}`;
119
+ const status = build.liveUrl ? `Live \u2022 ${displayHost(build.liveUrl)}` : `Not published \u2022 ${dateOf(build.updatedAt)}`;
120
+ const canPublish = Boolean(build.sandboxId);
118
121
  return /* @__PURE__ */ jsxs(View, { style: [styles.site, {
119
122
  backgroundColor: theme.card,
120
123
  borderColor: theme.border,
121
124
  shadowColor: theme.isDark ? "#000" : "#1c1917"
122
125
  }], children: [
123
- /* @__PURE__ */ jsxs(Tap, { onPress: onOpen, accessibilityRole: "button", accessibilityLabel: `Open ${title}`, style: styles.siteHead, pressedStyle: DIM, children: [
124
- /* @__PURE__ */ jsx(View, { style: [styles.siteGlobe, {
125
- backgroundColor: build.liveUrl ? theme.good : theme.accent
126
- }], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "web", size: 24, color: theme.accentInk }) }),
127
- /* @__PURE__ */ jsxs(View, { style: styles.siteHeadText, children: [
128
- /* @__PURE__ */ jsx(Text, { style: [styles.siteTitle, {
129
- color: theme.ink
130
- }], numberOfLines: 1, children: title }),
131
- /* @__PURE__ */ jsx(Text, { style: [styles.siteStatus, {
132
- color: theme.muted
133
- }], numberOfLines: 1, children: status })
126
+ /* @__PURE__ */ jsxs(View, { style: styles.siteHead, children: [
127
+ /* @__PURE__ */ jsxs(Tap, { onPress: onOpen, accessibilityRole: "button", accessibilityLabel: `Open ${title}`, style: styles.siteHeadMain, pressedStyle: DIM, children: [
128
+ /* @__PURE__ */ jsx(View, { style: [styles.siteMark, {
129
+ backgroundColor: build.liveUrl ? theme.good : UNPUBLISHED_MARK
130
+ }], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "check-bold", size: 22, color: "#ffffff" }) }),
131
+ /* @__PURE__ */ jsxs(View, { style: styles.siteHeadText, children: [
132
+ /* @__PURE__ */ jsx(Text, { style: [styles.siteTitle, {
133
+ color: theme.ink
134
+ }], numberOfLines: 1, children: title }),
135
+ /* @__PURE__ */ jsx(Text, { style: [styles.siteStatus, {
136
+ color: theme.muted
137
+ }], numberOfLines: 1, children: status })
138
+ ] })
139
+ ] }),
140
+ /* @__PURE__ */ jsxs(Tap, { onPress: onPublish, disabled: !canPublish, accessibilityRole: "button", accessibilityLabel: build.liveUrl ? "Publish the latest version" : "Publish", style: [styles.sitePublish, {
141
+ backgroundColor: theme.ink
142
+ }, !canPublish && styles.disabled], pressedStyle: DIM, testID: "webbuilder-card-publish", children: [
143
+ /* @__PURE__ */ jsx(Text, { style: [styles.sitePublishText, {
144
+ color: theme.card
145
+ }], children: "Publish" }),
146
+ !build.liveUrl && canPublish ? /* @__PURE__ */ jsx(View, { style: [styles.sitePublishDot, {
147
+ borderColor: theme.card
148
+ }] }) : null
134
149
  ] })
135
150
  ] }),
136
- /* @__PURE__ */ jsx(Tap, { onPress: onOpen, accessibilityRole: "button", accessibilityLabel: `Open the preview of ${title}`, children: /* @__PURE__ */ jsxs(View, { style: [styles.siteView, {
151
+ /* @__PURE__ */ jsx(Tap, { onPress: onOpen, accessibilityRole: "button", accessibilityLabel: `Open the preview of ${title}`, testID: "webbuilder-card-preview", children: /* @__PURE__ */ jsxs(View, { style: [styles.siteView, {
137
152
  backgroundColor: theme.stage,
138
153
  borderColor: theme.border
139
154
  }], pointerEvents: "none", children: [
140
- cover ? /* @__PURE__ */ jsx(Image, { source: {
141
- uri: cover
142
- }, style: styles.siteCover, resizeMode: "cover", onError: () => setCoverFailed(true), accessibilityIgnoresInvertColors: true }) : null,
143
- !cover && url && verified ? /* @__PURE__ */ jsx(WebView, { source: {
144
- uri: url
145
- }, style: [styles.siteWeb, !loaded && styles.hidden], scrollEnabled: false, javaScriptEnabled: true, domStorageEnabled: true, originWhitelist: ["*"], scalesPageToFit: true, injectedJavaScript: DESKTOP_VIEWPORT_SCRIPT, onLoadEnd: () => setLoaded(true), onHttpError: (event) => {
146
- if (event.nativeEvent.statusCode >= 500) setAsleep(true);
147
- }, onError: () => setAsleep(true) }, `${url}-${recheck}`) : null,
148
- !cover && (asleep || previewDown) ? /* @__PURE__ */ jsx(View, { style: [styles.siteLoading, {
149
- backgroundColor: theme.stage
150
- }], children: /* @__PURE__ */ jsx(PreviewPlaceholder, { theme, compact: true }) }) : null,
151
- !cover && !asleep && !previewDown && (!url || !loaded) ? /* @__PURE__ */ jsxs(View, { style: styles.siteLoading, children: [
152
- /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }),
153
- /* @__PURE__ */ jsx(Text, { style: [styles.siteLoadingText, {
154
- color: theme.muted
155
- }], children: "Loading preview\u2026" })
156
- ] }) : null,
155
+ /* @__PURE__ */ jsx(View, { style: [styles.siteBlob, styles.siteBlobTop, {
156
+ backgroundColor: theme.chip
157
+ }] }),
158
+ /* @__PURE__ */ jsx(View, { style: [styles.siteBlob, styles.siteBlobBottom, {
159
+ backgroundColor: theme.chip
160
+ }] }),
161
+ /* @__PURE__ */ jsxs(View, { style: [styles.sitePage, {
162
+ backgroundColor: theme.card,
163
+ borderColor: theme.border,
164
+ shadowColor: theme.isDark ? "#000" : "#1c1917"
165
+ }], children: [
166
+ cover ? /* @__PURE__ */ jsx(Image, { source: {
167
+ uri: cover
168
+ }, style: styles.siteCover, resizeMode: "cover", onError: () => setCoverFailed(true), accessibilityIgnoresInvertColors: true }) : null,
169
+ !cover && url && verified ? /* @__PURE__ */ jsx(WebView, { source: {
170
+ uri: url
171
+ }, style: [styles.siteWeb, !loaded && styles.hidden], scrollEnabled: false, javaScriptEnabled: true, domStorageEnabled: true, originWhitelist: ["*"], scalesPageToFit: true, injectedJavaScript: DESKTOP_VIEWPORT_SCRIPT, onLoadEnd: () => setLoaded(true), onHttpError: (event) => {
172
+ if (event.nativeEvent.statusCode >= 500) setAsleep(true);
173
+ }, onError: () => setAsleep(true) }, `${url}-${recheck}`) : null,
174
+ !cover && (asleep || previewDown) ? /* @__PURE__ */ jsx(View, { style: [styles.siteLoading, {
175
+ backgroundColor: theme.card
176
+ }], children: /* @__PURE__ */ jsx(PreviewPlaceholder, { theme, compact: true }) }) : null,
177
+ !cover && !asleep && !previewDown && (!url || !loaded) ? /* @__PURE__ */ jsxs(View, { style: styles.siteLoading, children: [
178
+ /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }),
179
+ /* @__PURE__ */ jsx(Text, { style: [styles.siteLoadingText, {
180
+ color: theme.muted
181
+ }], children: "Loading preview\u2026" })
182
+ ] }) : null
183
+ ] }),
157
184
  busy && (cover || loaded && !asleep) ? /* @__PURE__ */ jsxs(View, { style: [styles.siteBusy, {
158
185
  backgroundColor: theme.card
159
186
  }], children: [
@@ -174,21 +201,33 @@ function SiteCard({
174
201
  build.snapshotId ? "; a restore point is saved." : ".",
175
202
  " Publish to keep it online."
176
203
  ] })
177
- ] }) : null,
178
- /* @__PURE__ */ jsxs(View, { style: styles.siteFoot, children: [
179
- /* @__PURE__ */ jsx(Tap, { onPress: onOpen, accessibilityRole: "button", style: [styles.siteBtn, {
180
- backgroundColor: theme.chip
181
- }], pressedStyle: DIM, testID: "webbuilder-card-preview", children: /* @__PURE__ */ jsx(Text, { style: [styles.siteBtnText, {
182
- color: theme.ink
183
- }], children: "Preview" }) }),
184
- /* @__PURE__ */ jsx(Tap, { onPress: onPublish, disabled: !build.sandboxId, accessibilityRole: "button", style: [styles.siteBtn, {
185
- backgroundColor: theme.ink
186
- }, !build.sandboxId && styles.disabled], pressedStyle: DIM, testID: "webbuilder-card-publish", children: /* @__PURE__ */ jsx(Text, { style: [styles.siteBtnText, {
187
- color: theme.card
188
- }], children: "Publish" }) })
189
- ] })
204
+ ] }) : null
190
205
  ] });
191
206
  }
207
+ function SiteActions({
208
+ url,
209
+ theme
210
+ }) {
211
+ const [copied, setCopied] = useState(false);
212
+ useEffect(() => {
213
+ if (!copied) return void 0;
214
+ const timer = setTimeout(() => setCopied(false), 1800);
215
+ return () => clearTimeout(timer);
216
+ }, [copied]);
217
+ if (!url) return null;
218
+ return /* @__PURE__ */ jsx(View, { style: styles.siteActions, children: /* @__PURE__ */ jsxs(Tap, { onPress: () => {
219
+ try {
220
+ Clipboard.setString(url);
221
+ setCopied(true);
222
+ } catch (e) {
223
+ }
224
+ }, accessibilityRole: "button", accessibilityLabel: copied ? "Link copied" : "Copy the site link", style: styles.siteAction, pressedStyle: DIM, hitSlop: 8, testID: "webbuilder-card-copy", children: [
225
+ /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: copied ? "check" : "content-copy", size: 20, color: copied ? theme.good : theme.muted }),
226
+ copied ? /* @__PURE__ */ jsx(Text, { style: [styles.siteActionText, {
227
+ color: theme.good
228
+ }], children: "Copied" }) : null
229
+ ] }) });
230
+ }
192
231
  function emptyTitleFor(loading, hasBuild, siteTitle) {
193
232
  if (loading) return void 0;
194
233
  return hasBuild ? `What should change on ${siteTitle}?` : "Describe your idea";
@@ -224,6 +263,10 @@ function ProjectChat({
224
263
  const [top, setTop] = useState(0);
225
264
  const live = busy || Boolean(building);
226
265
  const loadingHistory = loading && messages.length === 0 && !live && !streaming;
266
+ const lastReply = messages[messages.length - 1];
267
+ const followUps = useMemo(() => (lastReply == null ? void 0 : lastReply.role) === "assistant" ? followUpSuggestions(withoutRestorePointLine(parseToolActivity(lastReply.content, false).text).text) : [], [lastReply]);
268
+ const chipsShown = followUps.length > 0 && !live;
269
+ const lastReplyId = (lastReply == null ? void 0 : lastReply.role) === "assistant" ? lastReply.id : null;
227
270
  const {
228
271
  shown,
229
272
  savedIds
@@ -241,19 +284,17 @@ function ProjectChat({
241
284
  text,
242
285
  saved: hadPoint
243
286
  } = withoutRestorePointLine(m.content);
244
- if (!hadPoint) return m;
245
- saved.add(m.id);
246
- return __spreadProps(__spreadValues({}, m), {
247
- content: text
287
+ const body = chipsShown && m.id === lastReplyId ? withoutNextSteps(text) : text;
288
+ if (hadPoint) saved.add(m.id);
289
+ return body === m.content ? m : __spreadProps(__spreadValues({}, m), {
290
+ content: body
248
291
  });
249
292
  });
250
293
  return {
251
294
  shown: out,
252
295
  savedIds: saved
253
296
  };
254
- }, [messages]);
255
- const lastReply = messages[messages.length - 1];
256
- const followUps = useMemo(() => (lastReply == null ? void 0 : lastReply.role) === "assistant" ? followUpSuggestions(withoutRestorePointLine(parseToolActivity(lastReply.content, false).text).text) : [], [lastReply]);
297
+ }, [messages, chipsShown, lastReplyId]);
257
298
  const renderExtras = (message) => {
258
299
  const chip = savedIds.has(message.id) ? /* @__PURE__ */ jsxs(View, { style: [styles.versionChip, {
259
300
  borderColor: theme.border,
@@ -280,6 +321,7 @@ function ProjectChat({
280
321
  };
281
322
  const footer = /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
282
323
  build ? /* @__PURE__ */ jsx(SiteCard, { build, title: siteTitle, busy: live, onOpen: onOpenPreview, onPublish, onAsleep: onPreviewAsleep, previewDown, theme }) : null,
324
+ build ? /* @__PURE__ */ jsx(SiteActions, { url: build.liveUrl || build.previewUrl, theme }) : null,
283
325
  live && !(streaming == null ? void 0 : streaming.trim()) ? /* @__PURE__ */ jsx(BuildingStatus, { building, theme }) : null,
284
326
  ask && onAnswerAsk && !dismissedAsks.includes(ask.requestId) ? /* @__PURE__ */ jsx(AskUserCard, { payload: ask, isDark: theme.isDark, onAnswer: (formatted) => {
285
327
  setDismissedAsks((prev) => [...prev, ask.requestId]);
@@ -456,44 +498,123 @@ const styles = StyleSheet.create({
456
498
  borderRadius: 22,
457
499
  borderWidth: StyleSheet.hairlineWidth,
458
500
  overflow: "hidden",
459
- shadowOpacity: 0.06,
460
- shadowRadius: 14,
501
+ shadowOpacity: 0.05,
502
+ shadowRadius: 12,
461
503
  shadowOffset: {
462
504
  width: 0,
463
- height: 4
505
+ height: 3
464
506
  },
465
507
  elevation: 2
466
508
  },
467
509
  siteHead: {
468
510
  flexDirection: "row",
469
511
  alignItems: "center",
470
- gap: 14,
471
- padding: 16
512
+ gap: 10,
513
+ paddingLeft: 14,
514
+ paddingRight: 12,
515
+ paddingVertical: 12
516
+ },
517
+ siteHeadMain: {
518
+ flex: 1,
519
+ flexDirection: "row",
520
+ alignItems: "center",
521
+ gap: 12,
522
+ minWidth: 0
472
523
  },
473
- siteGlobe: {
474
- width: 48,
475
- height: 48,
476
- borderRadius: 14,
524
+ siteMark: {
525
+ width: 40,
526
+ height: 40,
527
+ borderRadius: 11,
477
528
  alignItems: "center",
478
529
  justifyContent: "center"
479
530
  },
480
531
  siteHeadText: {
481
532
  flex: 1,
482
- gap: 2
533
+ gap: 1
483
534
  },
484
535
  siteTitle: {
485
- fontSize: 18,
486
- fontWeight: "700",
536
+ fontSize: 17,
537
+ fontWeight: "600",
487
538
  letterSpacing: -0.2
488
539
  },
489
540
  siteStatus: {
490
- fontSize: 14
541
+ fontSize: 13
542
+ },
543
+ sitePublish: {
544
+ height: 38,
545
+ paddingHorizontal: 16,
546
+ borderRadius: 12,
547
+ alignItems: "center",
548
+ justifyContent: "center"
549
+ },
550
+ sitePublishText: {
551
+ fontSize: 15,
552
+ fontWeight: "700"
553
+ },
554
+ sitePublishDot: {
555
+ position: "absolute",
556
+ top: -4,
557
+ right: -4,
558
+ width: 12,
559
+ height: 12,
560
+ borderRadius: 6,
561
+ borderWidth: 2,
562
+ backgroundColor: "#3b82f6"
491
563
  },
492
564
  siteView: {
493
- height: 240,
565
+ height: 220,
494
566
  borderTopWidth: StyleSheet.hairlineWidth,
495
- borderBottomWidth: StyleSheet.hairlineWidth,
496
- overflow: "hidden"
567
+ overflow: "hidden",
568
+ alignItems: "center"
569
+ },
570
+ siteActions: {
571
+ flexDirection: "row",
572
+ alignItems: "center",
573
+ gap: 16,
574
+ paddingHorizontal: 6,
575
+ marginTop: -6
576
+ },
577
+ siteAction: {
578
+ flexDirection: "row",
579
+ alignItems: "center",
580
+ gap: 6,
581
+ paddingVertical: 4
582
+ },
583
+ siteActionText: {
584
+ fontSize: 13,
585
+ fontWeight: "600"
586
+ },
587
+ siteBlob: {
588
+ position: "absolute",
589
+ width: 220,
590
+ height: 220,
591
+ borderRadius: 110,
592
+ opacity: 0.6
593
+ },
594
+ siteBlobTop: {
595
+ top: -110,
596
+ left: -70
597
+ },
598
+ siteBlobBottom: {
599
+ bottom: -120,
600
+ right: -80
601
+ },
602
+ sitePage: {
603
+ width: "76%",
604
+ flex: 1,
605
+ marginTop: 22,
606
+ borderTopLeftRadius: 14,
607
+ borderTopRightRadius: 14,
608
+ borderWidth: StyleSheet.hairlineWidth,
609
+ borderBottomWidth: 0,
610
+ overflow: "hidden",
611
+ shadowOpacity: 0.1,
612
+ shadowRadius: 14,
613
+ shadowOffset: {
614
+ width: 0,
615
+ height: 4
616
+ },
617
+ elevation: 3
497
618
  },
498
619
  siteWeb: {
499
620
  flex: 1,
@@ -544,22 +665,6 @@ const styles = StyleSheet.create({
544
665
  fontSize: 13,
545
666
  lineHeight: 18
546
667
  },
547
- siteFoot: {
548
- flexDirection: "row",
549
- gap: 10,
550
- padding: 14
551
- },
552
- siteBtn: {
553
- flex: 1,
554
- height: 46,
555
- borderRadius: 23,
556
- alignItems: "center",
557
- justifyContent: "center"
558
- },
559
- siteBtnText: {
560
- fontSize: 16,
561
- fontWeight: "700"
562
- },
563
668
  disabled: {
564
669
  opacity: 0.35
565
670
  },