@widgetic/creator 0.4.33 → 0.4.35

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/README.md CHANGED
@@ -130,7 +130,7 @@ console.log(CREATOR_MESSAGES['creator.embed.codeTitle']); // 'Embed Code ({forma
130
130
  | `creator.codegen.`, `creator.preview.`, `creator.version.`, `creator.versions.` | code generation, repositories and the confirm dialog, the preview banners, versions and checkpoints, and the rows of the version list |
131
131
  | `creator.publish.`, `creator.embed.`, `creator.dialog.` | publishing (buttons, the reasons a publish is not possible, toasts), the Embed step and the sentences of the dialogs that have a name inside them |
132
132
  | `creator.status.`, `creator.error.` | the status bar of a generation and the error texts the creator writes itself (see "What stays as it is") |
133
- | `creator.details.`, `creator.brandKit.`, `creator.livePreviews.` | the widget details panel, the brand kit panel and the live previews drawn on the canvas shapes |
133
+ | `creator.details.`, `creator.brandKit.`, `creator.livePreviews.` | the widget details panel, the chat's generation options (language and libraries; the `brandKit` prefix is the name they had when this panel held the brand kit, which is now account-level), and the live previews drawn on the canvas shapes |
134
134
  | `creator.selector.`, `creator.name.`, `creator.designEdit.`, `creator.fileSource.` | the dropdown that picks a canvas or a composition, the editable name, the quick edit of design values and the control that takes a file or a web address |
135
135
  | `chat.`, `canvas.`, `editor.`, `shadEditor.` and the File Browser's own keys | the chat, the canvas, the editor, the rich text editor of its text boxes and the File Browser that picks a file |
136
136
 
@@ -205,8 +205,8 @@ while the creator is open:
205
205
  (`src/lib/utils/directionPlacement.ts`): a divider is dragged toward the end of the line (`distanceTowardEnd`), a list
206
206
  under a cluster of controls is lined up with the end edge of the cluster (`listAlignedToEnd`), the title of a widget in
207
207
  its panel is given the room up to the box that stands beyond it (`roomBeforeNeighbour`; measured the left to right way it
208
- came out negative and the title showed as a dot), and the pop-up of the brand kit hangs from the start edge of its
209
- button (`popUpLeftFromAnchor`).
208
+ came out negative and the title showed as a dot), and a pop-up that hangs from a button hangs from the start edge of
209
+ that button (`popUpLeftFromAnchor`; nothing in the creator uses it since the brand kit pop-up went away).
210
210
  - **What a person types** (the chat box, the text fields of the quick edit) is read by its own first letter on a right to
211
211
  left screen, and a field with nothing in it yet takes the direction of the screen. A link (the file link field) and a
212
212
  colour code are addresses and stay left to right on every screen.
@@ -37,7 +37,8 @@
37
37
  import { widgetBuilderRequestInit } from './utils/widgetBuilderRequest.js';
38
38
  import { gzipRequestBodyMiddleware } from './utils/gzipRequestMiddleware.js';
39
39
  import type { SelectedWidgetElementReference } from './utils/widgetElementSelector.js';
40
- import BrandKitPanel from './components/BrandKitPanel.svelte';
40
+ import GenerationOptionsPanel from './components/GenerationOptionsPanel.svelte';
41
+ import { brandKitForRequest } from './generation/brandKitForRequest.js';
41
42
 
