@widgetic/creator 0.4.41 → 0.4.42

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.
@@ -875,6 +875,31 @@
875
875
  return partnerMode && err instanceof ResponseError && err.response?.status === 404;
876
876
  }
877
877
 
878
+ function canvasReadStatus(err: unknown): number | null {
879
+ return err instanceof ResponseError ? (err.response?.status ?? null) : null;
880
+ }
881
+
882
+ /** 401 and 403 are the answer. Asking again only delays the message on screen. */
883
+ function canvasReadWillNotChange(err: unknown): boolean {
884
+ const status = canvasReadStatus(err);
885
+ return status === 401 || status === 403 || saysCanvasIsMissing(err);
886
+ }
887
+
888
+ /** Stops the load retries and shows the API's own sentence. */
889
+ function stopAskingForCanvas(err: unknown, message: string): void {
890
+ if (canvasUnavailable) return;
891
+ canvasUnavailable = true;
892
+ clearCanvasLoadFailsafe();
893
+ clearCanvasHydrateRetry();
894
+ canvasApiLoadError = message;
895
+ const status = canvasReadStatus(err);
896
+ reportCanvasUnavailable({
897
+ canvasId: canvasId || null,
898
+ message,
899
+ code: status === 403 ? 'FORBIDDEN' : status === 401 ? 'UNAUTHORIZED' : 'NOT_FOUND',
900
+ });
901
+ }
902
+
878
903
  /** Credits left and days left, from the same billing status the publish gate uses. */
879
904
  async function refreshTrialCounter() {
880
905
  // An account matter: a visitor of a partner has no trial and no balance of their own to show.
@@ -973,7 +998,7 @@
973
998
  import type { DropdownItem } from './components/SelectorDropdown.svelte';
974
999
  import WidgetShapeLivePreviews from './components/WidgetShapeLivePreviews.svelte';
975
1000
  import HoverTooltip from './components/HoverTooltip.svelte';
976
- import VersionDropdownRow from './components/VersionDropdownRow.svelte';
1001
+ import VersionDropdownRow, { revealSelectedVersion } from './components/VersionDropdownRow.svelte';
977
1002
  // Type-only: erased at compile time, so the component's code is still
978
1003
  // dynamically imported below — this line exists so the ref types below can
979
1004
  // derive from the component's REAL class instead of the `any` a dynamic
@@ -3758,6 +3783,9 @@
3758
3783
  : $t('creator.codegen.widgetCodeAtCommitRefreshing', { commit: formatCommitShaShort(historicalSha) }),
3759
3784
  duration: 6000,
3760
3785
  });
3786
+ const alreadyCurrent = gitRollback?.alreadyCurrent === true || gitRollback?.already_current === true;
3787
+ const rebuiltFromFiles = gitRollback?.rebuilt === true;
3788
+ const previewWithoutGitlab = alreadyCurrent || rebuiltFromFiles;
3761
3789
  liveDesignValues = {};
3762
3790
  liveContentValues = {};
3763
3791
  liveContentItems = [];
@@ -3767,13 +3795,15 @@
3767
3795
  _isRestoringCheckpoint = true;
3768
3796
  const panelRef = panelWidgetId ? getWidgetDetailsRef(panelWidgetId) : widgetDetails;
