anentrypoint-design 0.0.343 → 0.0.345

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": "anentrypoint-design",
3
- "version": "0.0.343",
3
+ "version": "0.0.345",
4
4
  "description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
5
5
  "type": "module",
6
6
  "main": "./dist/247420.js",
@@ -371,12 +371,13 @@ export function AgentChat(props = {}) {
371
371
  // replay. Retry rides the existing actions row.
372
372
  stopped: m.stopped,
373
373
  incomplete: m.incomplete,
374
- // A dangling failed message (send rejected / no reply) gets its error
374
+ // A failed trailing turn (the host's send/stream rejected, regardless
375
+ // of which role the placeholder message landed on) gets its error
375
376
  // pinned to that specific turn, with retry right there — same pattern
376
377
  // as stopped/incomplete, but destructive-toned since this is a genuine
377
378
  // failure rather than a neutral "not finished" state.
378
- error: !isAssistant && i === lastIdx ? m.error : undefined,
379
- onRetry: (!isAssistant && i === lastIdx && m.error && onRetryMessage) ? () => onRetryMessage(m) : undefined,
379
+ error: i === lastIdx ? m.error : undefined,
380
+ onRetry: (i === lastIdx && m.error && onRetryMessage) ? () => onRetryMessage(m) : undefined,
380
381
  parts: emptyStreaming ? undefined : (parts.length ? parts : [{ kind: 'text', text: '' }]),
381
382
  });
382
383
  });
package/src/theme.js CHANGED
@@ -16,6 +16,7 @@
16
16
  const KEY = '247420:theme';
17
17
  const ACCENT_KEY = '247420:accent';
18
18
  const DENSITY_KEY = '247420:density';
19
+ const LOCALE_KEY = '247420:locale';
19
20
  // 'auto' is a mode, not a [data-theme] preset block — it stays in VALID for the
20
21
  // controller but is the OS-follow path. The named presets are the rest.
21
22
  const VALID = new Set(['auto', 'paper', 'ink', 'thebird']);
@@ -129,6 +130,42 @@ export function getDensity() {
129
130
  return document.documentElement.getAttribute('data-density');
130
131
  }
131
132
 
133
+ // ---- Direction: derived from an active locale, not user-toggled ----
134
+ //
135
+ // Unlike theme/accent/density (explicit user picks), direction is DERIVED
136
+ // from whichever locale the consumer's i18n catalog has active — mirrors the
137
+ // data-theme pattern (one attribute the CSS reads) but the input is a BCP-47
138
+ // locale tag, not a direct rtl/ltr choice. Intl.Locale(locale).textInfo is
139
+ // the real platform primitive for this (no manual RTL-language list to
140
+ // maintain). Falls back to 'ltr' for a locale the runtime can't resolve
141
+ // (unknown tag, or a runtime without Intl.Locale.textInfo support).
142
+ export function applyDirection(locale) {
143
+ if (!isBrowser()) return 'ltr';
144
+ let dir = 'ltr';
145
+ try {
146
+ const info = new Intl.Locale(locale).textInfo;
147
+ if (info && (info.direction === 'rtl' || info.direction === 'ltr')) dir = info.direction;
148
+ } catch { /* swallow: unresolvable locale tag or no Intl.Locale.textInfo support — default ltr already set */ }
149
+ document.documentElement.setAttribute('dir', dir);
150
+ try { window.localStorage.setItem(LOCALE_KEY, locale); } catch { /* swallow: persistence is best-effort, direction still applies in-memory */ }
151
+ return dir;
152
+ }
153
+
154
+ export function getDirection() {
155
+ if (!isBrowser()) return 'ltr';
156
+ return document.documentElement.getAttribute('dir') || 'ltr';
157
+ }
158
+
159
+ // Restores the last-applied locale's direction on boot (no-op if none
160
+ // stored — leaves whatever dir the page was authored/SSR'd with).
161
+ export function initDirection() {
162
+ if (!isBrowser()) return 'ltr';
163
+ let stored = null;
164
+ try { stored = window.localStorage.getItem(LOCALE_KEY); } catch { /* swallow: no stored locale, use SSR/authored dir as-is */ }
165
+ if (stored) return applyDirection(stored);
166
+ return getDirection();
167
+ }
168
+
132
169
  // Auto-init on browser import. Picks stored value, else falls back to
133
170
  // whatever data-theme is already on <html> (set by page-html.js), else 'auto'.
134
171
  export function initTheme() {
@@ -148,5 +185,8 @@ export function initTheme() {
148
185
 
149
186
  if (isBrowser()) {
150
187
  // Run on next microtask so SSR-injected attributes settle first.
151
- Promise.resolve().then(() => { try { initTheme(); } catch { /* swallow: deferred init is a progressive enhancement, page already rendered without it */ } });
188
+ Promise.resolve().then(() => {
189
+ try { initTheme(); } catch { /* swallow: deferred init is a progressive enhancement, page already rendered without it */ }
190
+ try { initDirection(); } catch { /* swallow: deferred init is a progressive enhancement, page already rendered without it */ }
191
+ });
152
192
  }