42
43
  /**
43
44
  * Idempotency middleware (Phase 2 hardening): the gateway rejects
@@ -225,7 +226,6 @@
225
226
  mayUseAddressBar,
226
227
  mayShowAccountBilling,
227
228
  maySuggestWidgetName,
228
- mayNameVersionOrDocumentsInGeneration,
229
229
  mayListenToSiteEvents,
230
230
  announceToSite,
231
231
  eventIsFromCreator,
@@ -1513,45 +1513,12 @@
1513
1513
  // Populated via Chat's onConversationChange callback and passed to generateCode()
1514
1514
  // so the backend can load multi-turn LLM history (Aider-style incremental edits).
1515
1515
  let currentChatConversationId: string | null = null;
1516
- let brandKitEnabled = false;
1517
1516
  let widgetLanguage: 'svelte' | 'react' = 'react';
1518
1517
  let librariesEnabled = false;
1519
- let brandPrimary = '#314F2F';
1520
- let brandSecondary = '#7BA668';
1521
- let brandTitle = '#0F2010';
1522
- let brandSub = '#5C6B58';
1523
- let brandFonts = ['Inter'];
1524
- let brandKitLibraries: string[] = [];
1518
+ let generationLibraries: string[] = [];
1525
1519
  let libraryGitUrl = '';
1526
1520
  let libraryFileName = '';
1527
1521
  let libraryUploads: { name: string; content: string; encoding: string }[] = [];
1528
- let fontUploads: { name: string; content: string; encoding: string }[] = [];
1529
-
1530
- function brandKitForRequest() {
1531
- const kit: {
1532
- colors?: { primary: string; secondary: string; title: string; sub: string };
1533
- fonts?: string[];
1534
- libraries?: string[];
1535
- uploads?: { name: string; content: string; encoding: string }[];
1536
- fontFiles?: { name: string; content: string; encoding: string }[];
1537
- } = {};
1538
- if (brandKitEnabled) {
1539
- kit.colors = {
1540
- primary: brandPrimary,
1541
- secondary: brandSecondary,
1542
- title: brandTitle,
1543
- sub: brandSub,
1544
- };
1545
- const families = brandFonts.map((family) => family.trim()).filter(Boolean).slice(0, 3);
1546
- if (families.length > 0) kit.fonts = families;
1547
- }
1548
- // Preset libraries are a debug test. An empty list is an explicit ban.
1549
- if (librariesEnabled && debugMode) kit.libraries = [...brandKitLibraries];
1550
- if (brandKitEnabled && fontUploads.length > 0) kit.fontFiles = fontUploads.map((file) => ({ ...file }));
1551
- if (libraryUploads.length > 0) kit.uploads = libraryUploads.map((file) => ({ ...file }));
1552
- if (!kit.colors && !kit.fonts && !kit.libraries && !kit.uploads && !kit.fontFiles) return undefined;
1553
- return kit;
1554
- }
1555
1522
 
1556
1523
  /** Prompt mentions a reference image but chat has no attachment (common UX mistake). */
1557
1524
  function promptImpliesVisionReference(prompt: string): boolean {
@@ -10644,14 +10611,7 @@ Requirements:
10644
10611
  language: 'svelte' | 'react';
10645
10612
  librariesEnabled: boolean;
10646
10613
  libraries: string[];
10647
- brandKitEnabled: boolean;
10648
- primary: string;
10649
- secondary: string;
10650
- title: string;
10651
- sub: string;
10652
- fonts: string[];
10653
10614
  libraryUploads: { name: string; content: string; encoding: string }[];
10654
- fontUploads: { name: string; content: string; encoding: string }[];
10655
10615
  };
10656
10616
 
10657
10617
  let generationOptionsMemory: Record<string, RememberedGenerationOptions> = {};
@@ -10660,15 +10620,8 @@ Requirements:
10660
10620
  return {
10661
10621
  language: widgetLanguage === 'react' ? 'react' : 'svelte',
10662
10622
  librariesEnabled,
10663
- libraries: [...brandKitLibraries],
10664
- brandKitEnabled,
10665
- primary: brandPrimary,
10666
- secondary: brandSecondary,
10667
- title: brandTitle,
10668
- sub: brandSub,
10669
- fonts: [...brandFonts],
10623
+ libraries: [...generationLibraries],
10670
10624
  libraryUploads: libraryUploads.map((file) => ({ ...file })),
10671
- fontUploads: fontUploads.map((file) => ({ ...file })),
10672
10625
  };
