camox 0.54.0 → 0.57.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/dist/features/canvas/CamoxCanvas.js +14 -11
- package/dist/features/canvas/CanvasLoadingScreen.js +1 -1
- package/dist/features/canvas/CanvasPageHeader.js +1 -1
- package/dist/features/canvas/canvasFrameDocument.js +13 -6
- package/dist/features/canvas/sidebar/CanvasViewHeader.js +1 -1
- package/dist/features/canvas/sidebar/{CanvasSidebar.js → ContentSidebar.js} +5 -5
- package/dist/features/canvas/sidebar/{CanvasSidebarFrame.js → ContentSidebarFrame.js} +4 -4
- package/dist/features/canvas/sidebar/{CanvasSidebarSkeleton.js → ContentSidebarSkeleton.js} +7 -7
- package/dist/features/preview/CamoxPreview.js +2 -2
- package/dist/features/preview/components/Frame.js +1 -18
- package/dist/features/preview/components/PreviewToolbar.js +1 -1
- package/dist/features/preview/components/SelectionEditor.js +2 -2
- package/dist/features/preview/components/SidebarStack.js +201 -116
- package/dist/features/preview/components/StudioEditingFallback.js +3 -3
- package/dist/features/preview/components/previewStyles.js +25 -1
- package/dist/features/renderer/RendererApp.js +55 -37
- package/dist/features/routes/pageRuntime.d.ts +1 -1
- package/dist/features/runtime/RuntimeChrome.js +4 -4
- package/dist/features/studio/components/AgentSidebar.js +56 -0
- package/dist/features/studio/components/ChatWidget.js +219 -0
- package/dist/features/studio/components/DraftsControl.js +17 -17
- package/dist/features/studio/components/Patrol.js +676 -0
- package/dist/features/studio/components/ReviewDraftSheet.js +38 -38
- package/dist/features/studio/components/Squareling.js +171 -84
- package/dist/features/studio/components/ThreadMessages.js +256 -136
- package/dist/features/studio/localeOptions.js +7 -3
- package/dist/features/studio/reportSentence.js +75 -0
- package/dist/features/studio/routes.js +2 -1
- package/dist/features/studio/showInCanvas.js +9 -2
- package/dist/features/studio/studioStore.js +5 -5
- package/dist/features/studio/workingSentence.js +55 -0
- package/dist/lib/queries.js +1 -1
- package/dist/lib/studio-reads.d.ts +1 -0
- package/dist/lib/studio-reads.js +5 -0
- package/dist/lib/use-thread.js +156 -190
- package/dist/package.js +1 -1
- package/dist/studio.css +1 -1
- package/package.json +4 -4
- package/skills/camox/SKILL.md +3 -10
- package/skills/camox/references/artifacts.md +2 -2
- package/skills/camox/references/block-definitions.md +1 -1
- package/skills/camox/references/layout-definitions.md +1 -1
- package/skills/camox/references/routed-layouts.md +2 -2
- package/skills/camox-cli/SKILL.md +15 -0
- package/skills/{camox → camox-cli}/references/cli-common.md +1 -1
- package/skills/{camox → camox-cli}/references/cli-content.md +2 -2
- package/skills/{camox → camox-cli}/references/cli-publishing.md +4 -4
- package/skills/camox-expand/SKILL.md +1 -1
- package/skills/camoxify/SKILL.md +1 -1
- package/dist/features/studio/components/ChatSidebar.js +0 -346
|
@@ -9,7 +9,7 @@ const studioStore = createStore({
|
|
|
9
9
|
open: false,
|
|
10
10
|
startRenaming: false
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
isDeleteDraftDialogOpen: false,
|
|
13
13
|
localeDialog: null,
|
|
14
14
|
websiteLocation: null
|
|
15
15
|
},
|
|
@@ -64,16 +64,16 @@ const studioStore = createStore({
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
},
|
|
67
|
-
|
|
67
|
+
openDeleteDraftDialog: (context) => {
|
|
68
68
|
return {
|
|
69
69
|
...context,
|
|
70
|
-
|
|
70
|
+
isDeleteDraftDialogOpen: true
|
|
71
71
|
};
|
|
72
72
|
},
|
|
73
|
-
|
|
73
|
+
closeDeleteDraftDialog: (context) => {
|
|
74
74
|
return {
|
|
75
75
|
...context,
|
|
76
|
-
|
|
76
|
+
isDeleteDraftDialogOpen: false
|
|
77
77
|
};
|
|
78
78
|
},
|
|
79
79
|
openLocaleDialog: (context, event) => {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { localeName } from "./localeOptions.js";
|
|
2
|
+
|
|
3
|
+
//#region src/features/studio/workingSentence.ts
|
|
4
|
+
const PHRASES = {
|
|
5
|
+
translator: {
|
|
6
|
+
verb: "Translating",
|
|
7
|
+
locale: "into",
|
|
8
|
+
singleLocale: "Add a language to translate into"
|
|
9
|
+
},
|
|
10
|
+
seoManager: {
|
|
11
|
+
verb: "Writing SEO for",
|
|
12
|
+
verbFor: { file: "Describing" },
|
|
13
|
+
locale: "in"
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/** The most locales a burst names; past it, the first are named and the rest counted. */
|
|
17
|
+
const NAMED_LOCALES = 3;
|
|
18
|
+
/** Joins parts as a list: "a", "a and b", "a, b and c". */
|
|
19
|
+
const listed = (parts) => parts.length < 2 ? parts.join("") : `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
|
|
20
|
+
/**
|
|
21
|
+
* Each locale of a burst with its count, the first counted by the caller: "into German and 12
|
|
22
|
+
* into Spanish", or with the rest counted together, "…and 9 into 2 other languages".
|
|
23
|
+
*/
|
|
24
|
+
function inLocales(locales, preposition) {
|
|
25
|
+
const named = locales.length > NAMED_LOCALES ? locales.slice(0, 2) : locales;
|
|
26
|
+
const rest = locales.slice(named.length);
|
|
27
|
+
const parts = named.map(({ locale, count }, index) => `${index === 0 ? "" : `${count} `}${preposition} ${localeName(locale)}`);
|
|
28
|
+
if (rest.length > 0) {
|
|
29
|
+
const count = rest.reduce((sum, each) => sum + each.count, 0);
|
|
30
|
+
parts.push(`${count} ${preposition} ${rest.length} other languages`);
|
|
31
|
+
}
|
|
32
|
+
return listed(parts);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* What a patroller is working on: "Translating hero into Spanish" for one subject, "Translating
|
|
36
|
+
* 38 items into German and 12 into Spanish" for a burst, counted in each locale.
|
|
37
|
+
*/
|
|
38
|
+
function workingSentence(id, working) {
|
|
39
|
+
const phrase = PHRASES[id];
|
|
40
|
+
const { subject, locales } = working;
|
|
41
|
+
const verb = (subject && phrase.verbFor?.[subject.entity]) ?? phrase.verb;
|
|
42
|
+
const first = locales[0]?.count ?? 0;
|
|
43
|
+
return [
|
|
44
|
+
verb,
|
|
45
|
+
subject?.name ?? `${first} ${first === 1 ? "item" : "items"}`,
|
|
46
|
+
inLocales(locales, phrase.locale)
|
|
47
|
+
].filter(Boolean).join(" ");
|
|
48
|
+
}
|
|
49
|
+
/** What a patroller says while idle in a project with a single locale, if anything. */
|
|
50
|
+
function singleLocaleSentence(id) {
|
|
51
|
+
return PHRASES[id].singleLocale;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
export { singleLocaleSentence, workingSentence };
|
package/dist/lib/queries.js
CHANGED
|
@@ -43,7 +43,7 @@ const projectMutations = {
|
|
|
43
43
|
};
|
|
44
44
|
const draftMutations = {
|
|
45
45
|
publish: () => getOrpc().drafts.publish.mutationOptions(),
|
|
46
|
-
|
|
46
|
+
delete: () => getOrpc().drafts.delete.mutationOptions(),
|
|
47
47
|
/** Requests the draft's overview again right away, once it failed. */
|
|
48
48
|
retryOverview: () => getOrpc().drafts.retryOverview.mutationOptions(),
|
|
49
49
|
/** Drops the draft's copy of an entity it conflicts on, to use Live's version instead. */
|
|
@@ -7,6 +7,7 @@ import "./queries.js";
|
|
|
7
7
|
import "react";
|
|
8
8
|
import "@camox/api-contract/query-keys";
|
|
9
9
|
import { QueryClient } from "@tanstack/react-query";
|
|
10
|
+
import "@camox/api-contract/patrol";
|
|
10
11
|
//#region src/lib/studio-reads.d.ts
|
|
11
12
|
type LayoutRead = Awaited<ReturnType<ApiClient["layouts"]["get"]>>;
|
|
12
13
|
/** A layout's structure: its blocks before and after the content of its pages. */
|
package/dist/lib/studio-reads.js
CHANGED
|
@@ -206,6 +206,11 @@ const reads = {
|
|
|
206
206
|
fetch: ({ apiIn, signal }, { projectId, draftId }) => apiIn(draftId).drafts.get({ projectId }, { signal }),
|
|
207
207
|
staleTime: Infinity
|
|
208
208
|
}),
|
|
209
|
+
patrol: entry({
|
|
210
|
+
key: ({ projectId }) => [...queryKeys.patrol.get, projectId],
|
|
211
|
+
everyLocale: true,
|
|
212
|
+
fetch: ({ api, signal }, { projectId }) => api.patrol.get({ projectId }, { signal })
|
|
213
|
+
}),
|
|
209
214
|
publishPreview: entry({
|
|
210
215
|
key: ({ draftId }) => [
|
|
211
216
|
...queryKeys.drafts.all,
|
package/dist/lib/use-thread.js
CHANGED
|
@@ -13,19 +13,16 @@ const OPEN = 1;
|
|
|
13
13
|
* signed-in editor's Live thread when `draftId` is null, or the draft's thread, which `draftId`
|
|
14
14
|
* names as the draft header does (`development` in dev mode). A message is resent with its
|
|
15
15
|
* operation id each time the thread shows itself after the socket opens, until it accepts it,
|
|
16
|
-
* which records it once, or turns it down. A thread that ended with its draft isn't
|
|
17
|
-
* to, but for a development draft's
|
|
18
|
-
*
|
|
16
|
+
* which records it once, or turns it down. A draft's thread that ended with its draft isn't
|
|
17
|
+
* reconnected to, but for a development draft's, which moves on to a new thread. Mount it once
|
|
18
|
+
* per project and draft.
|
|
19
19
|
*
|
|
20
|
-
* When the
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* that fresh Live thread, continued in the draft.
|
|
20
|
+
* When the agent on Live hands a request off to a draft it started, the studio that sent a
|
|
21
|
+
* message of that run hears it (`onEnterDraft`), to enter the draft. The editor's Live thread
|
|
22
|
+
* stays as it is, ending that turn on the draft's card, which every studio on Live shows.
|
|
24
23
|
*
|
|
25
24
|
* It reports what each writing script touched (`touched`), for runs one of its messages was part
|
|
26
|
-
* of only, so that the studio follows the agent; teammates' runs leave it where it is.
|
|
27
|
-
* entering the draft its Live thread started keeps following that run there, starting with what
|
|
28
|
-
* the write touched.
|
|
25
|
+
* of only, so that the studio follows the agent; teammates' runs leave it where it is.
|
|
29
26
|
*/
|
|
30
27
|
function useThread(apiUrl, projectId, draftId, t0) {
|
|
31
28
|
const $ = c(47);
|
|
@@ -35,8 +32,8 @@ function useThread(apiUrl, projectId, draftId, t0) {
|
|
|
35
32
|
$[0] = t0;
|
|
36
33
|
$[1] = t1;
|
|
37
34
|
} else t1 = $[1];
|
|
38
|
-
const {
|
|
39
|
-
const [state, setState] = React.useState(
|
|
35
|
+
const { onEnterDraft } = t1;
|
|
36
|
+
const [state, setState] = React.useState(EMPTY_THREAD_STATE);
|
|
40
37
|
let t2;
|
|
41
38
|
if ($[2] !== state) {
|
|
42
39
|
t2 = threadViewOf(state);
|
|
@@ -45,50 +42,37 @@ function useThread(apiUrl, projectId, draftId, t0) {
|
|
|
45
42
|
} else t2 = $[3];
|
|
46
43
|
const view = t2;
|
|
47
44
|
let t3;
|
|
48
|
-
if ($[4]
|
|
49
|
-
t3 =
|
|
50
|
-
$[4] =
|
|
51
|
-
|
|
52
|
-
} else t3 = $[5];
|
|
45
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
46
|
+
t3 = /* @__PURE__ */ new Map();
|
|
47
|
+
$[4] = t3;
|
|
48
|
+
} else t3 = $[4];
|
|
53
49
|
const [unaccepted, setUnaccepted] = React.useState(t3);
|
|
54
50
|
const [error, setError] = React.useState();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
$[6] =
|
|
60
|
-
$[7] =
|
|
61
|
-
|
|
62
|
-
|
|
51
|
+
let t4;
|
|
52
|
+
if ($[5] !== apiUrl || $[6] !== draftId || $[7] !== projectId) {
|
|
53
|
+
t4 = () => new Set(handedOffTo(apiUrl, projectId, draftId));
|
|
54
|
+
$[5] = apiUrl;
|
|
55
|
+
$[6] = draftId;
|
|
56
|
+
$[7] = projectId;
|
|
57
|
+
$[8] = t4;
|
|
58
|
+
} else t4 = $[8];
|
|
59
|
+
const [sent] = React.useState(t4);
|
|
63
60
|
const shown = React.useRef(false);
|
|
64
61
|
const [shows, setShows] = React.useState(0);
|
|
65
|
-
const [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} : void 0;
|
|
73
|
-
$[8] = carried;
|
|
74
|
-
$[9] = t6;
|
|
75
|
-
} else t6 = $[9];
|
|
76
|
-
const [touched, setTouched] = React.useState(t6);
|
|
77
|
-
const touchedWhileLeaving = React.useRef(void 0);
|
|
78
|
-
let t7;
|
|
79
|
-
if ($[10] !== apiUrl) {
|
|
80
|
-
t7 = apiSocketOptions(apiUrl);
|
|
81
|
-
$[10] = apiUrl;
|
|
82
|
-
$[11] = t7;
|
|
83
|
-
} else t7 = $[11];
|
|
62
|
+
const [touched, setTouched] = React.useState();
|
|
63
|
+
let t5;
|
|
64
|
+
if ($[9] !== apiUrl) {
|
|
65
|
+
t5 = apiSocketOptions(apiUrl);
|
|
66
|
+
$[9] = apiUrl;
|
|
67
|
+
$[10] = t5;
|
|
68
|
+
} else t5 = $[10];
|
|
84
69
|
const socket = usePartySocket({
|
|
85
|
-
...
|
|
70
|
+
...t5,
|
|
86
71
|
basePath: draftId ? `threads/draft/${projectId}/${draftId}` : `threads/live/${projectId}`,
|
|
87
72
|
maxEnqueuedMessages: 0,
|
|
88
73
|
shouldReconnectOnClose: _temp,
|
|
89
74
|
onClose(event_0) {
|
|
90
|
-
|
|
91
|
-
if (event_0.code === THREAD_ENDED_CLOSE_CODE && movesOn) socket.reconnect();
|
|
75
|
+
if (event_0.code === THREAD_ENDED_CLOSE_CODE && draftId === DEVELOPMENT_DRAFT) socket.reconnect();
|
|
92
76
|
},
|
|
93
77
|
onOpen() {
|
|
94
78
|
shown.current = false;
|
|
@@ -104,153 +88,125 @@ function useThread(apiUrl, projectId, draftId, t0) {
|
|
|
104
88
|
onFrame(frame);
|
|
105
89
|
}
|
|
106
90
|
});
|
|
91
|
+
let t6;
|
|
92
|
+
if ($[11] !== draftId || $[12] !== sent) {
|
|
93
|
+
t6 = (started) => draftId === null && started.operationIds.some((operationId) => sent.has(operationId));
|
|
94
|
+
$[11] = draftId;
|
|
95
|
+
$[12] = sent;
|
|
96
|
+
$[13] = t6;
|
|
97
|
+
} else t6 = $[13];
|
|
98
|
+
const asked = t6;
|
|
99
|
+
let t7;
|
|
100
|
+
if ($[14] !== sent) {
|
|
101
|
+
t7 = (batch) => batch.operationIds.some((operationId_0) => sent.has(operationId_0));
|
|
102
|
+
$[14] = sent;
|
|
103
|
+
$[15] = t7;
|
|
104
|
+
} else t7 = $[15];
|
|
105
|
+
const ours = t7;
|
|
107
106
|
let t8;
|
|
108
|
-
if ($[
|
|
109
|
-
t8 = (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
t9 = (batch) => batch.operationIds.some((operationId_0) => sent.current.has(operationId_0));
|
|
117
|
-
$[14] = t9;
|
|
118
|
-
} else t9 = $[14];
|
|
119
|
-
const ours = t9;
|
|
120
|
-
const onFrame = React.useEffectEvent((frame_0) => {
|
|
121
|
-
if (leaving.current) {
|
|
122
|
-
if (frame_0.type === "touched" && ours(frame_0.touched)) touchedWhileLeaving.current = frame_0.touched;
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
switch (frame_0.type) {
|
|
126
|
-
case "started-draft":
|
|
127
|
-
case "continued-in": {
|
|
128
|
-
const started_0 = frame_0.type === "started-draft" ? frame_0.startedDraft : frame_0.continuedIn;
|
|
129
|
-
if (wrote(started_0)) {
|
|
130
|
-
leaving.current = true;
|
|
131
|
-
setEntering(started_0.draftId);
|
|
107
|
+
if ($[16] !== apiUrl || $[17] !== asked || $[18] !== onEnterDraft || $[19] !== ours || $[20] !== projectId || $[21] !== sent) {
|
|
108
|
+
t8 = (frame_0) => {
|
|
109
|
+
switch (frame_0.type) {
|
|
110
|
+
case "started-draft":
|
|
111
|
+
if (asked(frame_0.startedDraft)) {
|
|
112
|
+
handedOff.set(threadKey(apiUrl, projectId, frame_0.startedDraft.draftId), sent);
|
|
113
|
+
onEnterDraft?.(frame_0.startedDraft.draftId);
|
|
114
|
+
}
|
|
132
115
|
return;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
116
|
+
case "events":
|
|
117
|
+
setState((current_2) => reduceThreadFrame(current_2, frame_0));
|
|
118
|
+
if (!shown.current) {
|
|
119
|
+
shown.current = true;
|
|
120
|
+
setShows(_temp2);
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
case "drafts":
|
|
124
|
+
setState((current_1) => reduceThreadFrame(current_1, frame_0));
|
|
125
|
+
return;
|
|
126
|
+
case "touched":
|
|
127
|
+
if (ours(frame_0.touched)) {
|
|
128
|
+
const batch_0 = frame_0.touched;
|
|
129
|
+
setTouched((last) => ({
|
|
130
|
+
sequence: (last?.sequence ?? 0) + 1,
|
|
131
|
+
batch: batch_0
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
return;
|
|
135
|
+
case "accepted":
|
|
136
|
+
setUnaccepted((current_0) => without(current_0, frame_0.operationId));
|
|
137
|
+
return;
|
|
138
|
+
case "error": {
|
|
139
|
+
console.error("[useThread]", frame_0.message);
|
|
140
|
+
setError(frame_0.message);
|
|
141
|
+
const { operationId: operationId_1 } = frame_0;
|
|
142
|
+
if (operationId_1) setUnaccepted((current) => without(current, operationId_1));
|
|
137
143
|
return;
|
|
138
144
|
}
|
|
139
|
-
setState((current_2) => reduceThreadFrame(current_2, frame_0));
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
case "events":
|
|
143
|
-
setState((current_1) => reduceThreadFrame(current_1, frame_0));
|
|
144
|
-
if (!shown.current) {
|
|
145
|
-
shown.current = true;
|
|
146
|
-
setShows(_temp2);
|
|
147
|
-
}
|
|
148
|
-
return;
|
|
149
|
-
case "touched":
|
|
150
|
-
if (ours(frame_0.touched)) {
|
|
151
|
-
const batch_0 = frame_0.touched;
|
|
152
|
-
setTouched((last) => ({
|
|
153
|
-
sequence: (last?.sequence ?? 0) + 1,
|
|
154
|
-
batch: batch_0
|
|
155
|
-
}));
|
|
156
|
-
}
|
|
157
|
-
return;
|
|
158
|
-
case "accepted":
|
|
159
|
-
setUnaccepted((current_0) => without(current_0, frame_0.operationId));
|
|
160
|
-
return;
|
|
161
|
-
case "error": {
|
|
162
|
-
console.error("[useThread]", frame_0.message);
|
|
163
|
-
setError(frame_0.message);
|
|
164
|
-
const { operationId: operationId_1 } = frame_0;
|
|
165
|
-
if (operationId_1) setUnaccepted((current) => without(current, operationId_1));
|
|
166
|
-
return;
|
|
167
145
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
146
|
+
};
|
|
147
|
+
$[16] = apiUrl;
|
|
148
|
+
$[17] = asked;
|
|
149
|
+
$[18] = onEnterDraft;
|
|
150
|
+
$[19] = ours;
|
|
151
|
+
$[20] = projectId;
|
|
152
|
+
$[21] = sent;
|
|
153
|
+
$[22] = t8;
|
|
154
|
+
} else t8 = $[22];
|
|
155
|
+
const onFrame = React.useEffectEvent(t8);
|
|
156
|
+
let t9;
|
|
157
|
+
if ($[23] !== socket || $[24] !== unaccepted) {
|
|
158
|
+
t9 = () => {
|
|
173
159
|
for (const [operationId_2, text] of unaccepted) transmit(socket, {
|
|
174
160
|
type: "send",
|
|
175
161
|
operationId: operationId_2,
|
|
176
162
|
text
|
|
177
163
|
});
|
|
178
164
|
};
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
} else
|
|
183
|
-
const resendUnaccepted = React.useEffectEvent(
|
|
184
|
-
let
|
|
185
|
-
if ($[
|
|
186
|
-
|
|
165
|
+
$[23] = socket;
|
|
166
|
+
$[24] = unaccepted;
|
|
167
|
+
$[25] = t9;
|
|
168
|
+
} else t9 = $[25];
|
|
169
|
+
const resendUnaccepted = React.useEffectEvent(t9);
|
|
170
|
+
let t10;
|
|
171
|
+
if ($[26] !== resendUnaccepted || $[27] !== shows) {
|
|
172
|
+
t10 = () => {
|
|
187
173
|
if (shows > 0) resendUnaccepted();
|
|
188
174
|
};
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
} else
|
|
175
|
+
$[26] = resendUnaccepted;
|
|
176
|
+
$[27] = shows;
|
|
177
|
+
$[28] = t10;
|
|
178
|
+
} else t10 = $[28];
|
|
179
|
+
let t11;
|
|
180
|
+
if ($[29] !== shows) {
|
|
181
|
+
t11 = [shows];
|
|
182
|
+
$[29] = shows;
|
|
183
|
+
$[30] = t11;
|
|
184
|
+
} else t11 = $[30];
|
|
185
|
+
React.useEffect(t10, t11);
|
|
193
186
|
let t12;
|
|
194
|
-
if ($[
|
|
195
|
-
t12 =
|
|
196
|
-
$[21] = shows;
|
|
197
|
-
$[22] = t12;
|
|
198
|
-
} else t12 = $[22];
|
|
199
|
-
React.useEffect(t11, t12);
|
|
200
|
-
let t13;
|
|
201
|
-
if ($[23] !== onEnterDraft || $[24] !== state || $[25] !== unaccepted) {
|
|
202
|
-
t13 = (started_1) => onEnterDraft?.(started_1, {
|
|
203
|
-
state,
|
|
204
|
-
unaccepted,
|
|
205
|
-
sent: sent.current,
|
|
206
|
-
touched: touchedWhileLeaving.current
|
|
207
|
-
});
|
|
208
|
-
$[23] = onEnterDraft;
|
|
209
|
-
$[24] = state;
|
|
210
|
-
$[25] = unaccepted;
|
|
211
|
-
$[26] = t13;
|
|
212
|
-
} else t13 = $[26];
|
|
213
|
-
const enterDraft = React.useEffectEvent(t13);
|
|
214
|
-
let t14;
|
|
215
|
-
if ($[27] !== enterDraft || $[28] !== entering) {
|
|
216
|
-
t14 = () => {
|
|
217
|
-
if (entering) enterDraft(entering);
|
|
218
|
-
};
|
|
219
|
-
$[27] = enterDraft;
|
|
220
|
-
$[28] = entering;
|
|
221
|
-
$[29] = t14;
|
|
222
|
-
} else t14 = $[29];
|
|
223
|
-
let t15;
|
|
224
|
-
if ($[30] !== entering) {
|
|
225
|
-
t15 = [entering];
|
|
226
|
-
$[30] = entering;
|
|
227
|
-
$[31] = t15;
|
|
228
|
-
} else t15 = $[31];
|
|
229
|
-
React.useEffect(t14, t15);
|
|
230
|
-
let t16;
|
|
231
|
-
if ($[32] !== socket) {
|
|
232
|
-
t16 = () => {
|
|
187
|
+
if ($[31] !== socket) {
|
|
188
|
+
t12 = () => {
|
|
233
189
|
const resync = () => {
|
|
234
190
|
if (document.visibilityState === "visible") transmit(socket, { type: "resync" });
|
|
235
191
|
};
|
|
236
192
|
document.addEventListener("visibilitychange", resync);
|
|
237
193
|
return () => document.removeEventListener("visibilitychange", resync);
|
|
238
194
|
};
|
|
239
|
-
$[
|
|
240
|
-
$[
|
|
241
|
-
} else
|
|
242
|
-
let
|
|
243
|
-
if ($[
|
|
244
|
-
|
|
245
|
-
$[
|
|
246
|
-
$[
|
|
247
|
-
} else
|
|
248
|
-
React.useEffect(
|
|
249
|
-
let
|
|
250
|
-
if ($[36] !== socket) {
|
|
251
|
-
|
|
195
|
+
$[31] = socket;
|
|
196
|
+
$[32] = t12;
|
|
197
|
+
} else t12 = $[32];
|
|
198
|
+
let t13;
|
|
199
|
+
if ($[33] !== socket) {
|
|
200
|
+
t13 = [socket];
|
|
201
|
+
$[33] = socket;
|
|
202
|
+
$[34] = t13;
|
|
203
|
+
} else t13 = $[34];
|
|
204
|
+
React.useEffect(t12, t13);
|
|
205
|
+
let t14;
|
|
206
|
+
if ($[35] !== sent || $[36] !== socket) {
|
|
207
|
+
t14 = (text_0) => {
|
|
252
208
|
const operationId_3 = crypto.randomUUID();
|
|
253
|
-
sent.
|
|
209
|
+
sent.add(operationId_3);
|
|
254
210
|
setError(void 0);
|
|
255
211
|
setUnaccepted((current_3) => new Map(current_3).set(operationId_3, text_0));
|
|
256
212
|
transmit(socket, {
|
|
@@ -259,23 +215,24 @@ function useThread(apiUrl, projectId, draftId, t0) {
|
|
|
259
215
|
text: text_0
|
|
260
216
|
});
|
|
261
217
|
};
|
|
218
|
+
$[35] = sent;
|
|
262
219
|
$[36] = socket;
|
|
263
|
-
$[37] =
|
|
264
|
-
} else
|
|
265
|
-
const send =
|
|
266
|
-
let
|
|
220
|
+
$[37] = t14;
|
|
221
|
+
} else t14 = $[37];
|
|
222
|
+
const send = t14;
|
|
223
|
+
let t15;
|
|
267
224
|
if ($[38] !== socket) {
|
|
268
|
-
|
|
225
|
+
t15 = () => transmit(socket, { type: "stop" });
|
|
269
226
|
$[38] = socket;
|
|
270
|
-
$[39] =
|
|
271
|
-
} else
|
|
272
|
-
const stop =
|
|
273
|
-
const
|
|
274
|
-
let
|
|
275
|
-
if ($[40] !== error || $[41] !== send || $[42] !== stop || $[43] !==
|
|
276
|
-
|
|
227
|
+
$[39] = t15;
|
|
228
|
+
} else t15 = $[39];
|
|
229
|
+
const stop = t15;
|
|
230
|
+
const t16 = unaccepted.size > 0;
|
|
231
|
+
let t17;
|
|
232
|
+
if ($[40] !== error || $[41] !== send || $[42] !== stop || $[43] !== t16 || $[44] !== touched || $[45] !== view) {
|
|
233
|
+
t17 = {
|
|
277
234
|
view,
|
|
278
|
-
sending:
|
|
235
|
+
sending: t16,
|
|
279
236
|
send,
|
|
280
237
|
stop,
|
|
281
238
|
error,
|
|
@@ -284,12 +241,12 @@ function useThread(apiUrl, projectId, draftId, t0) {
|
|
|
284
241
|
$[40] = error;
|
|
285
242
|
$[41] = send;
|
|
286
243
|
$[42] = stop;
|
|
287
|
-
$[43] =
|
|
244
|
+
$[43] = t16;
|
|
288
245
|
$[44] = touched;
|
|
289
246
|
$[45] = view;
|
|
290
|
-
$[46] =
|
|
291
|
-
} else
|
|
292
|
-
return
|
|
247
|
+
$[46] = t17;
|
|
248
|
+
} else t17 = $[46];
|
|
249
|
+
return t17;
|
|
293
250
|
}
|
|
294
251
|
function _temp2(count) {
|
|
295
252
|
return count + 1;
|
|
@@ -297,6 +254,15 @@ function _temp2(count) {
|
|
|
297
254
|
function _temp(event) {
|
|
298
255
|
return event.code !== THREAD_ENDED_CLOSE_CODE;
|
|
299
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The operation ids of the messages a studio sent on Live, by the draft the agent on Live handed
|
|
259
|
+
* its request off to: the draft's agent runs on them, so once the studio follows that draft's
|
|
260
|
+
* thread, it follows what they touch.
|
|
261
|
+
*/
|
|
262
|
+
const handedOff = /* @__PURE__ */ new Map();
|
|
263
|
+
const threadKey = (apiUrl, projectId, draftId) => `${apiUrl}|${projectId}|${draftId}`;
|
|
264
|
+
/** The operation ids a studio carries into the draft `draftId`: none for Live. */
|
|
265
|
+
const handedOffTo = (apiUrl, projectId, draftId) => draftId !== null && handedOff.get(threadKey(apiUrl, projectId, draftId)) || [];
|
|
300
266
|
function transmit(socket, message) {
|
|
301
267
|
if (socket.readyState === OPEN) socket.send(JSON.stringify(message));
|
|
302
268
|
}
|
package/dist/package.js
CHANGED