@widgetic/creator 0.4.20 → 0.4.21
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
CHANGED
|
@@ -11126,6 +11126,13 @@ Requirements:
|
|
|
11126
11126
|
}
|
|
11127
11127
|
|
|
11128
11128
|
if (op.status === 'completed') {
|
|
11129
|
+
const completedPreviewUrl = getOperationPreviewUrl(op.metadata);
|
|
11130
|
+
if (
|
|
11131
|
+
completedPreviewUrl
|
|
11132
|
+
&& widgetAbortControllers.get(generationWidgetId) === abortController
|
|
11133
|
+
) {
|
|
11134
|
+
publishRunningWorkerPreview(generationWidgetId, completedPreviewUrl);
|
|
11135
|
+
}
|
|
11129
11136
|
// The SSE callback runs on the page thread. Applying the result here
|
|
11130
11137
|
// rebuilds the chat before the browser can paint, so the status stays
|
|
11131
11138
|
// on the previous percent and the tab stops answering.
|
|
@@ -12467,16 +12474,33 @@ Requirements:
|
|
|
12467
12474
|
}
|
|
12468
12475
|
|
|
12469
12476
|
let lastRunningPreviewKey = '';
|
|
12477
|
+
/** Worker document published before the repository save. The shape uses it while the version row is still catching up. */
|
|
12478
|
+
let runningWorkerPreviewUrlByWidgetId: Record<string, string> = {};
|
|
12470
12479
|
function publishRunningWorkerPreview(widgetId: string, previewUrl: string): void {
|
|
12471
12480
|
const key = `${widgetId}:${previewUrl}`;
|
|
12472
12481
|
if (key === lastRunningPreviewKey) return;
|
|
12473
12482
|
lastRunningPreviewKey = key;
|
|
12483
|
+
runningWorkerPreviewUrlByWidgetId = {
|
|
12484
|
+
...runningWorkerPreviewUrlByWidgetId,
|
|
12485
|
+
[widgetId]: previewUrl,
|
|
12486
|
+
};
|
|
12474
12487
|
dynamicWorkerPreviewStatus.set({
|
|
12475
12488
|
widgetId,
|
|
12476
12489
|
previewUrl,
|
|
12477
12490
|
buildTimeMs: null,
|
|
12478
12491
|
timestamp: new Date().toISOString(),
|
|
12479
12492
|
});
|
|
12493
|
+
// The chat can already show the version while this flag is still on. The shape
|
|
12494
|
+
// has to take the document now, not after the save finishes.
|
|
12495
|
+
widgetShapeLivePreviewsRef?.requestReload?.(widgetId, { immediate: true });
|
|
12496
|
+
}
|
|
12497
|
+
|
|
12498
|
+
/** The canvas iframe painted, so the chat is no longer waiting on a hidden side preview. */
|
|
12499
|
+
function noteShapePreviewShown(widgetId: string): void {
|
|
12500
|
+
const status = getPanelDisplayState(widgetId).generateCodeStatus || '';
|
|
12501
|
+
if (!status.includes('loading preview')) return;
|
|
12502
|
+
patchCodegenUiState(widgetId, { generateCodeStatus: 'Preview ready' });
|
|
12503
|
+
getChatMethodsForWidget(widgetId)?.updateLatestCodegenStatusMessage?.('Preview ready');
|
|
12480
12504
|
}
|
|
12481
12505
|
|
|
12482
12506
|
function getOperationPreviewBuildError(metadata?: Record<string, unknown>): string | null {
|
|
@@ -13461,6 +13485,10 @@ Requirements:
|
|
|
13461
13485
|
const workerUrl = hasCode
|
|
13462
13486
|
? `${widgetBuilderPreviewBaseUrl()}/preview/${widgetId}`
|
|
13463
13487
|
: null;
|
|
13488
|
+
const runningPreview = runningWorkerPreviewUrlByWidgetId[widgetId] || null;
|
|
13489
|
+
// The poll learned this URL while the save was still running. The version menu
|
|
13490
|
+
// can already name the commit; the shape must not wait for that row's own build.
|
|
13491
|
+
if (runningPreview && generatingWidgetIds[widgetId]) return runningPreview;
|
|
13464
13492
|
|
|
13465
13493
|
if (source.startsWith('v:')) {
|
|
13466
13494
|
const version = parseInt(source.slice(2), 10);
|
|
@@ -13498,7 +13526,21 @@ Requirements:
|
|
|
13498
13526
|
) {
|
|
13499
13527
|
return workerUrl;
|
|
13500
13528
|
}
|
|
13501
|
-
|
|
13529
|
+
const isolatedUrl = resolveWidgetShapeVersionPreviewState(widgetId)?.url ?? null;
|
|
13530
|
+
if (isolatedUrl) return isolatedUrl;
|
|
13531
|
+
// The generation that just finished already published a Worker document.
|
|
13532
|
+
// A history row whose commit has not caught up yet must not hide that document.
|
|
13533
|
+
// A restored version stays on its own build: the shared URL would be the wrong commit.
|
|
13534
|
+
if (
|
|
13535
|
+
runningPreview
|
|
13536
|
+
&& !isPublished
|
|
13537
|
+
&& newestDraft != null
|
|
13538
|
+
&& version === newestDraft
|
|
13539
|
+
&& restoredViewingVersionByWidgetId[widgetId] == null
|
|
13540
|
+
) {
|
|
13541
|
+
return runningPreview;
|
|
13542
|
+
}
|
|
13543
|
+
return null;
|
|
13502
13544
|
}
|
|
13503
13545
|
return null;
|
|
13504
13546
|
}
|
|
@@ -17370,9 +17412,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17370
17412
|
const sketchCanvas = canvasRef as (typeof canvasRef & {
|
|
17371
17413
|
absorbCanvasSketchIntoWidget?: (widgetId: string, screenshotDataUrl: string) => Promise<string | null>;
|
|
17372
17414
|
}) | null;
|
|
17415
|
+
let placedShapeId: string | null = null;
|
|
17373
17416
|
if (embedded && !canvasAdvancedFeatures && sketchCanvas?.absorbCanvasSketchIntoWidget) {
|
|
17374
17417
|
try {
|
|
17375
|
-
await sketchCanvas.absorbCanvasSketchIntoWidget(widgetId, screenshot);
|
|
17418
|
+
placedShapeId = await sketchCanvas.absorbCanvasSketchIntoWidget(widgetId, screenshot);
|
|
17376
17419
|
setTimeout(() => {
|
|
17377
17420
|
canvasRef?.saveNow?.();
|
|
17378
17421
|
}, 800);
|
|
@@ -17382,6 +17425,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17382
17425
|
} else if (canvasRef && canvasObjectId) {
|
|
17383
17426
|
try {
|
|
17384
17427
|
await canvasRef.replaceObjectWithWidgetImage(canvasObjectId, widgetId, screenshot);
|
|
17428
|
+
placedShapeId = canvasObjectId;
|
|
17385
17429
|
// console.log('[WidgetCreator] Sketch replaced with WidgetShape screenshot');
|
|
17386
17430
|
// Flush the canvas AFTER the WidgetShape image fields are set
|
|
17387
17431
|
// (synchronous in replaceObjectWithWidgetImage). saveNow bypasses
|
|
@@ -17392,12 +17436,24 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17392
17436
|
} catch (replaceErr) {
|
|
17393
17437
|
console.warn('[WidgetCreator] Sketch replace failed (falling back to link):', replaceErr);
|
|
17394
17438
|
canvasRef.linkFrameToWidget(canvasObjectId, widgetId);
|
|
17439
|
+
placedShapeId = canvasObjectId;
|
|
17395
17440
|
setTimeout(() => {
|
|
17396
17441
|
canvasRef?.saveNow?.();
|
|
17397
17442
|
}, 800);
|
|
17398
17443
|
}
|
|
17399
17444
|
}
|
|
17400
17445
|
|
|
17446
|
+
// A text-only prompt leaves the board empty, and the published canvas
|
|
17447
|
+
// then absorbs nothing. The preview iframe needs a frame anyway.
|
|
17448
|
+
if (!placedShapeId && canvasRef?.addWidgetShape && !canvasRef.getLinkedWidgetIds?.().has(widgetId)) {
|
|
17449
|
+
placedShapeId = canvasRef.addWidgetShape(widgetId, newWidget.name || undefined, 0, 1, screenshot || null);
|
|
17450
|
+
console.log('[CreatorApp] Placed a preview frame — the board had no sketch', widgetId.substring(0, 8));
|
|
17451
|
+
setTimeout(() => {
|
|
17452
|
+
canvasRef?.saveNow?.();
|
|
17453
|
+
}, 800);
|
|
17454
|
+
}
|
|
17455
|
+
syncWidgetShapeLivePreviews();
|
|
17456
|
+
|
|
17401
17457
|
if (screenshot) {
|
|
17402
17458
|
void persistWidgetListThumbnail(widgetId, screenshot);
|
|
17403
17459
|
}
|
|
@@ -18299,6 +18355,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18299
18355
|
}}
|
|
18300
18356
|
onRefresh={handleWidgetShapeRefresh}
|
|
18301
18357
|
isGenerating={isAnyWidgetGenerating()}
|
|
18358
|
+
onLiveFrameShown={noteShapePreviewShown}
|
|
18302
18359
|
resolveSelectorEnabled={(widgetId) => !!selectorEnabledByWidgetId[widgetId]}
|
|
18303
18360
|
resolveSelectedElements={(widgetId) => selectedElementsByWidgetId[widgetId] ?? []}
|
|
18304
18361
|
onSelectWidgetElement={(widgetId, element) => handleSelectWidgetElement(widgetId, element)}
|
|
@@ -19135,34 +19192,6 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
19135
19192
|
{/if}
|
|
19136
19193
|
</div>
|
|
19137
19194
|
</div>
|
|
19138
|
-
{#if hourlyLimit}
|
|
19139
|
-
<div class="hourly-limit-banner p-3 bg-red-50 border border-red-200" style="border-radius: 0;">
|
|
19140
|
-
<p class="text-xs text-red-700 whitespace-pre-wrap">{$t('creator.preview.versionHourlyLimit')}</p>
|
|
19141
|
-
<div class="flex gap-2 mt-3 justify-center">
|
|
19142
|
-
<Button
|
|
19143
|
-
onclick={() => {
|
|
19144
|
-
if (!isPanelFocused) focusWidgetPanel(panelWidgetId);
|
|
19145
|
-
patchPanelSnapshot(panelWidgetId, {
|
|
19146
|
-
lastGenerationFailed: false,
|
|
19147
|
-
lastGenerationError: null,
|
|
19148
|
-
generateCodeStatus: 'Ready',
|
|
19149
|
-
});
|
|
19150
|
-
if (isPanelFocused || focusedPanelWidgetId === panelWidgetId) {
|
|
19151
|
-
lastGenerationFailed = false;
|
|
19152
|
-
lastGenerationError = null;
|
|
19153
|
-
generateCodeStatus = 'Ready';
|
|
19154
|
-
}
|
|
19155
|
-
panelDisplayRevision += 1;
|
|
19156
|
-
}}
|
|
19157
|
-
variant="outline"
|
|
19158
|
-
size="sm"
|
|
19159
|
-
class="border-gray-300 text-gray-600 hover:bg-gray-50 rounded-lg"
|
|
19160
|
-
>
|
|
19161
|
-
{$t('creator.general.dismiss')}
|
|
19162
|
-
</Button>
|
|
19163
|
-
</div>
|
|
19164
|
-
</div>
|
|
19165
|
-
{/if}
|
|
19166
19195
|
{#if publishPlanMessageByWidgetId[panelWidgetId]}
|
|
19167
19196
|
<div class="publish-plan-notice p-3 bg-red-50 border border-red-200" style="border-radius: 0;">
|
|
19168
19197
|
<p class="text-xs text-red-700 whitespace-pre-wrap">{publishPlanMessageByWidgetId[panelWidgetId]}</p>
|
|
@@ -95,6 +95,8 @@
|
|
|
95
95
|
resolvePublishDisabledReason?: ((widgetId: string, version: number) => string | null) | null;
|
|
96
96
|
/** Whether code generation is running (suppresses background captures / reloads). */
|
|
97
97
|
isGenerating?: boolean;
|
|
98
|
+
/** The shape iframe painted. The chat status waits on this when the side preview is hidden. */
|
|
99
|
+
onLiveFrameShown?: ((widgetId: string) => void) | null;
|
|
98
100
|
/** Simple canvas keeps the drag bar and hides the name, version, and publish controls. */
|
|
99
101
|
showChrome?: boolean;
|
|
100
102
|
/** Whether the interactive DOM Element Selector is active for this widget. */
|
|
@@ -144,6 +146,7 @@
|
|
|
144
146
|
/** Per-widget publish-gate reason for a Draft row (tooltip on Publish). */
|
|
145
147
|
resolvePublishDisabledReason = null,
|
|
146
148
|
isGenerating = false,
|
|
149
|
+
onLiveFrameShown = null,
|
|
147
150
|
showChrome = true,
|
|
148
151
|
resolveSelectorEnabled = null,
|
|
149
152
|
resolveSelectedElements = null,
|
|
@@ -242,9 +245,10 @@
|
|
|
242
245
|
// existed, so the codegen reload (the one that matches the new commit)
|
|
243
246
|
// never ran and the shape kept the previous build. Replace the timer so
|
|
244
247
|
// the later request wins. While generating, wait and try again.
|
|
245
|
-
// `immediate` is the call
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
+
// `immediate` is the call once a preview URL exists, including the one after the
|
|
249
|
+
// run flag has been cleared. Waiting on the prop left the old document up: the
|
|
250
|
+
// retry dropped `immediate`, and a later quiet window then dropped the reload.
|
|
251
|
+
if (isGenerating && !options?.immediate) {
|
|
248
252
|
const existing = coalescedReloadTimers.get(widgetId);
|
|
249
253
|
if (existing) clearTimeout(existing);
|
|
250
254
|
coalescedReloadTimers.set(
|
|
@@ -321,11 +325,11 @@
|
|
|
321
325
|
const resolvedSrc = resolveUrl(rect.widgetId) || '';
|
|
322
326
|
const previewState = resolvePreviewState?.(rect.widgetId);
|
|
323
327
|
const prev = overlays.find((o) => o.widgetId === rect.widgetId);
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
|
|
328
|
+
// A preview URL that already exists is shown while the repository is still
|
|
329
|
+
// saving. Keeping the previous frame, or skipping a shape that had none,
|
|
330
|
+
// left the canvas on the static image after the chat already had the version.
|
|
331
|
+
const src = resolvedSrc || (isGenerating ? prev?.src || '' : '');
|
|
327
332
|
if (!src && !previewState?.loading && !previewState?.error) continue;
|
|
328
|
-
if (isGenerating && !prev?.src && !previewState?.url) continue;
|
|
329
333
|
if (!prev || prev.src !== src) {
|
|
330
334
|
cancelPendingRefresh(rect.widgetId);
|
|
331
335
|
nextLoaded[rect.widgetId] = false;
|
|
@@ -471,6 +475,11 @@
|
|
|
471
475
|
if (!matchesFrame()) return;
|
|
472
476
|
iframeLoadedByWidgetId = { ...iframeLoadedByWidgetId, [widgetId]: true };
|
|
473
477
|
iframeElementByWidgetId = { ...iframeElementByWidgetId, [widgetId]: iframe };
|
|
478
|
+
try {
|
|
479
|
+
onLiveFrameShown?.(widgetId);
|
|
480
|
+
} catch (error) {
|
|
481
|
+
console.warn('[WidgetShapeLivePreviews] Preview-shown callback failed', error);
|
|
482
|
+
}
|
|
474
483
|
// Suppress auto-refresh / screenshot capture when code generation is running.
|
|
475
484
|
if (isGenerating) {
|
|
476
485
|
cancelPendingRefresh(widgetId);
|
|
@@ -94,6 +94,8 @@ interface Props {
|
|
|
94
94
|
resolvePublishDisabledReason?: ((widgetId: string, version: number) => string | null) | null;
|
|
95
95
|
/** Whether code generation is running (suppresses background captures / reloads). */
|
|
96
96
|
isGenerating?: boolean;
|
|
97
|
+
/** The shape iframe painted. The chat status waits on this when the side preview is hidden. */
|
|
98
|
+
onLiveFrameShown?: ((widgetId: string) => void) | null;
|
|
97
99
|
/** Simple canvas keeps the drag bar and hides the name, version, and publish controls. */
|
|
98
100
|
showChrome?: boolean;
|
|
99
101
|
/** Whether the interactive DOM Element Selector is active for this widget. */
|