reifyui 0.13.4 → 0.13.6

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reifyui",
3
- "version": "0.13.4",
3
+ "version": "0.13.6",
4
4
  "description": "The open-source rendering & interaction layer for agentic applications. Stream and render any agent's output as polished, application-native UI — model-agnostic, framework-agnostic, design-system-native. The foundation for building generative-UI and agent products.",
5
5
  "keywords": [
6
6
  "react",
@@ -34,6 +34,7 @@ const LANG = {
34
34
  sh: 'bash', bash: 'bash', zsh: 'bash', sql: 'sql', css: 'css', scss: 'scss', less: 'less',
35
35
  html: 'xml', htm: 'xml', xml: 'xml', svg: 'xml', json: 'json', yaml: 'yaml', yml: 'yaml',
36
36
  toml: 'ini', ini: 'ini', r: 'r', lua: 'lua', pl: 'perl', dockerfile: 'dockerfile', diff: 'diff',
37
+ md: 'markdown', txt: 'plaintext', log: 'plaintext', csv: 'plaintext',
37
38
  };
38
39
 
39
40
  // Presentations and word documents render faithfully through the server's PDF rendition.
@@ -49,6 +50,7 @@ function kindOf(name, mime = '') {
49
50
  if (mime.startsWith('audio/') || ['mp3', 'wav', 'ogg', 'm4a', 'flac'].includes(e)) return 'audio';
50
51
  if (e === 'csv' || e === 'tsv') return 'csv';
51
52
  if (e === 'md' || e === 'markdown') return 'markdown';
53
+ if (e === 'html' || e === 'htm') return 'html'; // the page itself, or its source: the header switches
52
54
  if (SHEET.has(e)) return 'sheet';
53
55
  if (OFFICE.has(e)) return 'office';
54
56
  if (mime.startsWith('text/') || LANG[e] || /^(txt|log|env|conf|cfg|gitignore)$/.test(e)) return 'code';
@@ -98,6 +100,9 @@ export function FilePreview({
98
100
  const { url, name } = file || {};
99
101
  const [st, setSt] = useState({ kind: 'loading' });
100
102
  const [tab, setTab] = useState(0);
103
+ // An HTML file opens as the page it is; Source shows what was written. The choice lives in the
104
+ // header, beside the name, so it reads as a property of the file being looked at.
105
+ const [view, setView] = useState('preview');
101
106
 
102
107
  useEffect(() => {
103
108
  if (!url) return undefined;
@@ -105,6 +110,7 @@ export function FilePreview({
105
110
  let obj;
106
111
  setSt({ kind: 'loading' });
107
112
  setTab(0);
113
+ setView('preview');
108
114
  const get = fetchFile || ((u) => fetch(u, { cache: 'no-store' }));
109
115
 
110
116
  (async () => {
@@ -142,7 +148,7 @@ export function FilePreview({
142
148
  }
143
149
  return;
144
150
  }
145
- if (kind === 'csv' || kind === 'markdown' || kind === 'code') {
151
+ if (kind === 'csv' || kind === 'markdown' || kind === 'code' || kind === 'html') {
146
152
  const text = await res.text();
147
153
  if (!alive) return;
148
154
  if (kind === 'csv') setSt({ kind: 'csv', rows: delimitedToRows(text, extOf(name) === 'tsv' ? '\t' : ',') });
@@ -164,6 +170,14 @@ export function FilePreview({
164
170
  <header className="uic-fp-head">
165
171
  <span className="uic-fp-ic"><FileTypeIcon name={name} size={20} /></span>
166
172
  <span className="uic-fp-name" title={name}>{name}</span>
173
+ {st.kind === 'html' && (
174
+ <div className="uic-fp-seg" role="tablist" aria-label="Show the page or its source">
175
+ {[['preview', 'Preview'], ['source', 'Source']].map(([id, label]) => (
176
+ <button key={id} type="button" role="tab" aria-selected={view === id}
177
+ className={'uic-fp-seg-btn' + (view === id ? ' is-on' : '')} onClick={() => setView(id)}>{label}</button>
178
+ ))}
179
+ </div>
180
+ )}
167
181
  <button type="button" className="uic-fp-btn" aria-label={`Download ${name}`} title="Download"
168
182
  onClick={download}><IcDownload /></button>
169
183
  {onClose && (
@@ -183,7 +197,13 @@ export function FilePreview({
183
197
  {renderMarkdown ? renderMarkdown(st.text || '') : <pre className="uic-fp-pre">{st.text}</pre>}
184
198
  </div>
185
199
  )}
186
- {st.kind === 'code' && <CodeBlock code={st.text || ''} lang={LANG[extOf(name)] || 'plaintext'} />}
200
+ {st.kind === 'code' && <CodeBlock code={st.text || ''} language={LANG[extOf(name)] || 'plaintext'} />}
201
+ {st.kind === 'html' && view === 'source' && <CodeBlock code={st.text || ''} language="xml" />}
202
+ {st.kind === 'html' && view === 'preview' && (
203
+ // The page runs in its own origin with scripts only: a mockup's own script and styles
204
+ // work, and nothing in it can read the host page, its cookies or its storage.
205
+ <iframe className="uic-fp-frame" title={name} sandbox="allow-scripts" srcDoc={st.text || ''} />
206
+ )}
187
207
  {st.kind === 'csv' && <Grid rows={st.rows} />}
188
208
  {st.kind === 'sheet' && st.sheets && (
189
209
  <div className="uic-fp-xlsx">
package/styles/file.css CHANGED
@@ -74,6 +74,10 @@
74
74
  display: inline-flex; align-items: center; justify-content: center;
75
75
  }
76
76
  .uic-fp-btn:hover { background: var(--uic-brand-faint, #EFF3FF); color: var(--uic-ink, #111317); }
77
+ /* the Preview | Source switch of an HTML file, a segmented control in the header */
78
+ .uic-fp-seg { flex: 0 0 auto; display: inline-flex; gap: 2px; padding: 2px; border-radius: 8px; background: var(--uic-surface-2, #F7F8FA); border: 1px solid var(--uic-line, #DDDFE6); }
79
+ .uic-fp-seg-btn { height: 24px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--uic-mute, #5B5D66); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
80
+ .uic-fp-seg-btn.is-on { background: var(--uic-surface, #FFFFFF); color: var(--uic-ink, #111317); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
77
81
 
78
82
  .uic-fp-body { flex: 1; min-height: 0; overflow: auto; }
79
83
  .uic-fp-pad { padding: 18px; }