3769
3797
  const scheduleBuildRetry = async () => {
3770
- const delays = [400, 2500, 5000, 8000];
3798
+ const delays = previewWithoutGitlab ? [400] : [400, 2500, 5000, 8000];
3771
3799
  for (let i = 0; i < delays.length; i++) {
3772
3800
  if (i > 0) await new Promise((r) => setTimeout(r, delays[i]));
3773
3801
  if (i === 0) suppressNextBuildFromRepoChatMessage = true;
3774
3802
  try {
3775
3803
  const activeRef = panelWidgetId ? getWidgetDetailsRef(panelWidgetId) : panelRef;
3776
- await activeRef?.triggerBuildFromRepo({ force: true });
3804
+ // The server already built from the files it read, or the branch was already
3805
+ // that version. Reloading the preview must not read GitLab again.
3806
+ await activeRef?.triggerBuildFromRepo(previewWithoutGitlab ? undefined : { force: true });
3777
3807
  const err = activeRef?.getPreviewError?.() ?? null;
3778
3808
  if (!err) {
3779
3809
  _isRestoringCheckpoint = false;
@@ -3803,8 +3833,14 @@
3803
3833
  console.warn('[Restore] The code was not rolled back', { widgetId: panelWidgetId, rollbackError });
3804
3834
  showToast('warning', gitlabLimited ? $t('creator.general.rateLimited') : $t('creator.version.failedToRestoreCheckpoint'), {
3805
3835
  description: rollbackError || $t('creator.version.codeWasNotRolledBack'),
3806
- duration: 9000,
3836
+ duration: gitlabLimited ? 20000 : 9000,
3807
3837
  });
3838
+ if (gitlabLimited && panelWidgetId) {
3839
+ getChatMethodsForWidget(panelWidgetId)?.addAssistantMessage?.(
3840
+ codegenFailureChatLine(rollbackError || 'GitLab rate limit reached (429), so nothing was changed. Wait a minute and try again.'),
3841
+ true,
3842
+ );
3843
+ }
3808
3844
  return null;
3809
3845
  } else {
3810
3846
  console.warn('[Chat→Backend] Git rollback not detected in response, refreshing preview anyway...');
@@ -5419,6 +5455,7 @@
5419
5455
  }
5420
5456
  }
5421
5457
  }
5458
+ if (selectedWidgetId) void postVisitorEntriesHost(selectedWidgetId);
5422
5459
  } catch (err: any) {
5423
5460
  console.error('[Compositions] Failed to load:', err);
5424
5461
  } finally {
@@ -5496,6 +5533,86 @@
5496
5533
  resolveLiveWidgetShapeIframe(widgetId)?.contentWindow?.postMessage(message, '*');
5497
5534
  }
5498
5535
 
