@widgetic/creator 0.4.1 → 0.4.2
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 +50 -35
- package/package.json +1 -1
package/dist/CreatorApp.svelte
CHANGED
|
@@ -6732,6 +6732,29 @@
|
|
|
6732
6732
|
let canvasRowDeferred = false;
|
|
6733
6733
|
let canvasRowCreatePromise: Promise<string | null> | null = null;
|
|
6734
6734
|
|
|
6735
|
+
const untitledCanvasBaseName = 'Untitled Widget';
|
|
6736
|
+
|
|
6737
|
+
function nextUntitledCanvasName(existingNames: string[]): string {
|
|
6738
|
+
const names = new Set(existingNames.map((name) => (name || '').trim()).filter(Boolean));
|
|
6739
|
+
if (!names.has(untitledCanvasBaseName)) return untitledCanvasBaseName;
|
|
6740
|
+
let highest = 1;
|
|
6741
|
+
for (const name of names) {
|
|
6742
|
+
const match = name.match(/^Untitled Widget (\d+)$/);
|
|
6743
|
+
if (!match) continue;
|
|
6744
|
+
const value = Number(match[1]);
|
|
6745
|
+
if (Number.isFinite(value) && value > highest) highest = value;
|
|
6746
|
+
}
|
|
6747
|
+
return `${untitledCanvasBaseName} ${highest + 1}`;
|
|
6748
|
+
}
|
|
6749
|
+
|
|
6750
|
+
function canvasCreateRequest(persistenceKey: string) {
|
|
6751
|
+
const trimmedProjectId = typeof projectId === 'string' ? projectId.trim() : '';
|
|
6752
|
+
return {
|
|
6753
|
+
persistenceKey,
|
|
6754
|
+
...(trimmedProjectId ? { projectId: trimmedProjectId } : {})
|
|
6755
|
+
};
|
|
6756
|
+
}
|
|
6757
|
+
|
|
6735
6758
|
async function ensureCanvasRowForFirstEdit(): Promise<string | null> {
|
|
6736
6759
|
const existingId = typeof canvasId === 'string' ? canvasId.trim() : '';
|
|
6737
6760
|
if (existingId) return existingId;
|
|
@@ -6742,15 +6765,9 @@
|
|
|
6742
6765
|
return null;
|
|
6743
6766
|
}
|
|
6744
6767
|
try {
|
|
6745
|
-
const
|
|
6746
|
-
let canvasIndex = userCanvases.length + 1;
|
|
6747
|
-
let newName = `Canvas ${canvasIndex}`;
|
|
6748
|
-
while (usedNames.has(newName)) {
|
|
6749
|
-
canvasIndex += 1;
|
|
6750
|
-
newName = `Canvas ${canvasIndex}`;
|
|
6751
|
-
}
|
|
6768
|
+
const newName = nextUntitledCanvasName(userCanvases.map((c) => c.name || ''));
|
|
6752
6769
|
const createdRaw = await canvasesClient.createCanvas({
|
|
6753
|
-
createCanvasRequest:
|
|
6770
|
+
createCanvasRequest: canvasCreateRequest(newName)
|
|
6754
6771
|
});
|
|
6755
6772
|
const createdId = unwrapCreatedCanvasId(createdRaw);
|
|
6756
6773
|
if (!createdId) {
|
|
@@ -6790,17 +6807,9 @@
|
|
|
6790
6807
|
}
|
|
6791
6808
|
|
|
6792
6809
|
try {
|
|
6793
|
-
|
|
6794
|
-
// canvases indistinguishable and contributed to cross-canvas widget mix-ups.
|
|
6795
|
-
const usedNames = new Set(userCanvases.map((c) => (c.name || '').trim()).filter(Boolean));
|
|
6796
|
-
let canvasIndex = userCanvases.length + 1;
|
|
6797
|
-
let newName = `Canvas ${canvasIndex}`;
|
|
6798
|
-
while (usedNames.has(newName)) {
|
|
6799
|
-
canvasIndex += 1;
|
|
6800
|
-
newName = `Canvas ${canvasIndex}`;
|
|
6801
|
-
}
|
|
6810
|
+
const newName = nextUntitledCanvasName(userCanvases.map((c) => c.name || ''));
|
|
6802
6811
|
const createdRaw = await canvasesClient.createCanvas({
|
|
6803
|
-
createCanvasRequest:
|
|
6812
|
+
createCanvasRequest: canvasCreateRequest(newName)
|
|
6804
6813
|
});
|
|
6805
6814
|
const createdId = unwrapCreatedCanvasId(createdRaw);
|
|
6806
6815
|
// console.log('[WidgetCreator] New canvas created:', createdId, newName, createdRaw);
|
|
@@ -10410,38 +10419,42 @@ Requirements:
|
|
|
10410
10419
|
stampWidgetRepositoryId(generationWidgetId, completedRepoId);
|
|
10411
10420
|
}
|
|
10412
10421
|
|
|
10422
|
+
const commitShort = completedCommitSha ? completedCommitSha.substring(0, 7) : '';
|
|
10423
|
+
const savedStatus = !completedCommitSha
|
|
10424
|
+
? 'Code was not saved to the repository. Retry saves it and records a version.'
|
|
10425
|
+
: completedPreviewBuildErr
|
|
10426
|
+
? `Code saved (${commitShort}) — building preview…`
|
|
10427
|
+
: `Code saved (${commitShort}) — loading preview…`;
|
|
10413
10428
|
patchCodegenUiState(generationWidgetId, {
|
|
10414
10429
|
hasGeneratedCode: true,
|
|
10415
10430
|
...(completedCommitSha ? { lastCommitId: completedCommitSha } : {}),
|
|
10416
|
-
lastGenerationFailed:
|
|
10431
|
+
lastGenerationFailed: !completedCommitSha,
|
|
10417
10432
|
lastGenerationError: completedPreviewBuildErr,
|
|
10418
|
-
generateCodeStatus:
|
|
10419
|
-
? `Code saved${completedCommitSha ? ` (${completedCommitSha.substring(0, 7)})` : ''} — building preview…`
|
|
10420
|
-
: `Code saved${completedCommitSha ? ` (${completedCommitSha.substring(0, 7)})` : ''} — loading preview…`,
|
|
10433
|
+
generateCodeStatus: savedStatus,
|
|
10421
10434
|
});
|
|
10422
10435
|
|
|
10423
|
-
const commitShort = completedCommitSha ? completedCommitSha.substring(0, 7) : '';
|
|
10424
10436
|
if (!completedCached) {
|
|
10425
|
-
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
10426
|
-
completedPreviewBuildErr
|
|
10427
|
-
? `Code saved${commitShort ? ` (${commitShort})` : ''} — building preview…`
|
|
10428
|
-
: `Code saved${commitShort ? ` (${commitShort})` : ''} — loading preview…`,
|
|
10429
|
-
);
|
|
10437
|
+
panelChat?.updateLatestCodegenStatusMessage?.(savedStatus);
|
|
10430
10438
|
}
|
|
10431
10439
|
|
|
10432
10440
|
// console.log('Widget Creator: Code generation operation completed for widget', generationWidgetId.substring(0, 8), ':', op);
|
|
10433
10441
|
|
|
10434
|
-
if (completedPreviewBuildErr) {
|
|
10442
|
+
if (completedPreviewBuildErr && completedCommitSha) {
|
|
10435
10443
|
generationPanelRef?.setPreviewBuildError(null);
|
|
10436
10444
|
generationPanelRef?.setPreviewLoadingState(true);
|
|
10437
10445
|
panelChat?.addAssistantMessage(
|
|
10438
|
-
`Code saved
|
|
10446
|
+
`Code saved (Commit: ${commitShort}), but preview build failed:\n${completedPreviewBuildErr}\n\nRebuilding preview…`,
|
|
10439
10447
|
true
|
|
10440
10448
|
);
|
|
10441
10449
|
showToast('warning', $t('creator.codegen.codeSavedRebuildingPreview'), {
|
|
10442
10450
|
description: completedPreviewBuildErr.length > 120 ? `${completedPreviewBuildErr.slice(0, 120)}…` : completedPreviewBuildErr,
|
|
10443
10451
|
duration: 8000
|
|
10444
10452
|
});
|
|
10453
|
+
} else if (!completedCommitSha) {
|
|
10454
|
+
showToast('warning', 'Code was not saved', {
|
|
10455
|
+
description: 'Retry saves it and records a version.',
|
|
10456
|
+
duration: 8000
|
|
10457
|
+
});
|
|
10445
10458
|
} else {
|
|
10446
10459
|
showToast(
|
|
10447
10460
|
'success',
|
|
@@ -10468,14 +10481,16 @@ Requirements:
|
|
|
10468
10481
|
// generation just happened.
|
|
10469
10482
|
panelChat?.addAssistantMessage(
|
|
10470
10483
|
cachedChatSummary ??
|
|
10471
|
-
(
|
|
10472
|
-
?
|
|
10473
|
-
:
|
|
10484
|
+
(!completedCommitSha
|
|
10485
|
+
? 'Code was not saved to the repository. Retry saves it and records a version.'
|
|
10486
|
+
: completedPreviewBuildErr
|
|
10487
|
+
? `Code saved (Commit: ${commitShort}), but preview build failed:\n${completedPreviewBuildErr}\n\nRebuilding preview…`
|
|
10488
|
+
: `Code generation completed! Commit: ${commitShort}\nPreview is loading…`),
|
|
10474
10489
|
true
|
|
10475
10490
|
);
|
|
10476
|
-
if (!completedPreviewBuildErr && !completedCached) {
|
|
10491
|
+
if (!completedPreviewBuildErr && !completedCached && completedCommitSha) {
|
|
10477
10492
|
panelChat?.updateLatestCodegenStatusMessage?.(
|
|
10478
|
-
`Code generation completed
|
|
10493
|
+
`Code generation completed! Commit: ${commitShort}\nPreview is loading…`,
|
|
10479
10494
|
);
|
|
10480
10495
|
}
|
|
10481
10496
|
|