10673
10626
  }
10674
10627
 
@@ -10682,12 +10635,6 @@ Requirements:
10682
10635
  language: options.language,
10683
10636
  librariesEnabled: options.librariesEnabled,
10684
10637
  libraries: options.libraries,
10685
- brandKitEnabled: options.brandKitEnabled,
10686
- primary: options.primary,
10687
- secondary: options.secondary,
10688
- title: options.title,
10689
- sub: options.sub,
10690
- fonts: options.fonts,
10691
10638
  }));
10692
10639
  } catch (error) {
10693
10640
  console.warn('[WidgetCreator] Could not store generation options', error);
@@ -10765,15 +10712,8 @@ Requirements:
10765
10712
  const storedLanguage = options?.language === 'svelte' || options?.language === 'react' ? options.language : null;
10766
10713
  widgetLanguage = languageToShow(widgetId, storedLanguage);
10767
10714
  librariesEnabled = !!options?.librariesEnabled;
10768
- brandKitLibraries = Array.isArray(options?.libraries) ? [...options.libraries] : [];
10769
- brandKitEnabled = !!options?.brandKitEnabled;
10770
- brandPrimary = options?.primary || '#314F2F';
10771
- brandSecondary = options?.secondary || '#7BA668';
10772
- brandTitle = options?.title || '#0F2010';
10773
- brandSub = options?.sub || '#5C6B58';
10774
- brandFonts = Array.isArray(options?.fonts) && options.fonts.length > 0 ? [...options.fonts] : ['Inter'];
10715
+ generationLibraries = Array.isArray(options?.libraries) ? [...options.libraries] : [];
10775
10716
  libraryUploads = inMemory?.libraryUploads ? inMemory.libraryUploads.map((file) => ({ ...file })) : [];
10776
- fontUploads = inMemory?.fontUploads ? inMemory.fontUploads.map((file) => ({ ...file })) : [];
10777
10717
  }
10778
10718
 
