@mandujs/core 0.18.22 → 0.19.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.
Files changed (91) hide show
  1. package/README.ko.md +0 -14
  2. package/package.json +4 -1
  3. package/src/brain/architecture/analyzer.ts +4 -4
  4. package/src/brain/doctor/analyzer.ts +18 -14
  5. package/src/bundler/build.test.ts +127 -0
  6. package/src/bundler/build.ts +291 -113
  7. package/src/bundler/css.ts +20 -5
  8. package/src/bundler/dev.ts +55 -2
  9. package/src/bundler/prerender.ts +195 -0
  10. package/src/change/snapshot.ts +4 -23
  11. package/src/change/types.ts +2 -3
  12. package/src/client/Form.tsx +105 -0
  13. package/src/client/__tests__/use-sse.test.ts +153 -0
  14. package/src/client/hooks.ts +105 -6
  15. package/src/client/index.ts +35 -6
  16. package/src/client/router.ts +670 -433
  17. package/src/client/rpc.ts +140 -0
  18. package/src/client/runtime.ts +24 -21
  19. package/src/client/use-fetch.ts +239 -0
  20. package/src/client/use-head.ts +197 -0
  21. package/src/client/use-sse.ts +378 -0
  22. package/src/components/Image.tsx +162 -0
  23. package/src/config/mandu.ts +5 -0
  24. package/src/config/validate.ts +34 -0
  25. package/src/content/index.ts +5 -1
  26. package/src/devtools/client/catchers/error-catcher.ts +17 -0
  27. package/src/devtools/client/catchers/network-proxy.ts +390 -367
  28. package/src/devtools/client/components/kitchen-root.tsx +479 -467
  29. package/src/devtools/client/components/panel/diff-viewer.tsx +219 -0
  30. package/src/devtools/client/components/panel/guard-panel.tsx +374 -244
  31. package/src/devtools/client/components/panel/index.ts +45 -32
  32. package/src/devtools/client/components/panel/panel-container.tsx +332 -312
  33. package/src/devtools/client/components/panel/preview-panel.tsx +188 -0
  34. package/src/devtools/client/state-manager.ts +535 -478
  35. package/src/devtools/design-tokens.ts +265 -264
  36. package/src/devtools/types.ts +345 -319
  37. package/src/filling/context.ts +65 -0
  38. package/src/filling/filling.ts +336 -14
  39. package/src/filling/index.ts +5 -1
  40. package/src/filling/session.ts +216 -0
  41. package/src/filling/ws.ts +78 -0
  42. package/src/generator/generate.ts +2 -2
  43. package/src/guard/auto-correct.ts +0 -29
  44. package/src/guard/check.ts +14 -31
  45. package/src/guard/presets/index.ts +296 -294
  46. package/src/guard/rules.ts +15 -19
  47. package/src/guard/validator.ts +834 -834
  48. package/src/index.ts +5 -1
  49. package/src/island/index.ts +373 -304
  50. package/src/kitchen/api/contract-api.ts +225 -0
  51. package/src/kitchen/api/diff-parser.ts +108 -0
  52. package/src/kitchen/api/file-api.ts +273 -0
  53. package/src/kitchen/api/guard-api.ts +83 -0
  54. package/src/kitchen/api/guard-decisions.ts +100 -0
  55. package/src/kitchen/api/routes-api.ts +50 -0
  56. package/src/kitchen/index.ts +21 -0
  57. package/src/kitchen/kitchen-handler.ts +256 -0
  58. package/src/kitchen/kitchen-ui.ts +1732 -0
  59. package/src/kitchen/stream/activity-sse.ts +145 -0
  60. package/src/kitchen/stream/file-tailer.ts +99 -0
  61. package/src/middleware/compress.ts +62 -0
  62. package/src/middleware/cors.ts +47 -0
  63. package/src/middleware/index.ts +10 -0
  64. package/src/middleware/jwt.ts +134 -0
  65. package/src/middleware/logger.ts +58 -0
  66. package/src/middleware/timeout.ts +55 -0
  67. package/src/paths.ts +0 -4
  68. package/src/plugins/hooks.ts +64 -0
  69. package/src/plugins/index.ts +3 -0
  70. package/src/plugins/types.ts +5 -0
  71. package/src/report/build.ts +0 -6
  72. package/src/resource/__tests__/backward-compat.test.ts +0 -1
  73. package/src/router/fs-patterns.ts +11 -1
  74. package/src/router/fs-routes.ts +78 -14
  75. package/src/router/fs-scanner.ts +2 -2
  76. package/src/router/fs-types.ts +2 -1
  77. package/src/runtime/adapter-bun.ts +62 -0
  78. package/src/runtime/adapter.ts +47 -0
  79. package/src/runtime/cache.ts +310 -0
  80. package/src/runtime/handler.ts +65 -0
  81. package/src/runtime/image-handler.ts +195 -0
  82. package/src/runtime/index.ts +12 -0
  83. package/src/runtime/middleware.ts +263 -0
  84. package/src/runtime/server.ts +686 -92
  85. package/src/runtime/ssr.ts +55 -29
  86. package/src/runtime/streaming-ssr.ts +106 -82
  87. package/src/spec/index.ts +0 -1
  88. package/src/spec/schema.ts +1 -0
  89. package/src/testing/index.ts +144 -0
  90. package/src/watcher/watcher.ts +27 -1
  91. package/src/spec/lock.ts +0 -56
