@widgetic/creator 0.4.50 → 0.4.51
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 +58 -1
- package/dist/CreatorApp.svelte.d.ts +7 -0
- package/dist/agentMascotWarmUp.d.ts +29 -0
- package/dist/agentMascotWarmUp.js +33 -0
- package/dist/agentSound.d.ts +28 -0
- package/dist/agentSound.js +47 -0
- package/dist/chatPeople.d.ts +19 -0
- package/dist/chatPeople.js +44 -0
- package/dist/creator-types.d.ts +24 -0
- package/dist/host/creatorHost.d.ts +5 -0
- package/dist/host/creatorHost.js +5 -0
- package/dist/i18n/language.d.ts +16 -7
- package/dist/syncSiteAuth.js +7 -2
- package/package.json +6 -3
package/dist/CreatorApp.svelte
CHANGED
|
@@ -423,6 +423,17 @@
|
|
|
423
423
|
$: editorLanguage.update({ locale, messages: languageSlices.editor });
|
|
424
424
|
$: chatMessages = languageSlices.chat;
|
|
425
425
|
$: canvasMessages = languageSlices.canvas;
|
|
426
|
+
/**
|
|
427
|
+
* The people and the sound of the chat (see `CreatorAppProps.chatMembers` and `CreatorAppProps.agentSoundEnabled`).
|
|
428
|
+
* The person who is signed in is known from the session; the rest of the team, and whether the agent's mascot makes
|
|
429
|
+
* sound, come from the page.
|
|
430
|
+
*/
|
|
431
|
+
export let chatMembers: CreatorAppProps['chatMembers'] = undefined;
|
|
432
|
+
export let agentSoundEnabled: CreatorAppProps['agentSoundEnabled'] = true;
|
|
433
|
+
/** Whether the assistant is drawn as the Scribble Mascot, with its sounds (see `CreatorAppProps.agentMascot`). On unless the page says false. */
|
|
434
|
+
export let agentMascot: CreatorAppProps['agentMascot'] = true;
|
|
435
|
+
/** "Desired Chat Person": the signed-in person as the chat knows people, or null when the session has nobody to draw. */
|
|
436
|
+
$: chatCurrentUser = chatPersonFromSession($userSession?.user);
|
|
426
437
|
/** The creator's own area of the page (see `eventIsFromCreator`). */
|
|
427
438
|
let creatorRootEl: HTMLElement | null = null;
|
|
428
439
|
const partnerMode = typeof getAccessToken === 'function';
|
|
@@ -1116,7 +1127,12 @@
|
|
|
1116
1127
|
|
|
1117
1128
|
// Chat module for code generation conversation UI
|
|
1118
1129
|
import { Chat, ContextType } from '@widgetic/chat';
|
|
1119
|
-
import type { ClarificationSuggestion } from '@widgetic/chat';
|
|
1130
|
+
import type { AgentAvatarRenderProps, ClarificationSuggestion } from '@widgetic/chat';
|
|
1131
|
+
// The agent's face in the chat (the brand's mascot), its sound, and the person the chat draws a face for
|
|
1132
|
+
import { Mascot } from '@widgetic/brand/mascot';
|
|
1133
|
+
import { createCreatorAgentSound, type CreatorAgentSound } from './agentSound.js';
|
|
1134
|
+
import { warmUpAgentMascot } from './agentMascotWarmUp.js';
|
|
1135
|
+
import { chatPersonFromSession } from './chatPeople.js';
|
|
1120
1136
|
import DesignQuickEdit from './components/DesignQuickEdit.svelte';
|
|
1121
1137
|
import { collectDesignProperties, resolveDesignIntent, toDesignControlRequest, type DesignControlRequest } from './utils/designIntentResolver';
|
|
1122
1138
|
import { isDesignCardAttached } from './utils/designQuickEditValues';
|
|
@@ -1592,6 +1608,30 @@
|
|
|
1592
1608
|
'Create a widget from the attached image (short description inside).';
|
|
1593
1609
|
/** Prefilled prompt for Convert-to-Widget — user edits or presses Send to start. */
|
|
1594
1610
|
const CONVERT_PROMPT = 'Create a widget starting from the attached image';
|
|
1611
|
+
/** "Agent Sound": the sound of the agent's mascot in the chat. Null until the creator is open, and where it could not be made. */
|
|
1612
|
+
let agentSound: CreatorAgentSound | null = null;
|
|
1613
|
+
onMount(() => {
|
|
1614
|
+
// The sounds belong to the mascot: with it off the player is made off, so its sound material is never even loaded
|
|
1615
|
+
agentSound = createCreatorAgentSound({ enabled: agentSoundEnabled !== false && agentMascot !== false });
|
|
1616
|
+
return () => {
|
|
1617
|
+
agentSound?.dispose();
|
|
1618
|
+
agentSound = null;
|
|
1619
|
+
};
|
|
1620
|
+
});
|
|
1621
|
+
// The page may mute the agent, or bring the sound back, while the creator is open (and the mascot, which the sound belongs to)
|
|
1622
|
+
$: agentSound?.setEnabled(agentSoundEnabled !== false && agentMascot !== false);
|
|
1623
|
+
|
|
1624
|
+
/** "Agent Mascot warm-up": the first mascot of a page waits for Three.js, the WebGL context and the shader (a still picture until then). */
|
|
1625
|
+
let isCreatorMounted = false;
|
|
1626
|
+
onMount(() => {
|
|
1627
|
+
isCreatorMounted = true;
|
|
1628
|
+
return () => {
|
|
1629
|
+
isCreatorMounted = false;
|
|
1630
|
+
};
|
|
1631
|
+
});
|
|
1632
|
+
// Got ready on an idle moment once the creator is open, so the agent's first turn starts moving at once, and again if the page brings the
|
|
1633
|
+
// mascot back. Asking more than once only keeps it warm longer, and with the mascot off nothing is fetched.
|
|
1634
|
+
$: if (isCreatorMounted && agentMascot !== false) void warmUpAgentMascot();
|
|
1595
1635
|
let codeGenerationPrompt = DEFAULT_PROMPT;
|
|
1596
1636
|
let isGeneratingCode = false;
|
|
1597
1637
|
let generatingWidgetIds: Record<string, boolean> = {};
|
|
@@ -21460,6 +21500,19 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21460
21500
|
onChange={(id, value) => applyDesignValuesToPreview(panelWidgetId, { [id]: value })}
|
|
21461
21501
|
/>
|
|
21462
21502
|
{/snippet}
|
|
21503
|
+
<!-- The agent's face: the brand's mascot, drawn when the chat asks for it (`renderAgentAvatar`). A turn that is
|
|
21504
|
+
not the newest comes as `live={false}`: a still picture, so a long history does not run dozens of mascots.
|
|
21505
|
+
Where the mascot cannot be drawn, or the page turned it off (`agentMascot`), the chat shows its plain avatar
|
|
21506
|
+
instead. Cast to any, as for renderDesignControls. -->
|
|
21507
|
+
{#snippet renderAgentAvatar(avatar: AgentAvatarRenderProps)}
|
|
21508
|
+
<Mascot
|
|
21509
|
+
state={avatar.state}
|
|
21510
|
+
size={avatar.size}
|
|
21511
|
+
label={avatar.label}
|
|
21512
|
+
frozenAt={avatar.live ? undefined : 0.5}
|
|
21513
|
+
settleTo="idle"
|
|
21514
|
+
/>
|
|
21515
|
+
{/snippet}
|
|
21463
21516
|
{#snippet generationOptionChecks()}
|
|
21464
21517
|
<BrandKitPanel
|
|
21465
21518
|
part="checks"
|
|
@@ -21498,6 +21551,10 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
|
|
|
21498
21551
|
style="height: 100%; min-height: {chatUserHeight == null ? CHAT_AUTO_MIN_HEIGHT : CHAT_MIN_HEIGHT}px;"
|
|
21499
21552
|
resizeExpandsContainer={true}
|
|
21500
21553
|
renderDesignControls={renderDesignControls as any}
|
|
21554
|
+
renderAgentAvatar={agentMascot === false ? undefined : (renderAgentAvatar as any)}
|
|
21555
|
+
agentSound={agentMascot === false ? undefined : agentSound?.player}
|
|
21556
|
+
members={chatMembers ?? undefined}
|
|
21557
|
+
currentUser={chatCurrentUser}
|
|
21501
21558
|
onMessagesResize={(deltaPx) => handleChatMessagesResize(panelWidgetId, deltaPx)}
|
|
21502
21559
|
showLogs={debugMode}
|
|
21503
21560
|
showHeader={false}
|
|
@@ -69,6 +69,13 @@ declare const CreatorApp: $$__sveltets_2_IsomorphicComponent<{
|
|
|
69
69
|
* its File Browser and rich text editor) reads it from Svelte's context and follows when the page changes `dir`;
|
|
70
70
|
* `textDirection` is the answer, for the creator's own decisions (where a pop-up opens from, which way a divider drags).
|
|
71
71
|
*/ dir?: CreatorAppProps["dir"];
|
|
72
|
+
/**
|
|
73
|
+
* The people and the sound of the chat (see `CreatorAppProps.chatMembers` and `CreatorAppProps.agentSoundEnabled`).
|
|
74
|
+
* The person who is signed in is known from the session; the rest of the team, and whether the agent's mascot makes
|
|
75
|
+
* sound, come from the page.
|
|
76
|
+
*/ chatMembers?: CreatorAppProps["chatMembers"];
|
|
77
|
+
agentSoundEnabled?: CreatorAppProps["agentSoundEnabled"];
|
|
78
|
+
/** Whether the assistant is drawn as the Scribble Mascot, with its sounds (see `CreatorAppProps.agentMascot`). On unless the page says false. */ agentMascot?: CreatorAppProps["agentMascot"];
|
|
72
79
|
publish?: () => Promise<void>;
|
|
73
80
|
flush?: () => Promise<void>;
|
|
74
81
|
setWidgetName?: (name: string, widgetId?: string | null) => Promise<void>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting the agent's first mascot ready before the chat asks for it.
|
|
3
|
+
*
|
|
4
|
+
* The first mascot of a page waits for Three.js (a chunk of its own), the WebGL context and the shader, and shows a still
|
|
5
|
+
* picture until they are done. `warmUpMascot` of `@widgetic/brand` does those steps ahead of time, on an idle moment, and keeps
|
|
6
|
+
* the context for the mascot that follows. This is the creator's use of it: once the creator is open and the page wants the
|
|
7
|
+
* mascot at all (`CreatorAppProps.agentMascot`), so the first turn of the agent starts moving at once.
|
|
8
|
+
*/
|
|
9
|
+
import { type MascotWarmUpStatus, type WarmUpMascotOptions } from '@widgetic/brand/mascot';
|
|
10
|
+
/**
|
|
11
|
+
* How long the context is kept warm for the mascot that follows, in milliseconds: two minutes. Long enough for a person who
|
|
12
|
+
* has opened the creator to write a first message, short enough not to hold a GPU context for a creator that is left open in a
|
|
13
|
+
* tab. After that the brand lets go; a chat that is used later starts a little slower (the context and the shader, with
|
|
14
|
+
* Three.js already loaded) and nothing else changes.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AGENT_MASCOT_KEEP_WARM_MILLISECONDS = 120000;
|
|
17
|
+
/** What the warm-up answers: the brand's answer, or `failed` when the call itself broke (the brand never rejects). */
|
|
18
|
+
export type AgentMascotWarmUpStatus = MascotWarmUpStatus | 'failed';
|
|
19
|
+
export interface AgentMascotWarmUpOptions {
|
|
20
|
+
/** How long to keep the context warm. {@link AGENT_MASCOT_KEEP_WARM_MILLISECONDS} by default. */
|
|
21
|
+
keepWarmForMilliseconds?: number;
|
|
22
|
+
/** Does the warm-up. `warmUpMascot` of the brand by default; the tests give a fake one. */
|
|
23
|
+
warmUp?: (options?: WarmUpMascotOptions) => Promise<MascotWarmUpStatus>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gets the mascot ready (see the top of this file). Safe to call more than once: the brand does the work once and only keeps
|
|
27
|
+
* it warm longer. It never throws and never rejects, so the creator has nothing to catch.
|
|
28
|
+
*/
|
|
29
|
+
export declare function warmUpAgentMascot(options?: AgentMascotWarmUpOptions): Promise<AgentMascotWarmUpStatus>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting the agent's first mascot ready before the chat asks for it.
|
|
3
|
+
*
|
|
4
|
+
* The first mascot of a page waits for Three.js (a chunk of its own), the WebGL context and the shader, and shows a still
|
|
5
|
+
* picture until they are done. `warmUpMascot` of `@widgetic/brand` does those steps ahead of time, on an idle moment, and keeps
|
|
6
|
+
* the context for the mascot that follows. This is the creator's use of it: once the creator is open and the page wants the
|
|
7
|
+
* mascot at all (`CreatorAppProps.agentMascot`), so the first turn of the agent starts moving at once.
|
|
8
|
+
*/
|
|
9
|
+
import { warmUpMascot } from '@widgetic/brand/mascot';
|
|
10
|
+
/**
|
|
11
|
+
* How long the context is kept warm for the mascot that follows, in milliseconds: two minutes. Long enough for a person who
|
|
12
|
+
* has opened the creator to write a first message, short enough not to hold a GPU context for a creator that is left open in a
|
|
13
|
+
* tab. After that the brand lets go; a chat that is used later starts a little slower (the context and the shader, with
|
|
14
|
+
* Three.js already loaded) and nothing else changes.
|
|
15
|
+
*/
|
|
16
|
+
export const AGENT_MASCOT_KEEP_WARM_MILLISECONDS = 120_000;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the mascot ready (see the top of this file). Safe to call more than once: the brand does the work once and only keeps
|
|
19
|
+
* it warm longer. It never throws and never rejects, so the creator has nothing to catch.
|
|
20
|
+
*/
|
|
21
|
+
export async function warmUpAgentMascot(options = {}) {
|
|
22
|
+
try {
|
|
23
|
+
const warmUp = options.warmUp ?? warmUpMascot;
|
|
24
|
+
return await warmUp({
|
|
25
|
+
keepWarmForMilliseconds: options.keepWarmForMilliseconds ?? AGENT_MASCOT_KEEP_WARM_MILLISECONDS
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
// The brand answers `unavailable` where it cannot do it, so this is for what is not its doing (a brand without the warm-up)
|
|
30
|
+
console.warn('[CreatorApp] The agent’s mascot could not be warmed up; the first one starts as it always did.', error);
|
|
31
|
+
return 'failed';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sound of the agent's mascot in the chat.
|
|
3
|
+
*
|
|
4
|
+
* `@widgetic/brand` makes the player but keeps no choice of the person's: the page that owns the settings says whether
|
|
5
|
+
* sound is on (`CreatorAppProps.agentSoundEnabled`) and this keeps the player in step with it. A browser starts audio
|
|
6
|
+
* only from inside a click or a key press, so a player that is on waits for the first one on the page and starts there.
|
|
7
|
+
*/
|
|
8
|
+
import { type MascotSound, type MascotSoundOptions } from '@widgetic/brand/mascot/sound';
|
|
9
|
+
export interface CreatorAgentSound {
|
|
10
|
+
/** The player the chat tells what the agent is doing (the `agentSound` of `Chat`). */
|
|
11
|
+
readonly player: MascotSound;
|
|
12
|
+
/** Follows the page's choice. Turning sound on starts it at the next click or key press (a browser's rule). */
|
|
13
|
+
setEnabled(isEnabled: boolean): void;
|
|
14
|
+
/** Stops waiting for a press and silences the player. For when the creator closes. */
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
export interface CreatorAgentSoundOptions {
|
|
18
|
+
/** Whether sound is on from the start. */
|
|
19
|
+
enabled: boolean;
|
|
20
|
+
/** Where the first click or key press is heard. The window by default. */
|
|
21
|
+
gestureTarget?: EventTarget;
|
|
22
|
+
/** Makes the player. `createMascotSound` by default; the tests give a fake one. */
|
|
23
|
+
createPlayer?: (options: MascotSoundOptions) => MascotSound;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The sound the creator gives the chat, or `null` when it cannot be made (the chat then stays silent; this says so once).
|
|
27
|
+
*/
|
|
28
|
+
export declare function createCreatorAgentSound(options: CreatorAgentSoundOptions): CreatorAgentSound | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sound of the agent's mascot in the chat.
|
|
3
|
+
*
|
|
4
|
+
* `@widgetic/brand` makes the player but keeps no choice of the person's: the page that owns the settings says whether
|
|
5
|
+
* sound is on (`CreatorAppProps.agentSoundEnabled`) and this keeps the player in step with it. A browser starts audio
|
|
6
|
+
* only from inside a click or a key press, so a player that is on waits for the first one on the page and starts there.
|
|
7
|
+
*/
|
|
8
|
+
import { createMascotSound } from '@widgetic/brand/mascot/sound';
|
|
9
|
+
/**
|
|
10
|
+
* The sound the creator gives the chat, or `null` when it cannot be made (the chat then stays silent; this says so once).
|
|
11
|
+
*/
|
|
12
|
+
export function createCreatorAgentSound(options) {
|
|
13
|
+
try {
|
|
14
|
+
const makePlayer = options.createPlayer ?? createMascotSound;
|
|
15
|
+
const player = makePlayer({ enabled: options.enabled });
|
|
16
|
+
// The first press unlocks audio for a player that is on; a player that is off is left alone
|
|
17
|
+
let stopWaitingForPress = player.enableOnFirstGesture(options.gestureTarget);
|
|
18
|
+
// The sound's material is loaded ahead of that press, so audio can start inside it (Safari needs that)
|
|
19
|
+
if (options.enabled)
|
|
20
|
+
void player.prepare();
|
|
21
|
+
return {
|
|
22
|
+
player,
|
|
23
|
+
setEnabled(isEnabled) {
|
|
24
|
+
if (isEnabled === player.enabled)
|
|
25
|
+
return;
|
|
26
|
+
if (!isEnabled) {
|
|
27
|
+
player.disable();
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// The page changed a setting, which is no press: sound is on from now and starts at the next press
|
|
31
|
+
void player.prepare();
|
|
32
|
+
void player.enable();
|
|
33
|
+
stopWaitingForPress?.();
|
|
34
|
+
stopWaitingForPress = player.enableOnFirstGesture(options.gestureTarget);
|
|
35
|
+
},
|
|
36
|
+
dispose() {
|
|
37
|
+
stopWaitingForPress?.();
|
|
38
|
+
stopWaitingForPress = null;
|
|
39
|
+
player.dispose();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.warn('[CreatorApp] The sound of the agent’s mascot could not be set up; the chat stays silent.', error);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The people the chat draws faces for.
|
|
3
|
+
*
|
|
4
|
+
* The chat (`@widgetic/chat`) finds who wrote a message by the `userId` the message carries: it looks the id up in the
|
|
5
|
+
* team a page gives it (`members`) and in the person who is signed in (`currentUser`, which also answers for the
|
|
6
|
+
* messages that person has just sent, before the real id is known). The creator knows only the second, from its
|
|
7
|
+
* session; the first comes from the page that mounts the creator (`CreatorAppProps.chatMembers`).
|
|
8
|
+
*/
|
|
9
|
+
import type { ChatMember } from '@widgetic/chat';
|
|
10
|
+
/**
|
|
11
|
+
* The person who is signed in, as the chat knows people. `null` when there is nobody to draw a face for:
|
|
12
|
+
* - nobody is signed in, or the session carries no id;
|
|
13
|
+
* - it is the visitor of a partner's page (`HOST_VISITOR`), who is no one in particular;
|
|
14
|
+
* - the session knows neither a name nor an e-mail, so the face would have no letter to show.
|
|
15
|
+
*
|
|
16
|
+
* A name that is only the session's stand-in (`SIGNED_IN_FALLBACK_NAME`) is not a name: a person with an e-mail but no
|
|
17
|
+
* name gets the initials of the e-mail instead of a "U" for "User".
|
|
18
|
+
*/
|
|
19
|
+
export declare function chatPersonFromSession(sessionUser: unknown): ChatMember | null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HOST_VISITOR, SIGNED_IN_FALLBACK_NAME } from './host/creatorHost.js';
|
|
2
|
+
/** The text of a field: trimmed, or null when it is not text or has nothing in it. */
|
|
3
|
+
function readSessionText(fieldValue) {
|
|
4
|
+
if (typeof fieldValue !== 'string')
|
|
5
|
+
return null;
|
|
6
|
+
const trimmedText = fieldValue.trim();
|
|
7
|
+
return trimmedText === '' ? null : trimmedText;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The person who is signed in, as the chat knows people. `null` when there is nobody to draw a face for:
|
|
11
|
+
* - nobody is signed in, or the session carries no id;
|
|
12
|
+
* - it is the visitor of a partner's page (`HOST_VISITOR`), who is no one in particular;
|
|
13
|
+
* - the session knows neither a name nor an e-mail, so the face would have no letter to show.
|
|
14
|
+
*
|
|
15
|
+
* A name that is only the session's stand-in (`SIGNED_IN_FALLBACK_NAME`) is not a name: a person with an e-mail but no
|
|
16
|
+
* name gets the initials of the e-mail instead of a "U" for "User".
|
|
17
|
+
*/
|
|
18
|
+
export function chatPersonFromSession(sessionUser) {
|
|
19
|
+
if (sessionUser === null || typeof sessionUser !== 'object')
|
|
20
|
+
return null;
|
|
21
|
+
const sessionRecord = sessionUser;
|
|
22
|
+
const rawPersonId = sessionRecord.id;
|
|
23
|
+
const personId = typeof rawPersonId === 'string'
|
|
24
|
+
? rawPersonId.trim()
|
|
25
|
+
: typeof rawPersonId === 'number'
|
|
26
|
+
? String(rawPersonId)
|
|
27
|
+
: '';
|
|
28
|
+
if (personId === '' || personId === HOST_VISITOR.id)
|
|
29
|
+
return null;
|
|
30
|
+
const personEmail = readSessionText(sessionRecord.email);
|
|
31
|
+
const givenName = readSessionText(sessionRecord.name);
|
|
32
|
+
const personName = givenName === SIGNED_IN_FALLBACK_NAME ? null : givenName;
|
|
33
|
+
if (personName === null && personEmail === null)
|
|
34
|
+
return null;
|
|
35
|
+
return {
|
|
36
|
+
id: personId,
|
|
37
|
+
name: personName,
|
|
38
|
+
email: personEmail,
|
|
39
|
+
// The site's session calls the picture `avatar`; a record straight from the API calls it `avatar_url`
|
|
40
|
+
avatarUrl: readSessionText(sessionRecord.avatar) ??
|
|
41
|
+
readSessionText(sessionRecord.avatar_url) ??
|
|
42
|
+
readSessionText(sessionRecord.avatarUrl)
|
|
43
|
+
};
|
|
44
|
+
}
|
package/dist/creator-types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { MediaLibraryProvider } from '@widgetic/file-browser';
|
|
2
2
|
import type { TextDirection } from '@widgetic/design-system/components/textDirection';
|
|
3
3
|
import type { ToolbarPosition } from '@widgetic/canvas';
|
|
4
|
+
import type { ChatMember } from '@widgetic/chat';
|
|
4
5
|
import type { LimitNotices, PublishState } from './host/hostControls.js';
|
|
5
6
|
export type { LimitNotices, PublishState };
|
|
6
7
|
/** Why the creator asks the page for a token. */
|
|
@@ -121,6 +122,29 @@ export interface CreatorAppProps {
|
|
|
121
122
|
* the live previews of the widgets and code stay left to right either way. A module sets it from `locale`.
|
|
122
123
|
*/
|
|
123
124
|
dir?: TextDirection;
|
|
125
|
+
/**
|
|
126
|
+
* The people of the project's team, for the faces the chat draws beside what each of them wrote (their picture, or their
|
|
127
|
+
* initials, and the e-mail when the pointer rests on it). Each is found by the `id` the saved messages carry as
|
|
128
|
+
* `userId`. The person who is signed in does not have to be in the list: the creator knows them from the session.
|
|
129
|
+
* Left out, only that person has a face; a message written by someone the creator cannot name has none. Give a new
|
|
130
|
+
* list while the creator is open when the team changes.
|
|
131
|
+
*/
|
|
132
|
+
chatMembers?: ChatMember[] | null;
|
|
133
|
+
/**
|
|
134
|
+
* Whether the agent's mascot makes its small sounds in the chat (a soft cue when it starts to think, to write, and when
|
|
135
|
+
* it is done or fails). On when left out. The creator keeps no choice of the person's: the page owns it (where it keeps
|
|
136
|
+
* the other settings) and gives `false` to mute, `true` to bring the sound back. Audio can only start after a first click
|
|
137
|
+
* or key press on the page, so the sound begins there.
|
|
138
|
+
*/
|
|
139
|
+
agentSoundEnabled?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Whether the assistant of the chat is drawn as the Scribble Mascot, the animated scribble that thinks, writes and ends in
|
|
142
|
+
* its success or error look (and makes the small sounds of `agentSoundEnabled`). On when left out. `false` draws the
|
|
143
|
+
* assistant as a plain round avatar and keeps the chat silent, whatever `agentSoundEnabled` says: the sounds belong to the
|
|
144
|
+
* mascot. Everything else about the chat (the thinking and code cards, the conclusion, the faces) is the same either way.
|
|
145
|
+
* Can change while the creator is open.
|
|
146
|
+
*/
|
|
147
|
+
agentMascot?: boolean;
|
|
124
148
|
canvasId?: string | null;
|
|
125
149
|
projectId?: string | null;
|
|
126
150
|
workspaceType?: 'personal' | 'organization';
|
|
@@ -30,6 +30,11 @@ export declare const HOST_VISITOR: {
|
|
|
30
30
|
readonly id: "00000000-0000-4000-8000-000000000000";
|
|
31
31
|
readonly name: "Visitor";
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* The name the site's session gives a signed-in person whose token carries none (`syncSessionFromSiteAuth`). It stands in
|
|
35
|
+
* for a name: nothing that shows people (the chat's faces) may take it for one.
|
|
36
|
+
*/
|
|
37
|
+
export declare const SIGNED_IN_FALLBACK_NAME = "User";
|
|
33
38
|
/** The three calls the creator makes on the browser's storage, so a stand-in only has to offer these. */
|
|
34
39
|
export type CreatorStorage = Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>;
|
|
35
40
|
/** What the creator tells the page. Every one is optional: a page that does not care leaves them out. */
|
package/dist/host/creatorHost.js
CHANGED
|
@@ -27,6 +27,11 @@
|
|
|
27
27
|
* fail the check.)
|
|
28
28
|
*/
|
|
29
29
|
export const HOST_VISITOR = { id: '00000000-0000-4000-8000-000000000000', name: 'Visitor' };
|
|
30
|
+
/**
|
|
31
|
+
* The name the site's session gives a signed-in person whose token carries none (`syncSessionFromSiteAuth`). It stands in
|
|
32
|
+
* for a name: nothing that shows people (the chat's faces) may take it for one.
|
|
33
|
+
*/
|
|
34
|
+
export const SIGNED_IN_FALLBACK_NAME = 'User';
|
|
30
35
|
const state = {
|
|
31
36
|
partnerMode: false,
|
|
32
37
|
handlers: {},
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -576,14 +576,25 @@ export declare const CREATOR_CATALOGS: {
|
|
|
576
576
|
readonly 'chat.messages.emptyTitle': "What do you want to build?";
|
|
577
577
|
readonly 'chat.messages.emptyHint': "Sketch it on the canvas, or describe it here.";
|
|
578
578
|
readonly 'chat.messages.loadingHistory': "Loading chat history...";
|
|
579
|
-
readonly 'chat.messages.thinking': "
|
|
580
|
-
readonly 'chat.generation.thinking': "Thinking";
|
|
581
|
-
readonly 'chat.generation.writingCode': "Writing code";
|
|
579
|
+
readonly 'chat.messages.thinking': "Thinking\u2026";
|
|
580
|
+
readonly 'chat.generation.thinking': "Thinking\u2026";
|
|
581
|
+
readonly 'chat.generation.writingCode': "Writing code\u2026";
|
|
582
582
|
readonly 'chat.generation.thoughtFor': "Thought for {seconds} s";
|
|
583
583
|
readonly 'chat.generation.expandThought': "Show thinking";
|
|
584
584
|
readonly 'chat.generation.collapseThought': "Hide thinking";
|
|
585
|
-
readonly 'chat.generation.statusThinking': "
|
|
586
|
-
readonly 'chat.generation.statusWritingCode': "
|
|
585
|
+
readonly 'chat.generation.statusThinking': "Thinking";
|
|
586
|
+
readonly 'chat.generation.statusWritingCode': "Writing code";
|
|
587
|
+
readonly 'chat.generation.codeTitle': "Code";
|
|
588
|
+
readonly 'chat.generation.codeWritten': "Code written";
|
|
589
|
+
readonly 'chat.generation.codeLineCount': "{count, plural, one {# line} other {# lines}}";
|
|
590
|
+
readonly 'chat.generation.expandCode': "Show code";
|
|
591
|
+
readonly 'chat.generation.collapseCode': "Hide code";
|
|
592
|
+
readonly 'chat.generation.doneMessage': "Done. Your changes are ready.";
|
|
593
|
+
readonly 'chat.agent.avatar.success': "Done";
|
|
594
|
+
readonly 'chat.agent.avatar.error': "Something went wrong";
|
|
595
|
+
readonly 'chat.member.avatarLabel': "{name} ({email})";
|
|
596
|
+
readonly 'chat.member.emailLabel': "Email {name}";
|
|
597
|
+
readonly 'chat.member.unknown': "Team member";
|
|
587
598
|
readonly 'chat.plan.title': "Build plan";
|
|
588
599
|
readonly 'chat.plan.progress': "{current} of {total}";
|
|
589
600
|
readonly 'chat.plan.showMoreTasks': "Show {count} more tasks";
|
|
@@ -593,7 +604,6 @@ export declare const CREATOR_CATALOGS: {
|
|
|
593
604
|
readonly 'chat.messages.attachmentMissingLabel': "Missing file attachment";
|
|
594
605
|
readonly 'chat.messages.attachmentMissingCaption': "Attachment not saved. Re-attach with Upload, then send it again.";
|
|
595
606
|
readonly 'chat.messages.failedTitle': "Could not build the widget";
|
|
596
|
-
readonly 'chat.messages.failedHint': "The build did not finish. Your sketch is safe, so you can try again.";
|
|
597
607
|
readonly 'chat.messages.failedRetry': "Try again";
|
|
598
608
|
readonly 'chat.messages.stoppedByYou': "You stopped the build.";
|
|
599
609
|
readonly 'chat.messages.upgrade': "Upgrade";
|
|
@@ -656,7 +666,6 @@ export declare const CREATOR_CATALOGS: {
|
|
|
656
666
|
readonly 'chat.input.send': "Send message";
|
|
657
667
|
readonly 'chat.input.tooLong': "Message is too long";
|
|
658
668
|
readonly 'chat.input.publishNudge': "First generate your widget, then you can publish it.";
|
|
659
|
-
readonly 'chat.composer.assistant': "Assistant";
|
|
660
669
|
readonly 'chat.messages.scrollToBottom': "Scroll to latest messages";
|
|
661
670
|
readonly 'chat.messages.clarificationPrompt': "Which option fits best?";
|
|
662
671
|
readonly 'chat.checkpoint.version': "Version {n}";
|
package/dist/syncSiteAuth.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { decodeJWT } from './pageHelpers';
|
|
2
2
|
import { setSession } from './stores/userSession';
|
|
3
3
|
import { syncLocalCacheOwner } from './localCacheGate.js';
|
|
4
|
+
import { SIGNED_IN_FALLBACK_NAME } from './host/creatorHost.js';
|
|
4
5
|
const SITE_SESSION_REQUEST_EVENT = 'widgetic:request-site-session';
|
|
5
6
|
function requestInMemorySiteSession() {
|
|
6
7
|
if (typeof window === 'undefined' || typeof window.dispatchEvent !== 'function') {
|
|
@@ -84,11 +85,15 @@ export function syncSessionFromSiteAuth() {
|
|
|
84
85
|
decoded.user_metadata?.full_name ||
|
|
85
86
|
decoded.name ||
|
|
86
87
|
session?.user?.name ||
|
|
87
|
-
|
|
88
|
+
SIGNED_IN_FALLBACK_NAME,
|
|
88
89
|
role: decoded.role || 'user',
|
|
89
90
|
avatar: decoded.user_metadata?.avatar_url || decoded.user_metadata?.picture
|
|
90
91
|
}
|
|
91
|
-
: session?.user || {
|
|
92
|
+
: session?.user || {
|
|
93
|
+
id: 'site-user',
|
|
94
|
+
email: 'user@widgetic.com',
|
|
95
|
+
name: SIGNED_IN_FALLBACK_NAME
|
|
96
|
+
};
|
|
92
97
|
// setSession → syncLocalCacheOwner when enableLocalCache is on
|
|
93
98
|
setSession(user, token);
|
|
94
99
|
// console.log('[CreatorApp] Session synced from site auth');
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widgetic/creator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.51",
|
|
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
|
+
"@widgetic/brand": "^0.1.1",
|
|
9
10
|
"@widgetic/cache-layer": "^0.1.2",
|
|
10
11
|
"@widgetic/canvas": "^0.5.39",
|
|
11
|
-
"@widgetic/chat": "^0.1.
|
|
12
|
+
"@widgetic/chat": "^0.1.40",
|
|
12
13
|
"@widgetic/design-system": "^0.5.39",
|
|
13
14
|
"@widgetic/editor": "^4.1.3",
|
|
14
15
|
"@widgetic/file-browser": "^0.5.25",
|
|
@@ -73,9 +74,10 @@
|
|
|
73
74
|
"@tailwindcss/typography": "^0.5.15",
|
|
74
75
|
"@types/node": "26.4.0",
|
|
75
76
|
"@widgetic/api-sdk": "^2.0.0",
|
|
77
|
+
"@widgetic/brand": "^0.1.1",
|
|
76
78
|
"@widgetic/cache-layer": "^0.1.2",
|
|
77
79
|
"@widgetic/canvas": "^0.5.39",
|
|
78
|
-
"@widgetic/chat": "^0.1.
|
|
80
|
+
"@widgetic/chat": "^0.1.40",
|
|
79
81
|
"@widgetic/design-system": "^0.5.39",
|
|
80
82
|
"@widgetic/dev-tools": "^0.3.0",
|
|
81
83
|
"@widgetic/editor": "^4.1.3",
|
|
@@ -96,6 +98,7 @@
|
|
|
96
98
|
"tailwindcss": "^4.1.4",
|
|
97
99
|
"tailwindcss-animate": "^1.0.7",
|
|
98
100
|
"terser": "^5.46.0",
|
|
101
|
+
"three": "^0.174.0",
|
|
99
102
|
"ts-node": "^10.9.2",
|
|
100
103
|
"typescript": "^5.8.3",
|
|
101
104
|
"typescript-eslint": "^8.20.0",
|