specdo 1.0.2
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/CHANGELOG.md +139 -0
- package/README.md +308 -0
- package/README.zh-CN.md +306 -0
- package/bin/specdo.js +3 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +297 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/_shared.d.ts +45 -0
- package/dist/commands/_shared.d.ts.map +1 -0
- package/dist/commands/_shared.js +124 -0
- package/dist/commands/_shared.js.map +1 -0
- package/dist/commands/apply.d.ts +30 -0
- package/dist/commands/apply.d.ts.map +1 -0
- package/dist/commands/apply.js +393 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/archive.d.ts +25 -0
- package/dist/commands/archive.d.ts.map +1 -0
- package/dist/commands/archive.js +362 -0
- package/dist/commands/archive.js.map +1 -0
- package/dist/commands/doctor.d.ts +21 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +180 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/domains.d.ts +14 -0
- package/dist/commands/domains.d.ts.map +1 -0
- package/dist/commands/domains.js +107 -0
- package/dist/commands/domains.js.map +1 -0
- package/dist/commands/explore.d.ts +48 -0
- package/dist/commands/explore.d.ts.map +1 -0
- package/dist/commands/explore.js +378 -0
- package/dist/commands/explore.js.map +1 -0
- package/dist/commands/init.d.ts +45 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +243 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +23 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +135 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/propose.d.ts +22 -0
- package/dist/commands/propose.d.ts.map +1 -0
- package/dist/commands/propose.js +316 -0
- package/dist/commands/propose.js.map +1 -0
- package/dist/commands/show.d.ts +15 -0
- package/dist/commands/show.d.ts.map +1 -0
- package/dist/commands/show.js +214 -0
- package/dist/commands/show.js.map +1 -0
- package/dist/commands/status.d.ts +17 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +146 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +21 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +113 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/validate.d.ts +117 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +446 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/core/apply-brief-renderer.d.ts +35 -0
- package/dist/core/apply-brief-renderer.d.ts.map +1 -0
- package/dist/core/apply-brief-renderer.js +242 -0
- package/dist/core/apply-brief-renderer.js.map +1 -0
- package/dist/core/config-store.d.ts +190 -0
- package/dist/core/config-store.d.ts.map +1 -0
- package/dist/core/config-store.js +280 -0
- package/dist/core/config-store.js.map +1 -0
- package/dist/core/context-store.d.ts +96 -0
- package/dist/core/context-store.d.ts.map +1 -0
- package/dist/core/context-store.js +426 -0
- package/dist/core/context-store.js.map +1 -0
- package/dist/core/json-schemas.d.ts +349 -0
- package/dist/core/json-schemas.d.ts.map +1 -0
- package/dist/core/json-schemas.js +125 -0
- package/dist/core/json-schemas.js.map +1 -0
- package/dist/core/skill-content/cross-domain.d.ts +12 -0
- package/dist/core/skill-content/cross-domain.d.ts.map +1 -0
- package/dist/core/skill-content/cross-domain.js +291 -0
- package/dist/core/skill-content/cross-domain.js.map +1 -0
- package/dist/core/skill-content/protocol-examples.d.ts +13 -0
- package/dist/core/skill-content/protocol-examples.d.ts.map +1 -0
- package/dist/core/skill-content/protocol-examples.js +190 -0
- package/dist/core/skill-content/protocol-examples.js.map +1 -0
- package/dist/core/skill-content/workflow-content.d.ts +25 -0
- package/dist/core/skill-content/workflow-content.d.ts.map +1 -0
- package/dist/core/skill-content/workflow-content.js +1572 -0
- package/dist/core/skill-content/workflow-content.js.map +1 -0
- package/dist/core/skill-exporter.d.ts +186 -0
- package/dist/core/skill-exporter.d.ts.map +1 -0
- package/dist/core/skill-exporter.js +922 -0
- package/dist/core/skill-exporter.js.map +1 -0
- package/dist/core/spec-sync.d.ts +65 -0
- package/dist/core/spec-sync.d.ts.map +1 -0
- package/dist/core/spec-sync.js +226 -0
- package/dist/core/spec-sync.js.map +1 -0
- package/dist/core/task-parser.d.ts +58 -0
- package/dist/core/task-parser.d.ts.map +1 -0
- package/dist/core/task-parser.js +244 -0
- package/dist/core/task-parser.js.map +1 -0
- package/dist/core/template-renderer.d.ts +51 -0
- package/dist/core/template-renderer.d.ts.map +1 -0
- package/dist/core/template-renderer.js +362 -0
- package/dist/core/template-renderer.js.map +1 -0
- package/dist/domains/architecture.d.ts +34 -0
- package/dist/domains/architecture.d.ts.map +1 -0
- package/dist/domains/architecture.js +341 -0
- package/dist/domains/architecture.js.map +1 -0
- package/dist/domains/backend.d.ts +35 -0
- package/dist/domains/backend.d.ts.map +1 -0
- package/dist/domains/backend.js +367 -0
- package/dist/domains/backend.js.map +1 -0
- package/dist/domains/frontend.d.ts +36 -0
- package/dist/domains/frontend.d.ts.map +1 -0
- package/dist/domains/frontend.js +373 -0
- package/dist/domains/frontend.js.map +1 -0
- package/dist/domains/index.d.ts +49 -0
- package/dist/domains/index.d.ts.map +1 -0
- package/dist/domains/index.js +255 -0
- package/dist/domains/index.js.map +1 -0
- package/dist/domains/operations.d.ts +37 -0
- package/dist/domains/operations.d.ts.map +1 -0
- package/dist/domains/operations.js +344 -0
- package/dist/domains/operations.js.map +1 -0
- package/dist/domains/pool-ranking.d.ts +43 -0
- package/dist/domains/pool-ranking.d.ts.map +1 -0
- package/dist/domains/pool-ranking.js +153 -0
- package/dist/domains/pool-ranking.js.map +1 -0
- package/dist/domains/quality.d.ts +45 -0
- package/dist/domains/quality.d.ts.map +1 -0
- package/dist/domains/quality.js +368 -0
- package/dist/domains/quality.js.map +1 -0
- package/dist/domains/security.d.ts +19 -0
- package/dist/domains/security.d.ts.map +1 -0
- package/dist/domains/security.js +364 -0
- package/dist/domains/security.js.map +1 -0
- package/dist/domains/signal-match.d.ts +25 -0
- package/dist/domains/signal-match.d.ts.map +1 -0
- package/dist/domains/signal-match.js +67 -0
- package/dist/domains/signal-match.js.map +1 -0
- package/dist/domains/types.d.ts +354 -0
- package/dist/domains/types.d.ts.map +1 -0
- package/dist/domains/types.js +12 -0
- package/dist/domains/types.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/protocols/index.d.ts +36 -0
- package/dist/protocols/index.d.ts.map +1 -0
- package/dist/protocols/index.js +85 -0
- package/dist/protocols/index.js.map +1 -0
- package/dist/protocols/review-to-solid.d.ts +32 -0
- package/dist/protocols/review-to-solid.d.ts.map +1 -0
- package/dist/protocols/review-to-solid.js +309 -0
- package/dist/protocols/review-to-solid.js.map +1 -0
- package/dist/utils/prompt.d.ts +37 -0
- package/dist/utils/prompt.d.ts.map +1 -0
- package/dist/utils/prompt.js +81 -0
- package/dist/utils/prompt.js.map +1 -0
- package/package.json +80 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontend Domain Module
|
|
3
|
+
*
|
|
4
|
+
* 来源 (5 个):
|
|
5
|
+
* - content/skills/frontend-ui-design/SKILL.md (110 行)
|
|
6
|
+
* + references/aesthetic-playbook.md (49) / anti-patterns.md (23) /
|
|
7
|
+
* tokens-and-semantics.md (38) / implementation-patterns.md (56) /
|
|
8
|
+
* react-next-best-practices.md (25) / ai-native-ui-patterns.md (42)
|
|
9
|
+
* 设计方向 / 一个 signature move / 设计令牌 / 严格 vs 灵活规则 / a11y / 性能预算
|
|
10
|
+
* - content/skills/react-best-practices/SKILL.md (122 行)
|
|
11
|
+
* Vercel 8 类共 45 条规则索引:消除 waterfall / bundle / 服务端 / 客户端数据 / 重渲染 / 渲染性能 / JS / 高级模式
|
|
12
|
+
* - content/roles/01-core-development/frontend-developer.toml (42 行)
|
|
13
|
+
* 用户可见行为 + state 完整性;route/component/state/data 边界
|
|
14
|
+
* - content/roles/01-core-development/ui-engineer.toml (47 行)
|
|
15
|
+
* 设计任务 + 修复任务双模式;交互状态 / 焦点顺序 / 视觉一致性
|
|
16
|
+
* - content/roles/01-core-development/mobile-developer.toml (47 行)
|
|
17
|
+
* RN/Flutter/SwiftUI/Compose;导航 / 状态 / 离线 / 平台 API;触控目标
|
|
18
|
+
*
|
|
19
|
+
* 压缩方法:
|
|
20
|
+
* 1. frontend-ui-design Quick Start + Workflow → design.checklist + design.patterns
|
|
21
|
+
* 2. aesthetic-playbook 6 个方向 → design.patterns "Aesthetic Direction"
|
|
22
|
+
* 3. anti-patterns.md 视觉/字体/动效/UX 反例 → design.antiPatterns
|
|
23
|
+
* 4. tokens-and-semantics 严格 vs 灵活规则 → design.checklist + implement.focusAreas
|
|
24
|
+
* 5. react-best-practices 8 类 45 规则 → implement.patterns + implement.antiPatterns(核心模式)
|
|
25
|
+
* 6. frontend-developer + ui-engineer quality checks → verify.checklist
|
|
26
|
+
* 7. mobile-developer 平台特定关注点 → design.checklist + implement.focusAreas
|
|
27
|
+
*
|
|
28
|
+
* 与相邻领域的边界:
|
|
29
|
+
* - 'lighthouse' / 'core web vitals' / 'lcp' 归 frontend;quality 用通用 'baseline metric'
|
|
30
|
+
* - 'bundle size' 归 frontend(tree-shaking / code splitting);operations 关注 release artefact
|
|
31
|
+
* - 'css' / 'animation' / 'react' 归 frontend;quality 关注通用 testing / review 方法
|
|
32
|
+
* - 'accessibility' / 'a11y' 归 frontend;security 关注 authn/authz
|
|
33
|
+
*/
|
|
34
|
+
export const frontendDomain = {
|
|
35
|
+
name: 'frontend',
|
|
36
|
+
description: 'UI engineering, React/Next.js performance, design systems, accessibility, motion, responsive layout, and mobile (RN/Flutter/SwiftUI/Compose)',
|
|
37
|
+
// ── Explore: 需求澄清 ─────────────────────────────────────
|
|
38
|
+
explore: {
|
|
39
|
+
signals: [
|
|
40
|
+
// 框架 / 渲染
|
|
41
|
+
'react', 'react.js', 'jsx', 'hooks', 'usestate', 'useeffect', 'usememo',
|
|
42
|
+
'usecallback', 'next.js', 'nextjs', 'app router', 'server component',
|
|
43
|
+
'client component', 'hydration', 'suspense', 'streaming', 'ssr', 'csr',
|
|
44
|
+
'vue', 'svelte', 'angular',
|
|
45
|
+
// UI / 视觉
|
|
46
|
+
'ui', 'component', 'design system', 'design tokens', 'theme',
|
|
47
|
+
'palette', 'typography', 'font pairing', 'layout', 'hero',
|
|
48
|
+
'landing page', 'modal', 'tooltip', 'dropdown', 'navigation',
|
|
49
|
+
// 样式
|
|
50
|
+
'css', 'scss', 'sass', 'tailwind', 'css module', 'styled-components',
|
|
51
|
+
'css variables',
|
|
52
|
+
// 动效 / 交互
|
|
53
|
+
'animation', 'motion', 'transition', 'micro-interaction',
|
|
54
|
+
'prefers-reduced-motion', 'hover state', 'focus state',
|
|
55
|
+
// 响应式 / 设备
|
|
56
|
+
'responsive', 'breakpoint', 'viewport', 'mobile-first',
|
|
57
|
+
// 可访问性
|
|
58
|
+
'a11y', 'accessibility', 'aria', 'keyboard navigation', 'screen reader',
|
|
59
|
+
// 性能(前端层面,与 quality 通用方法论切分)
|
|
60
|
+
'bundle size', 'code splitting', 'tree shaking', 'dynamic import',
|
|
61
|
+
'lazy load', 'lighthouse', 'core web vitals', 'lcp',
|
|
62
|
+
'cumulative layout shift', 'first input delay',
|
|
63
|
+
'image optimization', 're-render',
|
|
64
|
+
// 移动端
|
|
65
|
+
'react native', 'flutter', 'swiftui', 'jetpack compose', 'mobile app',
|
|
66
|
+
'safe area', 'touch target',
|
|
67
|
+
],
|
|
68
|
+
questions: {
|
|
69
|
+
defaultCount: 8,
|
|
70
|
+
items: [
|
|
71
|
+
// ── Tier 1: 用户与框架 (priority 10) ──────────────────
|
|
72
|
+
{
|
|
73
|
+
text: 'Who is the user and what is the job-to-be-done? What should feel "easy" or "obvious" after this change?',
|
|
74
|
+
signals: ['ui', 'user', 'component', 'ux', 'job-to-be-done', 'design', 'interaction', 'experience'],
|
|
75
|
+
priority: 10,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
text: 'Which framework and styling approach is in use? (React/Next.js, Vue, Svelte, Angular — Tailwind, CSS Modules, styled-components) — is this a new component or modifying existing?',
|
|
79
|
+
id: 'framework-styling',
|
|
80
|
+
signals: ['react', 'next.js', 'nextjs', 'vue', 'svelte', 'angular', 'tailwind', 'css', 'component', 'framework'],
|
|
81
|
+
priority: 10,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
text: 'Are there hard constraints? (brand tokens, design system, light/dark required, motion limits, must-preserve UI parts, performance budget in KB)',
|
|
85
|
+
signals: ['design system', 'design tokens', 'theme', 'light', 'dark', 'motion', 'constraint', 'brand', 'budget'],
|
|
86
|
+
priority: 9,
|
|
87
|
+
},
|
|
88
|
+
// ── Tier 2: 渲染策略 (priority 8) ─────────────────────
|
|
89
|
+
{
|
|
90
|
+
text: 'For React/Next.js: is this a Server Component, Client Component, or mixed? What data fetching pattern fits (server fetch, client SWR/TanStack Query)?',
|
|
91
|
+
signals: ['server component', 'client component', 'next.js', 'nextjs', 'app router', 'fetch', 'swr', 'tanstack', 'hydration', 'suspense'],
|
|
92
|
+
priority: 8,
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
text: 'What is the component tree decomposition? Which components are server-rendered, which are interactive islands, and where are the boundaries?',
|
|
96
|
+
signals: ['component', 'tree', 'server', 'client', 'boundary', 'interactive', 'island', 'architecture', 'composition'],
|
|
97
|
+
priority: 8,
|
|
98
|
+
requiresAnswer: ['frontend:framework-styling'],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
text: 'Is code splitting or lazy loading needed? Which heavy components or third-party libraries should be deferred?',
|
|
102
|
+
signals: ['code splitting', 'lazy load', 'dynamic import', 'bundle', 'tree shaking', 'next/dynamic', 'defer'],
|
|
103
|
+
priority: 7,
|
|
104
|
+
},
|
|
105
|
+
// ── Tier 3: 设计方向 (priority 8) ─────────────────────
|
|
106
|
+
{
|
|
107
|
+
text: 'What is the aesthetic direction? (Brutalist, Editorial, Swiss, Neo-Brutalism, Glassmorphism, Dark Luxury, Retro-Futurism — pick one, commit to it)',
|
|
108
|
+
signals: ['ui', 'design', 'aesthetic', 'style', 'visual', 'theme', 'brutalist', 'editorial', 'glass', 'luxury', 'retro', 'swiss'],
|
|
109
|
+
priority: 7,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
text: 'What is the one signature move? (a bold typography lockup, an overlapping bento grid, a parallax depth effect — one strong element, applied in 2-3 places max)',
|
|
113
|
+
signals: ['design', 'signature', 'hero', 'visual', 'animation', 'motion', 'typography', 'bento', 'parallax', 'layout'],
|
|
114
|
+
priority: 7,
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
text: 'What are the design tokens? (color scale, type ramp, spacing scale, radius scale, shadow tokens, motion durations + easing curves)',
|
|
118
|
+
signals: ['design tokens', 'tokens', 'css variables', 'theme', 'color', 'typography', 'spacing', 'radius', 'shadow', 'motion'],
|
|
119
|
+
priority: 7,
|
|
120
|
+
},
|
|
121
|
+
// ── Tier 4: 响应式 (priority 8) ───────────────────────
|
|
122
|
+
{
|
|
123
|
+
text: 'What are the responsive breakpoints? (320, 768, 1024, 1440 — mobile-first or desktop-first?) — what is the layout strategy at each?',
|
|
124
|
+
id: 'responsive-breakpoints',
|
|
125
|
+
signals: ['responsive', 'breakpoint', 'viewport', 'mobile-first', 'desktop', 'layout', 'grid', 'flexbox', 'media query'],
|
|
126
|
+
priority: 8,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
text: 'How does the layout adapt between mobile and desktop? Is the information hierarchy clear at both extremes?',
|
|
130
|
+
signals: ['responsive', 'mobile', 'desktop', 'layout', 'hierarchy', 'adapt', 'viewport', 'cramped', 'orphan'],
|
|
131
|
+
priority: 7,
|
|
132
|
+
requiresAnswer: ['frontend:responsive-breakpoints'],
|
|
133
|
+
},
|
|
134
|
+
// ── Tier 5: 状态完整性 (priority 8) ──────────────────
|
|
135
|
+
{
|
|
136
|
+
text: 'Which loading, empty, and error states does this UI need? How are they visually distinguished from each other (not just text)?',
|
|
137
|
+
signals: ['loading', 'empty', 'error', 'state', 'ui', 'skeleton', 'spinner', 'toast', 'fallback', 'ux'],
|
|
138
|
+
priority: 8,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
text: 'What happens during async operations? (loading indicator, optimistic update, error recovery — how is stale data or race conditions prevented?)',
|
|
142
|
+
signals: ['async', 'loading', 'optimistic', 'error', 'stale', 'race', 'data', 'fetch', 'update', 'suspense'],
|
|
143
|
+
priority: 8,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
text: 'What are the interactive states for every actionable element? (hover, focus, active/pressed, disabled, loading — are all 5 states designed?)',
|
|
147
|
+
signals: ['hover', 'focus', 'active', 'disabled', 'loading', 'state', 'interactive', 'button', 'input', 'affordance'],
|
|
148
|
+
priority: 7,
|
|
149
|
+
},
|
|
150
|
+
// ── Tier 6: 可访问性 (priority 8) ────────────────────
|
|
151
|
+
{
|
|
152
|
+
text: 'What are the accessibility requirements? (WCAG AA minimum, screen reader support, keyboard navigation, focus order, color contrast)',
|
|
153
|
+
id: 'accessibility-req',
|
|
154
|
+
signals: ['a11y', 'accessibility', 'wcag', 'aria', 'keyboard navigation', 'screen reader', 'focus', 'contrast', 'semantic'],
|
|
155
|
+
priority: 9,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
text: 'Is semantic HTML used? (button for actions, a for navigation, form for inputs, landmarks for page structure — not divs with onClick)',
|
|
159
|
+
signals: ['semantic', 'html', 'button', 'link', 'form', 'landmark', 'aria', 'a11y', 'accessibility'],
|
|
160
|
+
priority: 8,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
text: 'Does keyboard-only navigation work for the primary user journey? Are focus traps handled in modals/drawers/dropdowns?',
|
|
164
|
+
signals: ['keyboard', 'navigation', 'focus', 'trap', 'modal', 'a11y', 'accessibility', 'tab'],
|
|
165
|
+
priority: 8,
|
|
166
|
+
requiresAnswer: ['frontend:accessibility-req'],
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
text: 'Is prefers-reduced-motion respected? Are all animations disabled or downgraded for affected users?',
|
|
170
|
+
signals: ['prefers-reduced-motion', 'a11y', 'accessibility', 'animation', 'motion', 'reduce'],
|
|
171
|
+
priority: 7,
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
text: 'Are all inputs labeled? Do icon-only actions have accessible names (aria-label)? Is color never the only state indicator?',
|
|
175
|
+
signals: ['input', 'label', 'icon', 'aria-label', 'a11y', 'accessibility', 'color', 'screen reader'],
|
|
176
|
+
priority: 8,
|
|
177
|
+
},
|
|
178
|
+
// ── Tier 7: 移动端 (priority 7) ───────────────────────
|
|
179
|
+
{
|
|
180
|
+
text: 'For mobile: which platform(s)? (iOS/SwiftUI, Android/Compose, React Native, Flutter) — what platform-specific behaviors must be respected?',
|
|
181
|
+
signals: ['mobile', 'ios', 'android', 'react native', 'flutter', 'swiftui', 'compose', 'platform'],
|
|
182
|
+
priority: 7,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
text: 'Are touch targets at least 44pt (iOS) / 48dp (Android)? Is there adequate spacing between tappable elements?',
|
|
186
|
+
signals: ['touch target', 'mobile', 'tap', 'ios', 'android', 'spacing', 'responsive', 'gesture'],
|
|
187
|
+
priority: 7,
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
text: 'Are safe areas, notch, and dynamic island respected? Does content avoid being clipped by system UI?',
|
|
191
|
+
signals: ['safe area', 'notch', 'dynamic island', 'mobile', 'ios', 'android', 'layout', 'status bar'],
|
|
192
|
+
priority: 6,
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
text: 'For mobile: how is offline handled? Is there local storage, queue-and-sync, or graceful degradation when connectivity is lost?',
|
|
196
|
+
signals: ['offline', 'mobile', 'network', 'sync', 'local', 'storage', 'queue', 'degradation', 'connectivity'],
|
|
197
|
+
priority: 6,
|
|
198
|
+
},
|
|
199
|
+
// ── Tier 8: 性能 (priority 7) ─────────────────────────
|
|
200
|
+
{
|
|
201
|
+
text: 'What is the performance budget? (bundle size <150KB gzipped landing, <300KB app; LCP <2.5s; CLS <0.1; INP <200ms)',
|
|
202
|
+
signals: ['performance', 'bundle size', 'lcp', 'cls', 'inp', 'core web vitals', 'lighthouse', 'budget', 'ttfb'],
|
|
203
|
+
priority: 7,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
text: 'How are images optimized? (WebP/AVIF format, srcset/sizes, lazy loading for below-fold, explicit width/height to prevent CLS)',
|
|
207
|
+
signals: ['image optimization', 'webp', 'avif', 'lazy load', 'srcset', 'sizes', 'cls', 'next/image', 'layout shift'],
|
|
208
|
+
priority: 7,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
text: 'How are fonts loaded? (font-display: swap, subset, preload critical weight — max 2 font families)',
|
|
212
|
+
signals: ['font', 'typography', 'font-display', 'swap', 'preload', 'subset', 'web font', 'google fonts'],
|
|
213
|
+
priority: 6,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
text: 'Is there a measurable re-render or bundle size concern? Have React DevTools Profiler or Lighthouse been run on the changed route?',
|
|
217
|
+
signals: ['re-render', 'performance', 'bundle', 'profiler', 'lighthouse', 'react', 'optimize', 'memo'],
|
|
218
|
+
priority: 6,
|
|
219
|
+
},
|
|
220
|
+
// ── Tier 9: 动画 (priority 6) ─────────────────────────
|
|
221
|
+
{
|
|
222
|
+
text: 'Are animations using compositor-friendly properties only? (transform, opacity — never width/height/top/left)',
|
|
223
|
+
signals: ['animation', 'motion', 'transform', 'opacity', 'compositor', 'performance', 'css', 'will-change'],
|
|
224
|
+
priority: 6,
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
text: 'Is there one orchestrated page-load animation sequence rather than random micro-animations everywhere? Are durations reasonable (<500ms)?',
|
|
228
|
+
signals: ['animation', 'motion', 'orchestration', 'sequence', 'micro-interaction', 'duration', 'timeline'],
|
|
229
|
+
priority: 6,
|
|
230
|
+
},
|
|
231
|
+
// ── Tier 10: 黑暗模式 (priority 6) ────────────────────
|
|
232
|
+
{
|
|
233
|
+
text: 'Is dark mode a first-class concern? Do both light and dark modes have adequate contrast (WCAG AA minimum) for all text and UI elements?',
|
|
234
|
+
signals: ['dark mode', 'theme', 'light', 'contrast', 'wcag', 'a11y', 'accessibility', 'color'],
|
|
235
|
+
priority: 6,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
text: 'Are theme tokens centralized as CSS custom properties with a single root toggle ([data-theme="dark"])? No hardcoded color duplication across components?',
|
|
239
|
+
signals: ['css variables', 'tokens', 'theme', 'dark mode', 'color', 'design system', 'custom properties'],
|
|
240
|
+
priority: 6,
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
// ── Design: 设计阶段 ─────────────────────────────────────
|
|
246
|
+
design: {
|
|
247
|
+
checklist: [
|
|
248
|
+
// 一致性 + 设计方向 (frontend-ui-design Quick Start)
|
|
249
|
+
'Aesthetic direction is committed to up front (one direction, one signature move) — not "we will see how it looks"',
|
|
250
|
+
'Design tokens defined: color (bg / surface / ink / muted / accent + danger/warning/success/info), type ramp (xs..2xl + line-heights), shape (radius scale), depth (shadow rules), motion (durations + easing)',
|
|
251
|
+
'Existing tokens / components in the repo are reused before introducing a new global styling system',
|
|
252
|
+
'Strict tokens respected: semantic colors are meaning (not decoration), readable type ramp, sentence case UI, dark mode is first-class, one primary CTA per view, visible focus',
|
|
253
|
+
'Information hierarchy is clear at mobile + desktop breakpoints (no cramped type, no orphan CTAs)',
|
|
254
|
+
// 状态完整性 (frontend-developer + ui-engineer)
|
|
255
|
+
'Loading, empty, and error states are designed for every data-driven UI — not just the happy path',
|
|
256
|
+
'Component and state ownership is explicit: which component owns which piece of state, where transitions happen',
|
|
257
|
+
'Async update correctness: stale data, race conditions, and cancellation are designed for, not hand-waved',
|
|
258
|
+
'Backend / API contract alignment is verified before implementation; API errors map to specific UI states',
|
|
259
|
+
// a11y 与交互 (ui-engineer + frontend-ui-design)
|
|
260
|
+
'Semantic HTML used: link for navigation, button for actions; no buttons styled as links or vice versa',
|
|
261
|
+
'Focus order is logical and explicit; tab traversal reaches every interactive element',
|
|
262
|
+
'Keyboard-only flow tested for primary user journeys; hover-only affordances are forbidden for critical actions',
|
|
263
|
+
'Color contrast meets WCAG AA in both light and dark modes; never rely on color alone to convey state',
|
|
264
|
+
// 移动端 (mobile-developer)
|
|
265
|
+
'For mobile: target platforms identified (RN / Flutter / SwiftUI / Compose); platform-specific code paths planned for divergent behavior',
|
|
266
|
+
'Touch targets meet 44pt (iOS) / 48dp (Android) minimum; safe area / notch / dynamic island handled',
|
|
267
|
+
'Adaptive layouts for different screen sizes and orientations; dark mode supported with proper tokens',
|
|
268
|
+
// 性能预算 (react-best-practices + frontend-ui-design)
|
|
269
|
+
'Performance budget declared: bundle size limit, target LCP, target Cumulative Layout Shift, target Time to Interactive',
|
|
270
|
+
'Layout shift avoided via stable heights / predictable grids / aspect-ratio reservations for images and embeds',
|
|
271
|
+
'Server vs Client component split intentional in Next.js; "use client" only where state / effects / browser APIs are required',
|
|
272
|
+
],
|
|
273
|
+
patterns: {
|
|
274
|
+
'Commit-to-One-Aesthetic Direction': 'Pick a single aesthetic (Brutalist Raw / Editorial / Techno-Gothic / Neo-Poster / Soft Craft / Industrial) and one signature move. Apply the signature in 2–3 places maximum; keep everything else quiet and supportive. Avoid "AI slop" defaults: generic purple-on-white gradients, samey hero+3-cards+logo-wall+FAQ layout, indiscriminate glow-and-blur.',
|
|
275
|
+
'Strict Token Set + Flexible Knobs': 'Strict tokens: semantic colors, readable type ramp, dark mode first-class, one primary CTA per view, visible focus. Flexible knobs: brand accent hue, surface temperature in dark mode, density preset (compact vs comfy). Promote ad-hoc colors/sizes into tokens after ~2 components.',
|
|
276
|
+
'Server Components by Default (Next.js App Router)': 'Default to Server Components; mark "use client" only for interactive islands (state / effects / browser APIs). Keep Client Components small and composable. Data fetching goes on the server when possible; client state stays local and purposeful.',
|
|
277
|
+
'Macro Grid + Micro Flexbox': 'Use CSS Grid for page-level / macro layout (regions, two-dimensional structures); use Flexbox for micro layout inside components (toolbars, cards). Mixing them by scope keeps responsive behavior predictable.',
|
|
278
|
+
'Loading / Empty / Error State Trio': 'Every data-driven UI ships with three explicit states beyond success: loading (skeleton or spinner with timeout), empty (actionable next step, not just "no data"), error (recovery path, not just stack trace).',
|
|
279
|
+
'Reduced-Motion-Safe Animation Orchestration': 'One strong page-load orchestration + a few micro-interactions, not random flourishes. Wrap motion in @media (prefers-reduced-motion: reduce) fallbacks; never gate critical affordances on hover or motion.',
|
|
280
|
+
},
|
|
281
|
+
antiPatterns: [
|
|
282
|
+
// anti-patterns.md
|
|
283
|
+
'Generic purple-on-white gradients with soft glass cards everywhere — visual cliché that signals "AI default"',
|
|
284
|
+
'Samey startup landing layout: centered hero, 3 cards, logo wall, FAQ, identical CTA band — predictable means forgettable',
|
|
285
|
+
'Indiscriminate glow + blur layers — reduces legibility without adding hierarchy',
|
|
286
|
+
'Random micro-animations everywhere instead of one orchestrated sequence — visual noise without purpose',
|
|
287
|
+
'No prefers-reduced-motion handling — accessibility regression for vestibular-sensitive users',
|
|
288
|
+
'Hover-only affordances — mobile and keyboard users get nothing',
|
|
289
|
+
'Buttons styled as links (or vice versa) without correct semantics — breaks keyboard navigation and screen readers',
|
|
290
|
+
'Missing labels on inputs, icon-only actions without accessible names — screen-reader hostile',
|
|
291
|
+
'ALL CAPS for body / UI labels by default — reduces readability and signals shouting',
|
|
292
|
+
'Multiple primary CTAs competing on the same view — user is left guessing which action matters',
|
|
293
|
+
'Introducing a new global styling system in an existing repo without explicit ask — fragments the design language',
|
|
294
|
+
],
|
|
295
|
+
},
|
|
296
|
+
// ── Implement: 实施阶段 ──────────────────────────────────
|
|
297
|
+
implement: {
|
|
298
|
+
focusAreas: [
|
|
299
|
+
// React 性能(来自 react-best-practices 的 8 类核心)
|
|
300
|
+
'Eliminate request waterfalls: use Promise.all() for independent operations; start promises early and await late; use Suspense boundaries to stream content',
|
|
301
|
+
'Bundle size: avoid barrel imports; use next/dynamic for heavy components; defer third-party scripts until after hydration; preload on hover/focus for perceived speed',
|
|
302
|
+
'Server-side performance (Next.js): use React.cache() for per-request dedup; minimize data passed to Client Components; restructure components so fetches parallelize',
|
|
303
|
+
'Re-render optimization: memoize expensive components with React.memo; use primitive dependencies in effects; subscribe to derived booleans rather than raw values; functional setState for stable callbacks',
|
|
304
|
+
'Rendering performance: use content-visibility for long lists; hoist static JSX outside components; reduce SVG coordinate precision; ternary instead of && for conditional rendering',
|
|
305
|
+
// 实现纪律 (frontend-developer + ui-engineer)
|
|
306
|
+
'Diff is reviewable and scoped — no abstractions introduced unless they remove repeated complexity',
|
|
307
|
+
'Existing component / styling conventions preserved; new tokens or components only when truly required',
|
|
308
|
+
'Touch interactions: hover does not gate functionality; tap targets meet platform minimums; gestures have keyboard equivalents',
|
|
309
|
+
// a11y 实现
|
|
310
|
+
'Semantic landmarks (header / main / nav / footer) present; one h1 per page; skip-link when navigation is heavy',
|
|
311
|
+
'Focus is visible (do not remove outlines without a replacement that meets contrast); focus order follows visual order',
|
|
312
|
+
'ARIA used minimally and correctly — semantic HTML first, ARIA only where native semantics are insufficient',
|
|
313
|
+
// 数据 / 状态
|
|
314
|
+
'Client state stays local and purposeful; global state introduced only when sharing is real, not hypothetical',
|
|
315
|
+
'Server fetch with explicit cache / revalidate controls (Next.js); avoid client-side effects for data the server can prefetch',
|
|
316
|
+
// 移动端
|
|
317
|
+
'For mobile: avoid memory leaks from subscriptions / observers / closures; respect app lifecycle (background / foreground / state restoration)',
|
|
318
|
+
'Permissions requested at point of use with graceful degradation on denial; sensitive data goes to keychain / keystore',
|
|
319
|
+
// 性能验证 (react-best-practices low-impact但常见的 JS 类规则)
|
|
320
|
+
'Hot loops: hoist regexp / cache property access / use Set or Map for O(1) lookups / early-exit / length-check before expensive comparison',
|
|
321
|
+
'Image optimization: correct format (WebP / AVIF), responsive sizes, lazy loading, explicit width/height to avoid layout shift',
|
|
322
|
+
],
|
|
323
|
+
patterns: {
|
|
324
|
+
'next/dynamic for Heavy Components': 'For components that are heavy and not above-the-fold (modals, charts, editors): use next/dynamic with ssr: false where appropriate. The component is loaded on demand; the bundle is smaller; LCP is unaffected.',
|
|
325
|
+
'Server-Side fetch with Cache and Revalidate': 'In Server Components: const data = await fetch(url, { next: { revalidate: 60 } }). Lets you control cache lifetime declaratively; avoids client-side useEffect data fetching for data the server already knows.',
|
|
326
|
+
'Stable Layout via Reserved Height + aspect-ratio': 'Reserve space for images, embeds, and ads using width/height attributes or aspect-ratio CSS. Eliminates Cumulative Layout Shift, prevents content jumping after hydration.',
|
|
327
|
+
'Functional setState for Stable Callbacks': 'setCount(prev => prev + 1) instead of setCount(count + 1). Lets the callback be stable across renders without depending on count, eliminating a class of stale-closure bugs and unnecessary effect re-runs.',
|
|
328
|
+
'Memoization at the Right Boundary': 'React.memo / useMemo / useCallback only when profiling shows wasted re-renders or expensive calculation. Default is no memoization — premature memoization adds complexity without measurable benefit.',
|
|
329
|
+
'CSS Variables for Theme + Dark Mode': 'Define tokens as CSS custom properties (--bg, --ink, --accent, ...). Switch theme by overriding properties on a parent selector ([data-theme="dark"]), not by duplicating component CSS. Dark mode becomes a single-property change.',
|
|
330
|
+
},
|
|
331
|
+
antiPatterns: [
|
|
332
|
+
'Animating non-composited properties (top / left / width / height) instead of transform / opacity — triggers layout/paint, drops frames on mobile',
|
|
333
|
+
'Layout shift from late-loading images or web fonts without size reservation — kills CLS, frustrates real users',
|
|
334
|
+
'Using barrel imports (export * from "./...") in client bundles — defeats tree-shaking, bloats the entrypoint',
|
|
335
|
+
'Subscribing to a large state object in a leaf component when only one boolean is needed — every unrelated update re-renders the leaf',
|
|
336
|
+
'useEffect for derived state that could be computed during render — adds an extra render and a class of stale-derived-value bugs',
|
|
337
|
+
'Rendering long lists without virtualization or content-visibility — main thread spends seconds on hidden DOM',
|
|
338
|
+
'Hardcoding colors or font sizes in component CSS instead of consuming tokens — design system drifts every PR',
|
|
339
|
+
'Loading analytics / chat widgets / heavy third-party scripts during initial hydration — TTI regresses for every visitor',
|
|
340
|
+
'Using innerHTML / dangerouslySetInnerHTML with user-controlled data (also a security issue — see security domain)',
|
|
341
|
+
'For mobile: polling instead of push, fetching on every focus, holding subscriptions in detached views — burns battery and bandwidth',
|
|
342
|
+
],
|
|
343
|
+
},
|
|
344
|
+
// ── Verify: 验证阶段 ─────────────────────────────────────
|
|
345
|
+
verify: {
|
|
346
|
+
checklist: [
|
|
347
|
+
// 视觉与布局
|
|
348
|
+
'Layout looks intentional at mobile + desktop breakpoints (no cramped type, no orphan CTAs, signature move present but not overused)',
|
|
349
|
+
'Tokens are centralized (CSS variables / theme object) — no hardcoded colors or font sizes in changed components',
|
|
350
|
+
'Dark mode renders correctly with adequate contrast in both modes; no token leakage between themes',
|
|
351
|
+
// a11y 验证
|
|
352
|
+
'One h1 per page; landmarks present; logical tab order verified by keyboard-only traversal',
|
|
353
|
+
'Focus states visible on every interactive element (not removed without replacement)',
|
|
354
|
+
'prefers-reduced-motion respected: animations are disabled or downgraded for affected users',
|
|
355
|
+
'All inputs have labels; icon-only actions have accessible names; color is not the only state indicator',
|
|
356
|
+
// 性能验证
|
|
357
|
+
'Lighthouse / Core Web Vitals measured on the changed route(s): LCP, CLS, INP, TBT recorded before/after',
|
|
358
|
+
'Bundle size delta measured; new entry-point growth is justified or rolled back',
|
|
359
|
+
'No layout shift introduced by changes (images / fonts / dynamic content reserve space)',
|
|
360
|
+
'Hot user paths (typing, scrolling, opening modals) profiled — no jank from heavy effects on interaction',
|
|
361
|
+
// 状态完整性
|
|
362
|
+
'Loading, empty, and error states verified by walkthrough — not just happy path',
|
|
363
|
+
'Async update correctness verified: refresh while pending, navigate away, slow network — UI behaves predictably',
|
|
364
|
+
// 跨浏览器 / 设备
|
|
365
|
+
'Tested at minimum target browser matrix (latest Chrome, Safari, Firefox); mobile breakpoints verified on real or simulated device',
|
|
366
|
+
// 移动端
|
|
367
|
+
'For mobile: VoiceOver / TalkBack walkthrough completed for changed screens; dynamic type respected',
|
|
368
|
+
'Touch targets meet platform minimums; safe-area / notch / dynamic island do not clip critical UI',
|
|
369
|
+
'No memory leaks from subscriptions or observers; app lifecycle (background → foreground) preserves state',
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
};
|
|
373
|
+
//# sourceMappingURL=frontend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.js","sourceRoot":"","sources":["../../src/domains/frontend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,UAAU;IAChB,WAAW,EACT,8IAA8I;IAEhJ,yDAAyD;IAEzD,OAAO,EAAE;QACP,OAAO,EAAE;YACP,UAAU;YACV,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS;YACvE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,kBAAkB;YACpE,kBAAkB,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;YACtE,KAAK,EAAE,QAAQ,EAAE,SAAS;YAC1B,UAAU;YACV,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO;YAC5D,SAAS,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM;YACzD,cAAc,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY;YAC5D,KAAK;YACL,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,mBAAmB;YAC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,sIAAsI;YACtI,iIAAiI;YACjI,8GAA8G;YAC9G,8GAA8G;YAC9G,yHAAyH;YACzH,mHAAmH;YACnH,qIAAqI;SACtI;KACF;IAED,wDAAwD;IAExD,MAAM,EAAE;QACN,SAAS,EAAE;YACT,QAAQ;YACR,qIAAqI;YACrI,iHAAiH;YACjH,mGAAmG;YACnG,UAAU;YACV,2FAA2F;YAC3F,qFAAqF;YACrF,4FAA4F;YAC5F,wGAAwG;YACxG,OAAO;YACP,yGAAyG;YACzG,gFAAgF;YAChF,wFAAwF;YACxF,yGAAyG;YACzG,QAAQ;YACR,gFAAgF;YAChF,gHAAgH;YAChH,YAAY;YACZ,mIAAmI;YACnI,MAAM;YACN,oGAAoG;YACpG,kGAAkG;YAClG,0GAA0G;SAC3G;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain Registry
|
|
3
|
+
*
|
|
4
|
+
* 所有领域模块的注册中心和匹配引擎。
|
|
5
|
+
* scoreDomains() 是领域注入的核心函数 — 每个工作流阶段都通过它决定注入哪些领域知识。
|
|
6
|
+
*/
|
|
7
|
+
import type { DomainModule, DomainMatch, DomainOverrides } from './types.js';
|
|
8
|
+
export { tokenize, signalMatchesToken, TOKENIZE_SPLIT_CHARS, MIN_SIGNAL_LENGTH_FOR_SUBSTRING } from './signal-match.js';
|
|
9
|
+
export { rankQuestions, upgradeLegacyQuestions, extractQuestions, getQuestionCount, isQuestionPool } from './pool-ranking.js';
|
|
10
|
+
export interface ScoreDomainsOptions {
|
|
11
|
+
/** 返回的领域数量上限(默认 3;0 = 不限) */
|
|
12
|
+
maxDomains?: number;
|
|
13
|
+
}
|
|
14
|
+
/** 所有领域模块(6 领域全部注册) */
|
|
15
|
+
export declare const ALL_DOMAINS: DomainModule[];
|
|
16
|
+
/** 按名称查找领域模块 */
|
|
17
|
+
export declare function getDomainByName(name: string): DomainModule | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* 将项目级领域规则覆盖合并到领域模块中。
|
|
20
|
+
*
|
|
21
|
+
* 不可变操作 — 返回新 DomainModule,不修改原始模块。
|
|
22
|
+
*
|
|
23
|
+
* OverrideItem 合并规则:
|
|
24
|
+
* - prepend: 插入到列表最前面
|
|
25
|
+
* - append: 追加到列表最后面
|
|
26
|
+
* - replace: 整段替换默认列表;一旦出现 replace,prepend / append 全部失效
|
|
27
|
+
* - patterns 直接合并(同名 key 用覆盖值)
|
|
28
|
+
*
|
|
29
|
+
* 多模块共享: 对于 checklist、focusAreas、antiPatterns 等列表字段,
|
|
30
|
+
* 不同 stage 独立合并,不会冲突。
|
|
31
|
+
*
|
|
32
|
+
* @param domain - 原始领域模块
|
|
33
|
+
* @param overrides - 项目级覆盖配置(来自 config.yaml domains.overrides)
|
|
34
|
+
* @returns 合并了项目规则的新领域模块
|
|
35
|
+
*/
|
|
36
|
+
export declare function applyOverrides(domain: DomainModule, overrides: DomainOverrides | undefined): DomainModule;
|
|
37
|
+
/**
|
|
38
|
+
* 纯函数:对任意领域列表计算匹配分数。
|
|
39
|
+
*
|
|
40
|
+
* 与 matchDomains 的区别:接受显式 domains 参数,不依赖全局 ALL_DOMAINS。
|
|
41
|
+
* 导出让测试可以用独立的多领域 registry 验证排序、top-N、零匹配等行为。
|
|
42
|
+
*
|
|
43
|
+
* @param input - 用户输入文本
|
|
44
|
+
* @param domains - 领域模块列表
|
|
45
|
+
* @param options - 匹配选项;maxDomains 为返回数量上限(默认 3;0 = 不限)
|
|
46
|
+
* @returns 匹配的领域列表,按相关性降序,含分数和原因
|
|
47
|
+
*/
|
|
48
|
+
export declare function scoreDomains(input: string, domains: DomainModule[], options?: ScoreDomainsOptions | number): DomainMatch[];
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/domains/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EAKhB,MAAM,YAAY,CAAC;AAUpB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AACxH,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE9H,MAAM,WAAW,mBAAmB;IAClC,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,uBAAuB;AACvB,eAAO,MAAM,WAAW,EAAE,YAAY,EAOrC,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEtE;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,eAAe,GAAG,SAAS,GACrC,YAAY,CAiDd;AA8ID;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,YAAY,EAAE,EACvB,OAAO,GAAE,mBAAmB,GAAG,MAAW,GACzC,WAAW,EAAE,CAuDf"}
|