anentrypoint-design 0.0.333 → 0.0.335

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.333",
3
+ "version": "0.0.335",
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",
@@ -761,7 +761,7 @@ export const logs = makePage((ctx) => {
761
761
 
762
762
  async function loadSubsystems() {
763
763
  try { ctx.set({ subsystems: await api('/api/logs') }); }
764
- catch (e) { /* non-fatal: subsystem list is a filter convenience, not required for the stream */ }
764
+ catch (e) { /* swallow: non-fatal, subsystem list is a filter convenience, not required for the stream */ }
765
765
  }
766
766
 
767
767
  let unmounted = false;
@@ -789,7 +789,7 @@ export const logs = makePage((ctx) => {
789
789
  ctx.onCleanup(() => {
790
790
  unmounted = true;
791
791
  if (reconnectTimer) clearTimeout(reconnectTimer);
792
- try { currentWs?.close(); } catch {}
792
+ try { currentWs?.close(); } catch { /* swallow: teardown-only close, socket may already be closed/closing */ }
793
793
  unregisterDebug('logs');
794
794
  });
795
795
 
package/src/index.js CHANGED
@@ -24,6 +24,7 @@ import { registerFreddieChatElement, FreddieChat } from './web-components/freddi
24
24
  import { formatTime, formatDateTime, formatNumber, formatRelativeTime } from './locale.js';
25
25
  import { queueMessage, listQueued, flushQueue, watchReconnect, isOnline } from './idb-outbox.js';
26
26
  import { createVirtualizer, measureRef } from './virtual-scroll.js';
27
+ import { applyMotion, getMotion, isMotionReduced, onMotionChange, initMotion } from './motion-toggle.js';
27
28
 
28
29
  let _installed = false;
29
30
  export async function installStyles(target) {
@@ -93,7 +94,8 @@ export {
93
94
  t, registerLocale, getLocale, setLocale, availableLocales,
94
95
  formatTime, formatDateTime, formatNumber, formatRelativeTime,
95
96
  queueMessage, listQueued, flushQueue, watchReconnect, isOnline,
96
- createVirtualizer, measureRef
97
+ createVirtualizer, measureRef,
98
+ applyMotion, getMotion, isMotionReduced, onMotionChange, initMotion
97
99
  };
98
100
  export { applyTheme, getTheme, resolvedTheme, onThemeChange, initTheme,
99
101
  applyAccent, getAccent, applyDensity, getDensity } from './theme.js';
package/src/locale.js CHANGED
@@ -60,6 +60,6 @@ export function formatRelativeTime(date, locale = getLocale(), now = Date.now())
60
60
  if (Math.abs(duration) < division.amount) return rtf.format(Math.round(duration), division.unit);
61
61
  duration /= division.amount;
62
62
  }
63
- } catch { /* fall through to the plain-time fallback below */ }
63
+ } catch { /* swallow: Intl.RelativeTimeFormat unsupported/threw, fall through to the plain-time fallback below */ }
64
64
  return formatTime(date, locale);
65
65
  }
@@ -0,0 +1,78 @@
1
+ // 247420 design system — motion preference controller. Mirrors theme.js's
2
+ // applyX/getX + localStorage-persistence + browser-guard pattern.
3
+ //
4
+ // src/motion.js already gates every entry animation behind the OS-level
5
+ // @media (prefers-reduced-motion: no-preference) query -- a user whose OS
6
+ // default is "no preference" (the common default) has no way to opt OUT of
7
+ // motion without changing a system-wide OS setting. This adds a real
8
+ // in-app override: [data-motion="reduced"] on <html> disables/shortens
9
+ // transitions identically to the OS media query, independent of the OS
10
+ // setting.
11
+
12
+ const KEY = '247420:motion';
13
+ const VALID = new Set(['auto', 'reduced']);
14
+ const listeners = new Set();
15
+ let _current = 'auto';
16
+
17
+ function isBrowser() {
18
+ return typeof document !== 'undefined' && typeof window !== 'undefined';
19
+ }
20
+
21
+ function readStored() {
22
+ try {
23
+ const v = window.localStorage.getItem(KEY);
24
+ return VALID.has(v) ? v : null;
25
+ } catch { return null; }
26
+ }
27
+
28
+ function writeStored(mode) {
29
+ try { window.localStorage.setItem(KEY, mode); } catch { /* swallow: persistence is best-effort, motion preference still applies in-memory */ }
30
+ }
31
+
32
+ function writeAttr(mode) {
33
+ if (!isBrowser()) return;
34
+ if (mode === 'reduced') document.documentElement.setAttribute('data-motion', 'reduced');
35
+ else document.documentElement.removeAttribute('data-motion');
36
+ }
37
+
38
+ export function applyMotion(mode) {
39
+ if (!VALID.has(mode)) mode = 'auto';
40
+ _current = mode;
41
+ writeAttr(mode);
42
+ writeStored(mode);
43
+ for (const cb of listeners) {
44
+ try { cb({ mode }); } catch { /* swallow: a listener's error must not block notifying the rest */ }
45
+ }
46
+ return mode;
47
+ }
48
+
49
+ export function getMotion() {
50
+ return _current;
51
+ }
52
+
53
+ // True when motion is actually suppressed right now -- either the user's
54
+ // explicit override is 'reduced', OR (mode is 'auto' AND the OS itself
55
+ // prefers reduced motion). Consumers that gate a JS-driven animation (not
56
+ // just CSS transitions, which the [data-motion=reduced] selector already
57
+ // handles) should check this before running anything non-essential.
58
+ export function isMotionReduced() {
59
+ if (_current === 'reduced') return true;
60
+ if (_current !== 'auto') return false;
61
+ if (!isBrowser() || !window.matchMedia) return false;
62
+ try { return window.matchMedia('(prefers-reduced-motion: reduce)').matches; } catch { return false; }
63
+ }
64
+
65
+ export function onMotionChange(cb) {
66
+ listeners.add(cb);
67
+ return () => listeners.delete(cb);
68
+ }
69
+
70
+ // Auto-init on browser import. Picks stored value, else 'auto' (OS-driven).
71
+ export function initMotion() {
72
+ if (!isBrowser()) return 'auto';
73
+ const stored = readStored();
74
+ applyMotion(stored || 'auto');
75
+ return _current;
76
+ }
77
+
78
+ if (isBrowser()) initMotion();
package/src/motion.js CHANGED
@@ -19,6 +19,20 @@ export function installMotion() {
19
19
  .ds-247420 [data-anim="ready"] {
20
20
  opacity: 1; transform: translateY(0);
21
21
  }
22
+ }
23
+ /* [data-motion="reduced"] is the in-app user override (motion-toggle.js) —
24
+ applies the exact same reduced-motion treatment as the OS-level
25
+ prefers-reduced-motion media query above, independent of the OS setting.
26
+ Selector applies regardless of the media query's own match state, so it
27
+ correctly overrides the animated block above on any OS. */
28
+ :root[data-motion="reduced"] .ds-247420 [data-anim="in"],
29
+ .ds-247420[data-motion="reduced"] [data-anim="in"] {
30
+ opacity: 1 !important; transform: translateY(0) !important;
31
+ transition: none !important;
32
+ }
33
+ :root[data-motion="reduced"] .ds-247420 [data-anim="ready"],
34
+ .ds-247420[data-motion="reduced"] [data-anim="ready"] {
35
+ transition: none !important;
22
36
  }`.trim();
23
37
  document.head.appendChild(style);
24
38
  }