@adminide-stack/yantra-mobile 12.0.163 → 12.0.164

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 (158) hide show
  1. package/lib/components/CustomDrawer.js +8 -1
  2. package/lib/components/CustomDrawer.js.map +1 -1
  3. package/lib/components/NavigationHeader/HeaderSheet.js +23 -8
  4. package/lib/components/NavigationHeader/HeaderSheet.js.map +1 -1
  5. package/lib/components/NavigationHeader/HeaderSkillsButton.js +6 -3
  6. package/lib/components/NavigationHeader/HeaderSkillsButton.js.map +1 -1
  7. package/lib/components/NavigationHeader/HeaderSystemButtons.js +7 -0
  8. package/lib/components/NavigationHeader/HeaderSystemButtons.js.map +1 -0
  9. package/lib/components/NavigationHeader/HeaderTasksButton.js +144 -93
  10. package/lib/components/NavigationHeader/HeaderTasksButton.js.map +1 -1
  11. package/lib/components/NavigationHeader/NavigationHeader.js +2 -2
  12. package/lib/components/NavigationHeader/NavigationHeader.js.map +1 -1
  13. package/lib/features/agent-chat/NativeAgentChat.js +3 -3
  14. package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
  15. package/lib/features/audio-input/AudioRecorderPanel.js +1 -1
  16. package/lib/features/audio-input/NativeDictationBar.js +1 -1
  17. package/lib/features/canvas/CanvasExperience.js +1 -1
  18. package/lib/features/channels/ConnectAppsSheet.js +1 -1
  19. package/lib/features/channels/HomeImessage.js +1 -1
  20. package/lib/features/channels/useChannelsApi.js +1 -1
  21. package/lib/features/chat/OneTimeCodePrompt.js +1 -1
  22. package/lib/features/chat/QueuedFollowUps.js +4 -3
  23. package/lib/features/chat/QueuedFollowUps.js.map +1 -1
  24. package/lib/features/chat/TemporaryChatView.js +238 -0
  25. package/lib/features/chat/TemporaryChatView.js.map +1 -0
  26. package/lib/features/chat/connectorConnect.js +1 -1
  27. package/lib/features/chat/temporaryChatStore.js +59 -7
  28. package/lib/features/chat/temporaryChatStore.js.map +1 -1
  29. package/lib/features/chat/withTemporaryChat.js +24 -0
  30. package/lib/features/chat/withTemporaryChat.js.map +1 -0
  31. package/lib/features/dictate/recorderStatus.js +22 -0
  32. package/lib/features/dictate/recorderStatus.js.map +1 -0
  33. package/lib/features/dictate/useDictationRecorder.js +4 -4
  34. package/lib/features/dictate/useDictationRecorder.js.map +1 -1
  35. package/lib/features/home/sky/HomeSky.js +1 -1
  36. package/lib/features/skills/SkillTemplatePicker.js +107 -143
  37. package/lib/features/skills/SkillTemplatePicker.js.map +1 -1
  38. package/lib/features/webbuilder/WebBuilderExperience.js +402 -33
  39. package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
  40. package/lib/features/webbuilder/components/CloudSheet.js +35 -15
  41. package/lib/features/webbuilder/components/CloudSheet.js.map +1 -1
  42. package/lib/features/webbuilder/components/Credits.js +149 -0
  43. package/lib/features/webbuilder/components/Credits.js.map +1 -0
  44. package/lib/features/webbuilder/components/PreviewFrame.js +15 -4
  45. package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
  46. package/lib/features/webbuilder/components/PreviewScreen.js +5 -2
  47. package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
  48. package/lib/features/webbuilder/components/ProjectChat.js +58 -8
  49. package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
  50. package/lib/features/webbuilder/components/ProjectSheets.js +29 -6
  51. package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
  52. package/lib/features/webbuilder/components/ProjectsScreen.js +16 -7
  53. package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -1
  54. package/lib/features/webbuilder/components/PublishSheet.js +133 -2
  55. package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
  56. package/lib/features/webbuilder/components/RetentionBanner.js +130 -0
  57. package/lib/features/webbuilder/components/RetentionBanner.js.map +1 -0
  58. package/lib/features/webbuilder/components/ShareSheet.js +265 -0
  59. package/lib/features/webbuilder/components/ShareSheet.js.map +1 -0
  60. package/lib/features/webbuilder/components/SiteStatusSheet.js +533 -0
  61. package/lib/features/webbuilder/components/SiteStatusSheet.js.map +1 -0
  62. package/lib/features/webbuilder/components/StudioHome.js +8 -1
  63. package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
  64. package/lib/features/webbuilder/components/TemplateSuggestions.js +98 -0
  65. package/lib/features/webbuilder/components/TemplateSuggestions.js.map +1 -0
  66. package/lib/features/webbuilder/connectorTemplates.js +3 -3
  67. package/lib/features/webbuilder/connectorTemplates.js.map +1 -1
  68. package/lib/features/webbuilder/creditsLinks.js +5 -0
  69. package/lib/features/webbuilder/creditsLinks.js.map +1 -0
  70. package/lib/features/webbuilder/previewAccess.js +207 -0
  71. package/lib/features/webbuilder/previewAccess.js.map +1 -0
  72. package/lib/features/webbuilder/previewProbe.js +49 -1
  73. package/lib/features/webbuilder/previewProbe.js.map +1 -1
  74. package/lib/features/webbuilder/readiness.js +14 -0
  75. package/lib/features/webbuilder/readiness.js.map +1 -0
  76. package/lib/features/webbuilder/shareLink.js +26 -0
  77. package/lib/features/webbuilder/shareLink.js.map +1 -0
  78. package/lib/features/webbuilder/templateCover.js +11 -0
  79. package/lib/features/webbuilder/templateCover.js.map +1 -0
  80. package/lib/features/webbuilder/templateSuggestions.js +112 -0
  81. package/lib/features/webbuilder/templateSuggestions.js.map +1 -0
  82. package/lib/features/webbuilder/useGithubAutoSync.js +83 -0
  83. package/lib/features/webbuilder/useGithubAutoSync.js.map +1 -0
  84. package/lib/features/webbuilder/usePreviewAccess.js +61 -0
  85. package/lib/features/webbuilder/usePreviewAccess.js.map +1 -0
  86. package/lib/features/webbuilder/useWebBuilderCredits.js +99 -0
  87. package/lib/features/webbuilder/useWebBuilderCredits.js.map +1 -0
  88. package/lib/features/webbuilder/web/credits/credits.js +203 -0
  89. package/lib/features/webbuilder/web/credits/credits.js.map +1 -0
  90. package/lib/features/webbuilder/web/credits/creditsReader.js +65 -0
  91. package/lib/features/webbuilder/web/credits/creditsReader.js.map +1 -0
  92. package/lib/features/webbuilder/web/data/cloud.js +3 -3
  93. package/lib/features/webbuilder/web/data/cloud.js.map +1 -1
  94. package/lib/features/webbuilder/web/data/database.js +4 -1
  95. package/lib/features/webbuilder/web/data/database.js.map +1 -1
  96. package/lib/features/webbuilder/web/github/autoSync.js +231 -0
  97. package/lib/features/webbuilder/web/github/autoSync.js.map +1 -0
  98. package/lib/features/webbuilder/web/github/autoSyncEngine.js +367 -0
  99. package/lib/features/webbuilder/web/github/autoSyncEngine.js.map +1 -0
  100. package/lib/features/webbuilder/web/github/githubSync.js +54 -0
  101. package/lib/features/webbuilder/web/github/githubSync.js.map +1 -0
  102. package/lib/features/webbuilder/web/history/versions.js +83 -0
  103. package/lib/features/webbuilder/web/history/versions.js.map +1 -0
  104. package/lib/features/webbuilder/web/project/retention.js +217 -0
  105. package/lib/features/webbuilder/web/project/retention.js.map +1 -0
  106. package/lib/features/webbuilder/web/publish/actionErrors.js +81 -0
  107. package/lib/features/webbuilder/web/publish/actionErrors.js.map +1 -0
  108. package/lib/features/webbuilder/web/publish/publishSteps.js +86 -0
  109. package/lib/features/webbuilder/web/publish/publishSteps.js.map +1 -0
  110. package/lib/features/webbuilder/web/publish/siteAddress.js +79 -0
  111. package/lib/features/webbuilder/web/publish/siteAddress.js.map +1 -0
  112. package/lib/features/webbuilder/web/publish/siteHealth.js +497 -0
  113. package/lib/features/webbuilder/web/publish/siteHealth.js.map +1 -0
  114. package/lib/features/webbuilder/web/publish/siteInsights.js +145 -0
  115. package/lib/features/webbuilder/web/publish/siteInsights.js.map +1 -0
  116. package/lib/features/webbuilder/web/sharing/roles.js +108 -2
  117. package/lib/features/webbuilder/web/sharing/roles.js.map +1 -1
  118. package/lib/features/webbuilder/web/sharing/share.js +52 -0
  119. package/lib/features/webbuilder/web/sharing/share.js.map +1 -0
  120. package/lib/features/webbuilder/web/sharing/sharingApi.js +199 -0
  121. package/lib/features/webbuilder/web/sharing/sharingApi.js.map +1 -0
  122. package/lib/features/webbuilder/web/webServices.js +13 -2
  123. package/lib/features/webbuilder/web/webServices.js.map +1 -1
  124. package/lib/features/webbuilder/webbuilderPrompts.js +4 -1
  125. package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
  126. package/lib/features/webbuilder/workflow.js +2 -2
  127. package/lib/features/webbuilder/workflow.js.map +1 -1
  128. package/lib/hooks/useSurfaceJobs.js +113 -28
  129. package/lib/hooks/useSurfaceJobs.js.map +1 -1
  130. package/lib/index.js +1 -1
  131. package/lib/index.js.map +1 -1
  132. package/lib/screens/Chat/index.js +3 -2
  133. package/lib/screens/Chat/index.js.map +1 -1
  134. package/lib/screens/Home/HomeScreen.js +1 -1
  135. package/lib/screens/Home/components/BuildTemplatesSection.js +1 -1
  136. package/lib/screens/Home/components/ChooseTemplateModal.js +1 -1
  137. package/lib/screens/Home/components/HomeHero.js +1 -1
  138. package/lib/screens/Home/components/HomeSuggestions.js +1 -1
  139. package/lib/screens/Home/components/TemplateBrowserModal.js +1 -1
  140. package/lib/screens/Home/index.js +1 -1
  141. package/lib/screens/Home/index.js.map +1 -1
  142. package/lib/screens/WebBuilderNative/index.js +1 -1
  143. package/lib/screens/WebBuilderNative/index.js.map +1 -1
  144. package/lib/screens/WebBuilderNative/sandboxProxyApi.js +33 -3
  145. package/lib/screens/WebBuilderNative/sandboxProxyApi.js.map +1 -1
  146. package/lib/screens/WebBuilderNative/useWebBuilderHost.js +33 -13
  147. package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
  148. package/lib/screens/WebBuilderNative/useWebBuilderJobs.js +11 -4
  149. package/lib/screens/WebBuilderNative/useWebBuilderJobs.js.map +1 -1
  150. package/lib/screens/WebBuilderNative/webbuilderTransport.js +1 -1
  151. package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
  152. package/lib/services/brainQuickReply.js +47 -14
  153. package/lib/services/brainQuickReply.js.map +1 -1
  154. package/package.json +4 -4
  155. package/lib/components/NavigationHeader/HeaderMoreMenu.js +0 -78
  156. package/lib/components/NavigationHeader/HeaderMoreMenu.js.map +0 -1
  157. package/lib/components/NavigationHeader/HeaderSettingsMenu.js +0 -132
  158. package/lib/components/NavigationHeader/HeaderSettingsMenu.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useMemo,useState,useRef,useEffect,useCallback}from'react';import {StyleSheet,Keyboard,BackHandler,View,Text,Share,Linking,Alert}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {GestureHandlerRootView}from'react-native-gesture-handler';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {Tap,DIM}from'../inbox/components/Tap.js';import {isBareSeed,studioTurnText,siteScoreTurn}from'./studioCatalog.js';import {brandKitNote,findDesires,importBrandKit}from'../design/surface/brandKit.js';import {useBrandKitInUse}from'../design/surface/useBrandKitInUse.js';import {BrandSheet}from'../design/surface/BrandSheet.js';import {moveLegacyBrandKit}from'./brandKitMove.js';import {titleFromPrompt}from'./buildFragments.js';import {parseToolActivity}from'../chat/toolActivity.js';import {friendlySteps,firstContentLanded}from'./stepLabels.js';import {restoreTurnNote}from'./webbuilderPrompts.js';import {webbuilderTheme}from'./webbuilderTheme.js';import {CodeView}from'./components/CodeView.js';import {ProjectChat}from'./components/ProjectChat.js';import {ViewportToggle,PreviewScreen,ViewPicker}from'./components/PreviewScreen.js';import {PublishSheet}from'./components/PublishSheet.js';import {BOTTOM_TABS_SPACE,BottomTabs}from'./components/BottomTabs.js';import {SiteScoreSheet}from'./components/SiteScoreSheet.js';import {ProjectsScreen}from'./components/ProjectsScreen.js';import {TemplatesSheet}from'./components/TemplatesSheet.js';import {StudioHome}from'./components/StudioHome.js';import {VersionsSheet}from'./components/VersionsSheet.js';import {IconButton,Sheet,Toast}from'./components/ui.js';import {exportTurn,exportMessage}from'./exportCode.js';import {ownCloudflareTurn}from'./publishTools.js';import {SecretsSheet}from'./components/SecretsSheet.js';import {CloudSheet}from'./components/CloudSheet.js';import {IntegrationsPanel}from'./components/IntegrationsPanel.js';import {createWebServices}from'./web/webServices.js';import {ProjectMenuSheet,ProjectSettingsSheet,GithubPushSheet,IntegrationsSheet,ImportProjectSheet}from'./components/ProjectSheets.js';import {demoVideoSource,webbuilderDemoHandoff,encodeCodezenHandoff}from'./codezenHandoff.js';var __defProp = Object.defineProperty;
