@widgetic/creator 0.3.72 → 0.3.74
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 +821 -73
- package/dist/components/BrandKitPanel.svelte +556 -0
- package/dist/components/BrandKitPanel.svelte.d.ts +32 -0
- package/dist/components/DesignQuickEdit.svelte +218 -0
- package/dist/components/DesignQuickEdit.svelte.d.ts +33 -0
- package/dist/components/FileUrlSourceControl.svelte +69 -0
- package/dist/components/FileUrlSourceControl.svelte.d.ts +15 -0
- package/dist/components/VersionDropdownRow.svelte +86 -1
- package/dist/components/VersionDropdownRow.svelte.d.ts +10 -0
- package/dist/components/WidgetDetails.svelte +19 -2
- package/dist/components/WidgetShapeLivePreviews.svelte +8 -3
- package/dist/retiredSurface.test.d.ts +1 -0
- package/dist/retiredSurface.test.js +113 -0
- package/dist/stores/websocketStore.d.ts +3 -0
- package/dist/stores/websocketStore.js +4 -0
- package/dist/utils/canvasShapeSnapClient.d.ts +27 -0
- package/dist/utils/canvasShapeSnapClient.js +67 -0
- package/dist/utils/designIntentJevClient.d.ts +32 -0
- package/dist/utils/designIntentJevClient.js +51 -0
- package/dist/utils/designIntentResolver.d.ts +107 -0
- package/dist/utils/designIntentResolver.js +509 -0
- package/dist/utils/designIntentResolver.test.d.ts +1 -0
- package/dist/utils/designIntentResolver.test.js +246 -0
- package/dist/utils/designIntentTelemetry.d.ts +176 -0
- package/dist/utils/designIntentTelemetry.js +474 -0
- package/dist/utils/designIntentTelemetry.test.d.ts +1 -0
- package/dist/utils/designIntentTelemetry.test.js +385 -0
- package/dist/utils/designQuickEditValues.d.ts +51 -0
- package/dist/utils/designQuickEditValues.js +77 -0
- package/dist/utils/designQuickEditValues.test.d.ts +1 -0
- package/dist/utils/designQuickEditValues.test.js +100 -0
- package/dist/utils/pinScrollToBottom.js +9 -2
- package/package.json +2 -2
|
@@ -173,6 +173,8 @@ function setupSocketListeners(sock) {
|
|
|
173
173
|
status: data.status ?? null,
|
|
174
174
|
version: data.version,
|
|
175
175
|
artifactUrl: data.artifactUrl,
|
|
176
|
+
commitTitle: data.commitTitle ?? null,
|
|
177
|
+
commitSha: data.commitSha ?? null,
|
|
176
178
|
message: data.message,
|
|
177
179
|
error: data.error,
|
|
178
180
|
timestamp: new Date().toISOString()
|
|
@@ -186,6 +188,8 @@ function setupSocketListeners(sock) {
|
|
|
186
188
|
status: 'success',
|
|
187
189
|
version: data.versionPublished,
|
|
188
190
|
artifactUrl: data.artifactUrl,
|
|
191
|
+
commitTitle: data.commitTitle ?? null,
|
|
192
|
+
commitSha: data.commitSha ?? null,
|
|
189
193
|
message: data.message,
|
|
190
194
|
error: undefined,
|
|
191
195
|
timestamp: new Date().toISOString()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* canvasShapeSnapClient — the Canvas's Jev-backed stroke recognizer.
|
|
3
|
+
*
|
|
4
|
+
* When the user draws a shape freehand, the Canvas measures the stroke in code
|
|
5
|
+
* and decides on its own whenever the measurements are decisive: a drawn
|
|
6
|
+
* rectangle is a rectangle, with no model and no network. This client covers the
|
|
7
|
+
* residue — strokes whose measurements leave several shapes standing (a
|
|
8
|
+
* near-square, an oval that is almost a circle) — by asking the gateway for one
|
|
9
|
+
* closed-set decision over the measurements and the shapes the geometry allowed.
|
|
10
|
+
*
|
|
11
|
+
* The gateway owns the model, the confidence gate, and the rollout mode; this
|
|
12
|
+
* client only transports and reports. It never throws: a null result means
|
|
13
|
+
* "leave the stroke exactly as the user drew it", which is what the Canvas does
|
|
14
|
+
* with no recognizer at all.
|
|
15
|
+
*/
|
|
16
|
+
import type { StrokeRecognitionRequest, StrokeRecognitionResult } from '@widgetic/canvas';
|
|
17
|
+
export interface CanvasShapeSnapReply extends StrokeRecognitionResult {
|
|
18
|
+
/** `jev` = a real verdict; `degraded`/`disabled`/`no_candidates` = fallback. */
|
|
19
|
+
source: 'jev' | 'degraded' | 'disabled' | 'no_candidates' | 'client_unavailable';
|
|
20
|
+
}
|
|
21
|
+
export declare function recognizeStrokeViaJev(input: {
|
|
22
|
+
/** API base including the version segment, e.g. `http://localhost:3000/v1`. */
|
|
23
|
+
apiBasePath: string | undefined;
|
|
24
|
+
token: string | null;
|
|
25
|
+
request: StrokeRecognitionRequest;
|
|
26
|
+
signal?: AbortSignal;
|
|
27
|
+
}): Promise<CanvasShapeSnapReply | null>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* canvasShapeSnapClient — the Canvas's Jev-backed stroke recognizer.
|
|
3
|
+
*
|
|
4
|
+
* When the user draws a shape freehand, the Canvas measures the stroke in code
|
|
5
|
+
* and decides on its own whenever the measurements are decisive: a drawn
|
|
6
|
+
* rectangle is a rectangle, with no model and no network. This client covers the
|
|
7
|
+
* residue — strokes whose measurements leave several shapes standing (a
|
|
8
|
+
* near-square, an oval that is almost a circle) — by asking the gateway for one
|
|
9
|
+
* closed-set decision over the measurements and the shapes the geometry allowed.
|
|
10
|
+
*
|
|
11
|
+
* The gateway owns the model, the confidence gate, and the rollout mode; this
|
|
12
|
+
* client only transports and reports. It never throws: a null result means
|
|
13
|
+
* "leave the stroke exactly as the user drew it", which is what the Canvas does
|
|
14
|
+
* with no recognizer at all.
|
|
15
|
+
*/
|
|
16
|
+
export async function recognizeStrokeViaJev(input) {
|
|
17
|
+
if (!input.apiBasePath || !input.token)
|
|
18
|
+
return null;
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch(`${input.apiBasePath}/agent/shape/recognize`, {
|
|
21
|
+
method: 'POST',
|
|
22
|
+
headers: {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
Authorization: `Bearer ${input.token}`
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
measurements: input.request.measurements,
|
|
28
|
+
// Only shapes the client's geometry could not rule out are sent, so
|
|
29
|
+
// the model can never pick one that is plainly not what was drawn.
|
|
30
|
+
candidates: input.request.candidates.map((candidate) => ({
|
|
31
|
+
shape: candidate.shape,
|
|
32
|
+
label: candidate.label,
|
|
33
|
+
score: candidate.score
|
|
34
|
+
})),
|
|
35
|
+
deterministic: input.request.best
|
|
36
|
+
? { shape: input.request.best.shape, score: input.request.best.score }
|
|
37
|
+
: null
|
|
38
|
+
}),
|
|
39
|
+
signal: input.signal
|
|
40
|
+
});
|
|
41
|
+
if (!response.ok)
|
|
42
|
+
return null;
|
|
43
|
+
const json = (await response.json());
|
|
44
|
+
// The gateway's success envelope is `{ success, data }`; tolerate a bare body.
|
|
45
|
+
const data = (json?.data ?? json);
|
|
46
|
+
if (!data || typeof data !== 'object')
|
|
47
|
+
return null;
|
|
48
|
+
const source = data.source ?? 'degraded';
|
|
49
|
+
const reason = String(data.reason ?? '');
|
|
50
|
+
// `acted` is the only thing that authorizes a replacement: in shadow mode,
|
|
51
|
+
// on low confidence, or on a degradation the shape is null and the caller
|
|
52
|
+
// keeps the user's own stroke.
|
|
53
|
+
if (data.acted !== true || typeof data.shape !== 'string' || !data.shape) {
|
|
54
|
+
return { source, shape: null, reason, confidence: null };
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
source,
|
|
58
|
+
shape: data.shape,
|
|
59
|
+
reason,
|
|
60
|
+
confidence: typeof data.confidence === 'number' ? data.confidence : null
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Network/abort/parse failure: leave the stroke as drawn, silently.
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* designIntentJevClient — the canvas chat's Jev-backed design resolver fallback.
|
|
3
|
+
*
|
|
4
|
+
* The deterministic resolver (`designIntentResolver.ts`) applies explicit values
|
|
5
|
+
* and arithmetic locally. When it bails, the chat asks the gateway to resolve
|
|
6
|
+
* the message with JEV: one batched decision over the message plus the
|
|
7
|
+
* `design.json` roster already loaded here, picking a property and a bounded
|
|
8
|
+
* value.
|
|
9
|
+
*
|
|
10
|
+
* The gateway owns the model, the confidence gate, and the rollout mode; this
|
|
11
|
+
* client only transports and reports. It never throws and never blocks a send —
|
|
12
|
+
* a null result means "generate exactly as before".
|
|
13
|
+
*/
|
|
14
|
+
export interface DesignIntentJevResult {
|
|
15
|
+
/** `jev` = a real verdict; `degraded`/`disabled`/`no_properties` = fallback. */
|
|
16
|
+
source: 'jev' | 'degraded' | 'disabled' | 'no_properties';
|
|
17
|
+
/** True only when the gateway confidently resolved a property + value. */
|
|
18
|
+
acted: boolean;
|
|
19
|
+
reason: string;
|
|
20
|
+
property: string | null;
|
|
21
|
+
value: unknown;
|
|
22
|
+
confidence: number | null;
|
|
23
|
+
}
|
|
24
|
+
export declare function resolveDesignIntentViaJev(input: {
|
|
25
|
+
/** API base including the version segment, e.g. `http://localhost:3000/v1`. */
|
|
26
|
+
apiBasePath: string | undefined;
|
|
27
|
+
token: string | null;
|
|
28
|
+
message: string;
|
|
29
|
+
designSchema: unknown;
|
|
30
|
+
currentValues: Record<string, unknown>;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): Promise<DesignIntentJevResult | null>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* designIntentJevClient — the canvas chat's Jev-backed design resolver fallback.
|
|
3
|
+
*
|
|
4
|
+
* The deterministic resolver (`designIntentResolver.ts`) applies explicit values
|
|
5
|
+
* and arithmetic locally. When it bails, the chat asks the gateway to resolve
|
|
6
|
+
* the message with JEV: one batched decision over the message plus the
|
|
7
|
+
* `design.json` roster already loaded here, picking a property and a bounded
|
|
8
|
+
* value.
|
|
9
|
+
*
|
|
10
|
+
* The gateway owns the model, the confidence gate, and the rollout mode; this
|
|
11
|
+
* client only transports and reports. It never throws and never blocks a send —
|
|
12
|
+
* a null result means "generate exactly as before".
|
|
13
|
+
*/
|
|
14
|
+
export async function resolveDesignIntentViaJev(input) {
|
|
15
|
+
if (!input.apiBasePath || !input.token)
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(`${input.apiBasePath}/agent/design/resolve`, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: {
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
Authorization: `Bearer ${input.token}`,
|
|
23
|
+
},
|
|
24
|
+
body: JSON.stringify({
|
|
25
|
+
message: input.message,
|
|
26
|
+
designSchema: input.designSchema,
|
|
27
|
+
currentValues: input.currentValues,
|
|
28
|
+
}),
|
|
29
|
+
signal: input.signal,
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok)
|
|
32
|
+
return null;
|
|
33
|
+
const json = (await response.json());
|
|
34
|
+
// The gateway's success envelope is `{ success, data }`; tolerate a bare body.
|
|
35
|
+
const data = (json?.data ?? json);
|
|
36
|
+
if (!data || typeof data !== 'object')
|
|
37
|
+
return null;
|
|
38
|
+
return {
|
|
39
|
+
source: data.source ?? 'degraded',
|
|
40
|
+
acted: data.acted === true,
|
|
41
|
+
reason: String(data.reason ?? ''),
|
|
42
|
+
property: typeof data.property === 'string' && data.property ? data.property : null,
|
|
43
|
+
value: data.value ?? null,
|
|
44
|
+
confidence: typeof data.confidence === 'number' ? data.confidence : null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// Network/abort/parse failure: fall through to codegen, silently.
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* designIntentResolver — deterministic "user wants to change a design property"
|
|
3
|
+
* resolution, for the canvas chat.
|
|
4
|
+
*
|
|
5
|
+
* The canvas chat normally sends every message to codegen (an LLM turn). A large
|
|
6
|
+
* share of messages are really just design-property tweaks ("make the background
|
|
7
|
+
* #1a1a2e", "increase the padding by 8", "turn on the border"). Those are fully
|
|
8
|
+
* decidable in code against the widget's already-loaded `design.json` schema: the
|
|
9
|
+
* property set is a closed set, and the value is either explicit (hex / number /
|
|
10
|
+
* boolean / a dropdown option) or an arithmetic transform of the current value.
|
|
11
|
+
*
|
|
12
|
+
* This module is intentionally PURE and MODEL-FREE. It never calls JEV or an LLM;
|
|
13
|
+
* it returns `null` whenever the message needs semantic understanding ("make it
|
|
14
|
+
* pop", "give it more breathing room") so the caller can fall through to the
|
|
15
|
+
* existing codegen path. Arithmetic lives here, in code — never in the model.
|
|
16
|
+
*
|
|
17
|
+
* Scope: values that are unambiguous and safe to apply to the live preview:
|
|
18
|
+
* - colors (hex, rgb(), and a table of common named colors)
|
|
19
|
+
* - numbers (explicit, or delta/multiplier of the current value; clamped to constraints)
|
|
20
|
+
* - booleans (switch/checkbox/radiogroup on|off)
|
|
21
|
+
* - dropdown options (by option label/value token)
|
|
22
|
+
* - quoted free text (textInput/textArea) — only when explicitly quoted
|
|
23
|
+
*
|
|
24
|
+
* Anything else returns null, by design.
|
|
25
|
+
*/
|
|
26
|
+
export interface DesignOption {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}
|
|
30
|
+
/** A design-schema property, flattened from whatever shape the schema uses. */
|
|
31
|
+
export interface DesignPropertyDescriptor {
|
|
32
|
+
/** Schema key, also the CSS custom-property name used by `widgetic:update`. */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Human label from the schema (description || label || id). */
|
|
35
|
+
label: string;
|
|
36
|
+
/** Lowercased `inputController.type` (colorpicker, slider, dropdown, ...). */
|
|
37
|
+
controllerType: string;
|
|
38
|
+
/** Current value if known, otherwise the schema default. */
|
|
39
|
+
value: unknown;
|
|
40
|
+
defaultValue: unknown;
|
|
41
|
+
options: DesignOption[];
|
|
42
|
+
min?: number;
|
|
43
|
+
max?: number;
|
|
44
|
+
step?: number;
|
|
45
|
+
helpText?: string;
|
|
46
|
+
}
|
|
47
|
+
export type DesignChangeReason = 'explicit-color' | 'named-color' | 'explicit-number' | 'delta-number' | 'boolean' | 'option' | 'explicit-text';
|
|
48
|
+
export interface DesignChange {
|
|
49
|
+
propertyId: string;
|
|
50
|
+
label: string;
|
|
51
|
+
controllerType: string;
|
|
52
|
+
previousValue: unknown;
|
|
53
|
+
value: unknown;
|
|
54
|
+
reason: DesignChangeReason;
|
|
55
|
+
}
|
|
56
|
+
export interface DesignIntentResolution {
|
|
57
|
+
changes: DesignChange[];
|
|
58
|
+
/** Short, human copy for the assistant bubble. */
|
|
59
|
+
summary: string;
|
|
60
|
+
}
|
|
61
|
+
/** The payload the chat renders as an inline controller card. */
|
|
62
|
+
export interface DesignControlProperty {
|
|
63
|
+
id: string;
|
|
64
|
+
label: string;
|
|
65
|
+
controllerType: string;
|
|
66
|
+
value: unknown;
|
|
67
|
+
options?: DesignOption[];
|
|
68
|
+
min?: number;
|
|
69
|
+
max?: number;
|
|
70
|
+
step?: number;
|
|
71
|
+
helpText?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface DesignControlRequest {
|
|
74
|
+
summary: string;
|
|
75
|
+
properties: DesignControlProperty[];
|
|
76
|
+
/**
|
|
77
|
+
* The composition this card's control was authored against, when the host
|
|
78
|
+
* knows it.
|
|
79
|
+
*
|
|
80
|
+
* Persisted with the card so a reload can *re-attach* it: the host feeds the
|
|
81
|
+
* controls the live design values of this composition only, and renders them
|
|
82
|
+
* read-only while a different one is loaded — otherwise a card from an older
|
|
83
|
+
* composition would show, and write, whatever the newly selected one holds
|
|
84
|
+
* under the same property id. Absent on cards created before the field
|
|
85
|
+
* existed; those stay attached, which is the behaviour that preceded this.
|
|
86
|
+
*/
|
|
87
|
+
compositionId?: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Flatten whatever schema shape the codegen produced into a flat property list. */
|
|
90
|
+
export declare function collectDesignProperties(schema: unknown): DesignPropertyDescriptor[];
|
|
91
|
+
/**
|
|
92
|
+
* Properties the message names (directly or by synonym), strongest first.
|
|
93
|
+
* Used by the shadow-mode telemetry classifier to bucket a command without
|
|
94
|
+
* resolving a value for it.
|
|
95
|
+
*/
|
|
96
|
+
export declare function scoreDesignProperties(message: string, schema: unknown): Array<{
|
|
97
|
+
property: DesignPropertyDescriptor;
|
|
98
|
+
score: number;
|
|
99
|
+
}>;
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a chat message into concrete design-property changes, deterministically.
|
|
102
|
+
* Returns `null` when the message is not an unambiguous, in-scope design tweak —
|
|
103
|
+
* the caller should then fall through to the existing codegen path.
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveDesignIntent(message: string, schema: unknown, currentValues?: Record<string, unknown>): DesignIntentResolution | null;
|
|
106
|
+
/** Build the chat card payload from a resolution (used to render inline controls). */
|
|
107
|
+
export declare function toDesignControlRequest(resolution: DesignIntentResolution, schema: unknown, _currentValues?: Record<string, unknown>, compositionId?: string | null): DesignControlRequest;
|