@ihyeon/flow-qa 0.9.11 → 0.9.13

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.
Files changed (52) hide show
  1. package/THIRD_PARTY_NOTICES.md +2 -2
  2. package/dist/src/cli.js +13 -4
  3. package/dist/src/compiler.js +14 -5
  4. package/dist/src/engine.js +3 -3
  5. package/dist/src/ui/design-system/components.css +787 -0
  6. package/{node_modules/@hyeonse/design-system/dist → dist/src/ui/design-system}/preferences.js +20 -12
  7. package/{node_modules/@hyeonse/design-system/src → dist/src/ui/design-system}/tokens.css +56 -0
  8. package/dist/src/ui/public/app.js +28 -7
  9. package/dist/src/ui/server.js +39 -12
  10. package/docs/mobile.md +4 -0
  11. package/docs/releases.md +6 -0
  12. package/docs/ui.md +1 -1
  13. package/package.json +2 -5
  14. package/node_modules/@hyeonse/design-system/.github/workflows/ci.yml +0 -21
  15. package/node_modules/@hyeonse/design-system/.npmignore +0 -5
  16. package/node_modules/@hyeonse/design-system/AGENTS.md +0 -10
  17. package/node_modules/@hyeonse/design-system/README.md +0 -67
  18. package/node_modules/@hyeonse/design-system/THIRD_PARTY_NOTICES.md +0 -5
  19. package/node_modules/@hyeonse/design-system/dist/components.css +0 -105
  20. package/node_modules/@hyeonse/design-system/dist/preferences.d.ts +0 -21
  21. package/node_modules/@hyeonse/design-system/dist/react.d.ts +0 -21
  22. package/node_modules/@hyeonse/design-system/dist/react.js +0 -100
  23. package/node_modules/@hyeonse/design-system/dist/tokens.css +0 -75
  24. package/node_modules/@hyeonse/design-system/docs/api.md +0 -33
  25. package/node_modules/@hyeonse/design-system/docs/assets/fonts/dm-sans.woff2 +0 -0
  26. package/node_modules/@hyeonse/design-system/docs/assets/fonts/noto-kr-subset.woff2 +0 -0
  27. package/node_modules/@hyeonse/design-system/docs/audit.md +0 -29
  28. package/node_modules/@hyeonse/design-system/docs/foundations.md +0 -30
  29. package/node_modules/@hyeonse/design-system/docs/verification.md +0 -13
  30. package/node_modules/@hyeonse/design-system/index.html +0 -51
  31. package/node_modules/@hyeonse/design-system/licenses/DM-Sans-LICENSE.txt +0 -93
  32. package/node_modules/@hyeonse/design-system/licenses/Noto-Sans-KR-LICENSE.txt +0 -93
  33. package/node_modules/@hyeonse/design-system/licenses/arla6ka-MIT.txt +0 -21
  34. package/node_modules/@hyeonse/design-system/package.json +0 -35
  35. package/node_modules/@hyeonse/design-system/scripts/audit-tokens.mjs +0 -48
  36. package/node_modules/@hyeonse/design-system/scripts/build.mjs +0 -12
  37. package/node_modules/@hyeonse/design-system/showcase.css +0 -75
  38. package/node_modules/@hyeonse/design-system/showcase.mjs +0 -63
  39. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/SKILL.md +0 -18
  40. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/api.md +0 -7
  41. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/build.md +0 -7
  42. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/foundations.md +0 -7
  43. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/mapping.md +0 -7
  44. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/migration.md +0 -5
  45. package/node_modules/@hyeonse/design-system/skills/hyeonse-design-system/references/review-docs.md +0 -5
  46. package/node_modules/@hyeonse/design-system/src/components.css +0 -105
  47. package/node_modules/@hyeonse/design-system/src/preferences.ts +0 -87
  48. package/node_modules/@hyeonse/design-system/src/react.tsx +0 -161
  49. package/node_modules/@hyeonse/design-system/tests/audit.test.mjs +0 -30
  50. package/node_modules/@hyeonse/design-system/tests/preferences.test.mjs +0 -86
  51. package/node_modules/@hyeonse/design-system/tsconfig.json +0 -16
  52. /package/{node_modules/@hyeonse → dist/src/ui}/design-system/LICENSE +0 -0
