@mandujs/core 0.9.2 → 0.9.4

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/README.md CHANGED
@@ -1,200 +1,200 @@
1
- <p align="center">
2
- <img src="https://raw.githubusercontent.com/konamgil/mandu/main/mandu_only_simbol.png" alt="Mandu" width="200" />
3
- </p>
4
-
5
- <h1 align="center">@mandujs/core</h1>
6
-
7
- <p align="center">
8
- <strong>Mandu Framework Core</strong><br/>
9
- Spec, Generator, Guard, Runtime, Filling
10
- </p>
11
-
12
- <p align="center">
13
- English | <a href="./README.ko.md"><strong>한국어</strong></a>
14
- </p>
15
-
16
- ## Installation
17
-
18
- ```bash
19
- bun add @mandujs/core
20
- ```
21
-
22
- > Typically used through `@mandujs/cli`. Direct usage is for advanced use cases.
23
-
24
- ## Module Structure
25
-
26
- ```
27
- @mandujs/core
28
- ├── spec/ # Spec schema and loading
29
- ├── generator/ # Code generation
30
- ├── guard/ # Architecture checking and auto-correction
31
- ├── runtime/ # Server and router
32
- └── report/ # Guard report generation
33
- ```
34
-
35
- ## Spec Module
36
-
37
- Route manifest schema definition and loading.
38
-
39
- ```typescript
40
- import { loadManifest, RoutesManifest, RouteSpec } from "@mandujs/core";
41
-
42
- // Load and validate manifest
43
- const result = await loadManifest("spec/routes.manifest.json");
44
-
45
- if (result.success && result.data) {
46
- const manifest: RoutesManifest = result.data;
47
- manifest.routes.forEach((route: RouteSpec) => {
48
- console.log(route.id, route.pattern, route.kind);
49
- });
50
- }
51
- ```
52
-
53
- ### Lock File
54
-
55
- ```typescript
56
- import { writeLock, readLock } from "@mandujs/core";
57
-
58
- // Write lock file
59
- const lock = await writeLock("spec/spec.lock.json", manifest);
60
- console.log(lock.routesHash);
61
-
62
- // Read lock file
63
- const existing = await readLock("spec/spec.lock.json");
64
- ```
65
-
66
- ## Generator Module
67
-
68
- Spec-based code generation.
69
-
70
- ```typescript
71
- import { generateRoutes, GenerateResult } from "@mandujs/core";
72
-
73
- const result: GenerateResult = await generateRoutes(manifest, "./");
74
-
75
- console.log("Created:", result.created);
76
- console.log("Skipped:", result.skipped); // Existing slot files
77
- ```
78
-
79
- ### Template Functions
80
-
81
- ```typescript
82
- import {
83
- generateApiHandler,
84
- generateApiHandlerWithSlot,
85
- generateSlotLogic,
86
- generatePageComponent
87
- } from "@mandujs/core";
88
-
89
- // Generate API handler
90
- const code = generateApiHandler(route);
91
-
92
- // API handler with slot
93
- const codeWithSlot = generateApiHandlerWithSlot(route);
94
-
95
- // Slot logic file
96
- const slotCode = generateSlotLogic(route);
97
- ```
98
-
99
- ## Guard Module
100
-
101
- Architecture rule checking and auto-correction.
102
-
103
- ```typescript
104
- import {
105
- runGuardCheck,
106
- runAutoCorrect,
107
- GuardResult,
108
- GuardViolation
109
- } from "@mandujs/core";
110
-
111
- // Run check
112
- const result: GuardResult = await runGuardCheck(manifest, "./");
113
-
114
- if (!result.passed) {
115
- result.violations.forEach((v: GuardViolation) => {
116
- console.log(`${v.rule}: ${v.message}`);
117
- });
118
-
119
- // Run auto-correction
120
- const corrected = await runAutoCorrect(result.violations, manifest, "./");
121
- console.log("Fixed:", corrected.steps);
122
- console.log("Remaining violations:", corrected.remainingViolations);
123
- }
124
- ```
125
-
126
- ### Guard Rules
127
-
128
- | Rule ID | Description | Auto-correctable |
129
- |---------|-------------|------------------|
130
- | `SPEC_HASH_MISMATCH` | Spec and lock hash mismatch | ✅ |
131
- | `GENERATED_MANUAL_EDIT` | Manual edit to generated file | ✅ |
132
- | `HANDLER_NOT_FOUND` | Handler file not found | ❌ |
133
- | `COMPONENT_NOT_FOUND` | Component file not found | ❌ |
134
- | `SLOT_NOT_FOUND` | Slot file not found | ✅ |
135
-
136
- ## Runtime Module
137
-
138
- Server startup and routing.
139
-
140
- ```typescript
141
- import {
142
- startServer,
143
- registerApiHandler,
144
- registerPageLoader
145
- } from "@mandujs/core";
146
-
147
- // Register API handler
148
- registerApiHandler("getUsers", async (req) => {
149
- return { users: [] };
150
- });
151
-
152
- // Register page loader
153
- registerPageLoader("homePage", () => import("./pages/Home"));
154
-
155
- // Start server
156
- const server = startServer(manifest, { port: 3000 });
157
-
158
- // Stop
159
- server.stop();
160
- ```
161
-
162
- ## Report Module
163
-
164
- Guard result report generation.
165
-
166
- ```typescript
167
- import { buildGuardReport } from "@mandujs/core";
168
-
169
- const report = buildGuardReport(guardResult, lockPath);
170
- console.log(report); // Formatted text report
171
- ```
172
-
173
- ## Types
174
-
175
- ```typescript
176
- import type {
177
- RoutesManifest,
178
- RouteSpec,
179
- RouteKind,
180
- SpecLock,
181
- GuardResult,
182
- GuardViolation,
183
- GenerateResult,
184
- AutoCorrectResult,
185
- } from "@mandujs/core";
186
- ```
187
-
188
- ## Requirements
189
-
190
- - Bun >= 1.0.0
191
- - React >= 18.0.0
192
- - Zod >= 3.0.0
193
-
194
- ## Related Packages
195
-
196
- - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI tool
197
-
198
- ## License
199
-
200
- MIT
1
+ <p align="center">
2
+ <img src="https://raw.githubusercontent.com/konamgil/mandu/main/mandu_only_simbol.png" alt="Mandu" width="200" />
3
+ </p>
4
+
5
+ <h1 align="center">@mandujs/core</h1>
6
+
7
+ <p align="center">
8
+ <strong>Mandu Framework Core</strong><br/>
9
+ Spec, Generator, Guard, Runtime, Filling
10
+ </p>
11
+
12
+ <p align="center">
13
+ English | <a href="./README.ko.md"><strong>한국어</strong></a>
14
+ </p>
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ bun add @mandujs/core
20
+ ```
21
+
22
+ > Typically used through `@mandujs/cli`. Direct usage is for advanced use cases.
23
+
24
+ ## Module Structure
25
+
26
+ ```
27
+ @mandujs/core
28
+ ├── spec/ # Spec schema and loading
29
+ ├── generator/ # Code generation
30
+ ├── guard/ # Architecture checking and auto-correction
31
+ ├── runtime/ # Server and router
32
+ └── report/ # Guard report generation
33
+ ```
34
+
35
+ ## Spec Module
36
+
37
+ Route manifest schema definition and loading.
38
+
39
+ ```typescript
40
+ import { loadManifest, RoutesManifest, RouteSpec } from "@mandujs/core";
41
+
42
+ // Load and validate manifest
43
+ const result = await loadManifest("spec/routes.manifest.json");
44
+
45
+ if (result.success && result.data) {
46
+ const manifest: RoutesManifest = result.data;
47
+ manifest.routes.forEach((route: RouteSpec) => {
48
+ console.log(route.id, route.pattern, route.kind);
49
+ });
50
+ }
51
+ ```
52
+
53
+ ### Lock File
54
+
55
+ ```typescript
56
+ import { writeLock, readLock } from "@mandujs/core";
57
+
58
+ // Write lock file
59
+ const lock = await writeLock("spec/spec.lock.json", manifest);
60
+ console.log(lock.routesHash);
61
+
62
+ // Read lock file
63
+ const existing = await readLock("spec/spec.lock.json");
64
+ ```
65
+
66
+ ## Generator Module
67
+
68
+ Spec-based code generation.
69
+
70
+ ```typescript
71
+ import { generateRoutes, GenerateResult } from "@mandujs/core";
72
+
73
+ const result: GenerateResult = await generateRoutes(manifest, "./");
74
+
75
+ console.log("Created:", result.created);
76
+ console.log("Skipped:", result.skipped); // Existing slot files
77
+ ```
78
+
79
+ ### Template Functions
80
+
81
+ ```typescript
82
+ import {
83
+ generateApiHandler,
84
+ generateApiHandlerWithSlot,
85
+ generateSlotLogic,
86
+ generatePageComponent
87
+ } from "@mandujs/core";
88
+
89
+ // Generate API handler
90
+ const code = generateApiHandler(route);
91
+
92
+ // API handler with slot
93
+ const codeWithSlot = generateApiHandlerWithSlot(route);
94
+
95
+ // Slot logic file
96
+ const slotCode = generateSlotLogic(route);
97
+ ```
98
+
99
+ ## Guard Module
100
+
101
+ Architecture rule checking and auto-correction.
102
+
103
+ ```typescript
104
+ import {
105
+ runGuardCheck,
106
+ runAutoCorrect,
107
+ GuardResult,
108
+ GuardViolation
109
+ } from "@mandujs/core";
110
+
111
+ // Run check
112
+ const result: GuardResult = await runGuardCheck(manifest, "./");
113
+
114
+ if (!result.passed) {
115
+ result.violations.forEach((v: GuardViolation) => {
116
+ console.log(`${v.rule}: ${v.message}`);
117
+ });
118
+
119
+ // Run auto-correction
120
+ const corrected = await runAutoCorrect(result.violations, manifest, "./");
121
+ console.log("Fixed:", corrected.steps);
122
+ console.log("Remaining violations:", corrected.remainingViolations);
123
+ }
124
+ ```
125
+
126
+ ### Guard Rules
127
+
128
+ | Rule ID | Description | Auto-correctable |
129
+ |---------|-------------|------------------|
130
+ | `SPEC_HASH_MISMATCH` | Spec and lock hash mismatch | ✅ |
131
+ | `GENERATED_MANUAL_EDIT` | Manual edit to generated file | ✅ |
132
+ | `HANDLER_NOT_FOUND` | Handler file not found | ❌ |
133
+ | `COMPONENT_NOT_FOUND` | Component file not found | ❌ |
134
+ | `SLOT_NOT_FOUND` | Slot file not found | ✅ |
135
+
136
+ ## Runtime Module
137
+
138
+ Server startup and routing.
139
+
140
+ ```typescript
141
+ import {
142
+ startServer,
143
+ registerApiHandler,
144
+ registerPageLoader
145
+ } from "@mandujs/core";
146
+
147
+ // Register API handler
148
+ registerApiHandler("getUsers", async (req) => {
149
+ return { users: [] };
150
+ });
151
+
152
+ // Register page loader
153
+ registerPageLoader("homePage", () => import("./pages/Home"));
154
+
155
+ // Start server
156
+ const server = startServer(manifest, { port: 3000 });
157
+
158
+ // Stop
159
+ server.stop();
160
+ ```
161
+
162
+ ## Report Module
163
+
164
+ Guard result report generation.
165
+
166
+ ```typescript
167
+ import { buildGuardReport } from "@mandujs/core";
168
+
169
+ const report = buildGuardReport(guardResult, lockPath);
170
+ console.log(report); // Formatted text report
171
+ ```
172
+
173
+ ## Types
174
+
175
+ ```typescript
176
+ import type {
177
+ RoutesManifest,
178
+ RouteSpec,
179
+ RouteKind,
180
+ SpecLock,
181
+ GuardResult,
182
+ GuardViolation,
183
+ GenerateResult,
184
+ AutoCorrectResult,
185
+ } from "@mandujs/core";
186
+ ```
187
+
188
+ ## Requirements
189
+
190
+ - Bun >= 1.0.0
191
+ - React >= 18.0.0
192
+ - Zod >= 3.0.0
193
+
194
+ ## Related Packages
195
+
196
+ - [@mandujs/cli](https://www.npmjs.com/package/@mandujs/cli) - CLI tool
197
+
198
+ ## License
199
+
200
+ MIT
package/package.json CHANGED
@@ -1,52 +1,52 @@
1
- {
2
- "name": "@mandujs/core",
3
- "version": "0.9.2",
4
- "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
- "type": "module",
6
- "main": "./src/index.ts",
7
- "types": "./src/index.ts",
8
- "exports": {
9
- ".": "./src/index.ts",
10
- "./client": "./src/client/index.ts",
11
- "./*": "./src/*"
12
- },
13
- "files": [
14
- "src/**/*"
15
- ],
16
- "scripts": {
17
- "test": "bun test",
18
- "test:hydration": "bun test tests/hydration",
19
- "test:watch": "bun test --watch"
20
- },
21
- "devDependencies": {
22
- "@happy-dom/global-registrator": "^15.0.0"
23
- },
24
- "keywords": [
25
- "mandu",
26
- "framework",
27
- "agent",
28
- "ai",
29
- "code-generation"
30
- ],
31
- "repository": {
32
- "type": "git",
33
- "url": "git+https://github.com/konamgil/mandu.git",
34
- "directory": "packages/core"
35
- },
36
- "author": "konamgil",
37
- "license": "MIT",
38
- "publishConfig": {
39
- "access": "public"
40
- },
41
- "engines": {
42
- "bun": ">=1.0.0"
43
- },
44
- "peerDependencies": {
45
- "react": ">=18.0.0",
46
- "react-dom": ">=18.0.0",
47
- "zod": ">=3.0.0"
48
- },
49
- "dependencies": {
50
- "ollama": "^0.6.3"
51
- }
52
- }
1
+ {
2
+ "name": "@mandujs/core",
3
+ "version": "0.9.4",
4
+ "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
+ "type": "module",
6
+ "main": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "exports": {
9
+ ".": "./src/index.ts",
10
+ "./client": "./src/client/index.ts",
11
+ "./*": "./src/*"
12
+ },
13
+ "files": [
14
+ "src/**/*"
15
+ ],
16
+ "scripts": {
17
+ "test": "bun test",
18
+ "test:hydration": "bun test tests/hydration",
19
+ "test:watch": "bun test --watch"
20
+ },
21
+ "devDependencies": {
22
+ "@happy-dom/global-registrator": "^15.0.0"
23
+ },
24
+ "keywords": [
25
+ "mandu",
26
+ "framework",
27
+ "agent",
28
+ "ai",
29
+ "code-generation"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/konamgil/mandu.git",
34
+ "directory": "packages/core"
35
+ },
36
+ "author": "konamgil",
37
+ "license": "MIT",
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "engines": {
42
+ "bun": ">=1.0.0"
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=18.0.0",
46
+ "react-dom": ">=18.0.0",
47
+ "zod": ">=3.0.0"
48
+ },
49
+ "dependencies": {
50
+ "ollama": "^0.6.3"
51
+ }
52
+ }
@@ -269,6 +269,12 @@ import { jsxDEV } from 'react/jsx-dev-runtime';
269
269
  // React internals (ReactDOM이 내부적으로 접근 필요)
270
270
  const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
271
271
 
272
+ // 전역 React 설정 (모든 모듈에서 동일 인스턴스 공유)
273
+ if (typeof window !== 'undefined') {
274
+ window.React = React;
275
+ window.__MANDU_REACT__ = React;
276
+ }
277
+
272
278
  // Named exports
273
279
  export {
274
280
  createElement,