1
+ import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useMemo,useState,useCallback,useRef,useEffect}from'react';import {StyleSheet,Alert,Linking,Keyboard,BackHandler,View,Text,Share,Clipboard}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {GestureHandlerRootView}from'react-native-gesture-handler';import {useSafeInsets}from'../canvas/withRemoteSafeArea.js';import {useAppTheme}from'../../theme/AppThemeProvider.js';import {Tap,DIM}from'../inbox/components/Tap.js';import {isBareSeed,studioTurnText,siteScoreTurn}from'./studioCatalog.js';import {brandKitNote,findDesires,importBrandKit}from'../design/surface/brandKit.js';import {useBrandKitInUse}from'../design/surface/useBrandKitInUse.js';import {BrandSheet}from'../design/surface/BrandSheet.js';import {moveLegacyBrandKit}from'./brandKitMove.js';import {titleFromPrompt,displayHost}from'./buildFragments.js';import {parseToolActivity}from'../chat/toolActivity.js';import {friendlySteps,firstContentLanded}from'./stepLabels.js';import {restoreTurnNote}from'./webbuilderPrompts.js';import {webbuilderTheme}from'./webbuilderTheme.js';import {CodeView}from'./components/CodeView.js';import {ProjectChat}from'./components/ProjectChat.js';import {ViewportToggle,PreviewScreen,ViewPicker}from'./components/PreviewScreen.js';import {PublishSheet}from'./components/PublishSheet.js';import {BOTTOM_TABS_SPACE,BottomTabs}from'./components/BottomTabs.js';import {SiteScoreSheet}from'./components/SiteScoreSheet.js';import {ProjectsScreen}from'./components/ProjectsScreen.js';import {TemplatesSheet}from'./components/TemplatesSheet.js';import {StudioHome}from'./components/StudioHome.js';import {VersionsSheet}from'./components/VersionsSheet.js';import {IconButton,Sheet,Toast}from'./components/ui.js';import {exportMessage,exportTurn}from'./exportCode.js';import {ownCloudflareTurn,projectNameOfLiveUrl,plainActionError}from'./publishTools.js';import {SecretsSheet}from'./components/SecretsSheet.js';import {CloudSheet}from'./components/CloudSheet.js';import {notReadyHint,projectReadiness}from'./readiness.js';import {SiteStatusSheet}from'./components/SiteStatusSheet.js';import {useRetention,RetentionBanner}from'./components/RetentionBanner.js';import {useGithubAutoSync}from'./useGithubAutoSync.js';import {githubSyncStatus,repoNameOf,githubSettingsPatch}from'./web/github/githubSync.js';import {syncChip,canRunSync}from'./web/github/autoSync.js';import {normalizeGithubRepoUrl}from'./web/project/serverSettings.js';import {ShareSheet}from'./components/ShareSheet.js';import {roleCan}from'./web/sharing/roles.js';import {remixSnapshotParams,snapshotIdFromResult,remixSecretsCheck,buildRemixUrl}from'./web/sharing/share.js';import {OutOfCreditsCard,CreditsSheet}from'./components/Credits.js';import {billingPageUrl}from'./creditsLinks.js';import {useWebBuilderCredits}from'./useWebBuilderCredits.js';import {OUT_OF_CREDITS_TITLE,outOfCreditsText,chipLabel}from'./web/credits/credits.js';import {IntegrationsPanel}from'./components/IntegrationsPanel.js';import {createWebServices}from'./web/webServices.js';import {ProjectMenuSheet,ProjectSettingsSheet,GithubPushSheet,IntegrationsSheet,ImportProjectSheet}from'./components/ProjectSheets.js';import {demoVideoSource,webbuilderDemoHandoff,encodeCodezenHandoff}from'./codezenHandoff.js';import {PreviewAccessProvider,openPreviewInBrowser}from'./usePreviewAccess.js';import {probePreviewPrivacy}from'./previewProbe.js';import {siteShareTarget,PRIVATE_SHARE_TITLE,privateShareMessage}from'./shareLink.js';var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -17,6 +17,7 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ const CODEZEN_PREVIEW_MIN_VALID_MS = 9 * 6e4;
20
21
  const TOAST_MS = 2400;