5536
+ /** One lookup per composition. A failed lookup is dropped so the next preview can ask again. */
5537
+ const entriesHostByCompositionId = new Map<string, Promise<{ url: string; writeToken?: string } | null>>();
5538
+
5539
+ function entriesHostForComposition(compositionId: string): Promise<{ url: string; writeToken?: string } | null> {
5540
+ const cached = entriesHostByCompositionId.get(compositionId);
5541
+ if (cached) return cached;
5542
+ const root = (apiRoot || '').replace(/\/+$/, '');
5543
+ if (!root) return Promise.resolve(null);
5544
+ const pending = (async () => {
5545
+ try {
5546
+ const response = await fetch(`${root}/embed/compositions/${compositionId}`, { cache: 'reload' });
5547
+ if (!response.ok) {
5548
+ console.warn('[CreatorApp] Visitor entries address was not available', response.status);
5549
+ entriesHostByCompositionId.delete(compositionId);
5550
+ return null;
5551
+ }
5552
+ const body = await response.json();
5553
+ const data = body?.data ?? body;
5554
+ const writeToken = data?.entries?.writeToken || data?.entryWriteToken;
5555
+ return {
5556
+ url: `${root}/embed/compositions/${compositionId}/entries`,
5557
+ ...(typeof writeToken === 'string' && writeToken ? { writeToken } : {}),
5558
+ };
5559
+ } catch (error) {
5560
+ console.warn('[CreatorApp] Visitor entries address failed', error);
5561
+ entriesHostByCompositionId.delete(compositionId);
5562
+ return null;
5563
+ }
5564
+ })();
5565
+ entriesHostByCompositionId.set(compositionId, pending);
5566
+ return pending;
5567
+ }
5568
+
5569
+ /** The composition whose table a vote from this preview should fill. The open one, else the first. */
5570
+ async function compositionIdForVisitorEntries(widgetId: string): Promise<string | null> {
5571
+ const panel = getPanelDisplayState(widgetId);
5572
+ const openId = panel?.selectedComposition?.id;
5573
+ if (typeof openId === 'string' && openId) return openId;
5574
+ if (widgetId === selectedWidgetId && typeof selectedComposition?.id === 'string' && selectedComposition.id) {
5575
+ return selectedComposition.id;
5576
+ }
5577
+ if (!compositionsClient) return null;
5578
+ try {
5579
+ const res = await compositionsClient.getAllCompositions({ widgetId });
5580
+ const rows = ((res as { data?: unknown[] })?.data ?? []) as Array<Record<string, unknown>>;
5581
+ const mine = rows.filter((row) => (row.widget_id || row.widgetId) === widgetId);
5582
+ mine.sort((a, b) => {
5583
+ const aTime = new Date(String(a.createdAt ?? a.created_at ?? 0)).getTime();
5584
+ const bTime = new Date(String(b.createdAt ?? b.created_at ?? 0)).getTime();
5585
+ return aTime - bTime;
5586
+ });
5587
+ const id = mine[0]?.id;
5588
+ return typeof id === 'string' ? id : null;
5589
+ } catch (error) {
5590
+ console.warn('[CreatorApp] Could not read the composition for visitor entries', error);
5591
+ return null;
5592
+ }
5593
+ }
5594
+
5595
+ /** Tell the canvas preview, and the side preview, where a visitor entry is saved. */
5596
+ async function postVisitorEntriesHost(widgetId: string): Promise<void> {
5597
+ if (!widgetId) return;
5598
+ const compositionId = await compositionIdForVisitorEntries(widgetId);
5599
+ if (!compositionId) return;
5600
+ const entries = await entriesHostForComposition(compositionId);
5601
+ if (!entries) return;
5602
+ const message = {
5603
+ type: 'widgetic:host',
5604
+ version: 1,
5605
+ compositionId,
5606
+ context: null,
5607
+ values: null,
5608
+ mediaResolver: null,
5609
+ entries,
5610
+ };
5611
+ getWidgetDetailsRef(widgetId)?.sendMessageToPreview(message);
5612
+ resolveLiveWidgetShapeIframe(widgetId)?.contentWindow?.postMessage(message, '*');
5613
+ console.log('[CreatorApp] Told the preview where visitor entries are saved');
5614
+ }
5615
+
5499
5616
  /** Push composition overlay to a specific panel preview iframe. */
5500
5617
  function applyPanelCompositionToPreview(widgetId: string): void {
5501
5618
  const panelRef = getWidgetDetailsRef(widgetId);
@@ -6236,6 +6353,11 @@
6236
6353
  let canvasPrimaryWidgetId: string | null = null;
6237
6354
  /** Restore Checkpoint back to the sketch brings the drawing tools back until the next generation. */
6238
6355
  let sketchToolbarAfterRestore = false;
6356
+ /**
6357
+ * Single-widget canvases hide both bottom bars until the primary widget has been read.
6358
+ * Otherwise the drawing toolbar flashes, then the selector replaces it.
6359
+ */
6360
+ let singleWidgetChromeReady = false;
6239
6361
 
6240
6362
  function primaryWidgetHasGeneratedCode(): boolean {
6241
6363
  if (!canvasPrimaryWidgetId || isDraftConvertId(canvasPrimaryWidgetId)) return false;
@@ -6243,10 +6365,12 @@
6243
6365
  return !!(panel.hasGeneratedCode || panel.lastCommitId || panel.lastPublishedVersion != null);
6244
6366
  }
6245
6367
 
6246
- $: showDrawingTools = sketchToolbarAfterRestore || !(
6247
- panelDisplayRevision >= 0
6248
- && !!canvasPrimaryWidgetId
6249
- && primaryWidgetHasGeneratedCode()
6368
+ $: showDrawingTools = (multipleWidgetsAllowed || singleWidgetChromeReady) && (
6369
+ sketchToolbarAfterRestore || !(
6370
+ panelDisplayRevision >= 0
6371
+ && !!canvasPrimaryWidgetId
6372
+ && primaryWidgetHasGeneratedCode()
6373
+ )
6250
6374
  );
6251
6375
 
6252
6376
  function emitCreatorWireframeChanged() {
@@ -7569,6 +7693,7 @@
7569
7693
  // widget_id belonging to the previous canvas.
7570
7694
  routeCanvasId = entry.id;
7571
7695
  canvasPrimaryWidgetId = null;
7696
+ singleWidgetChromeReady = false;
7572
7697
  syncUrlCanvasId(entry.id);
7573
7698
 
7574
7699
  // Clear existing widgets and canvas visually
@@ -9364,9 +9489,9 @@
9364
9489
  publishHistoryResolvedForWidgetId: widget.id,
9365
9490
  });
9366
9491
  }
