@widgetic/creator 0.3.79 → 0.3.80

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.
@@ -8514,6 +8514,67 @@
8514
8514
  }, IDLE_THUMBNAIL_DELAY_MS);
8515
8515
  idleThumbnailTimers.set(widgetId, timer);
8516
8516
  }
8517
+ /**
8518
+ * Screenshot of whatever the preview is showing now, stored as the list thumbnail.
8519
+ * A published CDN file often has no capture script, so the Worker preview is the fallback.
8520
+ * That fallback still uses the main thread, so publish schedules it after the click returns.
8521
+ */
8522
+ async function captureListThumbnail(widgetId: string, interactive: boolean): Promise<void> {
8523
+ if (!widgetId || isDraftConvertId(widgetId)) return;
8524
+ if (codegenCaptureBlocked() || generatingWidgetIds[widgetId]) {
8525
+ if (interactive) {
8526
+ showToast('info', 'Preview image waits until generation finishes', { duration: 3000 });
8527
+ }
8528
+ return;
8529
+ }
8530
+ if (interactive) {
8531
+ showToast('info', 'Saving preview image...', { duration: 2500 });
8532
+ }
8533
+ try {
8534
+ const screenshot = await handleChatScreenshot(widgetId, null, false);
8535
+ if (!screenshot) {
8536
+ if (interactive) {
8537
+ showToast('error', 'Could not save the preview image', {
8538
+ description: 'The preview did not return an image. Refresh it, then try again.',
8539
+ duration: 5000,
8540
+ });
8541
+ }
8542
+ return;
8543
+ }
8544
+ canvasRef?.updateWidgetImage(widgetId, screenshot);
8545
+ await persistWidgetListThumbnail(widgetId, screenshot);
8546
+ if (interactive) {
8547
+ showToast('success', 'Preview image saved', { duration: 2000 });
8548
+ } else {
8549
+ console.log('[Chat→Screenshot] List thumbnail saved', widgetId.substring(0, 8));
8550
+ }
8551
+ } catch (error) {
8552
+ console.warn('[Chat→Screenshot] List thumbnail failed', widgetId.substring(0, 8), error);
8553
+ if (interactive) {
8554
+ showToast('error', 'Could not save the preview image', { duration: 4000 });
8555
+ }
8556
+ }
8557
+ }
8558
+
8559
+ const listThumbnailTimers = new Map<string, ReturnType<typeof setTimeout>>();
8560
+ function scheduleListThumbnailCapture(widgetId: string): void {
8561
+ if (!widgetId) return;
8562
+ const existing = listThumbnailTimers.get(widgetId);
8563
+ if (existing) clearTimeout(existing);
8564
+ const timer = setTimeout(() => {
8565
+ listThumbnailTimers.delete(widgetId);
8566
+ const run = () => {
8567
+ void captureListThumbnail(widgetId, false);
8568
+ };
8569
+ if (typeof requestIdleCallback === 'function') {
8570
+ requestIdleCallback(() => run(), { timeout: 8000 });
8571
+ } else {
8572
+ run();
8573
+ }
8574
+ }, 8000);
8575
+ listThumbnailTimers.set(widgetId, timer);
8576
+ }
8577
+
8517
8578
  async function persistIdleWidgetThumbnail(widgetId: string): Promise<void> {
8518
8579
  if (codegenCaptureBlocked() || generatingWidgetIds[widgetId]) return;
8519
8580
  const iframe = resolveLiveWidgetShapeIframe(widgetId);
@@ -10290,6 +10351,7 @@ Requirements:
10290
10351
  console.log('[Publish] Refreshing preview after publish (step:', widgetDetailsStep, ')');
10291
10352
  publishedPanelRef?.invalidatePublishedArtifactCache?.();
10292
10353
  await publishedPanelRef?.refreshPreview({ withRetry: true });
10354
+ scheduleListThumbnailCapture(capturedWidgetId);
10293
10355
 
10294
10356
  await loadPublishHistory();
10295
10357
  void refreshTrialCounter();
@@ -15979,7 +16041,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
15979
16041
  onWidgetShapeDuplicated={handleWidgetShapeDuplicated}
15980
16042
  onWidgetShapeDeleting={handleWidgetShapeDeleting}
15981
16043
  onWidgetRename={handleWidgetRename}
15982
- onRefreshScreenshot={null}
16044
+ onRefreshScreenshot={(widgetId) => {
16045
+ void captureListThumbnail(widgetId, true);
16046
+ }}
15983
16047
  onSetPrimaryWidget={handleSetPrimaryWidget}
15984
16048
  onAfterRender={syncWidgetShapeLivePreviews}
15985
16049
  getWidgetName={getWidgetNameById}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/creator",
3
- "version": "0.3.79",
3
+ "version": "0.3.80",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "@sveltejs/kit": "^2.20.0",