21
22
  const TOAST_ACTION_MS = 6e3;
22
23
  const PUBLISH_WATCH_MS = 10 * 60 * 1e3;
@@ -55,9 +56,10 @@ function WebBuilderExperience({
55
56
  publishTools,
56
57
  projectTools,
57
58
  code,
58
- initialAgentSeed = null
59
+ initialAgentSeed = null,
60
+ previewAccess
59
61
  }) {
60
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
61
63
  const appTheme = useAppTheme();
62
64
  const isDark = hostIsDark != null ? hostIsDark : appTheme.isDark;
63
65
  const theme = useMemo(() => webbuilderTheme(isDark), [isDark]);
@@ -74,6 +76,12 @@ function WebBuilderExperience({
74
76
  const brandKits = useBrandKitInUse(brandTools == null ? void 0 : brandTools.run, "webbuilder");
75
77
  const brand = brandKits.kit;
76
78
  const [brandOpen, setBrandOpen] = useState(false);
79
+ const credits = useWebBuilderCredits(brandTools == null ? void 0 : brandTools.run, Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), activeChannelId);
80
+ const holdTurn = useCallback(() => {
81
+ if (!(credits == null ? void 0 : credits.out)) return false;
82
+ credits.showCard();
83
+ return true;
84
+ }, [credits]);
77
85
  const brandMoved = useRef(false);
78
86
  useEffect(() => {
79
87
  if (brandMoved.current || !brandTools || brandKits.loading || brandKits.error) return;
@@ -92,6 +100,18 @@ function WebBuilderExperience({
92
100
  const startSite = useCallback((start, files) => {
93
101
  const brief = start.brief.trim() || (start.template ? start.template.chatPrompt || start.template.title : "");
94
102
  if (!brief && !(files == null ? void 0 : files.length)) return;
103
+ if (credits == null ? void 0 : credits.out) {
104
+ Alert.alert(OUT_OF_CREDITS_TITLE, outOfCreditsText(true), [{
105
+ text: "Not now",
106
+ style: "cancel"
107
+ }, {
108
+ text: "Plans and top-up",
109
+ onPress: () => {
110
+ Linking.openURL(billingPageUrl(projectTools == null ? void 0 : projectTools.appUrl)).catch(() => void 0);
111
+ }
112
+ }]);
113
+ return;
114
+ }
95
115
  onStartProject(__spreadValues(__spreadValues({
96
116
  text: studioTurnText({
97
117
  brief,
@@ -107,7 +127,7 @@ function WebBuilderExperience({
107
127
  setDraft("");
108
128
  setTemplate(null);
109
129
  setBrandOff(false);
110
- }, [onStartProject, brand, brandOff]);
130
+ }, [onStartProject, brand, brandOff, credits, projectTools == null ? void 0 : projectTools.appUrl]);
111
131
  const handedOff = useRef(false);
112
132
  useEffect(() => {
113
133
  if (handedOff.current || !initialAgentSeed || startBlocked) return;
@@ -159,13 +179,36 @@ function WebBuilderExperience({
159
179
  const [mode, setMode] = useState("chat");
160
180
  const [viewport, setViewport] = useState("phone");
161
181
  useEffect(() => setMode("chat"), [activeChannelId]);
182
+ const githubSyncRef = useRef(null);
183
+ const syncTurnRef = useRef(null);
162
184
  const sendToAgent = useCallback((text, files) => {
185
+ var _a2;
163
186
  const words = text.trim();
164
187
  if (!words && !(files == null ? void 0 : files.length) || !hostChat) return;
165
188
  const turn = build || /^build\b/i.test(words) ? words : `Build me: ${words}`;
166
- hostChat.send(turn, files, build);
167
189
  setMode("chat");
168
- }, [hostChat, build]);
190
+ const engine = (_a2 = githubSyncRef.current) == null ? void 0 : _a2.engine;
191
+ const channel = activeChannelId;
192
+ if (!engine || !channel || !(build == null ? void 0 : build.sandboxId)) {
193
+ hostChat.send(turn, files, build);
194
+ return;
195
+ }
196
+ engine.beforeTurn(channel).catch(() => ({
197
+ proceed: true,
198
+ preHead: void 0
199
+ })).then((gate) => {
200
+ if (!gate.proceed) {
201
+ showToast("Your message wasn't sent. Choose which version to keep first.");
202
+ return;
203
+ }
204
+ syncTurnRef.current = {
205
+ channelId: channel,
206
+ request: turn,
207
+ preHead: gate.preHead
208
+ };
209
+ hostChat.send(turn, files, build);
210
+ });
211
+ }, [hostChat, build, activeChannelId, showToast]);
169
212
  const openChat = useCallback(() => {
170
213
  Keyboard.dismiss();
171
214
  setMode("chat");
@@ -355,12 +398,6 @@ ${restoreTurnNote({
355
398
  let publishLabel = "Publish";
356
399
  if (publishing) publishLabel = "Publishing\u2026";
357
400
  const shareUrl = live || (build == null ? void 0 : build.previewUrl) || null;
358
- const shareSite = () => {
359
- if (shareUrl) Share.share({
360
- message: shareUrl,
361
- url: shareUrl
362
- }).catch(() => void 0);
363
- };
364
401
  const [menu, setMenu] = useState(null);
365
402
  const chooseMenu = (action) => {
366
403
  setMenu(null);
@@ -371,6 +408,10 @@ ${restoreTurnNote({
371
408
  showToast("Wait for the current turn to finish.");
372
409
  return;
373
410
  }
411
+ if (holdTurn()) {
412
+ setMode("chat");
413
+ return;
414
+ }
374
415
  hostChat.send(text, void 0, build);
375
416
  setMode("chat");
376
417
  };
@@ -395,23 +436,133 @@ ${restoreTurnNote({
395
436
  const [integrationsOpen, setIntegrationsOpen] = useState(false);
396
437
  const [importOpen, setImportOpen] = useState(false);
397
438
  const [secretsOpen, setSecretsOpen] = useState(false);
439
+ const [creditsOpen, setCreditsOpen] = useState(false);
440
+ const [siteStatusOpen, setSiteStatusOpen] = useState(false);
398
441
  const [cloudOpen, setCloudOpen] = useState(false);
399
442
  const webServices = useMemo(() => (projectTools == null ? void 0 : projectTools.graphql) && projectTools.scope ? createWebServices({
400
443
  transport: projectTools.graphql,
401
444
  scope: projectTools.scope,
402
445
  appUrl: projectTools.appUrl
403
446
  }) : null, [projectTools]);
447
+ const githubSync = useGithubAutoSync({
448
+ services: webServices,
449
+ run: publishTools == null ? void 0 : publishTools.run,
450
+ channelId: activeChannelId,
451
+ build,
452
+ onPreviewChanged: () => setPreviewNonce((n) => n + 1)
453
+ });
454
+ githubSyncRef.current = githubSync;
455
+ const syncBusy = Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy);
456
+ const syncWasBusy = useRef(false);
457
+ useEffect(() => {
458
+ var _a2, _b2, _c2;
459
+ const was = syncWasBusy.current;
460
+ syncWasBusy.current = syncBusy;
461
+ const turn = syncTurnRef.current;
462
+ if (!was || syncBusy || !turn || !githubSync.engine) return;
463
+ syncTurnRef.current = null;
464
+ const reply = (_c2 = (_b2 = [...(_a2 = hostChat == null ? void 0 : hostChat.messages) != null ? _a2 : []].reverse().find((m) => m.role === "assistant")) == null ? void 0 : _b2.content) != null ? _c2 : null;
465
+ githubSync.engine.afterTurn(turn.channelId, {
466
+ request: turn.request,
467
+ reply,
468
+ preHead: turn.preHead
469
+ }).catch(() => void 0);
470
+ }, [syncBusy, githubSync.engine, hostChat == null ? void 0 : hostChat.messages]);
471
+ const divergedPrompt = githubSync.prompt;
472
+ const syncEngine = githubSync.engine;
473
+ useEffect(() => {
474
+ if (!divergedPrompt || !syncEngine) return;
475
+ const engine = syncEngine;
476
+ const counts = divergedPrompt.behind || divergedPrompt.ahead ? ` (${divergedPrompt.behind} new on GitHub, ${divergedPrompt.ahead} here)` : "";
477
+ Alert.alert("Your GitHub repo and this project both changed.", `${divergedPrompt.forTurn ? "Your message waits until you choose" : "Choose which version to keep"}${counts}. "Use GitHub's version" replaces this project's code; "Keep mine and push" sends this project's changes to the branch webbuilder-sync, to merge on GitHub.`, [{
478
+ text: "Use GitHub's version",
479
+ onPress: () => engine.resolvePrompt("github")
480
+ }, {
481
+ text: "Keep mine and push",
482
+ onPress: () => engine.resolvePrompt("mine")
483
+ }, {
484
+ text: "Cancel",
485
+ style: "cancel",
486
+ onPress: () => engine.resolvePrompt("cancel")
487
+ }], {
488
+ cancelable: false
489
+ });
490
+ }, [divergedPrompt, syncEngine]);
491
+ const [shareOpen, setShareOpen] = useState(false);
492
+ const retention = useRetention(projectTools == null ? void 0 : projectTools.graphql, activeChannelId);
493
+ const [roleEpoch, setRoleEpoch] = useState(0);
494
+ const [projectRole, setProjectRole] = useState(null);
495
+ useEffect(() => {
496
+ setProjectRole(null);
497
+ if (!webServices || !activeChannelId) return void 0;
498
+ let live2 = true;
499
+ webServices.sharing.myRole(activeChannelId, {
500
+ force: roleEpoch > 0
501
+ }).then((role) => live2 && setProjectRole(role)).catch(() => void 0);
502
+ return () => {
503
+ live2 = false;
504
+ };
505
+ }, [webServices, activeChannelId, roleEpoch]);
506
+ const shareAsTemplate = async () => {
507
+ if (!(build == null ? void 0 : build.sandboxId) || !(publishTools == null ? void 0 : publishTools.run) || !(projectTools == null ? void 0 : projectTools.webBuilderUrl)) return;
508
+ showToast("Making the template link\u2026");
509
+ const title = siteTitle || build.title || "";
510
+ const r = await publishTools.run(build, "WEBBUILDER_SNAPSHOT", remixSnapshotParams(build.sandboxId, title), 18e4).catch((err) => ({
511
+ successful: false,
512
+ error: err instanceof Error ? err.message : String(err)
513
+ }));
514
+ const data = r.successful && r.data && typeof r.data === "object" ? r.data : null;
515
+ const snapshotId = snapshotIdFromResult(data);
516
+ if (!snapshotId) {
517
+ Alert.alert("Share as template", r.successful ? "Could not create the template link. Try again." : plainActionError(r.error, "Could not create the template link. Try again."));
518
+ return;
519
+ }
520
+ const secrets = remixSecretsCheck(data);
521
+ if (!secrets.ok) {
522
+ Alert.alert("Share as template", secrets.message || "Could not create the template link.");
523
+ return;
524
+ }
525
+ const url = buildRemixUrl(projectTools.webBuilderUrl, snapshotId, title);
526
+ Clipboard.setString(url);
527
+ Alert.alert("Template link copied", `Anyone with this link gets their own copy to change.${secrets.note ? `
528
+
529
+ ${secrets.note}` : ""}`, [{
530
+ text: "Done",
531
+ style: "cancel"
532
+ }, {
533
+ text: "Share\u2026",
534
+ onPress: () => Share.share({
535
+ message: url,
536
+ url
537
+ }).catch(() => void 0)
538
+ }]);
539
+ };
404
540
  const filmDemo = () => {
405
541
  const demo = build && !building ? demoVideoSource(live, build.previewUrl) : null;
406
542
  if (!demo || !onOpenCodezen) return;
407
- const film = () => {
543
+ const handOff = (source) => {
408
544
  try {
409
- const handoff = webbuilderDemoHandoff(siteTitle || (build == null ? void 0 : build.title) || "", demo);
545
+ const handoff = webbuilderDemoHandoff(siteTitle || (build == null ? void 0 : build.title) || "", source);
410
546
  onOpenCodezen(encodeCodezenHandoff(handoff), handoff);
411
547
  } catch (err) {
412
548
  showToast(err instanceof Error ? err.message : "Couldn't open Codezen.");
413
549
  }
414
550
  };
551
+ const film = () => {
552
+ if (demo.stable || !(previewAccess == null ? void 0 : previewAccess.gated(demo.url)) || !activeChannelId) {
553
+ handOff(demo);
554
+ return;
555
+ }
556
+ previewAccess.resolve(demo.url, activeChannelId, {
557
+ minValidMs: CODEZEN_PREVIEW_MIN_VALID_MS
558
+ }).then((url) => {
559
+ var _a2;
560
+ return handOff(url === demo.url ? demo : __spreadProps(__spreadValues({}, demo), {
561
+ url,
562
+ displayUrl: (_a2 = demo.displayUrl) != null ? _a2 : displayHost(demo.url)
563
+ }));
564
+ }).catch(() => handOff(demo));
565
+ };
415
566
  if (demo.stable) {
416
567
  film();
417
568
  return;
@@ -424,6 +575,54 @@ ${restoreTurnNote({
424
575
  onPress: film
425
576
  }]);
426
577
  };
578
+ const unpublishedPreview = !live && (build == null ? void 0 : build.previewUrl) ? build.previewUrl : null;
579
+ const previewGated = Boolean(unpublishedPreview && (previewAccess == null ? void 0 : previewAccess.gated(unpublishedPreview)));
580
+ useEffect(() => {
581
+ if (unpublishedPreview && previewGated) probePreviewPrivacy(unpublishedPreview).catch(() => void 0);
582
+ }, [unpublishedPreview, previewGated]);
583
+ const shareTarget = async () => siteShareTarget({
584
+ liveUrl: live,
585
+ previewUrl: build == null ? void 0 : build.previewUrl,
586
+ previewPrivate: unpublishedPreview && previewGated ? await probePreviewPrivacy(unpublishedPreview) : null
587
+ });
588
+ const canInvite = Boolean(webServices && activeChannelId && roleCan(projectRole, "share"));
589
+ const explainPrivateShare = () => {
590
+ const buttons = [{
591
+ text: "Cancel",
592
+ style: "cancel"
593
+ }];
594
+ if (canInvite) buttons.push({
595
+ text: "Invite people",
596
+ onPress: () => setShareOpen(true)
597
+ });
598
+ if ((build == null ? void 0 : build.sandboxId) && onPublish) buttons.push({
599
+ text: "Publish",
600
+ onPress: () => setPublishOpen(true)
601
+ });
602
+ Alert.alert(PRIVATE_SHARE_TITLE, privateShareMessage(canInvite), buttons);
603
+ };
604
+ const shareSite = () => {
605
+ shareTarget().then((target) => {
606
+ if (target.kind === "private") {
607
+ explainPrivateShare();
608
+ } else if (target.kind === "link") {
609
+ Share.share({
610
+ message: target.url,
611
+ url: target.url
612
+ }).catch(() => void 0);
613
+ }
614
+ }).catch(() => void 0);
615
+ };
616
+ const copySiteLink = async () => {
617
+ const target = await shareTarget();
618
+ if (target.kind === "private") {
619
+ explainPrivateShare();
620
+ return false;
621
+ }
622
+ if (target.kind !== "link") return false;
623
+ Clipboard.setString(target.url);
624
+ return true;
625
+ };
427
626
  const projectMenu = () => {
428
627
  const view = [];
429
628
  if ((build == null ? void 0 : build.previewUrl) && mode !== "preview") {
@@ -448,8 +647,9 @@ ${restoreTurnNote({
448
647
  key: "browser",
449
648
  icon: "open-in-new",
450
649
  label: "Open in browser",
650
+ // A private preview gets its token first (the browser opens once it is in the link).
451
651
  run: () => {
452
- Linking.openURL(url).catch(() => void 0);
652
+ openPreviewInBrowser(previewAccess != null ? previewAccess : null, url, activeChannelId).catch(() => void 0);
453
653
  }
454
654
  });
455
655
  }
@@ -483,27 +683,130 @@ ${restoreTurnNote({
483
683
  });
484
684
  }
485
685
  if (projectTools && hostChat) {
686
+ const builtHint = notReadyHint(projectReadiness({
687
+ channelId: activeChannelId,
688
+ sandboxId: build == null ? void 0 : build.sandboxId
689
+ }));
486
690
  tools.push({
487
691
  key: "integrations",
488
692
  icon: "power-plug-outline",
489
693
  label: "Integrations",
490
- hint: "Stripe, email, Slack, AI\u2026",
694
+ hint: builtHint || "Stripe, email, Slack, AI\u2026",
695
+ disabled: Boolean(builtHint),
491
696
  run: () => setIntegrationsOpen(true)
492
697
  });
493
698
  }
494
699
  if (projectTools && (build == null ? void 0 : build.sandboxId)) {
700
+ const gh = githubSync.settings;
701
+ const repoUrl = normalizeGithubRepoUrl(gh == null ? void 0 : gh.repoUrl);
702
+ const ghStatus = githubSyncStatus(gh, Date.now());
703
+ const chip = syncChip(githubSync.status, Date.now());
704
+ const canSync = canRunSync(projectRole);
705
+ const {
706
+ engine
707
+ } = githubSync;
708
+ const children = [];
709
+ if (repoUrl) {
710
+ children.push({
711
+ key: "github-open",
712
+ icon: "open-in-new",
713
+ label: "Open on GitHub",
714
+ hint: repoNameOf(repoUrl) || void 0,
715
+ run: () => {
716
+ Linking.openURL(repoUrl).catch(() => void 0);
717
+ }
718
+ });
719
+ }
720
+ children.push({
721
+ key: "github-push",
722
+ icon: "github",
723
+ label: "Push to my GitHub",
724
+ hint: "Create or update a repo with this code",
725
+ run: () => setGithubOpen(true)
726
+ });
727
+ if (repoUrl && engine && activeChannelId && canSync) {
728
+ const channel = activeChannelId;
729
+ children.push({
730
+ key: "github-pull",
731
+ icon: "arrow-collapse-down",
732
+ label: "Pull from GitHub",
733
+ hint: chip.text,
734
+ attention: chip.tone === "error" || chip.tone === "warn",
735
+ run: () => {
736
+ showToast("Pulling from GitHub\u2026");
737
+ engine.pullNow(channel).catch(() => void 0);
738
+ }
739
+ }, {
740
+ key: "github-push-now",
741
+ icon: "arrow-collapse-up",
742
+ label: "Push now",
743
+ hint: githubSync.status.warning || chip.title || void 0,
744
+ run: () => {
745
+ showToast("Pushing to GitHub\u2026");
746
+ engine.pushNow(channel).catch(() => void 0);
747
+ }
748
+ });
749
+ }
750
+ if (ghStatus.notice) {
751
+ const {
752
+ href,
753
+ text
754
+ } = ghStatus.notice;
755
+ children.push({
756
+ key: "github-notice",
757
+ icon: "source-merge",
758
+ label: "Merge on GitHub",
759
+ hint: text,
760
+ attention: true,
761
+ run: () => {
762
+ Linking.openURL(href).catch(() => void 0);
763
+ }
764
+ });
765
+ }
766
+ if (repoUrl && canSync && webServices && activeChannelId) {
767
+ const channel = activeChannelId;
768
+ const on = Boolean(gh == null ? void 0 : gh.sync);
769
+ children.push({
770
+ key: "github-sync",
771
+ icon: on ? "checkbox-marked-outline" : "checkbox-blank-outline",
772
+ label: "Keep in sync",
773
+ hint: ghStatus.lines.join(" \xB7 ") || "Pull before each change, push after",
774
+ run: () => {
775
+ const patch = githubSettingsPatch(repoUrl, gh == null ? void 0 : gh.branch, !on);
776
+ if (!patch) return;
777
+ webServices.data.updateSettings(channel, {
778
+ github: patch
779
+ }).then((r) => {
780
+ let note = r.message || "Couldn't save the sync setting.";
781
+ if (r.ok) note = on ? "Sync is off." : "Keeping in sync.";
782
+ showToast(note);
783
+ githubSync.reload();
784
+ }).catch(() => void 0);
785
+ }
786
+ });
787
+ }
788
+ let hint;
789
+ if (repoUrl) hint = (gh == null ? void 0 : gh.sync) ? "Keeping in sync" : "Connected";
495
790
  tools.push({
496
791
  key: "github",
497
792
  icon: "github",
498
793
  label: "GitHub",
794
+ hint,
795
+ attention: Boolean(ghStatus.notice) || chip.tone === "error" || chip.tone === "warn",
499
796
  run: () => void 0,
500
- children: [{
501
- key: "github-push",
502
- icon: "github",
503
- label: "Push to my GitHub",
504
- hint: "Create or update a repo with this code",
505
- run: () => setGithubOpen(true)
506
- }]
797
+ children
798
+ });
799
+ }
800
+ if (credits == null ? void 0 : credits.balance) {
801
+ tools.push({
802
+ key: "credits",
803
+ icon: "circle-multiple-outline",
804
+ label: "AI credits",
805
+ hint: chipLabel(credits.balance),
806
+ run: () => {
807
+ setCreditsOpen(true);
808
+ credits.refresh().catch(() => void 0);
809
+ }
507
810
  });
508
811
  }
509
812
  const demo = build && !building ? demoVideoSource(live, build.previewUrl) : null;
@@ -523,17 +826,58 @@ ${restoreTurnNote({
523
826
  hint: "GitHub",
524
827
  run: () => setImportOpen(true)
525
828
  }];
829
+ const share = [];
830
+ if (webServices && activeChannelId) {
831
+ const canShare = roleCan(projectRole, "share");
832
+ share.push({
833
+ key: "people",
834
+ icon: "account-plus-outline",
835
+ label: canShare ? "Invite people" : "People with access",
836
+ hint: canShare ? "Add people and choose their role" : "See who can open this project",
837
+ run: () => setShareOpen(true)
838
+ });
839
+ }
840
+ if (build) {
841
+ share.push({
842
+ key: "site-link",
843
+ icon: "link-variant",
844
+ label: siteLive ? "Copy public link" : "Get a public link",
845
+ hint: siteLive ? "Anyone with the link can view the live site" : "Publish first: the preview link sleeps, the live site stays up",
846
+ run: () => {
847
+ if (!siteLive) {
848
+ setPublishOpen(true);
849
+ return;
850
+ }
851
+ Clipboard.setString(siteLive);
852
+ showToast("Public link copied.");
853
+ }
854
+ });
855
+ }
856
+ if ((build == null ? void 0 : build.sandboxId) && (publishTools == null ? void 0 : publishTools.run) && (projectTools == null ? void 0 : projectTools.webBuilderUrl) && !building) {
857
+ share.push({
858
+ key: "template",
859
+ icon: "shape-outline",
860
+ label: "Share as template",
861
+ hint: "A link that gives others their own copy to change",
862
+ run: () => {
863
+ shareAsTemplate().catch(() => void 0);
864
+ }
865
+ });
866
+ }
526
867
  return [{
527
868
  items: [...project2, ...view]
528
869
  }, {
529
870
  title: "TOOLS",
530
871
  items: tools
872
+ }, {
873
+ title: "SHARE",
874
+ items: share
531
875
  }, {
532
876
  items: more
533
877
  }];
534
878
  };
535
879
  const openMore = () => setProjectMenuOpen(true);
536
- return /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
880
+ const page = /* @__PURE__ */ jsxs(GestureHandlerRootView, { style: [styles.fill, {
537
881
  backgroundColor: theme.screen
538
882
  }], children: [
539
883
  activeChannelId ? /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -565,8 +909,13 @@ ${restoreTurnNote({
565
909
  ] })
566
910
  ] })
567
911
  ] }),
568
- mode === "chat" ? /* @__PURE__ */ jsx(ProjectChat, { messages: (_k = hostChat == null ? void 0 : hostChat.messages) != null ? _k : [], streaming: (_l = hostChat == null ? void 0 : hostChat.streaming) != null ? _l : null, busy: Boolean(hostChat == null ? void 0 : hostChat.busy), error: (_m = hostChat == null ? void 0 : hostChat.error) != null ? _m : null, connected: Boolean(hostChat == null ? void 0 : hostChat.connected), building, build, siteTitle: siteTitle || "Your site", onSend: (text, files) => sendToAgent(text, files), codeActions: Boolean(hostChat && (build == null ? void 0 : build.sandboxId)), onOpenPreview: () => setMode("preview"), onPublish: () => setPublishOpen(true), onPreviewAsleep: () => wakePreview(), previewDown: Boolean(previewTrouble && previewTrouble.kind !== "restoring"), ask: (_n = hostChat == null ? void 0 : hostChat.ask) != null ? _n : null, onAnswerAsk: (formatted) => hostChat == null ? void 0 : hostChat.send(formatted), loading: historyLoading, steering: hostChat == null ? void 0 : hostChat.steering, renderConnectorCard: hostChat == null ? void 0 : hostChat.renderConnectorCard, theme, bottomInset: insets.bottom }) : null,
569
- mode === "preview" ? /* @__PURE__ */ jsx(PreviewScreen, { build, building, loading: buildsLoading, previewNonce, onReload: () => setPreviewNonce((n) => n + 1), onWake: () => wakePreview(), waking, trouble: previewTrouble, onRetry: () => wakePreview(true), onRestore: restoreFromSavedCopy, onAskAiRestore: hostChat ? askAiToRestore : void 0, agentBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), steps: liveSteps, onPublish: () => setPublishOpen(true), publishLabel, error: (_o = hostChat == null ? void 0 : hostChat.error) != null ? _o : null, theme, bottomInset: insets.bottom, viewport, unpublished: Boolean(build == null ? void 0 : build.sandboxId) && !(build == null ? void 0 : build.liveUrl), readSourceFile: code && build ? (path) => code.readFile(build, path, false).then((r) => {
912
+ mode === "chat" ? /* @__PURE__ */ jsx(ProjectChat, { messages: (_k = hostChat == null ? void 0 : hostChat.messages) != null ? _k : [], streaming: (_l = hostChat == null ? void 0 : hostChat.streaming) != null ? _l : null, busy: Boolean(hostChat == null ? void 0 : hostChat.busy), error: (_m = hostChat == null ? void 0 : hostChat.error) != null ? _m : null, connected: Boolean(hostChat == null ? void 0 : hostChat.connected), building, build, siteTitle: siteTitle || "Your site", onSend: (text, files) => sendToAgent(text, files), codeActions: Boolean(hostChat && (build == null ? void 0 : build.sandboxId)), holdTurn, templates, onStartFromTemplate: (t, brief) => startSite({
913
+ brief,
914
+ template: t
915
+ }), banner: /* @__PURE__ */ jsx(RetentionBanner, { view: retention, appUrl: projectTools == null ? void 0 : projectTools.appUrl, canExtend: projectRole !== "viewer", onDownload: (build == null ? void 0 : build.sandboxId) && !building ? downloadCode : void 0, theme }), costLine: ((_n = credits == null ? void 0 : credits.costLine) == null ? void 0 : _n.channelId) === activeChannelId ? credits.costLine.text : null, creditsCard: (credits == null ? void 0 : credits.cardOpen) ? /* @__PURE__ */ jsx(OutOfCreditsCard, { appUrl: projectTools == null ? void 0 : projectTools.appUrl, onCheckAgain: () => credits.refresh({
916
+ fresh: true
917
+ }), onDismiss: credits.dismissCard, theme }) : null, onOpenPreview: () => setMode("preview"), onPublish: () => setPublishOpen(true), onPreviewAsleep: () => wakePreview(), previewDown: Boolean(previewTrouble && previewTrouble.kind !== "restoring"), ask: (_o = hostChat == null ? void 0 : hostChat.ask) != null ? _o : null, onAnswerAsk: (formatted) => hostChat == null ? void 0 : hostChat.send(formatted), loading: historyLoading, steering: hostChat == null ? void 0 : hostChat.steering, renderConnectorCard: hostChat == null ? void 0 : hostChat.renderConnectorCard, onCopyLink: copySiteLink, theme, bottomInset: insets.bottom }) : null,
918
+ mode === "preview" ? /* @__PURE__ */ jsx(PreviewScreen, { build, building, loading: buildsLoading, previewNonce, onReload: () => setPreviewNonce((n) => n + 1), onWake: () => wakePreview(), waking, trouble: previewTrouble, onRetry: () => wakePreview(true), onRestore: restoreFromSavedCopy, onAskAiRestore: hostChat ? askAiToRestore : void 0, agentBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), steps: liveSteps, onPublish: () => setPublishOpen(true), publishLabel, error: (_p = hostChat == null ? void 0 : hostChat.error) != null ? _p : null, theme, bottomInset: insets.bottom, viewport, unpublished: Boolean(build == null ? void 0 : build.sandboxId) && !(build == null ? void 0 : build.liveUrl), readSourceFile: code && build ? (path) => code.readFile(build, path, false).then((r) => {
570
919
  var _a2;
571
920
  return r.ok ? (_a2 = r.content) != null ? _a2 : null : null;
572
921
  }) : void 0, onShowCode: canShowCode ? () => setMode("code") : void 0, buildingCover }) : null,
@@ -584,7 +933,7 @@ ${restoreTurnNote({
584
933
  color: theme.ink
585
934
  }], numberOfLines: 1, children: "Code" })
586
935
  ] }),
587
- /* @__PURE__ */ jsx(CodeView, { files: (_p = build == null ? void 0 : build.files) != null ? _p : null, build, code, busy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onWake: build && onResumePreview ? () => onResumePreview(build).then((outcome) => {
936
+ /* @__PURE__ */ jsx(CodeView, { files: (_q = build == null ? void 0 : build.files) != null ? _q : null, build, code, busy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onWake: build && onResumePreview ? () => onResumePreview(build).then((outcome) => {
588
937
  if (outcome === "ok") setPreviewNonce((n) => n + 1);
589
938
  return outcome;
590
939
  }) : void 0, theme, onAsk: openChat })
@@ -594,10 +943,13 @@ ${restoreTurnNote({
594
943
  paddingTop: insets.top + 4,
595
944
  borderBottomColor: "transparent"
596
945
  }], children: /* @__PURE__ */ jsx(IconButton, { icon: "arrow-left", label: "Leave Web Builder", onPress: back, theme, testID: "webbuilder-back" }) }) : null,
597
- /* @__PURE__ */ jsx(View, { style: styles.fill, children: homeTab === "create" ? /* @__PURE__ */ jsx(StudioHome, { draft, onDraft: setDraft, template, onClearTemplate: () => setTemplate(null), onBrowseTemplates: () => setTemplatesOpen(true), brand, brandOff, onBrandOffChange: setBrandOff, onBrand: () => setBrandOpen(true), onSiteScore: () => setScoreOpen(true), onStart: startSite, connecting: startBlocked, startNotice, theme, bottomInset: BOTTOM_TABS_SPACE + insets.bottom }) : /* @__PURE__ */ jsx(ProjectsScreen, { projects, loading: projectsLoading, error: projectsError, hasMore: projectsHasMore, onRefresh: onRefreshProjects, onLoadMore: onLoadMoreProjects, onOpen: (p) => onOpenProject(p.channelId), onNewProject: () => setHomeTab("create"), topInset: insets.top + 12, bottomInset: BOTTOM_TABS_SPACE + insets.bottom, theme }) }),
946
+ /* @__PURE__ */ jsx(View, { style: styles.fill, children: homeTab === "create" ? /* @__PURE__ */ jsx(StudioHome, { draft, onDraft: setDraft, template, onClearTemplate: () => setTemplate(null), onBrowseTemplates: () => setTemplatesOpen(true), templates, onUseTemplate: (t, brief) => {
947
+ pickTemplate(t);
948
+ if (brief) setDraft(brief);
949
+ }, brand, brandOff, onBrandOffChange: setBrandOff, onBrand: () => setBrandOpen(true), onSiteScore: () => setScoreOpen(true), onStart: startSite, connecting: startBlocked, startNotice, theme, bottomInset: BOTTOM_TABS_SPACE + insets.bottom }) : /* @__PURE__ */ jsx(ProjectsScreen, { projects, loading: projectsLoading, error: projectsError, hasMore: projectsHasMore, onRefresh: onRefreshProjects, onLoadMore: onLoadMoreProjects, onOpen: (p) => onOpenProject(p.channelId), onNewProject: () => setHomeTab("create"), topInset: insets.top + 12, bottomInset: BOTTOM_TABS_SPACE + insets.bottom, theme }) }),
598
950
  /* @__PURE__ */ jsx(BottomTabs, { tab: homeTab, onTab: setHomeTab, theme, bottomInset: insets.bottom })
599
951
  ] }),
600
- /* @__PURE__ */ jsx(TemplatesSheet, { visible: templatesOpen, onClose: () => setTemplatesOpen(false), templates, loading: templatesLoading, error: templatesError, onReload: onReloadTemplates, selectedId: (_q = template == null ? void 0 : template.id) != null ? _q : null, onPick: pickTemplate, theme }),
952
+ /* @__PURE__ */ jsx(TemplatesSheet, { visible: templatesOpen, onClose: () => setTemplatesOpen(false), templates, loading: templatesLoading, error: templatesError, onReload: onReloadTemplates, selectedId: (_r = template == null ? void 0 : template.id) != null ? _r : null, onPick: pickTemplate, theme }),
601
953
  /* @__PURE__ */ jsx(SiteScoreSheet, { visible: scoreOpen, onClose: () => setScoreOpen(false), blocked: startBlocked, onCheck: (url) => {
602
954
  setScoreOpen(false);
603
955
  onStartProject({
@@ -618,10 +970,18 @@ ${restoreTurnNote({
618
970
  /* @__PURE__ */ jsx(GithubPushSheet, { visible: githubOpen, build, channelId: activeChannelId, title: siteTitle || (build == null ? void 0 : build.title) || "", tools: projectTools, onStarted: (message) => {
619
971
  showToast(message);
620
972
  setMode("chat");
973
+ setTimeout(githubSync.reload, 5e3);
621
974
  }, onClose: () => setGithubOpen(false), theme }),
622
975
  webServices ? /* @__PURE__ */ jsx(IntegrationsPanel, { visible: integrationsOpen, channelId: activeChannelId, services: webServices, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onRequest: (text) => askAgent(text), onClose: () => setIntegrationsOpen(false), theme }) : /* @__PURE__ */ jsx(IntegrationsSheet, { visible: integrationsOpen, channelId: activeChannelId, tools: projectTools, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onRequest: (text) => askAgent(text), onClose: () => setIntegrationsOpen(false), theme })
623
976
  ] }) : null,
624
- webServices ? /* @__PURE__ */ jsx(CloudSheet, { visible: cloudOpen, channelId: activeChannelId, data: webServices.data, busy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onRequest: (text) => {
977
+ webServices ? /* @__PURE__ */ jsx(CreditsSheet, { visible: creditsOpen, balance: (_s = credits == null ? void 0 : credits.balance) != null ? _s : null, appUrl: projectTools == null ? void 0 : projectTools.appUrl, onRefresh: () => {
978
+ var _a2;
979
+ return (_a2 = credits == null ? void 0 : credits.refresh({
980
+ fresh: true
981
+ })) != null ? _a2 : Promise.resolve(null);
982
+ }, onClose: () => setCreditsOpen(false), theme }) : null,
983
+ webServices ? /* @__PURE__ */ jsx(ShareSheet, { visible: shareOpen, channelId: activeChannelId, title: siteTitle || (build == null ? void 0 : build.title) || "this project", sharing: webServices.sharing, onChanged: () => setRoleEpoch((n) => n + 1), onClose: () => setShareOpen(false), theme }) : null,
984
+ webServices ? /* @__PURE__ */ jsx(CloudSheet, { role: projectRole, visible: cloudOpen, channelId: activeChannelId, data: webServices.data, busy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onRequest: (text) => {
625
985
  if (!build || !hostChat || hostChat.busy) return false;
626
986
  setCloudOpen(false);
627
987
  askAgent(text);
@@ -635,20 +995,29 @@ ${restoreTurnNote({
635
995
  agent: true
636
996
  });
637
997
  }, onClose: () => setImportOpen(false), theme }),
638
- /* @__PURE__ */ jsx(PublishSheet, { visible: publishOpen, build, publishing, onPublish: onPublish ? publish : void 0, onClose: () => setPublishOpen(false), theme, liveUrl: live, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), tools: publishTools, onDownloadCode: (build == null ? void 0 : build.sandboxId) && !building ? downloadCode : void 0, onExport: hostChat && !building ? exportTo : void 0, onOwnCloudflare: hostChat && !building ? () => askAgent(ownCloudflareTurn(siteTitle || (build == null ? void 0 : build.title) || "")) : void 0, onFixWithAi: hostChat ? (text) => askAgent(text) : void 0, onUnpublished: () => showToast("The site is offline now.") }),
998
+ /* @__PURE__ */ jsx(PublishSheet, { visible: publishOpen, build, publishing, onPublish: onPublish ? publish : void 0, onClose: () => setPublishOpen(false), theme, liveUrl: live, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), tools: publishTools, onDownloadCode: (build == null ? void 0 : build.sandboxId) && !building ? downloadCode : void 0, onExport: hostChat && !building ? exportTo : void 0, onOwnCloudflare: hostChat && !building ? () => askAgent(ownCloudflareTurn(siteTitle || (build == null ? void 0 : build.title) || "")) : void 0, onFixWithAi: hostChat ? (text) => askAgent(text) : void 0, onUnpublished: () => showToast("The site is offline now."), onSiteStatus: (publishTools == null ? void 0 : publishTools.run) && live ? () => {
999
+ setPublishOpen(false);
1000
+ setTimeout(() => setSiteStatusOpen(true), 300);
1001
+ } : void 0, progressText: publishing ? (_t = building == null ? void 0 : building.statusText) != null ? _t : null : null }),
1002
+ (publishTools == null ? void 0 : publishTools.run) && live ? /* @__PURE__ */ jsx(SiteStatusSheet, { visible: siteStatusOpen, build, projectName: projectNameOfLiveUrl(live), channelId: activeChannelId, run: publishTools.run, graphql: projectTools == null ? void 0 : projectTools.graphql, aiBusy: Boolean(building) || Boolean(hostChat == null ? void 0 : hostChat.busy), onFixWithAi: (text) => {
1003
+ if (!build || !hostChat || hostChat.busy) return false;
1004
+ askAgent(text);
1005
+ return true;
1006
+ }, onClose: () => setSiteStatusOpen(false), theme }) : null,
639
1007
  /* @__PURE__ */ jsx(VersionsSheet, { visible: versionsOpen, builds, selectedKey, onSelect: (picked) => {
640
1008
  setSelectedKey(picked.key === (latest == null ? void 0 : latest.key) ? null : picked.key);
641
1009
  setVersionsOpen(false);
642
1010
  }, onClose: () => setVersionsOpen(false), theme }),
643
- /* @__PURE__ */ jsx(Sheet, { visible: menu !== null, title: (_r = menu == null ? void 0 : menu.title) != null ? _r : "", onClose: () => setMenu(null), theme, children: /* @__PURE__ */ jsx(View, { style: [styles.menuList, {
1011
+ /* @__PURE__ */ jsx(Sheet, { visible: menu !== null, title: (_u = menu == null ? void 0 : menu.title) != null ? _u : "", onClose: () => setMenu(null), theme, children: /* @__PURE__ */ jsx(View, { style: [styles.menuList, {
644
1012
  paddingBottom: insets.bottom + 8
645
- }], children: ((_s = menu == null ? void 0 : menu.actions) != null ? _s : []).map((action) => /* @__PURE__ */ jsx(Tap, { onPress: () => chooseMenu(action), accessibilityRole: "button", style: [styles.menuRow, {
1013
+ }], children: ((_v = menu == null ? void 0 : menu.actions) != null ? _v : []).map((action) => /* @__PURE__ */ jsx(Tap, { onPress: () => chooseMenu(action), accessibilityRole: "button", style: [styles.menuRow, {
646
1014
  borderBottomColor: theme.border
647
1015
  }], pressedStyle: DIM, children: /* @__PURE__ */ jsx(Text, { style: [styles.menuLabel, {
648
1016
  color: action.destructive ? theme.crit : theme.ink
649
1017
  }], children: action.label }) }, action.label)) }) }),
650
1018
  /* @__PURE__ */ jsx(Toast, { message: toast, action: toastAction, theme, bottom: insets.bottom + 80 })
651
1019
  ] });
1020
+ return /* @__PURE__ */ jsx(PreviewAccessProvider, { access: previewAccess, channelId: activeChannelId, children: page });
652
1021
  }
653
1022
  const styles = StyleSheet.create({
654
1023
  codeBar: {