@adminide-stack/yantra-mobile 12.0.142 → 12.0.145-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.
- package/lib/features/attachments/displayUserMessageText.js +2 -2
- package/lib/features/attachments/displayUserMessageText.js.map +1 -1
- package/lib/features/devices/readings.js.map +1 -1
- package/lib/features/devices/session.js +2 -22
- package/lib/features/devices/session.js.map +1 -1
- package/lib/features/notion/NotionAgentPanel.js +987 -0
- package/lib/features/notion/NotionAgentPanel.js.map +1 -0
- package/lib/features/notion/NotionAskAiSheet.js +362 -0
- package/lib/features/notion/NotionAskAiSheet.js.map +1 -0
- package/lib/features/notion/NotionBlockView.js +4 -3
- package/lib/features/notion/NotionBlockView.js.map +1 -1
- package/lib/features/notion/NotionConnectionsSheet.js +47 -13
- package/lib/features/notion/NotionConnectionsSheet.js.map +1 -1
- package/lib/features/notion/NotionPageView.js +68 -8
- package/lib/features/notion/NotionPageView.js.map +1 -1
- package/lib/features/notion/NotionSidebarSections.js +1 -1
- package/lib/features/notion/NotionSidebarSections.js.map +1 -1
- package/lib/features/notion/NotionWorkspaceView.js +14 -9
- package/lib/features/notion/NotionWorkspaceView.js.map +1 -1
- package/lib/features/notion/database/DatabaseCells.js +3 -1
- package/lib/features/notion/database/DatabaseCells.js.map +1 -1
- package/lib/features/notion/database/DatabaseDateLayouts.js +1 -1
- package/lib/features/notion/database/DatabaseDateLayouts.js.map +1 -1
- package/lib/features/notion/database/NotionDatabaseView.js +1 -1
- package/lib/features/notion/database/NotionDatabaseView.js.map +1 -1
- package/lib/features/notion/notionAgentRunStatus.js +2 -2
- package/lib/features/notion/notionAgentRunStatus.js.map +1 -1
- package/lib/features/notion/notionAgentRuns.js +57 -0
- package/lib/features/notion/notionAgentRuns.js.map +1 -0
- package/lib/features/notion/notionAiContext.js +91 -0
- package/lib/features/notion/notionAiContext.js.map +1 -0
- package/lib/features/notion/notionConnections.js +42 -4
- package/lib/features/notion/notionConnections.js.map +1 -1
- package/lib/features/notion/notionDocuments.js +61 -1
- package/lib/features/notion/notionDocuments.js.map +1 -1
- package/lib/features/notion/notionNotesAgent.js +173 -3
- package/lib/features/notion/notionNotesAgent.js.map +1 -1
- package/lib/features/notion/notionPageKinds.js +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +229 -97
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +33 -7
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/buildJob.js +2 -2
- package/lib/features/webbuilder/buildJob.js.map +1 -1
- package/lib/features/webbuilder/codeFiles.js +18 -1
- package/lib/features/webbuilder/codeFiles.js.map +1 -1
- package/lib/features/webbuilder/components/BottomTabs.js.map +1 -1
- package/lib/features/webbuilder/components/CodeView.js +134 -56
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/Composer.js +2 -2
- package/lib/features/webbuilder/components/Composer.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewFrame.js +19 -3
- package/lib/features/webbuilder/components/PreviewFrame.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +310 -46
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +141 -12
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectSheets.js +792 -0
- package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -0
- package/lib/features/webbuilder/components/ProjectsScreen.js +14 -2
- package/lib/features/webbuilder/components/ProjectsScreen.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +914 -58
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/TemplateCard.js +9 -6
- package/lib/features/webbuilder/components/TemplateCard.js.map +1 -1
- package/lib/features/webbuilder/components/TemplatesSheet.js +5 -17
- package/lib/features/webbuilder/components/TemplatesSheet.js.map +1 -1
- package/lib/features/webbuilder/connectorTemplates.js +171 -0
- package/lib/features/webbuilder/connectorTemplates.js.map +1 -0
- package/lib/features/webbuilder/fileTree.js +163 -0
- package/lib/features/webbuilder/fileTree.js.map +1 -0
- package/lib/features/webbuilder/followUps.js +67 -0
- package/lib/features/webbuilder/followUps.js.map +1 -0
- package/lib/features/webbuilder/previewProbe.js +49 -0
- package/lib/features/webbuilder/previewProbe.js.map +1 -0
- package/lib/features/webbuilder/previewRoutes.js +156 -0
- package/lib/features/webbuilder/previewRoutes.js.map +1 -0
- package/lib/features/webbuilder/projectTools.js +341 -0
- package/lib/features/webbuilder/projectTools.js.map +1 -0
- package/lib/features/webbuilder/publishTools.js +475 -0
- package/lib/features/webbuilder/publishTools.js.map +1 -0
- package/lib/features/webbuilder/sleepNotice.js +13 -0
- package/lib/features/webbuilder/sleepNotice.js.map +1 -0
- package/lib/features/webbuilder/stepLabels.js +37 -7
- package/lib/features/webbuilder/stepLabels.js.map +1 -1
- package/lib/features/webbuilder/studioCatalog.js +5 -1
- package/lib/features/webbuilder/studioCatalog.js.map +1 -1
- package/lib/features/webbuilder/templateCatalog.js +140 -0
- package/lib/features/webbuilder/templateCatalog.js.map +1 -0
- package/lib/features/webbuilder/webbuilderPrompts.js +31 -5
- package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
- package/lib/features/webbuilder/workflow.js +8 -4
- package/lib/features/webbuilder/workflow.js.map +1 -1
- package/lib/screens/Devices/index.js +3 -205
- package/lib/screens/Devices/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js +9 -6
- package/lib/screens/WebBuilderNative/codeWorkspaceApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/keepAlive.js +53 -3
- package/lib/screens/WebBuilderNative/keepAlive.js.map +1 -1
- package/lib/screens/WebBuilderNative/unreachableRetry.js +23 -0
- package/lib/screens/WebBuilderNative/unreachableRetry.js.map +1 -0
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js +37 -0
- package/lib/screens/WebBuilderNative/useConnectorTemplates.js.map +1 -0
- package/lib/screens/WebBuilderNative/useSandboxKeepAlive.js +6 -0
- package/lib/screens/WebBuilderNative/useSandboxKeepAlive.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +302 -40
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderJobs.js +2 -2
- package/lib/screens/WebBuilderNative/useWebBuilderJobs.js.map +1 -1
- package/lib/screens/WebBuilderNative/versionUndo.js +1 -1
- package/lib/screens/WebBuilderNative/versionUndo.js.map +1 -1
- package/lib/screens/WebBuilderNative/webbuilderTransport.js +147 -77
- package/lib/screens/WebBuilderNative/webbuilderTransport.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/devices/bodyComposition.js +0 -116
- package/lib/features/devices/bodyComposition.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useRef,useState,useMemo,useEffect,
|
|
1
|
+
import {useRef,useState,useCallback,useMemo,useEffect,useSyncExternalStore}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {useAiCodeDeployToCloudflareMutation}from'common/graphql';import {v4}from'uuid';import AsyncStorage from'@react-native-async-storage/async-storage';import {projectInstructionsNote,readDeleteReply,readSettingsUpdateReply,parseProjectSettings}from'../../features/webbuilder/projectTools.js';import {useCdecliConnection}from'../../contexts/CdecliConnectionContext.js';import {useChatStream}from'../../hooks/useChatStream.js';import {useHostChatChannel}from'../../hooks/useHostChatChannel.js';import {config}from'../../config/env-config.js';import {useChatMessages,subscribeRememberedHistory,historyRunningChannelIds}from'../../hooks/useChatApi.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useCanvasSession}from'../../features/canvas/useCanvasSession.js';import {tokenClaims}from'../../features/canvas/sessionIdentity.js';import {buildsFromPosts,hasWorkflowPosts,siteNameFromRequest,titleFromPrompt,stripAgentNote,projectFromPosts,turnState,pendingWork,transcriptFromPosts,userBubbleText,displayAgentText}from'../../features/webbuilder/buildFragments.js';import {handEditsNote,savedCodeSource}from'../../features/webbuilder/codeFiles.js';import {createCodeWorkspace}from'./codeWorkspaceApi.js';import {WEBBUILDER_CHAT_SKILL,buildTriggerParams,templateRemixNote,newObjectId}from'../../features/webbuilder/workflow.js';import {useWebBuilderGallery}from'./useWebBuilderGallery.js';import {agentEditNote,agentPublishMessage}from'../../features/webbuilder/webbuilderPrompts.js';import {useCodeAssistantCatalog}from'./useCodeAssistantCatalog.js';import {useConnectorTemplates}from'./useConnectorTemplates.js';import {directChannels,uploadAttachment,triggerBuild,createSandboxRouter,directSandboxRun,wakeSandbox,restoreFromSavedCopy,OUTDATED_SERVER_RE}from'./webbuilderTransport.js';import {useSandboxProxyApi}from'./sandboxProxyApi.js';import {useSandboxKeepAlive}from'./useSandboxKeepAlive.js';import {pendingAskUser}from'../../features/chat/askUser.js';import {runningBuild,useRunningBuilds,markBuildDone}from'./runningBuilds.js';import {isAgentSite}from'./siteLane.js';import {undoLastChange,redoChange}from'./versionUndo.js';import {WEBBUILDER_EXPORT_ZIP_ACTION,exportZipParams,exportZipUrl}from'../../features/webbuilder/exportCode.js';import {useRestoredSandboxes,applyRestored}from'./useRestoredSandboxes.js';import {useWebBuilderJobs}from'./useWebBuilderJobs.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -21,6 +21,72 @@ const POLL_MS = 2500;
|
|
|
21
21
|
const ADOPTED_KEY = "yantra.webbuilder.adopted.v1";
|
|
22
22
|
const TURN_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
23
23
|
const NO_REPLY_TIMEOUT_MS = 3 * 60 * 1e3;
|
|
24
|
+
const PROJECT_SETTINGS_QUERY = gql`
|
|
25
|
+
query aiCodeProjectSettings($channelId: String!) {
|
|
26
|
+
aiCodeProjectSettings(channelId: $channelId)
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const UPDATE_PROJECT_SETTINGS_MUTATION = gql`
|
|
30
|
+
mutation aiCodeUpdateProjectSettings($channelId: String!, $input: JSON!) {
|
|
31
|
+
aiCodeUpdateProjectSettings(channelId: $channelId, input: $input)
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
const DELETE_PROJECT_MUTATION = gql`
|
|
35
|
+
mutation aiCodeDeleteProject($channelId: String!) {
|
|
36
|
+
aiCodeDeleteProject(channelId: $channelId)
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
const DELETE_CHANNEL_MUTATION = gql`
|
|
40
|
+
mutation deleteChannel($id: ID!) {
|
|
41
|
+
deleteChannel(id: $id)
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const PUSH_TO_GITHUB_MUTATION = gql`
|
|
45
|
+
mutation aiCodePushToGithub($sandboxId: String!, $repoName: String!, $channelId: String) {
|
|
46
|
+
aiCodePushToGithub(sandboxId: $sandboxId, repoName: $repoName, channelId: $channelId) {
|
|
47
|
+
success
|
|
48
|
+
message
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const INTEGRATION_CATALOG_QUERY = gql`
|
|
53
|
+
query WebbuilderIntegrationConnectors($search: String, $category: String) {
|
|
54
|
+
integrationConnectors(search: $search, category: $category) {
|
|
55
|
+
id
|
|
56
|
+
title
|
|
57
|
+
description
|
|
58
|
+
logo
|
|
59
|
+
authMethods
|
|
60
|
+
meta {
|
|
61
|
+
categories
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
const DEPLOY_WITH_DOMAIN_MUTATION = gql`
|
|
67
|
+
mutation aiCodeDeployToCloudflareWithDomain(
|
|
68
|
+
$sandboxId: String!
|
|
69
|
+
$projectName: String
|
|
70
|
+
$channelId: String
|
|
71
|
+
$customDomain: String
|
|
72
|
+
) {
|
|
73
|
+
aiCodeDeployToCloudflare(
|
|
74
|
+
sandboxId: $sandboxId
|
|
75
|
+
projectName: $projectName
|
|
76
|
+
channelId: $channelId
|
|
77
|
+
customDomain: $customDomain
|
|
78
|
+
) {
|
|
79
|
+
success
|
|
80
|
+
message
|
|
81
|
+
eventId
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
const PRE_PUBLISH_REVIEW_QUERY = gql`
|
|
86
|
+
query aiCodePrePublishReview($channelId: String!, $sandboxId: String!) {
|
|
87
|
+
aiCodePrePublishReview(channelId: $channelId, sandboxId: $sandboxId)
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
24
90
|
function notSetUp(org) {
|
|
25
91
|
return `Builds are not set up for ${org || "this workspace"} yet. Ask an admin to configure the Code Assistant templates.`;
|
|
26
92
|
}
|
|
@@ -46,7 +112,13 @@ function useWebBuilderHost(routeOrg) {
|
|
|
46
112
|
const tokenRef = useRef(token);
|
|
47
113
|
tokenRef.current = token;
|
|
48
114
|
const catalog = useCodeAssistantCatalog(effectiveOrg);
|
|
49
|
-
const
|
|
115
|
+
const [templatesReload, setTemplatesReload] = useState(0);
|
|
116
|
+
const galleryTemplates = useConnectorTemplates(token, indexUrl, catalog.templates, templatesReload);
|
|
117
|
+
const reloadCatalog = catalog.reload;
|
|
118
|
+
const reloadTemplates = useCallback(() => {
|
|
119
|
+
reloadCatalog();
|
|
120
|
+
setTemplatesReload((n) => n + 1);
|
|
121
|
+
}, [reloadCatalog]);
|
|
50
122
|
const cdnOrigin = config.AWS_CDN_URL;
|
|
51
123
|
const gallery = useWebBuilderGallery(effectiveOrg, cdnOrigin);
|
|
52
124
|
const {
|
|
@@ -135,6 +207,7 @@ function useWebBuilderHost(routeOrg) {
|
|
|
135
207
|
const run = adoptAgentProject(channelId, title).then((adopted) => {
|
|
136
208
|
if (adopted) {
|
|
137
209
|
adoptedRef.current.add(channelId);
|
|
210
|
+
directChannels.delete(channelId);
|
|
138
211
|
AsyncStorage.setItem(ADOPTED_KEY, JSON.stringify([...adoptedRef.current].slice(-500))).catch(() => void 0);
|
|
139
212
|
}
|
|
140
213
|
return adopted;
|
|
@@ -142,6 +215,7 @@ function useWebBuilderHost(routeOrg) {
|
|
|
142
215
|
adoptingRef.current.set(channelId, run);
|
|
143
216
|
return run;
|
|
144
217
|
}, [adoptAgentProject]);
|
|
218
|
+
const instructionsByChannel = useRef(/* @__PURE__ */ new Map());
|
|
145
219
|
const jobs = useWebBuilderJobs(effectiveOrg);
|
|
146
220
|
const agentJob = useRef(null);
|
|
147
221
|
const sendAgentTurn = useCallback((channelId, text, files, task) => {
|
|
@@ -154,14 +228,18 @@ function useWebBuilderHost(routeOrg) {
|
|
|
154
228
|
lane: "agent",
|
|
155
229
|
startedAt: Date.now()
|
|
156
230
|
}) : Promise.resolve(null);
|
|
157
|
-
const adopted = ready.then(() => ensureAdopted(channelId, (task == null ? void 0 : task.siteTitle) || titleFromPrompt(stripAgentNote(text)) || "New site").catch(() => false));
|
|
231
|
+
const adopted = ready.then(() => ensureAdopted(channelId, (task == null ? void 0 : task.siteTitle) || siteNameFromRequest(text) || titleFromPrompt(stripAgentNote(text)) || "New site").catch(() => false));
|
|
158
232
|
Promise.all([adopted, recorded]).then(([, job]) => {
|
|
159
233
|
unsavedAgentChannels.current.delete(channelId);
|
|
160
234
|
if (job) agentJob.current = {
|
|
161
235
|
channelId,
|
|
162
236
|
job
|
|
163
237
|
};
|
|
164
|
-
|
|
238
|
+
const knowledge = instructionsByChannel.current.get(channelId);
|
|
239
|
+
const turn2 = knowledge ? `${text}
|
|
240
|
+
|
|
241
|
+
${projectInstructionsNote(knowledge)}` : text;
|
|
242
|
+
return chat.sendMessage(turn2, files, channelId, false, void 0, {
|
|
165
243
|
job: job == null ? void 0 : job.ref
|
|
166
244
|
});
|
|
167
245
|
}).then((outcome) => {
|
|
@@ -496,9 +574,9 @@ ${templateRemixNote(request.template)}` : request.text,
|
|
|
496
574
|
const rows = transcriptFromPosts(posts).map((m) => ({
|
|
497
575
|
id: m.id,
|
|
498
576
|
role: m.role,
|
|
499
|
-
content: m.role === "user" ?
|
|
577
|
+
content: m.role === "user" ? userBubbleText(m.content) : displayAgentText(m.content)
|
|
500
578
|
})).filter((m) => m.role === "user" || m.content.trim());
|
|
501
|
-
const pending = running && (turn == null ? void 0 : turn.text) ? turn.text
|
|
579
|
+
const pending = running && (turn == null ? void 0 : turn.text) ? userBubbleText(turn.text) : "";
|
|
502
580
|
if (pending && !rows.some((m) => m.role === "user" && pending.startsWith(m.content))) {
|
|
503
581
|
rows.push({
|
|
504
582
|
id: `pending-${turn == null ? void 0 : turn.startedAt}`,
|
|
@@ -564,7 +642,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
564
642
|
id: `${m.role}-${index}`,
|
|
565
643
|
role: m.role,
|
|
566
644
|
// The template note is for the agent; the person sees what they typed.
|
|
567
|
-
content: m.role === "user" ?
|
|
645
|
+
content: m.role === "user" ? userBubbleText(m.content) : displayAgentText(m.content),
|
|
568
646
|
attachments: m.attachments
|
|
569
647
|
})).filter((m) => m.role === "user" || m.content.trim()), [chat.messages]);
|
|
570
648
|
const withOpenRun = useCallback((rows) => {
|
|
@@ -636,10 +714,15 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
636
714
|
}),
|
|
637
715
|
proxyMissing: sandboxApi.proxyMissing
|
|
638
716
|
}), [activeChannelId, token, indexUrl, sandboxApi]);
|
|
717
|
+
const [goneSandboxIds, setGoneSandboxIds] = useState(() => /* @__PURE__ */ new Set());
|
|
718
|
+
const markGone = useCallback((sandboxId) => {
|
|
719
|
+
setGoneSandboxIds((prev) => prev.has(sandboxId) ? prev : new Set(prev).add(sandboxId));
|
|
720
|
+
}, []);
|
|
639
721
|
const keepAlive = useSandboxKeepAlive({
|
|
640
722
|
run: token || activeChannelId ? sandboxCall : null,
|
|
641
723
|
sandboxId: (_h = builds[0]) == null ? void 0 : _h.sandboxId,
|
|
642
|
-
live: activeChannelId !== null && Boolean((_i = builds[0]) == null ? void 0 : _i.sandboxId)
|
|
724
|
+
live: activeChannelId !== null && Boolean((_i = builds[0]) == null ? void 0 : _i.sandboxId),
|
|
725
|
+
onGone: markGone
|
|
643
726
|
});
|
|
644
727
|
const {
|
|
645
728
|
noteActivity
|
|
@@ -647,36 +730,66 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
647
730
|
useEffect(() => {
|
|
648
731
|
if (activeChannelId) noteActivity();
|
|
649
732
|
}, [activeChannelId, posts.length, chat.messages.length, noteActivity]);
|
|
650
|
-
const
|
|
733
|
+
const savedCopies = useRef(/* @__PURE__ */ new Map());
|
|
734
|
+
const backupRepoRef = useRef(null);
|
|
735
|
+
const resumePreview = useCallback(async (build, opts) => {
|
|
736
|
+
var _a2;
|
|
651
737
|
const channelId = activeChannelId;
|
|
652
738
|
if (!build.sandboxId || !tokenRef.current && !channelId) return "failed";
|
|
653
739
|
noteActivity();
|
|
654
|
-
const result = await
|
|
740
|
+
const result = await wakeSandbox(sandboxCall, {
|
|
655
741
|
sandboxId: build.sandboxId,
|
|
656
742
|
snapshotId: build.snapshotId,
|
|
743
|
+
backupRepo: backupRepoRef.current,
|
|
657
744
|
templateId: build.templateId,
|
|
658
|
-
previewUrl: build.previewUrl
|
|
745
|
+
previewUrl: build.previewUrl,
|
|
746
|
+
asked: opts == null ? void 0 : opts.asked
|
|
659
747
|
});
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
upsertProject(__spreadProps(__spreadValues({}, activeProject), {
|
|
664
|
-
previewUrl: result.previewUrl
|
|
665
|
-
}));
|
|
666
|
-
}
|
|
667
|
-
if (channelId) {
|
|
668
|
-
sandboxApi.persist({
|
|
669
|
-
channelId,
|
|
670
|
-
sandboxId: result.sandboxId,
|
|
671
|
-
sandboxUrl: result.previewUrl.split("?")[0],
|
|
672
|
-
snapshotId: build.snapshotId,
|
|
673
|
-
previousSandboxId: build.sandboxId
|
|
674
|
-
}).then((saved) => {
|
|
675
|
-
if (!saved.ok) console.warn("[WebBuilderNative] persist sandbox identity failed", saved.message);
|
|
676
|
-
}).catch(() => void 0);
|
|
677
|
-
}
|
|
678
|
-
}
|
|
748
|
+
const named = (_a2 = result.savedCopy) == null ? void 0 : _a2.snapshotId;
|
|
749
|
+
if (named) savedCopies.current.set(build.key, named);
|
|
750
|
+
if (result.outcome === "gone") markGone(build.sandboxId);
|
|
679
751
|
return result.outcome;
|
|
752
|
+
}, [activeChannelId, sandboxCall, noteActivity, markGone]);
|
|
753
|
+
const restorePreview = useCallback(async (build) => {
|
|
754
|
+
const channelId = activeChannelId;
|
|
755
|
+
if (!build.sandboxId || !tokenRef.current && !channelId) {
|
|
756
|
+
return {
|
|
757
|
+
ok: false,
|
|
758
|
+
reason: "Sign in again to restore this site."
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
noteActivity();
|
|
762
|
+
const snapshotId = savedCopies.current.get(build.key) || build.snapshotId;
|
|
763
|
+
const result = await restoreFromSavedCopy(sandboxCall, {
|
|
764
|
+
sandboxId: build.sandboxId,
|
|
765
|
+
snapshotId,
|
|
766
|
+
templateId: build.templateId
|
|
767
|
+
});
|
|
768
|
+
if (result.outcome !== "ok") return {
|
|
769
|
+
ok: false,
|
|
770
|
+
reason: result.reason,
|
|
771
|
+
snapshotId: snapshotId != null ? snapshotId : null
|
|
772
|
+
};
|
|
773
|
+
rememberRestored(build.key, result.sandboxId, result.previewUrl);
|
|
774
|
+
if (activeProject && activeProject.previewUrl === build.previewUrl) {
|
|
775
|
+
upsertProject(__spreadProps(__spreadValues({}, activeProject), {
|
|
776
|
+
previewUrl: result.previewUrl
|
|
777
|
+
}));
|
|
778
|
+
}
|
|
779
|
+
if (channelId && !directChannels.has(channelId)) {
|
|
780
|
+
sandboxApi.persist({
|
|
781
|
+
channelId,
|
|
782
|
+
sandboxId: result.sandboxId,
|
|
783
|
+
sandboxUrl: result.previewUrl.split("?")[0],
|
|
784
|
+
snapshotId: snapshotId != null ? snapshotId : null,
|
|
785
|
+
previousSandboxId: build.sandboxId
|
|
786
|
+
}).then((saved) => {
|
|
787
|
+
if (!saved.ok) console.warn("[WebBuilderNative] persist sandbox identity failed", saved.message);
|
|
788
|
+
}).catch(() => void 0);
|
|
789
|
+
}
|
|
790
|
+
return {
|
|
791
|
+
ok: true
|
|
792
|
+
};
|
|
680
793
|
}, [activeChannelId, sandboxCall, noteActivity, sandboxApi, rememberRestored, activeProject, upsertProject]);
|
|
681
794
|
const redoFor = useRef(/* @__PURE__ */ new Map());
|
|
682
795
|
const undo = useCallback(async (build) => {
|
|
@@ -714,6 +827,144 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
714
827
|
const result = await sandboxCall(WEBBUILDER_EXPORT_ZIP_ACTION, exportZipParams(build.sandboxId, build.title), 10 * 60 * 1e3).catch(() => null);
|
|
715
828
|
return exportZipUrl(result);
|
|
716
829
|
}, [sandboxCall, noteActivity]);
|
|
830
|
+
const apollo = useApolloClient();
|
|
831
|
+
const publishTools = useMemo(() => ({
|
|
832
|
+
run: (build, action, params, timeoutMs = 6e4) => sandboxCall(action, __spreadValues(__spreadValues({}, build.sandboxId ? {
|
|
833
|
+
sandbox_id: build.sandboxId
|
|
834
|
+
} : {}), params), timeoutMs).catch((err) => ({
|
|
835
|
+
successful: false,
|
|
836
|
+
error: err instanceof Error ? err.message : String(err)
|
|
837
|
+
})),
|
|
838
|
+
review: async (build) => {
|
|
839
|
+
var _a2, _b2;
|
|
840
|
+
if (!activeChannelId || !build.sandboxId) return null;
|
|
841
|
+
const result = await apollo.query({
|
|
842
|
+
query: PRE_PUBLISH_REVIEW_QUERY,
|
|
843
|
+
variables: {
|
|
844
|
+
channelId: activeChannelId,
|
|
845
|
+
sandboxId: build.sandboxId
|
|
846
|
+
},
|
|
847
|
+
fetchPolicy: "network-only"
|
|
848
|
+
});
|
|
849
|
+
return (_b2 = (_a2 = result.data) == null ? void 0 : _a2.aiCodePrePublishReview) != null ? _b2 : null;
|
|
850
|
+
}
|
|
851
|
+
}), [sandboxCall, apollo, activeChannelId]);
|
|
852
|
+
const projectTools = useMemo(() => ({
|
|
853
|
+
loadSettings: async (channelId) => {
|
|
854
|
+
var _a2, _b2;
|
|
855
|
+
const result = await apollo.query({
|
|
856
|
+
query: PROJECT_SETTINGS_QUERY,
|
|
857
|
+
variables: {
|
|
858
|
+
channelId
|
|
859
|
+
},
|
|
860
|
+
fetchPolicy: "network-only"
|
|
861
|
+
});
|
|
862
|
+
const raw = (_b2 = (_a2 = result.data) == null ? void 0 : _a2.aiCodeProjectSettings) != null ? _b2 : null;
|
|
863
|
+
const settings = parseProjectSettings(raw);
|
|
864
|
+
if (settings) instructionsByChannel.current.set(channelId, settings.instructions);
|
|
865
|
+
return raw;
|
|
866
|
+
},
|
|
867
|
+
updateSettings: async (channelId, patch) => {
|
|
868
|
+
var _a2;
|
|
869
|
+
const result = await apollo.mutate({
|
|
870
|
+
mutation: UPDATE_PROJECT_SETTINGS_MUTATION,
|
|
871
|
+
variables: {
|
|
872
|
+
channelId,
|
|
873
|
+
input: patch
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
const raw = (_a2 = result.data) == null ? void 0 : _a2.aiCodeUpdateProjectSettings;
|
|
877
|
+
if (readSettingsUpdateReply(raw).ok) {
|
|
878
|
+
if (typeof patch.instructions === "string") {
|
|
879
|
+
instructionsByChannel.current.set(channelId, patch.instructions);
|
|
880
|
+
}
|
|
881
|
+
const row = projects.find((p) => p.channelId === channelId);
|
|
882
|
+
if (typeof patch.title === "string" && row) upsertProject(__spreadProps(__spreadValues({}, row), {
|
|
883
|
+
title: patch.title
|
|
884
|
+
}));
|
|
885
|
+
}
|
|
886
|
+
return raw;
|
|
887
|
+
},
|
|
888
|
+
deleteProject: async (channelId) => {
|
|
889
|
+
var _a2, _b2;
|
|
890
|
+
try {
|
|
891
|
+
const result2 = await apollo.mutate({
|
|
892
|
+
mutation: DELETE_PROJECT_MUTATION,
|
|
893
|
+
variables: {
|
|
894
|
+
channelId
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
const reply = readDeleteReply((_a2 = result2.data) == null ? void 0 : _a2.aiCodeDeleteProject);
|
|
898
|
+
if (reply.ok) instructionsByChannel.current.delete(channelId);
|
|
899
|
+
return reply;
|
|
900
|
+
} catch (err) {
|
|
901
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
902
|
+
if (!OUTDATED_SERVER_RE.test(message)) return {
|
|
903
|
+
ok: false,
|
|
904
|
+
error: message
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
const result = await apollo.mutate({
|
|
908
|
+
mutation: DELETE_CHANNEL_MUTATION,
|
|
909
|
+
variables: {
|
|
910
|
+
id: channelId
|
|
911
|
+
}
|
|
912
|
+
});
|
|
913
|
+
const done = ((_b2 = result.data) == null ? void 0 : _b2.deleteChannel) !== false;
|
|
914
|
+
return done ? {
|
|
915
|
+
ok: true
|
|
916
|
+
} : {
|
|
917
|
+
ok: false,
|
|
918
|
+
error: "The project could not be deleted."
|
|
919
|
+
};
|
|
920
|
+
},
|
|
921
|
+
pushToGithub: async (build, repoName) => {
|
|
922
|
+
var _a2;
|
|
923
|
+
if (!build.sandboxId) return {
|
|
924
|
+
ok: false,
|
|
925
|
+
message: "Wake the preview to push to GitHub."
|
|
926
|
+
};
|
|
927
|
+
noteActivity();
|
|
928
|
+
try {
|
|
929
|
+
const result = await apollo.mutate({
|
|
930
|
+
mutation: PUSH_TO_GITHUB_MUTATION,
|
|
931
|
+
variables: {
|
|
932
|
+
sandboxId: build.sandboxId,
|
|
933
|
+
repoName,
|
|
934
|
+
channelId: activeChannelId
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
const payload = (_a2 = result.data) == null ? void 0 : _a2.aiCodePushToGithub;
|
|
938
|
+
return (payload == null ? void 0 : payload.success) ? {
|
|
939
|
+
ok: true,
|
|
940
|
+
message: payload.message || "Push started. Follow along in the chat."
|
|
941
|
+
} : {
|
|
942
|
+
ok: false,
|
|
943
|
+
message: "The push didn't start. Try again in a moment."
|
|
944
|
+
};
|
|
945
|
+
} catch (e) {
|
|
946
|
+
return {
|
|
947
|
+
ok: false,
|
|
948
|
+
message: "The push didn't start. Check your connection and try again."
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
integrations: async (search) => {
|
|
953
|
+
var _a2, _b2;
|
|
954
|
+
const result = await apollo.query({
|
|
955
|
+
query: INTEGRATION_CATALOG_QUERY,
|
|
956
|
+
variables: search ? {
|
|
957
|
+
search
|
|
958
|
+
} : {},
|
|
959
|
+
fetchPolicy: "network-only"
|
|
960
|
+
});
|
|
961
|
+
return (_b2 = (_a2 = result.data) == null ? void 0 : _a2.integrationConnectors) != null ? _b2 : [];
|
|
962
|
+
}
|
|
963
|
+
}), [apollo, projects, upsertProject, noteActivity, activeChannelId]);
|
|
964
|
+
useEffect(() => {
|
|
965
|
+
if (!activeChannelId) return;
|
|
966
|
+
projectTools.loadSettings(activeChannelId).catch(() => void 0);
|
|
967
|
+
}, [activeChannelId]);
|
|
717
968
|
const codeApi = useMemo(() => createCodeWorkspace(sandboxCall, (edit) => {
|
|
718
969
|
handEditsRef.current = [...handEditsRef.current.filter((e) => e.file !== edit.file), edit];
|
|
719
970
|
}), [sandboxCall]);
|
|
@@ -735,6 +986,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
735
986
|
};
|
|
736
987
|
}, [activeChannelId, readBackupRepo, newestBuildAt]);
|
|
737
988
|
const siteBackupRepo = (backupRepo == null ? void 0 : backupRepo.channelId) === activeChannelId ? backupRepo.repo : null;
|
|
989
|
+
backupRepoRef.current = siteBackupRepo;
|
|
738
990
|
const code = useMemo(() => {
|
|
739
991
|
const target = (build) => ({
|
|
740
992
|
sandboxId: build.sandboxId,
|
|
@@ -762,7 +1014,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
762
1014
|
};
|
|
763
1015
|
}, [codeApi, siteLiveUrl, siteBackupRepo]);
|
|
764
1016
|
const [deployToCloudflare] = useAiCodeDeployToCloudflareMutation({});
|
|
765
|
-
const publish = useCallback(async (build, projectName) => {
|
|
1017
|
+
const publish = useCallback(async (build, projectName, customDomain) => {
|
|
766
1018
|
var _a2;
|
|
767
1019
|
if (!build.sandboxId || !activeChannelId) {
|
|
768
1020
|
return {
|
|
@@ -771,18 +1023,24 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
771
1023
|
};
|
|
772
1024
|
}
|
|
773
1025
|
if (build.origin === "agent") {
|
|
774
|
-
sendAgentTurn(activeChannelId, agentPublishMessage(build, projectName));
|
|
1026
|
+
sendAgentTurn(activeChannelId, agentPublishMessage(build, projectName, customDomain));
|
|
775
1027
|
return {
|
|
776
1028
|
ok: true
|
|
777
1029
|
};
|
|
778
1030
|
}
|
|
779
1031
|
try {
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
1032
|
+
const variables = {
|
|
1033
|
+
sandboxId: build.sandboxId,
|
|
1034
|
+
projectName,
|
|
1035
|
+
channelId: activeChannelId
|
|
1036
|
+
};
|
|
1037
|
+
const result = customDomain ? await apollo.mutate({
|
|
1038
|
+
mutation: DEPLOY_WITH_DOMAIN_MUTATION,
|
|
1039
|
+
variables: __spreadProps(__spreadValues({}, variables), {
|
|
1040
|
+
customDomain
|
|
1041
|
+
})
|
|
1042
|
+
}) : await deployToCloudflare({
|
|
1043
|
+
variables
|
|
786
1044
|
});
|
|
787
1045
|
const payload = (_a2 = result.data) == null ? void 0 : _a2.aiCodeDeployToCloudflare;
|
|
788
1046
|
if (payload == null ? void 0 : payload.success) return {
|
|
@@ -800,7 +1058,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
800
1058
|
message: "Publishing didn't start. Check your connection and try again."
|
|
801
1059
|
};
|
|
802
1060
|
}
|
|
803
|
-
}, [deployToCloudflare, activeChannelId, sendAgentTurn]);
|
|
1061
|
+
}, [deployToCloudflare, activeChannelId, sendAgentTurn, apollo]);
|
|
804
1062
|
let startBlocked = null;
|
|
805
1063
|
if (!token && !cdecli.channelConnected) {
|
|
806
1064
|
startBlocked = session.ready && session.error ? session.error : "Connecting to Web Builder\u2026";
|
|
@@ -812,7 +1070,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
812
1070
|
projectsHasMore: gallery.hasMore,
|
|
813
1071
|
refreshProjects,
|
|
814
1072
|
loadMoreProjects: gallery.loadMore,
|
|
815
|
-
templates:
|
|
1073
|
+
templates: galleryTemplates,
|
|
816
1074
|
templatesLoading: catalog.loading,
|
|
817
1075
|
templatesError: catalog.error,
|
|
818
1076
|
reloadTemplates,
|
|
@@ -829,9 +1087,13 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
829
1087
|
hostChat,
|
|
830
1088
|
publish,
|
|
831
1089
|
resumePreview,
|
|
1090
|
+
restorePreview,
|
|
1091
|
+
goneSandboxIds,
|
|
832
1092
|
undo,
|
|
833
1093
|
redo,
|
|
834
1094
|
downloadCode,
|
|
1095
|
+
publishTools,
|
|
1096
|
+
projectTools,
|
|
835
1097
|
code
|
|
836
1098
|
};
|
|
837
1099
|
}export{useWebBuilderHost};//# sourceMappingURL=useWebBuilderHost.js.map
|