@widgetic/creator 0.4.5 → 0.4.6
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 +24 -2
- package/dist/components/VersionDropdownRow.svelte +17 -0
- package/dist/components/WidgetShapeLivePreviews.svelte +9 -1
- package/dist/i18n/language.d.ts +1 -1
- package/dist/i18n/messages.d.ts +1 -1
- package/dist/i18n/messages.js +1 -1
- package/dist/i18n/statusText.js +1 -1
- package/dist/utils/versionPreviewError.js +1 -1
- package/package.json +1 -1
package/dist/CreatorApp.svelte
CHANGED
|
@@ -10898,11 +10898,13 @@ Requirements:
|
|
|
10898
10898
|
return;
|
|
10899
10899
|
}
|
|
10900
10900
|
|
|
10901
|
-
// Handle rate limiting (429) — too many API requests in the time window
|
|
10901
|
+
// Handle rate limiting (429) — too many API requests in the time window.
|
|
10902
|
+
// A cost-budget 429 is the hourly generation/preview limit. It is not the short request window.
|
|
10902
10903
|
if (httpStatus === 429) {
|
|
10904
|
+
const hourlyBudget = await responseIsALimit(error.response);
|
|
10903
10905
|
// A visitor who used up the budget the partner gave them is told that, and not that the API is busy: a wait
|
|
10904
10906
|
// of half a minute would not help them. (The page is told by the limit middleware.)
|
|
10905
|
-
if (partnerMode &&
|
|
10907
|
+
if (partnerMode && hourlyBudget) {
|
|
10906
10908
|
console.warn('Widget Creator: the visitor reached their budget during code generation');
|
|
10907
10909
|
const limitMessage = await deriveApiErrorMessage(error, 'Usage limit exceeded');
|
|
10908
10910
|
patchCodegenUiState(generationWidgetId, {
|
|
@@ -10914,6 +10916,17 @@ Requirements:
|
|
|
10914
10916
|
pushCodegenFailureToChat(generationWidgetId, limitMessage);
|
|
10915
10917
|
return;
|
|
10916
10918
|
}
|
|
10919
|
+
if (hourlyBudget) {
|
|
10920
|
+
const hourlyMessage = $t('creator.preview.versionHourlyLimit');
|
|
10921
|
+
console.warn('Widget Creator: hourly generation budget reached');
|
|
10922
|
+
patchCodegenUiState(generationWidgetId, {
|
|
10923
|
+
generateCodeStatus: `⚠️ ${hourlyMessage}`,
|
|
10924
|
+
lastGenerationFailed: true,
|
|
10925
|
+
lastGenerationError: hourlyMessage,
|
|
10926
|
+
});
|
|
10927
|
+
showToast('warning', $t('creator.general.limitReached'), { description: hourlyMessage, duration: 8000 });
|
|
10928
|
+
return;
|
|
10929
|
+
}
|
|
10917
10930
|
console.warn('Widget Creator: Rate limited (429) during code generation');
|
|
10918
10931
|
patchCodegenUiState(generationWidgetId, {
|
|
10919
10932
|
generateCodeStatus: '⚠️ Rate limited — too many requests. Wait ~30s and retry.',
|
|
@@ -11572,6 +11585,15 @@ Requirements:
|
|
|
11572
11585
|
}
|
|
11573
11586
|
});
|
|
11574
11587
|
|
|
11588
|
+
// A click in the preview iframe does not reach this document, so the version list stays open.
|
|
11589
|
+
onMount(() => {
|
|
11590
|
+
const closeHistoryWhenPreviewTakesFocus = () => {
|
|
11591
|
+
if (isHistoryOpen) isHistoryOpen = false;
|
|
11592
|
+
};
|
|
11593
|
+
window.addEventListener('blur', closeHistoryWhenPreviewTakesFocus);
|
|
11594
|
+
return () => window.removeEventListener('blur', closeHistoryWhenPreviewTakesFocus);
|
|
11595
|
+
});
|
|
11596
|
+
|
|
11575
11597
|
// Register click-outside listener for canvas dropdown
|
|
11576
11598
|
onMount(() => {
|
|
11577
11599
|
window.addEventListener('click', handleCanvasDropdownOutsideClick);
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* it); LIVE sits in the action slot with the exact width of PUBLISH, so
|
|
9
9
|
* the right edge lines up across every row.
|
|
10
10
|
*/
|
|
11
|
+
import { tick } from 'svelte';
|
|
11
12
|
import HoverTooltip from './HoverTooltip.svelte';
|
|
12
13
|
import { useCreatorLanguage } from '../i18n/index.js';
|
|
13
14
|
|
|
@@ -66,6 +67,21 @@
|
|
|
66
67
|
let editingTitle = $state(false);
|
|
67
68
|
let titleDraft = $state('');
|
|
68
69
|
let titleInputEl: HTMLInputElement | null = $state(null);
|
|
70
|
+
let rowEl: HTMLDivElement | null = $state(null);
|
|
71
|
+
|
|
72
|
+
// Both menus open with the newest row at the top. Put the open version at the top of that window.
|
|
73
|
+
$effect(() => {
|
|
74
|
+
if (!selected || !rowEl) return;
|
|
75
|
+
const node = rowEl;
|
|
76
|
+
void tick().then(() => {
|
|
77
|
+
requestAnimationFrame(() => {
|
|
78
|
+
const scroller = node.closest('.widget-shape-version-scroll, .wc-version-history-scroll');
|
|
79
|
+
if (!(scroller instanceof HTMLElement)) return;
|
|
80
|
+
const rowTop = node.getBoundingClientRect().top - scroller.getBoundingClientRect().top + scroller.scrollTop;
|
|
81
|
+
scroller.scrollTop = Math.max(0, rowTop);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
69
85
|
|
|
70
86
|
function openTitleEditor(): void {
|
|
71
87
|
if (!editableTitle || renameDisabled) return;
|
|
@@ -94,6 +110,7 @@
|
|
|
94
110
|
</script>
|
|
95
111
|
|
|
96
112
|
<div
|
|
113
|
+
bind:this={rowEl}
|
|
97
114
|
class="version-dropdown-row flex items-center justify-between gap-2 rounded px-2 py-1.5 w-full text-[10px] cursor-pointer {selected ? 'bg-emerald-200 text-emerald-950' : 'text-gray-700 hover:bg-emerald-100'}"
|
|
98
115
|
role="option"
|
|
99
116
|
aria-selected={selected}
|
|
@@ -701,6 +701,13 @@
|
|
|
701
701
|
});
|
|
702
702
|
document.addEventListener('pointerdown', handleDocumentPointerDown, true);
|
|
703
703
|
document.addEventListener('keydown', handleDocumentKeydown);
|
|
704
|
+
// A click inside the preview iframe never reaches this document. The window blurs instead.
|
|
705
|
+
const closeVersionMenuWhenPreviewTakesFocus = () => {
|
|
706
|
+
if (!openVersionMenuWidgetId) return;
|
|
707
|
+
openVersionMenuWidgetId = null;
|
|
708
|
+
versionMenuBox = null;
|
|
709
|
+
};
|
|
710
|
+
window.addEventListener('blur', closeVersionMenuWhenPreviewTakesFocus);
|
|
704
711
|
const onShapePointerBlock = (event: Event) => {
|
|
705
712
|
const detail = (event as CustomEvent<{ widgetId?: string | null; active?: boolean }>).detail;
|
|
706
713
|
if (!detail) return;
|
|
@@ -714,6 +721,7 @@
|
|
|
714
721
|
coalescedReloadTimers.clear();
|
|
715
722
|
document.removeEventListener('pointerdown', handleDocumentPointerDown, true);
|
|
716
723
|
document.removeEventListener('keydown', handleDocumentKeydown);
|
|
724
|
+
window.removeEventListener('blur', closeVersionMenuWhenPreviewTakesFocus);
|
|
717
725
|
window.removeEventListener('widgetic:widget-shape-pointer-block', onShapePointerBlock);
|
|
718
726
|
};
|
|
719
727
|
});
|
|
@@ -982,7 +990,7 @@
|
|
|
982
990
|
{/if}
|
|
983
991
|
{#if previewState?.error && !previewState.loading}
|
|
984
992
|
<div class="widget-shape-preview-error pointer-events-auto absolute inset-0 flex flex-col items-center justify-center gap-2 overflow-auto bg-white p-4 text-center text-xs text-red-600 [scrollbar-color:rgba(0,0,0,0.2)_transparent]" role="alert">
|
|
985
|
-
<span>{errorLabel(previewState.error, $t)}</span>
|
|
993
|
+
<span class="widget-shape-preview-error-text whitespace-pre-line">{errorLabel(previewState.error, $t)}</span>
|
|
986
994
|
{#if onRetryPreview}
|
|
987
995
|
<button type="button" class="widget-shape-preview-retry pointer-events-auto cursor-pointer rounded border border-gray-300 bg-white px-3 py-1.5 text-gray-700 hover:bg-gray-100 focus:outline-none focus-visible:outline-none focus-visible:bg-gray-100"
|
|
988
996
|
onpointerdown={(event) => event.stopPropagation()}
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -263,7 +263,7 @@ export declare const CREATOR_CATALOGS: {
|
|
|
263
263
|
readonly 'creator.preview.rebuilt': "Preview rebuilt";
|
|
264
264
|
readonly 'creator.preview.versionHasCodeError': "This version has a code error.";
|
|
265
265
|
readonly 'creator.preview.versionCouldNotLoad': "Could not load this version. Please try again.";
|
|
266
|
-
readonly 'creator.preview.versionHourlyLimit': "Hourly limit reached for generations and version previews
|
|
266
|
+
readonly 'creator.preview.versionHourlyLimit': "Hourly limit reached for generations and version previews.\nWait about an hour, then try again.";
|
|
267
267
|
readonly 'creator.preview.recompiledIn': "Recompiled in {ms}ms — commit {commit}.";
|
|
268
268
|
readonly 'creator.preview.commitRefreshed': "Commit {commit}. Preview refreshed.";
|
|
269
269
|
readonly 'creator.preview.noValidPreviewAvailable': "No valid preview available";
|
package/dist/i18n/messages.d.ts
CHANGED
|
@@ -259,7 +259,7 @@ export declare const CREATOR_MESSAGES: {
|
|
|
259
259
|
readonly 'creator.preview.rebuilt': "Preview rebuilt";
|
|
260
260
|
readonly 'creator.preview.versionHasCodeError': "This version has a code error.";
|
|
261
261
|
readonly 'creator.preview.versionCouldNotLoad': "Could not load this version. Please try again.";
|
|
262
|
-
readonly 'creator.preview.versionHourlyLimit': "Hourly limit reached for generations and version previews
|
|
262
|
+
readonly 'creator.preview.versionHourlyLimit': "Hourly limit reached for generations and version previews.\nWait about an hour, then try again.";
|
|
263
263
|
readonly 'creator.preview.recompiledIn': "Recompiled in {ms}ms — commit {commit}.";
|
|
264
264
|
readonly 'creator.preview.commitRefreshed': "Commit {commit}. Preview refreshed.";
|
|
265
265
|
readonly 'creator.preview.noValidPreviewAvailable': "No valid preview available";
|
package/dist/i18n/messages.js
CHANGED
|
@@ -267,7 +267,7 @@ export const CREATOR_MESSAGES = {
|
|
|
267
267
|
'creator.preview.rebuilt': 'Preview rebuilt',
|
|
268
268
|
'creator.preview.versionHasCodeError': 'This version has a code error.',
|
|
269
269
|
'creator.preview.versionCouldNotLoad': 'Could not load this version. Please try again.',
|
|
270
|
-
'creator.preview.versionHourlyLimit': 'Hourly limit reached for generations and version previews
|
|
270
|
+
'creator.preview.versionHourlyLimit': 'Hourly limit reached for generations and version previews.\nWait about an hour, then try again.',
|
|
271
271
|
'creator.preview.recompiledIn': 'Recompiled in {ms}ms — commit {commit}.',
|
|
272
272
|
'creator.preview.commitRefreshed': 'Commit {commit}. Preview refreshed.',
|
|
273
273
|
'creator.preview.noValidPreviewAvailable': 'No valid preview available',
|
package/dist/i18n/statusText.js
CHANGED
|
@@ -28,7 +28,7 @@ const KNOWN_TEXTS = new Map([
|
|
|
28
28
|
// The two lines of utils/versionPreviewError.js (a JavaScript file, which the node tests of the creator read)
|
|
29
29
|
['This version has a code error.', (t) => t('creator.preview.versionHasCodeError')],
|
|
30
30
|
['Could not load this version. Please try again.', (t) => t('creator.preview.versionCouldNotLoad')],
|
|
31
|
-
['Hourly limit reached for generations and version previews
|
|
31
|
+
['Hourly limit reached for generations and version previews.\nWait about an hour, then try again.', (t) => t('creator.preview.versionHourlyLimit')],
|
|
32
32
|
['Code was not saved to the repository. Retry saves it and records a version.', (t) => t('creator.codegen.codeWasNotSavedToTheRepository')],
|
|
33
33
|
['Code saved — building preview…', (t) => t('creator.status.savedBuildingPreview')],
|
|
34
34
|
['Code saved — loading preview…', (t) => t('creator.status.savedLoadingPreview')],
|
|
@@ -14,7 +14,7 @@ export async function parseVersionPreviewError(error) {
|
|
|
14
14
|
message: kind === 'compile'
|
|
15
15
|
? 'This version has a code error.'
|
|
16
16
|
: hourlyLimit
|
|
17
|
-
? 'Hourly limit reached for generations and version previews
|
|
17
|
+
? 'Hourly limit reached for generations and version previews.\nWait about an hour, then try again.'
|
|
18
18
|
: status === 429
|
|
19
19
|
? 'Rate limited — too many requests. Wait ~30s and retry.'
|
|
20
20
|
: 'Could not load this version. Please try again.',
|