@widgetic/creator 0.4.43 → 0.4.45
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 +88 -37
- package/dist/CreatorApp.svelte.d.ts +1 -0
- package/dist/components/WidgetDetails.svelte +18 -4
- package/dist/creator-types.d.ts +5 -0
- package/dist/errors/toUserFriendlyError.d.ts +44 -0
- package/dist/errors/toUserFriendlyError.js +236 -0
- package/dist/i18n/language.d.ts +77 -119
- package/dist/i18n/messages.d.ts +9 -0
- package/dist/i18n/messages.js +9 -0
- package/dist/i18n/statusText.d.ts +8 -3
- package/dist/i18n/statusText.js +48 -12
- package/dist/pageHelpers.d.ts +9 -3
- package/dist/pageHelpers.js +37 -15
- package/package.json +11 -11
package/dist/CreatorApp.svelte
CHANGED
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
import {
|
|
158
158
|
normalizeErrorMessage,
|
|
159
159
|
codegenFailureChatLine,
|
|
160
|
+
friendlyTextFromStoredError,
|
|
160
161
|
toErrorMessage,
|
|
161
162
|
deriveApiErrorMessage,
|
|
162
163
|
extractDetailsMessage,
|
|
@@ -167,6 +168,7 @@
|
|
|
167
168
|
sanitizePreviewBuildError,
|
|
168
169
|
isInfrastructurePreviewError
|
|
169
170
|
} from './pageHelpers.js';
|
|
171
|
+
import { CANVAS_LOAD_ERROR_DISPLAY, CODEGEN_ERROR_DISPLAY } from './errors/toUserFriendlyError.js';
|
|
170
172
|
import {
|
|
171
173
|
ChatUploadRefusedError,
|
|
172
174
|
shouldUseTusForChatUpload,
|
|
@@ -344,6 +346,7 @@
|
|
|
344
346
|
export let onLimitReached: CreatorAppProps['onLimitReached'] = undefined;
|
|
345
347
|
export let onCanvasUnavailable: CreatorAppProps['onCanvasUnavailable'] = undefined;
|
|
346
348
|
export let onCanvasChanged: CreatorAppProps['onCanvasChanged'] = undefined;
|
|
349
|
+
export let replaceAddressBarUrl: CreatorAppProps['replaceAddressBarUrl'] = undefined;
|
|
347
350
|
export let onReady: CreatorAppProps['onReady'] = undefined;
|
|
348
351
|
/** Partner library for chat/canvas uploads (see `CreatorAppProps.mediaLibrary`). */
|
|
349
352
|
export let mediaLibrary: CreatorAppProps['mediaLibrary'] = undefined;
|
|
@@ -484,7 +487,12 @@
|
|
|
484
487
|
url.searchParams.delete('canvas-id');
|
|
485
488
|
url.searchParams.delete('widget_id');
|
|
486
489
|
url.searchParams.delete('new_widget');
|
|
487
|
-
|
|
490
|
+
const href = url.toString();
|
|
491
|
+
if (replaceAddressBarUrl) {
|
|
492
|
+
replaceAddressBarUrl(href);
|
|
493
|
+
} else {
|
|
494
|
+
window.history.replaceState(window.history.state, '', href);
|
|
495
|
+
}
|
|
488
496
|
// console.log('[CreatorApp] URL synced to canvas:', canvasIdToSync);
|
|
489
497
|
} catch (err) {
|
|
490
498
|
console.warn('[CreatorApp] Failed to sync canvas URL:', err);
|
|
@@ -1365,6 +1373,15 @@
|
|
|
1365
1373
|
emitCanvasWidgetsList('linked-ids');
|
|
1366
1374
|
}
|
|
1367
1375
|
|
|
1376
|
+
/**
|
|
1377
|
+
* Where the layers of the creator's own confirm dialogs start (`layerBase` of `Dialog.Content`). The design system stacks
|
|
1378
|
+
* dialogs from z 50, and the creator draws its floating panels at z 2003 (`floating-panels-overlay`): a confirm dialog has to
|
|
1379
|
+
* start above that, or the panels would be drawn over it and a click would go through to them. It used to be a global
|
|
1380
|
+
* `[data-dialog-overlay] { z-index: 9998 !important }`, which also lifted the scrim of every dialog of the dashboard above
|
|
1381
|
+
* its panel (see src/lib/dialogLayering.test.ts); this is the same wish, asked of the one dialog that needs it.
|
|
1382
|
+
*/
|
|
1383
|
+
const creatorDialogLayerBase = 2300;
|
|
1384
|
+
|
|
1368
1385
|
// Delete Widget Shape confirmation dialog state
|
|
1369
1386
|
let deleteDialogOpen = false;
|
|
1370
1387
|
let deleteDialogWidgetName = '';
|
|
@@ -2231,7 +2248,7 @@
|
|
|
2231
2248
|
|
|
2232
2249
|
function pushCodegenFailureToChat(widgetId: string, errorText: string) {
|
|
2233
2250
|
const panelChat = getChatMethodsForWidget(widgetId);
|
|
2234
|
-
const content = codegenFailureChatLine(errorText);
|
|
2251
|
+
const content = codegenFailureChatLine(errorText, codegenErrorDisplay);
|
|
2235
2252
|
panelChat?.addAssistantMessage?.(content);
|
|
2236
2253
|
// console.log('[Chat] Codegen failure bubble:', content.slice(0, 160));
|
|
2237
2254
|
}
|
|
@@ -2892,7 +2909,7 @@
|
|
|
2892
2909
|
display_order: att.display_order ?? i + 1,
|
|
2893
2910
|
}));
|
|
2894
2911
|
if (compressedPersistImages.length === 0 && persistFileItems.length === 0) {
|
|
2895
|
-
console.
|
|
2912
|
+
console.debug('[Codegen] Persist user message has no attachment URLs for widget', widgetId?.substring(0, 8));
|
|
2896
2913
|
}
|
|
2897
2914
|
const fileHasImage = persistFileItems.some((att) => {
|
|
2898
2915
|
const type = String(att.file_type || '');
|
|
@@ -6321,6 +6338,8 @@
|
|
|
6321
6338
|
|
|
6322
6339
|
// debugMode — current ON/OFF state. User can still toggle when the UI is available.
|
|
6323
6340
|
let debugMode = debugModeAvailable;
|
|
6341
|
+
$: codegenErrorDisplay = { debugMode, ...CODEGEN_ERROR_DISPLAY };
|
|
6342
|
+
$: canvasLoadErrorDisplay = { debugMode, ...CANVAS_LOAD_ERROR_DISPLAY };
|
|
6324
6343
|
/** Mobile embedded sketch: Canvas | Chat tabs (both panes stay mounted; CSS hides the inactive one). */
|
|
6325
6344
|
let embeddedSketchMobileTab: EmbeddedSketchMobileTab = 'canvas';
|
|
6326
6345
|
$: embeddedSketchShell = embedded && !canvasAdvancedFeatures;
|
|
@@ -7346,13 +7365,16 @@
|
|
|
7346
7365
|
|
|
7347
7366
|
if (operation.status === 'failed') {
|
|
7348
7367
|
if (!announce) return;
|
|
7349
|
-
const
|
|
7368
|
+
const rawFailureText = operation.error || 'Unknown error';
|
|
7369
|
+
const failureText = friendlyTextFromStoredError(rawFailureText, codegenErrorDisplay);
|
|
7350
7370
|
patchCodegenUiState(widgetId, {
|
|
7351
7371
|
generateCodeStatus: '❌ Code generation failed',
|
|
7352
7372
|
lastGenerationFailed: true,
|
|
7353
7373
|
lastGenerationError: failureText,
|
|
7354
7374
|
});
|
|
7355
|
-
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
7375
|
+
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
7376
|
+
codegenFailureChatLine(rawFailureText, codegenErrorDisplay),
|
|
7377
|
+
);
|
|
7356
7378
|
showToast('error', $t('creator.status.failed'), { description: failureText, duration: 8000 });
|
|
7357
7379
|
// What the other tab saved of the failure reaches this tab's conversation
|
|
7358
7380
|
setTimeout(() => {
|
|
@@ -9126,7 +9148,11 @@
|
|
|
9126
9148
|
err
|
|
9127
9149
|
);
|
|
9128
9150
|
// Partner mode: the first read to be told "no such canvas" says so for the whole creator.
|
|
9129
|
-
if (saysCanvasIsMissing(err))
|
|
9151
|
+
if (saysCanvasIsMissing(err))
|
|
9152
|
+
declareCanvasUnavailable(
|
|
9153
|
+
targetCanvasId,
|
|
9154
|
+
toErrorMessage(err, 'Canvas not found', canvasLoadErrorDisplay),
|
|
9155
|
+
);
|
|
9130
9156
|
return null;
|
|
9131
9157
|
}
|
|
9132
9158
|
}
|
|
@@ -11912,7 +11938,10 @@ Requirements:
|
|
|
11912
11938
|
const generateEnvelope = response as unknown as { error?: string; message?: string };
|
|
11913
11939
|
const generateErrorMessage = generateEnvelope && (generateEnvelope.error || generateEnvelope.message);
|
|
11914
11940
|
if (generateErrorMessage) {
|
|
11915
|
-
const normalizedMessage =
|
|
11941
|
+
const normalizedMessage = friendlyTextFromStoredError(
|
|
11942
|
+
normalizeErrorMessage(generateErrorMessage),
|
|
11943
|
+
codegenErrorDisplay,
|
|
11944
|
+
);
|
|
11916
11945
|
patchCodegenUiState(generationWidgetId, {
|
|
11917
11946
|
generateCodeStatus: `❌ Code generation failed: ${normalizedMessage}`,
|
|
11918
11947
|
lastGenerationFailed: true,
|
|
@@ -12003,7 +12032,8 @@ Requirements:
|
|
|
12003
12032
|
}
|
|
12004
12033
|
|
|
12005
12034
|
if (op.status === 'failed') {
|
|
12006
|
-
const
|
|
12035
|
+
const rawErrorMsg = op.error || 'Unknown error';
|
|
12036
|
+
const errorMsg = friendlyTextFromStoredError(rawErrorMsg, codegenErrorDisplay);
|
|
12007
12037
|
patchCodegenUiState(generationWidgetId, {
|
|
12008
12038
|
generateCodeStatus: '❌ Code generation failed',
|
|
12009
12039
|
lastGenerationFailed: true,
|
|
@@ -12011,18 +12041,21 @@ Requirements:
|
|
|
12011
12041
|
});
|
|
12012
12042
|
clearActiveOperationId(generationWidgetId);
|
|
12013
12043
|
|
|
12014
|
-
const isGitlabLimit = /gitlab rate limit|gitlab refused the (save|rollback)|last status code:\s*429/i.test(
|
|
12015
|
-
const isServiceError =
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12044
|
+
const isGitlabLimit = /gitlab rate limit|gitlab refused the (save|rollback)|last status code:\s*429/i.test(rawErrorMsg);
|
|
12045
|
+
const isServiceError =
|
|
12046
|
+
isGitlabLimit ||
|
|
12047
|
+
rawErrorMsg.includes('temporarily unavailable') ||
|
|
12048
|
+
rawErrorMsg.includes('Our team has been notified') ||
|
|
12049
|
+
rawErrorMsg.includes('Too many generation requests');
|
|
12050
|
+
const isSvelteSyntaxError =
|
|
12051
|
+
rawErrorMsg.includes('Svelte') ||
|
|
12052
|
+
rawErrorMsg.includes('rune') ||
|
|
12053
|
+
rawErrorMsg.includes('{#if}') ||
|
|
12054
|
+
rawErrorMsg.includes('{/if}');
|
|
12022
12055
|
|
|
12023
12056
|
const chatMessage = isServiceError
|
|
12024
|
-
? `⚠️ ${
|
|
12025
|
-
:
|
|
12057
|
+
? `⚠️ ${friendlyTextFromStoredError(rawErrorMsg, codegenErrorDisplay)}`
|
|
12058
|
+
: codegenFailureChatLine(rawErrorMsg, codegenErrorDisplay);
|
|
12026
12059
|
panelChat?.addAssistantMessage(chatMessage);
|
|
12027
12060
|
|
|
12028
12061
|
const toastDescription = isServiceError
|
|
@@ -12514,10 +12547,12 @@ Requirements:
|
|
|
12514
12547
|
patchCodegenUiState(generationWidgetId, {
|
|
12515
12548
|
generateCodeStatus: '⚠️ This app needs a refresh to continue.',
|
|
12516
12549
|
lastGenerationFailed: true,
|
|
12517
|
-
lastGenerationError:
|
|
12550
|
+
lastGenerationError: 'This app needs a refresh to continue.',
|
|
12518
12551
|
});
|
|
12519
12552
|
showToast('warning', $t('creator.common.thisAppNeedsARefresh'), {
|
|
12520
|
-
description:
|
|
12553
|
+
description: debugMode
|
|
12554
|
+
? error.message
|
|
12555
|
+
: $t('creator.status.needsRefresh'),
|
|
12521
12556
|
duration: 12000,
|
|
12522
12557
|
action: {
|
|
12523
12558
|
label: $t('creator.common.reload'),
|
|
@@ -12535,7 +12570,7 @@ Requirements:
|
|
|
12535
12570
|
// of half a minute would not help them. (The page is told by the limit middleware.)
|
|
12536
12571
|
if (partnerMode && hourlyBudget) {
|
|
12537
12572
|
console.warn('Widget Creator: the visitor reached their budget during code generation');
|
|
12538
|
-
const limitMessage = await deriveApiErrorMessage(error, 'Usage limit exceeded');
|
|
12573
|
+
const limitMessage = await deriveApiErrorMessage(error, 'Usage limit exceeded', codegenErrorDisplay);
|
|
12539
12574
|
patchCodegenUiState(generationWidgetId, {
|
|
12540
12575
|
generateCodeStatus: '⚠️ Limit reached for now. Please try again later.',
|
|
12541
12576
|
lastGenerationFailed: true,
|
|
@@ -12588,7 +12623,7 @@ Requirements:
|
|
|
12588
12623
|
}
|
|
12589
12624
|
|
|
12590
12625
|
console.error('Widget Creator: Code generation error response:', error);
|
|
12591
|
-
const message = await deriveApiErrorMessage(error, 'Code generation failed.');
|
|
12626
|
+
const message = await deriveApiErrorMessage(error, 'Code generation failed.', codegenErrorDisplay);
|
|
12592
12627
|
patchCodegenUiState(generationWidgetId, {
|
|
12593
12628
|
generateCodeStatus: `❌ ${message}`,
|
|
12594
12629
|
lastGenerationFailed: true,
|
|
@@ -13036,7 +13071,9 @@ Requirements:
|
|
|
13036
13071
|
setGoogleFontsApiKey(String(googleFontsKey));
|
|
13037
13072
|
// console.log('[CreatorApp] Google Fonts API key set for FontIC');
|
|
13038
13073
|
} else {
|
|
13039
|
-
console.
|
|
13074
|
+
console.info(
|
|
13075
|
+
'[CreatorApp] No PUBLIC_GOOGLE_FONTS_API_KEY — FontIC uses its fallback catalog (see site .env.example)'
|
|
13076
|
+
);
|
|
13040
13077
|
}
|
|
13041
13078
|
setWebsocketApiUrl(apiRoot ?? null);
|
|
13042
13079
|
if (partnerMode) {
|
|
@@ -17251,7 +17288,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17251
17288
|
return;
|
|
17252
17289
|
}
|
|
17253
17290
|
|
|
17254
|
-
const derivedMessage = await deriveApiErrorMessage(error, defaultErrorMessage);
|
|
17291
|
+
const derivedMessage = await deriveApiErrorMessage(error, defaultErrorMessage, { debugMode });
|
|
17255
17292
|
authStatus = derivedMessage.startsWith(defaultErrorMessage)
|
|
17256
17293
|
? derivedMessage
|
|
17257
17294
|
: `${defaultErrorMessage}: ${derivedMessage}`;
|
|
@@ -18190,7 +18227,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18190
18227
|
canvasShapesLoaded = true;
|
|
18191
18228
|
} catch (loadErr) {
|
|
18192
18229
|
console.warn('[WidgetCreator] canvasRef.loadCanvas failed/timed out — clearing loading overlay:', loadErr);
|
|
18193
|
-
canvasApiLoadError = toErrorMessage(loadErr, $t('creator.canvas.canvasShapesFailedToRender')
|
|
18230
|
+
canvasApiLoadError = toErrorMessage(loadErr, $t('creator.canvas.canvasShapesFailedToRender'), {
|
|
18231
|
+
debugMode,
|
|
18232
|
+
context: 'canvasLoad',
|
|
18233
|
+
});
|
|
18194
18234
|
}
|
|
18195
18235
|
if (canvasShapesLoaded) canvasApiLoadError = null;
|
|
18196
18236
|
}
|
|
@@ -18212,7 +18252,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18212
18252
|
}
|
|
18213
18253
|
} catch (err) {
|
|
18214
18254
|
console.warn('[WidgetCreator] Failed to load canvas from API:', err);
|
|
18215
|
-
const errMsg = toErrorMessage(err, $t('creator.canvas.failedToLoadCanvasFrom')
|
|
18255
|
+
const errMsg = toErrorMessage(err, $t('creator.canvas.failedToLoadCanvasFrom'), {
|
|
18256
|
+
debugMode,
|
|
18257
|
+
context: 'canvasLoad',
|
|
18258
|
+
});
|
|
18216
18259
|
canvasApiLoadError = errMsg;
|
|
18217
18260
|
// Partner mode: the API says the canvas does not exist for this visitor. It is not an empty canvas to start on
|
|
18218
18261
|
// (the fallbacks below would call it one and say the creator is ready): the page is told, and that is the end.
|
|
@@ -19188,7 +19231,11 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19188
19231
|
|
|
19189
19232
|
console.error('Failed to verify repository', error);
|
|
19190
19233
|
if (!silent) {
|
|
19191
|
-
const message = await deriveApiErrorMessage(
|
|
19234
|
+
const message = await deriveApiErrorMessage(
|
|
19235
|
+
error,
|
|
19236
|
+
$t('creator.codegen.unableToVerifyRepositoryStatus'),
|
|
19237
|
+
codegenErrorDisplay,
|
|
19238
|
+
);
|
|
19192
19239
|
showToast('error', $t('creator.codegen.repositoryVerificationFailed'), {
|
|
19193
19240
|
description: message,
|
|
19194
19241
|
duration: 5000
|
|
@@ -20597,7 +20644,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20597
20644
|
<span class="codegen-save-spinner inline-block h-3 w-3 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-forest-green" aria-hidden="true"></span>
|
|
20598
20645
|
{/if}
|
|
20599
20646
|
<div class="generate-code-status-el text-xs flex-1 min-w-0 truncate text-gray-500">
|
|
20600
|
-
<span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit || ps.lastGenerationFailed ? $t('creator.status.ready') : statusLabel(statusText, $t)}
|
|
20647
|
+
<span class="text-gray-400">{$t('creator.status.label')}</span> {hourlyLimit || ps.lastGenerationFailed ? $t('creator.status.ready') : statusLabel(statusText, $t, codegenErrorDisplay)}
|
|
20601
20648
|
</div>
|
|
20602
20649
|
</div>
|
|
20603
20650
|
{#if publishPlanMessageByWidgetId[panelWidgetId]}
|
|
@@ -20643,7 +20690,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20643
20690
|
>
|
|
20644
20691
|
{#if ps.lastGenerationFailed && !isHourlyLimitText(ps.lastGenerationError)}
|
|
20645
20692
|
<div class="generation-failed-overlay sticky top-0 z-20 mx-3 mt-3 border border-red-200 bg-red-50 p-3">
|
|
20646
|
-
<p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t)}</p>
|
|
20693
|
+
<p class="text-xs text-red-700 whitespace-pre-wrap">{errorLabel(ps.lastGenerationError, $t, codegenErrorDisplay)}</p>
|
|
20647
20694
|
<div class="generation-failed-actions mt-3 flex justify-center gap-2">
|
|
20648
20695
|
{#if isPlanLimitMessage(ps.lastGenerationError)}
|
|
20649
20696
|
<Button
|
|
@@ -20751,7 +20798,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20751
20798
|
<Chat class="code-generation-chat h-full w-full max-w-full rounded-none border-0"
|
|
20752
20799
|
locale={locale}
|
|
20753
20800
|
messages={chatMessages}
|
|
20754
|
-
storedLineLabel={(line) =>
|
|
20801
|
+
storedLineLabel={(line) =>
|
|
20802
|
+
conversationLineLabel(line, $t, codegenErrorDisplay)}
|
|
20755
20803
|
actionBarExtras={generationOptionChecks as any}
|
|
20756
20804
|
style="height: 100%; min-height: {chatUserHeight == null ? CHAT_AUTO_MIN_HEIGHT : CHAT_MIN_HEIGHT}px;"
|
|
20757
20805
|
resizeExpandsContainer={true}
|
|
@@ -21341,7 +21389,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21341
21389
|
<!-- Dialog.Root (bits-ui AlertDialogRoot) exposes no class prop — styling hooks
|
|
21342
21390
|
live on Content/Header below. -->
|
|
21343
21391
|
<Dialog.Root bind:open={deleteDialogOpen} onOpenChange={(open) => { if (!open) handleDeleteDialogResponse('cancel'); }}>
|
|
21344
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-delete-dialog-content max-w-md bg-white z-9999">
|
|
21392
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-delete-dialog-content max-w-md bg-white z-9999">
|
|
21345
21393
|
<Dialog.Header class="confirm-delete-dialog-header">
|
|
21346
21394
|
<Dialog.Title>{$t('creator.widget.deleteWidgetShape')}</Dialog.Title>
|
|
21347
21395
|
<Dialog.Description>
|
|
@@ -21381,7 +21429,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21381
21429
|
|
|
21382
21430
|
<!-- Delete Canvas Confirmation Dialog -->
|
|
21383
21431
|
<Dialog.Root bind:open={showDeleteCanvasDialog} onOpenChange={(open) => { if (!open) { showDeleteCanvasDialog = false; deleteCanvasTarget = null; } }}>
|
|
21384
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-delete-canvas-dialog-content max-w-sm bg-white z-9999">
|
|
21432
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-delete-canvas-dialog-content max-w-sm bg-white z-9999">
|
|
21385
21433
|
<Dialog.Header class="confirm-delete-canvas-dialog-header">
|
|
21386
21434
|
<Dialog.Title>{$t('creator.canvas.deleteCanvas')}</Dialog.Title>
|
|
21387
21435
|
<Dialog.Description>
|
|
@@ -21446,7 +21494,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21446
21494
|
if (!open) confirmGenerateWidgetId = null;
|
|
21447
21495
|
}}
|
|
21448
21496
|
>
|
|
21449
|
-
<Dialog.Content closeLabel={$t('creator.common.close')} class="confirm-generate-dialog-content max-w-lg bg-white z-9999">
|
|
21497
|
+
<Dialog.Content closeLabel={$t('creator.common.close')} layerBase={creatorDialogLayerBase} class="confirm-generate-dialog-content max-w-lg bg-white z-9999">
|
|
21450
21498
|
<Dialog.Header class="confirm-generate-dialog-header">
|
|
21451
21499
|
<Dialog.Title>{$t('creator.codegen.confirmCodeGeneration')}</Dialog.Title>
|
|
21452
21500
|
<Dialog.Description>
|
|
@@ -21571,10 +21619,13 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21571
21619
|
.widget-item:hover .widget-item-edit-icon {
|
|
21572
21620
|
opacity: 1;
|
|
21573
21621
|
}
|
|
21574
|
-
/*
|
|
21575
|
-
|
|
21576
|
-
|
|
21577
|
-
|
|
21622
|
+
/*
|
|
21623
|
+
* No rule for the design system's dialogs here (`[data-dialog-overlay]`, `[data-widgetic-overlay]`): this style block is
|
|
21624
|
+
* global once the creator is loaded, so a `z-index` on the scrim of every dialog reaches the dashboard's too. One did
|
|
21625
|
+
* ("Dialog overlay + content must sit above FabricJS canvas": 9998 !important on the scrim, the panel left at 51) and
|
|
21626
|
+
* every dialog of the page, the Invite dialog first, was drawn under its own blur. The design system orders its own
|
|
21627
|
+
* layers (scrim, panel, popovers) and keeps them out of reach of page CSS; src/lib/dialogLayering.test.ts guards this.
|
|
21628
|
+
*/
|
|
21578
21629
|
.wc-version-history-toggle:focus,
|
|
21579
21630
|
.wc-version-history-toggle:focus-visible,
|
|
21580
21631
|
.wc-live-history-backdrop:focus,
|
|
@@ -49,6 +49,7 @@ declare const CreatorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
49
49
|
onLimitReached?: CreatorAppProps["onLimitReached"];
|
|
50
50
|
onCanvasUnavailable?: CreatorAppProps["onCanvasUnavailable"];
|
|
51
51
|
onCanvasChanged?: CreatorAppProps["onCanvasChanged"];
|
|
52
|
+
replaceAddressBarUrl?: CreatorAppProps["replaceAddressBarUrl"];
|
|
52
53
|
onReady?: CreatorAppProps["onReady"];
|
|
53
54
|
/** Partner library for chat/canvas uploads (see `CreatorAppProps.mediaLibrary`). */ mediaLibrary?: CreatorAppProps["mediaLibrary"];
|
|
54
55
|
/** Optional override for PropsEditor file fields (`purpose: 'field'`). */ mediaLibraryForFields?: CreatorAppProps["mediaLibraryForFields"];
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
import HoverTooltip from './HoverTooltip.svelte';
|
|
39
39
|
import EditableName from './EditableName.svelte';
|
|
40
40
|
import { errorLabel, useCreatorLanguage } from '../i18n/index.js';
|
|
41
|
+
import { CODEGEN_ERROR_DISPLAY } from '../errors/toUserFriendlyError.js';
|
|
41
42
|
import { useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
42
43
|
import { distanceTowardEnd, opensOnRightOfShape, roomBeforeNeighbour } from '../utils/directionPlacement.js';
|
|
43
44
|
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
export const isCheckingActiveGeneration: boolean = false;
|
|
99
100
|
export let lastCommitId: string | null = null;
|
|
100
101
|
export let debugMode: boolean = false;
|
|
102
|
+
$: codegenErrorDisplay = { debugMode, ...CODEGEN_ERROR_DISPLAY };
|
|
101
103
|
export let forceMockReady: boolean = false;
|
|
102
104
|
// Passed by CreatorApp but never read here — export const keeps the
|
|
103
105
|
// init-set contract without the unused-reactive warning.
|
|
@@ -1604,7 +1606,12 @@
|
|
|
1604
1606
|
}
|
|
1605
1607
|
|
|
1606
1608
|
const status = buildErr?.response?.status ?? buildErr?.status;
|
|
1607
|
-
const
|
|
1609
|
+
const isAuthFailure =
|
|
1610
|
+
status === 401 ||
|
|
1611
|
+
status === 403 ||
|
|
1612
|
+
/\bunauthorized\b/i.test(lastBuildErrorMsg);
|
|
1613
|
+
const isRetryable =
|
|
1614
|
+
!isAuthFailure && (status === 404 || status === 500 || !status);
|
|
1608
1615
|
if (isRetryable && attempt < maxRetries) {
|
|
1609
1616
|
// console.log(`[WidgetDetails] triggerBuildFromRepo attempt ${attempt}/${maxRetries} failed (${lastBuildErrorMsg}), retrying in ${retryDelayMs}ms...`);
|
|
1610
1617
|
await new Promise(r => setTimeout(r, retryDelayMs));
|
|
@@ -3622,7 +3629,7 @@
|
|
|
3622
3629
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
3623
3630
|
<div
|
|
3624
3631
|
class="widget-details-floating-shell pointer-events-none overflow-visible {showWidgetDetails ? '' : 'hidden'} {dockRight
|
|
3625
|
-
? 'widget-details-dock-right h-full w-full max-lg:relative max-lg:inset-auto lg:absolute lg:inset-y-0 lg:end-0 lg:w-[var(--dock-panel-width)]'
|
|
3632
|
+
? 'widget-details-dock-right h-full max-lg:w-full max-lg:relative max-lg:inset-auto lg:absolute lg:inset-y-0 lg:end-0 lg:w-[var(--dock-panel-width)] lg:max-w-[var(--dock-panel-width)]'
|
|
3626
3633
|
: 'fixed'}"
|
|
3627
3634
|
style={dockRight
|
|
3628
3635
|
? `--dock-panel-width: ${consoleColumnOpen ? CONSOLE_COLUMN_PANEL_WIDTH : DOCKED_CHAT_COLUMN_WIDTH}px; z-index: ${panelZIndex};`
|
|
@@ -4043,7 +4050,7 @@
|
|
|
4043
4050
|
<div class="widget-preview-error-indicator flex flex-col items-center justify-center text-center p-4">
|
|
4044
4051
|
<div class="text-3xl mb-2">⚠️</div>
|
|
4045
4052
|
<div class="font-medium text-sm text-red-600 mb-1">{$t('creator.details.previewUnavailable')}</div>
|
|
4046
|
-
<div class="text-xs max-w-[200px] text-gray-600 mb-3">{errorLabel(previewError, $t)}</div>
|
|
4053
|
+
<div class="text-xs max-w-[200px] text-gray-600 mb-3">{errorLabel(previewError, $t, { debugMode })}</div>
|
|
4047
4054
|
{#if !normalizeRepositoryId(selectedWidget)}
|
|
4048
4055
|
<button type="button" onclick={() => { previewError = null; dispatch('retryRepository', { widgetId: selectedWidgetId }); }} class="px-3 py-1.5 text-xs rounded border border-blue-400 text-blue-600 bg-white hover:bg-blue-50 cursor-pointer font-medium">{$t('creator.details.createRepository')}</button>
|
|
4049
4056
|
{:else}
|
|
@@ -4065,7 +4072,7 @@
|
|
|
4065
4072
|
<div class="widget-preview-generation-error flex flex-col items-center justify-center text-center p-4">
|
|
4066
4073
|
<div class="text-3xl mb-2">⚠️</div>
|
|
4067
4074
|
<div class="font-medium text-sm text-red-600 mb-1">{$t('creator.status.failed')}</div>
|
|
4068
|
-
<div class="text-xs max-w-[220px] text-gray-600 mb-3">{errorLabel(lastGenerationError, $t) || $t('creator.details.fixThePromptOrAttachments')}</div>
|
|
4075
|
+
<div class="text-xs max-w-[220px] text-gray-600 mb-3">{errorLabel(lastGenerationError, $t, codegenErrorDisplay) || $t('creator.details.fixThePromptOrAttachments')}</div>
|
|
4069
4076
|
<button
|
|
4070
4077
|
type="button"
|
|
4071
4078
|
onclick={() => { dispatch('generateNow', { widgetId: selectedWidgetId }); }}
|
|
@@ -4193,6 +4200,13 @@
|
|
|
4193
4200
|
outline: none;
|
|
4194
4201
|
box-shadow: none;
|
|
4195
4202
|
}
|
|
4203
|
+
/** Docked embed chat: column width on lg+ even if Tailwind misses arbitrary lg:w-[var(...)] in dev. */
|
|
4204
|
+
@media (min-width: 1024px) {
|
|
4205
|
+
.widget-details-dock-right.widget-details-floating-shell {
|
|
4206
|
+
width: var(--dock-panel-width);
|
|
4207
|
+
max-width: var(--dock-panel-width);
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4196
4210
|
.widget-details-dock-right :global(.action-bar) {
|
|
4197
4211
|
flex-wrap: nowrap;
|
|
4198
4212
|
gap: 0.35rem;
|
package/dist/creator-types.d.ts
CHANGED
|
@@ -184,6 +184,11 @@ export interface CreatorAppProps {
|
|
|
184
184
|
onPublishStateChanged?: (state: PublishState) => void;
|
|
185
185
|
/** When true, hides auth screen + top bar; syncs session from site localStorage */
|
|
186
186
|
embedded?: boolean;
|
|
187
|
+
/**
|
|
188
|
+
* When embedded in SvelteKit, syncs the address bar without tripping the router warning: the host passes
|
|
189
|
+
* `replaceState` from `$app/navigation`. Omitted: `history.replaceState` keeps the existing state object.
|
|
190
|
+
*/
|
|
191
|
+
replaceAddressBarUrl?: (href: string) => void;
|
|
187
192
|
/**
|
|
188
193
|
* API gateway origin for embedded hosts (e.g. site `PUBLIC_API_URL`).
|
|
189
194
|
* Without this, the creator falls back to the SDK default, `https://api.widgetic.com/v1` (the production API).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type UserFriendlyErrorContext = 'codeGeneration' | 'canvasLoad' | 'generic';
|
|
2
|
+
/** Display options wired through chat and status UI (context literals live here for i18n audits). */
|
|
3
|
+
export declare const CODEGEN_ERROR_DISPLAY: {
|
|
4
|
+
readonly context: "codeGeneration";
|
|
5
|
+
};
|
|
6
|
+
export declare const CANVAS_LOAD_ERROR_DISPLAY: {
|
|
7
|
+
readonly context: "canvasLoad";
|
|
8
|
+
};
|
|
9
|
+
export type UserFriendlyErrorCategory = 'providerNotConfigured' | 'rateLimit' | 'usageLimit' | 'timeout' | 'network' | 'authExpired' | 'notFound' | 'permission' | 'validation' | 'server' | 'unknown';
|
|
10
|
+
export type UserFriendlyErrorOptions = {
|
|
11
|
+
debugMode: boolean;
|
|
12
|
+
context?: UserFriendlyErrorContext;
|
|
13
|
+
};
|
|
14
|
+
export type UserFriendlyErrorResult = {
|
|
15
|
+
userMessage: string;
|
|
16
|
+
technicalDetail: string | null;
|
|
17
|
+
category: UserFriendlyErrorCategory;
|
|
18
|
+
};
|
|
19
|
+
/** Canonical English shown to visitors; single source of truth is the catalog (statusText KNOWN_TEXTS mirrors these). */
|
|
20
|
+
export declare const USER_FRIENDLY_COPY: {
|
|
21
|
+
readonly providerNotConfigured: "Code generation is not available right now. Please try again later.";
|
|
22
|
+
readonly providerNotConfiguredGeneric: "This feature is not available right now. Please try again later.";
|
|
23
|
+
readonly rateLimit: "Too many requests, please try again later.";
|
|
24
|
+
readonly usageLimit: "Usage limit exceeded";
|
|
25
|
+
readonly timeout: "This took too long. Please try again.";
|
|
26
|
+
readonly network: "Could not reach the server. Try again.";
|
|
27
|
+
readonly authExpired: "Authentication expired. Please login again.";
|
|
28
|
+
readonly notFound: "We couldn't find that. It may have been deleted.";
|
|
29
|
+
readonly canvasNotFound: "We couldn't find this sketch. It may have been deleted.";
|
|
30
|
+
readonly permission: "You don't have permission to do that.";
|
|
31
|
+
readonly validation: "Something was wrong with the request. Please check your input and try again.";
|
|
32
|
+
readonly server: "Something went wrong on our side. Please try again in a moment.";
|
|
33
|
+
readonly generic: "Something went wrong. Please try again.";
|
|
34
|
+
readonly codeGenerationFailed: "Code generation failed.";
|
|
35
|
+
};
|
|
36
|
+
/** Strip marks and prefixes the creator adds before showing a stored failure. */
|
|
37
|
+
export declare function stripErrorDecorations(text: string): string;
|
|
38
|
+
/** Whether a stored line still looks like a raw server or runtime error. */
|
|
39
|
+
export declare function isLikelyTechnicalError(text: string): boolean;
|
|
40
|
+
export declare function toUserFriendlyError(error: unknown, options: UserFriendlyErrorOptions): UserFriendlyErrorResult;
|
|
41
|
+
/** What to store or show: friendly text, with technical detail only in debug mode. */
|
|
42
|
+
export declare function formatUserFacingErrorText(error: unknown, options: UserFriendlyErrorOptions): string;
|
|
43
|
+
/** Sanitize a string that is already stored in chat or UI state. */
|
|
44
|
+
export declare function friendlyTextFromStoredError(storedText: string, options: UserFriendlyErrorOptions): string;
|