@@ -0,0 +1,188 @@
1
+ /**
2
+ * Mandu Kitchen DevTools - Preview Panel
3
+ * @version 2.0.0
4
+ *
5
+ * Shows recent file changes with inline diff viewer.
6
+ */
7
+
8
+ import React, { useState, useCallback } from 'react';
9
+ import type { RecentChange } from '../../../types';
10
+ import { DiffViewer, type FileDiff } from './diff-viewer';
11
+ import { colors, typography, spacing, borderRadius, animation } from '../../../design-tokens';
12
+
13
+ // ============================================================================
14
+ // Styles
15
+ // ============================================================================
16
+
17
+ const styles = {
18
+ container: {
19
+ padding: spacing.md,
20
+ height: '100%',
21
+ display: 'flex',
22
+ flexDirection: 'column' as const,
23
+ gap: spacing.md,
24
+ },
25
+ header: {
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ justifyContent: 'space-between',
29
+ },
30
+ clearButton: {
31
+ padding: `${spacing.xs} ${spacing.sm}`,
32
+ borderRadius: borderRadius.sm,
33
+ backgroundColor: colors.background.light,
34
+ border: 'none',
35
+ color: colors.text.secondary,
36
+ fontSize: typography.fontSize.xs,
37
+ cursor: 'pointer',
38
+ transition: `all ${animation.duration.fast}`,
39
+ },
40
+ list: {
41
+ flex: 1,
42
+ overflow: 'auto',
43
+ display: 'flex',
44
+ flexDirection: 'column' as const,
45
+ gap: spacing.xs,
46
+ },
47
+ emptyState: {
48
+ flex: 1,
49
+ display: 'flex',
50
+ flexDirection: 'column' as const,
51
+ alignItems: 'center',
52
+ justifyContent: 'center',
53
+ gap: spacing.md,
54
+ padding: spacing.xl,
55
+ color: colors.text.muted,
56
+ fontSize: typography.fontSize.sm,
57
+ textAlign: 'center' as const,
58
+ },
59
+ changeItem: {
60
+ display: 'flex',
61
+ alignItems: 'center',
62
+ gap: spacing.sm,
63
+ padding: `${spacing.sm} ${spacing.md}`,
64
+ borderRadius: borderRadius.sm,
65
+ backgroundColor: colors.background.medium,
66
+ cursor: 'pointer',
67
+ transition: `all ${animation.duration.fast}`,
68
+ fontSize: typography.fontSize.sm,
69
+ },
70
+ changeIcon: {
71
+ flexShrink: 0,
72
+ fontSize: typography.fontSize.md,
73
+ },
74
+ changePath: {
75
+ flex: 1,
76
+ overflow: 'hidden',
77
+ textOverflow: 'ellipsis',
78
+ whiteSpace: 'nowrap' as const,
79
+ fontFamily: typography.fontFamily.mono,
80
+ fontSize: typography.fontSize.xs,
81
+ color: colors.text.primary,
82
+ },
83
+ changeTime: {
84
+ flexShrink: 0,
85
+ fontSize: typography.fontSize.xs,
86
+ color: colors.text.muted,
87
+ },
88
+ };
89
+
90
+ const typeIcons: Record<string, string> = {
91
+ add: '➕',
92
+ change: '✏️',
93
+ delete: '🗑️',
94
+ };
95
+
96
+ // ============================================================================
97
+ // Props
98
+ // ============================================================================
99
+
100
+ export interface PreviewPanelProps {
101
+ recentChanges: RecentChange[];
102
+ onClearChanges?: () => void;
103
+ }
104
+
105
+ // ============================================================================
106
+ // Component
107
+ // ============================================================================
108
+
109
+ export function PreviewPanel({ recentChanges, onClearChanges }: PreviewPanelProps): React.ReactElement {
110
+ const [selectedDiff, setSelectedDiff] = useState<FileDiff | null>(null);
111
+ const [loadingDiff, setLoadingDiff] = useState<string | null>(null);
112
+
113
+ const handleFileClick = useCallback(async (filePath: string) => {
114
+ setLoadingDiff(filePath);
115
+ try {
116
+ const res = await fetch(`/__kitchen/api/file/diff?path=${encodeURIComponent(filePath)}`);
117
+ if (res.ok) {
118
+ const diff = await res.json();
119
+ setSelectedDiff(diff);
120
+ }
121
+ } catch {
122
+ // API not available
123
+ } finally {
124
+ setLoadingDiff(null);
125
+ }
126
+ }, []);
127
+
128
+ const handleCloseDiff = useCallback(() => {
129
+ setSelectedDiff(null);
130
+ }, []);
131
+
132
+ if (selectedDiff) {
133
+ return <DiffViewer diff={selectedDiff} onClose={handleCloseDiff} />;
134
+ }
135
+
136
+ if (recentChanges.length === 0) {
137
+ return (
138
+ <div style={styles.container}>
139
+ <div style={styles.emptyState}>
140
+ 📝
141
+ <p>파일을 수정하면 여기에 변경사항이 표시됩니다</p>
142
+ </div>
143
+ </div>
144
+ );
145
+ }
146
+
147
+ return (
148
+ <div style={styles.container}>
149
+ <div style={styles.header}>
150
+ <span style={{ fontSize: typography.fontSize.sm, color: colors.text.secondary }}>
151
+ {recentChanges.length}개의 변경사항
152
+ </span>
153
+ {onClearChanges && (
154
+ <button style={styles.clearButton} onClick={onClearChanges}>
155
+ 모두 지우기
156
+ </button>
157
+ )}
158
+ </div>
159
+
160
+ <div style={styles.list}>
161
+ {recentChanges.map((change, i) => {
162
+ const isLoading = loadingDiff === change.filePath;
163
+ return (
164
+ <div
165
+ key={`${change.filePath}-${change.timestamp}-${i}`}
166
+ style={{
167
+ ...styles.changeItem,
168
+ opacity: isLoading ? 0.5 : 1,
169
+ }}
170
+ onClick={() => !isLoading && handleFileClick(change.filePath)}
171
+ >
172
+ <span style={styles.changeIcon}>{typeIcons[change.type] ?? '✏️'}</span>
173
+ <span style={styles.changePath}>{change.filePath}</span>
174
+ <span style={styles.changeTime}>
175
+ {formatTime(change.timestamp)}
176
+ </span>
177
+ </div>
178
+ );
179
+ })}
180
+ </div>
181
+ </div>
182
+ );
183
+ }
184
+
185
+ function formatTime(ts: number): string {
186
+ const d = new Date(ts);
187
+ return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });
188
+ }