@widgetic/creator 0.4.32 → 0.4.33
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/CreatorApp.svelte +136 -9
- package/dist/host/creatorHost.d.ts +28 -0
- package/dist/host/creatorHost.js +36 -0
- package/dist/i18n/labels.d.ts +5 -0
- package/dist/i18n/labels.js +16 -0
- package/dist/i18n/language.d.ts +9 -2
- package/dist/i18n/messages.d.ts +8 -1
- package/dist/i18n/messages.js +10 -1
- package/dist/utils/generationRequestFields.d.ts +45 -0
- package/dist/utils/generationRequestFields.js +41 -0
- package/dist/utils/teamEditingRefusals.d.ts +74 -0
- package/dist/utils/teamEditingRefusals.js +102 -0
- package/package.json +3 -3
package/dist/CreatorApp.svelte
CHANGED
|
@@ -192,6 +192,14 @@
|
|
|
192
192
|
type OperationSnapshot
|
|
193
193
|
} from './utils/generationSharing.js';
|
|
194
194
|
import { failureNoticeChanges } from './utils/failureNotice.js';
|
|
195
|
+
import { generationVersionAndDocumentFields } from './utils/generationRequestFields.js';
|
|
196
|
+
import {
|
|
197
|
+
generationRefusalText,
|
|
198
|
+
headCommitForComparison,
|
|
199
|
+
operationToFollow,
|
|
200
|
+
readTeamEditingRefusalOf,
|
|
201
|
+
restoreRefusalText
|
|
202
|
+
} from './utils/teamEditingRefusals.js';
|
|
195
203
|
import { generateEmbedCode, EMBED_FORMATS, type EmbedFormat } from './utils/embedCode.js';
|
|
196
204
|
|
|
197
205
|
function openEmbedTestPage(href: string) {
|
|
@@ -216,6 +224,8 @@
|
|
|
216
224
|
setHostHandlers,
|
|
217
225
|
mayUseAddressBar,
|
|
218
226
|
mayShowAccountBilling,
|
|
227
|
+
maySuggestWidgetName,
|
|
228
|
+
mayNameVersionOrDocumentsInGeneration,
|
|
219
229
|
mayListenToSiteEvents,
|
|
220
230
|
announceToSite,
|
|
221
231
|
eventIsFromCreator,
|
|
@@ -3509,16 +3519,23 @@
|
|
|
3509
3519
|
checkpointMessageId: string,
|
|
3510
3520
|
restoreWidgetId?: string | null,
|
|
3511
3521
|
): Promise<any> {
|
|
3522
|
+
// The widget whose code the restore puts back, as the panel looks at it when the request is made (the person may look at
|
|
3523
|
+
// another panel while it runs).
|
|
3524
|
+
const widgetIdAtRestore = restoreWidgetId || focusedPanelWidgetId || selectedWidgetId || null;
|
|
3512
3525
|
try {
|
|
3513
3526
|
if (!messagesClient) {
|
|
3514
3527
|
console.warn('[Chat→Backend] messagesClient not initialized');
|
|
3515
3528
|
return null;
|
|
3516
3529
|
}
|
|
3530
|
+
// The head the person is looking at. The API refuses the restore, before it deletes a message, when newer code was saved
|
|
3531
|
+
// since (a teammate, another window): rolling back over it would lose it.
|
|
3532
|
+
const expectedHeadSha = widgetIdAtRestore ? shownHeadCommitSha(widgetIdAtRestore) : null;
|
|
3517
3533
|
const response = await messagesClient.restoreCheckpointRaw({
|
|
3518
3534
|
conversationId,
|
|
3519
3535
|
restoreCheckpointRequest: {
|
|
3520
3536
|
conversationId,
|
|
3521
3537
|
checkpointMessageId,
|
|
3538
|
+
...(expectedHeadSha ? { expectedHeadSha } : {}),
|
|
3522
3539
|
}
|
|
3523
3540
|
}, widgetBuilderRequestInit(widgetBuilderPreviewBaseUrl()));
|
|
3524
3541
|
const json = await response.raw.json();
|
|
@@ -3668,6 +3685,17 @@
|
|
|
3668
3685
|
}
|
|
3669
3686
|
return data;
|
|
3670
3687
|
} catch (error) {
|
|
3688
|
+
// The API turns a restore away before it deletes a message or touches a file: while a generation runs (it would commit
|
|
3689
|
+
// over the restored code), after newer code was saved since the person looked, or when it cannot read the head to
|
|
3690
|
+
// compare. The chat and the code are as they were.
|
|
3691
|
+
const refusal = await readTeamEditingRefusalOf(error);
|
|
3692
|
+
const refusalText = restoreRefusalText(refusal, $t);
|
|
3693
|
+
if (refusalText) {
|
|
3694
|
+
console.warn('[Restore] The API refused the restore; nothing was restored', { widgetId: widgetIdAtRestore?.substring(0, 8), refusal });
|
|
3695
|
+
showToast('warning', $t('creator.version.failedToRestoreCheckpoint'), { description: refusalText, duration: 9000 });
|
|
3696
|
+
if (refusal.kind === 'repository_head_changed' && widgetIdAtRestore) void catchUpAfterNewerCode(widgetIdAtRestore);
|
|
3697
|
+
return null;
|
|
3698
|
+
}
|
|
3671
3699
|
console.error('[Chat→Backend] Failed to restore checkpoint:', error);
|
|
3672
3700
|
showToast('error', $t('creator.version.failedToRestoreCheckpoint'), {
|
|
3673
3701
|
description: error instanceof Error ? error.message : $t('creator.general.unknownError'),
|
|
@@ -3786,6 +3814,32 @@
|
|
|
3786
3814
|
return normalizedA.startsWith(normalizedB.slice(0, 7)) || normalizedB.startsWith(normalizedA.slice(0, 7));
|
|
3787
3815
|
}
|
|
3788
3816
|
|
|
3817
|
+
/**
|
|
3818
|
+
* The head of a widget's code as this panel shows it: the commit the last generation, restore or head probe left in the panel
|
|
3819
|
+
* (or the one this browser kept for the widget). It is the head the person has seen, so a request that names it as
|
|
3820
|
+
* `expectedHeadSha` is refused by the API, before anything is charged, deleted or written, when newer code was saved since
|
|
3821
|
+
* (a teammate, another window). Null when the creator knows no head, or one the API would not accept: then nothing is
|
|
3822
|
+
* compared and the request goes as it always did.
|
|
3823
|
+
*/
|
|
3824
|
+
function shownHeadCommitSha(widgetId: string): string | null {
|
|
3825
|
+
return headCommitForComparison(getPanelDisplayState(widgetId).lastCommitId ?? loadCommitIdForWidget(widgetId));
|
|
3826
|
+
}
|
|
3827
|
+
|
|
3828
|
+
/**
|
|
3829
|
+
* Puts the words of a request the API refused back into the chat's message box, so the person can send it again without typing
|
|
3830
|
+
* it again. Only a request that was typed in the chat, and only into an empty box: what the person has typed since stays.
|
|
3831
|
+
*/
|
|
3832
|
+
function giveRefusedPromptBack(widgetId: string, refusedPrompt: string): void {
|
|
3833
|
+
try {
|
|
3834
|
+
const panelChat = getChatMethodsForWidget(widgetId);
|
|
3835
|
+
if (!panelChat?.setDraftText || refusedPrompt.trim() === '') return;
|
|
3836
|
+
if ((panelChat.getDraftText?.() ?? '').trim() !== '') return;
|
|
3837
|
+
panelChat.setDraftText(refusedPrompt);
|
|
3838
|
+
} catch (error) {
|
|
3839
|
+
console.warn('[TeamEditing] Could not put the refused request back into the message box', { widgetId, error });
|
|
3840
|
+
}
|
|
3841
|
+
}
|
|
3842
|
+
|
|
3789
3843
|
function formatCommitShaShort(sha: string | null | undefined): string {
|
|
3790
3844
|
const normalized = normalizeCommitSha(sha);
|
|
3791
3845
|
return normalized ? normalized.slice(0, 8) : '—';
|
|
@@ -6610,7 +6664,9 @@
|
|
|
6610
6664
|
/** This tab's own Stop came after the job had ended: shows how it ended. */
|
|
6611
6665
|
| 'stop-too-late'
|
|
6612
6666
|
/** This tab's own Stop could not reach the server: the job may still be running. */
|
|
6613
|
-
| 'stop-failed'
|
|
6667
|
+
| 'stop-failed'
|
|
6668
|
+
/** The API refused this tab's request because the person's own generation (another window, another device) is running: the refusal named it. */
|
|
6669
|
+
| 'refused';
|
|
6614
6670
|
|
|
6615
6671
|
/** Forgets the id this browser kept for the widget, when it is this operation's (the id of a newer generation stays). */
|
|
6616
6672
|
async function forgetStoredOperationId(widgetId: string, operationId: string): Promise<void> {
|
|
@@ -6660,7 +6716,8 @@
|
|
|
6660
6716
|
// It ended before this tab asked (the tab was away, or the stop came too late): show how it ended. A stop that
|
|
6661
6717
|
// did go through, whose answer was lost on the way, is on the screen already.
|
|
6662
6718
|
if (origin === 'stop-failed' && snapshot.status === 'cancelled') return;
|
|
6663
|
-
|
|
6719
|
+
// A refused request is waiting for news too: the run it was refused for ended in the meantime, so say how it ended
|
|
6720
|
+
await finishFollowedGeneration(widgetId, operationId, snapshot, origin === 'stored' || origin === 'stop-too-late' || origin === 'refused');
|
|
6664
6721
|
return;
|
|
6665
6722
|
}
|
|
6666
6723
|
|
|
@@ -6694,7 +6751,8 @@
|
|
|
6694
6751
|
void getChatMethodsForWidget(widgetId)?.reloadConversationMessages?.();
|
|
6695
6752
|
// This tab learned of it from the browser's own store: the other tabs may not know of it yet
|
|
6696
6753
|
if (origin === 'stored') generationChannel?.announceStarted(widgetId, operationId);
|
|
6697
|
-
|
|
6754
|
+
// (A refused request has been told already, in the words of its refusal)
|
|
6755
|
+
if (widgetId === focusedPanelWidgetId && origin !== 'stop-failed' && origin !== 'refused') {
|
|
6698
6756
|
showToast('info', $t('creator.codegen.generationInProgress'), {
|
|
6699
6757
|
description: $t('creator.codegen.reconnectedToAnActiveCode'),
|
|
6700
6758
|
duration: 4000
|
|
@@ -6854,6 +6912,24 @@
|
|
|
6854
6912
|
}
|
|
6855
6913
|
}
|
|
6856
6914
|
|
|
6915
|
+
/**
|
|
6916
|
+
* Brings what the panel knows of a widget's code up to date after the API said that newer code was saved than the person had
|
|
6917
|
+
* seen (a teammate saved, or another window generated): the head the panel names, the version menu and the conversation, read
|
|
6918
|
+
* from the server again. The preview stays as it is: the person looks at the newer code by choosing its version, and the next
|
|
6919
|
+
* request they send names the head they have now.
|
|
6920
|
+
*/
|
|
6921
|
+
async function catchUpAfterNewerCode(widgetId: string): Promise<void> {
|
|
6922
|
+
try {
|
|
6923
|
+
await reconcileWidgetHeadCommit(widgetId);
|
|
6924
|
+
const { [widgetId]: _resolved, ...restResolved } = shapeHistoryResolvedByWidgetId;
|
|
6925
|
+
shapeHistoryResolvedByWidgetId = restResolved;
|
|
6926
|
+
await loadPublishHistoryForPanel(widgetId, { silent: true, fresh: true });
|
|
6927
|
+
await getChatMethodsForWidget(widgetId)?.reloadConversationMessages?.();
|
|
6928
|
+
} catch (error) {
|
|
6929
|
+
console.warn('[TeamEditing] Could not bring the widget up to date after newer code was saved', { widgetId, error });
|
|
6930
|
+
}
|
|
6931
|
+
}
|
|
6932
|
+
|
|
6857
6933
|
/** Follows the generation whose id this browser kept for the widget, when it has one (see `GenerationFollowOrigin`). */
|
|
6858
6934
|
async function followStoredGeneration(widgetId: string): Promise<void> {
|
|
6859
6935
|
try {
|
|
@@ -10836,6 +10912,11 @@ Requirements:
|
|
|
10836
10912
|
|
|
10837
10913
|
// console.log('Widget Creator: Starting code generation for widget:', generationWidgetId);
|
|
10838
10914
|
|
|
10915
|
+
// What to do once this run has let go of the widget, after the API refused it: follow the person's own generation that holds
|
|
10916
|
+
// the widget, or catch up with the newer code that was saved. It waits for the cleanup in `finally`, because a widget that
|
|
10917
|
+
// still counts as generating in this tab is not followed.
|
|
10918
|
+
let afterRefusal: (() => void) | null = null;
|
|
10919
|
+
|
|
10839
10920
|
try {
|
|
10840
10921
|
const generationWidget =
|
|
10841
10922
|
getWidgetById(generationWidgetId) ||
|
|
@@ -11018,6 +11099,21 @@ Requirements:
|
|
|
11018
11099
|
? undefined
|
|
11019
11100
|
: resolvePlannerModelIdForGeneration(prompt, coderModelForRequest);
|
|
11020
11101
|
const runtimeLogsForRequest = collectRuntimeLogsForCodegen(generationWidgetId);
|
|
11102
|
+
// The version the person chose to build on, when it is not the head, and the head they chose it on: the API refuses the
|
|
11103
|
+
// request, before it charges anything, when newer code was saved since (a teammate, another window).
|
|
11104
|
+
// (Not with the token of an editor session, a partner's customer: the gateway's door for a session does not list these
|
|
11105
|
+
// fields, nor the text documents, and refuses a request that has one of them, so they are left out of the request
|
|
11106
|
+
// there. A Shopify store's token has no such door. See utils/generationRequestFields.ts.)
|
|
11107
|
+
const mayNameVersionOrDocuments = mayNameVersionOrDocumentsInGeneration(authenticatedClientsToken);
|
|
11108
|
+
const chosenBaseCommitSha =
|
|
11109
|
+
options.compileFixOnly || !mayNameVersionOrDocuments ? null : generationBaseCommitSha(generationWidgetId);
|
|
11110
|
+
const headTheVersionWasChosenOn = chosenBaseCommitSha ? shownHeadCommitSha(generationWidgetId) : null;
|
|
11111
|
+
const versionAndDocumentFields = generationVersionAndDocumentFields({
|
|
11112
|
+
mayNameVersionOrDocuments,
|
|
11113
|
+
baseCommitSha: chosenBaseCommitSha,
|
|
11114
|
+
expectedHeadSha: headTheVersionWasChosenOn,
|
|
11115
|
+
textDocuments: options.forkUserMessage ? undefined : options.textDocuments,
|
|
11116
|
+
});
|
|
11021
11117
|
// Stopped, or replaced, while the request was being prepared: no job is started for a run nobody waits for
|
|
11022
11118
|
if (signal.aborted) return;
|
|
11023
11119
|
// The generated client types this call as void and drops the 202 body.
|
|
@@ -11035,9 +11131,10 @@ Requirements:
|
|
|
11035
11131
|
: undefined,
|
|
11036
11132
|
images: imagesToSend,
|
|
11037
11133
|
attachmentIds: attachmentIdsToSend,
|
|
11038
|
-
|
|
11134
|
+
// The text documents, the version to build on and the head it was chosen on: only the ones with something to say,
|
|
11135
|
+
// and none with an editor session's token (see above)
|
|
11136
|
+
...versionAndDocumentFields,
|
|
11039
11137
|
runtimeLogs: runtimeLogsForRequest,
|
|
11040
|
-
...(options.compileFixOnly ? {} : { baseCommitSha: generationBaseCommitSha(generationWidgetId) }),
|
|
11041
11138
|
compileFixOnly: options.compileFixOnly === true,
|
|
11042
11139
|
skipIntentGate: options.skipIntentGate === true,
|
|
11043
11140
|
chipIntent: options.chipIntent,
|
|
@@ -11753,14 +11850,36 @@ Requirements:
|
|
|
11753
11850
|
// Handle concurrent generation conflict (409) — SDK throws ResponseError with .response (native Response)
|
|
11754
11851
|
const httpStatus = error?.response?.status;
|
|
11755
11852
|
if (httpStatus === 409) {
|
|
11756
|
-
|
|
11853
|
+
// The API turned the request away before it charged anything, for one of two reasons it says in the answer: a run holds
|
|
11854
|
+
// the widget's code (the person's own in another window, or a teammate's), or the version to build on was chosen on
|
|
11855
|
+
// code that is no longer the newest. A 409 that says neither keeps the words it always had.
|
|
11856
|
+
const refusal = await readTeamEditingRefusalOf(error);
|
|
11857
|
+
console.warn('Widget Creator: Code generation refused (409)', { widgetId: generationWidgetId.substring(0, 8), refusal });
|
|
11858
|
+
if (options.fromChat && refusal.kind !== 'other') giveRefusedPromptBack(generationWidgetId, prompt);
|
|
11859
|
+
|
|
11860
|
+
if (refusal.kind === 'repository_head_changed') {
|
|
11861
|
+
patchCodegenUiState(generationWidgetId, { generateCodeStatus: 'Ready' });
|
|
11862
|
+
showToast('warning', $t('creator.codegen.newerCodeWasSaved'), {
|
|
11863
|
+
description: $t('creator.codegen.chosenVersionIsOutOfDate'),
|
|
11864
|
+
duration: 10000
|
|
11865
|
+
});
|
|
11866
|
+
afterRefusal = () => void catchUpAfterNewerCode(generationWidgetId);
|
|
11867
|
+
return;
|
|
11868
|
+
}
|
|
11869
|
+
|
|
11757
11870
|
patchCodegenUiState(generationWidgetId, {
|
|
11758
11871
|
generateCodeStatus: '⚠️ A code generation is already running. Please wait for it to finish.',
|
|
11759
11872
|
});
|
|
11760
11873
|
showToast('warning', $t('creator.codegen.generationAlreadyInProgress'), {
|
|
11761
|
-
description:
|
|
11762
|
-
|
|
11874
|
+
description:
|
|
11875
|
+
refusal.kind === 'generation_in_progress'
|
|
11876
|
+
? generationRefusalText(refusal, $t, get(languageTag))
|
|
11877
|
+
: $t('creator.codegen.anotherCodeGenerationIsAlready'),
|
|
11878
|
+
duration: refusal.kind === 'generation_in_progress' ? 9000 : 5000
|
|
11763
11879
|
});
|
|
11880
|
+
// The person's own run is followed (its progress shows in the widget, as in any tab that began it), once this run has let go
|
|
11881
|
+
const runToFollow = operationToFollow(refusal);
|
|
11882
|
+
if (runToFollow) afterRefusal = () => void followGeneration(generationWidgetId, runToFollow, 'refused');
|
|
11764
11883
|
return;
|
|
11765
11884
|
}
|
|
11766
11885
|
|
|
@@ -11873,6 +11992,13 @@ Requirements:
|
|
|
11873
11992
|
widgetShapeLivePreviewsRef?.requestReload?.(generationWidgetId, { immediate: true });
|
|
11874
11993
|
});
|
|
11875
11994
|
}
|
|
11995
|
+
// The API refused this run and the widget is free of it now: follow the person's own generation, or catch up with the
|
|
11996
|
+
// newer code that was saved. (Not awaited: a followed run can take minutes, and the queue behind this one must not wait.)
|
|
11997
|
+
if (afterRefusal) {
|
|
11998
|
+
const actAfterRefusal = afterRefusal;
|
|
11999
|
+
afterRefusal = null;
|
|
12000
|
+
actAfterRefusal();
|
|
12001
|
+
}
|
|
11876
12002
|
}
|
|
11877
12003
|
}
|
|
11878
12004
|
}
|
|
@@ -17731,7 +17857,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17731
17857
|
let widgetName = draftName;
|
|
17732
17858
|
try {
|
|
17733
17859
|
const sketchForName = screenshot.startsWith('data:image/') ? screenshot : null;
|
|
17734
|
-
|
|
17860
|
+
// (Not in a partner's page: the gateway refuses a session this route, and the draft's name does as well.)
|
|
17861
|
+
if (agentClient && maySuggestWidgetName() && (prompt.trim().length >= 2 || sketchForName)) {
|
|
17735
17862
|
authStatus = 'Naming widget...';
|
|
17736
17863
|
const suggestedNameReply = await agentClient.agentWidgetNamePost({
|
|
17737
17864
|
agentWidgetNamePostRequest: { prompt, ...(sketchForName ? { image: sketchForName } : {}) },
|
|
@@ -93,6 +93,34 @@ export declare function mayUseAddressBar(): boolean;
|
|
|
93
93
|
export declare function mayUseRealtimeSocket(): boolean;
|
|
94
94
|
/** Whether the creator may ask for the account's trial and credit counter (an account matter, not a visitor's). */
|
|
95
95
|
export declare function mayShowAccountBilling(): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the creator may ask the API for a title for the widget it is about to make from a sketch (`POST
|
|
98
|
+
* /agent/widget-name`). That route is not on the gateway's allow-list for a partner's visitor (a title is asked before the
|
|
99
|
+
* widget exists, so there is no widget of theirs to check the request against), so every ask would be refused. In a
|
|
100
|
+
* partner's page the creator does not ask, and the widget keeps the name of its draft.
|
|
101
|
+
*/
|
|
102
|
+
export declare function maySuggestWidgetName(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* What the token of an editor session starts with: the credential a partner mints for one of its customers' browsers (the
|
|
105
|
+
* gateway's `EDITOR_SESSION_TOKEN_PREFIX`, and the way it tells a session from any other token as well).
|
|
106
|
+
*/
|
|
107
|
+
export declare const EDITOR_SESSION_TOKEN_PREFIX = "wgt_ses_";
|
|
108
|
+
/** Whether the token is an editor session's. A Shopify store's session token, a person's login and an API key are not. */
|
|
109
|
+
export declare function isEditorSessionToken(token: string | null | undefined): boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Whether a generation request (`POST /agent/code/generate`) may name the older version to build on (`baseCommitSha`), the
|
|
112
|
+
* head the person chose it on (`expectedHeadSha`), and the words of the text documents attached to the message
|
|
113
|
+
* (`textDocuments`). None of the three is on the gateway's allow-list for an editor session (what a partner's customer
|
|
114
|
+
* works with): its door refuses a request that has a field it does not list, whatever the field's value (even
|
|
115
|
+
* `baseCommitSha: null`), so one that carried any of them would be refused whole and the visitor could not generate at all.
|
|
116
|
+
* With a session's token the creator leaves the three out, and the AI builds on the latest code from the message alone, as it
|
|
117
|
+
* did before the API client knew the fields (it dropped them without a word).
|
|
118
|
+
*
|
|
119
|
+
* It is the token that decides, not partner mode: a Shopify store's page is in partner mode too (the page handed the creator a
|
|
120
|
+
* token), but its token is a Shopify session, which has no such door, and the team of a store is exactly who the head check
|
|
121
|
+
* protects. `utils/generationRequestFields.ts` is where the request is built from the answer.
|
|
122
|
+
*/
|
|
123
|
+
export declare function mayNameVersionOrDocumentsInGeneration(token: string | null | undefined): boolean;
|
|
96
124
|
/** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
|
|
97
125
|
export declare function mayListenToSiteEvents(): boolean;
|
|
98
126
|
/**
|
package/dist/host/creatorHost.js
CHANGED
|
@@ -99,6 +99,42 @@ export function mayUseRealtimeSocket() {
|
|
|
99
99
|
export function mayShowAccountBilling() {
|
|
100
100
|
return !state.partnerMode;
|
|
101
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Whether the creator may ask the API for a title for the widget it is about to make from a sketch (`POST
|
|
104
|
+
* /agent/widget-name`). That route is not on the gateway's allow-list for a partner's visitor (a title is asked before the
|
|
105
|
+
* widget exists, so there is no widget of theirs to check the request against), so every ask would be refused. In a
|
|
106
|
+
* partner's page the creator does not ask, and the widget keeps the name of its draft.
|
|
107
|
+
*/
|
|
108
|
+
export function maySuggestWidgetName() {
|
|
109
|
+
return !state.partnerMode;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* What the token of an editor session starts with: the credential a partner mints for one of its customers' browsers (the
|
|
113
|
+
* gateway's `EDITOR_SESSION_TOKEN_PREFIX`, and the way it tells a session from any other token as well).
|
|
114
|
+
*/
|
|
115
|
+
export const EDITOR_SESSION_TOKEN_PREFIX = 'wgt_ses_';
|
|
116
|
+
/** Whether the token is an editor session's. A Shopify store's session token, a person's login and an API key are not. */
|
|
117
|
+
export function isEditorSessionToken(token) {
|
|
118
|
+
if (typeof token !== 'string')
|
|
119
|
+
return false;
|
|
120
|
+
return token.replace(/^Bearer\s+/i, '').trim().startsWith(EDITOR_SESSION_TOKEN_PREFIX);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether a generation request (`POST /agent/code/generate`) may name the older version to build on (`baseCommitSha`), the
|
|
124
|
+
* head the person chose it on (`expectedHeadSha`), and the words of the text documents attached to the message
|
|
125
|
+
* (`textDocuments`). None of the three is on the gateway's allow-list for an editor session (what a partner's customer
|
|
126
|
+
* works with): its door refuses a request that has a field it does not list, whatever the field's value (even
|
|
127
|
+
* `baseCommitSha: null`), so one that carried any of them would be refused whole and the visitor could not generate at all.
|
|
128
|
+
* With a session's token the creator leaves the three out, and the AI builds on the latest code from the message alone, as it
|
|
129
|
+
* did before the API client knew the fields (it dropped them without a word).
|
|
130
|
+
*
|
|
131
|
+
* It is the token that decides, not partner mode: a Shopify store's page is in partner mode too (the page handed the creator a
|
|
132
|
+
* token), but its token is a Shopify session, which has no such door, and the team of a store is exactly who the head check
|
|
133
|
+
* protects. `utils/generationRequestFields.ts` is where the request is built from the answer.
|
|
134
|
+
*/
|
|
135
|
+
export function mayNameVersionOrDocumentsInGeneration(token) {
|
|
136
|
+
return !isEditorSessionToken(token);
|
|
137
|
+
}
|
|
102
138
|
/** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
|
|
103
139
|
export function mayListenToSiteEvents() {
|
|
104
140
|
return !state.partnerMode;
|
package/dist/i18n/labels.d.ts
CHANGED
|
@@ -12,3 +12,8 @@ export declare function embedFormatLabel(format: EmbedFormat, t: Translate<Creat
|
|
|
12
12
|
* clock. A date that is not a date is written as a dash.
|
|
13
13
|
*/
|
|
14
14
|
export declare function versionDateText(when: Date, locale: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* The time of day, as the sentences that say "since 10:00" show it: hours and minutes on a 24 hour clock, written the way
|
|
17
|
+
* `locale` writes them, on the visitor's own clock. A date that is not a date is written as a dash.
|
|
18
|
+
*/
|
|
19
|
+
export declare function clockTimeText(when: Date, locale: string): string;
|
package/dist/i18n/labels.js
CHANGED
|
@@ -37,3 +37,19 @@ export function versionDateText(when, locale) {
|
|
|
37
37
|
// English puts a comma between the date and the time ("10/01/2026, 10:00"); the lists have always read "10/01/2026 10:00".
|
|
38
38
|
return written.replace(', ', ' ');
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The time of day, as the sentences that say "since 10:00" show it: hours and minutes on a 24 hour clock, written the way
|
|
42
|
+
* `locale` writes them, on the visitor's own clock. A date that is not a date is written as a dash.
|
|
43
|
+
*/
|
|
44
|
+
export function clockTimeText(when, locale) {
|
|
45
|
+
if (!(when instanceof Date) || Number.isNaN(when.getTime()))
|
|
46
|
+
return '—';
|
|
47
|
+
const options = { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' };
|
|
48
|
+
try {
|
|
49
|
+
return new Intl.DateTimeFormat(locale, options).format(when);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// A tag this browser cannot use (the language kit has already settled on one it can, so this is only a guard): English.
|
|
53
|
+
return new Intl.DateTimeFormat('en', options).format(when);
|
|
54
|
+
}
|
|
55
|
+
}
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -220,6 +220,11 @@ export declare const CREATOR_CATALOGS: {
|
|
|
220
220
|
readonly 'creator.codegen.codeSavedPreviewIsLoading': "Code saved. Preview is loading.";
|
|
221
221
|
readonly 'creator.codegen.generationAlreadyInProgress': "Generation already in progress";
|
|
222
222
|
readonly 'creator.codegen.anotherCodeGenerationIsAlready': "Another code generation is already running. Wait for it to finish or cancel it first.";
|
|
223
|
+
readonly 'creator.codegen.teammateIsGeneratingSince': "A teammate has been generating in this widget since {time}. Your request was not sent: send it again when that generation has finished.";
|
|
224
|
+
readonly 'creator.codegen.generationRunningInTheWidget': "Another generation is already running in this widget. Your request was not sent: send it again when it has finished.";
|
|
225
|
+
readonly 'creator.codegen.yourGenerationRunsElsewhere': "You already have a generation running in this widget, in another window or app. Your request was not sent: send it again when it has finished.";
|
|
226
|
+
readonly 'creator.codegen.newerCodeWasSaved': "Newer code was saved";
|
|
227
|
+
readonly 'creator.codegen.chosenVersionIsOutOfDate': "The widget changed after you chose that version, so nothing was generated. Check the version list, choose the version again, then send your request.";
|
|
223
228
|
readonly 'creator.codegen.codeGenerationError': "Code generation error";
|
|
224
229
|
readonly 'creator.codegen.imagePastedToPrompt': "Image pasted to prompt";
|
|
225
230
|
readonly 'creator.codegen.codeGenerationInProgressWait': "Code generation in progress — wait until it finishes.";
|
|
@@ -242,7 +247,6 @@ export declare const CREATOR_CATALOGS: {
|
|
|
242
247
|
readonly 'creator.codegen.repositoryCreatedButNotPersisted': "Repository created but not persisted";
|
|
243
248
|
readonly 'creator.codegen.repositoryExistsButFailedTo': "Repository exists but failed to sync with widget record. Try generating code to resync.";
|
|
244
249
|
readonly 'creator.codegen.repositoryReadyForUse': "Repository {id}… ready for use.";
|
|
245
|
-
readonly 'creator.codegen.generationFailed': "Generation Failed";
|
|
246
250
|
readonly 'creator.codegen.previewBuilderIsUnavailable': "Preview builder is unavailable";
|
|
247
251
|
readonly 'creator.codegen.theWidgetCodeWasSaved': "The widget code was saved, but the preview service could not compile it. This is not a Svelte syntax error. Go back to Create and use Rebuild.";
|
|
248
252
|
readonly 'creator.codegen.rebuildInCreate': "🔄 Rebuild in Create";
|
|
@@ -276,6 +280,9 @@ export declare const CREATOR_CATALOGS: {
|
|
|
276
280
|
readonly 'creator.version.checkpointRestored': "Checkpoint restored";
|
|
277
281
|
readonly 'creator.version.restoreCompletedWithWarnings': "Restore completed with warnings";
|
|
278
282
|
readonly 'creator.version.failedToRestoreCheckpoint': "Failed to restore checkpoint";
|
|
283
|
+
readonly 'creator.version.restoreRefusedWhileGenerating': "Nothing was restored because a generation is running in this widget. Try again when it has finished.";
|
|
284
|
+
readonly 'creator.version.restoreRefusedNewerCode': "Nothing was restored because newer code was saved after this checkpoint was shown. Check the version list, then restore again if you still want this checkpoint.";
|
|
285
|
+
readonly 'creator.version.restoreRefusedLatestCodeUnknown': "Nothing was restored because the latest code could not be checked. Try again in a moment.";
|
|
279
286
|
readonly 'creator.version.versionIsNowLive': "Version {version} is now live.";
|
|
280
287
|
readonly 'creator.version.version': "Version {version}";
|
|
281
288
|
readonly 'creator.version.theSelectedDraftVersionWas': "The selected draft version was not found.";
|
|
@@ -952,4 +959,4 @@ export declare const useCreatorLanguage: () => import("@widgetic/design-system/i
|
|
|
952
959
|
* The English `t` of the creator, for code that has no component around it. The screens of the creator get their words, in
|
|
953
960
|
* the page's language, from `useCreatorLanguage`.
|
|
954
961
|
*/
|
|
955
|
-
export declare const translateEnglish: import("@widgetic/design-system/i18n").Translate<"creator.common.close" | "creator.common.new" | "creator.common.doubleClickToRename" | "creator.common.thisAppNeedsARefresh" | "creator.common.reload" | "creator.common.publish" | "creator.common.switchVersion" | "creator.common.live" | "creator.common.buildThisDraftVersionAnd" | "creator.common.setLive" | "creator.common.retry" | "creator.common.delete" | "creator.common.draft" | "creator.common.loading" | "creator.general.unknownError" | "creator.general.couldNotLoadUploadedImage" | "creator.general.tryUploadingTheImageAgain" | "creator.general.uploadFailed" | "creator.general.couldNotUpdateConversationStatus" | "creator.general.changeUndone" | "creator.general.failedToLoadEditorSettings" | "creator.general.setTo" | "creator.general.failedToUpdate" | "creator.general.failedToSaveDimensions" | "creator.general.nothingToSave" | "creator.general.serviceTemporarilyUnavailable" | "creator.general.retryingWhenTheApiIs" | "creator.general.invalidFileType" | "creator.general.pleaseSelectAnImageFile" | "creator.general.imageTooLarge" | "creator.general.maximumImageSizeIsMb" | "creator.general.tooManyImages" | "creator.general.maximumImagesAllowedRemoveAn" | "creator.general.failedToProcessImage" | "creator.general.couldNotReadTheImage" | "creator.general.imagePasted" | "creator.general.screenshotCaptureFailed" | "creator.general.missingOperationId" | "creator.general.switchToThatPanelTo" | "creator.general.limitReached" | "creator.general.rateLimited" | "creator.general.theApiRateLimitWas" | "creator.general.liveV" | "creator.general.anUnexpectedErrorOccurredPlease" | "creator.general.latestCommitIsAlreadyLive" | "creator.general.theServerRefusedTheRename" | "creator.general.checkYourConnectionAndTry" | "creator.general.unableToReachTheApi" | "creator.general.pleaseWaitForTheCurrent" | "creator.general.created" | "creator.general.saveBlocked" | "creator.general.keptALocalCopyCheck" | "creator.general.apiClientUnavailable" | "creator.general.screenshotCouldNotBeCaptured" | "creator.general.fixTheSelectionZoomOut" | "creator.general.checkConsoleForDetails" | "creator.general.retryLoad" | "creator.general.dismiss" | "creator.general.saving" | "creator.general.saved" | "creator.general.saveError" | "creator.general.loadingHistory" | "creator.general.upgrade" | "creator.general.fixInCreate" | "creator.general.save" | "creator.general.cancel" | "creator.general.noEditableSettingsAvailableYet" | "creator.general.dimensions" | "creator.general.w" | "creator.general.h" | "creator.general.px" | "creator.general.copy" | "creator.general.testPage" | "creator.general.zoomedReference" | "creator.general.keepInDatabase" | "creator.general.deleteFromDatabase" | "creator.general.checkingWhatWillBeDeleted" | "creator.general.describeWhatYouWant" | "creator.session.endedStartAgain" | "creator.session.canvasCannotOpen" | "creator.session.sessionEnded" | "creator.session.sessionExpiredSignInAgain" | "creator.session.sessionExpired" | "creator.session.authenticationExpired" | "creator.session.pleaseLoginAgainToContinue" | "creator.session.signInAgainToPublish" | "creator.session.loginRequiredToDuplicateWidget" | "creator.session.pleaseLoginFirst" | "creator.session.authenticationRequired" | "creator.session.pleaseLoginBeforeCreatingA" | "creator.session.thisWidgetReferencesARepository" | "creator.session.signInAgainThenRetry" | "creator.widget.notFound" | "creator.widget.fallbackName" | "creator.widget.noWidgetSelected" | "creator.widget.shapeRemoved" | "creator.widget.widgetKeptInDatabase" | "creator.widget.widgetDeletedFromDatabase" | "creator.widget.widgetWasAlreadyDeleted" | "creator.widget.failedToDeleteWidgetFrom" | "creator.widget.selectAWidgetFirst" | "creator.widget.duplicateFromTheHeaderCopies" | "creator.widget.failedToLoadWidgets" | "creator.widget.couldNotRestoreShapesYet" | "creator.widget.widgetRenamedTo" | "creator.widget.failedToRenameWidget" | "creator.widget.capturingWidgetScreenshot" | "creator.widget.widgetsApiClientIsNot" | "creator.widget.unlinkedWidgetShape" | "creator.widget.duplicatingWidget" | "creator.widget.failedToDuplicateWidget" | "creator.widget.widgetDuplicated" | "creator.widget.widgetKeptInDatabase2" | "creator.widget.youCanKeepEditingWidgets" | "creator.widget.widgetDraftCreated" | "creator.widget.failedToPrepareWidgetDraft" | "creator.widget.failedToCreateWidgetFrom" | "creator.widget.widgetCreatedButNoId" | "creator.widget.widgetCreated" | "creator.widget.failedToFinalizeWidgetConversion" | "creator.widget.repoIdToDeleteUse" | "creator.widget.restoreShapes" | "creator.widget.directWidgetUrl" | "creator.widget.deleteWidgetShape" | "creator.widget.theseWidgetsBelongToMore" | "creator.canvas.appearsEmptyButWidgets" | "creator.canvas.restoredShapes" | "creator.canvas.removedTheLeftoverShapeFrom" | "creator.canvas.clickAWidgetOnThe" | "creator.canvas.canvasIsNotReadyYet" | "creator.canvas.failedToLoadCanvases" | "creator.canvas.couldNotDeleteThisCanvas" | "creator.canvas.noCanvasIdCannotLoad" | "creator.canvas.canvasMayStillBeLoading" | "creator.canvas.widgetPreviewUpdatedOnCanvas" | "creator.canvas.widgetCanvasAndRepositoryAre" | "creator.canvas.canvasIsRequiredBeforePublishing" | "creator.canvas.thisShapePointsToA" | "creator.canvas.shapeRemovedFromCanvas" | "creator.canvas.canvasIsTakingLongerThan" | "creator.canvas.canvasShapesFailedToRender" | "creator.canvas.failedToLoadCanvasFrom" | "creator.canvas.canvasLoadFailedCheckSupabase" | "creator.canvas.apiMayBeThrottledOr" | "creator.canvas.canvasSnapshotLookedEmptyRefresh" | "creator.canvas.canvasSaved" | "creator.canvas.sketchRestored" | "creator.canvas.canvasSaveFailed" | "creator.canvas.canvasSavedLocally" | "creator.canvas.noCanvasIdYet" | "creator.canvas.canvasUnavailable" | "creator.canvas.canvasShapesFailedToLoad" | "creator.canvas.shapeDataMayBeMissing" | "creator.canvas.deleteCanvas" | "creator.composition.compositionCreated" | "creator.composition.failedToCreateComposition" | "creator.composition.compositionSaved" | "creator.composition.compositionRenamed" | "creator.composition.failedToRenameComposition" | "creator.composition.compositionDeleted" | "creator.composition.failedToDeleteComposition" | "creator.composition.fixTheSyntaxErrorIn" | "creator.composition.compositions" | "creator.composition.selectComposition" | "creator.composition.deleteThisComposition" | "creator.composition.webComponentFormatRequiresA" | "creator.composition.compositionUrl" | "creator.codegen.referenceImages" | "creator.codegen.referenceNumber" | "creator.codegen.missingReferenceImage" | "creator.codegen.unreadableAttachmentsTitle" | "creator.codegen.unreadableAttachments" | "creator.codegen.missingImageError" | "creator.codegen.visionModelNote" | "creator.codegen.noImageTitle" | "creator.codegen.repositoryCreated" | "creator.codegen.failedToCreateRepository" | "creator.codegen.noVisionNote" | "creator.codegen.codeRevertedToCommitRefreshing" | "creator.codegen.widgetCodeAtCommitRefreshing" | "creator.codegen.gitRollbackMayNotHave" | "creator.codegen.codeGenerationCompleted" | "creator.codegen.generationInProgress" | "creator.codegen.reconnectedToAnActiveCode" | "creator.codegen.generationStopped" | "creator.codegen.codeGenerationWasCancelledYou" | "creator.codegen.couldNotStopGeneration" | "creator.codegen.generationMayStillBeRunning" | "creator.codegen.imageAddedToYourPrompt" | "creator.codegen.generateCodeFirstToCapture" | "creator.codegen.previewIsMissingTheCapture" | "creator.codegen.promptTooShort" | "creator.codegen.pleaseProvideAPromptWith" | "creator.codegen.mockCodeGenerated" | "creator.codegen.thisIsASimulationNo" | "creator.codegen.missingRepository" | "creator.codegen.coderVision" | "creator.codegen.answeredWithoutGenerating" | "creator.codegen.noGenerationStarted" | "creator.codegen.cannotTrackCodeGenerationProgress" | "creator.codegen.aiGeneratedInvalidSvelteSyntax" | "creator.codegen.codeSavedRebuildingPreview" | "creator.codegen.codeWasNotSaved" | "creator.codegen.codeWasNotSavedToTheRepository" | "creator.codegen.retrySavesItAndRecordsAVersion" | "creator.codegen.generationCompleted" | "creator.codegen.codeSavedPreviewIsLoading" | "creator.codegen.generationAlreadyInProgress" | "creator.codegen.anotherCodeGenerationIsAlready" | "creator.codegen.codeGenerationError" | "creator.codegen.imagePastedToPrompt" | "creator.codegen.codeGenerationInProgressWait" | "creator.codegen.repositoryMissingUseRebuildCode" | "creator.codegen.buildFailedCheckLogsFor" | "creator.codegen.createdWithExistingCode" | "creator.codegen.editTheSketchFreelySending" | "creator.codegen.isReadyGenerationStarted" | "creator.codegen.repositoryIsNowLinkedTo" | "creator.codegen.repositoryExists" | "creator.codegen.repositoryOwnedByAnotherAccount" | "creator.codegen.repositoryFound" | "creator.codegen.linkedToRepository" | "creator.codegen.repositoryReferenceInvalid" | "creator.codegen.supabaseDoesNotHaveThis" | "creator.codegen.unableToVerifyRepositoryStatus" | "creator.codegen.repositoryVerificationFailed" | "creator.codegen.repositoryCreationFailed" | "creator.codegen.couldNotDetermineRepositoryId" | "creator.codegen.repositoryCreatedButNotPersisted" | "creator.codegen.repositoryExistsButFailedTo" | "creator.codegen.repositoryReadyForUse" | "creator.codegen.generationFailed" | "creator.codegen.previewBuilderIsUnavailable" | "creator.codegen.theWidgetCodeWasSaved" | "creator.codegen.rebuildInCreate" | "creator.codegen.codeDoesNotCompile" | "creator.codegen.latestCodeDoesNotCompile" | "creator.codegen.generateCodeFirstToCustomize" | "creator.codegen.noWidgetCodeYet" | "creator.codegen.goToStep1Create" | "creator.codegen.confirmCodeGeneration" | "creator.codegen.reviewThePromptAndReference" | "creator.codegen.describeTheWidgetYouWant" | "creator.codegen.prompt" | "creator.codegen.editPromptFirst" | "creator.codegen.generateNow" | "creator.preview.newerThanLive" | "creator.preview.mayShowLive" | "creator.preview.rebuilt" | "creator.preview.versionHasCodeError" | "creator.preview.versionCouldNotLoad" | "creator.preview.versionHourlyLimit" | "creator.preview.recompiledIn" | "creator.preview.commitRefreshed" | "creator.preview.noValidPreviewAvailable" | "creator.preview.theWidgetDidNotRespond" | "creator.preview.captureErrorRefreshThePreview" | "creator.preview.imageWaitsForGeneration" | "creator.preview.savingImage" | "creator.preview.imageSaved" | "creator.preview.couldNotSaveImage" | "creator.preview.imageNotReturned" | "creator.version.checkpointRestored" | "creator.version.restoreCompletedWithWarnings" | "creator.version.failedToRestoreCheckpoint" | "creator.version.versionIsNowLive" | "creator.version.version" | "creator.version.theSelectedDraftVersionWas" | "creator.version.thisIsADraftVersion" | "creator.version.thisVersionIsNowWhat" | "creator.version.versionRenamed" | "creator.version.versionTitleCleared" | "creator.version.couldNotRenameTheVersion" | "creator.version.closeVersionHistory" | "creator.publish.cannotPublish" | "creator.publish.noEditableSettingsFoundGenerate" | "creator.publish.publishingViaWidgetBuilder" | "creator.publish.widgetPublished" | "creator.publish.publishedAutomaticallyAfterCodeGeneration" | "creator.publish.publishFailed" | "creator.publish.publishing" | "creator.publish.publishingInProgress" | "creator.publish.anotherWidgetIsPublishingWait" | "creator.publish.publishIsRunningInAnother" | "creator.publish.thisVersionIsAlreadyPublished" | "creator.publish.thisDraftHasNoRecorded" | "creator.publish.generateWidgetCodeBeforePublishing" | "creator.publish.publishWidget" | "creator.publish.publishChanges" | "creator.publish.noNewVersionToPublish" | "creator.publish.publishNewV" | "creator.publish.generateOrRebuildSoWe" | "creator.publish.cannotPublishYet" | "creator.publish.publishedVSuccessfully" | "creator.publish.published" | "creator.publish.widgetPublishFailed" | "creator.publish.failedToLoadPublishHistory" | "creator.publish.pressPublishToMakeThe" | "creator.publish.failedToSetLiveVersion" | "creator.publish.publishTheLatestGeneratedCode" | "creator.publish.liveGenerateNewCodeTo" | "creator.publish.publishThisVersionSoVisitors" | "creator.publish.noHistoryRecordsYetGenerate" | "creator.publish.retryPublish" | "creator.publish.notPublishedYet" | "creator.publish.generateOnCreatePreviewThe" | "creator.publish.widgetNotPublishedYet" | "creator.publish.publishYourWidgetFromThe" | "creator.publish.publishYourWidgetFromTheCreate" | "creator.embed.codeTitle" | "creator.embed.formatIframe" | "creator.embed.formatWebComponent" | "creator.embed.copied" | "creator.embed.versionIsLiveAndReady" | "creator.embed.embedYourWidget" | "creator.embed.setDimensionsAndCopyThe" | "creator.embed.embedWidth" | "creator.embed.embedHeight" | "creator.embed.copyEmbedCode" | "creator.embed.embedFormat" | "creator.dialog.removeShape" | "creator.dialog.alsoDeleteWidget" | "creator.dialog.deleteCanvas" | "creator.dialog.alsoDeleteWidgets" | "creator.status.label" | "creator.status.preparingCodeGeneration" | "creator.status.ready" | "creator.status.completedPreviewReady" | "creator.status.generationCompletePreviewReady" | "creator.status.completedAutoSaving" | "creator.status.completedSaved" | "creator.status.completedChangesSaved" | "creator.status.failed" | "creator.status.stoppedByUser" | "creator.status.fixingCompilationErrors" | "creator.status.generatingMockCode" | "creator.status.mockCodeComplete" | "creator.status.processingQueuedRequest" | "creator.status.sessionExpired" | "creator.status.repositoryRequired" | "creator.status.runningQueued" | "creator.status.repositoryReady" | "creator.status.answeredFromDetails" | "creator.status.needMoreDetail" | "creator.status.noGenerationNeeded" | "creator.status.authenticationExpired" | "creator.status.noOperationId" | "creator.status.processingQueued" | "creator.status.inProgress" | "creator.status.generating" | "creator.status.generatingProgress" | "creator.status.savedBuildingPreview" | "creator.status.savedLoadingPreview" | "creator.status.savedPreviewRebuilt" | "creator.status.alreadySavedCompilingPreview" | "creator.status.alreadySavedShaCompilingPreview" | "creator.status.alreadySavedPreviewFailed" | "creator.status.alreadySavedShaPreviewFailed" | "creator.status.previewReady" | "creator.status.alreadyRunning" | "creator.status.needsRefresh" | "creator.status.limitReached" | "creator.status.rateLimited" | "creator.status.failedWithReason" | "creator.status.reconnected" | "creator.conversation.version" | "creator.conversation.previousVersion" | "creator.conversation.restoredFromCommit" | "creator.conversation.completedCommitPreviewLoading" | "creator.conversation.completedCommitPreviewReady" | "creator.conversation.completedPreviewLoading" | "creator.conversation.codeSavedShaBuilding" | "creator.conversation.codeSavedShaLoading" | "creator.conversation.codeSavedShaRebuilt" | "creator.conversation.codeSavedCommitPreviewFailed" | "creator.conversation.stoppedRetryPrompt" | "creator.conversation.previewRecompiled" | "creator.conversation.previewRecompiledCommitPart" | "creator.conversation.previewRecompiledDurationPart" | "creator.conversation.alreadyDoneWithCommit" | "creator.conversation.alreadyDone" | "creator.conversation.alreadyDoneFilesSuffix" | "creator.conversation.convert" | "creator.conversation.widgetConversion" | "creator.error.generationFailedWhileYouWere" | "creator.error.generationTrackingLost" | "creator.error.unableToResolveRepositoryFor" | "creator.error.authenticationExpiredPleaseLoginAgain" | "creator.error.cannotTrackCodeGenerationProgress" | "creator.error.usageLimitExceeded" | "creator.error.tooManyRequestsPleaseTry" | "creator.error.codeGenerationFailed" | "creator.error.widgetBuilderIsNotReachable" | "creator.error.buildRequestFailed" | "creator.error.notAuthenticated" | "creator.error.apiClientIsNotConfigured" | "creator.error.publishedVersionIsNotAvailable" | "creator.error.failedToCompileWidgetCode" | "creator.error.previewNotReadyYetClick" | "creator.error.previewNotReadyYetClickRebuild" | "creator.error.previewLoadedButTheWidget" | "creator.error.previewTimedOutTheDev" | "creator.error.couldNotOpenPreviewUrl" | "creator.error.couldNotFetchThePreview" | "creator.error.widgetPreviewRuntimeErrorHttp" | "creator.error.previewBuildFailed" | "creator.error.savedCodeCouldNotBeCompiled" | "creator.error.couldNotReachThePreview" | "creator.error.previewRebuildIsUnavailableIn" | "creator.error.previewBuilderIsUnavailableThe" | "creator.error.previewBuilderReturnedAnUnexpected" | "creator.error.anUnknownErrorOccurred" | "creator.error.couldNotReachTheServer" | "creator.error.buildFailed" | "creator.details.fixThePromptOrAttachments" | "creator.details.codeGenerationWillStartShortly" | "creator.details.saveWillExecuteShortly" | "creator.details.codeGenerationQueued" | "creator.details.saveQueued" | "creator.details.closeWidgetDetails" | "creator.details.widgetDraft" | "creator.details.createWidgetCode" | "creator.details.create" | "creator.details.editComposition" | "creator.details.publishTheWidgetToEdit" | "creator.details.edit" | "creator.details.embedThePublishedWidget" | "creator.details.publishTheWidgetToGet" | "creator.details.embed" | "creator.details.openLivePreview" | "creator.details.closeLivePreview" | "creator.details.showLivePreview" | "creator.details.preview" | "creator.details.dragToResizeChatPreview" | "creator.details.livePreview" | "creator.details.recompileWidgetCodeForPreview" | "creator.details.rebuilding" | "creator.details.rebuild" | "creator.details.clickToFocusThisWidget" | "creator.details.livePreviewBelow" | "creator.details.generatingCode" | "creator.details.loadingPreview" | "creator.details.sketchDraft" | "creator.details.yourSketchIsStillOn" | "creator.details.sendThePromptInChat" | "creator.details.preparingWidget" | "creator.details.settingUpRepository" | "creator.details.widgetHasNoRepository" | "creator.details.repositoryCreationFailedPreviouslyClick" | "creator.details.createRepository" | "creator.details.noCodeYet" | "creator.details.writeAPromptAndGenerate" | "creator.details.generateNow" | "creator.details.previewUnavailable" | "creator.details.rebuildCode" | "creator.details.fixCompileError" | "creator.details.retryBuild" | "creator.details.retry" | "creator.details.buildingPreview" | "creator.details.compilingWidgetCode" | "creator.details.previewWillAppearAfterCode" | "creator.details.resizePanel" | "creator.details.resizeWidth" | "creator.details.resizeHeight" | "creator.brandKit.addFont" | "creator.brandKit.fontLabel" | "creator.brandKit.brandKit" | "creator.brandKit.languageIsFixedAfterThe" | "creator.brandKit.selectLanguage" | "creator.brandKit.libraries" | "creator.brandKit.addLibrary" | "creator.brandKit.uploadLibrary" | "creator.brandKit.removeLibrary" | "creator.brandKit.replacesTheWidgeticPaletteFor" | "creator.brandKit.colorPalette" | "creator.brandKit.primary" | "creator.brandKit.secondary" | "creator.brandKit.title" | "creator.brandKit.sub" | "creator.brandKit.fonts" | "creator.brandKit.font" | "creator.brandKit.removeFont" | "creator.brandKit.uploadFonts" | "creator.brandKit.uploadAFontFileOr" | "creator.brandKit.urlArchiveWoff2TtfOtf" | "creator.brandKit.removeUploadedFont" | "creator.brandKit.icons" | "creator.brandKit.addIconLibrary" | "creator.brandKit.removeIconLibrary" | "creator.brandKit.uploadCustomLibraryTooltip" | "creator.brandKit.uploadIconLibraryTooltip" | "creator.brandKit.urlLibraries" | "creator.brandKit.urlIcons" | "creator.livePreviews.dragWidget" | "creator.livePreviews.primaryWidget" | "creator.livePreviews.setPrimary" | "creator.livePreviews.publishLatest" | "creator.livePreviews.currentlyLive" | "creator.livePreviews.makeThisVersionLive" | "creator.livePreviews.publishThisDraft" | "creator.livePreviews.noCommitToPublish" | "creator.livePreviews.currentVersion" | "creator.livePreviews.editMode" | "creator.livePreviews.refreshPreview" | "creator.livePreviews.refresh" | "creator.livePreviews.openChat" | "creator.livePreviews.chat" | "creator.livePreviews.liveWidgetPreview" | "creator.livePreviews.building" | "creator.versions.addTitle" | "creator.versions.renameVersion" | "creator.versions.addVersionTitle" | "creator.versions.addATitleForThis" | "creator.versions.notPublishedPreviewOnly" | "creator.versions.live" | "creator.selector.select" | "creator.selector.doubleClickToRename" | "creator.selector.toggleList" | "creator.selector.noItemsFound" | "creator.name.unnamed" | "creator.name.saveName" | "creator.name.renameWidget" | "creator.designEdit.shownAsAppliedTheseControls" | "creator.designEdit.notAvailableInThisWidget" | "creator.fileSource.uploadFile" | "creator.fileSource.url" | "creator.elementSelector.removeSelectedElement" | "creator.elementSelector.clickPartToReference" | "creator.elementSelector.parentChild" | "creator.elementSelector.hold" | "creator.elementSelector.cmdCtrl" | "creator.elementSelector.toInteract" | "creator.elementSelector.esc" | "creator.elementSelector.done">;
|
|
962
|
+
export declare const translateEnglish: import("@widgetic/design-system/i18n").Translate<"creator.common.close" | "creator.common.new" | "creator.common.doubleClickToRename" | "creator.common.thisAppNeedsARefresh" | "creator.common.reload" | "creator.common.publish" | "creator.common.switchVersion" | "creator.common.live" | "creator.common.buildThisDraftVersionAnd" | "creator.common.setLive" | "creator.common.retry" | "creator.common.delete" | "creator.common.draft" | "creator.common.loading" | "creator.general.unknownError" | "creator.general.couldNotLoadUploadedImage" | "creator.general.tryUploadingTheImageAgain" | "creator.general.uploadFailed" | "creator.general.couldNotUpdateConversationStatus" | "creator.general.changeUndone" | "creator.general.failedToLoadEditorSettings" | "creator.general.setTo" | "creator.general.failedToUpdate" | "creator.general.failedToSaveDimensions" | "creator.general.nothingToSave" | "creator.general.serviceTemporarilyUnavailable" | "creator.general.retryingWhenTheApiIs" | "creator.general.invalidFileType" | "creator.general.pleaseSelectAnImageFile" | "creator.general.imageTooLarge" | "creator.general.maximumImageSizeIsMb" | "creator.general.tooManyImages" | "creator.general.maximumImagesAllowedRemoveAn" | "creator.general.failedToProcessImage" | "creator.general.couldNotReadTheImage" | "creator.general.imagePasted" | "creator.general.screenshotCaptureFailed" | "creator.general.missingOperationId" | "creator.general.switchToThatPanelTo" | "creator.general.limitReached" | "creator.general.rateLimited" | "creator.general.theApiRateLimitWas" | "creator.general.liveV" | "creator.general.anUnexpectedErrorOccurredPlease" | "creator.general.latestCommitIsAlreadyLive" | "creator.general.theServerRefusedTheRename" | "creator.general.checkYourConnectionAndTry" | "creator.general.unableToReachTheApi" | "creator.general.pleaseWaitForTheCurrent" | "creator.general.created" | "creator.general.saveBlocked" | "creator.general.keptALocalCopyCheck" | "creator.general.apiClientUnavailable" | "creator.general.screenshotCouldNotBeCaptured" | "creator.general.fixTheSelectionZoomOut" | "creator.general.checkConsoleForDetails" | "creator.general.retryLoad" | "creator.general.dismiss" | "creator.general.saving" | "creator.general.saved" | "creator.general.saveError" | "creator.general.loadingHistory" | "creator.general.upgrade" | "creator.general.fixInCreate" | "creator.general.save" | "creator.general.cancel" | "creator.general.noEditableSettingsAvailableYet" | "creator.general.dimensions" | "creator.general.w" | "creator.general.h" | "creator.general.px" | "creator.general.copy" | "creator.general.testPage" | "creator.general.zoomedReference" | "creator.general.keepInDatabase" | "creator.general.deleteFromDatabase" | "creator.general.checkingWhatWillBeDeleted" | "creator.general.describeWhatYouWant" | "creator.session.endedStartAgain" | "creator.session.canvasCannotOpen" | "creator.session.sessionEnded" | "creator.session.sessionExpiredSignInAgain" | "creator.session.sessionExpired" | "creator.session.authenticationExpired" | "creator.session.pleaseLoginAgainToContinue" | "creator.session.signInAgainToPublish" | "creator.session.loginRequiredToDuplicateWidget" | "creator.session.pleaseLoginFirst" | "creator.session.authenticationRequired" | "creator.session.pleaseLoginBeforeCreatingA" | "creator.session.thisWidgetReferencesARepository" | "creator.session.signInAgainThenRetry" | "creator.widget.notFound" | "creator.widget.fallbackName" | "creator.widget.noWidgetSelected" | "creator.widget.shapeRemoved" | "creator.widget.widgetKeptInDatabase" | "creator.widget.widgetDeletedFromDatabase" | "creator.widget.widgetWasAlreadyDeleted" | "creator.widget.failedToDeleteWidgetFrom" | "creator.widget.selectAWidgetFirst" | "creator.widget.duplicateFromTheHeaderCopies" | "creator.widget.failedToLoadWidgets" | "creator.widget.couldNotRestoreShapesYet" | "creator.widget.widgetRenamedTo" | "creator.widget.failedToRenameWidget" | "creator.widget.capturingWidgetScreenshot" | "creator.widget.widgetsApiClientIsNot" | "creator.widget.unlinkedWidgetShape" | "creator.widget.duplicatingWidget" | "creator.widget.failedToDuplicateWidget" | "creator.widget.widgetDuplicated" | "creator.widget.widgetKeptInDatabase2" | "creator.widget.youCanKeepEditingWidgets" | "creator.widget.widgetDraftCreated" | "creator.widget.failedToPrepareWidgetDraft" | "creator.widget.failedToCreateWidgetFrom" | "creator.widget.widgetCreatedButNoId" | "creator.widget.widgetCreated" | "creator.widget.failedToFinalizeWidgetConversion" | "creator.widget.repoIdToDeleteUse" | "creator.widget.restoreShapes" | "creator.widget.directWidgetUrl" | "creator.widget.deleteWidgetShape" | "creator.widget.theseWidgetsBelongToMore" | "creator.canvas.appearsEmptyButWidgets" | "creator.canvas.restoredShapes" | "creator.canvas.removedTheLeftoverShapeFrom" | "creator.canvas.clickAWidgetOnThe" | "creator.canvas.canvasIsNotReadyYet" | "creator.canvas.failedToLoadCanvases" | "creator.canvas.couldNotDeleteThisCanvas" | "creator.canvas.noCanvasIdCannotLoad" | "creator.canvas.canvasMayStillBeLoading" | "creator.canvas.widgetPreviewUpdatedOnCanvas" | "creator.canvas.widgetCanvasAndRepositoryAre" | "creator.canvas.canvasIsRequiredBeforePublishing" | "creator.canvas.thisShapePointsToA" | "creator.canvas.shapeRemovedFromCanvas" | "creator.canvas.canvasIsTakingLongerThan" | "creator.canvas.canvasShapesFailedToRender" | "creator.canvas.failedToLoadCanvasFrom" | "creator.canvas.canvasLoadFailedCheckSupabase" | "creator.canvas.apiMayBeThrottledOr" | "creator.canvas.canvasSnapshotLookedEmptyRefresh" | "creator.canvas.canvasSaved" | "creator.canvas.sketchRestored" | "creator.canvas.canvasSaveFailed" | "creator.canvas.canvasSavedLocally" | "creator.canvas.noCanvasIdYet" | "creator.canvas.canvasUnavailable" | "creator.canvas.canvasShapesFailedToLoad" | "creator.canvas.shapeDataMayBeMissing" | "creator.canvas.deleteCanvas" | "creator.composition.compositionCreated" | "creator.composition.failedToCreateComposition" | "creator.composition.compositionSaved" | "creator.composition.compositionRenamed" | "creator.composition.failedToRenameComposition" | "creator.composition.compositionDeleted" | "creator.composition.failedToDeleteComposition" | "creator.composition.fixTheSyntaxErrorIn" | "creator.composition.compositions" | "creator.composition.selectComposition" | "creator.composition.deleteThisComposition" | "creator.composition.webComponentFormatRequiresA" | "creator.composition.compositionUrl" | "creator.codegen.referenceImages" | "creator.codegen.referenceNumber" | "creator.codegen.missingReferenceImage" | "creator.codegen.unreadableAttachmentsTitle" | "creator.codegen.unreadableAttachments" | "creator.codegen.missingImageError" | "creator.codegen.visionModelNote" | "creator.codegen.noImageTitle" | "creator.codegen.repositoryCreated" | "creator.codegen.failedToCreateRepository" | "creator.codegen.noVisionNote" | "creator.codegen.codeRevertedToCommitRefreshing" | "creator.codegen.widgetCodeAtCommitRefreshing" | "creator.codegen.gitRollbackMayNotHave" | "creator.codegen.codeGenerationCompleted" | "creator.codegen.generationInProgress" | "creator.codegen.reconnectedToAnActiveCode" | "creator.codegen.generationStopped" | "creator.codegen.codeGenerationWasCancelledYou" | "creator.codegen.couldNotStopGeneration" | "creator.codegen.generationMayStillBeRunning" | "creator.codegen.imageAddedToYourPrompt" | "creator.codegen.generateCodeFirstToCapture" | "creator.codegen.previewIsMissingTheCapture" | "creator.codegen.promptTooShort" | "creator.codegen.pleaseProvideAPromptWith" | "creator.codegen.mockCodeGenerated" | "creator.codegen.thisIsASimulationNo" | "creator.codegen.missingRepository" | "creator.codegen.coderVision" | "creator.codegen.answeredWithoutGenerating" | "creator.codegen.noGenerationStarted" | "creator.codegen.cannotTrackCodeGenerationProgress" | "creator.codegen.aiGeneratedInvalidSvelteSyntax" | "creator.codegen.codeSavedRebuildingPreview" | "creator.codegen.codeWasNotSaved" | "creator.codegen.codeWasNotSavedToTheRepository" | "creator.codegen.retrySavesItAndRecordsAVersion" | "creator.codegen.generationCompleted" | "creator.codegen.codeSavedPreviewIsLoading" | "creator.codegen.generationAlreadyInProgress" | "creator.codegen.anotherCodeGenerationIsAlready" | "creator.codegen.teammateIsGeneratingSince" | "creator.codegen.generationRunningInTheWidget" | "creator.codegen.yourGenerationRunsElsewhere" | "creator.codegen.newerCodeWasSaved" | "creator.codegen.chosenVersionIsOutOfDate" | "creator.codegen.codeGenerationError" | "creator.codegen.imagePastedToPrompt" | "creator.codegen.codeGenerationInProgressWait" | "creator.codegen.repositoryMissingUseRebuildCode" | "creator.codegen.buildFailedCheckLogsFor" | "creator.codegen.createdWithExistingCode" | "creator.codegen.editTheSketchFreelySending" | "creator.codegen.isReadyGenerationStarted" | "creator.codegen.repositoryIsNowLinkedTo" | "creator.codegen.repositoryExists" | "creator.codegen.repositoryOwnedByAnotherAccount" | "creator.codegen.repositoryFound" | "creator.codegen.linkedToRepository" | "creator.codegen.repositoryReferenceInvalid" | "creator.codegen.supabaseDoesNotHaveThis" | "creator.codegen.unableToVerifyRepositoryStatus" | "creator.codegen.repositoryVerificationFailed" | "creator.codegen.repositoryCreationFailed" | "creator.codegen.couldNotDetermineRepositoryId" | "creator.codegen.repositoryCreatedButNotPersisted" | "creator.codegen.repositoryExistsButFailedTo" | "creator.codegen.repositoryReadyForUse" | "creator.codegen.previewBuilderIsUnavailable" | "creator.codegen.theWidgetCodeWasSaved" | "creator.codegen.rebuildInCreate" | "creator.codegen.codeDoesNotCompile" | "creator.codegen.latestCodeDoesNotCompile" | "creator.codegen.generateCodeFirstToCustomize" | "creator.codegen.noWidgetCodeYet" | "creator.codegen.goToStep1Create" | "creator.codegen.confirmCodeGeneration" | "creator.codegen.reviewThePromptAndReference" | "creator.codegen.describeTheWidgetYouWant" | "creator.codegen.prompt" | "creator.codegen.editPromptFirst" | "creator.codegen.generateNow" | "creator.preview.newerThanLive" | "creator.preview.mayShowLive" | "creator.preview.rebuilt" | "creator.preview.versionHasCodeError" | "creator.preview.versionCouldNotLoad" | "creator.preview.versionHourlyLimit" | "creator.preview.recompiledIn" | "creator.preview.commitRefreshed" | "creator.preview.noValidPreviewAvailable" | "creator.preview.theWidgetDidNotRespond" | "creator.preview.captureErrorRefreshThePreview" | "creator.preview.imageWaitsForGeneration" | "creator.preview.savingImage" | "creator.preview.imageSaved" | "creator.preview.couldNotSaveImage" | "creator.preview.imageNotReturned" | "creator.version.checkpointRestored" | "creator.version.restoreCompletedWithWarnings" | "creator.version.failedToRestoreCheckpoint" | "creator.version.restoreRefusedWhileGenerating" | "creator.version.restoreRefusedNewerCode" | "creator.version.restoreRefusedLatestCodeUnknown" | "creator.version.versionIsNowLive" | "creator.version.version" | "creator.version.theSelectedDraftVersionWas" | "creator.version.thisIsADraftVersion" | "creator.version.thisVersionIsNowWhat" | "creator.version.versionRenamed" | "creator.version.versionTitleCleared" | "creator.version.couldNotRenameTheVersion" | "creator.version.closeVersionHistory" | "creator.publish.cannotPublish" | "creator.publish.noEditableSettingsFoundGenerate" | "creator.publish.publishingViaWidgetBuilder" | "creator.publish.widgetPublished" | "creator.publish.publishedAutomaticallyAfterCodeGeneration" | "creator.publish.publishFailed" | "creator.publish.publishing" | "creator.publish.publishingInProgress" | "creator.publish.anotherWidgetIsPublishingWait" | "creator.publish.publishIsRunningInAnother" | "creator.publish.thisVersionIsAlreadyPublished" | "creator.publish.thisDraftHasNoRecorded" | "creator.publish.generateWidgetCodeBeforePublishing" | "creator.publish.publishWidget" | "creator.publish.publishChanges" | "creator.publish.noNewVersionToPublish" | "creator.publish.publishNewV" | "creator.publish.generateOrRebuildSoWe" | "creator.publish.cannotPublishYet" | "creator.publish.publishedVSuccessfully" | "creator.publish.published" | "creator.publish.widgetPublishFailed" | "creator.publish.failedToLoadPublishHistory" | "creator.publish.pressPublishToMakeThe" | "creator.publish.failedToSetLiveVersion" | "creator.publish.publishTheLatestGeneratedCode" | "creator.publish.liveGenerateNewCodeTo" | "creator.publish.publishThisVersionSoVisitors" | "creator.publish.noHistoryRecordsYetGenerate" | "creator.publish.retryPublish" | "creator.publish.notPublishedYet" | "creator.publish.generateOnCreatePreviewThe" | "creator.publish.widgetNotPublishedYet" | "creator.publish.publishYourWidgetFromThe" | "creator.publish.publishYourWidgetFromTheCreate" | "creator.embed.codeTitle" | "creator.embed.formatIframe" | "creator.embed.formatWebComponent" | "creator.embed.copied" | "creator.embed.versionIsLiveAndReady" | "creator.embed.embedYourWidget" | "creator.embed.setDimensionsAndCopyThe" | "creator.embed.embedWidth" | "creator.embed.embedHeight" | "creator.embed.copyEmbedCode" | "creator.embed.embedFormat" | "creator.dialog.removeShape" | "creator.dialog.alsoDeleteWidget" | "creator.dialog.deleteCanvas" | "creator.dialog.alsoDeleteWidgets" | "creator.status.label" | "creator.status.preparingCodeGeneration" | "creator.status.ready" | "creator.status.completedPreviewReady" | "creator.status.generationCompletePreviewReady" | "creator.status.completedAutoSaving" | "creator.status.completedSaved" | "creator.status.completedChangesSaved" | "creator.status.failed" | "creator.status.stoppedByUser" | "creator.status.fixingCompilationErrors" | "creator.status.generatingMockCode" | "creator.status.mockCodeComplete" | "creator.status.processingQueuedRequest" | "creator.status.sessionExpired" | "creator.status.repositoryRequired" | "creator.status.runningQueued" | "creator.status.repositoryReady" | "creator.status.answeredFromDetails" | "creator.status.needMoreDetail" | "creator.status.noGenerationNeeded" | "creator.status.authenticationExpired" | "creator.status.noOperationId" | "creator.status.processingQueued" | "creator.status.inProgress" | "creator.status.generating" | "creator.status.generatingProgress" | "creator.status.savedBuildingPreview" | "creator.status.savedLoadingPreview" | "creator.status.savedPreviewRebuilt" | "creator.status.alreadySavedCompilingPreview" | "creator.status.alreadySavedShaCompilingPreview" | "creator.status.alreadySavedPreviewFailed" | "creator.status.alreadySavedShaPreviewFailed" | "creator.status.previewReady" | "creator.status.alreadyRunning" | "creator.status.needsRefresh" | "creator.status.limitReached" | "creator.status.rateLimited" | "creator.status.failedWithReason" | "creator.status.reconnected" | "creator.conversation.version" | "creator.conversation.previousVersion" | "creator.conversation.restoredFromCommit" | "creator.conversation.completedCommitPreviewLoading" | "creator.conversation.completedCommitPreviewReady" | "creator.conversation.completedPreviewLoading" | "creator.conversation.codeSavedShaBuilding" | "creator.conversation.codeSavedShaLoading" | "creator.conversation.codeSavedShaRebuilt" | "creator.conversation.codeSavedCommitPreviewFailed" | "creator.conversation.stoppedRetryPrompt" | "creator.conversation.previewRecompiled" | "creator.conversation.previewRecompiledCommitPart" | "creator.conversation.previewRecompiledDurationPart" | "creator.conversation.alreadyDoneWithCommit" | "creator.conversation.alreadyDone" | "creator.conversation.alreadyDoneFilesSuffix" | "creator.conversation.convert" | "creator.conversation.widgetConversion" | "creator.error.generationFailedWhileYouWere" | "creator.error.generationTrackingLost" | "creator.error.unableToResolveRepositoryFor" | "creator.error.authenticationExpiredPleaseLoginAgain" | "creator.error.cannotTrackCodeGenerationProgress" | "creator.error.usageLimitExceeded" | "creator.error.tooManyRequestsPleaseTry" | "creator.error.codeGenerationFailed" | "creator.error.widgetBuilderIsNotReachable" | "creator.error.buildRequestFailed" | "creator.error.notAuthenticated" | "creator.error.apiClientIsNotConfigured" | "creator.error.publishedVersionIsNotAvailable" | "creator.error.failedToCompileWidgetCode" | "creator.error.previewNotReadyYetClick" | "creator.error.previewNotReadyYetClickRebuild" | "creator.error.previewLoadedButTheWidget" | "creator.error.previewTimedOutTheDev" | "creator.error.couldNotOpenPreviewUrl" | "creator.error.couldNotFetchThePreview" | "creator.error.widgetPreviewRuntimeErrorHttp" | "creator.error.previewBuildFailed" | "creator.error.savedCodeCouldNotBeCompiled" | "creator.error.couldNotReachThePreview" | "creator.error.previewRebuildIsUnavailableIn" | "creator.error.previewBuilderIsUnavailableThe" | "creator.error.previewBuilderReturnedAnUnexpected" | "creator.error.anUnknownErrorOccurred" | "creator.error.couldNotReachTheServer" | "creator.error.buildFailed" | "creator.details.fixThePromptOrAttachments" | "creator.details.codeGenerationWillStartShortly" | "creator.details.saveWillExecuteShortly" | "creator.details.codeGenerationQueued" | "creator.details.saveQueued" | "creator.details.closeWidgetDetails" | "creator.details.widgetDraft" | "creator.details.createWidgetCode" | "creator.details.create" | "creator.details.editComposition" | "creator.details.publishTheWidgetToEdit" | "creator.details.edit" | "creator.details.embedThePublishedWidget" | "creator.details.publishTheWidgetToGet" | "creator.details.embed" | "creator.details.openLivePreview" | "creator.details.closeLivePreview" | "creator.details.showLivePreview" | "creator.details.preview" | "creator.details.dragToResizeChatPreview" | "creator.details.livePreview" | "creator.details.recompileWidgetCodeForPreview" | "creator.details.rebuilding" | "creator.details.rebuild" | "creator.details.clickToFocusThisWidget" | "creator.details.livePreviewBelow" | "creator.details.generatingCode" | "creator.details.loadingPreview" | "creator.details.sketchDraft" | "creator.details.yourSketchIsStillOn" | "creator.details.sendThePromptInChat" | "creator.details.preparingWidget" | "creator.details.settingUpRepository" | "creator.details.widgetHasNoRepository" | "creator.details.repositoryCreationFailedPreviouslyClick" | "creator.details.createRepository" | "creator.details.noCodeYet" | "creator.details.writeAPromptAndGenerate" | "creator.details.generateNow" | "creator.details.previewUnavailable" | "creator.details.rebuildCode" | "creator.details.fixCompileError" | "creator.details.retryBuild" | "creator.details.retry" | "creator.details.buildingPreview" | "creator.details.compilingWidgetCode" | "creator.details.previewWillAppearAfterCode" | "creator.details.resizePanel" | "creator.details.resizeWidth" | "creator.details.resizeHeight" | "creator.brandKit.addFont" | "creator.brandKit.fontLabel" | "creator.brandKit.brandKit" | "creator.brandKit.languageIsFixedAfterThe" | "creator.brandKit.selectLanguage" | "creator.brandKit.libraries" | "creator.brandKit.addLibrary" | "creator.brandKit.uploadLibrary" | "creator.brandKit.removeLibrary" | "creator.brandKit.replacesTheWidgeticPaletteFor" | "creator.brandKit.colorPalette" | "creator.brandKit.primary" | "creator.brandKit.secondary" | "creator.brandKit.title" | "creator.brandKit.sub" | "creator.brandKit.fonts" | "creator.brandKit.font" | "creator.brandKit.removeFont" | "creator.brandKit.uploadFonts" | "creator.brandKit.uploadAFontFileOr" | "creator.brandKit.urlArchiveWoff2TtfOtf" | "creator.brandKit.removeUploadedFont" | "creator.brandKit.icons" | "creator.brandKit.addIconLibrary" | "creator.brandKit.removeIconLibrary" | "creator.brandKit.uploadCustomLibraryTooltip" | "creator.brandKit.uploadIconLibraryTooltip" | "creator.brandKit.urlLibraries" | "creator.brandKit.urlIcons" | "creator.livePreviews.dragWidget" | "creator.livePreviews.primaryWidget" | "creator.livePreviews.setPrimary" | "creator.livePreviews.publishLatest" | "creator.livePreviews.currentlyLive" | "creator.livePreviews.makeThisVersionLive" | "creator.livePreviews.publishThisDraft" | "creator.livePreviews.noCommitToPublish" | "creator.livePreviews.currentVersion" | "creator.livePreviews.editMode" | "creator.livePreviews.refreshPreview" | "creator.livePreviews.refresh" | "creator.livePreviews.openChat" | "creator.livePreviews.chat" | "creator.livePreviews.liveWidgetPreview" | "creator.livePreviews.building" | "creator.versions.addTitle" | "creator.versions.renameVersion" | "creator.versions.addVersionTitle" | "creator.versions.addATitleForThis" | "creator.versions.notPublishedPreviewOnly" | "creator.versions.live" | "creator.selector.select" | "creator.selector.doubleClickToRename" | "creator.selector.toggleList" | "creator.selector.noItemsFound" | "creator.name.unnamed" | "creator.name.saveName" | "creator.name.renameWidget" | "creator.designEdit.shownAsAppliedTheseControls" | "creator.designEdit.notAvailableInThisWidget" | "creator.fileSource.uploadFile" | "creator.fileSource.url" | "creator.elementSelector.removeSelectedElement" | "creator.elementSelector.clickPartToReference" | "creator.elementSelector.parentChild" | "creator.elementSelector.hold" | "creator.elementSelector.cmdCtrl" | "creator.elementSelector.toInteract" | "creator.elementSelector.esc" | "creator.elementSelector.done">;
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -216,6 +216,11 @@ export declare const CREATOR_MESSAGES: {
|
|
|
216
216
|
readonly 'creator.codegen.codeSavedPreviewIsLoading': "Code saved. Preview is loading.";
|
|
217
217
|
readonly 'creator.codegen.generationAlreadyInProgress': "Generation already in progress";
|
|
218
218
|
readonly 'creator.codegen.anotherCodeGenerationIsAlready': "Another code generation is already running. Wait for it to finish or cancel it first.";
|
|
219
|
+
readonly 'creator.codegen.teammateIsGeneratingSince': "A teammate has been generating in this widget since {time}. Your request was not sent: send it again when that generation has finished.";
|
|
220
|
+
readonly 'creator.codegen.generationRunningInTheWidget': "Another generation is already running in this widget. Your request was not sent: send it again when it has finished.";
|
|
221
|
+
readonly 'creator.codegen.yourGenerationRunsElsewhere': "You already have a generation running in this widget, in another window or app. Your request was not sent: send it again when it has finished.";
|
|
222
|
+
readonly 'creator.codegen.newerCodeWasSaved': "Newer code was saved";
|
|
223
|
+
readonly 'creator.codegen.chosenVersionIsOutOfDate': "The widget changed after you chose that version, so nothing was generated. Check the version list, choose the version again, then send your request.";
|
|
219
224
|
readonly 'creator.codegen.codeGenerationError': "Code generation error";
|
|
220
225
|
readonly 'creator.codegen.imagePastedToPrompt': "Image pasted to prompt";
|
|
221
226
|
readonly 'creator.codegen.codeGenerationInProgressWait': "Code generation in progress — wait until it finishes.";
|
|
@@ -238,7 +243,6 @@ export declare const CREATOR_MESSAGES: {
|
|
|
238
243
|
readonly 'creator.codegen.repositoryCreatedButNotPersisted': "Repository created but not persisted";
|
|
239
244
|
readonly 'creator.codegen.repositoryExistsButFailedTo': "Repository exists but failed to sync with widget record. Try generating code to resync.";
|
|
240
245
|
readonly 'creator.codegen.repositoryReadyForUse': "Repository {id}… ready for use.";
|
|
241
|
-
readonly 'creator.codegen.generationFailed': "Generation Failed";
|
|
242
246
|
readonly 'creator.codegen.previewBuilderIsUnavailable': "Preview builder is unavailable";
|
|
243
247
|
readonly 'creator.codegen.theWidgetCodeWasSaved': "The widget code was saved, but the preview service could not compile it. This is not a Svelte syntax error. Go back to Create and use Rebuild.";
|
|
244
248
|
readonly 'creator.codegen.rebuildInCreate': "🔄 Rebuild in Create";
|
|
@@ -272,6 +276,9 @@ export declare const CREATOR_MESSAGES: {
|
|
|
272
276
|
readonly 'creator.version.checkpointRestored': "Checkpoint restored";
|
|
273
277
|
readonly 'creator.version.restoreCompletedWithWarnings': "Restore completed with warnings";
|
|
274
278
|
readonly 'creator.version.failedToRestoreCheckpoint': "Failed to restore checkpoint";
|
|
279
|
+
readonly 'creator.version.restoreRefusedWhileGenerating': "Nothing was restored because a generation is running in this widget. Try again when it has finished.";
|
|
280
|
+
readonly 'creator.version.restoreRefusedNewerCode': "Nothing was restored because newer code was saved after this checkpoint was shown. Check the version list, then restore again if you still want this checkpoint.";
|
|
281
|
+
readonly 'creator.version.restoreRefusedLatestCodeUnknown': "Nothing was restored because the latest code could not be checked. Try again in a moment.";
|
|
275
282
|
readonly 'creator.version.versionIsNowLive': "Version {version} is now live.";
|
|
276
283
|
readonly 'creator.version.version': "Version {version}";
|
|
277
284
|
readonly 'creator.version.theSelectedDraftVersionWas': "The selected draft version was not found.";
|
package/dist/i18n/messages.js
CHANGED
|
@@ -223,6 +223,12 @@ export const CREATOR_MESSAGES = {
|
|
|
223
223
|
'creator.codegen.codeSavedPreviewIsLoading': 'Code saved. Preview is loading.',
|
|
224
224
|
'creator.codegen.generationAlreadyInProgress': 'Generation already in progress',
|
|
225
225
|
'creator.codegen.anotherCodeGenerationIsAlready': 'Another code generation is already running. Wait for it to finish or cancel it first.',
|
|
226
|
+
// A generation the API refused because a run holds the widget's code, or because newer code was saved after the person looked
|
|
227
|
+
'creator.codegen.teammateIsGeneratingSince': 'A teammate has been generating in this widget since {time}. Your request was not sent: send it again when that generation has finished.',
|
|
228
|
+
'creator.codegen.generationRunningInTheWidget': 'Another generation is already running in this widget. Your request was not sent: send it again when it has finished.',
|
|
229
|
+
'creator.codegen.yourGenerationRunsElsewhere': 'You already have a generation running in this widget, in another window or app. Your request was not sent: send it again when it has finished.',
|
|
230
|
+
'creator.codegen.newerCodeWasSaved': 'Newer code was saved',
|
|
231
|
+
'creator.codegen.chosenVersionIsOutOfDate': 'The widget changed after you chose that version, so nothing was generated. Check the version list, choose the version again, then send your request.',
|
|
226
232
|
'creator.codegen.codeGenerationError': 'Code generation error',
|
|
227
233
|
'creator.codegen.imagePastedToPrompt': 'Image pasted to prompt',
|
|
228
234
|
'creator.codegen.codeGenerationInProgressWait': 'Code generation in progress — wait until it finishes.',
|
|
@@ -245,7 +251,6 @@ export const CREATOR_MESSAGES = {
|
|
|
245
251
|
'creator.codegen.repositoryCreatedButNotPersisted': 'Repository created but not persisted',
|
|
246
252
|
'creator.codegen.repositoryExistsButFailedTo': 'Repository exists but failed to sync with widget record. Try generating code to resync.',
|
|
247
253
|
'creator.codegen.repositoryReadyForUse': 'Repository {id}… ready for use.',
|
|
248
|
-
'creator.codegen.generationFailed': 'Generation Failed',
|
|
249
254
|
'creator.codegen.previewBuilderIsUnavailable': 'Preview builder is unavailable',
|
|
250
255
|
'creator.codegen.theWidgetCodeWasSaved': 'The widget code was saved, but the preview service could not compile it. This is not a Svelte syntax error. Go back to Create and use Rebuild.',
|
|
251
256
|
'creator.codegen.rebuildInCreate': '🔄 Rebuild in Create',
|
|
@@ -281,6 +286,10 @@ export const CREATOR_MESSAGES = {
|
|
|
281
286
|
'creator.version.checkpointRestored': 'Checkpoint restored',
|
|
282
287
|
'creator.version.restoreCompletedWithWarnings': 'Restore completed with warnings',
|
|
283
288
|
'creator.version.failedToRestoreCheckpoint': 'Failed to restore checkpoint',
|
|
289
|
+
// A restore the API refused before it deleted a message or touched a file (the toast's title is the line above)
|
|
290
|
+
'creator.version.restoreRefusedWhileGenerating': 'Nothing was restored because a generation is running in this widget. Try again when it has finished.',
|
|
291
|
+
'creator.version.restoreRefusedNewerCode': 'Nothing was restored because newer code was saved after this checkpoint was shown. Check the version list, then restore again if you still want this checkpoint.',
|
|
292
|
+
'creator.version.restoreRefusedLatestCodeUnknown': 'Nothing was restored because the latest code could not be checked. Try again in a moment.',
|
|
284
293
|
'creator.version.versionIsNowLive': 'Version {version} is now live.',
|
|
285
294
|
'creator.version.version': 'Version {version}',
|
|
286
295
|
'creator.version.theSelectedDraftVersionWas': 'The selected draft version was not found.',
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three fields of a generation request (`POST /agent/code/generate`) that a request carries only when there is something
|
|
3
|
+
* to say, and that an editor session (a partner's customer) may not carry at all.
|
|
4
|
+
*
|
|
5
|
+
* - `baseCommitSha`: the older version the person chose to build on, when it is not the head of the code.
|
|
6
|
+
* - `expectedHeadSha`: the head they chose that version on, so the API can refuse the request, before it charges anything,
|
|
7
|
+
* when newer code was saved since (a teammate, another window).
|
|
8
|
+
* - `textDocuments`: the words of the Markdown and text files attached to the message.
|
|
9
|
+
*
|
|
10
|
+
* Two things about how they travel, which the generated API client made visible when it was regenerated (1.0.46):
|
|
11
|
+
*
|
|
12
|
+
* 1. A field that is there with `null` is a field. The client writes `baseCommitSha: null` into the body when it is given
|
|
13
|
+
* `null`, and the gateway's door for an editor session refuses a body with a field it does not list, whatever the value. So
|
|
14
|
+
* a field with nothing to say is left out, not sent empty.
|
|
15
|
+
* 2. The gateway's list of what an editor session may send in a generation does not have these three (the list is what the
|
|
16
|
+
* generation reads for a visitor: the request is refused whole, `403 EDITOR_SESSION_FIELD_NOT_ALLOWED`, and the visitor
|
|
17
|
+
* cannot generate at all). The client of the modules until now (1.0.29) did not know the three fields and dropped them
|
|
18
|
+
* without a word, so with a session's token the AI has always built on the latest code from the message alone. It still
|
|
19
|
+
* does; the creator now says so by leaving them out (`mayNameVersionOrDocumentsInGeneration(token)` of
|
|
20
|
+
* `host/creatorHost.ts` is the question; a Shopify store's token is not a session's, has no such door, and so names them).
|
|
21
|
+
*
|
|
22
|
+
* It is plain TypeScript with no Svelte in it, so a test can hold it to both.
|
|
23
|
+
*/
|
|
24
|
+
/** What the creator knows when it builds a generation request. */
|
|
25
|
+
export interface GenerationVersionAndDocumentInput<TextDocument> {
|
|
26
|
+
/** `mayNameVersionOrDocumentsInGeneration(token)`: false for the token of an editor session. */
|
|
27
|
+
mayNameVersionOrDocuments: boolean;
|
|
28
|
+
/** The version the person chose to build on, when it is not the head; null or undefined when they build on the head. */
|
|
29
|
+
baseCommitSha: string | null | undefined;
|
|
30
|
+
/** The head they chose that version on; null or undefined when the creator knows no head it could name. */
|
|
31
|
+
expectedHeadSha: string | null | undefined;
|
|
32
|
+
/** The words of the text documents attached to the message. */
|
|
33
|
+
textDocuments: readonly TextDocument[] | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** The fields of the generation request that are there only when there is something to say. */
|
|
36
|
+
export interface GenerationVersionAndDocumentFields<TextDocument> {
|
|
37
|
+
baseCommitSha?: string;
|
|
38
|
+
expectedHeadSha?: string;
|
|
39
|
+
textDocuments?: TextDocument[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The fields to add to a generation request: none for an editor session, and for any other token only the ones that have
|
|
43
|
+
* something to say. The head to compare with goes only with a chosen version (it is the head that version was chosen on).
|
|
44
|
+
*/
|
|
45
|
+
export declare function generationVersionAndDocumentFields<TextDocument>(input: GenerationVersionAndDocumentInput<TextDocument>): GenerationVersionAndDocumentFields<TextDocument>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The three fields of a generation request (`POST /agent/code/generate`) that a request carries only when there is something
|
|
3
|
+
* to say, and that an editor session (a partner's customer) may not carry at all.
|
|
4
|
+
*
|
|
5
|
+
* - `baseCommitSha`: the older version the person chose to build on, when it is not the head of the code.
|
|
6
|
+
* - `expectedHeadSha`: the head they chose that version on, so the API can refuse the request, before it charges anything,
|
|
7
|
+
* when newer code was saved since (a teammate, another window).
|
|
8
|
+
* - `textDocuments`: the words of the Markdown and text files attached to the message.
|
|
9
|
+
*
|
|
10
|
+
* Two things about how they travel, which the generated API client made visible when it was regenerated (1.0.46):
|
|
11
|
+
*
|
|
12
|
+
* 1. A field that is there with `null` is a field. The client writes `baseCommitSha: null` into the body when it is given
|
|
13
|
+
* `null`, and the gateway's door for an editor session refuses a body with a field it does not list, whatever the value. So
|
|
14
|
+
* a field with nothing to say is left out, not sent empty.
|
|
15
|
+
* 2. The gateway's list of what an editor session may send in a generation does not have these three (the list is what the
|
|
16
|
+
* generation reads for a visitor: the request is refused whole, `403 EDITOR_SESSION_FIELD_NOT_ALLOWED`, and the visitor
|
|
17
|
+
* cannot generate at all). The client of the modules until now (1.0.29) did not know the three fields and dropped them
|
|
18
|
+
* without a word, so with a session's token the AI has always built on the latest code from the message alone. It still
|
|
19
|
+
* does; the creator now says so by leaving them out (`mayNameVersionOrDocumentsInGeneration(token)` of
|
|
20
|
+
* `host/creatorHost.ts` is the question; a Shopify store's token is not a session's, has no such door, and so names them).
|
|
21
|
+
*
|
|
22
|
+
* It is plain TypeScript with no Svelte in it, so a test can hold it to both.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* The fields to add to a generation request: none for an editor session, and for any other token only the ones that have
|
|
26
|
+
* something to say. The head to compare with goes only with a chosen version (it is the head that version was chosen on).
|
|
27
|
+
*/
|
|
28
|
+
export function generationVersionAndDocumentFields(input) {
|
|
29
|
+
const fields = {};
|
|
30
|
+
if (!input.mayNameVersionOrDocuments)
|
|
31
|
+
return fields;
|
|
32
|
+
if (input.baseCommitSha) {
|
|
33
|
+
fields.baseCommitSha = input.baseCommitSha;
|
|
34
|
+
if (input.expectedHeadSha)
|
|
35
|
+
fields.expectedHeadSha = input.expectedHeadSha;
|
|
36
|
+
}
|
|
37
|
+
if (input.textDocuments && input.textDocuments.length > 0) {
|
|
38
|
+
fields.textDocuments = [...input.textDocuments];
|
|
39
|
+
}
|
|
40
|
+
return fields;
|
|
41
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Translate } from '@widgetic/design-system/i18n';
|
|
2
|
+
import type { CreatorMessageKey } from '../i18n/messages.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the API says when it turns a request away because of what somebody else is doing in the same widget.
|
|
5
|
+
*
|
|
6
|
+
* A widget's code has one author at a time. While a generation runs, a second generation and a restore of a checkpoint are
|
|
7
|
+
* refused with `409 BUSINESS_STATE_CONFLICT` and `error.details.reason: 'generation_in_progress'`: `heldBy` says whether the
|
|
8
|
+
* run is the caller's own (`'you'`: another window, another device, an app) or somebody else's (`'another_member'`), and
|
|
9
|
+
* never a name; `startedAt` says since when; `operationId`, given only to the person who started the run, is the run to
|
|
10
|
+
* follow. A generation of a chosen older version, and a restore of a checkpoint, can say which head of the code the person
|
|
11
|
+
* saw (`expectedHeadSha`); newer code saved since is refused with `409` and `details.reason: 'repository_head_changed'`
|
|
12
|
+
* (`expectedHeadSha`, `currentHeadSha`) before anything is charged, deleted or written. A restore that cannot read the head
|
|
13
|
+
* it was asked to compare with is `503 SERVICE_UNAVAILABLE`: a head that cannot be read is no confirmation.
|
|
14
|
+
*
|
|
15
|
+
* This reads those answers, and says what each means in the visitor's words. It is plain TypeScript with no Svelte in it,
|
|
16
|
+
* so a test can hold it to the shapes the API gives (the gateway's `generationLockRoutes.test.ts` and
|
|
17
|
+
* `restoreCheckpointRoute.test.ts` are the other half of that agreement).
|
|
18
|
+
*/
|
|
19
|
+
/** Who holds the widget's code, as far as the API says. The API never names a person, so neither does the creator. */
|
|
20
|
+
export type GenerationHolder = 'you' | 'another_member' | 'unknown';
|
|
21
|
+
/** A run holds the widget's code. */
|
|
22
|
+
export interface GenerationInProgressRefusal {
|
|
23
|
+
kind: 'generation_in_progress';
|
|
24
|
+
heldBy: GenerationHolder;
|
|
25
|
+
/** When the run that holds the widget began, when the API said. */
|
|
26
|
+
startedAt: Date | null;
|
|
27
|
+
/** The run to follow. The API gives it only to the person who started the run, and only when it knows it. */
|
|
28
|
+
operationId: string | null;
|
|
29
|
+
}
|
|
30
|
+
/** Newer code was saved after the person looked at the head the request names. */
|
|
31
|
+
export interface RepositoryHeadChangedRefusal {
|
|
32
|
+
kind: 'repository_head_changed';
|
|
33
|
+
/** The head the person saw, when the API repeated it. */
|
|
34
|
+
expectedHeadSha: string | null;
|
|
35
|
+
/** The head now, when the API said. */
|
|
36
|
+
currentHeadSha: string | null;
|
|
37
|
+
}
|
|
38
|
+
/** What a refused request comes to. `other` is anything this file does not know: the caller keeps what it did before. */
|
|
39
|
+
export type TeamEditingRefusal = GenerationInProgressRefusal | RepositoryHeadChangedRefusal
|
|
40
|
+
/** The restore could not read the head of the code to compare it with the one the person saw (503): nothing was restored. */
|
|
41
|
+
| {
|
|
42
|
+
kind: 'latest_code_unreadable';
|
|
43
|
+
} | {
|
|
44
|
+
kind: 'other';
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Reads an answer the API gave: its HTTP status, and its JSON body (`{ success: false, error: { code, message, details } }`).
|
|
48
|
+
* Anything that is not one of the refusals above is `other`; a body that is not the gateway's (a proxy's page, nothing at all)
|
|
49
|
+
* is `other` too, whatever the status.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readTeamEditingRefusal(status: number | undefined, body: unknown): TeamEditingRefusal;
|
|
52
|
+
/**
|
|
53
|
+
* Reads what the generated client threw (`ResponseError`, with the native `Response` on it). The body is read from a copy, so
|
|
54
|
+
* whoever else reads the answer (the page's limit reporter, the creator's own message) still can. A failure that is not an
|
|
55
|
+
* answer of the API (the network, an abort) is `other`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function readTeamEditingRefusalOf(error: unknown): Promise<TeamEditingRefusal>;
|
|
58
|
+
/**
|
|
59
|
+
* The operation of the person's own generation that a refusal points at, or null when there is none to follow: the API gives
|
|
60
|
+
* an operation id only to the person who started the run, and only when it knows the run.
|
|
61
|
+
*/
|
|
62
|
+
export declare function operationToFollow(refusal: TeamEditingRefusal): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* What a visitor reads when a generation they asked for was refused because a run holds the widget. Who holds it is told as far as
|
|
65
|
+
* the API told it: a teammate (with the time the run began), the person's own other window or app, or just "another generation".
|
|
66
|
+
*/
|
|
67
|
+
export declare function generationRefusalText(refusal: GenerationInProgressRefusal, t: Translate<CreatorMessageKey>, locale: string): string;
|
|
68
|
+
/**
|
|
69
|
+
* What a visitor reads when a restore of a checkpoint was refused before anything was deleted. `other` has no text here: a
|
|
70
|
+
* refusal this file does not know is shown the way every other failure of the restore is.
|
|
71
|
+
*/
|
|
72
|
+
export declare function restoreRefusalText(refusal: TeamEditingRefusal, t: Translate<CreatorMessageKey>): string | null;
|
|
73
|
+
/** The head of the code, when it is one the API accepts as `expectedHeadSha` (7 to 40 hexadecimal digits); otherwise null, and nothing is compared. */
|
|
74
|
+
export declare function headCommitForComparison(sha: string | null | undefined): string | null;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { clockTimeText } from '../i18n/labels.js';
|
|
2
|
+
import { httpStatusOfFailure } from './generationSharing.js';
|
|
3
|
+
const KNOWN_HOLDERS = ['you', 'another_member', 'unknown'];
|
|
4
|
+
/** The id of an operation as the API writes it in a path: no space, slash or query in it. */
|
|
5
|
+
const OPERATION_ID_PATTERN = /^[A-Za-z0-9._-]{1,128}$/;
|
|
6
|
+
/** A commit id as the API writes it: 7 to 40 hexadecimal digits. */
|
|
7
|
+
const COMMIT_ID_PATTERN = /^[0-9a-f]{7,40}$/i;
|
|
8
|
+
const asRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value) ? value : null;
|
|
9
|
+
/**
|
|
10
|
+
* Reads an answer the API gave: its HTTP status, and its JSON body (`{ success: false, error: { code, message, details } }`).
|
|
11
|
+
* Anything that is not one of the refusals above is `other`; a body that is not the gateway's (a proxy's page, nothing at all)
|
|
12
|
+
* is `other` too, whatever the status.
|
|
13
|
+
*/
|
|
14
|
+
export function readTeamEditingRefusal(status, body) {
|
|
15
|
+
const root = asRecord(body);
|
|
16
|
+
const error = asRecord(root?.error) ?? root;
|
|
17
|
+
if (status === 503) {
|
|
18
|
+
return error?.code === 'SERVICE_UNAVAILABLE' ? { kind: 'latest_code_unreadable' } : { kind: 'other' };
|
|
19
|
+
}
|
|
20
|
+
if (status !== 409)
|
|
21
|
+
return { kind: 'other' };
|
|
22
|
+
const details = asRecord(error?.details);
|
|
23
|
+
if (details?.reason === 'generation_in_progress') {
|
|
24
|
+
const heldBy = KNOWN_HOLDERS.find((holder) => holder === details.heldBy) ?? 'unknown';
|
|
25
|
+
const startedAtMs = typeof details.startedAt === 'string' ? Date.parse(details.startedAt) : Number.NaN;
|
|
26
|
+
const operationId = typeof details.operationId === 'string' && OPERATION_ID_PATTERN.test(details.operationId) ? details.operationId : null;
|
|
27
|
+
return {
|
|
28
|
+
kind: 'generation_in_progress',
|
|
29
|
+
heldBy,
|
|
30
|
+
startedAt: Number.isFinite(startedAtMs) ? new Date(startedAtMs) : null,
|
|
31
|
+
operationId,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (details?.reason === 'repository_head_changed') {
|
|
35
|
+
const commitIdOf = (value) => (typeof value === 'string' && COMMIT_ID_PATTERN.test(value) ? value : null);
|
|
36
|
+
return {
|
|
37
|
+
kind: 'repository_head_changed',
|
|
38
|
+
expectedHeadSha: commitIdOf(details.expectedHeadSha),
|
|
39
|
+
currentHeadSha: commitIdOf(details.currentHeadSha),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { kind: 'other' };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Reads what the generated client threw (`ResponseError`, with the native `Response` on it). The body is read from a copy, so
|
|
46
|
+
* whoever else reads the answer (the page's limit reporter, the creator's own message) still can. A failure that is not an
|
|
47
|
+
* answer of the API (the network, an abort) is `other`.
|
|
48
|
+
*/
|
|
49
|
+
export async function readTeamEditingRefusalOf(error) {
|
|
50
|
+
const status = httpStatusOfFailure(error);
|
|
51
|
+
if (status !== 409 && status !== 503)
|
|
52
|
+
return { kind: 'other' };
|
|
53
|
+
const response = error?.response;
|
|
54
|
+
let body = null;
|
|
55
|
+
try {
|
|
56
|
+
body = await response?.clone().json();
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Not JSON, or already read: the status alone says what it can, and a 409 that says nothing more is `other`.
|
|
60
|
+
}
|
|
61
|
+
return readTeamEditingRefusal(status, body);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The operation of the person's own generation that a refusal points at, or null when there is none to follow: the API gives
|
|
65
|
+
* an operation id only to the person who started the run, and only when it knows the run.
|
|
66
|
+
*/
|
|
67
|
+
export function operationToFollow(refusal) {
|
|
68
|
+
return refusal.kind === 'generation_in_progress' && refusal.heldBy === 'you' ? refusal.operationId : null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What a visitor reads when a generation they asked for was refused because a run holds the widget. Who holds it is told as far as
|
|
72
|
+
* the API told it: a teammate (with the time the run began), the person's own other window or app, or just "another generation".
|
|
73
|
+
*/
|
|
74
|
+
export function generationRefusalText(refusal, t, locale) {
|
|
75
|
+
if (refusal.heldBy === 'you')
|
|
76
|
+
return t('creator.codegen.yourGenerationRunsElsewhere');
|
|
77
|
+
if (refusal.heldBy === 'another_member' && refusal.startedAt) {
|
|
78
|
+
return t('creator.codegen.teammateIsGeneratingSince', { time: clockTimeText(refusal.startedAt, locale) });
|
|
79
|
+
}
|
|
80
|
+
return t('creator.codegen.generationRunningInTheWidget');
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* What a visitor reads when a restore of a checkpoint was refused before anything was deleted. `other` has no text here: a
|
|
84
|
+
* refusal this file does not know is shown the way every other failure of the restore is.
|
|
85
|
+
*/
|
|
86
|
+
export function restoreRefusalText(refusal, t) {
|
|
87
|
+
switch (refusal.kind) {
|
|
88
|
+
case 'generation_in_progress':
|
|
89
|
+
return t('creator.version.restoreRefusedWhileGenerating');
|
|
90
|
+
case 'repository_head_changed':
|
|
91
|
+
return t('creator.version.restoreRefusedNewerCode');
|
|
92
|
+
case 'latest_code_unreadable':
|
|
93
|
+
return t('creator.version.restoreRefusedLatestCodeUnknown');
|
|
94
|
+
default:
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** The head of the code, when it is one the API accepts as `expectedHeadSha` (7 to 40 hexadecimal digits); otherwise null, and nothing is compared. */
|
|
99
|
+
export function headCommitForComparison(sha) {
|
|
100
|
+
const trimmed = typeof sha === 'string' ? sha.trim() : '';
|
|
101
|
+
return COMMIT_ID_PATTERN.test(trimmed) ? trimmed : null;
|
|
102
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/creator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.33",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@sveltejs/kit": "^2.20.0",
|
|
8
|
-
"@widgetic/api-sdk": "^1.0.
|
|
8
|
+
"@widgetic/api-sdk": "^1.0.46",
|
|
9
9
|
"@widgetic/cache-layer": "^0.1.2",
|
|
10
10
|
"@widgetic/canvas": "^0.5.27",
|
|
11
11
|
"@widgetic/chat": "^0.1.17",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@tailwindcss/postcss": "^4.1.4",
|
|
73
73
|
"@tailwindcss/typography": "^0.5.15",
|
|
74
74
|
"@types/node": "26.4.0",
|
|
75
|
-
"@widgetic/api-sdk": "^1.0.
|
|
75
|
+
"@widgetic/api-sdk": "^1.0.46",
|
|
76
76
|
"@widgetic/cache-layer": "^0.1.2",
|
|
77
77
|
"@widgetic/canvas": "^0.5.27",
|
|
78
78
|
"@widgetic/chat": "^0.1.17",
|