@@ -1,161 +0,0 @@
1
- 'use client';
2
-
3
- import { createContext, useCallback, useContext, useId, useLayoutEffect, useRef, useState } from 'react';
4
- import type { ReactNode } from 'react';
5
- import {
6
- defaultPreferences, effectiveMotion, parsePreferences, preferencesKey,
7
- resolvedTheme, serializePreferences, validatePreferences,
8
- } from './preferences.js';
9
- import type { Preferences, ThemePreference } from './preferences.js';
10
- export type Locale = 'ko' | 'en';
11
- const defaultEventName = 'hyeonse:preferences';
12
-
13
- type PreferenceContext = {
14
- preferences: Preferences;
15
- setPreference: <K extends keyof Preferences>(key: K, value: Preferences[K]) => void;
16
- resetPreferences: () => void;
17
- };
18
-
19
- const Context = createContext<PreferenceContext | null>(null);
20
-
21
- function applyPreferences(preferences: Preferences, eventName: string) {
22
- const root = document.documentElement;
23
- const dark = window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false;
24
- const reduced = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
25
- root.dataset.theme = resolvedTheme(preferences.theme, dark);
26
- root.dataset.themePreference = preferences.theme;
27
- root.dataset.accent = preferences.accent;
28
- root.dataset.density = preferences.density;
29
- root.dataset.corners = preferences.corners;
30
- root.dataset.motion = effectiveMotion(preferences.motion, reduced);
31
- window.dispatchEvent(new CustomEvent(eventName, { detail: preferences }));
32
- }
33
-
34
- function readPreferences(storageKey: string): Preferences {
35
- try { return parsePreferences(window.localStorage.getItem(storageKey)); }
36
- catch { return { ...defaultPreferences }; }
37
- }
38
-
39
- export function PreferencesProvider({ children, storageKey = preferencesKey, eventName = defaultEventName }: {
40
- children: ReactNode; storageKey?: string; eventName?: string;
41
- }) {
42
- const [preferences, setPreferences] = useState<Preferences>(defaultPreferences);
43
- const preferencesRef = useRef<Preferences>(defaultPreferences);
44
-
45
- useLayoutEffect(() => {
46
- const stored = readPreferences(storageKey);
47
- preferencesRef.current = stored;
48
- setPreferences(stored);
49
- applyPreferences(stored, eventName);
50
-
51
- const themeQuery = window.matchMedia('(prefers-color-scheme: dark)');
52
- const motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
53
- const onSystemChange = () => applyPreferences(preferencesRef.current, eventName);
54
- const onStorage = (event: StorageEvent) => {
55
- if (event.key !== storageKey && event.key !== null) return;
56
- const next = readPreferences(storageKey);
57
- preferencesRef.current = next;
58
- setPreferences(next);
59
- applyPreferences(next, eventName);
60
- };
61
- themeQuery.addEventListener('change', onSystemChange);
62
- motionQuery.addEventListener('change', onSystemChange);
63
- window.addEventListener('storage', onStorage);
64
- return () => {
65
- themeQuery.removeEventListener('change', onSystemChange);
66
- motionQuery.removeEventListener('change', onSystemChange);
67
- window.removeEventListener('storage', onStorage);
68
- };
69
- }, [storageKey, eventName]);
70
-
71
- const save = useCallback((next: Preferences) => {
72
- const safe = validatePreferences(next);
73
- preferencesRef.current = safe;
74
- setPreferences(safe);
75
- applyPreferences(safe, eventName);
76
- try { window.localStorage.setItem(storageKey, serializePreferences(safe)); }
77
- catch { /* Settings still work for this tab when storage is unavailable. */ }
78
- }, [storageKey, eventName]);
79
-
80
- const setPreference = useCallback(<K extends keyof Preferences>(key: K, value: Preferences[K]) => {
81
- save({ ...preferencesRef.current, [key]: value });
82
- }, [save]);
83
-
84
- const resetPreferences = useCallback(() => save({ ...defaultPreferences }), [save]);
85
-
86
- return <Context.Provider value={{ preferences, setPreference, resetPreferences }}>{children}</Context.Provider>;
87
- }
88
-
89
- export function usePreferences() {
90
- const context = useContext(Context);
91
- if (!context) throw new Error('PreferencesProvider가 필요합니다.');
92
- return context;
93
- }
94
-
95
- const themeOptions: Record<Locale, { value: ThemePreference; label: string }[]> = {
96
- ko: [{ value: 'system', label: '기기 설정' }, { value: 'light', label: '밝게' }, { value: 'dark', label: '어둡게' }],
97
- en: [{ value: 'system', label: 'System' }, { value: 'light', label: 'Light' }, { value: 'dark', label: 'Dark' }],
98
- };
99
-
100
- export function ThemeToggle({ locale = 'ko' }: { locale?: Locale }) {
101
- const { preferences, setPreference } = usePreferences();
102
- const options = themeOptions[locale];
103
- const current = options.find(option => option.value === preferences.theme)!;
104
- const next = options[(options.findIndex(option => option.value === preferences.theme) + 1) % options.length]!;
105
- return <button
106
- type="button"
107
- className={'hds-themeToggle'}
108
- onClick={() => setPreference('theme', next.value)}
109
- aria-label={locale === 'ko' ? `현재 테마 ${current.label}. ${next.label} 모드로 변경` : `Current theme: ${current.label}. Switch to ${next.label} mode`}
110
- title={locale === 'ko' ? `현재 ${current.label} · 다음 ${next.label}` : `Current: ${current.label} · Next: ${next.label}`}
111
- >
112
- <svg aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
113
- {preferences.theme === 'system' && <><rect x="3" y="4" width="18" height="13" rx="1" /><path d="M8 21h8M12 17v4" /></>}
114
- {preferences.theme === 'light' && <><circle cx="12" cy="12" r="4" /><path d="M12 2v2m0 16v2M2 12h2m16 0h2M4.9 4.9l1.4 1.4m11.4 11.4 1.4 1.4m0-14.2-1.4 1.4M6.3 17.7l-1.4 1.4" /></>}
115
- {preferences.theme === 'dark' && <path d="M20.3 15.7A8.5 8.5 0 0 1 8.3 3.7a8.5 8.5 0 1 0 12 12Z" />}
116
- </svg>
117
- <span aria-hidden="true">{current.label}</span>
118
- </button>;
119
- }
120
-
121
- type Choice<K extends keyof Preferences> = { value: Preferences[K]; label: string };
122
-
123
- function RadioGroup<K extends 'theme' | 'density' | 'corners' | 'motion'>({
124
- field, legend, choices, name,
125
- }: { field: K; legend: string; choices: Choice<K>[]; name: string }) {
126
- const { preferences, setPreference } = usePreferences();
127
- return <fieldset className={'hds-group'}>
128
- <legend>{legend}</legend>
129
- <div className={'hds-options'}>
130
- {choices.map(choice => <label className={'hds-radioOption'} key={choice.value}>
131
- <input type="radio" name={`${name}-${field}`} value={choice.value} checked={preferences[field] === choice.value} onChange={() => setPreference(field, choice.value)} />
132
- <span>{choice.label}</span>
133
- </label>)}
134
- </div>
135
- </fieldset>;
136
- }
137
-
138
- export function PreferencesPanel({ locale = 'ko' }: { locale?: Locale }) {
139
- const { preferences, setPreference, resetPreferences } = usePreferences();
140
- const panelId = useId();
141
- const en = locale === 'en';
142
- const accentOptions = en
143
- ? [{ value: 'cobalt', label: 'Cobalt' }, { value: 'forest', label: 'Forest' }, { value: 'coral', label: 'Coral' }] as const
144
- : [{ value: 'cobalt', label: '코발트' }, { value: 'forest', label: '포레스트' }, { value: 'coral', label: '코랄' }] as const;
145
- return <section className={'hds-panel'} aria-labelledby={`${panelId}-title`}>
146
- <div className={'hds-heading'}><div><span className={'hds-kicker'}>DISPLAY / CONTROL</span><h2 id={`${panelId}-title`}>{en ? 'Display settings' : '화면 설정'}</h2></div><p>{en ? 'Adjust the display for comfortable reading.' : '읽기 편한 화면으로 바꿔 보세요.'}</p></div>
147
- <div className={'hds-groups'}>
148
- <RadioGroup field="theme" legend={en ? 'Theme' : '테마'} choices={themeOptions[locale]} name={panelId} />
149
- <fieldset className={'hds-group'}>
150
- <legend>{en ? 'Accent color' : '강조 색상'}</legend>
151
- <div className={'hds-accents'}>
152
- {accentOptions.map(({ value, label }) => <button type="button" key={value} className={`${'hds-accentButton'} ${`hds-${value}`}`} aria-pressed={preferences.accent === value} aria-label={en ? `${label} accent color${preferences.accent === value ? ', selected' : ''}` : `${label} 강조 색상${preferences.accent === value ? ', 선택됨' : ''}`} onClick={() => setPreference('accent', value)}><span className={'hds-swatch'} aria-hidden="true">{preferences.accent === value ? '✓' : ''}</span><span>{label}</span></button>)}
153
- </div>
154
- </fieldset>
155
- <RadioGroup field="density" legend={en ? 'Spacing' : '간격'} choices={en ? [{ value: 'comfortable', label: 'Default' }, { value: 'compact', label: 'Compact' }] : [{ value: 'comfortable', label: '기본' }, { value: 'compact', label: '촘촘하게' }]} name={panelId} />
156
- <RadioGroup field="corners" legend={en ? 'Corners' : '모서리'} choices={en ? [{ value: 'crisp', label: 'Sharp' }, { value: 'soft', label: 'Rounded' }] : [{ value: 'crisp', label: '각지게' }, { value: 'soft', label: '부드럽게' }]} name={panelId} />
157
- <RadioGroup field="motion" legend={en ? 'Motion' : '움직임'} choices={en ? [{ value: 'full', label: 'Default' }, { value: 'reduced', label: 'Reduced' }] : [{ value: 'full', label: '기본' }, { value: 'reduced', label: '줄이기' }]} name={panelId} />
158
- </div>
159
- <div className={'hds-footer'}><p role="status" aria-live="polite">{en ? 'Current settings: ' : '현재 설정: '}{themeOptions[locale].find(option => option.value === preferences.theme)?.label}, {accentOptions.find(option => option.value === preferences.accent)?.label}, {en ? (preferences.density === 'compact' ? 'compact spacing' : 'default spacing') : (preferences.density === 'compact' ? '촘촘한 간격' : '기본 간격')}, {en ? (preferences.corners === 'soft' ? 'rounded corners' : 'sharp corners') : (preferences.corners === 'soft' ? '부드러운 모서리' : '각진 모서리')}, {en ? (preferences.motion === 'reduced' ? 'reduced motion' : 'default motion') : (preferences.motion === 'reduced' ? '움직임 줄이기' : '기본 움직임')}</p><button type="button" onClick={resetPreferences}>{en ? 'Reset to defaults' : '기본값으로 되돌리기'}</button></div>
160
- </section>;
161
- }
@@ -1,30 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import {mkdtemp, mkdir, writeFile, rm} from 'node:fs/promises';
4
- import {tmpdir} from 'node:os';
5
- import {join} from 'node:path';
6
- import {fileURLToPath} from 'node:url';
7
- import {spawnSync} from 'node:child_process';
8
- const cli=fileURLToPath(new URL('../scripts/audit-tokens.mjs',import.meta.url));
9
- test('CSS audit catches new drift and bounds material exceptions by count',async()=>{
10
- const root=await mkdtemp(join(tmpdir(),'hds-audit-'));
11
- try{
12
- await mkdir(join(root,'src'));
13
- const config={paths:['src']};
14
- const writeConfig=()=>writeFile(join(root,'design-system.audit.json'),JSON.stringify(config));
15
- const css=join(root,'src','sample.css');
16
- const run=()=>spawnSync(process.execPath,[cli,root],{encoding:'utf8'});
17
- await writeConfig();
18
- await writeFile(css,'.card {color:var(--ink);background:var(--paper)} /* #abcdef is a note */');
19
- assert.equal(run().status,0);
20
- await writeFile(css,'.card {color:#ff00ff}');
21
- assert.equal(run().status,1);assert.match(run().stderr,/raw color/);
22
- config.exceptions={'src/sample.css':{reason:'Illustration material',colors:{'#ff00ff':1}}};
23
- await writeConfig();assert.equal(run().status,0);
24
- await writeFile(css,'.card {color:#ff00ff; border-color:#ff00ff}');assert.equal(run().status,1);
25
- await writeFile(css,':root {--ink:var(--accent-text)}');assert.match(run().stderr,/shared token --ink/);
26
- await writeFile(css,'.card {color:var(--ink)}');
27
- await writeFile(join(root,'src','new-file.css'),'.new {background:rgb(0 0 0)}');
28
- assert.match(run().stderr,/new-file\.css: raw color/);
29
- }finally{await rm(root,{recursive:true,force:true});}
30
- });
@@ -1,86 +0,0 @@
1
- import test from 'node:test';
2
- import assert from 'node:assert/strict';
3
- import vm from 'node:vm';
4
- import React from 'react';
5
- import { renderToStaticMarkup } from 'react-dom/server';
6
- import {
7
- createPreferenceScript, defaultPreferences, effectiveMotion, parsePreferences,
8
- preferenceScript, preferencesKey, resolvedTheme, serializePreferences, validatePreferences,
9
- } from '../dist/preferences.js';
10
- import { PreferencesPanel, PreferencesProvider, ThemeToggle } from '../dist/react.js';
11
-
12
- test('malformed and untrusted preferences fall back field by field', () => {
13
- assert.deepEqual(parsePreferences('{bad'), defaultPreferences);
14
- assert.deepEqual(parsePreferences('[]'), defaultPreferences);
15
- assert.deepEqual(validatePreferences({ theme: 'dark', accent: 'unknown', motion: 'reduced' }), {
16
- ...defaultPreferences, theme: 'dark', motion: 'reduced',
17
- });
18
- assert.deepEqual(JSON.parse(serializePreferences({ ...defaultPreferences, theme: 'dark', accent: 'bad' })), {
19
- ...defaultPreferences, theme: 'dark',
20
- });
21
- assert.equal(resolvedTheme('system', true), 'dark');
22
- assert.equal(resolvedTheme('system', false), 'light');
23
- assert.equal(resolvedTheme('light', true), 'light');
24
- assert.equal(effectiveMotion('full', true), 'reduced');
25
- assert.equal(effectiveMotion('full', false), 'full');
26
- });
27
-
28
- function runInitialScript({ key = preferencesKey, stored, dark = false, reduced = false, storageThrows = false } = {}) {
29
- const dataset = {};
30
- const requestedKeys = [];
31
- const context = {
32
- document: { documentElement: { dataset } },
33
- localStorage: { getItem(requested) {
34
- requestedKeys.push(requested);
35
- if (storageThrows) throw new Error('blocked');
36
- return stored ?? null;
37
- } },
38
- window: { matchMedia(query) {
39
- return { matches: query.includes('color-scheme') ? dark : reduced };
40
- } },
41
- };
42
- vm.runInNewContext(createPreferenceScript(key), context);
43
- return { dataset, requestedKeys };
44
- }
45
-
46
- test('initial script uses the same defaults, validation and OS overrides', () => {
47
- assert.equal(preferenceScript, createPreferenceScript());
48
- const stored = JSON.stringify({ theme: 'system', accent: 'forest', density: 'invalid', corners: 'soft', motion: 'full' });
49
- assert.deepEqual(runInitialScript({ stored, dark: true, reduced: true }).dataset, {
50
- theme: 'dark', themePreference: 'system', accent: 'forest', density: 'comfortable', corners: 'soft', motion: 'reduced',
51
- });
52
- assert.deepEqual(runInitialScript({ stored: '{bad', dark: true }).dataset, {
53
- theme: 'dark', themePreference: 'system', accent: 'cobalt', density: 'comfortable', corners: 'crisp', motion: 'full',
54
- });
55
- assert.deepEqual(runInitialScript({ storageThrows: true }).dataset, {
56
- theme: 'light', themePreference: 'system', accent: 'cobalt', density: 'comfortable', corners: 'crisp', motion: 'full',
57
- });
58
- });
59
-
60
- test('custom storage key is honored and safe inside inline HTML', () => {
61
- const key = '</script><script>alert(1)</script>\u2028';
62
- const script = createPreferenceScript(key);
63
- assert.equal(script.includes('</script>'), false);
64
- assert.equal(script.includes('<script>'), false);
65
- assert.equal(script.includes('\u2028'), false);
66
- assert.deepEqual(runInitialScript({ key }).requestedKeys, [key]);
67
- });
68
-
69
- test('SSR retains localized semantics and isolates multiple panels', () => {
70
- const html = renderToStaticMarkup(React.createElement(PreferencesProvider, null,
71
- React.createElement(React.Fragment, null,
72
- React.createElement(ThemeToggle, { locale: 'en' }),
73
- React.createElement(PreferencesPanel, { locale: 'ko' }),
74
- React.createElement(PreferencesPanel, { locale: 'en' }),
75
- )));
76
- assert.match(html, /Current theme: System\. Switch to Light mode/);
77
- assert.match(html, /화면 설정/);
78
- assert.match(html, /Display settings/);
79
- const ids = [...html.matchAll(/<h2 id="([^"]+)"/g)].map(match => match[1]);
80
- assert.equal(ids.length, 2);
81
- assert.notEqual(ids[0], ids[1]);
82
- assert.ok(ids.every(id => html.includes(`aria-labelledby="${id}"`)));
83
- const themeNames = [...html.matchAll(/name="([^"]+-theme)"/g)].map(match => match[1]);
84
- assert.equal(new Set(themeNames).size, 2);
85
- assert.match(html, /hds-panel/);
86
- });
@@ -1,16 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "lib": ["DOM", "ES2020"],
5
- "module": "ESNext",
6
- "moduleResolution": "Bundler",
7
- "jsx": "react-jsx",
8
- "declaration": true,
9
- "strict": true,
10
- "skipLibCheck": true,
11
- "noEmitOnError": true,
12
- "rootDir": "src",
13
- "outDir": "dist"
14
- },
15
- "include": ["src/**/*.ts", "src/**/*.tsx"]
16
- }