@widgetic/creator 0.4.36 → 0.4.38
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 +241 -27
- package/dist/components/BrandKitPanel.svelte +585 -0
- package/dist/components/BrandKitPanel.svelte.d.ts +34 -0
- package/dist/components/FileUrlSourceControl.svelte.d.ts +1 -1
- package/dist/components/VersionDropdownRow.svelte +1 -19
- package/dist/components/WidgetDetails.svelte.d.ts +1 -1
- package/dist/components/WidgetElementSelector.svelte +149 -33
- package/dist/components/WidgetElementSelector.svelte.d.ts +1 -0
- package/dist/components/WidgetShapeLivePreviews.svelte +9 -2
- package/dist/components/WidgetShapeLivePreviews.svelte.d.ts +4 -0
- package/dist/generation/brandKitForRequest.d.ts +17 -0
- package/dist/generation/brandKitForRequest.js +18 -1
- package/dist/host/creatorHost.d.ts +7 -0
- package/dist/host/creatorHost.js +9 -0
- package/dist/i18n/language.d.ts +174 -5
- package/dist/i18n/messages.d.ts +27 -1
- package/dist/i18n/messages.js +27 -1
- package/dist/i18n/statusText.js +4 -0
- package/dist/pageHelpers.d.ts +2 -0
- package/dist/pageHelpers.js +10 -0
- package/dist/stores/websocketStore.d.ts +9 -0
- package/dist/stores/websocketStore.js +20 -0
- package/dist/utils/versionRatings.d.ts +65 -0
- package/dist/utils/versionRatings.js +97 -0
- package/dist/utils/widgetElementSelector.d.ts +6 -0
- package/dist/utils/widgetElementSelector.js +23 -0
- package/package.json +3 -3
- package/dist/components/GenerationOptionsPanel.svelte +0 -216
- package/dist/components/GenerationOptionsPanel.svelte.d.ts +0 -21
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
parentToPick,
|
|
8
8
|
serializePickedElement,
|
|
9
9
|
computeChipPlacement,
|
|
10
|
-
FALLBACK_PICKER_BRIDGE_SCRIPT
|
|
10
|
+
FALLBACK_PICKER_BRIDGE_SCRIPT,
|
|
11
|
+
pageScriptNonce,
|
|
12
|
+
stampScriptsWithNonce
|
|
11
13
|
} from '../utils/widgetElementSelector';
|
|
12
14
|
import { useCreatorLanguage } from '../i18n/index.js';
|
|
13
15
|
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
selectedElements?: SelectedWidgetElementReference[];
|
|
24
26
|
onSelectElement?: (element: SelectedWidgetElementReference) => void;
|
|
25
27
|
onRemoveElement?: (id: string) => void;
|
|
28
|
+
onUpdateElementNote?: (id: string, note: string) => void;
|
|
26
29
|
onCloseSelector?: () => void;
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -36,6 +39,7 @@
|
|
|
36
39
|
selectedElements = [],
|
|
37
40
|
onSelectElement,
|
|
38
41
|
onRemoveElement,
|
|
42
|
+
onUpdateElementNote,
|
|
39
43
|
onCloseSelector
|
|
40
44
|
}: Props = $props();
|
|
41
45
|
|
|
@@ -52,6 +56,13 @@
|
|
|
52
56
|
|
|
53
57
|
let pingTimer: ReturnType<typeof setTimeout> | null = null;
|
|
54
58
|
let lastPointerPosition = { x: 0, y: 0 };
|
|
59
|
+
let dragOrigin = $state<{ x: number; y: number } | null>(null);
|
|
60
|
+
let dragRect = $state<{ x: number; y: number; width: number; height: number } | null>(null);
|
|
61
|
+
let dragMoved = false;
|
|
62
|
+
let suppressNextClick = false;
|
|
63
|
+
|
|
64
|
+
const DRAG_START_PX = 6;
|
|
65
|
+
const AREA_MIN_PX = 8;
|
|
55
66
|
|
|
56
67
|
function getDirectDocument(): Document | null {
|
|
57
68
|
if (fallbackIframeRef?.contentDocument?.body) {
|
|
@@ -104,7 +115,7 @@
|
|
|
104
115
|
const withBridge = withBase.includes('</body>')
|
|
105
116
|
? withBase.replace('</body>', `${FALLBACK_PICKER_BRIDGE_SCRIPT}\n</body>`)
|
|
106
117
|
: `${withBase}\n${FALLBACK_PICKER_BRIDGE_SCRIPT}`;
|
|
107
|
-
fallbackSrcdoc = withBridge;
|
|
118
|
+
fallbackSrcdoc = stampScriptsWithNonce(withBridge, pageScriptNonce());
|
|
108
119
|
bridgeReady = true;
|
|
109
120
|
} catch (error) {
|
|
110
121
|
console.warn('[WidgetElementSelector] Fallback srcdoc fetch failed:', error);
|
|
@@ -192,37 +203,35 @@
|
|
|
192
203
|
};
|
|
193
204
|
}
|
|
194
205
|
|
|
195
|
-
function
|
|
196
|
-
if (!enabled || passthroughHeld) return;
|
|
197
|
-
const surface = event.currentTarget as HTMLElement;
|
|
206
|
+
function pointOnSurface(event: PointerEvent, surface: HTMLElement) {
|
|
198
207
|
const bounds = surface.getBoundingClientRect();
|
|
199
208
|
const scaleX = bounds.width > 0 ? viewportWidth / bounds.width : 1;
|
|
200
209
|
const scaleY = bounds.height > 0 ? viewportHeight / bounds.height : 1;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (!runDirectHitTest(localX, localY)) {
|
|
206
|
-
postToTargetIframe({
|
|
207
|
-
type: 'widgetic:picker-hit-test',
|
|
208
|
-
x: localX,
|
|
209
|
-
y: localY
|
|
210
|
-
});
|
|
211
|
-
}
|
|
210
|
+
return {
|
|
211
|
+
x: (event.clientX - bounds.left) * scaleX,
|
|
212
|
+
y: (event.clientY - bounds.top) * scaleY,
|
|
213
|
+
};
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
function
|
|
215
|
-
|
|
216
|
-
directHoveredNode = null;
|
|
217
|
-
directCurrentNode = null;
|
|
218
|
-
directDescendants = [];
|
|
216
|
+
function newSelectionId() {
|
|
217
|
+
return `sel_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
|
|
219
218
|
}
|
|
220
219
|
|
|
221
|
-
function
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
220
|
+
function selectArea(rect: { x: number; y: number; width: number; height: number }) {
|
|
221
|
+
const width = Math.round(rect.width);
|
|
222
|
+
const height = Math.round(rect.height);
|
|
223
|
+
console.log('[WidgetElementSelector] Area selected', width, height);
|
|
224
|
+
onSelectElement?.(rememberFrame({
|
|
225
|
+
id: newSelectionId(),
|
|
226
|
+
tagName: 'area',
|
|
227
|
+
selector: '',
|
|
228
|
+
label: `area ${width}×${height}`,
|
|
229
|
+
rect,
|
|
230
|
+
textSnippet: '',
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
225
233
|
|
|
234
|
+
function selectAtPoint() {
|
|
226
235
|
const doc = getDirectDocument();
|
|
227
236
|
if (doc) {
|
|
228
237
|
let target = directCurrentNode;
|
|
@@ -231,28 +240,112 @@
|
|
|
231
240
|
target = rawHit ? pickTarget(rawHit) : null;
|
|
232
241
|
}
|
|
233
242
|
if (target) {
|
|
234
|
-
|
|
235
|
-
onSelectElement?.(rememberFrame(selectedRef));
|
|
243
|
+
onSelectElement?.(rememberFrame(serializePickedElement(target)));
|
|
236
244
|
}
|
|
237
245
|
return;
|
|
238
246
|
}
|
|
239
247
|
|
|
240
248
|
if (hoveredElement) {
|
|
241
|
-
|
|
249
|
+
onSelectElement?.(rememberFrame({
|
|
242
250
|
...hoveredElement,
|
|
243
|
-
id:
|
|
244
|
-
};
|
|
245
|
-
onSelectElement?.(rememberFrame(selectedRef));
|
|
251
|
+
id: newSelectionId(),
|
|
252
|
+
}));
|
|
246
253
|
return;
|
|
247
254
|
}
|
|
248
255
|
|
|
249
256
|
postToTargetIframe({
|
|
250
257
|
type: 'widgetic:picker-select',
|
|
251
258
|
x: lastPointerPosition.x,
|
|
252
|
-
y: lastPointerPosition.y
|
|
259
|
+
y: lastPointerPosition.y,
|
|
253
260
|
});
|
|
254
261
|
}
|
|
255
262
|
|
|
263
|
+
function handlePointerDown(event: PointerEvent) {
|
|
264
|
+
if (!enabled || passthroughHeld || event.button !== 0) return;
|
|
265
|
+
const surface = event.currentTarget as HTMLElement;
|
|
266
|
+
try {
|
|
267
|
+
surface.setPointerCapture(event.pointerId);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
console.warn('[WidgetElementSelector] Pointer capture failed', error);
|
|
270
|
+
}
|
|
271
|
+
const point = pointOnSurface(event, surface);
|
|
272
|
+
dragOrigin = point;
|
|
273
|
+
dragRect = null;
|
|
274
|
+
dragMoved = false;
|
|
275
|
+
lastPointerPosition = point;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function handlePointerMove(event: PointerEvent) {
|
|
279
|
+
if (!enabled || passthroughHeld) return;
|
|
280
|
+
const surface = event.currentTarget as HTMLElement;
|
|
281
|
+
const point = pointOnSurface(event, surface);
|
|
282
|
+
lastPointerPosition = point;
|
|
283
|
+
|
|
284
|
+
if (dragOrigin) {
|
|
285
|
+
const deltaX = point.x - dragOrigin.x;
|
|
286
|
+
const deltaY = point.y - dragOrigin.y;
|
|
287
|
+
if (Math.hypot(deltaX, deltaY) > DRAG_START_PX) {
|
|
288
|
+
dragMoved = true;
|
|
289
|
+
dragRect = {
|
|
290
|
+
x: Math.min(dragOrigin.x, point.x),
|
|
291
|
+
y: Math.min(dragOrigin.y, point.y),
|
|
292
|
+
width: Math.abs(deltaX),
|
|
293
|
+
height: Math.abs(deltaY),
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
if (dragMoved) return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const localX = point.x;
|
|
300
|
+
const localY = point.y;
|
|
301
|
+
if (!runDirectHitTest(localX, localY)) {
|
|
302
|
+
postToTargetIframe({
|
|
303
|
+
type: 'widgetic:picker-hit-test',
|
|
304
|
+
x: localX,
|
|
305
|
+
y: localY
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
function handlePointerUp(event: PointerEvent) {
|
|
311
|
+
if (!dragOrigin) return;
|
|
312
|
+
const moved = dragMoved;
|
|
313
|
+
const rect = dragRect;
|
|
314
|
+
dragOrigin = null;
|
|
315
|
+
dragRect = null;
|
|
316
|
+
dragMoved = false;
|
|
317
|
+
if (!enabled || passthroughHeld) return;
|
|
318
|
+
if (moved && rect && rect.width >= AREA_MIN_PX && rect.height >= AREA_MIN_PX) {
|
|
319
|
+
suppressNextClick = true;
|
|
320
|
+
event.preventDefault();
|
|
321
|
+
event.stopPropagation();
|
|
322
|
+
selectArea(rect);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (!moved) {
|
|
326
|
+
suppressNextClick = true;
|
|
327
|
+
event.preventDefault();
|
|
328
|
+
event.stopPropagation();
|
|
329
|
+
selectAtPoint();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
function handlePointerLeave() {
|
|
334
|
+
if (dragOrigin) return;
|
|
335
|
+
hoveredElement = null;
|
|
336
|
+
directHoveredNode = null;
|
|
337
|
+
directCurrentNode = null;
|
|
338
|
+
directDescendants = [];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function handleOverlayClick(event: MouseEvent) {
|
|
342
|
+
if (suppressNextClick) {
|
|
343
|
+
suppressNextClick = false;
|
|
344
|
+
event.preventDefault();
|
|
345
|
+
event.stopPropagation();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
256
349
|
function walkHierarchy(direction: 'up' | 'down') {
|
|
257
350
|
const doc = getDirectDocument();
|
|
258
351
|
if (doc && directCurrentNode) {
|
|
@@ -405,13 +498,27 @@
|
|
|
405
498
|
style="left: {box.x}px; top: {box.y}px; width: {box.width}px; height: {box.height}px; /* rtl-ok: DOM element bounding box is measured from the left edge of the widget frame */"
|
|
406
499
|
></div>
|
|
407
500
|
<div
|
|
408
|
-
class="pointer-events-auto absolute z-[38] flex max-w-[
|
|
501
|
+
class="pointer-events-auto absolute z-[38] flex w-max max-w-[min(100%-8px,520px)] items-center gap-1.5 whitespace-nowrap rounded-full border border-[#7BA668]/45 bg-[#0F2010] px-2.5 py-1 font-mono text-[11px] font-medium leading-none text-[#A5CE8F] shadow-md"
|
|
409
502
|
style="left: {chipPos.left}px; top: {chipPos.top}px; /* rtl-ok: chip position is measured from the left edge of the widget frame */"
|
|
410
503
|
>
|
|
411
504
|
<span class="flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-[#7BA668] font-sans text-[10px] font-bold text-white">
|
|
412
505
|
{index + 1}
|
|
413
506
|
</span>
|
|
414
507
|
<span class="truncate">{item.label}</span>
|
|
508
|
+
{#if onUpdateElementNote}
|
|
509
|
+
<input
|
|
510
|
+
class="selector-note ms-1 h-6 w-40 shrink-0 rounded border border-white/20 bg-black/30 px-1.5 font-sans text-[11px] leading-4 text-white outline-none focus:border-[#A5CE8F] focus:outline-none"
|
|
511
|
+
type="text"
|
|
512
|
+
placeholder={$t('creator.elementSelector.notePlaceholder')}
|
|
513
|
+
value={item.note ?? ''}
|
|
514
|
+
aria-label={$t('creator.elementSelector.notePlaceholder')}
|
|
515
|
+
tabindex="-1"
|
|
516
|
+
onpointerdown={(event) => event.stopPropagation()}
|
|
517
|
+
onclick={(event) => event.stopPropagation()}
|
|
518
|
+
onkeydown={(event) => event.stopPropagation()}
|
|
519
|
+
oninput={(event) => onUpdateElementNote?.(item.id, event.currentTarget.value)}
|
|
520
|
+
/>
|
|
521
|
+
{/if}
|
|
415
522
|
{#if onRemoveElement}
|
|
416
523
|
<button
|
|
417
524
|
type="button"
|
|
@@ -436,7 +543,9 @@
|
|
|
436
543
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
437
544
|
<div
|
|
438
545
|
class=" absolute inset-0 z-[36] select-none {passthroughHeld ? 'pointer-events-none' : 'pointer-events-auto cursor-crosshair'}"
|
|
546
|
+
onpointerdown={handlePointerDown}
|
|
439
547
|
onpointermove={handlePointerMove}
|
|
548
|
+
onpointerup={handlePointerUp}
|
|
440
549
|
onpointerleave={handlePointerLeave}
|
|
441
550
|
onclick={handleOverlayClick}
|
|
442
551
|
data-testid="widget-element-selector-overlay"
|
|
@@ -472,6 +581,13 @@
|
|
|
472
581
|
{/if}
|
|
473
582
|
{/if}
|
|
474
583
|
|
|
584
|
+
{#if dragRect && dragRect.width > 0 && dragRect.height > 0}
|
|
585
|
+
<div
|
|
586
|
+
class="selector-drag-box pointer-events-none absolute z-[37] border-2 border-solid border-[#5E8C4A] bg-[#7BA668]/20"
|
|
587
|
+
style="left: {dragRect.x}px; top: {dragRect.y}px; width: {dragRect.width}px; height: {dragRect.height}px; /* rtl-ok: the area being dragged is measured from the left edge of the widget frame, like the element boxes above */"
|
|
588
|
+
></div>
|
|
589
|
+
{/if}
|
|
590
|
+
|
|
475
591
|
</div>
|
|
476
592
|
{/if}
|
|
477
593
|
{/if}
|
|
@@ -9,6 +9,7 @@ interface Props {
|
|
|
9
9
|
selectedElements?: SelectedWidgetElementReference[];
|
|
10
10
|
onSelectElement?: (element: SelectedWidgetElementReference) => void;
|
|
11
11
|
onRemoveElement?: (id: string) => void;
|
|
12
|
+
onUpdateElementNote?: (id: string, note: string) => void;
|
|
12
13
|
onCloseSelector?: () => void;
|
|
13
14
|
}
|
|
14
15
|
declare const WidgetElementSelector: import("svelte").Component<Props, {}, "">;
|
|
@@ -103,12 +103,16 @@
|
|
|
103
103
|
onCommandClickPreview?: ((widgetId: string) => void) | null;
|
|
104
104
|
/** Whether the interactive DOM Element Selector is active for this widget. */
|
|
105
105
|
resolveSelectorEnabled?: ((widgetId: string) => boolean) | null;
|
|
106
|
+
/** The note under the shape. Off when that note sits in the canvas toolbar instead. */
|
|
107
|
+
showUnderShapeSelectorHint?: boolean;
|
|
106
108
|
/** Selected widget elements currently referenced in the chat panel for this widget. */
|
|
107
109
|
resolveSelectedElements?: ((widgetId: string) => SelectedWidgetElementReference[]) | null;
|
|
108
110
|
/** Fired when the user clicks a widget part in Selector mode. */
|
|
109
111
|
onSelectWidgetElement?: ((widgetId: string, element: SelectedWidgetElementReference) => void) | null;
|
|
110
112
|
/** Fired when the user removes a selected element chip from the canvas overlay. */
|
|
111
113
|
onRemoveWidgetElement?: ((widgetId: string, elementId: string) => void) | null;
|
|
114
|
+
/** A note typed beside a pick or a drawn box. */
|
|
115
|
+
onUpdateWidgetElementNote?: ((widgetId: string, elementId: string, note: string) => void) | null;
|
|
112
116
|
/** Fired when the user presses Escape in Selector mode. */
|
|
113
117
|
onCloseWidgetSelector?: ((widgetId: string) => void) | null;
|
|
114
118
|
}
|
|
@@ -151,9 +155,11 @@
|
|
|
151
155
|
onLiveFrameShown = null,
|
|
152
156
|
showChrome = true,
|
|
153
157
|
resolveSelectorEnabled = null,
|
|
158
|
+
showUnderShapeSelectorHint = true,
|
|
154
159
|
resolveSelectedElements = null,
|
|
155
160
|
onSelectWidgetElement = null,
|
|
156
161
|
onRemoveWidgetElement = null,
|
|
162
|
+
onUpdateWidgetElementNote = null,
|
|
157
163
|
onCloseWidgetSelector = null,
|
|
158
164
|
onCommandClickPreview = null,
|
|
159
165
|
}: Props = $props();
|
|
@@ -1167,6 +1173,7 @@
|
|
|
1167
1173
|
selectedElements={resolveSelectedElements?.(overlay.widgetId) ?? []}
|
|
1168
1174
|
onSelectElement={(element) => onSelectWidgetElement?.(overlay.widgetId, element)}
|
|
1169
1175
|
onRemoveElement={(elementId) => onRemoveWidgetElement?.(overlay.widgetId, elementId)}
|
|
1176
|
+
onUpdateElementNote={(elementId, note) => onUpdateWidgetElementNote?.(overlay.widgetId, elementId, note)}
|
|
1170
1177
|
onCloseSelector={() => onCloseWidgetSelector?.(overlay.widgetId)}
|
|
1171
1178
|
/>
|
|
1172
1179
|
</div>
|
|
@@ -1200,7 +1207,7 @@
|
|
|
1200
1207
|
></div>
|
|
1201
1208
|
{/if}
|
|
1202
1209
|
</div>
|
|
1203
|
-
{#if resolveSelectorEnabled?.(overlay.widgetId)}
|
|
1210
|
+
{#if resolveSelectorEnabled?.(overlay.widgetId) && showUnderShapeSelectorHint}
|
|
1204
1211
|
<div
|
|
1205
1212
|
class="widget-shape-selector-hint pointer-events-none fixed z-[70] flex justify-center"
|
|
1206
1213
|
style="left: {overlay.left}px; top: {overlay.top + (overlay.localHeight ?? overlay.height) + 8}px; width: {chromeWidth}px; /* rtl-ok: centered on the shape, under it, the same way the bar sits above */"
|
|
@@ -1249,7 +1256,7 @@
|
|
|
1249
1256
|
selected={selectedVersion?.id === option.id}
|
|
1250
1257
|
busy={optionBusy}
|
|
1251
1258
|
publishDisabled={optionPublishDisabled}
|
|
1252
|
-
publishDisabledReason={optionPublishReason || $t('creator.
|
|
1259
|
+
publishDisabledReason={optionPublishReason || $t('creator.livePreviews.publishThisDraft')}
|
|
1253
1260
|
setLiveDisabled={settingLiveVersion === optionVersion}
|
|
1254
1261
|
onselect={() => selectVersionFromMenu(overlay.widgetId, option.id)}
|
|
1255
1262
|
onpublish={() => handlePublishDraftClickFromMenu(overlay.widgetId, option.id)}
|
|
@@ -102,12 +102,16 @@ interface Props {
|
|
|
102
102
|
onCommandClickPreview?: ((widgetId: string) => void) | null;
|
|
103
103
|
/** Whether the interactive DOM Element Selector is active for this widget. */
|
|
104
104
|
resolveSelectorEnabled?: ((widgetId: string) => boolean) | null;
|
|
105
|
+
/** The note under the shape. Off when that note sits in the canvas toolbar instead. */
|
|
106
|
+
showUnderShapeSelectorHint?: boolean;
|
|
105
107
|
/** Selected widget elements currently referenced in the chat panel for this widget. */
|
|
106
108
|
resolveSelectedElements?: ((widgetId: string) => SelectedWidgetElementReference[]) | null;
|
|
107
109
|
/** Fired when the user clicks a widget part in Selector mode. */
|
|
108
110
|
onSelectWidgetElement?: ((widgetId: string, element: SelectedWidgetElementReference) => void) | null;
|
|
109
111
|
/** Fired when the user removes a selected element chip from the canvas overlay. */
|
|
110
112
|
onRemoveWidgetElement?: ((widgetId: string, elementId: string) => void) | null;
|
|
113
|
+
/** A note typed beside a pick or a drawn box. */
|
|
114
|
+
onUpdateWidgetElementNote?: ((widgetId: string, elementId: string, note: string) => void) | null;
|
|
111
115
|
/** Fired when the user presses Escape in Selector mode. */
|
|
112
116
|
onCloseWidgetSelector?: ((widgetId: string) => void) | null;
|
|
113
117
|
}
|
|
@@ -5,12 +5,29 @@ export type BrandKitUpload = {
|
|
|
5
5
|
encoding: string;
|
|
6
6
|
};
|
|
7
7
|
export type GenerationBrandKit = {
|
|
8
|
+
colors?: {
|
|
9
|
+
primary?: string;
|
|
10
|
+
secondary?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
sub?: string;
|
|
13
|
+
};
|
|
14
|
+
fonts?: string[];
|
|
8
15
|
libraries?: string[];
|
|
9
16
|
uploads?: BrandKitUpload[];
|
|
17
|
+
fontFiles?: BrandKitUpload[];
|
|
10
18
|
};
|
|
11
19
|
export declare function brandKitForRequest(options: {
|
|
12
20
|
librariesEnabled: boolean;
|
|
13
21
|
debugMode: boolean;
|
|
14
22
|
libraries: string[];
|
|
15
23
|
libraryUploads: BrandKitUpload[];
|
|
24
|
+
brandKitEnabled?: boolean;
|
|
25
|
+
colors?: {
|
|
26
|
+
primary?: string;
|
|
27
|
+
secondary?: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
sub?: string;
|
|
30
|
+
};
|
|
31
|
+
fonts?: string[];
|
|
32
|
+
fontUploads?: BrandKitUpload[];
|
|
16
33
|
}): GenerationBrandKit | undefined;
|
|
@@ -6,7 +6,24 @@ export function brandKitForRequest(options) {
|
|
|
6
6
|
kit.libraries = [...options.libraries];
|
|
7
7
|
if (options.libraryUploads.length > 0)
|
|
8
8
|
kit.uploads = options.libraryUploads.map((file) => ({ ...file }));
|
|
9
|
-
|
|
9
|
+
// Checked only in debug. These colors and fonts sit over the workspace kit for this message.
|
|
10
|
+
if (options.brandKitEnabled && options.debugMode) {
|
|
11
|
+
const colors = options.colors;
|
|
12
|
+
if (colors && (colors.primary || colors.secondary || colors.title || colors.sub)) {
|
|
13
|
+
kit.colors = { ...colors };
|
|
14
|
+
}
|
|
15
|
+
const families = (options.fonts ?? []).map((family) => family.trim()).filter(Boolean).slice(0, 3);
|
|
16
|
+
if (families.length > 0)
|
|
17
|
+
kit.fonts = families;
|
|
18
|
+
if (options.fontUploads && options.fontUploads.length > 0) {
|
|
19
|
+
kit.fontFiles = options.fontUploads.map((file) => ({ ...file }));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (kit.libraries === undefined
|
|
23
|
+
&& kit.uploads === undefined
|
|
24
|
+
&& !kit.colors
|
|
25
|
+
&& !kit.fonts
|
|
26
|
+
&& !kit.fontFiles)
|
|
10
27
|
return undefined;
|
|
11
28
|
return kit;
|
|
12
29
|
}
|
|
@@ -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;
|