10779
10719
  function languageForGeneration(widgetId: string): 'svelte' | 'react' {
@@ -11101,15 +11041,11 @@ Requirements:
11101
11041
  const runtimeLogsForRequest = collectRuntimeLogsForCodegen(generationWidgetId);
11102
11042
  // The version the person chose to build on, when it is not the head, and the head they chose it on: the API refuses the
11103
11043
  // request, before it charges anything, when newer code was saved since (a teammate, another window).
11104
- // (Not with the token of an editor session, a partner's customer: the gateway's door for a session does not list these
11105
- // fields, nor the text documents, and refuses a request that has one of them, so they are left out of the request
11106
- // there. A Shopify store's token has no such door. See utils/generationRequestFields.ts.)
11107
- const mayNameVersionOrDocuments = mayNameVersionOrDocumentsInGeneration(authenticatedClientsToken);
11108
- const chosenBaseCommitSha =
11109
- options.compileFixOnly || !mayNameVersionOrDocuments ? null : generationBaseCommitSha(generationWidgetId);
11044
+ // Every kind of token sends them, the token of an editor session (a partner's customer) as well: the gateway's door
11045
+ // lists these fields and the text documents. See utils/generationRequestFields.ts.
11046
+ const chosenBaseCommitSha = options.compileFixOnly ? null : generationBaseCommitSha(generationWidgetId);
11110
11047
  const headTheVersionWasChosenOn = chosenBaseCommitSha ? shownHeadCommitSha(generationWidgetId) : null;
11111
11048
  const versionAndDocumentFields = generationVersionAndDocumentFields({
11112
- mayNameVersionOrDocuments,
11113
11049
  baseCommitSha: chosenBaseCommitSha,
11114
11050
  expectedHeadSha: headTheVersionWasChosenOn,
11115
11051
  textDocuments: options.forkUserMessage ? undefined : options.textDocuments,
@@ -11131,15 +11067,19 @@ Requirements:
11131
11067
  : undefined,
11132
11068
  images: imagesToSend,
11133
11069
  attachmentIds: attachmentIdsToSend,
11134
- // The text documents, the version to build on and the head it was chosen on: only the ones with something to say,
11135
- // and none with an editor session's token (see above)
11070
+ // The text documents, the version to build on and the head it was chosen on: only the ones with something to say
11136
11071
  ...versionAndDocumentFields,
11137
11072
  runtimeLogs: runtimeLogsForRequest,
11138
11073
  compileFixOnly: options.compileFixOnly === true,
11139
11074
  skipIntentGate: options.skipIntentGate === true,
11140
11075
  chipIntent: options.chipIntent,
11141
11076
  language: languageForGeneration(generationWidgetId),
11142
- brandKit: brandKitForRequest(),
11077
+ brandKit: brandKitForRequest({
11078
+ librariesEnabled,
11079
+ debugMode,
11080
+ libraries: generationLibraries,
11081
+ libraryUploads,
11082
+ }),
11143
11083
  ...(options.selectedElements && options.selectedElements.length > 0
11144
11084
  ? {
11145
11085
  selectedElements: options.selectedElements.map((el) => ({
@@ -19841,22 +19781,14 @@ $: if (codeGenerationPrompt && selectedWidgetId && promptLoadedForWidgetId === s
19841
19781
  />
19842
19782
  {/snippet}
19843
19783
  {#snippet generationOptionChecks()}
19844
- <BrandKitPanel
19784
+ <GenerationOptionsPanel
19845
19785
  part="checks"
19846
19786
  showPresetLibraries={debugMode}
19847
- suspendPickers={!!generatingWidgetIds[panelWidgetId]}
19848
- bind:brandKitEnabled
19849
19787
  bind:librariesEnabled
19850
- bind:libraries={brandKitLibraries}
19788
+ bind:libraries={generationLibraries}
19851
19789
  bind:libraryGitUrl
19852
19790
  bind:libraryFileName
19853
19791
  bind:libraryUploads
19854
- bind:fontUploads
19855
- bind:primary={brandPrimary}
19856
- bind:secondary={brandSecondary}
19857
- bind:title={brandTitle}
19858
- bind:sub={brandSub}
19859
- bind:fonts={brandFonts}
19860
19792
  showLanguage={debugMode}
19861
19793
  languageLocked={!!(generatingWidgetIds[panelWidgetId] || ps.lastCommitId || ps.lastPublishedVersion != null)}
19862
19794
  bind:language={widgetLanguage}
@@ -0,0 +1,216 @@
1
+ <!--
2
+ Generation options of the chat: the language of a new widget and, in debug mode, the preset and uploaded libraries.
3
+ The brand kit (colors, fonts, icons, spacing, corner radius and style notes) is not here: it belongs to the account
4
+ and is edited in the account settings, so every widget of that account uses it. (The `creator.brandKit.*` message
5
+ keys keep the name they had when this panel held the brand kit; they hold the texts of these options.)
6
+ -->
7
+
8
+ <script lang="ts">
9
+ import { DropdownMenu } from '@widgetic/design-system';
10
+ import FileUrlSourceControl from './FileUrlSourceControl.svelte';
11
+ import HoverTooltip from './HoverTooltip.svelte';
12
+ import { useCreatorLanguage } from '../i18n/index.js';
13
+
14
+ const { t } = useCreatorLanguage();
15
+
16
+ interface Props {
17
+ class?: string;
18
+ style?: string;
19
+ part?: 'checks' | 'panel';
20
+ librariesEnabled?: boolean;
21
+ showPresetLibraries?: boolean;
22
+ libraries?: string[];
23
+ libraryGitUrl?: string;
24
+ libraryFileName?: string;
25
+ libraryUploads?: { name: string; content: string; encoding: string }[];
26
+ showLanguage?: boolean;
27
+ language?: string;
28
+ languageLocked?: boolean;
29
+ }
30
+
31
+ let {
32
+ class: className = '',
33
+ style = '',
34
+ part = 'checks',
35
+ librariesEnabled = $bindable(false),
36
+ showPresetLibraries = false,
37
+ libraries = $bindable([] as string[]),
38
+ libraryGitUrl = $bindable(''),
39
+ libraryFileName = $bindable(''),
40
+ libraryUploads = $bindable([] as { name: string; content: string; encoding: string }[]),
41
+ showLanguage = false,
42
+ language = $bindable('react'),
43
+ languageLocked = false,
44
+ }: Props = $props();
45
+
46
+ const libraryChoices = [
47
+ { id: 'chart.js/auto', label: 'Chart.js' },
48
+ { id: 'd3', label: 'D3' },
49
+ { id: 'gsap', label: 'GSAP' },
50
+ { id: 'three', label: 'Three.js' },
51
+ ];
52
+
53
+ function toggleLibrary(id: string) {
54
+ const next = libraries.includes(id)
55
+ ? libraries.filter((entry) => entry !== id)
56
+ : [...libraries, id];
57
+ libraries = next;
58
+ if (next.length > 0) librariesEnabled = true;
59
+ }
60
+
61
+ type SourceRow = { id: string; fileName: string; url: string; content: string; encoding: string };
62
+ const emptySource = (): SourceRow => ({
63
+ id: crypto.randomUUID(),
64
+ fileName: '',
65
+ url: '',
66
+ content: '',
67
+ encoding: 'utf8',
68
+ });
69
+ let libraryRows = $state<SourceRow[]>([emptySource()]);
70
+
71
+ function addSourceRow() {
72
+ if (libraryRows.length >= 4) return;
73
+ libraryRows = [emptySource(), ...libraryRows];
74
+ }
75
+
76
+ function removeSourceRow(id: string) {
77
+ const next = libraryRows.filter((row) => row.id !== id);
78
+ libraryRows = next.length > 0 ? next : [emptySource()];
79
+ }
80
+
81
+ function onLibrariesChange(event: Event) {
82
+ librariesEnabled = (event.currentTarget as HTMLInputElement).checked;
83
+ }
84
+
85
+ function componentExtension() {
86
+ return language === 'react' ? '.jsx' : '.svelte';
87
+ }
88
+
89
+ function sourceAccept() {
90
+ return ['.js', '.ts', componentExtension(), '.zip', '.tar', '.tgz', '.gz'].join(',');
91
+ }
92
+
93
+ $effect(() => {
94
+ libraryFileName = libraryRows[0]?.fileName || '';
95
+ libraryGitUrl = libraryRows[0]?.url || '';
96
+ libraryUploads = libraryRows
97
+ .filter((row) => row.fileName && row.content)
98
+ .map((row) => ({ name: row.fileName, content: row.content, encoding: row.encoding }));
99
+ });
100
+ </script>
101
+
102
+ {#if part === 'checks'}
103
+ <div class="generation-options-checks contents {className}" {style}>
104
+ {#if showLanguage || showPresetLibraries}
105
+ <div class="generation-libraries-row ms-auto flex w-full flex-col gap-2">
106
+ <div class="generation-libraries-checks flex flex-nowrap items-center gap-1">
107
+ {#if showLanguage}
108
+ {#if languageLocked}
109
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.languageIsFixedAfterThe')}>
110
+ <span
111
+ class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-default items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900 opacity-60"
112
+ aria-disabled="true"
113
+ >
114
+ <span class="truncate">{language === 'react' ? 'React' : 'Svelte'}</span>
115
+ </span>
116
+ </HoverTooltip>
117
+ {:else}
118
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.selectLanguage')}>
119
+ <DropdownMenu.Root>
120
+ <DropdownMenu.Trigger
121
+ class="generation-language-select flex h-10 w-[4.75rem] shrink-0 cursor-pointer items-center justify-between gap-0.5 rounded-lg border border-gray-300 bg-white px-1.5 text-sm text-gray-900"
122
+ >
123
+ <span class="truncate">{language === 'react' ? 'React' : 'Svelte'}</span>
124
+ <svg class="h-3 w-3 shrink-0 text-gray-500" viewBox="0 0 12 12" fill="none" aria-hidden="true">
125
+ <path d="M3 4.5 6 7.5 9 4.5" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" />
126
+ </svg>
127
+ </DropdownMenu.Trigger>
128
+ <DropdownMenu.Content class="w-[4.75rem] min-w-0">
129
+ <DropdownMenu.Item
130
+ class="cursor-pointer {language === 'svelte' ? 'bg-[#314F2F]/15 text-[#314F2F]' : ''}"
131
+ onSelect={() => (language = 'svelte')}
132
+ >Svelte</DropdownMenu.Item>
133
+ <DropdownMenu.Item
134
+ class="cursor-pointer {language === 'react' ? 'bg-[#314F2F]/15 text-[#314F2F]' : ''}"
135
+ onSelect={() => (language = 'react')}
136
+ >React</DropdownMenu.Item>
137
+ </DropdownMenu.Content>
138
+ </DropdownMenu.Root>
139
+ </HoverTooltip>
140
+ {/if}
141
+ {/if}
142
+ {#if showPresetLibraries}
143
+ <label class="generation-option-toggle flex h-10 shrink-0 cursor-pointer items-center gap-1.5 rounded-lg border px-2 text-sm {librariesEnabled ? 'border-[#314F2F] bg-[#314F2F] text-white' : 'border-gray-300 bg-white text-gray-800'}">
144
+ <input class="generation-option-check cursor-pointer" type="checkbox" checked={librariesEnabled} onchange={onLibrariesChange} />
145
+ {$t('creator.brandKit.libraries')}
146
+ </label>
147
+ {/if}
148
+ {#if librariesEnabled && showPresetLibraries}
149
+ {#each libraryChoices as choice (choice.id)}
150
+ <label class="generation-library flex items-center gap-1 text-xs text-gray-700">
151
+ <input
152
+ class="generation-library-check cursor-pointer"
153
+ type="checkbox"
154
+ checked={libraries.includes(choice.id)}
155
+ onchange={() => toggleLibrary(choice.id)}
156
+ />
157
+ {choice.label}
158
+ </label>
159
+ {/each}
160
+ {/if}
161
+ {#if librariesEnabled && showPresetLibraries}
162
+ <HoverTooltip class="inline-flex shrink-0" text={$t('creator.brandKit.addLibrary')}>
163
+ <button
164
+ type="button"
165
+ class="generation-library-add flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 bg-white text-sm text-gray-800"
166
+ aria-label={$t('creator.brandKit.addLibrary')}
167
+ onclick={addSourceRow}
168
+ >+</button>
169
+ </HoverTooltip>
170
+ {/if}
171
+ </div>
172
+ {#if librariesEnabled && showPresetLibraries}
173
+ {#each libraryRows as row (row.id)}
174
+ <div class="generation-source-row flex items-center gap-1">
175
+ <FileUrlSourceControl
176
+ class="min-w-0 flex-1"
177
+ bind:fileName={row.fileName}
178
+ bind:fileContent={row.content}
179
+ bind:fileEncoding={row.encoding}
180
+ bind:url={row.url}
181
+ fileLabel={$t('creator.brandKit.uploadLibrary')}
182
+ fileTitle={$t('creator.brandKit.uploadCustomLibraryTooltip')}
183
+ urlPlaceholder={$t('creator.brandKit.urlLibraries', { extension: componentExtension() })}
184
+ accept={sourceAccept()}
185
+ />
186
+ {#if libraryRows.length > 1}
187
+ <button
188
+ type="button"
189
+ class="generation-source-remove flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-300 text-gray-500"
190
+ aria-label={$t('creator.brandKit.removeLibrary')}
191
+ onclick={() => removeSourceRow(row.id)}
192
+ >
193
+ <svg class="h-3.5 w-3.5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true">
194
+ <path d="M4 7h16" />
195
+ <path d="M9 7V5h6v2" />
196
+ <path d="M8 7l1 13h6l1-13" />
197
+ </svg>
198
+ </button>
199
+ {/if}
200
+ </div>
201
+ {/each}
202
+ {/if}
203
+ </div>
204
+ {/if}
205
+ </div>
206
+ {/if}
207
+
208
+ <style>
209
+ .generation-options-checks input:focus,
210
+ .generation-options-checks input:focus-visible,
211
+ .generation-language-select:focus,
212
+ .generation-language-select:focus-visible {
213
+ outline: none;
214
+ box-shadow: none;
215
+ }
216
+ </style>
@@ -0,0 +1,21 @@
1
+ interface Props {
2
+ class?: string;
3
+ style?: string;
4
+ part?: 'checks' | 'panel';
5
+ librariesEnabled?: boolean;
6
+ showPresetLibraries?: boolean;
7
+ libraries?: string[];
8
+ libraryGitUrl?: string;
9
+ libraryFileName?: string;
10
+ libraryUploads?: {
11
+ name: string;
12
+ content: string;
13
+ encoding: string;
14
+ }[];
15
+ showLanguage?: boolean;
16
+ language?: string;
17
+ languageLocked?: boolean;
18
+ }
19
+ declare const GenerationOptionsPanel: import("svelte").Component<Props, {}, "librariesEnabled" | "libraries" | "libraryGitUrl" | "libraryFileName" | "libraryUploads" | "language">;
20
+ type GenerationOptionsPanel = ReturnType<typeof GenerationOptionsPanel>;
21
+ export default GenerationOptionsPanel;
@@ -4194,12 +4194,6 @@
4194
4194
  .widget-details-dock-right :global(.action-label) {
4195
4195
  font-size: 0.7rem;
4196
4196
  }
4197
- .widget-details-dock-right :global(.generation-brand-kit-toggle) {
4198
- height: 2rem;
4199
- gap: 0.3rem;
4200
- padding-inline: 0.4rem;
4201
- font-size: 0.75rem;
4202
- }
4203
4197
  .widget-details-create-models-ct :global(button:focus),
4204
4198
  .widget-details-create-models-ct :global(button:focus-visible),
4205
4199
  .widget-details-create-models-ct :global(select:focus),
@@ -0,0 +1,16 @@
1
+ /** Payload shape for POST /code/generate `brandKit` (account-level colors/fonts live on the gateway; chat only sends libraries). */
2
+ export type BrandKitUpload = {
3
+ name: string;
4
+ content: string;
5
+ encoding: string;
6
+ };
7
+ export type GenerationBrandKit = {
8
+ libraries?: string[];
9
+ uploads?: BrandKitUpload[];
10
+ };
11
+ export declare function brandKitForRequest(options: {
12
+ librariesEnabled: boolean;
13
+ debugMode: boolean;
14
+ libraries: string[];
15
+ libraryUploads: BrandKitUpload[];
16
+ }): GenerationBrandKit | undefined;
@@ -0,0 +1,12 @@
1
+ /** Payload shape for POST /code/generate `brandKit` (account-level colors/fonts live on the gateway; chat only sends libraries). */
2
+ export function brandKitForRequest(options) {
3
+ const kit = {};
4
+ // Preset libraries are a debug test. An empty list is an explicit ban.
5
+ if (options.librariesEnabled && options.debugMode)
6
+ kit.libraries = [...options.libraries];
7
+ if (options.libraryUploads.length > 0)
8
+ kit.uploads = options.libraryUploads.map((file) => ({ ...file }));
9
+ if (kit.libraries === undefined && kit.uploads === undefined)
10
+ return undefined;
11
+ return kit;
12
+ }
@@ -100,27 +100,6 @@ 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
- * What the token of an editor session starts with: the credential a partner mints for one of its customers' browsers (the
105
- * gateway's `EDITOR_SESSION_TOKEN_PREFIX`, and the way it tells a session from any other token as well).
106
- */
107
- export declare const EDITOR_SESSION_TOKEN_PREFIX = "wgt_ses_";
108
- /** Whether the token is an editor session's. A Shopify store's session token, a person's login and an API key are not. */
109
- export declare function isEditorSessionToken(token: string | null | undefined): boolean;
110
- /**
111
- * Whether a generation request (`POST /agent/code/generate`) may name the older version to build on (`baseCommitSha`), the
112
- * head the person chose it on (`expectedHeadSha`), and the words of the text documents attached to the message
113
- * (`textDocuments`). None of the three is on the gateway's allow-list for an editor session (what a partner's customer
114
- * works with): its door refuses a request that has a field it does not list, whatever the field's value (even
115
- * `baseCommitSha: null`), so one that carried any of them would be refused whole and the visitor could not generate at all.
116
- * With a session's token the creator leaves the three out, and the AI builds on the latest code from the message alone, as it
117
- * did before the API client knew the fields (it dropped them without a word).
118
- *
119
- * It is the token that decides, not partner mode: a Shopify store's page is in partner mode too (the page handed the creator a
120
- * token), but its token is a Shopify session, which has no such door, and the team of a store is exactly who the head check
121
- * protects. `utils/generationRequestFields.ts` is where the request is built from the answer.
122
- */
123
- export declare function mayNameVersionOrDocumentsInGeneration(token: string | null | undefined): boolean;
124
103
  /** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
125
104
  export declare function mayListenToSiteEvents(): boolean;
126
105
  /**
@@ -108,33 +108,6 @@ export function mayShowAccountBilling() {
108
108
  export function maySuggestWidgetName() {
109
109
  return !state.partnerMode;
110
110
  }
111
- /**
112
- * What the token of an editor session starts with: the credential a partner mints for one of its customers' browsers (the
113
- * gateway's `EDITOR_SESSION_TOKEN_PREFIX`, and the way it tells a session from any other token as well).
114
- */
115
- export const EDITOR_SESSION_TOKEN_PREFIX = 'wgt_ses_';
116
- /** Whether the token is an editor session's. A Shopify store's session token, a person's login and an API key are not. */
117
- export function isEditorSessionToken(token) {
118
- if (typeof token !== 'string')
119
- return false;
120
- return token.replace(/^Bearer\s+/i, '').trim().startsWith(EDITOR_SESSION_TOKEN_PREFIX);
121
- }
122
- /**
123
- * Whether a generation request (`POST /agent/code/generate`) may name the older version to build on (`baseCommitSha`), the
124
- * head the person chose it on (`expectedHeadSha`), and the words of the text documents attached to the message
125
- * (`textDocuments`). None of the three is on the gateway's allow-list for an editor session (what a partner's customer
126
- * works with): its door refuses a request that has a field it does not list, whatever the field's value (even
127
- * `baseCommitSha: null`), so one that carried any of them would be refused whole and the visitor could not generate at all.
128
- * With a session's token the creator leaves the three out, and the AI builds on the latest code from the message alone, as it
129
- * did before the API client knew the fields (it dropped them without a word).
130
- *
131
- * It is the token that decides, not partner mode: a Shopify store's page is in partner mode too (the page handed the creator a
132
- * token), but its token is a Shopify session, which has no such door, and the team of a store is exactly who the head check
133
- * protects. `utils/generationRequestFields.ts` is where the request is built from the answer.
134
- */
135
- export function mayNameVersionOrDocumentsInGeneration(token) {
136
- return !isEditorSessionToken(token);
137
- }
138
111
  /** Whether the creator may take part in the page-wide `widgetic:*` events it exchanges with the Widgetic site's own page chrome. */
139
112
  export function mayListenToSiteEvents() {
140
113
  return !state.partnerMode;