@widgetic/creator 0.4.28 → 0.4.29
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 +294 -79
- package/dist/components/BrandKitPanel.svelte +2 -0
- package/dist/components/DesignQuickEdit.svelte +40 -10
- package/dist/components/HoverTooltip.svelte +1 -1
- package/dist/components/WidgetDetails.svelte +40 -9
- package/dist/components/WidgetElementSelector.svelte +15 -10
- package/dist/components/WidgetShapeLivePreviews.svelte +116 -4
- package/dist/components/WidgetShapeLivePreviews.svelte.d.ts +3 -1
- package/dist/i18n/language.d.ts +5 -4
- package/dist/i18n/messages.d.ts +2 -1
- package/dist/i18n/messages.js +2 -1
- package/dist/i18n/statusText.js +1 -0
- package/package.json +1 -1
package/dist/CreatorApp.svelte
CHANGED
|
@@ -493,10 +493,19 @@
|
|
|
493
493
|
const gate = targetId ? getPublishGateForPanel(targetId) : null;
|
|
494
494
|
const canPublish = !!gate && !gate.disabled;
|
|
495
495
|
const label = gate?.label || $t('creator.common.publish');
|
|
496
|
-
const
|
|
496
|
+
const publishedAlready = !!targetId && getPanelDisplayState(targetId).lastPublishedVersion !== null;
|
|
497
|
+
const unpublished = canPublish && (
|
|
498
|
+
/publish new v/i.test(label)
|
|
499
|
+
|| (publishedAlready && hasUnpublishedChangesForPanel(targetId))
|
|
500
|
+
);
|
|
501
|
+
const signature = `${targetId}:${canPublish}:${label}:${unpublished}:${panelDisplayRevision}:${isPublishing}:${generatingMark}`;
|
|
497
502
|
if (signature !== lastAnnouncedPublishState) {
|
|
498
503
|
lastAnnouncedPublishState = signature;
|
|
499
|
-
announceToSite(CREATOR_PUBLISH_STATE_EVENT, {
|
|
504
|
+
announceToSite(CREATOR_PUBLISH_STATE_EVENT, {
|
|
505
|
+
canPublish,
|
|
506
|
+
label: unpublished ? 'Publish changes' : label,
|
|
507
|
+
unpublished,
|
|
508
|
+
});
|
|
500
509
|
}
|
|
501
510
|
}
|
|
502
511
|
|
|
@@ -1342,6 +1351,13 @@
|
|
|
1342
1351
|
// while the repository save is still finishing. The canvas shape stays
|
|
1343
1352
|
// deferred because generatingWidgetIds is still set.
|
|
1344
1353
|
let previewUnblockedByWidgetId: Record<string, boolean> = {};
|
|
1354
|
+
/** The status line was set when the preview appeared. A later GitLab save must not write "Preview ready" again. */
|
|
1355
|
+
let previewReadyAnnouncedByWidgetId: Record<string, boolean> = {};
|
|
1356
|
+
/** Publish stays hidden until about five seconds after the preview is on screen. */
|
|
1357
|
+
let publishHeldByWidgetId: Record<string, boolean> = {};
|
|
1358
|
+
const PREVIEW_READY_STATUS = 'Generation complete (100%) · Preview ready';
|
|
1359
|
+
const PUBLISH_REVEAL_DELAY_MS = 5000;
|
|
1360
|
+
const publishRevealTimers = new Map<string, ReturnType<typeof setTimeout>>();
|
|
1345
1361
|
/** Last slice of the model stream, per widget. Painted with the status throttle, not per token. */
|
|
1346
1362
|
let generationStreamByWidgetId: Record<string, string> = {};
|
|
1347
1363
|
function isAnyWidgetGenerating(): boolean {
|
|
@@ -1781,6 +1797,16 @@
|
|
|
1781
1797
|
...(attachments || []),
|
|
1782
1798
|
{ url: canvasSketch, fileType: 'image/png', fileName: 'design-screenshot.png' },
|
|
1783
1799
|
];
|
|
1800
|
+
getChatMethodsForWidget(widgetId)?.updateLastUserMessageAttachments?.(
|
|
1801
|
+
(attachments || [])
|
|
1802
|
+
.filter((attachment) => typeof attachment.url === 'string' && attachment.url.length > 0)
|
|
1803
|
+
.map((attachment) => ({
|
|
1804
|
+
url: attachment.url,
|
|
1805
|
+
file_type: attachment.fileType,
|
|
1806
|
+
file_name: attachment.fileName ?? null,
|
|
1807
|
+
})),
|
|
1808
|
+
);
|
|
1809
|
+
console.log('[Chat→Sketch] Sketch attached to the sent message', widgetId.substring(0, 8));
|
|
1784
1810
|
}
|
|
1785
1811
|
}
|
|
1786
1812
|
} catch (captureError) {
|
|
@@ -4550,14 +4576,7 @@
|
|
|
4550
4576
|
// Clear stuck "Code saved — loading preview…" once the iframe has content
|
|
4551
4577
|
const panelStatus = getPanelState(panelWidgetId).generateCodeStatus || '';
|
|
4552
4578
|
if (/loading preview|building preview|preview rebuilt from saved code/i.test(panelStatus)) {
|
|
4553
|
-
|
|
4554
|
-
getPanelState(panelWidgetId).lastCommitId || loadCommitIdForWidget(panelWidgetId);
|
|
4555
|
-
const commitShort = panelCommit ? panelCommit.substring(0, 7) : '';
|
|
4556
|
-
patchCodegenUiState(panelWidgetId, {
|
|
4557
|
-
hasGeneratedCode: true,
|
|
4558
|
-
...(panelCommit ? { lastCommitId: panelCommit } : {}),
|
|
4559
|
-
generateCodeStatus: `Code generation completed!${commitShort ? ` Commit: ${commitShort}` : ''} Preview ready.`,
|
|
4560
|
-
});
|
|
4579
|
+
markGenerationPreviewReady(panelWidgetId);
|
|
4561
4580
|
}
|
|
4562
4581
|
if (event.detail.step === 'create') {
|
|
4563
4582
|
let psCreate = getPanelDisplayState(panelWidgetId);
|
|
@@ -4802,12 +4821,20 @@
|
|
|
4802
4821
|
compositionDirty = true;
|
|
4803
4822
|
if (widgetId === focusedPanelWidgetId) {
|
|
4804
4823
|
syncFocusedPanelEditorSnapshot();
|
|
4805
|
-
|
|
4806
|
-
|
|
4824
|
+
scheduleDesignPersist(widgetId);
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
|
|
4828
|
+
let designPersistTimer: ReturnType<typeof setTimeout> | null = null;
|
|
4829
|
+
/** The preview updates on each key. The composition save waits until typing pauses, so a slow save cannot put the old color back. */
|
|
4830
|
+
function scheduleDesignPersist(widgetId: string): void {
|
|
4831
|
+
if (designPersistTimer) clearTimeout(designPersistTimer);
|
|
4832
|
+
designPersistTimer = setTimeout(() => {
|
|
4833
|
+
designPersistTimer = null;
|
|
4807
4834
|
if (selectedComposition && selectedWidgetId === widgetId) {
|
|
4808
4835
|
void updateCompositionValues();
|
|
4809
4836
|
}
|
|
4810
|
-
}
|
|
4837
|
+
}, 400);
|
|
4811
4838
|
}
|
|
4812
4839
|
|
|
4813
4840
|
/**
|
|
@@ -6702,18 +6729,6 @@
|
|
|
6702
6729
|
if (panelHadPublishedVersion) patchPanelSnapshot(widgetId, { pendingPublishAfterCodegen: true });
|
|
6703
6730
|
panelDisplayRevision += 1;
|
|
6704
6731
|
|
|
6705
|
-
if (announce) {
|
|
6706
|
-
const isFocusedPanel = widgetId === focusedPanelWidgetId;
|
|
6707
|
-
const completedWidgetName = getWidgetById(widgetId)?.name || 'widget';
|
|
6708
|
-
showToast(
|
|
6709
|
-
'success',
|
|
6710
|
-
isFocusedPanel ? $t('creator.codegen.codeGenerationCompleted') : $t('creator.codegen.generationCompleted', { name: completedWidgetName }),
|
|
6711
|
-
{
|
|
6712
|
-
description: isFocusedPanel ? $t('creator.codegen.codeSavedToGitlabAnd') : $t('creator.general.switchToThatPanelTo'),
|
|
6713
|
-
duration: 5000
|
|
6714
|
-
}
|
|
6715
|
-
);
|
|
6716
|
-
}
|
|
6717
6732
|
setTimeout(() => {
|
|
6718
6733
|
void refreshWidgetAfterRemoteGeneration(widgetId);
|
|
6719
6734
|
}, 800);
|
|
@@ -6747,7 +6762,8 @@
|
|
|
6747
6762
|
shapePreviewSourceByWidgetId = { ...shapePreviewSourceByWidgetId, [widgetId]: 'preview' };
|
|
6748
6763
|
syncWidgetShapeLivePreviews();
|
|
6749
6764
|
widgetShapeLivePreviewsRef?.requestReload?.(widgetId);
|
|
6750
|
-
patchCodegenUiState(widgetId, { generateCodeStatus:
|
|
6765
|
+
patchCodegenUiState(widgetId, { generateCodeStatus: PREVIEW_READY_STATUS });
|
|
6766
|
+
markGenerationPreviewReady(widgetId);
|
|
6751
6767
|
void refreshTrialCounter();
|
|
6752
6768
|
setTimeout(async () => {
|
|
6753
6769
|
try {
|
|
@@ -10689,6 +10705,12 @@ Requirements:
|
|
|
10689
10705
|
cancelQuietScreenshots();
|
|
10690
10706
|
cancelIdleThumbnailPersist();
|
|
10691
10707
|
widgetShapeLivePreviewsRef?.cancelReloads?.();
|
|
10708
|
+
if (options.fromChat) {
|
|
10709
|
+
console.log('[Chat→Preview] Reloading preview iframe on send', generationWidgetId.substring(0, 8));
|
|
10710
|
+
widgetShapeLivePreviewsRef?.requestReload?.(generationWidgetId, { immediate: true });
|
|
10711
|
+
void getWidgetDetailsRef(generationWidgetId)?.refreshPreview?.();
|
|
10712
|
+
}
|
|
10713
|
+
holdPublishForGeneration(generationWidgetId);
|
|
10692
10714
|
if (restoredViewingVersionByWidgetId[generationWidgetId] != null) {
|
|
10693
10715
|
const { [generationWidgetId]: _droppedRestore, ...restRestored } = restoredViewingVersionByWidgetId;
|
|
10694
10716
|
restoredViewingVersionByWidgetId = restRestored;
|
|
@@ -10968,6 +10990,57 @@ Requirements:
|
|
|
10968
10990
|
// a generation slot. Anything unexpected here falls through to the
|
|
10969
10991
|
// normal path (operation tracking), never blocks a real build.
|
|
10970
10992
|
const gatedData = (response as any)?.data;
|
|
10993
|
+
if (gatedData?.gated === true && gatedData.action === 'property_edit') {
|
|
10994
|
+
const propertyKey = typeof gatedData.key === 'string' ? gatedData.key : '';
|
|
10995
|
+
const propertyValue = gatedData.value;
|
|
10996
|
+
clearActiveOperationId(generationWidgetId);
|
|
10997
|
+
if (propertyKey && gatedData.group !== 'content') {
|
|
10998
|
+
applyDesignValuesToPreview(generationWidgetId, { [propertyKey]: propertyValue });
|
|
10999
|
+
}
|
|
11000
|
+
const psNow = getPanelDisplayState(generationWidgetId);
|
|
11001
|
+
const schemaProp = collectDesignProperties(psNow.compositionDesignSchema).find(
|
|
11002
|
+
(property) => property.id === propertyKey || property.id.endsWith(`.${propertyKey}`)
|
|
11003
|
+
);
|
|
11004
|
+
const label = schemaProp?.label || propertyKey;
|
|
11005
|
+
const card: DesignControlRequest = {
|
|
11006
|
+
summary: gatedData.reply || `Set ${label} to ${String(propertyValue)}.`,
|
|
11007
|
+
properties: propertyKey
|
|
11008
|
+
? [{
|
|
11009
|
+
id: schemaProp?.id || propertyKey,
|
|
11010
|
+
label,
|
|
11011
|
+
controllerType: schemaProp?.controllerType ?? '',
|
|
11012
|
+
value: propertyValue,
|
|
11013
|
+
options: schemaProp?.options,
|
|
11014
|
+
min: schemaProp?.min,
|
|
11015
|
+
max: schemaProp?.max,
|
|
11016
|
+
step: schemaProp?.step,
|
|
11017
|
+
helpText: schemaProp?.helpText,
|
|
11018
|
+
}]
|
|
11019
|
+
: [],
|
|
11020
|
+
compositionId: psNow.selectedComposition?.id ?? gatedData.compositionId ?? null,
|
|
11021
|
+
};
|
|
11022
|
+
getChatMethodsForWidget(generationWidgetId)?.addDesignControlsMessage?.(card.summary, card);
|
|
11023
|
+
patchCodegenUiState(generationWidgetId, {
|
|
11024
|
+
lastGenerationFailed: false,
|
|
11025
|
+
lastGenerationError: null,
|
|
11026
|
+
generateCodeStatus: 'Ready',
|
|
11027
|
+
});
|
|
11028
|
+
if (debugMode) {
|
|
11029
|
+
showToast('info', $t('creator.codegen.noGenerationStarted'), {
|
|
11030
|
+
description: String(gatedData.reply || '').slice(0, 140),
|
|
11031
|
+
duration: 8000,
|
|
11032
|
+
});
|
|
11033
|
+
}
|
|
11034
|
+
generatingWidgetIds = (() => {
|
|
11035
|
+
const { [generationWidgetId]: _gated, ...rest } = generatingWidgetIds;
|
|
11036
|
+
return rest;
|
|
11037
|
+
})();
|
|
11038
|
+
isGeneratingCode = !!(focusedPanelWidgetId && generatingWidgetIds[focusedPanelWidgetId]);
|
|
11039
|
+
setCrossTabGenerating(false, generationWidgetId);
|
|
11040
|
+
widgetAbortControllers.delete(generationWidgetId);
|
|
11041
|
+
console.log('[DesignIntent] Applied a property edit without generating', propertyKey);
|
|
11042
|
+
return;
|
|
11043
|
+
}
|
|
10971
11044
|
if (gatedData?.gated === true && typeof gatedData.action === 'string' && gatedData.action !== 'generate') {
|
|
10972
11045
|
const gatedAction = gatedData.action as 'answer' | 'redirect' | 'clarify';
|
|
10973
11046
|
const gatedReply: string = gatedData.reply ?? '';
|
|
@@ -10994,14 +11067,16 @@ Requirements:
|
|
|
10994
11067
|
chatMethods.addAssistantMessage(gatedReply);
|
|
10995
11068
|
}
|
|
10996
11069
|
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
|
|
11070
|
+
if (debugMode) {
|
|
11071
|
+
showToast(
|
|
11072
|
+
gatedAction === 'answer' ? 'info' : 'warning',
|
|
11073
|
+
gatedAction === 'answer' ? $t('creator.codegen.answeredWithoutGenerating') : $t('creator.codegen.noGenerationStarted'),
|
|
11074
|
+
{
|
|
11075
|
+
description: gatedReply.slice(0, 140),
|
|
11076
|
+
duration: 8000,
|
|
11077
|
+
},
|
|
11078
|
+
);
|
|
11079
|
+
}
|
|
11005
11080
|
generatingWidgetIds = (() => {
|
|
11006
11081
|
const { [generationWidgetId]: _gated, ...rest } = generatingWidgetIds;
|
|
11007
11082
|
return rest;
|
|
@@ -11114,7 +11189,7 @@ Requirements:
|
|
|
11114
11189
|
...previewUnblockedByWidgetId,
|
|
11115
11190
|
[generationWidgetId]: true,
|
|
11116
11191
|
};
|
|
11117
|
-
|
|
11192
|
+
markGenerationPreviewReady(generationWidgetId);
|
|
11118
11193
|
options.onPreviewVisible?.();
|
|
11119
11194
|
}
|
|
11120
11195
|
}
|
|
@@ -11378,11 +11453,18 @@ Requirements:
|
|
|
11378
11453
|
const commitShort = completedCommitSha ? completedCommitSha.substring(0, 7) : '';
|
|
11379
11454
|
const unsavedText = repositorySaveError
|
|
11380
11455
|
|| 'Code was not saved to the repository. Retry saves it and records a version.';
|
|
11456
|
+
const previewAlreadyOnCanvas = !!(
|
|
11457
|
+
previewReadyAnnouncedByWidgetId[generationWidgetId]
|
|
11458
|
+
|| previewUnblockedByWidgetId[generationWidgetId]
|
|
11459
|
+
|| runningWorkerPreviewUrlByWidgetId[generationWidgetId]
|
|
11460
|
+
);
|
|
11381
11461
|
const savedStatus = !completedCommitSha
|
|
11382
11462
|
? unsavedText
|
|
11383
|
-
:
|
|
11384
|
-
?
|
|
11385
|
-
:
|
|
11463
|
+
: previewAlreadyOnCanvas
|
|
11464
|
+
? PREVIEW_READY_STATUS
|
|
11465
|
+
: completedPreviewBuildErr
|
|
11466
|
+
? `Code saved (${commitShort}) — building preview…`
|
|
11467
|
+
: `Code saved (${commitShort}) — loading preview…`;
|
|
11386
11468
|
const shownFailure = [completedPreviewBuildErr, !completedCommitSha ? unsavedText : null]
|
|
11387
11469
|
.filter((part): part is string => !!part)
|
|
11388
11470
|
.join('\n');
|
|
@@ -11393,6 +11475,9 @@ Requirements:
|
|
|
11393
11475
|
lastGenerationError: shownFailure || null,
|
|
11394
11476
|
generateCodeStatus: savedStatus,
|
|
11395
11477
|
});
|
|
11478
|
+
if (previewAlreadyOnCanvas && completedCommitSha && !completedPreviewBuildErr) {
|
|
11479
|
+
markGenerationPreviewReady(generationWidgetId);
|
|
11480
|
+
}
|
|
11396
11481
|
|
|
11397
11482
|
if (!completedCached) {
|
|
11398
11483
|
panelChat?.updateLatestCodegenStatusMessage?.(savedStatus);
|
|
@@ -11416,7 +11501,7 @@ Requirements:
|
|
|
11416
11501
|
description: repositorySaveError || $t('creator.codegen.retrySavesItAndRecordsAVersion'),
|
|
11417
11502
|
duration: 8000
|
|
11418
11503
|
});
|
|
11419
|
-
} else {
|
|
11504
|
+
} else if (debugMode) {
|
|
11420
11505
|
showToast(
|
|
11421
11506
|
'success',
|
|
11422
11507
|
isFocusedPanel ? $t('creator.codegen.codeGenerationCompleted') : $t('creator.codegen.generationCompleted', { name: completedWidgetName }),
|
|
@@ -11462,7 +11547,7 @@ Requirements:
|
|
|
11462
11547
|
// Served from the operation metadata; the server also embeds it in the
|
|
11463
11548
|
// persisted reply, so it survives a reload.
|
|
11464
11549
|
const designContractWarning = getOperationDesignContractWarning(op.metadata);
|
|
11465
|
-
if (designContractWarning) {
|
|
11550
|
+
if (designContractWarning && debugMode) {
|
|
11466
11551
|
panelChat?.addAssistantMessage(designContractWarning, true);
|
|
11467
11552
|
}
|
|
11468
11553
|
|
|
@@ -11500,10 +11585,10 @@ Requirements:
|
|
|
11500
11585
|
// cache-busts the same URL and looks like an extra reload.
|
|
11501
11586
|
// console.log('[CreatorApp] Skipping extra preview remount — Worker iframe already showing');
|
|
11502
11587
|
activePanelRef?.setPreviewLoadingState(false);
|
|
11503
|
-
//
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
}
|
|
11588
|
+
// The running preview already wrote the status. Don't write "Preview ready" again.
|
|
11589
|
+
if (!previewReadyAnnouncedByWidgetId[generationWidgetId]) {
|
|
11590
|
+
markGenerationPreviewReady(generationWidgetId);
|
|
11591
|
+
}
|
|
11507
11592
|
} else {
|
|
11508
11593
|
activePanelRef?.setPreviewLoadingState(true);
|
|
11509
11594
|
await activePanelRef?.refreshPreview?.({ withRetry: true, skipIfAlreadyShowing: true });
|
|
@@ -11531,12 +11616,9 @@ Requirements:
|
|
|
11531
11616
|
} else if (!completedPreviewBuildErr) {
|
|
11532
11617
|
await applyDesignSchemaDefaultsToPreview(generationWidgetId);
|
|
11533
11618
|
pendingCreatePreviewDefaultsWidgetId = null;
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
patchCodegenUiState(generationWidgetId, {
|
|
11538
|
-
generateCodeStatus: `Code generation completed!${commitShort ? ` Commit: ${commitShort}` : ''} Preview ready.`,
|
|
11539
|
-
});
|
|
11619
|
+
if (!previewReadyAnnouncedByWidgetId[generationWidgetId]) {
|
|
11620
|
+
markGenerationPreviewReady(generationWidgetId);
|
|
11621
|
+
}
|
|
11540
11622
|
void refreshTrialCounter();
|
|
11541
11623
|
setTimeout(async () => {
|
|
11542
11624
|
await panelChat?.reloadConversationMessages?.();
|
|
@@ -11691,11 +11773,13 @@ Requirements:
|
|
|
11691
11773
|
// Update global flag: true only if the CURRENT widget is still generating
|
|
11692
11774
|
isGeneratingCode = !!(focusedPanelWidgetId && generatingWidgetIds[focusedPanelWidgetId]);
|
|
11693
11775
|
setCrossTabGenerating(false, generationWidgetId);
|
|
11694
|
-
//
|
|
11695
|
-
//
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11776
|
+
// A finished run already loads the new preview. Reloading here as well
|
|
11777
|
+
// flashed the shape a second time. A failed run still needs the one reload.
|
|
11778
|
+
if (getPanelState(generationWidgetId).lastGenerationFailed) {
|
|
11779
|
+
void tick().then(() => {
|
|
11780
|
+
widgetShapeLivePreviewsRef?.requestReload?.(generationWidgetId, { immediate: true });
|
|
11781
|
+
});
|
|
11782
|
+
}
|
|
11699
11783
|
}
|
|
11700
11784
|
}
|
|
11701
11785
|
}
|
|
@@ -12370,6 +12454,18 @@ Requirements:
|
|
|
12370
12454
|
return () => window.removeEventListener('keydown', handleEscapeCapture, { capture: true });
|
|
12371
12455
|
});
|
|
12372
12456
|
|
|
12457
|
+
onMount(() => {
|
|
12458
|
+
const closeSelectorOnSelectTool = () => {
|
|
12459
|
+
const next: Record<string, boolean> = {};
|
|
12460
|
+
for (const widgetId of Object.keys(selectorEnabledByWidgetId)) next[widgetId] = false;
|
|
12461
|
+
selectorEnabledByWidgetId = next;
|
|
12462
|
+
panelDisplayRevision += 1;
|
|
12463
|
+
console.log('[WidgetShape] Select tool closes the element selector');
|
|
12464
|
+
};
|
|
12465
|
+
window.addEventListener('widgetic:canvas-select-tool', closeSelectorOnSelectTool);
|
|
12466
|
+
return () => window.removeEventListener('widgetic:canvas-select-tool', closeSelectorOnSelectTool);
|
|
12467
|
+
});
|
|
12468
|
+
|
|
12373
12469
|
// Capture-phase paste: redirect clipboard images to prompt images
|
|
12374
12470
|
// ONLY when the paste target is inside the widget-details panel or widgets-list
|
|
12375
12471
|
// (e.g., user is focused on the prompt input). If target is body/document/canvas area,
|
|
@@ -12547,9 +12643,10 @@ Requirements:
|
|
|
12547
12643
|
/** The canvas iframe painted, so the chat is no longer waiting on a hidden side preview. */
|
|
12548
12644
|
function noteShapePreviewShown(widgetId: string): void {
|
|
12549
12645
|
const status = getPanelDisplayState(widgetId).generateCodeStatus || '';
|
|
12550
|
-
|
|
12551
|
-
|
|
12552
|
-
|
|
12646
|
+
const waitingOnPreview = /loading preview|building preview|generating code|code generation in progress|code saved/i.test(status);
|
|
12647
|
+
const generationRunning = !!generatingWidgetIds[widgetId] || !!previewUnblockedByWidgetId[widgetId];
|
|
12648
|
+
if (!waitingOnPreview && !generationRunning) return;
|
|
12649
|
+
markGenerationPreviewReady(widgetId);
|
|
12553
12650
|
}
|
|
12554
12651
|
|
|
12555
12652
|
function getOperationPreviewBuildError(metadata?: Record<string, unknown>): string | null {
|
|
@@ -12645,10 +12742,79 @@ Requirements:
|
|
|
12645
12742
|
return typeof raw === 'string' ? raw.slice(-1600) : '';
|
|
12646
12743
|
}
|
|
12647
12744
|
|
|
12745
|
+
function holdPublishForGeneration(widgetId: string): void {
|
|
12746
|
+
const pending = publishRevealTimers.get(widgetId);
|
|
12747
|
+
if (pending) {
|
|
12748
|
+
clearTimeout(pending);
|
|
12749
|
+
publishRevealTimers.delete(widgetId);
|
|
12750
|
+
}
|
|
12751
|
+
publishHeldByWidgetId = { ...publishHeldByWidgetId, [widgetId]: true };
|
|
12752
|
+
if (previewReadyAnnouncedByWidgetId[widgetId]) {
|
|
12753
|
+
const next = { ...previewReadyAnnouncedByWidgetId };
|
|
12754
|
+
delete next[widgetId];
|
|
12755
|
+
previewReadyAnnouncedByWidgetId = next;
|
|
12756
|
+
}
|
|
12757
|
+
}
|
|
12758
|
+
|
|
12759
|
+
function releasePublishHold(widgetId: string): void {
|
|
12760
|
+
const pending = publishRevealTimers.get(widgetId);
|
|
12761
|
+
if (pending) {
|
|
12762
|
+
clearTimeout(pending);
|
|
12763
|
+
publishRevealTimers.delete(widgetId);
|
|
12764
|
+
}
|
|
12765
|
+
if (!publishHeldByWidgetId[widgetId]) return;
|
|
12766
|
+
const next = { ...publishHeldByWidgetId };
|
|
12767
|
+
delete next[widgetId];
|
|
12768
|
+
publishHeldByWidgetId = next;
|
|
12769
|
+
panelDisplayRevision += 1;
|
|
12770
|
+
}
|
|
12771
|
+
|
|
12772
|
+
function schedulePublishReveal(widgetId: string): void {
|
|
12773
|
+
const pending = publishRevealTimers.get(widgetId);
|
|
12774
|
+
if (pending) clearTimeout(pending);
|
|
12775
|
+
publishRevealTimers.set(widgetId, setTimeout(() => {
|
|
12776
|
+
publishRevealTimers.delete(widgetId);
|
|
12777
|
+
releasePublishHold(widgetId);
|
|
12778
|
+
console.log('[CodeGen] Publish revealed after preview', widgetId.substring(0, 8));
|
|
12779
|
+
}, PUBLISH_REVEAL_DELAY_MS));
|
|
12780
|
+
}
|
|
12781
|
+
|
|
12782
|
+
function cancelPendingCodegenStatus(widgetId: string): void {
|
|
12783
|
+
if (codegenStatusTimers[widgetId]) {
|
|
12784
|
+
clearTimeout(codegenStatusTimers[widgetId]);
|
|
12785
|
+
delete codegenStatusTimers[widgetId];
|
|
12786
|
+
}
|
|
12787
|
+
delete codegenStatusPendingLine[widgetId];
|
|
12788
|
+
delete codegenStreamPending[widgetId];
|
|
12789
|
+
if (codegenChatStatusTimers[widgetId]) {
|
|
12790
|
+
clearTimeout(codegenChatStatusTimers[widgetId]);
|
|
12791
|
+
delete codegenChatStatusTimers[widgetId];
|
|
12792
|
+
}
|
|
12793
|
+
delete codegenChatStatusPendingLine[widgetId];
|
|
12794
|
+
}
|
|
12795
|
+
|
|
12796
|
+
/** Preview is on screen. Status settles once. Publish waits about five seconds. GitLab keeps saving. */
|
|
12797
|
+
function markGenerationPreviewReady(widgetId: string): void {
|
|
12798
|
+
const alreadyAnnounced = !!previewReadyAnnouncedByWidgetId[widgetId];
|
|
12799
|
+
if (!alreadyAnnounced) {
|
|
12800
|
+
previewReadyAnnouncedByWidgetId = { ...previewReadyAnnouncedByWidgetId, [widgetId]: true };
|
|
12801
|
+
cancelPendingCodegenStatus(widgetId);
|
|
12802
|
+
schedulePublishReveal(widgetId);
|
|
12803
|
+
console.log('[CodeGen] Preview ready', widgetId.substring(0, 8));
|
|
12804
|
+
}
|
|
12805
|
+
const current = getPanelState(widgetId).generateCodeStatus || '';
|
|
12806
|
+
if (current === PREVIEW_READY_STATUS) return;
|
|
12807
|
+
patchCodegenUiState(widgetId, { generateCodeStatus: PREVIEW_READY_STATUS });
|
|
12808
|
+
if (!alreadyAnnounced) {
|
|
12809
|
+
getChatMethodsForWidget(widgetId)?.updateLatestCodegenStatusMessage?.(PREVIEW_READY_STATUS);
|
|
12810
|
+
}
|
|
12811
|
+
}
|
|
12812
|
+
|
|
12648
12813
|
function pushCodegenProgressToUi(op: OperationStatus, widgetId: string | null | undefined) {
|
|
12649
12814
|
// The preview is already on the canvas while the version is still saving.
|
|
12650
12815
|
// The bar stays at 70 until that save ends, so show 100 for that pause.
|
|
12651
12816
|
const stillRunning = String(op.status || '').toLowerCase() === 'running';
|
|
12817
|
+
if (widgetId && previewReadyAnnouncedByWidgetId[widgetId] && stillRunning) return;
|
|
12652
12818
|
const versionStillSaving = !!(widgetId && previewUnblockedByWidgetId[widgetId] && stillRunning);
|
|
12653
12819
|
const shown = versionStillSaving ? { ...op, progress: 100 } : op;
|
|
12654
12820
|
const line = formatCodegenProgressStatus(shown);
|
|
@@ -12696,7 +12862,7 @@ Requirements:
|
|
|
12696
12862
|
const pendingTail = codegenStreamPending[widgetId];
|
|
12697
12863
|
delete codegenStatusPendingLine[widgetId];
|
|
12698
12864
|
delete codegenStreamPending[widgetId];
|
|
12699
|
-
if (pending) patchCodegenUiState(widgetId, { generateCodeStatus: pending });
|
|
12865
|
+
if (pending && !previewReadyAnnouncedByWidgetId[widgetId]) patchCodegenUiState(widgetId, { generateCodeStatus: pending });
|
|
12700
12866
|
if (pendingTail && pendingTail !== generationStreamByWidgetId[widgetId]) {
|
|
12701
12867
|
generationStreamByWidgetId = { ...generationStreamByWidgetId, [widgetId]: pendingTail };
|
|
12702
12868
|
}
|
|
@@ -12715,7 +12881,9 @@ Requirements:
|
|
|
12715
12881
|
delete codegenChatStatusTimers[key];
|
|
12716
12882
|
const pending = codegenChatStatusPendingLine[key];
|
|
12717
12883
|
delete codegenChatStatusPendingLine[key];
|
|
12718
|
-
if (pending
|
|
12884
|
+
if (pending && !(widgetId && previewReadyAnnouncedByWidgetId[widgetId])) {
|
|
12885
|
+
getChatMethodsForWidget(widgetId)?.updateLatestCodegenStatusMessage?.(pending);
|
|
12886
|
+
}
|
|
12719
12887
|
}, CODEGEN_STATUS_THROTTLE_MS);
|
|
12720
12888
|
}
|
|
12721
12889
|
|
|
@@ -15069,6 +15237,10 @@ Requirements:
|
|
|
15069
15237
|
}
|
|
15070
15238
|
|
|
15071
15239
|
function hasUnpublishedChangesForPanel(widgetId: string): boolean {
|
|
15240
|
+
if (publishHeldByWidgetId[widgetId]) return false;
|
|
15241
|
+
if (generatingWidgetIds[widgetId] && !previewReadyAnnouncedByWidgetId[widgetId]) return false;
|
|
15242
|
+
// Preview is up and the five seconds have passed. GitLab may still be saving.
|
|
15243
|
+
if (generatingWidgetIds[widgetId] && previewReadyAnnouncedByWidgetId[widgetId]) return true;
|
|
15072
15244
|
const ps = getPanelDisplayState(widgetId);
|
|
15073
15245
|
if (ps.pendingPublishAfterCodegen) return true;
|
|
15074
15246
|
|
|
@@ -15203,7 +15375,12 @@ Requirements:
|
|
|
15203
15375
|
showDisabledHint: true,
|
|
15204
15376
|
};
|
|
15205
15377
|
}
|
|
15206
|
-
|
|
15378
|
+
const gitlabSaveStillRunning = !!(
|
|
15379
|
+
generatingWidgetIds[widgetId]
|
|
15380
|
+
&& previewReadyAnnouncedByWidgetId[widgetId]
|
|
15381
|
+
&& !publishHeldByWidgetId[widgetId]
|
|
15382
|
+
);
|
|
15383
|
+
if (generatingWidgetIds[widgetId] && !gitlabSaveStillRunning) {
|
|
15207
15384
|
return {
|
|
15208
15385
|
disabled: true,
|
|
15209
15386
|
label: getPublishButtonLabelFallback(ps),
|
|
@@ -15483,15 +15660,23 @@ $: if ($widgetPublishStatus.timestamp && $widgetPublishStatus.widgetId) {
|
|
|
15483
15660
|
// console.log('[Publish] WS success — refreshing preview after publish for', publishWidgetId.substring(0, 8));
|
|
15484
15661
|
void getWidgetDetailsRef(publishWidgetId)?.refreshPreview({ withRetry: true });
|
|
15485
15662
|
}
|
|
15486
|
-
if (publishWidgetId) {
|
|
15487
|
-
// console.log('[Publish] Refreshing canvas widget screenshot after successful publish');
|
|
15488
|
-
scheduleQuietScreenshot(publishWidgetId, 2000);
|
|
15489
|
-
}
|
|
15490
15663
|
if (embedded && onPublishComplete && publishWidgetId) {
|
|
15491
|
-
|
|
15492
|
-
|
|
15493
|
-
|
|
15494
|
-
|
|
15664
|
+
const publishedWidgetId = publishWidgetId;
|
|
15665
|
+
const publishedVersion = publishResult.version;
|
|
15666
|
+
void (async () => {
|
|
15667
|
+
await Promise.race([
|
|
15668
|
+
handleRefreshScreenshot(publishedWidgetId, { quiet: true }).catch((error) => {
|
|
15669
|
+
console.warn('[Publish] Thumbnail before leaving the canvas failed', error);
|
|
15670
|
+
}),
|
|
15671
|
+
new Promise((resolve) => setTimeout(resolve, 2500)),
|
|
15672
|
+
]);
|
|
15673
|
+
onPublishComplete({
|
|
15674
|
+
widgetId: publishedWidgetId,
|
|
15675
|
+
version: publishedVersion
|
|
15676
|
+
});
|
|
15677
|
+
})();
|
|
15678
|
+
} else if (publishWidgetId) {
|
|
15679
|
+
scheduleQuietScreenshot(publishWidgetId, 2000);
|
|
15495
15680
|
}
|
|
15496
15681
|
} else if (publishResult.status === 'failure') {
|
|
15497
15682
|
if (isFocusedPublish) {
|
|
@@ -15660,6 +15845,30 @@ async function readPublishHistoryForPanel(widgetId: string, opts: { silent?: boo
|
|
|
15660
15845
|
// must stop `ensureShapePublishHistory` from re-fetching on every render.
|
|
15661
15846
|
shapeHistoryResolvedByWidgetId = { ...shapeHistoryResolvedByWidgetId, [widgetId]: true };
|
|
15662
15847
|
queueUnpublishedHeadOnShape(widgetId);
|
|
15848
|
+
const publishedVersions = history
|
|
15849
|
+
.filter((row) => row.publishedAt ?? row.published_at)
|
|
15850
|
+
.map((row) => Number(row.version))
|
|
15851
|
+
.filter((version) => Number.isFinite(version));
|
|
15852
|
+
const liveFromHistory = publishedVersions.length > 0 ? Math.max(...publishedVersions) : null;
|
|
15853
|
+
const draftVersions = history
|
|
15854
|
+
.filter((row) => !(row.publishedAt ?? row.published_at))
|
|
15855
|
+
.map((row) => Number(row.version))
|
|
15856
|
+
.filter((version) => Number.isFinite(version));
|
|
15857
|
+
const newestDraft = draftVersions.length > 0 ? Math.max(...draftVersions) : null;
|
|
15858
|
+
const knownLive = getPanelState(widgetId).lastPublishedVersion ?? liveFromHistory;
|
|
15859
|
+
const draftAhead = newestDraft != null && knownLive != null && newestDraft > knownLive;
|
|
15860
|
+
if ((getPanelState(widgetId).lastPublishedVersion == null && liveFromHistory != null) || draftAhead) {
|
|
15861
|
+
patchPanelSnapshot(widgetId, {
|
|
15862
|
+
...(getPanelState(widgetId).lastPublishedVersion == null && liveFromHistory != null
|
|
15863
|
+
? { lastPublishedVersion: liveFromHistory }
|
|
15864
|
+
: {}),
|
|
15865
|
+
...(draftAhead ? { pendingPublishAfterCodegen: true, hasGeneratedCode: true } : {}),
|
|
15866
|
+
});
|
|
15867
|
+
if (widgetId === focusedPanelWidgetId && getPanelState(widgetId).lastPublishedVersion != null) {
|
|
15868
|
+
lastPublishedVersion = getPanelState(widgetId).lastPublishedVersion;
|
|
15869
|
+
}
|
|
15870
|
+
}
|
|
15871
|
+
void reconcileWidgetHeadCommit(widgetId);
|
|
15663
15872
|
if (widgetId === focusedPanelWidgetId) {
|
|
15664
15873
|
publishHistory = history;
|
|
15665
15874
|
publishHistoryResolved = true;
|
|
@@ -18314,7 +18523,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18314
18523
|
|
|
18315
18524
|
|
|
18316
18525
|
<!-- Widgetic Canvas Editor - Full width background (lazy-loaded) -->
|
|
18317
|
-
<div class="wc-canvas-area flex-1 min-h-0 relative {embedded && !canvasAdvancedFeatures ? 'pe-[
|
|
18526
|
+
<div class="wc-canvas-area flex-1 min-h-0 relative {embedded && !canvasAdvancedFeatures ? 'pe-[450px]' : ''}">
|
|
18318
18527
|
<!-- Embedded: Debug toggle lives in site AppHeader (avoids overlapping Props Panel). -->
|
|
18319
18528
|
{#if canvasApiLoadError || canvasShapesMissingWarning}
|
|
18320
18529
|
<div class="canvas-state-warning-ct absolute top-3 left-1/2 -translate-x-1/2 z-30 max-w-lg w-[calc(100%-2rem)] pointer-events-auto">
|
|
@@ -18454,7 +18663,17 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18454
18663
|
resolveSelectedElements={(widgetId) => selectedElementsByWidgetId[widgetId] ?? []}
|
|
18455
18664
|
onSelectWidgetElement={(widgetId, element) => handleSelectWidgetElement(widgetId, element)}
|
|
18456
18665
|
onRemoveWidgetElement={(widgetId, elementId) => handleRemoveWidgetElement(widgetId, elementId)}
|
|
18457
|
-
onCloseWidgetSelector={(widgetId) =>
|
|
18666
|
+
onCloseWidgetSelector={(widgetId) => {
|
|
18667
|
+
handleToggleWidgetSelector(widgetId, false);
|
|
18668
|
+
canvasRef?.setWidgetShapeBodyDragAllowed?.(widgetId, false);
|
|
18669
|
+
}}
|
|
18670
|
+
onCommandClickPreview={(widgetId) => {
|
|
18671
|
+
const next = !selectorEnabledByWidgetId[widgetId];
|
|
18672
|
+
canvasRef?.selectWidgetShapeById?.(widgetId);
|
|
18673
|
+
canvasSelectedWidgetShapeId = widgetId;
|
|
18674
|
+
handleToggleWidgetSelector(widgetId, next);
|
|
18675
|
+
console.log('[WidgetShape] Alt click toggles the selector', widgetId.substring(0, 8), next);
|
|
18676
|
+
}}
|
|
18458
18677
|
/>
|
|
18459
18678
|
|
|
18460
18679
|
<!-- ═══ PANEL 2: Widgets Panel — debug + showWidgetsList (site passes false) ═══ -->
|
|
@@ -18592,7 +18811,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18592
18811
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
18593
18812
|
<div
|
|
18594
18813
|
class="widget-item widgets-list-grid-row items-center gap-x-2 border rounded px-2 py-1 text-sm {selectedWidgetId === w.id ? 'border-blue-500 bg-blue-50 cursor-default' : 'border-gray-200 cursor-pointer hover:bg-blue-50'}"
|
|
18595
|
-
tabindex="
|
|
18814
|
+
tabindex="-1"
|
|
18596
18815
|
role="button"
|
|
18597
18816
|
onclick={() => {
|
|
18598
18817
|
if (renamingWidgetId === w.id) return;
|
|
@@ -18849,12 +19068,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18849
19068
|
if (!previewWidgetId) return;
|
|
18850
19069
|
// Clear the "…loading preview…" / "…building preview…" status once the iframe reports ready.
|
|
18851
19070
|
const panelStatus = getPanelState(previewWidgetId).generateCodeStatus || '';
|
|
18852
|
-
if (/loading preview|building preview|preview rebuilt from saved code/i.test(panelStatus)) {
|
|
18853
|
-
|
|
18854
|
-
const commitShort = panelCommit ? panelCommit.substring(0, 7) : '';
|
|
18855
|
-
patchCodegenUiState(previewWidgetId, {
|
|
18856
|
-
generateCodeStatus: `Code generation completed!${commitShort ? ` Commit: ${commitShort}` : ''} Preview ready.`,
|
|
18857
|
-
});
|
|
19071
|
+
if (/loading preview|building preview|preview rebuilt from saved code|generating code/i.test(panelStatus)) {
|
|
19072
|
+
markGenerationPreviewReady(previewWidgetId);
|
|
18858
19073
|
}
|
|
18859
19074
|
if (isPanelFocused && previewWidgetId === panelWidgetId) {
|
|
18860
19075
|
chatMethods?.clearStalePreviewBuildFailures?.();
|
|
@@ -19186,7 +19401,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19186
19401
|
{/if}
|
|
19187
19402
|
{/if}
|
|
19188
19403
|
{#if isHistoryOpen && isPanelFocused}
|
|
19189
|
-
<Portal target="wc-live-history-portal-{panelWidgetId}">
|
|
19404
|
+
<Portal target="wc-live-history-portal-{panelWidgetId}" style="z-index: 100000010; width: auto; height: auto; overflow: visible;">
|
|
19190
19405
|
<button
|
|
19191
19406
|
type="button"
|
|
19192
19407
|
class="wc-live-history-backdrop fixed start-0 end-0 bottom-0 top-14 z-[9998] cursor-default bg-transparent"
|
|
@@ -288,6 +288,7 @@
|
|
|
288
288
|
/>
|
|
289
289
|
{$t('creator.brandKit.brandKit')}
|
|
290
290
|
</label>
|
|
291
|
+
{#if showLanguage || showPresetLibraries}
|
|
291
292
|
<div class="generation-libraries-row flex w-full flex-col gap-2">
|
|
292
293
|
<div class="generation-libraries-checks flex flex-nowrap items-center gap-1">
|
|
293
294
|
{#if showLanguage}
|
|
@@ -387,6 +388,7 @@
|
|
|
387
388
|
{/each}
|
|
388
389
|
{/if}
|
|
389
390
|
</div>
|
|
391
|
+
{/if}
|
|
390
392
|
</div>
|
|
391
393
|
{#if brandPanelOpen}
|
|
392
394
|
<Portal
|