@mandujs/core 0.7.6 → 0.7.7

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": "@mandujs/core",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Mandu Framework Core - Spec, Generator, Guard, Runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -198,12 +198,15 @@ export async function hydrateIslands() {
198
198
 
199
199
  /**
200
200
  * 자동 초기화
201
+ * queueMicrotask로 지연: Island 등록 코드가 먼저 실행되도록 함
201
202
  */
202
- if (document.readyState === 'loading') {
203
- document.addEventListener('DOMContentLoaded', hydrateIslands);
204
- } else {
205
- hydrateIslands();
206
- }
203
+ queueMicrotask(() => {
204
+ if (document.readyState === 'loading') {
205
+ document.addEventListener('DOMContentLoaded', hydrateIslands);
206
+ } else {
207
+ hydrateIslands();
208
+ }
209
+ });
207
210
 
208
211
  // 글로벌 레지스트리 접근용 getter
209
212
  export const getIslandRegistry = () => window.__MANDU_ISLANDS__;
@@ -338,6 +338,7 @@ export function initializeRuntime(): void {
338
338
  }
339
339
 
340
340
  // 자동 초기화 여부 (번들 시 설정)
341
+ // queueMicrotask로 지연: 번들 내 Island 등록 코드가 먼저 실행되도록 함
341
342
  if (typeof window !== "undefined" && (window as any).__MANDU_AUTO_INIT__ !== false) {
342
- initializeRuntime();
343
+ queueMicrotask(() => initializeRuntime());
343
344
  }
@@ -141,6 +141,9 @@ export class ManduFilling<TLoaderData = unknown> {
141
141
  return this;
142
142
  }
143
143
 
144
+ /**
145
+ * 요청 시작 훅
146
+ */
144
147
  onRequest(fn: OnRequestHandler): this {
145
148
  this.config.lifecycle.onRequest.push({ fn, scope: "local" });
146
149
  return this;
@@ -159,6 +162,10 @@ export class ManduFilling<TLoaderData = unknown> {
159
162
  return this;
160
163
  }
161
164
 
165
+ /**
166
+ * 바디 파싱 훅
167
+ * body를 읽을 때는 req.clone() 사용 권장
168
+ */
162
169
  onParse(fn: OnParseHandler): this {
163
170
  this.config.lifecycle.onParse.push({ fn, scope: "local" });
164
171
  return this;
@@ -184,21 +191,33 @@ export class ManduFilling<TLoaderData = unknown> {
184
191
  return this.guard(fn);
185
192
  }
186
193
 
194
+ /**
195
+ * 핸들러 후 훅
196
+ */
187
197
  afterHandle(fn: AfterHandleHandler): this {
188
198
  this.config.lifecycle.afterHandle.push({ fn, scope: "local" });
189
199
  return this;
190
200
  }
191
201
 
202
+ /**
203
+ * 최종 응답 매핑 훅
204
+ */
192
205
  mapResponse(fn: MapResponseHandler): this {
193
206
  this.config.lifecycle.mapResponse.push({ fn, scope: "local" });
194
207
  return this;
195
208
  }
196
209
 
210
+ /**
211
+ * 에러 핸들링 훅
212
+ */
197
213
  onError(fn: OnErrorHandler): this {
198
214
  this.config.lifecycle.onError.push({ fn, scope: "local" });
199
215
  return this;
200
216
  }
201
217
 
218
+ /**
219
+ * 응답 후 훅 (비동기)
220
+ */
202
221
  afterResponse(fn: AfterResponseHandler): this {
203
222
  this.config.lifecycle.afterResponse.push({ fn, scope: "local" });
204
223
  return this;