camox 0.75.0 → 0.76.1
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/dist/core/editing/createEditableBlock.js +1077 -1681
- package/dist/core/editing/fieldSlot.js +251 -0
- package/dist/core/editing/useFieldSlot.js +159 -0
- package/dist/core/layoutContext.d.ts +2 -0
- package/dist/core/layoutContext.js +27 -1
- package/dist/features/canvas/CanvasPageFrame.js +2 -2
- package/dist/features/canvas/CanvasPreviewPageSlot.js +1 -1
- package/dist/features/canvas/canvasCameraController.js +595 -0
- package/dist/features/canvas/useCanvasCamera.js +141 -587
- package/dist/features/canvas/useCanvasFrame.js +1 -1
- package/dist/features/page/DerivedPageContent.js +4 -8
- package/dist/features/preview/components/AssetLightbox.js +6 -65
- package/dist/features/preview/components/CanvasPreview.js +2 -2
- package/dist/features/preview/components/Frame.js +3 -3
- package/dist/features/preview/components/ItemFieldsEditor.js +376 -460
- package/dist/features/preview/components/Overlays.js +4 -9
- package/dist/features/preview/components/PreviewPanel.js +3 -3
- package/dist/features/preview/components/RemovedBlockPlaceholder.js +2 -2
- package/dist/features/preview/components/SelectionEditor.js +285 -339
- package/dist/features/preview/components/ZoomableImage.js +105 -0
- package/dist/features/preview/components/contentFieldSchema.js +3 -1
- package/dist/features/preview/components/useFieldWriter.js +30 -51
- package/dist/features/preview/components/useRecordView.js +3 -3
- package/dist/features/preview/overlayMessages.js +20 -58
- package/dist/features/preview/previewStore.js +6 -123
- package/dist/features/preview/repeatableItemPath.js +47 -0
- package/dist/features/provider/AuthenticatedCamoxProvider.js +75 -63
- package/dist/features/renderer/RendererApp.js +6 -6
- package/dist/features/renderer/RendererFrames.js +2 -2
- package/dist/features/renderer/rendererHost.js +1 -1
- package/dist/features/routes/pageRuntime.d.ts +8 -12
- package/dist/features/routes/pageRuntime.js +26 -106
- package/dist/features/runtime/pageApp.js +1 -1
- package/dist/features/runtime/pageRead.js +105 -0
- package/dist/features/runtime/reader.d.ts +25 -0
- package/dist/features/runtime/reader.js +142 -0
- package/dist/features/runtime/runtime.d.ts +9 -3
- package/dist/features/runtime/runtime.js +608 -776
- package/dist/features/sdkBundle/buildSdkBundle.d.ts +5 -0
- package/dist/features/sdkBundle/buildSdkBundle.js +9 -3
- package/dist/features/studio/components/ChatWidget.js +137 -121
- package/dist/features/studio/components/ClearThread.js +121 -0
- package/dist/features/studio/components/DeleteDraftDialog.js +67 -65
- package/dist/features/studio/components/DraftBar.js +60 -49
- package/dist/features/studio/components/DraftNotices.js +149 -0
- package/dist/features/studio/components/DraftsControl.js +217 -180
- package/dist/features/studio/components/DraftsSheet.js +446 -0
- package/dist/features/studio/components/PublishedTab.js +511 -0
- package/dist/features/studio/components/ReviewDraftDialog.js +104 -89
- package/dist/features/studio/components/SheetTable.js +46 -0
- package/dist/features/studio/components/Specialists.js +1 -1
- package/dist/features/studio/components/ThreadMessages.js +227 -176
- package/dist/features/studio/draftLabel.js +15 -1
- package/dist/features/studio/draftNotice.js +1 -0
- package/dist/features/studio/showInCanvas.js +9 -19
- package/dist/features/studio/studioStore.js +5 -5
- package/dist/features/studio/useArchiveDraft.js +60 -0
- package/dist/features/studio/useEditorSelection.js +8 -19
- package/dist/features/studio/useRestoreDraft.js +70 -0
- package/dist/features/studio/viewSwitch.js +19 -11
- package/dist/lib/draft-scope.d.ts +1 -1
- package/dist/lib/draft-scope.js +6 -3
- package/dist/lib/queries.js +12 -1
- package/dist/lib/studio-reads.js +22 -0
- package/dist/lib/use-project-room.js +19 -13
- package/dist/lib/use-thread.js +1 -1
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/dist/core/hooks/useFieldSelection.js +0 -67
- package/dist/core/hooks/useIsEditable.js +0 -21
- package/dist/core/hooks/useOverlayMessage.js +0 -70
|
@@ -15,6 +15,11 @@ export interface BuiltSdkBundle {
|
|
|
15
15
|
name: string;
|
|
16
16
|
/** Its files, every one at the root: entries, chunks and assets. */
|
|
17
17
|
dir: string;
|
|
18
|
+
/**
|
|
19
|
+
* The modules a page loads at first paint, by id, for the browser bundle as just built: what
|
|
20
|
+
* every visitor downloads, before anything loads lazily.
|
|
21
|
+
*/
|
|
22
|
+
firstPaint?: string[];
|
|
18
23
|
}
|
|
19
24
|
export type SdkBundleBuild = Record<SdkBundleTarget, BuiltSdkBundle>;
|
|
20
25
|
/** The lockfile a website installed from, and the website's importer in it. */
|
|
@@ -62,7 +62,7 @@ async function buildSdkBundle({ root, outDir, settings }) {
|
|
|
62
62
|
importer,
|
|
63
63
|
target
|
|
64
64
|
});
|
|
65
|
-
const entries = await buildTarget({
|
|
65
|
+
const { entries, firstPaint } = await buildTarget({
|
|
66
66
|
root: resolve(root),
|
|
67
67
|
dir,
|
|
68
68
|
target,
|
|
@@ -79,7 +79,8 @@ async function buildSdkBundle({ root, outDir, settings }) {
|
|
|
79
79
|
await writeFile(join(dir, SDK_BUNDLE_MANIFEST), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
80
80
|
result[target] = {
|
|
81
81
|
name: names[target],
|
|
82
|
-
dir
|
|
82
|
+
dir,
|
|
83
|
+
...firstPaint ? { firstPaint } : {}
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
86
|
return result;
|
|
@@ -164,9 +165,11 @@ async function buildTarget({ root, dir, target, specifiers, names, settings }) {
|
|
|
164
165
|
}
|
|
165
166
|
}
|
|
166
167
|
};
|
|
168
|
+
let firstPaint;
|
|
167
169
|
if (!workerd) {
|
|
168
170
|
const input = config.build.rolldownOptions.input;
|
|
169
171
|
const pageModules = await modulesLoadedStatically(config, Object.fromEntries(specifiers.filter(loadsAtFirstPaint).map((specifier) => [entryName(specifier), input[entryName(specifier)]])));
|
|
172
|
+
firstPaint = [...pageModules];
|
|
170
173
|
const output = config.build.rolldownOptions.output;
|
|
171
174
|
output.codeSplitting = { groups: [{
|
|
172
175
|
name: "react",
|
|
@@ -179,7 +182,10 @@ async function buildTarget({ root, dir, target, specifiers, names, settings }) {
|
|
|
179
182
|
}] };
|
|
180
183
|
}
|
|
181
184
|
await build(config);
|
|
182
|
-
return
|
|
185
|
+
return {
|
|
186
|
+
entries: Object.fromEntries(specifiers.map((specifier) => [specifier, sdkBundleEntryFile(specifier)])),
|
|
187
|
+
...firstPaint ? { firstPaint } : {}
|
|
188
|
+
};
|
|
183
189
|
}
|
|
184
190
|
/**
|
|
185
191
|
* The chunks a page loads at first paint, beside the entry files it imports: its code, React, and
|
|
@@ -5,13 +5,14 @@ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
|
|
|
5
5
|
import { cn } from "../../../lib/utils.js";
|
|
6
6
|
import { BOTTOM_CARD_EDGES, CARD_BODY_EDGES } from "../../preview/components/SidebarStack.js";
|
|
7
7
|
import { studioStore } from "../studioStore.js";
|
|
8
|
+
import { useRestoreDraft } from "../useRestoreDraft.js";
|
|
9
|
+
import { ThreadMessages } from "./ThreadMessages.js";
|
|
8
10
|
import { FollowAgentContext } from "../followAgentContext.js";
|
|
9
11
|
import { useThread } from "../../../lib/use-thread.js";
|
|
10
12
|
import { useAgentRunToast } from "../agentRunToast.js";
|
|
11
13
|
import { EditorWhereContext } from "../editorWhereContext.js";
|
|
12
14
|
import { useEditorSelection } from "../useEditorSelection.js";
|
|
13
15
|
import { ThreadComposer, useComposerCarrier } from "./ThreadComposer.js";
|
|
14
|
-
import { ThreadMessages } from "./ThreadMessages.js";
|
|
15
16
|
import { c } from "react/compiler-runtime";
|
|
16
17
|
import * as React from "react";
|
|
17
18
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -24,9 +25,10 @@ import { EMPTY_THREAD_VIEW } from "@camox/api-contract/threads";
|
|
|
24
25
|
* studio it is only hidden: the studio keeps following the editor's runs there. It follows
|
|
25
26
|
* where the studio is: the editor's own Live thread on Live, and the draft's thread in a draft.
|
|
26
27
|
* When the agent on Live hands the editor's request off to a draft, the studio that asked enters
|
|
27
|
-
* it, if it still shows Live; the card the Live turn ends on opens it too
|
|
28
|
-
* agent where the editor is: the page they look at, with
|
|
29
|
-
* cleared it from the composer, or the Canvas with no page
|
|
28
|
+
* it, if it still shows Live; the card the Live turn ends on opens it too, or restores it once
|
|
29
|
+
* it's archived. Each message tells the agent where the editor is: the page they look at, with
|
|
30
|
+
* what they selected on it unless they cleared it from the composer, or the Canvas with no page
|
|
31
|
+
* selected. A message the studio sends
|
|
30
32
|
* from elsewhere (`studioStore`'s `sendToAgent`), such as Fix with agent's, goes out through the
|
|
31
33
|
* thread it follows, as if the editor had sent it. In a draft, it tells the studio whether a turn
|
|
32
34
|
* is going in the draft's thread, whoever started it, which publishing waits for.
|
|
@@ -135,7 +137,7 @@ function CurrentThread() {
|
|
|
135
137
|
return t4;
|
|
136
138
|
}
|
|
137
139
|
function Thread(t0) {
|
|
138
|
-
const $ = c(
|
|
140
|
+
const $ = c(52);
|
|
139
141
|
const { apiUrl, projectId, draftId, onEnterDraft, onOpenDraft, composerCarry } = t0;
|
|
140
142
|
let t1;
|
|
141
143
|
if ($[0] !== onEnterDraft) {
|
|
@@ -145,10 +147,22 @@ function Thread(t0) {
|
|
|
145
147
|
} else t1 = $[1];
|
|
146
148
|
const { view, sending, send, stop, error, touched } = useThread(apiUrl, projectId, draftId, t1);
|
|
147
149
|
useAgentRunToast(view, draftId);
|
|
150
|
+
const { restore } = useRestoreDraft(projectId);
|
|
148
151
|
let t2;
|
|
152
|
+
if ($[2] !== restore || $[3] !== view.messages) {
|
|
153
|
+
t2 = (restored) => {
|
|
154
|
+
const card = view.messages.find((message) => message.from === "draft" && message.draftId === restored);
|
|
155
|
+
restore(restored, card?.from === "draft" ? card.name : void 0);
|
|
156
|
+
};
|
|
157
|
+
$[2] = restore;
|
|
158
|
+
$[3] = view.messages;
|
|
159
|
+
$[4] = t2;
|
|
160
|
+
} else t2 = $[4];
|
|
161
|
+
const restoreCard = t2;
|
|
149
162
|
let t3;
|
|
150
|
-
|
|
151
|
-
|
|
163
|
+
let t4;
|
|
164
|
+
if ($[5] !== draftId || $[6] !== view.running) {
|
|
165
|
+
t3 = () => {
|
|
152
166
|
if (!draftId) return;
|
|
153
167
|
studioStore.trigger.agentWorking({
|
|
154
168
|
draftId,
|
|
@@ -159,167 +173,169 @@ function Thread(t0) {
|
|
|
159
173
|
working: false
|
|
160
174
|
});
|
|
161
175
|
};
|
|
162
|
-
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
176
|
+
t4 = [draftId, view.running];
|
|
177
|
+
$[5] = draftId;
|
|
178
|
+
$[6] = view.running;
|
|
179
|
+
$[7] = t3;
|
|
180
|
+
$[8] = t4;
|
|
167
181
|
} else {
|
|
168
|
-
|
|
169
|
-
|
|
182
|
+
t3 = $[7];
|
|
183
|
+
t4 = $[8];
|
|
170
184
|
}
|
|
171
|
-
React.useEffect(
|
|
185
|
+
React.useEffect(t3, t4);
|
|
172
186
|
const follow = React.use(FollowAgentContext);
|
|
173
|
-
let t4;
|
|
174
|
-
if ($[6] !== follow) {
|
|
175
|
-
t4 = (batch) => follow?.receive(batch);
|
|
176
|
-
$[6] = follow;
|
|
177
|
-
$[7] = t4;
|
|
178
|
-
} else t4 = $[7];
|
|
179
|
-
const followTouched = React.useEffectEvent(t4);
|
|
180
187
|
let t5;
|
|
181
|
-
if ($[
|
|
182
|
-
t5 = () =>
|
|
183
|
-
|
|
184
|
-
};
|
|
185
|
-
$[8] = followTouched;
|
|
186
|
-
$[9] = touched;
|
|
188
|
+
if ($[9] !== follow) {
|
|
189
|
+
t5 = (batch) => follow?.receive(batch);
|
|
190
|
+
$[9] = follow;
|
|
187
191
|
$[10] = t5;
|
|
188
192
|
} else t5 = $[10];
|
|
193
|
+
const followTouched = React.useEffectEvent(t5);
|
|
189
194
|
let t6;
|
|
190
|
-
if ($[11] !== touched) {
|
|
191
|
-
t6 =
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
195
|
+
if ($[11] !== followTouched || $[12] !== touched) {
|
|
196
|
+
t6 = () => {
|
|
197
|
+
if (touched) followTouched(touched.batch);
|
|
198
|
+
};
|
|
199
|
+
$[11] = followTouched;
|
|
200
|
+
$[12] = touched;
|
|
201
|
+
$[13] = t6;
|
|
202
|
+
} else t6 = $[13];
|
|
203
|
+
let t7;
|
|
204
|
+
if ($[14] !== touched) {
|
|
205
|
+
t7 = [touched];
|
|
206
|
+
$[14] = touched;
|
|
207
|
+
$[15] = t7;
|
|
208
|
+
} else t7 = $[15];
|
|
209
|
+
React.useEffect(t6, t7);
|
|
196
210
|
const where = React.use(EditorWhereContext);
|
|
197
211
|
const selection = useEditorSelection(where);
|
|
198
|
-
let
|
|
199
|
-
if ($[
|
|
200
|
-
|
|
212
|
+
let t8;
|
|
213
|
+
if ($[16] !== selection) {
|
|
214
|
+
t8 = selection ? JSON.stringify([
|
|
201
215
|
selection.blockId,
|
|
202
216
|
selection.itemId,
|
|
203
217
|
selection.recordId,
|
|
204
218
|
selection.fieldName
|
|
205
219
|
]) : null;
|
|
206
|
-
$[
|
|
207
|
-
$[
|
|
208
|
-
} else
|
|
209
|
-
const selectionKey =
|
|
220
|
+
$[16] = selection;
|
|
221
|
+
$[17] = t8;
|
|
222
|
+
} else t8 = $[17];
|
|
223
|
+
const selectionKey = t8;
|
|
210
224
|
const [cleared, setCleared] = React.useState(null);
|
|
211
225
|
if (cleared !== null && selectionKey !== cleared) setCleared(null);
|
|
212
226
|
const carried = selection && selectionKey !== cleared ? selection : void 0;
|
|
213
|
-
let
|
|
214
|
-
if ($[
|
|
215
|
-
|
|
227
|
+
let t9;
|
|
228
|
+
if ($[18] !== carried || $[19] !== follow || $[20] !== send || $[21] !== where) {
|
|
229
|
+
t9 = (text) => {
|
|
216
230
|
follow?.resume();
|
|
217
231
|
send(text, where?.on === "page" && carried ? {
|
|
218
232
|
...where,
|
|
219
233
|
selection: carried
|
|
220
234
|
} : where);
|
|
221
235
|
};
|
|
222
|
-
$[
|
|
223
|
-
$[
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
} else
|
|
228
|
-
const sendFollowing =
|
|
236
|
+
$[18] = carried;
|
|
237
|
+
$[19] = follow;
|
|
238
|
+
$[20] = send;
|
|
239
|
+
$[21] = where;
|
|
240
|
+
$[22] = t9;
|
|
241
|
+
} else t9 = $[22];
|
|
242
|
+
const sendFollowing = t9;
|
|
229
243
|
const waiting = useSelector(studioStore, _temp);
|
|
230
|
-
let t9;
|
|
231
|
-
if ($[20] !== sendFollowing) {
|
|
232
|
-
t9 = () => {
|
|
233
|
-
for (const message of studioStore.getSnapshot().context.agentMessages) {
|
|
234
|
-
studioStore.trigger.takeAgentMessage({ id: message.id });
|
|
235
|
-
sendFollowing(message.text);
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
$[20] = sendFollowing;
|
|
239
|
-
$[21] = t9;
|
|
240
|
-
} else t9 = $[21];
|
|
241
|
-
const sendWaiting = React.useEffectEvent(t9);
|
|
242
244
|
let t10;
|
|
243
|
-
if ($[
|
|
245
|
+
if ($[23] !== sendFollowing) {
|
|
244
246
|
t10 = () => {
|
|
245
|
-
|
|
247
|
+
for (const message_0 of studioStore.getSnapshot().context.agentMessages) {
|
|
248
|
+
studioStore.trigger.takeAgentMessage({ id: message_0.id });
|
|
249
|
+
sendFollowing(message_0.text);
|
|
250
|
+
}
|
|
246
251
|
};
|
|
247
|
-
$[
|
|
248
|
-
$[23] = waiting;
|
|
252
|
+
$[23] = sendFollowing;
|
|
249
253
|
$[24] = t10;
|
|
250
254
|
} else t10 = $[24];
|
|
255
|
+
const sendWaiting = React.useEffectEvent(t10);
|
|
251
256
|
let t11;
|
|
252
|
-
if ($[25] !== waiting) {
|
|
253
|
-
t11 =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
if ($[25] !== sendWaiting || $[26] !== waiting) {
|
|
258
|
+
t11 = () => {
|
|
259
|
+
if (waiting.length > 0) sendWaiting();
|
|
260
|
+
};
|
|
261
|
+
$[25] = sendWaiting;
|
|
262
|
+
$[26] = waiting;
|
|
263
|
+
$[27] = t11;
|
|
264
|
+
} else t11 = $[27];
|
|
258
265
|
let t12;
|
|
259
|
-
if ($[
|
|
260
|
-
t12 =
|
|
266
|
+
if ($[28] !== waiting) {
|
|
267
|
+
t12 = [waiting];
|
|
268
|
+
$[28] = waiting;
|
|
269
|
+
$[29] = t12;
|
|
270
|
+
} else t12 = $[29];
|
|
271
|
+
React.useEffect(t11, t12);
|
|
272
|
+
let t13;
|
|
273
|
+
if ($[30] !== onOpenDraft || $[31] !== restoreCard || $[32] !== sending || $[33] !== view) {
|
|
274
|
+
t13 = /* @__PURE__ */ jsx(ThreadMessages, {
|
|
261
275
|
view,
|
|
262
276
|
sending,
|
|
263
|
-
onOpenDraft
|
|
277
|
+
onOpenDraft,
|
|
278
|
+
onRestoreDraft: restoreCard
|
|
264
279
|
});
|
|
265
|
-
$[
|
|
266
|
-
$[
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
280
|
+
$[30] = onOpenDraft;
|
|
281
|
+
$[31] = restoreCard;
|
|
282
|
+
$[32] = sending;
|
|
283
|
+
$[33] = view;
|
|
284
|
+
$[34] = t13;
|
|
285
|
+
} else t13 = $[34];
|
|
286
|
+
let t14;
|
|
287
|
+
if ($[35] !== error) {
|
|
288
|
+
t14 = error && /* @__PURE__ */ jsx("p", {
|
|
273
289
|
role: "alert",
|
|
274
290
|
className: "text-destructive px-2 pt-2 text-sm",
|
|
275
291
|
children: error
|
|
276
292
|
});
|
|
277
|
-
$[
|
|
278
|
-
$[
|
|
279
|
-
} else
|
|
280
|
-
let t14;
|
|
281
|
-
if ($[33] !== carried?.path) {
|
|
282
|
-
t14 = carried?.path.at(-1);
|
|
283
|
-
$[33] = carried?.path;
|
|
284
|
-
$[34] = t14;
|
|
285
|
-
} else t14 = $[34];
|
|
293
|
+
$[35] = error;
|
|
294
|
+
$[36] = t14;
|
|
295
|
+
} else t14 = $[36];
|
|
286
296
|
let t15;
|
|
287
|
-
if ($[
|
|
288
|
-
t15 = ()
|
|
289
|
-
$[
|
|
290
|
-
$[
|
|
291
|
-
} else t15 = $[
|
|
297
|
+
if ($[37] !== carried?.path) {
|
|
298
|
+
t15 = carried?.path.at(-1);
|
|
299
|
+
$[37] = carried?.path;
|
|
300
|
+
$[38] = t15;
|
|
301
|
+
} else t15 = $[38];
|
|
292
302
|
let t16;
|
|
293
|
-
if ($[
|
|
294
|
-
t16 =
|
|
303
|
+
if ($[39] !== selectionKey) {
|
|
304
|
+
t16 = () => selectionKey !== null && setCleared(selectionKey);
|
|
305
|
+
$[39] = selectionKey;
|
|
306
|
+
$[40] = t16;
|
|
307
|
+
} else t16 = $[40];
|
|
308
|
+
let t17;
|
|
309
|
+
if ($[41] !== composerCarry || $[42] !== sendFollowing || $[43] !== stop || $[44] !== t15 || $[45] !== t16 || $[46] !== view.running) {
|
|
310
|
+
t17 = /* @__PURE__ */ jsx(ThreadComposer, {
|
|
295
311
|
onSend: sendFollowing,
|
|
296
312
|
onStop: stop,
|
|
297
|
-
selection:
|
|
298
|
-
onClearSelection:
|
|
313
|
+
selection: t15,
|
|
314
|
+
onClearSelection: t16,
|
|
299
315
|
running: view.running,
|
|
300
316
|
carry: composerCarry
|
|
301
317
|
});
|
|
302
|
-
$[
|
|
303
|
-
$[
|
|
304
|
-
$[
|
|
305
|
-
$[
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
308
|
-
$[43] = t16;
|
|
309
|
-
} else t16 = $[43];
|
|
310
|
-
let t17;
|
|
311
|
-
if ($[44] !== t12 || $[45] !== t13 || $[46] !== t16) {
|
|
312
|
-
t17 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
313
|
-
t12,
|
|
314
|
-
t13,
|
|
315
|
-
t16
|
|
316
|
-
] });
|
|
317
|
-
$[44] = t12;
|
|
318
|
-
$[45] = t13;
|
|
319
|
-
$[46] = t16;
|
|
318
|
+
$[41] = composerCarry;
|
|
319
|
+
$[42] = sendFollowing;
|
|
320
|
+
$[43] = stop;
|
|
321
|
+
$[44] = t15;
|
|
322
|
+
$[45] = t16;
|
|
323
|
+
$[46] = view.running;
|
|
320
324
|
$[47] = t17;
|
|
321
325
|
} else t17 = $[47];
|
|
322
|
-
|
|
326
|
+
let t18;
|
|
327
|
+
if ($[48] !== t13 || $[49] !== t14 || $[50] !== t17) {
|
|
328
|
+
t18 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
329
|
+
t13,
|
|
330
|
+
t14,
|
|
331
|
+
t17
|
|
332
|
+
] });
|
|
333
|
+
$[48] = t13;
|
|
334
|
+
$[49] = t14;
|
|
335
|
+
$[50] = t17;
|
|
336
|
+
$[51] = t18;
|
|
337
|
+
} else t18 = $[51];
|
|
338
|
+
return t18;
|
|
323
339
|
}
|
|
324
340
|
function _temp(state) {
|
|
325
341
|
return state.context.agentMessages;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { publicationMutations } from "../../../lib/queries.js";
|
|
2
|
+
import { c } from "react/compiler-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { useMutation } from "@tanstack/react-query";
|
|
6
|
+
import { Button } from "@camox/ui/button";
|
|
7
|
+
import { toast } from "@camox/ui/toaster";
|
|
8
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "@camox/ui/alert-dialog";
|
|
9
|
+
import { Spinner } from "@camox/ui/spinner";
|
|
10
|
+
|
|
11
|
+
//#region src/features/studio/components/ClearThread.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Clear thread, for a Publication's thread a secret was pasted into: asks first, then wipes the
|
|
14
|
+
* thread for good. The Publication stays, so it can still be reverted (ADR 0045).
|
|
15
|
+
*/
|
|
16
|
+
function ClearThread(t0) {
|
|
17
|
+
const $ = c(24);
|
|
18
|
+
const { projectId, id } = t0;
|
|
19
|
+
const [open, setOpen] = React.useState(false);
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
22
|
+
t1 = {
|
|
23
|
+
...publicationMutations.clearThread(),
|
|
24
|
+
onSuccess: () => setOpen(false),
|
|
25
|
+
onError: _temp
|
|
26
|
+
};
|
|
27
|
+
$[0] = t1;
|
|
28
|
+
} else t1 = $[0];
|
|
29
|
+
const clearThread = useMutation(t1);
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
32
|
+
t2 = /* @__PURE__ */ jsx(Button, {
|
|
33
|
+
type: "button",
|
|
34
|
+
variant: "ghost",
|
|
35
|
+
size: "sm",
|
|
36
|
+
onClick: () => setOpen(true),
|
|
37
|
+
children: "Clear thread"
|
|
38
|
+
});
|
|
39
|
+
$[1] = t2;
|
|
40
|
+
} else t2 = $[1];
|
|
41
|
+
let t3;
|
|
42
|
+
if ($[2] !== clearThread.isPending) {
|
|
43
|
+
t3 = (next) => {
|
|
44
|
+
if (!clearThread.isPending) setOpen(next);
|
|
45
|
+
};
|
|
46
|
+
$[2] = clearThread.isPending;
|
|
47
|
+
$[3] = t3;
|
|
48
|
+
} else t3 = $[3];
|
|
49
|
+
let t4;
|
|
50
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
51
|
+
t4 = /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: "Clear this thread?" }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: "Its messages are deleted for everyone, for good. What was published, and what it replaced, stay. This can't be undone." })] });
|
|
52
|
+
$[4] = t4;
|
|
53
|
+
} else t4 = $[4];
|
|
54
|
+
let t5;
|
|
55
|
+
if ($[5] !== clearThread.isPending) {
|
|
56
|
+
t5 = /* @__PURE__ */ jsx(AlertDialogCancel, {
|
|
57
|
+
variant: "outline",
|
|
58
|
+
size: "default",
|
|
59
|
+
disabled: clearThread.isPending,
|
|
60
|
+
children: "Cancel"
|
|
61
|
+
});
|
|
62
|
+
$[5] = clearThread.isPending;
|
|
63
|
+
$[6] = t5;
|
|
64
|
+
} else t5 = $[6];
|
|
65
|
+
let t6;
|
|
66
|
+
if ($[7] !== clearThread || $[8] !== id || $[9] !== projectId) {
|
|
67
|
+
t6 = () => clearThread.mutate({
|
|
68
|
+
projectId,
|
|
69
|
+
id
|
|
70
|
+
});
|
|
71
|
+
$[7] = clearThread;
|
|
72
|
+
$[8] = id;
|
|
73
|
+
$[9] = projectId;
|
|
74
|
+
$[10] = t6;
|
|
75
|
+
} else t6 = $[10];
|
|
76
|
+
let t7;
|
|
77
|
+
if ($[11] !== clearThread.isPending) {
|
|
78
|
+
t7 = clearThread.isPending ? /* @__PURE__ */ jsx(Spinner, {}) : null;
|
|
79
|
+
$[11] = clearThread.isPending;
|
|
80
|
+
$[12] = t7;
|
|
81
|
+
} else t7 = $[12];
|
|
82
|
+
let t8;
|
|
83
|
+
if ($[13] !== clearThread.isPending || $[14] !== t6 || $[15] !== t7) {
|
|
84
|
+
t8 = /* @__PURE__ */ jsxs(AlertDialogAction, {
|
|
85
|
+
variant: "destructive",
|
|
86
|
+
disabled: clearThread.isPending,
|
|
87
|
+
onClick: t6,
|
|
88
|
+
children: [t7, "Clear thread"]
|
|
89
|
+
});
|
|
90
|
+
$[13] = clearThread.isPending;
|
|
91
|
+
$[14] = t6;
|
|
92
|
+
$[15] = t7;
|
|
93
|
+
$[16] = t8;
|
|
94
|
+
} else t8 = $[16];
|
|
95
|
+
let t9;
|
|
96
|
+
if ($[17] !== t5 || $[18] !== t8) {
|
|
97
|
+
t9 = /* @__PURE__ */ jsxs(AlertDialogContent, { children: [t4, /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [t5, t8] })] });
|
|
98
|
+
$[17] = t5;
|
|
99
|
+
$[18] = t8;
|
|
100
|
+
$[19] = t9;
|
|
101
|
+
} else t9 = $[19];
|
|
102
|
+
let t10;
|
|
103
|
+
if ($[20] !== open || $[21] !== t3 || $[22] !== t9) {
|
|
104
|
+
t10 = /* @__PURE__ */ jsxs(Fragment, { children: [t2, /* @__PURE__ */ jsx(AlertDialog, {
|
|
105
|
+
open,
|
|
106
|
+
onOpenChange: t3,
|
|
107
|
+
children: t9
|
|
108
|
+
})] });
|
|
109
|
+
$[20] = open;
|
|
110
|
+
$[21] = t3;
|
|
111
|
+
$[22] = t9;
|
|
112
|
+
$[23] = t10;
|
|
113
|
+
} else t10 = $[23];
|
|
114
|
+
return t10;
|
|
115
|
+
}
|
|
116
|
+
function _temp(error) {
|
|
117
|
+
return toast.error(error.message || "Could not clear the thread");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { ClearThread };
|