9367
- // Reconcile GitLab HEAD whenever we have a repo — unpublished widgets
9368
- // also need lastCommitId so Create preview is not stuck on "No Code Yet".
9369
- if (currentRepositoryId) {
9492
+ // The version menu is the database history. GitLab is asked for HEAD only when this
9493
+ // browser has no commit yet, so a first open on another machine can leave "No Code Yet".
9494
+ if (currentRepositoryId && !lastCommitId) {
9370
9495
  void reconcileWidgetHeadCommit(widget.id);
9371
9496
  }
9372
9497
  }
@@ -11825,16 +11950,12 @@ Requirements:
11825
11950
  setTimeout(() => alignGeneratedVersion(0), 1200);
11826
11951
  }
11827
11952
 
11828
- // Always reconcile GitLab HEAD after codegen (metadata.commitId can be missing/stale).
11829
- // Deferred — same window as the schema/history reloads above.
11953
+ // The generation already returned its commit. Ask GitLab for HEAD only when that commit is missing.
11830
11954
  if (generationWidgetId) {
11831
11955
  setTimeout(() => {
11832
11956
  void (async () => {
11833
11957
  try {
11834
- const fetchedHead = await fetchRepoHeadCommitSha(generationWidgetId);
11835
- // Prefer the codegen commit from the operation. GitLab HEAD can still
11836
- // be the previous live SHA for a few seconds — that used to clear
11837
- // pending publish until Widget Details was reopened.
11958
+ const fetchedHead = completedCommitSha ? null : await fetchRepoHeadCommitSha(generationWidgetId);
11838
11959
  const headSha = completedCommitSha || fetchedHead;
11839
11960
  if (!headSha) return;
11840
11961
  saveCommitIdForWidget(generationWidgetId, headSha);
@@ -12644,7 +12765,10 @@ Requirements:
12644
12765
  for (const frame of frames) {
12645
12766
  if (!(frame instanceof HTMLIFrameElement) || event.source !== frame.contentWindow) continue;
12646
12767
  const widgetId = frame.dataset.widgetId;
12647
- if (widgetId) postContentItemsToPreviewFrames(widgetId);
12768
+ if (widgetId) {
12769
+ postContentItemsToPreviewFrames(widgetId);
12770
+ void postVisitorEntriesHost(widgetId);
12771
+ }
12648
12772
  }
12649
12773
  };
12650
12774
  window.addEventListener('message', onShapeWidgetReady);
@@ -13120,6 +13244,10 @@ Requirements:
13120
13244
 
13121
13245
  /** The canvas iframe painted, so the chat is no longer waiting on a hidden side preview. */
13122
13246
  function noteShapePreviewShown(widgetId: string): void {
13247
+ // The widget listens after it mounts. The load event can be early, and a reload can miss
13248
+ // `widgetic:ready`, so the address is sent again once the frame has had time to listen.
13249
+ void postVisitorEntriesHost(widgetId);
13250
+ setTimeout(() => { void postVisitorEntriesHost(widgetId); }, 800);
13123
13251
  const status = getPanelDisplayState(widgetId).generateCodeStatus || '';
13124
13252
  const waitingOnPreview = /loading preview|building preview|generating code|code generation in progress|code saved/i.test(status);
13125
13253
  const generationRunning = !!generatingWidgetIds[widgetId] || !!previewUnblockedByWidgetId[widgetId];
@@ -16386,7 +16514,6 @@ async function readPublishHistoryForPanel(widgetId: string, opts: { silent?: boo
16386
16514
  lastPublishedVersion = getPanelState(widgetId).lastPublishedVersion;
16387
16515
  }
16388
16516
  }
16389
- void reconcileWidgetHeadCommit(widgetId);
16390
16517
  if (widgetId === focusedPanelWidgetId) {
16391
16518
  publishHistory = history;
16392
16519
  publishHistoryResolved = true;
@@ -17462,6 +17589,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17462
17589
  if (!embedded || canvasAdvancedFeatures || !canvasComponentReady) return;
17463
17590
  if (finalizingDraftConversions.size > 0) return;
17464
17591
  const primaryId = (canvasPrimaryWidgetId || '').trim();
17592
+ // The canvas JSON is loaded before the primary widget is known. Opening the draft chat in that gap
17593
+ // paints the empty suggestions, then the real conversation replaces them.
17594
+ if (!primaryId && !singleWidgetChromeReady) return;
17465
17595
  const targetId = primaryId || CANVAS_SKETCH_DRAFT_ID;
17466
17596
  const key = `${canvasId || 'pending'}:${targetId}`;
17467
17597
  if (simpleCanvasChatKey === key && openWidgetPanelIds.includes(targetId)) return;
@@ -17480,16 +17610,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17480
17610
  }
17481
17611
  }
17482
17612
 
17483
- $: if (embedded && !canvasAdvancedFeatures && canvasComponentReady && isCanvasStateLoaded) {
17484
- const simpleChatTarget = (canvasPrimaryWidgetId || '').trim() || CANVAS_SKETCH_DRAFT_ID;
17485
- if (!openWidgetPanelIds.includes(simpleChatTarget)) {
17486
- void ensureSimpleCanvasChat();
17487
- }
17613
+ $: if (embedded && !canvasAdvancedFeatures && canvasComponentReady && isCanvasStateLoaded && (singleWidgetChromeReady || !!(canvasPrimaryWidgetId || '').trim())) {
17614
+ void ensureSimpleCanvasChat();
17488
17615
  }
17489
17616
 
17490
17617
  async function handleCanvasReady() {
17491
17618
  markCanvasOpenStep('creator:canvas-ready');
17492
17619
  // console.log('[WidgetCreator] Canvas component ready');
17620
+ singleWidgetChromeReady = false;
17493
17621
  await waitForCanvasRef();
17494
17622
  canvasComponentReady = true;
17495
17623
  if (ignoreIncomingCanvasLoads) {
@@ -17502,12 +17630,16 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17502
17630
  placeSelectedWidgetShapeOnCanvas();
17503
17631
  }
17504
17632
  syncWidgetShapeLivePreviews();
17633
+ singleWidgetChromeReady = true;
17505
17634
  void ensureSimpleCanvasChat();
17506
17635
  return;
17507
17636
  }
17508
17637
  const { loaded, widgetIds: widgetIdsOnCanvas } = await tryLoadCanvasState();
17509
17638
  if (!loaded) {
17510
17639
  console.log('[WidgetCreator] Canvas ready — JSON load deferred until canvasId is resolved');
17640
+ if (isCanvasStateLoaded && (canvasPrimaryWidgetId || widgets.length === 0)) {
17641
+ singleWidgetChromeReady = true;
17642
+ }
17511
17643
  if (!isCanvasStateLoaded) {
17512
17644
  scheduleCanvasHydrateRetry('canvas ready before canvasId');
17513
17645
  }
@@ -17528,6 +17660,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17528
17660
  setTimeout(() => applyPrimarySelectionOnCanvas(primaryId), 80);
17529
17661
  });
17530
17662
  syncWidgetShapeLivePreviews();
17663
+ singleWidgetChromeReady = true;
17531
17664
  void ensureSimpleCanvasChat();
17532
17665
  }
17533
17666
 
@@ -17687,8 +17820,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17687
17820
  console.log('[CanvasDebug] getCanvas returned no canvasContent, retry', attempt + 1);
17688
17821
  } catch (getErr) {
17689
17822
  console.warn('[CanvasDebug] getCanvas failed, retry', attempt + 1, getErr);
17690
- // "No such canvas" is an answer, not a hiccup: asking again would only get it again.
17691
- if (saysCanvasIsMissing(getErr) || attempt >= maxCanvasReadAttempts - 1) throw getErr;
17823
+ // Access denied and "no such canvas" are answers. A pause and another read only delay the sentence.
17824
+ if (canvasReadWillNotChange(getErr) || attempt >= maxCanvasReadAttempts - 1) throw getErr;
17692
17825
  }
17693
17826
  if (attempt < maxCanvasReadAttempts - 1) {
17694
17827
  await new Promise((resolve) => setTimeout(resolve, 400 * (attempt + 1)));
@@ -17755,8 +17888,9 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
17755
17888
  canvasApiLoadError = errMsg;
17756
17889
  // Partner mode: the API says the canvas does not exist for this visitor. It is not an empty canvas to start on
17757
17890
  // (the fallbacks below would call it one and say the creator is ready): the page is told, and that is the end.
17758
- if (saysCanvasIsMissing(err)) {
17759
- declareCanvasUnavailable(canvasId || null, errMsg);
17891
+ if (canvasReadWillNotChange(err)) {
17892
+ if (saysCanvasIsMissing(err)) declareCanvasUnavailable(canvasId || null, errMsg);
17893
+ else stopAskingForCanvas(err, errMsg);
17760
17894
  return emptyResult;
17761
17895
  }
17762
17896
  if (/timed out|failed to fetch|network|econnrefused|503|502|load canvases/i.test(errMsg)) {
@@ -19106,7 +19240,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19106
19240
  {#if canvasApiLoadError}
19107
19241
  <p class="font-semibold">{canvasUnavailable ? $t('creator.canvas.canvasUnavailable') : $t('creator.canvas.canvasShapesFailedToLoad')}</p>
19108
19242
  <p class="text-xs mt-1">{canvasApiLoadError}</p>
19109
- {#if !partnerMode}
19243
+ {#if !partnerMode && !canvasUnavailable}
19110
19244
  <p class="text-xs mt-1 opacity-90">If Supabase shows a billing/quota warning, upgrade or review billing — API reads may fail while the widget list still loads.</p>
19111
19245
  {/if}
19112
19246
  {:else}
@@ -19155,7 +19289,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19155
19289
  void captureListThumbnail(widgetId, true);
19156
19290
  }}
19157
19291
  onSetPrimaryWidget={handleSetPrimaryWidget}
19158
- showElementSelector={!!canvasPrimaryWidgetId && !isDraftConvertId(canvasPrimaryWidgetId)}
19292
+ showElementSelector={(multipleWidgetsAllowed || singleWidgetChromeReady) && !!canvasPrimaryWidgetId && !isDraftConvertId(canvasPrimaryWidgetId)}
19159
19293
  showDrawingTools={showDrawingTools}
19160
19294
  elementSelectorActive={!!(canvasPrimaryWidgetId && selectorEnabledByWidgetId[canvasPrimaryWidgetId])}
19161
19295
  selectorGuide={{
@@ -20017,6 +20151,7 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
20017
20151
  {:else}
20018
20152
  <div
20019
20153
  class="wc-version-history-scroll flex flex-col gap-1 overflow-x-hidden {hasChatScroll ? 'overflow-y-auto' : 'overflow-y-visible'}"
20154
+ use:revealSelectedVersion
20020
20155
  style="{hasChatScroll ? 'max-height: 185px; margin-inline-end: -4px; padding-inline-end: 4px;' : 'max-height: none;'} scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.2) transparent;"
20021
20156
  >
20022
20157
  {#each [...ps.publishHistory].sort((a, b) => Number(a.version) - Number(b.version)) as record (record.id)}
@@ -29,6 +29,6 @@ interface Props {
29
29
  language?: string;
30
30
  languageLocked?: boolean;
31
31
  }
32
- declare const BrandKitPanel: import("svelte").Component<Props, {}, "brandKitEnabled" | "librariesEnabled" | "primary" | "secondary" | "title" | "sub" | "fonts" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "fontUploads" | "language">;
32
+ declare const BrandKitPanel: import("svelte").Component<Props, {}, "sub" | "title" | "brandKitEnabled" | "librariesEnabled" | "primary" | "secondary" | "fonts" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "fontUploads" | "language">;
33
33
  type BrandKitPanel = ReturnType<typeof BrandKitPanel>;
34
34
  export default BrandKitPanel;
@@ -10,6 +10,6 @@ interface Props {
10
10
  urlPlaceholder?: string;
11
11
  accept?: string;
12
12
  }
13
- declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "fileName" | "fileContent" | "fileEncoding" | "url">;
13
+ declare const FileUrlSourceControl: import("svelte").Component<Props, {}, "url" | "fileName" | "fileContent" | "fileEncoding">;
14
14
  type FileUrlSourceControl = ReturnType<typeof FileUrlSourceControl>;
15
15
  export default FileUrlSourceControl;
@@ -1,3 +1,28 @@
1
+ <script lang="ts" module>
2
+ /** Puts the selected row in view inside this menu only. Does not move the chat or the page. */
3
+ export function revealSelectedVersion(node: HTMLElement) {
4
+ const reveal = () => {
5
+ const selected = node.querySelector('[aria-selected="true"]');
6
+ if (!(selected instanceof HTMLElement)) return;
7
+ const rowRect = selected.getBoundingClientRect();
8
+ const viewRect = node.getBoundingClientRect();
9
+ if (rowRect.height === 0 || viewRect.height === 0) return;
10
+ if (rowRect.top >= viewRect.top && rowRect.bottom <= viewRect.bottom) return;
11
+ const delta = rowRect.top - viewRect.top - (viewRect.height - rowRect.height) / 2;
12
+ node.scrollTop += delta;
13
+ };
14
+ const frame = requestAnimationFrame(reveal);
15
+ const observer = new MutationObserver(() => requestAnimationFrame(reveal));
16
+ observer.observe(node, { childList: true });
17
+ return {
18
+ destroy() {
19
+ cancelAnimationFrame(frame);
20
+ observer.disconnect();
21
+ },
22
+ };
23
+ }
24
+ </script>
25
+
1
26
  <script lang="ts">
2
27
  /**
3
28
  * VersionDropdownRow — the ONE row used by BOTH version dropdowns (chat
@@ -1,3 +1,7 @@
1
+ /** Puts the selected row in view inside this menu only. Does not move the chat or the page. */
2
+ export declare function revealSelectedVersion(node: HTMLElement): {
3
+ destroy(): void;
4
+ };
1
5
  interface Props {
2
6
  /** Version label shown in the first cell (e.g. "v2"). */
3
7
  versionLabel: string;
@@ -100,7 +100,7 @@ declare const WidgetDetails: $$__sveltets_2_IsomorphicComponent<{
100
100
  /** Stacking order when multiple Widget Details panels are open. */ panelZIndex?: number;
101
101
  /** Cascade offset index (0 = centered, 1+ = shifted down-right). */ panelCascadeIndex?: number;
102
102
  /** False when another panel has keyboard/chat focus. */ isFocusedPanel?: boolean;
103
- currentStep?: "create" | "edit" | "embed";
103
+ currentStep?: "embed" | "create" | "edit";
104
104
  /**
105
105
  * Canvas Creator is code-only (chat + preview). Edit/Embed header steps stay
106
106
  * off until composition editing lives on /composition. Keep the Edit/Embed
@@ -7,7 +7,7 @@
7
7
  import { Checked } from '@widgetic/design-system/icons';
8
8
  import { Portal } from '@widgetic/design-system';
9
9
  import HoverTooltip from './HoverTooltip.svelte';
10
- import VersionDropdownRow from './VersionDropdownRow.svelte';
10
+ import VersionDropdownRow, { revealSelectedVersion } from './VersionDropdownRow.svelte';
11
11
  import WidgetElementSelector from './WidgetElementSelector.svelte';
12
12
  import type { SelectedWidgetElementReference } from '../utils/widgetElementSelector';
13
13
  import { errorLabel, useCreatorLanguage } from '../i18n/index.js';
@@ -1239,6 +1239,7 @@
1239
1239
  >
1240
1240
  <div
1241
1241
  class="widget-shape-version-scroll flex flex-col gap-1 overflow-x-hidden {hasScroll ? 'overflow-y-auto' : 'overflow-y-visible'}"
1242
+ use:revealSelectedVersion
1242
1243
  style="{hasScroll ? 'max-height: 185px; margin-inline-end: -4px; padding-inline-end: 4px;' : 'max-height: none;'} scrollbar-width: thin; scrollbar-color: rgba(0,0,0,0.2) transparent;"
1243
1244
  >
1244
1245
  {#each versionOptions as option (option.id)}
@@ -593,9 +593,7 @@ export declare const CREATOR_CATALOGS: {
593
593
  readonly 'chat.messages.restore': "Restore Checkpoint";
594
594
  readonly 'chat.messages.restoreTitle': "Restore widget code to this prompt's commit";
595
595
  readonly 'chat.messages.alreadyHead': "This checkpoint is already HEAD";
596
- readonly 'chat.messages.rateGroup': "Rate this version";
597
- readonly 'chat.messages.rateUp': "This version is good";
598
- readonly 'chat.messages.rateDown': "This version is not good";
596
+ readonly 'chat.messages.showSuggestions': "Show suggestions";
599
597
  readonly 'chat.messages.version': "Version {number}";
600
598
  readonly 'chat.messages.restoredFrom': "Restored from {label}";
601
599
  readonly 'chat.messages.previousVersion': "a previous version";
@@ -706,6 +704,7 @@ export declare const CREATOR_CATALOGS: {
706
704
  readonly 'canvas.state.loading': "Loading canvas\u2026";
707
705
  readonly 'canvas.state.initFailed': "Canvas failed to initialize.";
708
706
  readonly 'canvas.error.imageFromUrl': "Failed to load image from URL. Make sure the URL is correct and allows cross-origin requests.";
707
+ readonly 'canvas.defaults.text': "Hello World!";
709
708
  readonly 'canvas.defaults.textBox': "Type here";
710
709
  readonly 'canvas.defaults.frameLabel': "Frame";
711
710
  readonly 'canvas.defaults.untitledFrame': "Untitled Frame";
@@ -727,7 +726,6 @@ export declare const CREATOR_CATALOGS: {
727
726
  readonly 'canvas.tool.circle': "Circle";
728
727
  readonly 'canvas.tool.frame': "Frame";
729
728
  readonly 'canvas.tool.text': "Text";
730
- readonly 'canvas.tool.selector': "Selector";
731
729
  readonly 'canvas.tool.image': "Image";
732
730
  readonly 'canvas.tool.video': "Video";
733
731
  readonly 'canvas.tool.shapes': "Shapes";
@@ -825,7 +823,6 @@ export declare const CREATOR_CATALOGS: {
825
823
  readonly 'canvas.zoom.gridLabel': "Toggle grid";
826
824
  readonly 'canvas.zoom.panTitle': "Hand / Pan [H]";
827
825
  readonly 'canvas.zoom.panLabel': "Hand / pan tool";
828
- readonly 'canvas.zoom.panBanner': "Dragging the canvas";
829
826
  readonly 'canvas.zoom.outTitle': "Zoom Out [Ctrl/Cmd] + [\u2212]";
830
827
  readonly 'canvas.zoom.outLabel': "Zoom out";
831
828
  readonly 'canvas.zoom.inTitle': "Zoom In [Ctrl/Cmd] + [+]";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/creator",
3
- "version": "0.4.41",
3
+ "version": "0.4.42",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "peerDependencies": {