@widgetic/creator 0.4.17 → 0.4.18
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 +104 -12
- package/package.json +3 -3
package/dist/CreatorApp.svelte
CHANGED
|
@@ -4991,15 +4991,42 @@
|
|
|
4991
4991
|
}
|
|
4992
4992
|
}
|
|
4993
4993
|
|
|
4994
|
+
/**
|
|
4995
|
+
* The generated widget reads its slides from `contentItems`. On Create, the
|
|
4996
|
+
* composition overlay is skipped, and the canvas shape is a second iframe
|
|
4997
|
+
* that never received those items — so the preview stayed on "No content".
|
|
4998
|
+
*/
|
|
4999
|
+
function postContentItemsToPreviewFrames(widgetId: string): void {
|
|
5000
|
+
if (!widgetId) return;
|
|
5001
|
+
const ps = getPanelDisplayState(widgetId);
|
|
5002
|
+
let items = ps.liveContentItems || [];
|
|
5003
|
+
if (items.length === 0) {
|
|
5004
|
+
const schema = ps.compositionContentSchema;
|
|
5005
|
+
const schemaItems = schema?.contentItems ?? schema?.data?.contentItems;
|
|
5006
|
+
if (Array.isArray(schemaItems) && schemaItems.length > 0) {
|
|
5007
|
+
items = schemaItems;
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
if (!Array.isArray(items) || items.length === 0) return;
|
|
5011
|
+
const message = {
|
|
5012
|
+
type: 'widgetic:update',
|
|
5013
|
+
contentItems: flattenContentItemsForPreview(items),
|
|
5014
|
+
};
|
|
5015
|
+
getWidgetDetailsRef(widgetId)?.sendMessageToPreview(message);
|
|
5016
|
+
resolveLiveWidgetShapeIframe(widgetId)?.contentWindow?.postMessage(message, '*');
|
|
5017
|
+
}
|
|
5018
|
+
|
|
4994
5019
|
/** Push composition overlay to a specific panel preview iframe. */
|
|
4995
5020
|
function applyPanelCompositionToPreview(widgetId: string): void {
|
|
4996
5021
|
const panelRef = getWidgetDetailsRef(widgetId);
|
|
4997
|
-
if (!panelRef) return;
|
|
4998
5022
|
const step = widgetId === focusedPanelWidgetId ? widgetDetailsStep : 'create';
|
|
4999
5023
|
if (step === 'create') {
|
|
5000
|
-
//
|
|
5024
|
+
// Create shows the generated defaults, not a saved composition.
|
|
5025
|
+
// The slides still have to reach both preview iframes.
|
|
5026
|
+
postContentItemsToPreviewFrames(widgetId);
|
|
5001
5027
|
return;
|
|
5002
5028
|
}
|
|
5029
|
+
if (!panelRef) return;
|
|
5003
5030
|
const ps = getPanelDisplayState(widgetId);
|
|
5004
5031
|
if (Object.keys(ps.liveDesignValues).length > 0) {
|
|
5005
5032
|
panelRef.sendMessageToPreview({ type: 'widgetic:update', design: flattenDesignValuesForPreview(ps.liveDesignValues as Record<string, unknown>) });
|
|
@@ -5008,10 +5035,12 @@
|
|
|
5008
5035
|
panelRef.sendMessageToPreview({ type: 'widgetic:update', content: ps.liveContentValues });
|
|
5009
5036
|
}
|
|
5010
5037
|
if (ps.liveContentItems.length > 0) {
|
|
5011
|
-
|
|
5038
|
+
const contentItemsMessage = {
|
|
5012
5039
|
type: 'widgetic:update',
|
|
5013
5040
|
contentItems: flattenContentItemsForPreview(ps.liveContentItems),
|
|
5014
|
-
}
|
|
5041
|
+
};
|
|
5042
|
+
panelRef.sendMessageToPreview(contentItemsMessage);
|
|
5043
|
+
resolveLiveWidgetShapeIframe(widgetId)?.contentWindow?.postMessage(contentItemsMessage, '*');
|
|
5015
5044
|
}
|
|
5016
5045
|
}
|
|
5017
5046
|
|
|
@@ -6500,7 +6529,7 @@
|
|
|
6500
6529
|
try {
|
|
6501
6530
|
const { [widgetId]: _resolved, ...restResolved } = shapeHistoryResolvedByWidgetId;
|
|
6502
6531
|
shapeHistoryResolvedByWidgetId = restResolved;
|
|
6503
|
-
await loadPublishHistoryForPanel(widgetId, { silent: true });
|
|
6532
|
+
await loadPublishHistoryForPanel(widgetId, { silent: true, fresh: true });
|
|
6504
6533
|
void loadWidgetSchemas(widgetId, { force: true });
|
|
6505
6534
|
|
|
6506
6535
|
const panelRef = getWidgetDetailsRef(widgetId);
|
|
@@ -7892,6 +7921,25 @@
|
|
|
7892
7921
|
|
|
7893
7922
|
if (missingIds.length === 0) return;
|
|
7894
7923
|
|
|
7924
|
+
// Both start paths reach here together once the shared widget list arrives; the same ids are fetched once.
|
|
7925
|
+
const mergeKey = `${resolveHostCanvasId() ?? ''}:${[...missingIds].sort().join(',')}`;
|
|
7926
|
+
if (linkedWidgetsMerge?.key === mergeKey) {
|
|
7927
|
+
await linkedWidgetsMerge.done;
|
|
7928
|
+
return;
|
|
7929
|
+
}
|
|
7930
|
+
const done = fetchAndMergeLinkedWidgets(missingIds);
|
|
7931
|
+
linkedWidgetsMerge = { key: mergeKey, done };
|
|
7932
|
+
try {
|
|
7933
|
+
await done;
|
|
7934
|
+
} finally {
|
|
7935
|
+
if (linkedWidgetsMerge?.done === done) linkedWidgetsMerge = null;
|
|
7936
|
+
}
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
let linkedWidgetsMerge: { key: string; done: Promise<void> } | null = null;
|
|
7940
|
+
|
|
7941
|
+
async function fetchAndMergeLinkedWidgets(missingIds: string[]): Promise<void> {
|
|
7942
|
+
if (!widgetsClient) return;
|
|
7895
7943
|
// Scope merge to THIS canvas: a shape can linger on several canvases (legacy canvas
|
|
7896
7944
|
// duplication), but a widget belongs to exactly one. Merging foreign widgets is what
|
|
7897
7945
|
// made another canvas's widgets show up in this canvas's list/picker.
|
|
@@ -10884,7 +10932,7 @@ Requirements:
|
|
|
10884
10932
|
// Start the history request on this turn, before any timer. A stall in
|
|
10885
10933
|
// the timer then still shows up in the API log as this request.
|
|
10886
10934
|
if (generationWidgetId) {
|
|
10887
|
-
void loadPublishHistoryForPanel(generationWidgetId, { silent: true });
|
|
10935
|
+
void loadPublishHistoryForPanel(generationWidgetId, { silent: true, fresh: true });
|
|
10888
10936
|
}
|
|
10889
10937
|
setTimeout(() => {
|
|
10890
10938
|
setTimeout(() => {
|
|
@@ -10958,7 +11006,7 @@ Requirements:
|
|
|
10958
11006
|
const alignWidgetId = generationWidgetId;
|
|
10959
11007
|
const alignCommitSha = completedCommitSha;
|
|
10960
11008
|
const alignGeneratedVersion = (attempt: number) => {
|
|
10961
|
-
void loadPublishHistoryForPanel(alignWidgetId, { silent: true }).then(() => {
|
|
11009
|
+
void loadPublishHistoryForPanel(alignWidgetId, { silent: true, fresh: true }).then(() => {
|
|
10962
11010
|
// The refetch is authoritative, but a snapshot that raced the
|
|
10963
11011
|
// row's title (or an API row still missing it) gets the
|
|
10964
11012
|
// operation's label — the guard inside keeps a user rename.
|
|
@@ -11544,7 +11592,7 @@ Requirements:
|
|
|
11544
11592
|
// Creator always opens on the step the user/URL requested.
|
|
11545
11593
|
}
|
|
11546
11594
|
|
|
11547
|
-
void loadPublishHistoryForPanel(widgetId, { silent: true });
|
|
11595
|
+
void loadPublishHistoryForPanel(widgetId, { silent: true, fresh: true });
|
|
11548
11596
|
}
|
|
11549
11597
|
|
|
11550
11598
|
/**
|
|
@@ -11707,7 +11755,7 @@ Requirements:
|
|
|
11707
11755
|
publishedPanelRef?.invalidatePublishedArtifactCache?.();
|
|
11708
11756
|
await publishedPanelRef?.refreshPreview({ withRetry: true });
|
|
11709
11757
|
scheduleListThumbnailCapture(capturedWidgetId);
|
|
11710
|
-
await loadPublishHistory();
|
|
11758
|
+
await loadPublishHistory({ fresh: true });
|
|
11711
11759
|
void refreshTrialCounter();
|
|
11712
11760
|
} catch (previewErr) {
|
|
11713
11761
|
// The version is already live. A preview reload must not be reported as a failed publish.
|
|
@@ -11765,6 +11813,23 @@ Requirements:
|
|
|
11765
11813
|
|
|
11766
11814
|
let lastHarnessChatLine = '';
|
|
11767
11815
|
|
|
11816
|
+
// The canvas shape iframe loads on its own. When it says it is listening,
|
|
11817
|
+
// hand it the slide list. A message sent before that is dropped.
|
|
11818
|
+
onMount(() => {
|
|
11819
|
+
const onShapeWidgetReady = (event: MessageEvent) => {
|
|
11820
|
+
if (event.data?.type !== 'widgetic:ready') return;
|
|
11821
|
+
const searchRoot = getCreatorShadowRoot(creatorRootEl) ?? document;
|
|
11822
|
+
const frames = searchRoot.querySelectorAll('iframe.widget-shape-live-preview-iframe');
|
|
11823
|
+
for (const frame of frames) {
|
|
11824
|
+
if (!(frame instanceof HTMLIFrameElement) || event.source !== frame.contentWindow) continue;
|
|
11825
|
+
const widgetId = frame.dataset.widgetId;
|
|
11826
|
+
if (widgetId) postContentItemsToPreviewFrames(widgetId);
|
|
11827
|
+
}
|
|
11828
|
+
};
|
|
11829
|
+
window.addEventListener('message', onShapeWidgetReady);
|
|
11830
|
+
return () => window.removeEventListener('message', onShapeWidgetReady);
|
|
11831
|
+
});
|
|
11832
|
+
|
|
11768
11833
|
// Restore session on mount with expiration check
|
|
11769
11834
|
onMount(() => {
|
|
11770
11835
|
const googleFontsKey =
|
|
@@ -15115,11 +15180,38 @@ $: if ($dynamicWorkerPreviewStatus.widgetId && $dynamicWorkerPreviewStatus.previ
|
|
|
15115
15180
|
|
|
15116
15181
|
// ===================== Publish History =====================
|
|
15117
15182
|
|
|
15183
|
+
/**
|
|
15184
|
+
* Selection, the panel and the shape badge all ask for the same widget's history while the page opens; a caller that
|
|
15185
|
+
* comes while a read is running waits on it. After a publish or a generation, callers pass `fresh` to read again.
|
|
15186
|
+
*/
|
|
15187
|
+
const publishHistoryReadsInFlight = new Map<string, Promise<void>>();
|
|
15188
|
+
|
|
15118
15189
|
/**
|
|
15119
15190
|
* Loads publish history for a widget panel (background-safe).
|
|
15120
15191
|
*/
|
|
15121
|
-
async function loadPublishHistoryForPanel(widgetId: string, opts: { silent?: boolean } = {}) {
|
|
15192
|
+
async function loadPublishHistoryForPanel(widgetId: string, opts: { silent?: boolean; fresh?: boolean } = {}) {
|
|
15122
15193
|
if (!widgetId || !$userSession?.jwt) return;
|
|
15194
|
+
const showsLoading = !opts.silent && widgetId === selectedWidgetId;
|
|
15195
|
+
const inFlight = opts.fresh ? undefined : publishHistoryReadsInFlight.get(widgetId);
|
|
15196
|
+
if (inFlight) {
|
|
15197
|
+
if (showsLoading) isLoadingHistory = true;
|
|
15198
|
+
try {
|
|
15199
|
+
await inFlight;
|
|
15200
|
+
} finally {
|
|
15201
|
+
if (showsLoading) isLoadingHistory = false;
|
|
15202
|
+
}
|
|
15203
|
+
return;
|
|
15204
|
+
}
|
|
15205
|
+
const read = readPublishHistoryForPanel(widgetId, opts);
|
|
15206
|
+
publishHistoryReadsInFlight.set(widgetId, read);
|
|
15207
|
+
try {
|
|
15208
|
+
await read;
|
|
15209
|
+
} finally {
|
|
15210
|
+
if (publishHistoryReadsInFlight.get(widgetId) === read) publishHistoryReadsInFlight.delete(widgetId);
|
|
15211
|
+
}
|
|
15212
|
+
}
|
|
15213
|
+
|
|
15214
|
+
async function readPublishHistoryForPanel(widgetId: string, opts: { silent?: boolean } = {}) {
|
|
15123
15215
|
|
|
15124
15216
|
if (!opts.silent && widgetId === selectedWidgetId) {
|
|
15125
15217
|
isLoadingHistory = true;
|
|
@@ -15185,7 +15277,7 @@ async function loadPublishHistoryForPanel(widgetId: string, opts: { silent?: boo
|
|
|
15185
15277
|
* Loads publish history for the selected widget from the API.
|
|
15186
15278
|
* Called when the user expands the history panel, or silently on widget select.
|
|
15187
15279
|
*/
|
|
15188
|
-
async function loadPublishHistory(opts: { silent?: boolean } = {}) {
|
|
15280
|
+
async function loadPublishHistory(opts: { silent?: boolean; fresh?: boolean } = {}) {
|
|
15189
15281
|
if (!selectedWidgetId || !$userSession?.jwt) return;
|
|
15190
15282
|
await loadPublishHistoryForPanel(selectedWidgetId, opts);
|
|
15191
15283
|
}
|
|
@@ -15351,7 +15443,7 @@ function togglePublishHistory(triggerEl?: HTMLElement | null) {
|
|
|
15351
15443
|
|
|
15352
15444
|
/** Refresh history after a new publish */
|
|
15353
15445
|
$: if (lastPublishedVersion !== null && isHistoryOpen) {
|
|
15354
|
-
loadPublishHistory();
|
|
15446
|
+
loadPublishHistory({ fresh: true });
|
|
15355
15447
|
}
|
|
15356
15448
|
|
|
15357
15449
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/creator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.18",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@sveltejs/kit": "^2.20.0",
|
|
8
8
|
"@widgetic/api-sdk": "^1.0.23",
|
|
9
9
|
"@widgetic/cache-layer": "^0.1.2",
|
|
10
|
-
"@widgetic/canvas": "^0.5.
|
|
10
|
+
"@widgetic/canvas": "^0.5.27",
|
|
11
11
|
"@widgetic/chat": "^0.1.17",
|
|
12
12
|
"@widgetic/design-system": "^0.5.15",
|
|
13
13
|
"@widgetic/editor": "^4.0.10",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@types/node": "26.4.0",
|
|
75
75
|
"@widgetic/api-sdk": "^1.0.23",
|
|
76
76
|
"@widgetic/cache-layer": "^0.1.2",
|
|
77
|
-
"@widgetic/canvas": "^0.5.
|
|
77
|
+
"@widgetic/canvas": "^0.5.27",
|
|
78
78
|
"@widgetic/chat": "^0.1.17",
|
|
79
79
|
"@widgetic/design-system": "^0.5.15",
|
|
80
80
|
"@widgetic/dev-tools": "^0.3.0",
|