@proulr/sdui-contract 0.1.8 → 0.1.12
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/package.json
CHANGED
|
@@ -52,10 +52,23 @@ export type SduiActionWire = {
|
|
|
52
52
|
event_props?: Record<string, unknown>;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
+
/** Layout/chrome hints for the generic app shell (wire snake_case). */
|
|
56
|
+
export type SduiScreenChromeMetaWire = {
|
|
57
|
+
full_bleed_scroll?: boolean;
|
|
58
|
+
owns_header?: boolean;
|
|
59
|
+
self_managed?: boolean;
|
|
60
|
+
hub_kind?: 'inbox' | null;
|
|
61
|
+
wide_layout?: 'chat_master_detail' | 'vibes_rail' | null;
|
|
62
|
+
surface?: 'discover' | 'vibes' | null;
|
|
63
|
+
header_slot?: boolean;
|
|
64
|
+
pull_refresh?: boolean;
|
|
65
|
+
};
|
|
66
|
+
|
|
55
67
|
export type SduiScreenMetaWire = {
|
|
56
68
|
cache_ttl_ms?: number;
|
|
57
69
|
offline_policy?: SduiOfflinePolicy;
|
|
58
70
|
bff?: string;
|
|
71
|
+
chrome?: SduiScreenChromeMetaWire;
|
|
59
72
|
};
|
|
60
73
|
|
|
61
74
|
export type SduiScreenWire = {
|
|
@@ -101,10 +114,23 @@ export type SduiAction = {
|
|
|
101
114
|
eventProps?: Record<string, unknown>;
|
|
102
115
|
};
|
|
103
116
|
|
|
117
|
+
/** Layout/chrome hints for the generic app shell (camelCase domain). */
|
|
118
|
+
export type SduiScreenChromeMeta = {
|
|
119
|
+
fullBleedScroll?: boolean;
|
|
120
|
+
ownsHeader?: boolean;
|
|
121
|
+
selfManaged?: boolean;
|
|
122
|
+
hubKind?: 'inbox' | null;
|
|
123
|
+
wideLayout?: 'chat_master_detail' | 'vibes_rail' | null;
|
|
124
|
+
surface?: 'discover' | 'vibes' | null;
|
|
125
|
+
headerSlot?: boolean;
|
|
126
|
+
pullRefresh?: boolean;
|
|
127
|
+
};
|
|
128
|
+
|
|
104
129
|
export type SduiScreenMeta = {
|
|
105
130
|
cacheTtlMs: number;
|
|
106
131
|
offlinePolicy: SduiOfflinePolicy;
|
|
107
132
|
bff?: string;
|
|
133
|
+
chrome?: SduiScreenChromeMeta;
|
|
108
134
|
};
|
|
109
135
|
|
|
110
136
|
export type SduiScreen = {
|
|
@@ -189,6 +215,7 @@ export type StyleWire = {
|
|
|
189
215
|
opacity?: number;
|
|
190
216
|
flex?: number;
|
|
191
217
|
align_items?: 'flex-start' | 'center' | 'flex-end';
|
|
218
|
+
text_align?: 'left' | 'center' | 'right';
|
|
192
219
|
typography?: TypeToken;
|
|
193
220
|
};
|
|
194
221
|
|
|
@@ -42,6 +42,46 @@ describe('decodeSduiScreenWire', () => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
it('decodes meta.chrome into camelCase layout hints', () => {
|
|
46
|
+
const screen = decodeSduiScreenWire({
|
|
47
|
+
schema_version: 1,
|
|
48
|
+
screen_id: 'discover.home',
|
|
49
|
+
blocks: [],
|
|
50
|
+
meta: {
|
|
51
|
+
chrome: {
|
|
52
|
+
full_bleed_scroll: true,
|
|
53
|
+
header_slot: true,
|
|
54
|
+
pull_refresh: true,
|
|
55
|
+
surface: 'discover',
|
|
56
|
+
hub_kind: 'inbox',
|
|
57
|
+
wide_layout: 'chat_master_detail',
|
|
58
|
+
owns_header: false,
|
|
59
|
+
self_managed: false,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
expect(screen.meta.chrome).toEqual({
|
|
65
|
+
fullBleedScroll: true,
|
|
66
|
+
ownsHeader: false,
|
|
67
|
+
selfManaged: false,
|
|
68
|
+
hubKind: 'inbox',
|
|
69
|
+
wideLayout: 'chat_master_detail',
|
|
70
|
+
surface: 'discover',
|
|
71
|
+
headerSlot: true,
|
|
72
|
+
pullRefresh: true,
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('omits chrome when meta.chrome is absent', () => {
|
|
77
|
+
const screen = decodeSduiScreenWire({
|
|
78
|
+
schema_version: 1,
|
|
79
|
+
screen_id: 'demo.home',
|
|
80
|
+
blocks: [],
|
|
81
|
+
});
|
|
82
|
+
expect(screen.meta.chrome).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
|
|
45
85
|
it('throws SduiCodecError for non-object payload', () => {
|
|
46
86
|
expect(() => decodeSduiScreenWire(null)).toThrow(SduiCodecError);
|
|
47
87
|
});
|
package/src/sdui-screen-codec.ts
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
type SduiHeaderWire,
|
|
10
10
|
type SduiOfflinePolicy,
|
|
11
11
|
type SduiScreen,
|
|
12
|
+
type SduiScreenChromeMeta,
|
|
13
|
+
type SduiScreenChromeMetaWire,
|
|
12
14
|
type SduiScreenMeta,
|
|
13
15
|
type SduiScreenMetaWire,
|
|
14
16
|
type SduiScreenWire,
|
|
@@ -63,11 +65,28 @@ function mapHeaderWire(wire: SduiHeaderWire): SduiHeader {
|
|
|
63
65
|
};
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
function mapChromeMetaWire(
|
|
69
|
+
wire: SduiScreenChromeMetaWire | undefined,
|
|
70
|
+
): SduiScreenChromeMeta | undefined {
|
|
71
|
+
if (!wire) return undefined;
|
|
72
|
+
return {
|
|
73
|
+
fullBleedScroll: wire.full_bleed_scroll,
|
|
74
|
+
ownsHeader: wire.owns_header,
|
|
75
|
+
selfManaged: wire.self_managed,
|
|
76
|
+
hubKind: wire.hub_kind,
|
|
77
|
+
wideLayout: wire.wide_layout,
|
|
78
|
+
surface: wire.surface,
|
|
79
|
+
headerSlot: wire.header_slot,
|
|
80
|
+
pullRefresh: wire.pull_refresh,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
function mapMetaWire(wire: SduiScreenMetaWire | undefined): SduiScreenMeta {
|
|
67
85
|
return {
|
|
68
86
|
cacheTtlMs: wire?.cache_ttl_ms ?? DEFAULT_CACHE_TTL_MS,
|
|
69
87
|
offlinePolicy: wire?.offline_policy ?? DEFAULT_OFFLINE_POLICY,
|
|
70
88
|
bff: wire?.bff,
|
|
89
|
+
chrome: mapChromeMetaWire(wire?.chrome),
|
|
71
90
|
};
|
|
72
91
|
}
|
|
73
92
|
|