@widgetic/creator 0.4.37 → 0.4.39
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 +268 -30
- package/dist/CreatorApp.svelte.d.ts +11 -0
- package/dist/creator-types.d.ts +48 -0
- package/dist/host/creatorHost.d.ts +7 -0
- package/dist/host/creatorHost.js +9 -0
- package/dist/host/hostControls.d.ts +94 -0
- package/dist/host/hostControls.js +121 -0
- package/dist/i18n/language.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/utils/serialQueue.d.ts +24 -0
- package/dist/utils/serialQueue.js +25 -0
- package/dist/utils/versionRatings.d.ts +65 -0
- package/dist/utils/versionRatings.js +97 -0
- package/package.json +5 -5
package/dist/CreatorApp.svelte
CHANGED
|
@@ -194,6 +194,13 @@
|
|
|
194
194
|
type OperationSnapshot
|
|
195
195
|
} from './utils/generationSharing.js';
|
|
196
196
|
import { failureNoticeChanges } from './utils/failureNotice.js';
|
|
197
|
+
import {
|
|
198
|
+
loadRememberedVersionRatings,
|
|
199
|
+
rateVersionThroughApi,
|
|
200
|
+
rememberVersionRating,
|
|
201
|
+
saveRememberedVersionRatings,
|
|
202
|
+
type VersionRating
|
|
203
|
+
} from './utils/versionRatings.js';
|
|
197
204
|
import { generationVersionAndDocumentFields } from './utils/generationRequestFields.js';
|
|
198
205
|
import {
|
|
199
206
|
generationRefusalText,
|
|
@@ -227,6 +234,7 @@
|
|
|
227
234
|
mayUseAddressBar,
|
|
228
235
|
mayShowAccountBilling,
|
|
229
236
|
maySuggestWidgetName,
|
|
237
|
+
mayRateVersions,
|
|
230
238
|
mayListenToSiteEvents,
|
|
231
239
|
announceToSite,
|
|
232
240
|
eventIsFromCreator,
|
|
@@ -240,6 +248,14 @@
|
|
|
240
248
|
reportCanvasUnavailable
|
|
241
249
|
} from './host/creatorHost.js';
|
|
242
250
|
import { answerMayBeALimit, createLimitReporter, responseIsALimit } from './host/limitRefusal.js';
|
|
251
|
+
import {
|
|
252
|
+
createPublishStateReporter,
|
|
253
|
+
limitRefusalNeedsNoToast,
|
|
254
|
+
normalizeInitialMessage,
|
|
255
|
+
normalizeLimitNotices,
|
|
256
|
+
publishTargetOf
|
|
257
|
+
} from './host/hostControls.js';
|
|
258
|
+
import { createSerialQueue } from './utils/serialQueue.js';
|
|
243
259
|
|
|
244
260
|
function resolveCreatorWorkflowStep(
|
|
245
261
|
step?: CreatorAppProps['initialStep'] | 'create' | 'edit' | 'embed' | null
|
|
@@ -264,6 +280,24 @@
|
|
|
264
280
|
export let initialPrompt: CreatorAppProps['initialPrompt'] = null;
|
|
265
281
|
/** The initial prompt was put in the input; later draft restores leave the person's own text alone. */
|
|
266
282
|
let appliedInitialPrompt = false;
|
|
283
|
+
/** Words for the chat of a new widget and whether to send them (see `CreatorAppProps.initialMessage`). Used once. */
|
|
284
|
+
export let initialMessage: CreatorAppProps['initialMessage'] = null;
|
|
285
|
+
/** The host's message was put in the input (and sent, when asked); later draft restores leave the person's text alone. */
|
|
286
|
+
let appliedInitialMessage = false;
|
|
287
|
+
/** Where the canvas's tool bar stands along the bottom edge (see `CreatorAppProps.toolbarPosition`). */
|
|
288
|
+
export let toolbarPosition: CreatorAppProps['toolbarPosition'] = undefined;
|
|
289
|
+
/** Whether the canvas shows its Save button (see `CreatorAppProps.showSaveButton`): the site and the standalone creator do. */
|
|
290
|
+
export let showSaveButton: CreatorAppProps['showSaveButton'] = true;
|
|
291
|
+
/** How a refusal because of a limit is told (see `CreatorAppProps.limitNotices`). */
|
|
292
|
+
export let limitNotices: CreatorAppProps['limitNotices'] = 'all';
|
|
293
|
+
$: limitNoticeMode = normalizeLimitNotices(limitNotices);
|
|
294
|
+
/** What Publish would do now, for the host that draws its own button (see `CreatorAppProps.onPublishStateChanged`). */
|
|
295
|
+
export let onPublishStateChanged: CreatorAppProps['onPublishStateChanged'] = undefined;
|
|
296
|
+
/**
|
|
297
|
+
* How long the person can keep changing the canvas before it is saved anyway. The canvas waits for a quiet moment
|
|
298
|
+
* (`autosaveDelayMs`) so the API is not asked after every stroke; this is the most that waiting may take.
|
|
299
|
+
*/
|
|
300
|
+
const CANVAS_AUTOSAVE_MAX_WAIT_MS = 15000;
|
|
267
301
|
export let apiUrl: CreatorAppProps['apiUrl'] = null;
|
|
268
302
|
export let widgetBuilderUrl: CreatorAppProps['widgetBuilderUrl'] = null;
|
|
269
303
|
export let initialDebugMode: CreatorAppProps['initialDebugMode'] = undefined;
|
|
@@ -495,11 +529,23 @@
|
|
|
495
529
|
void applyHostWidgetName(detail.widgetId, detail.name);
|
|
496
530
|
}
|
|
497
531
|
|
|
532
|
+
/**
|
|
533
|
+
* Tells the page's `onPublishStateChanged` what Publish would do, once per change (the state is worked out again on every
|
|
534
|
+
* change of a panel). A handler that throws does not reach the creator.
|
|
535
|
+
*/
|
|
536
|
+
const publishStateReporter = createPublishStateReporter((state) => {
|
|
537
|
+
try {
|
|
538
|
+
onPublishStateChanged?.(state);
|
|
539
|
+
} catch (error) {
|
|
540
|
+
console.error(`[CreatorApp] The page's onPublishStateChanged handler threw:`, error);
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
|
|
498
544
|
let lastAnnouncedPublishState = '';
|
|
499
545
|
$: if (embedded && typeof window !== 'undefined') {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
546
|
+
// The widget the header's Publish speaks for: `publish()` below asks the same rule, so the button that looks
|
|
547
|
+
// ready and the publish it runs are about the same widget.
|
|
548
|
+
const targetId = publishTargetOf(focusedPanelWidgetId, canvasPrimaryWidgetId, isDraftConvertId);
|
|
503
549
|
const generatingMark = targetId ? !!generatingWidgetIds[targetId] : false;
|
|
504
550
|
const gate = targetId ? getPublishGateForPanel(targetId) : null;
|
|
505
551
|
const canPublish = !!gate && !gate.disabled;
|
|
@@ -518,6 +564,14 @@
|
|
|
518
564
|
unpublished,
|
|
519
565
|
});
|
|
520
566
|
}
|
|
567
|
+
// The page that draws its own Publish button (a partner's page has no header of the site's to hear the event).
|
|
568
|
+
publishStateReporter.note({
|
|
569
|
+
widgetId: targetId || null,
|
|
570
|
+
canPublish,
|
|
571
|
+
publishing: isPublishing && (!publishingWidgetId || publishingWidgetId === targetId),
|
|
572
|
+
label: unpublished ? $t('creator.publish.publishChanges') : label,
|
|
573
|
+
unpublished,
|
|
574
|
+
});
|
|
521
575
|
}
|
|
522
576
|
|
|
523
577
|
function handleHostRequestPublishEvent(): void {
|
|
@@ -530,6 +584,55 @@
|
|
|
530
584
|
runPublishForPanel(targetId);
|
|
531
585
|
}
|
|
532
586
|
|
|
587
|
+
// ===================== Controls the host can call on the component =====================
|
|
588
|
+
//
|
|
589
|
+
// A page that draws its own header around the creator (the Shopify app: a Back arrow, the name of the widget, a Publish
|
|
590
|
+
// button) calls these on the component (`bind:this`, or the module's methods). The Widgetic site does the same things
|
|
591
|
+
// through the `widgetic:host-*` events above, which a partner's page never gets (see `mayListenToSiteEvents`).
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Presses Publish for the widget the header's Publish speaks for (the rule that works out the state the page is told, see
|
|
595
|
+
* `publishTargetOf`). Resolves when the request is over. The page learns how it went from `onPublishComplete` and
|
|
596
|
+
* `onPublishStateChanged`; a refusal is the creator's own toast, never a throw into the page.
|
|
597
|
+
*/
|
|
598
|
+
export async function publish(): Promise<void> {
|
|
599
|
+
const targetId = publishTargetOf(focusedPanelWidgetId, canvasPrimaryWidgetId, isDraftConvertId);
|
|
600
|
+
if (!targetId) {
|
|
601
|
+
console.warn('[CreatorApp] Host publish ignored: there is no widget to publish yet');
|
|
602
|
+
showToast('error', $t('creator.publish.cannotPublish'), { description: $t('creator.widget.noWidgetSelected') });
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
try {
|
|
606
|
+
await runPublishForPanel(targetId);
|
|
607
|
+
} catch (error) {
|
|
608
|
+
console.error('[CreatorApp] Host publish failed:', error);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/**
|
|
613
|
+
* Saves what the person changed on the canvas now, without waiting for the quiet moment, and resolves once the server has
|
|
614
|
+
* it (the saves already on their way are waited for too). A page that is about to take the person away from the creator
|
|
615
|
+
* (its Back arrow) calls this first. Never rejects: a save that fails stays unsaved on the canvas, and the copy kept in the
|
|
616
|
+
* browser is not lost (see `handleCanvasAutoSave`).
|
|
617
|
+
*/
|
|
618
|
+
export async function flush(): Promise<void> {
|
|
619
|
+
try {
|
|
620
|
+
await canvasRef?.flushAutosave?.();
|
|
621
|
+
await canvasSaveQueue.whenIdle();
|
|
622
|
+
} catch (error) {
|
|
623
|
+
console.warn('[CreatorApp] Host flush failed:', error);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Renames a widget the way the site's header does: the name changes on the canvas and in the creator's panels at once,
|
|
629
|
+
* and is saved to the API. `widgetId` names the widget (the page knows it from `onWidgetRenamed`); without it the widget
|
|
630
|
+
* of the panel the person is on is renamed.
|
|
631
|
+
*/
|
|
632
|
+
export async function setWidgetName(name: string, widgetId?: string | null): Promise<void> {
|
|
633
|
+
await applyHostWidgetName(widgetId, name);
|
|
634
|
+
}
|
|
635
|
+
|
|
533
636
|
let className = '';
|
|
534
637
|
export { className as class };
|
|
535
638
|
export let style = '';
|
|
@@ -3498,6 +3601,32 @@
|
|
|
3498
3601
|
/** One restore at a time. A second click while GitLab is still answering used to be told a generation was running. */
|
|
3499
3602
|
let _restoreCheckpointInFlight = false;
|
|
3500
3603
|
|
|
3604
|
+
/**
|
|
3605
|
+
* The thumbs the person gave to versions, by the id of the message that announced the version. The API keeps the word for Widget
|
|
3606
|
+
* Lessons (what the code generator learns across people) but has no call that lists them, so the creator remembers them and hands
|
|
3607
|
+
* them back to the chat (`versionRatings`) when it opens again. In a partner's page the storage is memory, and no thumbs is offered.
|
|
3608
|
+
*/
|
|
3609
|
+
let versionRatingsByMessageId: Record<string, VersionRating> = loadRememberedVersionRatings();
|
|
3610
|
+
|
|
3611
|
+
/**
|
|
3612
|
+
* A thumbs the person pressed next to a version in the chat: tells the API, then remembers it. It throws when the API could not be
|
|
3613
|
+
* told, and the chat then puts the thumbs back as it was (nothing is remembered). The same conversation and message ids the chat
|
|
3614
|
+
* lists are the ones the API knows: a version is the saved message that announced a commit.
|
|
3615
|
+
*/
|
|
3616
|
+
async function handleRateVersion(conversationId: string, messageId: string, rating: VersionRating): Promise<void> {
|
|
3617
|
+
if (!messagesClient || !conversationId || isLocalOnlyConversationId(conversationId)) {
|
|
3618
|
+
console.warn('[Chat→Backend] A version cannot be rated before its conversation is saved', { conversationId, messageId });
|
|
3619
|
+
throw new Error('The conversation of this version is not saved yet');
|
|
3620
|
+
}
|
|
3621
|
+
const outcome = await rateVersionThroughApi(messagesClient, { conversationId, messageId, rating });
|
|
3622
|
+
if (outcome.recorded === false) {
|
|
3623
|
+
// Not a failure: the version has no trace to attach the word to (it is older than the tracing), or the learning is off.
|
|
3624
|
+
console.debug('[Chat→Backend] The API did not keep the thumbs', { messageId, rating, reason: outcome.reason });
|
|
3625
|
+
}
|
|
3626
|
+
versionRatingsByMessageId = rememberVersionRating(versionRatingsByMessageId, messageId, rating);
|
|
3627
|
+
saveRememberedVersionRatings(versionRatingsByMessageId);
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3501
3630
|
/** Restore conversation to a checkpoint message via backend (deletes messages + git rollback) */
|
|
3502
3631
|
async function handleRestoreCheckpoint(
|
|
3503
3632
|
conversationId: string,
|
|
@@ -9952,6 +10081,16 @@
|
|
|
9952
10081
|
if (chatDraftRestoredForWidgetId === selectedWidgetId) return;
|
|
9953
10082
|
chatDraftRestoredForWidgetId = selectedWidgetId;
|
|
9954
10083
|
|
|
10084
|
+
// The host's own message (`initialMessage`), when it has one that can be used and has not been used yet.
|
|
10085
|
+
const hostInitialMessage = appliedInitialMessage ? null : normalizeInitialMessage(initialMessage);
|
|
10086
|
+
if (initialMessage && !appliedInitialMessage && !hostInitialMessage) {
|
|
10087
|
+
console.warn('[CreatorApp] The host\'s initialMessage is ignored: it needs `text` that is not empty and not over 4000 characters, and `attachments`, when it has any, must be at most 5 PNG, JPEG, WebP or GIF files of at most 10 MB each');
|
|
10088
|
+
}
|
|
10089
|
+
/** Words to send once the draft is restored (the host asked for `send`); sending inside the restore would be undone by it. */
|
|
10090
|
+
let messageToSendAfterRestore: string | null = null;
|
|
10091
|
+
/** The pictures of the host's message: sent with its words, or put in the input beside them (the host did not ask for `send`). */
|
|
10092
|
+
let hostPictures: File[] = [];
|
|
10093
|
+
|
|
9955
10094
|
suppressChatDraftSync = true;
|
|
9956
10095
|
try {
|
|
9957
10096
|
if (pendingChatDraftText) {
|
|
@@ -9959,6 +10098,13 @@
|
|
|
9959
10098
|
if (promptImages.length > 0) {
|
|
9960
10099
|
chatMethods.restoreAttachmentsFromDataUrls?.(promptImages);
|
|
9961
10100
|
}
|
|
10101
|
+
} else if (hostInitialMessage && !appliedInitialMessage) {
|
|
10102
|
+
// The host opened a new widget with a message for it (a link to replicate): it goes into the input first, so
|
|
10103
|
+
// a person whose message could not be sent still has it, and is sent after the restore when the host asked.
|
|
10104
|
+
appliedInitialMessage = true;
|
|
10105
|
+
chatMethods.setDraftText?.(hostInitialMessage.text);
|
|
10106
|
+
hostPictures = hostInitialMessage.attachments;
|
|
10107
|
+
if (hostInitialMessage.send) messageToSendAfterRestore = hostInitialMessage.text;
|
|
9962
10108
|
} else if (!appliedInitialPrompt && typeof initialPrompt === 'string' && initialPrompt.trim()) {
|
|
9963
10109
|
// The host opened a new widget with words already in the chat (a Figma link from the Design page):
|
|
9964
10110
|
// put them in the input once, for the person to read and send. Never sent by the creator itself.
|
|
@@ -9973,6 +10119,59 @@
|
|
|
9973
10119
|
} finally {
|
|
9974
10120
|
suppressChatDraftSync = false;
|
|
9975
10121
|
}
|
|
10122
|
+
|
|
10123
|
+
if (messageToSendAfterRestore) {
|
|
10124
|
+
// A turn later: the restore above is finished and the chat has its input in place, as it has when a person sends.
|
|
10125
|
+
// The chat that is ready now is the one that sends, whichever panel the person is on by then.
|
|
10126
|
+
const wordsToSend = messageToSendAfterRestore;
|
|
10127
|
+
const picturesToSend = hostPictures;
|
|
10128
|
+
const chatToSendFrom = chatMethods;
|
|
10129
|
+
setTimeout(() => void sendInitialMessageFromHost(wordsToSend, picturesToSend, chatToSendFrom), 0);
|
|
10130
|
+
} else if (hostPictures.length > 0) {
|
|
10131
|
+
// Not sent: the pictures wait in the input beside the words, for the person to look at and send.
|
|
10132
|
+
void putHostPicturesInInput(hostPictures, chatMethods);
|
|
10133
|
+
}
|
|
10134
|
+
}
|
|
10135
|
+
|
|
10136
|
+
/**
|
|
10137
|
+
* Sends the host's `initialMessage` through the chat's own `sendMessage`, the function the chat's Enter key calls, so the
|
|
10138
|
+
* message goes the way a typed one does (the widget is made, the generation starts). The pictures go as the files the
|
|
10139
|
+
* person would have attached: the chat shows them in the message and the builder looks at them. A failure is logged and
|
|
10140
|
+
* leaves the words in the input, where the person can send them.
|
|
10141
|
+
*/
|
|
10142
|
+
async function sendInitialMessageFromHost(text: string, pictures: File[], methods: typeof chatMethods): Promise<void> {
|
|
10143
|
+
if (!methods?.sendMessage) {
|
|
10144
|
+
console.warn('[CreatorApp] The host\'s first message stays in the input: the chat cannot send yet');
|
|
10145
|
+
return;
|
|
10146
|
+
}
|
|
10147
|
+
try {
|
|
10148
|
+
if (pictures.length > 0) {
|
|
10149
|
+
await methods.sendMessage(text, pictures);
|
|
10150
|
+
} else {
|
|
10151
|
+
await methods.sendMessage(text);
|
|
10152
|
+
}
|
|
10153
|
+
} catch (error) {
|
|
10154
|
+
console.error('[CreatorApp] The host\'s first message could not be sent; it stays in the input:', error);
|
|
10155
|
+
}
|
|
10156
|
+
}
|
|
10157
|
+
|
|
10158
|
+
/**
|
|
10159
|
+
* Puts the pictures of the host's `initialMessage` in the chat's input, beside its words, as if the person had attached
|
|
10160
|
+
* them: each is read as an image and handed to the chat's own `addImageAttachment`. A picture that cannot be read is
|
|
10161
|
+
* logged and left out; the others still go in.
|
|
10162
|
+
*/
|
|
10163
|
+
async function putHostPicturesInInput(pictures: File[], methods: typeof chatMethods): Promise<void> {
|
|
10164
|
+
if (!methods?.addImageAttachment) {
|
|
10165
|
+
console.warn('[CreatorApp] The host\'s pictures are left out: the chat cannot take an attachment yet');
|
|
10166
|
+
return;
|
|
10167
|
+
}
|
|
10168
|
+
for (const picture of pictures) {
|
|
10169
|
+
try {
|
|
10170
|
+
methods.addImageAttachment(await fileToBase64(picture), picture.name || 'attached-image.png');
|
|
10171
|
+
} catch (error) {
|
|
10172
|
+
console.error('[CreatorApp] A picture of the host\'s message could not be read; it is left out:', error);
|
|
10173
|
+
}
|
|
10174
|
+
}
|
|
9976
10175
|
}
|
|
9977
10176
|
|
|
9978
10177
|
function handleChatReady(methods: NonNullable<typeof chatMethods>, widgetId?: string | null) {
|
|
@@ -11946,7 +12145,10 @@ Requirements:
|
|
|
11946
12145
|
lastGenerationFailed: true,
|
|
11947
12146
|
lastGenerationError: limitMessage,
|
|
11948
12147
|
});
|
|
11949
|
-
|
|
12148
|
+
// The page may want the reason in the chat alone (`limitNotices: 'chat'`): a budget that is used up is a limit.
|
|
12149
|
+
if (!limitRefusalNeedsNoToast(limitNoticeMode, true)) {
|
|
12150
|
+
showToast('warning', $t('creator.general.limitReached'), { description: limitMessage, duration: 8000 });
|
|
12151
|
+
}
|
|
11950
12152
|
pushCodegenFailureToChat(generationWidgetId, limitMessage);
|
|
11951
12153
|
return;
|
|
11952
12154
|
}
|
|
@@ -11997,7 +12199,12 @@ Requirements:
|
|
|
11997
12199
|
lastGenerationError: message,
|
|
11998
12200
|
});
|
|
11999
12201
|
clearActiveOperationId(generationWidgetId); // Clear persisted operationId on error
|
|
12000
|
-
|
|
12202
|
+
// A refusal because of a limit (credits used up) is told in the chat alone when the page asked for that
|
|
12203
|
+
// (`limitNotices: 'chat'`): the toast would say the same thing a second time. Any other failure keeps its toast.
|
|
12204
|
+
const refusedForALimit = await responseIsALimit(error?.response);
|
|
12205
|
+
if (!limitRefusalNeedsNoToast(limitNoticeMode, refusedForALimit)) {
|
|
12206
|
+
showToast('error', $t('creator.codegen.codeGenerationError'), { description: message, duration: 6000 });
|
|
12207
|
+
}
|
|
12001
12208
|
pushCodegenFailureToChat(generationWidgetId, message);
|
|
12002
12209
|
} finally {
|
|
12003
12210
|
noteCodegenActive(false);
|
|
@@ -12322,6 +12529,9 @@ Requirements:
|
|
|
12322
12529
|
?? publishEnvelope?.commitTitle
|
|
12323
12530
|
?? null;
|
|
12324
12531
|
applyPublishSuccessToWidgetState(capturedWidgetId, version, artifactUrl, commitSha, commitTitle);
|
|
12532
|
+
// The site hears of a finished publish from the realtime socket (see the `widgetPublishStatus` block). A partner's
|
|
12533
|
+
// creator opens no socket, so the answer of this request is what tells its page.
|
|
12534
|
+
if (partnerMode) notifyPublishComplete(capturedWidgetId, version);
|
|
12325
12535
|
|
|
12326
12536
|
if (!publishOpts.silent) {
|
|
12327
12537
|
showToast('success', $t('creator.publish.widgetPublished'), {
|
|
@@ -15824,13 +16034,41 @@ Requirements:
|
|
|
15824
16034
|
);
|
|
15825
16035
|
}
|
|
15826
16036
|
|
|
16037
|
+
/**
|
|
16038
|
+
* Tells the page (`onPublishComplete`) that a widget was published. The widget's thumbnail is refreshed first, for at most
|
|
16039
|
+
* two and a half seconds, so a page that leaves the canvas at once (the host's Publish goes back to its dashboard) shows
|
|
16040
|
+
* the published widget and not the old picture. On the Widgetic site the realtime socket says a publish is done; a
|
|
16041
|
+
* partner's creator has no socket, so it goes by the answer of the publish request (see `executePublishWidget`). A
|
|
16042
|
+
* handler that throws does not reach the creator.
|
|
16043
|
+
*/
|
|
16044
|
+
function notifyPublishComplete(publishedWidgetId: string, publishedVersion: number | undefined): void {
|
|
16045
|
+
if (!embedded || !onPublishComplete) return;
|
|
16046
|
+
void (async () => {
|
|
16047
|
+
await Promise.race([
|
|
16048
|
+
handleRefreshScreenshot(publishedWidgetId, { quiet: true }).catch((error) => {
|
|
16049
|
+
console.warn('[Publish] Thumbnail before leaving the canvas failed', error);
|
|
16050
|
+
}),
|
|
16051
|
+
new Promise((resolve) => setTimeout(resolve, 2500)),
|
|
16052
|
+
]);
|
|
16053
|
+
try {
|
|
16054
|
+
onPublishComplete({
|
|
16055
|
+
widgetId: publishedWidgetId,
|
|
16056
|
+
version: publishedVersion
|
|
16057
|
+
});
|
|
16058
|
+
} catch (error) {
|
|
16059
|
+
console.error(`[CreatorApp] The page's onPublishComplete handler threw:`, error);
|
|
16060
|
+
}
|
|
16061
|
+
})();
|
|
16062
|
+
}
|
|
16063
|
+
|
|
15827
16064
|
/**
|
|
15828
16065
|
* Publish for a panel. Pass `targetVersion` to publish a specific Draft the
|
|
15829
16066
|
* user selected in the version list (built from that version's own commit);
|
|
15830
|
-
* omit it to publish the newest generated code.
|
|
16067
|
+
* omit it to publish the newest generated code. The promise ends when the request is over; the buttons that start it do
|
|
16068
|
+
* not wait for it, and `publish()` (the host's control) does.
|
|
15831
16069
|
*/
|
|
15832
|
-
function runPublishForPanel(panelWidgetId: string, targetVersion?: number | null): void {
|
|
15833
|
-
|
|
16070
|
+
function runPublishForPanel(panelWidgetId: string, targetVersion?: number | null): Promise<void> {
|
|
16071
|
+
return (async () => {
|
|
15834
16072
|
if (isPublishing && !publishingWidgetId) {
|
|
15835
16073
|
console.warn('[Publish] Clearing stuck global isPublishing flag');
|
|
15836
16074
|
isPublishing = false;
|
|
@@ -15906,20 +16144,7 @@ $: if ($widgetPublishStatus.timestamp && $widgetPublishStatus.widgetId) {
|
|
|
15906
16144
|
void getWidgetDetailsRef(publishWidgetId)?.refreshPreview({ withRetry: true });
|
|
15907
16145
|
}
|
|
15908
16146
|
if (embedded && onPublishComplete && publishWidgetId) {
|
|
15909
|
-
|
|
15910
|
-
const publishedVersion = publishResult.version;
|
|
15911
|
-
void (async () => {
|
|
15912
|
-
await Promise.race([
|
|
15913
|
-
handleRefreshScreenshot(publishedWidgetId, { quiet: true }).catch((error) => {
|
|
15914
|
-
console.warn('[Publish] Thumbnail before leaving the canvas failed', error);
|
|
15915
|
-
}),
|
|
15916
|
-
new Promise((resolve) => setTimeout(resolve, 2500)),
|
|
15917
|
-
]);
|
|
15918
|
-
onPublishComplete({
|
|
15919
|
-
widgetId: publishedWidgetId,
|
|
15920
|
-
version: publishedVersion
|
|
15921
|
-
});
|
|
15922
|
-
})();
|
|
16147
|
+
notifyPublishComplete(publishWidgetId, publishResult.version);
|
|
15923
16148
|
} else if (publishWidgetId) {
|
|
15924
16149
|
scheduleQuietScreenshot(publishWidgetId, 2000);
|
|
15925
16150
|
}
|
|
@@ -17590,6 +17815,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17590
17815
|
*/
|
|
17591
17816
|
let autosaveSequence = 0;
|
|
17592
17817
|
let lastResolvedAutosaveSequence = 0;
|
|
17818
|
+
/** The requests that write the canvas to the API, one at a time and in the order they were made (see `handleCanvasAutoSave`). */
|
|
17819
|
+
const canvasSaveQueue = createSerialQueue();
|
|
17593
17820
|
/**
|
|
17594
17821
|
* Trailing save deferred while `isLoadCooldownActive` is set.
|
|
17595
17822
|
* See {@link handleCanvasAutoSave}: dropping cooldown saves lost user edits.
|
|
@@ -17709,14 +17936,21 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
17709
17936
|
// Save to API via SDK with sequence race protection
|
|
17710
17937
|
if (canvasId && canvasesClient) {
|
|
17711
17938
|
const currentSeq = ++autosaveSequence;
|
|
17939
|
+
// The canvas this save is for, read now: the request waits its turn in the queue, and the person may switch canvas meanwhile.
|
|
17940
|
+
const saveCanvasId = canvasId;
|
|
17941
|
+
const saveClient = canvasesClient;
|
|
17712
17942
|
try {
|
|
17713
|
-
|
|
17714
|
-
|
|
17715
|
-
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
|
|
17943
|
+
// One request at a time, in the order the canvas was changed: two in flight can reach the server in either
|
|
17944
|
+
// order, and the older canvas would overwrite the newer one.
|
|
17945
|
+
await canvasSaveQueue.run(() =>
|
|
17946
|
+
saveClient.updateCanvas({
|
|
17947
|
+
id: saveCanvasId,
|
|
17948
|
+
updateCanvasRequest: {
|
|
17949
|
+
canvasContent: parsedCanvas ?? JSON.parse(json)
|
|
17950
|
+
}
|
|
17951
|
+
})
|
|
17952
|
+
);
|
|
17953
|
+
canvasRecordReads.delete(saveCanvasId);
|
|
17720
17954
|
if (currentSeq < lastResolvedAutosaveSequence) {
|
|
17721
17955
|
// console.log(
|
|
17722
17956
|
// `[CanvasDebug] Dropped out-of-order autosave response (${currentSeq} < ${lastResolvedAutosaveSequence})`
|
|
@@ -18925,8 +19159,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
18925
19159
|
widgetDetails?.closeWidgetDetails();
|
|
18926
19160
|
}}
|
|
18927
19161
|
panZoomPosition="TL"
|
|
18928
|
-
|
|
19162
|
+
toolbarPosition={toolbarPosition}
|
|
19163
|
+
showSaveButton={showSaveButton}
|
|
18929
19164
|
autosaveDelayMs={import.meta.env.DEV ? 15000 : 5000}
|
|
19165
|
+
autosaveMaxWaitMs={CANVAS_AUTOSAVE_MAX_WAIT_MS}
|
|
18930
19166
|
suspendAutosave={suspendCanvasAutosave}
|
|
18931
19167
|
isExternalDataLoading={!isCanvasStateLoaded}
|
|
18932
19168
|
/>
|
|
@@ -20035,6 +20271,8 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
20035
20271
|
onRestoreCheckpointBackend={(conversationId, checkpointMessageId) =>
|
|
20036
20272
|
handleRestoreCheckpoint(conversationId, checkpointMessageId, panelWidgetId)
|
|
20037
20273
|
}
|
|
20274
|
+
onRateVersion={mayRateVersions() ? handleRateVersion : undefined}
|
|
20275
|
+
versionRatings={versionRatingsByMessageId}
|
|
20038
20276
|
onChatReady={(methods) => handleChatReady(methods, panelWidgetId)}
|
|
20039
20277
|
onDraftChange={() => handleChatDraftChange(panelWidgetId)}
|
|
20040
20278
|
onConversationChange={(conversationId) => handleChatConversationChange(conversationId, panelWidgetId)}
|
|
@@ -24,6 +24,11 @@ declare const CreatorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
24
24
|
forceCreateNewWidget?: CreatorAppProps["forceCreateNewWidget"];
|
|
25
25
|
initialSketchName?: CreatorAppProps["initialSketchName"];
|
|
26
26
|
/** Words to put in the chat input of a new widget, once (never sent by the creator itself). */ initialPrompt?: CreatorAppProps["initialPrompt"];
|
|
27
|
+
/** Words for the chat of a new widget and whether to send them (see `CreatorAppProps.initialMessage`). Used once. */ initialMessage?: CreatorAppProps["initialMessage"];
|
|
28
|
+
/** Where the canvas's tool bar stands along the bottom edge (see `CreatorAppProps.toolbarPosition`). */ toolbarPosition?: CreatorAppProps["toolbarPosition"];
|
|
29
|
+
/** Whether the canvas shows its Save button (see `CreatorAppProps.showSaveButton`): the site and the standalone creator do. */ showSaveButton?: CreatorAppProps["showSaveButton"];
|
|
30
|
+
/** How a refusal because of a limit is told (see `CreatorAppProps.limitNotices`). */ limitNotices?: CreatorAppProps["limitNotices"];
|
|
31
|
+
/** What Publish would do now, for the host that draws its own button (see `CreatorAppProps.onPublishStateChanged`). */ onPublishStateChanged?: CreatorAppProps["onPublishStateChanged"];
|
|
27
32
|
apiUrl?: CreatorAppProps["apiUrl"];
|
|
28
33
|
widgetBuilderUrl?: CreatorAppProps["widgetBuilderUrl"];
|
|
29
34
|
initialDebugMode?: CreatorAppProps["initialDebugMode"];
|
|
@@ -60,12 +65,18 @@ declare const CreatorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
60
65
|
* its File Browser and rich text editor) reads it from Svelte's context and follows when the page changes `dir`;
|
|
61
66
|
* `textDirection` is the answer, for the creator's own decisions (where a pop-up opens from, which way a divider drags).
|
|
62
67
|
*/ dir?: CreatorAppProps["dir"];
|
|
68
|
+
publish?: () => Promise<void>;
|
|
69
|
+
flush?: () => Promise<void>;
|
|
70
|
+
setWidgetName?: (name: string, widgetId?: string | null) => Promise<void>;
|
|
63
71
|
class?: string;
|
|
64
72
|
style?: string;
|
|
65
73
|
}, {
|
|
66
74
|
[evt: string]: CustomEvent<any>;
|
|
67
75
|
}, {}, {
|
|
68
76
|
onBack: CreatorAppProps["onBack"];
|
|
77
|
+
publish: () => Promise<void>;
|
|
78
|
+
flush: () => Promise<void>;
|
|
79
|
+
setWidgetName: (name: string, widgetId?: string | null) => Promise<void>;
|
|
69
80
|
}, string>;
|
|
70
81
|
type CreatorApp = InstanceType<typeof CreatorApp>;
|
|
71
82
|
export default CreatorApp;
|
package/dist/creator-types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { MediaLibraryProvider } from '@widgetic/file-browser';
|
|
2
2
|
import type { TextDirection } from '@widgetic/design-system/components/textDirection';
|
|
3
|
+
import type { ToolbarPosition } from '@widgetic/canvas';
|
|
4
|
+
import type { LimitNotices, PublishState } from './host/hostControls.js';
|
|
5
|
+
export type { LimitNotices, PublishState };
|
|
3
6
|
/** Why the creator asks the page for a token. */
|
|
4
7
|
export type CreatorTokenReason =
|
|
5
8
|
/** It wants the token to use now (the page keeps it fresh), or is starting. */
|
|
@@ -139,6 +142,46 @@ export interface CreatorAppProps {
|
|
|
139
142
|
* a widget with a pasted Figma link this way). Ignored when the widget has a draft of its own.
|
|
140
143
|
*/
|
|
141
144
|
initialPrompt?: string | null;
|
|
145
|
+
/**
|
|
146
|
+
* Words for the chat of a new widget, and whether to send them: `{ text, send?, attachments? }`. With `send: true` the
|
|
147
|
+
* creator sends them as the first message, once the chat is ready, exactly as if the person had typed them and pressed
|
|
148
|
+
* Enter (the generation starts); without it they wait in the input, like `initialPrompt`. A Shopify merchant who pastes a
|
|
149
|
+
* Figma link to replicate gets a widget whose first message is that link. `attachments` are pictures that go with the
|
|
150
|
+
* words (a photo to replicate): at most five `File`s of the host's own, each a PNG, JPEG, WebP or GIF of at most 10 MB.
|
|
151
|
+
* They are sent with the message, as if the person had attached them, or (without `send`) wait in the input beside the
|
|
152
|
+
* words. Used once per creator; ignored when the widget has a draft of its own; empty words, words that are not text,
|
|
153
|
+
* words longer than 4000 characters and pictures that cannot be used (one that fails fails the message) are ignored.
|
|
154
|
+
*/
|
|
155
|
+
initialMessage?: {
|
|
156
|
+
text: string;
|
|
157
|
+
send?: boolean;
|
|
158
|
+
attachments?: File[];
|
|
159
|
+
} | null;
|
|
160
|
+
/**
|
|
161
|
+
* Where the canvas's tool bar (the drawing tools and the element selector) stands along the bottom edge: `'BL'`
|
|
162
|
+
* (bottom left), `'BC'` (bottom centre, the default) or `'BR'` (bottom right). A host whose own page puts something
|
|
163
|
+
* over the centre of the bottom edge (Shopify's Sidekick) moves it.
|
|
164
|
+
*/
|
|
165
|
+
toolbarPosition?: ToolbarPosition;
|
|
166
|
+
/**
|
|
167
|
+
* Whether the canvas shows its Save button and the dot that says the board has changes the server does not have.
|
|
168
|
+
* Default `true`. The canvas saves on its own either way (a moment after the last change, at the latest every fifteen
|
|
169
|
+
* seconds of work, and when the page is hidden or closed); a host that wants no save control on its page passes `false`.
|
|
170
|
+
*/
|
|
171
|
+
showSaveButton?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* How a refusal because of a limit (credits used up, a plan that does not include it) is told on the creator's own
|
|
174
|
+
* screen. `'all'` (the default) shows a toast and puts the reason in the chat. `'chat'` puts it in the chat only: the page
|
|
175
|
+
* shows no second notice, or draws its own. Only refusals the API marks as a limit are affected; every other failure
|
|
176
|
+
* keeps its toast.
|
|
177
|
+
*/
|
|
178
|
+
limitNotices?: LimitNotices;
|
|
179
|
+
/**
|
|
180
|
+
* The host's Publish button follows this: what Publish would do now (`canPublish`, `publishing`, `label`,
|
|
181
|
+
* `unpublished`) for the widget it would publish (`widgetId`). Called with the first state once the creator knows it,
|
|
182
|
+
* then on every change, and never twice with the same state. The host presses Publish with `publish()` on the component.
|
|
183
|
+
*/
|
|
184
|
+
onPublishStateChanged?: (state: PublishState) => void;
|
|
142
185
|
/** When true, hides auth screen + top bar; syncs session from site localStorage */
|
|
143
186
|
embedded?: boolean;
|
|
144
187
|
/**
|
|
@@ -185,6 +228,11 @@ export interface CreatorAppProps {
|
|
|
185
228
|
enableLocalCache?: boolean;
|
|
186
229
|
class?: string;
|
|
187
230
|
style?: string;
|
|
231
|
+
/**
|
|
232
|
+
* A widget was published (its new version is live). Called once per publish, a moment after the answer (the creator
|
|
233
|
+
* first refreshes the widget's thumbnail, for at most two and a half seconds). On the Widgetic site the realtime socket
|
|
234
|
+
* says it; in a partner's page, which has no socket, the answer of the publish request does.
|
|
235
|
+
*/
|
|
188
236
|
onPublishComplete?: (detail: {
|
|
189
237
|
widgetId: string;
|
|
190
238
|
version?: number;
|
|
@@ -100,6 +100,13 @@ export declare function mayShowAccountBilling(): boolean;
|
|
|
100
100
|
* partner's page the creator does not ask, and the widget keeps the name of its draft.
|
|
101
101
|
*/
|
|
102
102
|
export declare function maySuggestWidgetName(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Whether the creator may offer a person the thumbs next to a version of their widget (`PUT
|
|
105
|
+
* /conversations/{conversationId}/messages/{messageId}/rating`). That call is for Widgetic's own apps: it is not on the gateway's
|
|
106
|
+
* list of what a partner's visitor may reach (the editor session), so in a partner's page every press would be refused. There the
|
|
107
|
+
* creator draws no thumbs at all.
|
|
108
|
+
*/
|
|
109
|
+
export declare function mayRateVersions(): boolean;
|
|
103
110
|
/** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
|
|
104
111
|
export declare function mayListenToSiteEvents(): boolean;
|
|
105
112
|
/**
|
package/dist/host/creatorHost.js
CHANGED
|
@@ -108,6 +108,15 @@ export function mayShowAccountBilling() {
|
|
|
108
108
|
export function maySuggestWidgetName() {
|
|
109
109
|
return !state.partnerMode;
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether the creator may offer a person the thumbs next to a version of their widget (`PUT
|
|
113
|
+
* /conversations/{conversationId}/messages/{messageId}/rating`). That call is for Widgetic's own apps: it is not on the gateway's
|
|
114
|
+
* list of what a partner's visitor may reach (the editor session), so in a partner's page every press would be refused. There the
|
|
115
|
+
* creator draws no thumbs at all.
|
|
116
|
+
*/
|
|
117
|
+
export function mayRateVersions() {
|
|
118
|
+
return !state.partnerMode;
|
|
119
|
+
}
|
|
111
120
|
/** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
|
|
112
121
|
export function mayListenToSiteEvents() {
|
|
113
122
|
return !state.partnerMode;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page that mounts the creator can ask of it besides its props, and the small rules behind it.
|
|
3
|
+
*
|
|
4
|
+
* A host that draws its own header around the creator (the Shopify app does: a Back arrow, the widget's name, a Publish
|
|
5
|
+
* button) needs four things from it, none of which are a prop:
|
|
6
|
+
*
|
|
7
|
+
* - to know whether Publish is possible right now, and what it would say (`PublishState`, told with
|
|
8
|
+
* `onPublishStateChanged`);
|
|
9
|
+
* - to press Publish for the person (`publish()`);
|
|
10
|
+
* - to put what the person changed on the server before it leaves the page (`flush()`);
|
|
11
|
+
* - to rename the widget the creator shows (`setWidgetName()`).
|
|
12
|
+
*
|
|
13
|
+
* It also lets the host choose how a refusal because of a limit (credits used up) is told (`limitNotices`), and put a
|
|
14
|
+
* message in the chat of a new widget and send it (`initialMessage`: a link to replicate, or a photo to replicate, for one).
|
|
15
|
+
*
|
|
16
|
+
* This file is plain TypeScript with no Svelte in it, so a test can hold it to every one of those rules.
|
|
17
|
+
*/
|
|
18
|
+
/** How a refusal because of a limit is told on the creator's own screen. */
|
|
19
|
+
export type LimitNotices =
|
|
20
|
+
/** A toast and a line in the chat: what the creator always did, and what the site and a partner's page get. */
|
|
21
|
+
'all'
|
|
22
|
+
/** The line in the chat only. The page tells the person anything more itself, or nothing. */
|
|
23
|
+
| 'chat';
|
|
24
|
+
/** What a page that says nothing about it gets. */
|
|
25
|
+
export declare const DEFAULT_LIMIT_NOTICES: LimitNotices;
|
|
26
|
+
/** The notices a page asked for; anything the creator does not know is the default. */
|
|
27
|
+
export declare function normalizeLimitNotices(value: unknown): LimitNotices;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a refusal leaves out its toast. Only a refusal because of a limit can: every other failure keeps its toast,
|
|
30
|
+
* whatever the page asked for, because the chat line alone does not say that something went wrong with the request.
|
|
31
|
+
*/
|
|
32
|
+
export declare function limitRefusalNeedsNoToast(notices: LimitNotices, refusalIsALimit: boolean): boolean;
|
|
33
|
+
/** The longest message a host can hand the creator: a link and a sentence or two, not a document. */
|
|
34
|
+
export declare const INITIAL_MESSAGE_MAX_CHARS = 4000;
|
|
35
|
+
/** The most pictures a host can send with its message: what one request to the builder takes, and what the chat's input holds. */
|
|
36
|
+
export declare const INITIAL_MESSAGE_MAX_ATTACHMENTS = 5;
|
|
37
|
+
/** The biggest picture a host can send, in bytes: the limit of the creator's own image upload (10 MB). */
|
|
38
|
+
export declare const INITIAL_MESSAGE_MAX_ATTACHMENT_BYTES: number;
|
|
39
|
+
/** The kinds of picture a host can send: the ones the builder looks at and every browser can draw. (Not SVG, not HEIC.) */
|
|
40
|
+
export declare const INITIAL_MESSAGE_ATTACHMENT_TYPES: readonly string[];
|
|
41
|
+
/** A message the host puts in the chat of a new widget. */
|
|
42
|
+
export interface InitialMessage {
|
|
43
|
+
/** The words, trimmed. */
|
|
44
|
+
text: string;
|
|
45
|
+
/** Whether the creator sends it as the first message, as if the person had typed it and pressed Enter. */
|
|
46
|
+
send: boolean;
|
|
47
|
+
/** The pictures that go with the words (a photo to replicate): sent with them, or put in the input beside them. Often none. */
|
|
48
|
+
attachments: File[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The pictures a host handed over, or null when they cannot be used. Nothing given (undefined, null) is no pictures. Anything
|
|
52
|
+
* else must be a list of the host's own `File`s: no more than five, each a PNG, JPEG, WebP or GIF, not empty and not over
|
|
53
|
+
* 10 MB. One picture that fails makes all of them unusable, because the message then says something ("replicate this photo")
|
|
54
|
+
* about a picture that is not there. The list returned is a copy; the files are the host's own.
|
|
55
|
+
*/
|
|
56
|
+
export declare function normalizeInitialMessageAttachments(value: unknown): File[] | null;
|
|
57
|
+
/**
|
|
58
|
+
* The message a host handed over, or null when there is none to use: nothing given, no words, words that are not text
|
|
59
|
+
* or too many of them, or pictures that cannot be used (see `normalizeInitialMessageAttachments`). `send` is on only when
|
|
60
|
+
* the host said `true`, never for a value that merely looks true.
|
|
61
|
+
*/
|
|
62
|
+
export declare function normalizeInitialMessage(value: unknown): InitialMessage | null;
|
|
63
|
+
/**
|
|
64
|
+
* The widget the host's Publish speaks for: the widget of the panel the person is on (a draft that is not a widget yet
|
|
65
|
+
* does not count), else the primary widget of the canvas. The Publish button the host draws and the publish the creator
|
|
66
|
+
* runs when it is pressed must be about the same widget, so both ask here.
|
|
67
|
+
*/
|
|
68
|
+
export declare function publishTargetOf(focusedPanelWidgetId: string | null | undefined, canvasPrimaryWidgetId: string | null | undefined, isDraftId: (widgetId: string) => boolean): string;
|
|
69
|
+
/** What the host needs to draw its Publish button. */
|
|
70
|
+
export interface PublishState {
|
|
71
|
+
/** The widget Publish would publish; null when there is none yet. */
|
|
72
|
+
widgetId: string | null;
|
|
73
|
+
/** Publish can be pressed now. */
|
|
74
|
+
canPublish: boolean;
|
|
75
|
+
/** A publish of that widget is running. */
|
|
76
|
+
publishing: boolean;
|
|
77
|
+
/** The words the creator's own Publish button would carry ("Publish", "Publish changes"). */
|
|
78
|
+
label: string;
|
|
79
|
+
/** The widget has changes no published version has. */
|
|
80
|
+
unpublished: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** One line that is the same for two states that say the same thing. */
|
|
83
|
+
export declare function publishStateSignature(state: PublishState): string;
|
|
84
|
+
export interface PublishStateReporter {
|
|
85
|
+
/** Takes the state as it is now; tells the host only when it differs from what the host was told last. Returns whether it told. */
|
|
86
|
+
note(state: PublishState): boolean;
|
|
87
|
+
/** What the host was told last, or null when it was told nothing. */
|
|
88
|
+
readonly last: PublishState | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Tells the host the publish state when it changes, and only then: the creator works the state out again on every
|
|
92
|
+
* change of its panels, and a host that redraws a button must not be told the same thing a hundred times.
|
|
93
|
+
*/
|
|
94
|
+
export declare function createPublishStateReporter(report: (state: PublishState) => void): PublishStateReporter;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a page that mounts the creator can ask of it besides its props, and the small rules behind it.
|
|
3
|
+
*
|
|
4
|
+
* A host that draws its own header around the creator (the Shopify app does: a Back arrow, the widget's name, a Publish
|
|
5
|
+
* button) needs four things from it, none of which are a prop:
|
|
6
|
+
*
|
|
7
|
+
* - to know whether Publish is possible right now, and what it would say (`PublishState`, told with
|
|
8
|
+
* `onPublishStateChanged`);
|
|
9
|
+
* - to press Publish for the person (`publish()`);
|
|
10
|
+
* - to put what the person changed on the server before it leaves the page (`flush()`);
|
|
11
|
+
* - to rename the widget the creator shows (`setWidgetName()`).
|
|
12
|
+
*
|
|
13
|
+
* It also lets the host choose how a refusal because of a limit (credits used up) is told (`limitNotices`), and put a
|
|
14
|
+
* message in the chat of a new widget and send it (`initialMessage`: a link to replicate, or a photo to replicate, for one).
|
|
15
|
+
*
|
|
16
|
+
* This file is plain TypeScript with no Svelte in it, so a test can hold it to every one of those rules.
|
|
17
|
+
*/
|
|
18
|
+
/** What a page that says nothing about it gets. */
|
|
19
|
+
export const DEFAULT_LIMIT_NOTICES = 'all';
|
|
20
|
+
/** The notices a page asked for; anything the creator does not know is the default. */
|
|
21
|
+
export function normalizeLimitNotices(value) {
|
|
22
|
+
return value === 'chat' ? 'chat' : DEFAULT_LIMIT_NOTICES;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether a refusal leaves out its toast. Only a refusal because of a limit can: every other failure keeps its toast,
|
|
26
|
+
* whatever the page asked for, because the chat line alone does not say that something went wrong with the request.
|
|
27
|
+
*/
|
|
28
|
+
export function limitRefusalNeedsNoToast(notices, refusalIsALimit) {
|
|
29
|
+
return notices === 'chat' && refusalIsALimit;
|
|
30
|
+
}
|
|
31
|
+
/** The longest message a host can hand the creator: a link and a sentence or two, not a document. */
|
|
32
|
+
export const INITIAL_MESSAGE_MAX_CHARS = 4000;
|
|
33
|
+
/** The most pictures a host can send with its message: what one request to the builder takes, and what the chat's input holds. */
|
|
34
|
+
export const INITIAL_MESSAGE_MAX_ATTACHMENTS = 5;
|
|
35
|
+
/** The biggest picture a host can send, in bytes: the limit of the creator's own image upload (10 MB). */
|
|
36
|
+
export const INITIAL_MESSAGE_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
|
37
|
+
/** The kinds of picture a host can send: the ones the builder looks at and every browser can draw. (Not SVG, not HEIC.) */
|
|
38
|
+
export const INITIAL_MESSAGE_ATTACHMENT_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/gif'];
|
|
39
|
+
/**
|
|
40
|
+
* The pictures a host handed over, or null when they cannot be used. Nothing given (undefined, null) is no pictures. Anything
|
|
41
|
+
* else must be a list of the host's own `File`s: no more than five, each a PNG, JPEG, WebP or GIF, not empty and not over
|
|
42
|
+
* 10 MB. One picture that fails makes all of them unusable, because the message then says something ("replicate this photo")
|
|
43
|
+
* about a picture that is not there. The list returned is a copy; the files are the host's own.
|
|
44
|
+
*/
|
|
45
|
+
export function normalizeInitialMessageAttachments(value) {
|
|
46
|
+
if (value === undefined || value === null)
|
|
47
|
+
return [];
|
|
48
|
+
if (!Array.isArray(value))
|
|
49
|
+
return null;
|
|
50
|
+
if (value.length > INITIAL_MESSAGE_MAX_ATTACHMENTS)
|
|
51
|
+
return null;
|
|
52
|
+
// A server render has no `File`: nothing can be a picture there, and the host that handed one is not in a server render.
|
|
53
|
+
if (typeof File === 'undefined')
|
|
54
|
+
return value.length === 0 ? [] : null;
|
|
55
|
+
const pictures = [];
|
|
56
|
+
for (const item of value) {
|
|
57
|
+
if (!(item instanceof File))
|
|
58
|
+
return null;
|
|
59
|
+
if (!INITIAL_MESSAGE_ATTACHMENT_TYPES.includes(item.type.toLowerCase()))
|
|
60
|
+
return null;
|
|
61
|
+
if (item.size <= 0 || item.size > INITIAL_MESSAGE_MAX_ATTACHMENT_BYTES)
|
|
62
|
+
return null;
|
|
63
|
+
pictures.push(item);
|
|
64
|
+
}
|
|
65
|
+
return pictures;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The message a host handed over, or null when there is none to use: nothing given, no words, words that are not text
|
|
69
|
+
* or too many of them, or pictures that cannot be used (see `normalizeInitialMessageAttachments`). `send` is on only when
|
|
70
|
+
* the host said `true`, never for a value that merely looks true.
|
|
71
|
+
*/
|
|
72
|
+
export function normalizeInitialMessage(value) {
|
|
73
|
+
if (!value || typeof value !== 'object')
|
|
74
|
+
return null;
|
|
75
|
+
const { text, send, attachments } = value;
|
|
76
|
+
if (typeof text !== 'string')
|
|
77
|
+
return null;
|
|
78
|
+
const trimmed = text.trim();
|
|
79
|
+
if (!trimmed || trimmed.length > INITIAL_MESSAGE_MAX_CHARS)
|
|
80
|
+
return null;
|
|
81
|
+
const pictures = normalizeInitialMessageAttachments(attachments);
|
|
82
|
+
if (pictures === null)
|
|
83
|
+
return null;
|
|
84
|
+
return { text: trimmed, send: send === true, attachments: pictures };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The widget the host's Publish speaks for: the widget of the panel the person is on (a draft that is not a widget yet
|
|
88
|
+
* does not count), else the primary widget of the canvas. The Publish button the host draws and the publish the creator
|
|
89
|
+
* runs when it is pressed must be about the same widget, so both ask here.
|
|
90
|
+
*/
|
|
91
|
+
export function publishTargetOf(focusedPanelWidgetId, canvasPrimaryWidgetId, isDraftId) {
|
|
92
|
+
if (focusedPanelWidgetId && !isDraftId(focusedPanelWidgetId))
|
|
93
|
+
return focusedPanelWidgetId;
|
|
94
|
+
return (canvasPrimaryWidgetId || '').trim();
|
|
95
|
+
}
|
|
96
|
+
/** One line that is the same for two states that say the same thing. */
|
|
97
|
+
export function publishStateSignature(state) {
|
|
98
|
+
return JSON.stringify([state.widgetId, state.canPublish, state.publishing, state.label, state.unpublished]);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Tells the host the publish state when it changes, and only then: the creator works the state out again on every
|
|
102
|
+
* change of its panels, and a host that redraws a button must not be told the same thing a hundred times.
|
|
103
|
+
*/
|
|
104
|
+
export function createPublishStateReporter(report) {
|
|
105
|
+
let lastSignature = null;
|
|
106
|
+
let lastState = null;
|
|
107
|
+
return {
|
|
108
|
+
note(state) {
|
|
109
|
+
const signature = publishStateSignature(state);
|
|
110
|
+
if (signature === lastSignature)
|
|
111
|
+
return false;
|
|
112
|
+
lastSignature = signature;
|
|
113
|
+
lastState = { ...state };
|
|
114
|
+
report({ ...state });
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
117
|
+
get last() {
|
|
118
|
+
return lastState;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -593,6 +593,9 @@ 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
599
|
readonly 'chat.messages.version': "Version {number}";
|
|
597
600
|
readonly 'chat.messages.restoredFrom': "Restored from {label}";
|
|
598
601
|
readonly 'chat.messages.previousVersion': "a previous version";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as CreatorApp } from './CreatorApp.svelte';
|
|
2
|
-
export type { CreatorAppProps } from './creator-types.js';
|
|
2
|
+
export type { CreatorAppProps, LimitNotices, PublishState } from './creator-types.js';
|
|
3
3
|
export { syncSessionFromSiteAuth } from './syncSiteAuth.js';
|
|
4
4
|
export { ALL_CREATOR_MESSAGES, CREATOR_MESSAGES, checkCreatorMessages, type CreatorMessageKey } from './i18n/index.js';
|
|
5
5
|
export { mount, unmount } from 'svelte';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs asynchronous jobs one at a time, in the order they were handed in.
|
|
3
|
+
*
|
|
4
|
+
* The creator saves the canvas to the API whenever the person has changed it, and the saves can overlap: the canvas
|
|
5
|
+
* saves on its own timer, the creator saves once more when it is taken off the page, a Save pressed by hand goes through
|
|
6
|
+
* the same function. Two requests in flight at once can reach the server in either order, and the older canvas
|
|
7
|
+
* overwrites the newer one. Handing every save through one queue makes the server see them in the order they were made,
|
|
8
|
+
* so the last save the creator made is the one that stays.
|
|
9
|
+
*
|
|
10
|
+
* A job that fails does not stop the ones behind it: each is its own request, and the person's next change must still
|
|
11
|
+
* be saved. The failure is the caller's, through the promise `run` gave it.
|
|
12
|
+
*/
|
|
13
|
+
export interface SerialQueue {
|
|
14
|
+
/**
|
|
15
|
+
* Runs `job` once every job handed in before it has finished (done or failed). Resolves or rejects as `job` does.
|
|
16
|
+
* `job` is called when its turn comes, not when it is handed in, so it reads the world as it is then.
|
|
17
|
+
*/
|
|
18
|
+
run<T>(job: () => Promise<T>): Promise<T>;
|
|
19
|
+
/** Resolves once every job handed in so far, and any handed in while waiting, has finished. Never rejects. */
|
|
20
|
+
whenIdle(): Promise<void>;
|
|
21
|
+
/** How many jobs are waiting or running. */
|
|
22
|
+
readonly pendingCount: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function createSerialQueue(): SerialQueue;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function createSerialQueue() {
|
|
2
|
+
/** Settles when the last job handed in has finished, however it ended. */
|
|
3
|
+
let tail = Promise.resolve();
|
|
4
|
+
let pendingCount = 0;
|
|
5
|
+
return {
|
|
6
|
+
run(job) {
|
|
7
|
+
pendingCount += 1;
|
|
8
|
+
// `then` turns a job that throws before it returns a promise into a rejection, like any other failure.
|
|
9
|
+
const result = tail.then(() => job());
|
|
10
|
+
const finished = () => {
|
|
11
|
+
pendingCount -= 1;
|
|
12
|
+
};
|
|
13
|
+
tail = result.then(finished, finished);
|
|
14
|
+
return result;
|
|
15
|
+
},
|
|
16
|
+
async whenIdle() {
|
|
17
|
+
// A job handed in while this waits moves `tail`, and the loop waits for that one too.
|
|
18
|
+
while (pendingCount > 0)
|
|
19
|
+
await tail;
|
|
20
|
+
},
|
|
21
|
+
get pendingCount() {
|
|
22
|
+
return pendingCount;
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* versionRatings — the thumbs a person gives to the versions of a widget in the creator's chat.
|
|
3
|
+
*
|
|
4
|
+
* The chat (`@widgetic/chat`) draws two thumbs next to each version and tells the creator what the person pressed (`onRateVersion`).
|
|
5
|
+
* The creator does two things with it:
|
|
6
|
+
*
|
|
7
|
+
* 1. It tells the API (`PUT /conversations/{conversationId}/messages/{messageId}/rating`, the generated `rateMessageVersionRaw`),
|
|
8
|
+
* which keeps the word for Widget Lessons (what the code generator learns across people). The API takes three words: `up`, `down`
|
|
9
|
+
* and `none` (a rating taken back).
|
|
10
|
+
* 2. It remembers the thumbs here, in the creator's own storage, so the thumbs is still showing when the chat opens again: the API
|
|
11
|
+
* has no call that lists ratings, so the chat is handed what the creator remembers (`versionRatings`).
|
|
12
|
+
*
|
|
13
|
+
* Nothing here throws into the chat except the call to the API: when it fails the chat puts the thumbs back as it was, and nothing is
|
|
14
|
+
* remembered. A storage that is full or blocked is never a reason to fail a press.
|
|
15
|
+
*/
|
|
16
|
+
/** What a person can say about a version: a thumbs up, a thumbs down, or nothing (a rating taken back). */
|
|
17
|
+
export type VersionRating = 'up' | 'down' | 'none';
|
|
18
|
+
/** Where the creator remembers the thumbs: one record of the id of the message that announced a version, to `up` or `down`. */
|
|
19
|
+
export declare const VERSION_RATINGS_STORAGE_KEY = "widgetCreator_versionRatings_v1";
|
|
20
|
+
/** How many thumbs are remembered: the newest ones, because an old version is rarely looked at again. */
|
|
21
|
+
export declare const MAX_REMEMBERED_VERSION_RATINGS = 500;
|
|
22
|
+
/** What the creator asks of the API client: the generated `MessagesApi` has this call once the SDK is regenerated. */
|
|
23
|
+
export interface VersionRatingClient {
|
|
24
|
+
rateMessageVersionRaw(requestParameters: {
|
|
25
|
+
conversationId: string;
|
|
26
|
+
messageId: string;
|
|
27
|
+
rateMessageVersionRequest: {
|
|
28
|
+
rating: VersionRating;
|
|
29
|
+
};
|
|
30
|
+
}): Promise<{
|
|
31
|
+
raw: {
|
|
32
|
+
json(): Promise<unknown>;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
/** Which version of which conversation is rated, and how. */
|
|
37
|
+
export interface VersionRatingRequest {
|
|
38
|
+
conversationId: string;
|
|
39
|
+
messageId: string;
|
|
40
|
+
rating: VersionRating;
|
|
41
|
+
}
|
|
42
|
+
/** What the API said about the word it was sent. */
|
|
43
|
+
export interface VersionRatingOutcome {
|
|
44
|
+
/** Whether the API kept the word: `null` when its answer could not be read. */
|
|
45
|
+
recorded: boolean | null;
|
|
46
|
+
/** Why it did not (`switched_off`, `no_record`, `unavailable`), when it said. */
|
|
47
|
+
reason: string | null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Tells the API what the person pressed. The API answers 200 for anyone who may rate, and says in the answer when it could not keep the
|
|
51
|
+
* word (`recorded: false`: the version is older than the tracing, or the learning is switched off); that is no failure for the person,
|
|
52
|
+
* so it is handed back for the caller to note and nothing more. A call that fails (offline, refused) throws, and the chat undoes the press.
|
|
53
|
+
*/
|
|
54
|
+
export declare function rateVersionThroughApi(client: VersionRatingClient, request: VersionRatingRequest): Promise<VersionRatingOutcome>;
|
|
55
|
+
/** The thumbs found in what the storage held: a record of message id to `up` or `down`, and nothing else. Anything unreadable is nothing. */
|
|
56
|
+
export declare function parseRememberedVersionRatings(stored: string | null | undefined): Record<string, VersionRating>;
|
|
57
|
+
/**
|
|
58
|
+
* The thumbs after a version was rated: the rating replaces the one the version had and is put last, `none` takes it away, and past
|
|
59
|
+
* `limit` the oldest are dropped. The record that was given is not changed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function rememberVersionRating(ratings: Readonly<Record<string, VersionRating>>, messageId: string, rating: VersionRating, limit?: number): Record<string, VersionRating>;
|
|
62
|
+
/** The thumbs the creator remembers. A storage that cannot be read is no thumbs. */
|
|
63
|
+
export declare function loadRememberedVersionRatings(): Record<string, VersionRating>;
|
|
64
|
+
/** Remembers the thumbs. A storage that is full or blocked is never a reason to fail a press. */
|
|
65
|
+
export declare function saveRememberedVersionRatings(ratings: Readonly<Record<string, VersionRating>>): void;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* versionRatings — the thumbs a person gives to the versions of a widget in the creator's chat.
|
|
3
|
+
*
|
|
4
|
+
* The chat (`@widgetic/chat`) draws two thumbs next to each version and tells the creator what the person pressed (`onRateVersion`).
|
|
5
|
+
* The creator does two things with it:
|
|
6
|
+
*
|
|
7
|
+
* 1. It tells the API (`PUT /conversations/{conversationId}/messages/{messageId}/rating`, the generated `rateMessageVersionRaw`),
|
|
8
|
+
* which keeps the word for Widget Lessons (what the code generator learns across people). The API takes three words: `up`, `down`
|
|
9
|
+
* and `none` (a rating taken back).
|
|
10
|
+
* 2. It remembers the thumbs here, in the creator's own storage, so the thumbs is still showing when the chat opens again: the API
|
|
11
|
+
* has no call that lists ratings, so the chat is handed what the creator remembers (`versionRatings`).
|
|
12
|
+
*
|
|
13
|
+
* Nothing here throws into the chat except the call to the API: when it fails the chat puts the thumbs back as it was, and nothing is
|
|
14
|
+
* remembered. A storage that is full or blocked is never a reason to fail a press.
|
|
15
|
+
*/
|
|
16
|
+
import { creatorStorage } from '../host/creatorHost.js';
|
|
17
|
+
/** Where the creator remembers the thumbs: one record of the id of the message that announced a version, to `up` or `down`. */
|
|
18
|
+
export const VERSION_RATINGS_STORAGE_KEY = 'widgetCreator_versionRatings_v1';
|
|
19
|
+
/** How many thumbs are remembered: the newest ones, because an old version is rarely looked at again. */
|
|
20
|
+
export const MAX_REMEMBERED_VERSION_RATINGS = 500;
|
|
21
|
+
/**
|
|
22
|
+
* Tells the API what the person pressed. The API answers 200 for anyone who may rate, and says in the answer when it could not keep the
|
|
23
|
+
* word (`recorded: false`: the version is older than the tracing, or the learning is switched off); that is no failure for the person,
|
|
24
|
+
* so it is handed back for the caller to note and nothing more. A call that fails (offline, refused) throws, and the chat undoes the press.
|
|
25
|
+
*/
|
|
26
|
+
export async function rateVersionThroughApi(client, request) {
|
|
27
|
+
const { conversationId, messageId, rating } = request;
|
|
28
|
+
const response = await client.rateMessageVersionRaw({ conversationId, messageId, rateMessageVersionRequest: { rating } });
|
|
29
|
+
try {
|
|
30
|
+
const body = (await response.raw.json());
|
|
31
|
+
const recorded = typeof body?.data?.recorded === 'boolean' ? body.data.recorded : null;
|
|
32
|
+
const reason = typeof body?.data?.reason === 'string' ? body.data.reason : null;
|
|
33
|
+
return { recorded, reason };
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
/* an answer that cannot be read changes nothing for the person: the word was sent */
|
|
37
|
+
return { recorded: null, reason: null };
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** The thumbs found in what the storage held: a record of message id to `up` or `down`, and nothing else. Anything unreadable is nothing. */
|
|
41
|
+
export function parseRememberedVersionRatings(stored) {
|
|
42
|
+
if (!stored)
|
|
43
|
+
return {};
|
|
44
|
+
try {
|
|
45
|
+
const parsed = JSON.parse(stored);
|
|
46
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
47
|
+
return {};
|
|
48
|
+
const remembered = {};
|
|
49
|
+
for (const [messageId, rating] of Object.entries(parsed)) {
|
|
50
|
+
if (rating === 'up' || rating === 'down')
|
|
51
|
+
remembered[messageId] = rating;
|
|
52
|
+
}
|
|
53
|
+
return remembered;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The thumbs after a version was rated: the rating replaces the one the version had and is put last, `none` takes it away, and past
|
|
61
|
+
* `limit` the oldest are dropped. The record that was given is not changed.
|
|
62
|
+
*/
|
|
63
|
+
export function rememberVersionRating(ratings, messageId, rating, limit = MAX_REMEMBERED_VERSION_RATINGS) {
|
|
64
|
+
const others = {};
|
|
65
|
+
for (const [otherId, otherRating] of Object.entries(ratings)) {
|
|
66
|
+
if (otherId !== messageId)
|
|
67
|
+
others[otherId] = otherRating;
|
|
68
|
+
}
|
|
69
|
+
if (rating === 'none')
|
|
70
|
+
return others;
|
|
71
|
+
const next = { ...others, [messageId]: rating };
|
|
72
|
+
const ids = Object.keys(next);
|
|
73
|
+
if (ids.length <= limit)
|
|
74
|
+
return next;
|
|
75
|
+
const kept = {};
|
|
76
|
+
for (const id of ids.slice(ids.length - Math.max(1, limit)))
|
|
77
|
+
kept[id] = next[id];
|
|
78
|
+
return kept;
|
|
79
|
+
}
|
|
80
|
+
/** The thumbs the creator remembers. A storage that cannot be read is no thumbs. */
|
|
81
|
+
export function loadRememberedVersionRatings() {
|
|
82
|
+
try {
|
|
83
|
+
return parseRememberedVersionRatings(creatorStorage.getItem(VERSION_RATINGS_STORAGE_KEY));
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return {};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Remembers the thumbs. A storage that is full or blocked is never a reason to fail a press. */
|
|
90
|
+
export function saveRememberedVersionRatings(ratings) {
|
|
91
|
+
try {
|
|
92
|
+
creatorStorage.setItem(VERSION_RATINGS_STORAGE_KEY, JSON.stringify(ratings));
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
/* a full or blocked store must never break a press */
|
|
96
|
+
}
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/creator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.39",
|
|
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": "^2.0.0",
|
|
9
9
|
"@widgetic/cache-layer": "^0.1.2",
|
|
10
|
-
"@widgetic/canvas": "^0.5.
|
|
11
|
-
"@widgetic/chat": "^0.1.
|
|
10
|
+
"@widgetic/canvas": "^0.5.35",
|
|
11
|
+
"@widgetic/chat": "^0.1.34",
|
|
12
12
|
"@widgetic/design-system": "^0.5.15",
|
|
13
13
|
"@widgetic/editor": "^4.0.10",
|
|
14
14
|
"@widgetic/file-browser": "^0.5.24",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@types/node": "26.4.0",
|
|
75
75
|
"@widgetic/api-sdk": "^2.0.0",
|
|
76
76
|
"@widgetic/cache-layer": "^0.1.2",
|
|
77
|
-
"@widgetic/canvas": "^0.5.
|
|
78
|
-
"@widgetic/chat": "^0.1.
|
|
77
|
+
"@widgetic/canvas": "^0.5.35",
|
|
78
|
+
"@widgetic/chat": "^0.1.34",
|
|
79
79
|
"@widgetic/design-system": "^0.5.15",
|
|
80
80
|
"@widgetic/dev-tools": "^0.3.0",
|
|
81
81
|
"@widgetic/editor": "^4.0.10",
|