@widgetic/creator 0.3.60 → 0.3.61

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.
@@ -8,23 +8,45 @@ interface VersionOption {
8
8
  dateLabel?: string;
9
9
  /** True when this option is the live published version. */
10
10
  isLive?: boolean;
11
+ /** True when this version has never been published. */
12
+ isDraft?: boolean;
11
13
  }
14
+ type ShapeRect = {
15
+ widgetId: string;
16
+ left: number;
17
+ top: number;
18
+ width: number;
19
+ height: number;
20
+ localWidth?: number;
21
+ localHeight?: number;
22
+ matrix?: number[];
23
+ /** Pointer is over the shape (Fabric mouse:over); keeps chrome visible. */
24
+ hovered?: boolean;
25
+ src: string;
26
+ };
12
27
  interface Props {
13
28
  class?: string;
14
29
  style?: string;
15
30
  enabled?: boolean;
16
- /** Screen-space boxes for widget shapes currently on the canvas. */
17
- getRects?: (() => Array<{
18
- widgetId: string;
19
- left: number;
20
- top: number;
21
- width: number;
22
- height: number;
23
- }>) | null;
31
+ /** Shared host: inactive units < active body (60) < controls (70) < active chrome (80). */
32
+ portalTarget?: string;
33
+ /** Bounds park chrome; the local dimensions/matrix transform the live body. */
34
+ getRects?: (() => Array<Omit<ShapeRect, 'src'>>) | null;
24
35
  /** Resolve a live preview URL for a widget (CDN published or Worker preview). */
25
36
  resolveUrl?: ((widgetId: string) => string | null) | null;
37
+ /** Keep chrome visible while a historical build is pending or failed. */
38
+ resolvePreviewState?: ((widgetId: string) => {
39
+ loading: boolean;
40
+ error: string | null;
41
+ } | null) | null;
42
+ /** Retry the selected historical version; never refresh shared HEAD. */
43
+ onRetryPreview?: ((widgetId: string) => void) | null;
26
44
  /** Currently selected WidgetShape id (highlights chrome). */
27
45
  selectedWidgetId?: string | null;
46
+ primaryWidgetId?: string | null;
47
+ onSetPrimary?: ((widgetId: string) => void) | null;
48
+ /** Shared publish gate; explicit versions must not inherit another row's error. */
49
+ resolvePublishDisabled?: ((widgetId: string, version?: number | null) => boolean) | null;
28
50
  /** Translate shape by screen-pixel delta. */
29
51
  onTranslate?: ((widgetId: string, dxScreen: number, dyScreen: number) => void) | null;
30
52
  /** Fired once when a chrome drag ends (mark canvas dirty / history). */
@@ -41,21 +63,31 @@ interface Props {
41
63
  resolveVersionOptions?: ((widgetId: string) => Array<VersionOption> | null) | null;
42
64
  /** Currently selected version option id. */
43
65
  resolveVersionSelectedId?: ((widgetId: string) => string | null) | null;
44
- onVersionChange?: ((widgetId: string, versionId: string) => void) | null;
66
+ onVersionChange?: ((widgetId: string, versionId: string, buildPreview?: boolean) => void) | null;
45
67
  /** Promote a published version to Live (same as chat Set live). */
46
68
  onSetLive?: ((widgetId: string, version: number) => void) | null;
47
69
  /** Version currently being set live (disables that row's button). */
48
70
  settingLiveVersion?: number | null;
49
- /** Optional notify after local iframe reload (does not capture screenshots). */
50
- onRefresh?: ((widgetId: string) => void) | null;
71
+ /** Capture callback after an explicit reload has loaded and settled. */
72
+ onRefresh?: ((widgetId: string, iframe: HTMLIFrameElement, isCurrent: () => boolean) => void | Promise<void>) | null;
51
73
  /** Bump when widget names / publish state change so chrome re-renders. */
52
74
  titleRevision?: number;
53
75
  /** Whether this widget has unpublished codegen ahead of Live (show Publish). */
54
76
  resolveCanPublish?: ((widgetId: string) => boolean) | null;
77
+ /**
78
+ * Whether a specific Draft row can be published. Drafts carry their own
79
+ * commit, so they can be promoted without regenerating first — the main
80
+ * `resolveCanPublish` gate is about HEAD vs Live and would say "no".
81
+ */
82
+ resolveCanPublishDraft?: ((widgetId: string, version: number) => boolean) | null;
55
83
  /** Publish HEAD as a new live version (shape bar Publish button). */
56
84
  onPublish?: ((widgetId: string) => void) | null;
85
+ /** Publish a specific Draft version (built from that version's own commit). */
86
+ onPublishDraft?: ((widgetId: string, version: number) => void) | null;
57
87
  /** True while publish is in flight for this widget. */
58
88
  resolveIsPublishing?: ((widgetId: string) => boolean) | null;
89
+ /** Publish-disabled reason for a specific Draft row (null = enabled). */
90
+ resolvePublishDisabledReason?: ((widgetId: string, version: number) => string | null) | null;
59
91
  }
60
92
  declare const WidgetShapeLivePreviews: import("svelte").Component<Props, {
61
93
  sync: () => void;
@@ -0,0 +1,9 @@
1
+ /** Keep SDK diagnostics separate from the friendly, version-scoped preview message. */
2
+ export function parseVersionPreviewError(error: any): Promise<{
3
+ kind: string;
4
+ code: any;
5
+ status: number;
6
+ message: string;
7
+ technicalMessage: any;
8
+ commitSha: any;
9
+ }>;
@@ -0,0 +1,19 @@
1
+ /** Keep SDK diagnostics separate from the friendly, version-scoped preview message. */
2
+ export async function parseVersionPreviewError(error) {
3
+ let payload = null;
4
+ const response = error?.response;
5
+ try {
6
+ payload = response ? await response.clone().json() : null;
7
+ } catch { /* Network failures and non-JSON responses still have a useful status. */ }
8
+ const code = payload?.error?.code ?? payload?.code ?? error?.code ?? null;
9
+ const status = Number(response?.status ?? error?.status) || null;
10
+ const kind = status === 422 || code === 'VERSION_BUILD_FAILED' ? 'compile' : 'load';
11
+ return {
12
+ kind, code, status,
13
+ message: kind === 'compile'
14
+ ? 'This version has a code error.'
15
+ : 'Could not load this version. Please try again.',
16
+ technicalMessage: payload?.error?.message ?? payload?.message ?? error?.message ?? String(error),
17
+ commitSha: payload?.error?.data?.commitSha ?? payload?.data?.commitSha ?? null,
18
+ };
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/creator",
3
- "version": "0.3.60",
3
+ "version": "0.3.61",
4
4
  "type": "module",
5
5
  "peerDependencies": {
6
6
  "@sveltejs/kit": "^2.20.0",