@fluojs/runtime 1.0.0-beta.10 → 1.0.0-beta.11

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.ko.md CHANGED
@@ -26,7 +26,7 @@ npm install @fluojs/runtime
26
26
  다음과 같은 경우에 이 패키지를 사용합니다:
27
27
  - **fluo 애플리케이션 부트스트랩**: 모듈을 실행 중인 HTTP 서버나 마이크로서비스로 변환할 때.
28
28
  - **DI 및 라이프사이클 오케스트레이션**: 모듈 그래프 컴파일, 프로바이더 연결 및 애플리케이션 훅(`onModuleInit`, `onApplicationBootstrap`)을 관리할 때.
29
- - **독립형 컨텍스트 생성**: HTTP 서버는 필요 없지만 DI가 필요한 CLI 태스크, 마이그레이션 또는 워커를 실행할 때.
29
+ - **독립형 컨텍스트 생성**: HTTP 서버는 필요 없지만 DI가 필요한 CLI task, script 또는 worker를 실행할 때.
30
30
  - **진단 및 검사**: CLI 내보내기와 Studio 소유 그래프 보기/렌더링을 위한 기계 읽기 가능한 플랫폼 snapshot을 생산할 때.
31
31
 
32
32
  ## 퀵 스타트
@@ -115,7 +115,7 @@ class DatabaseModule {}
115
115
 
116
116
  @Module({
117
117
  imports: [DatabaseModule],
118
- providers: [UsersService], // 이제 DatabaseService를 주입받을 수 있음
118
+ providers: [UsersService], // UsersService가 DatabaseService를 주입받을 수 있음
119
119
  })
120
120
  class UsersModule {}
121
121
  ```
@@ -144,22 +144,28 @@ class UsersModule {}
144
144
  ## 공개 API 개요
145
145
 
146
146
  - `fluoFactory`: 패키지 예제에서 사용하는 런타임 부트스트랩 파사드의 lower-camel-case 별칭입니다.
147
- - `FluoFactory`: 호환성과 명시적 static 접근을 위해 유지되는 클래스 기반 런타임 부트스트랩 파사드입니다.
147
+ - `FluoFactory`: 명시적 static 접근을 제공하는 클래스 기반 런타임 부트스트랩 파사드입니다.
148
148
  - `Application`: `ApplicationContext`를 확장하며 `listen()`, `dispatch()`, `state`를 포함합니다.
149
- - `ApplicationContext`: `get<T>(token)`, `close()` 기능을 제공하며 `container`와 `modules`에 접근할 수 있습니다.
149
+ - `ApplicationContext`: `get<T>(token)`, `close()` 기능을 제공하며 `container`, `modules`, bootstrap diagnostics에 접근할 수 있습니다.
150
150
  - `LifecycleHooks`: `OnModuleInit`, `OnApplicationBootstrap`, `OnModuleDestroy`, `OnApplicationShutdown`를 묶는 편의 union 타입입니다.
151
- - `createHealthModule(options)`: bootstrap 및 shutdown 라이프사이클 전이에 맞춰 readiness marker를 관리하는 런타임 소유 `/health`, `/ready` 모듈 팩토리입니다.
151
+ - `HealthModule.forRoot(options)`: bootstrap 및 shutdown 라이프사이클 전이에 맞춰 readiness marker를 관리하는 런타임 소유 `/health`, `/ready` 모듈 파사드입니다.
152
+ - `createHealthModule(options)`: 같은 런타임 health module 계약을 위한 deprecated compatibility helper입니다. 애플리케이션-facing module import에서는 `HealthModule.forRoot(...)`를 우선 사용하세요.
152
153
  - `defineModule(cls, metadata)`: 프로그래밍 방식의 모듈 정의 헬퍼입니다.
153
154
  - `bootstrapApplication(options)`: 저수준 비동기 부트스트랩 함수입니다.
155
+ - `bootstrapModule(...)`: 저수준 module graph bootstrap helper입니다.
156
+ - `createBootstrapTimingDiagnostics(...)`, `createRuntimeDiagnosticsGraph(...)`: CLI/support tooling을 위한 runtime diagnostics helper입니다.
157
+ - `createRequestAbortContext(...)`, `trackActiveRequestTransaction(...)`, `untrackActiveRequestTransaction(...)`: runtime-aware integration이 사용하는 request abort 및 active transaction helper입니다.
154
158
 
155
159
  ## 플랫폼 전용 서브경로
156
160
 
157
161
  | 서브경로 | 용도 |
158
162
  | :--- | :--- |
159
163
  | `@fluojs/runtime/node` | 로거 팩토리, Node 어댑터/부트스트랩 헬퍼, 종료 시그널 등록을 위한 지원되는 Node.js 전용 진입점입니다. |
160
- | `@fluojs/runtime/web` | Bun, Deno, Cloudflare Workers를 위한 공유 표준 요청/응답 유틸리티. |
161
- | `@fluojs/runtime/internal` | 저수준 오케스트레이션 헬퍼 HTTP 어댑터 기본 로직. |
162
- | `@fluojs/runtime/internal-node` | 어댑터/패키지 호환 계층이 사용하는 Node 전용 내부 seam이며, 애플리케이션 코드에서는 `@fluojs/runtime/node`를 우선 사용하세요. |
164
+ | `@fluojs/runtime/web` | Bun, Deno, Cloudflare Workers를 위한 공유 Web 표준 요청/응답 유틸리티입니다. `createWebRequestResponseFactory`, `dispatchWebRequest`, `createWebFrameworkRequest`, `parseMultipart`를 포함합니다. |
165
+ | `@fluojs/runtime/internal` | package integration을 위한 token-only internal seam입니다. |
166
+ | `@fluojs/runtime/internal-node` | adapter/runtime plumbing을 위한 Node 전용 internal seam이며, 애플리케이션 코드에서는 `@fluojs/runtime/node`를 우선 사용하세요. |
167
+ | `@fluojs/runtime/internal/http-adapter` | platform package를 위한 internal HTTP adapter seam입니다. |
168
+ | `@fluojs/runtime/internal/request-response-factory` | platform package를 위한 internal request/response factory seam입니다. |
163
169
 
164
170
  ### Node 전용 서브경로 (`@fluojs/runtime/node`)
165
171
 
@@ -184,10 +190,10 @@ const adapter = createNodeHttpAdapter({
184
190
 
185
191
  공개 Node 런타임 surface에서 `maxBodySize`는 바이트 수를 나타내는 숫자만 허용합니다. `'1mb'` 같은 값은 나중에 암묵 변환되지 않고 어댑터 생성 시점에 즉시 거부됩니다.
186
192
 
187
- - `createConsoleApplicationLogger()`: `process.stdout`/`process.stderr`를 사용하는 컬러 콘솔 로거입니다. 기본값은 기존 pretty 형식을 유지합니다. 더 간결한 `[fluo] LEVEL [context] message` 줄을 원하면 `{ mode: 'minimal' }`, 런타임 로거 출력을 숨기려면 `{ mode: 'silent' }`, 낮은 심각도 메시지를 걸러내려면 `{ level: 'warn' }` 같은 threshold, 결정적인 비컬러 출력을 원하면 `{ color: false }`를 전달하세요.
193
+ - `createConsoleApplicationLogger()`: `process.stdout`/`process.stderr`를 사용하는 컬러 콘솔 로거입니다. 기본값은 pretty 형식입니다. 더 간결한 `[fluo] LEVEL [context] message` 줄을 원하면 `{ mode: 'minimal' }`, 런타임 로거 출력을 숨기려면 `{ mode: 'silent' }`, 낮은 심각도 메시지를 걸러내려면 `{ level: 'warn' }` 같은 threshold, 결정적인 비컬러 출력을 원하면 `{ color: false }`를 전달하세요.
188
194
  - `createJsonApplicationLogger()`: `process.stdout`/`process.stderr`를 사용하는 구조화된 JSON 로거.
189
195
  - `createNodeHttpAdapter()`: 어댑터 우선 런타임 구성을 위한 raw Node `http`/`https` 어댑터 팩토리입니다. primary Node 요청 `content-type`을 JSON/멀티파트 판별 전에 normalize하며, `maxBodySize`는 숫자 바이트 수만 받습니다.
190
- - `bootstrapNodeApplication()` / `runNodeApplication()`: 호환 패키지와 직접 Node 런타임 흐름에서 사용하는 Node 전용 부트스트랩 헬퍼.
196
+ - `bootstrapNodeApplication()` / `runNodeApplication()`: 직접 Node runtime flow에서 사용하는 Node 전용 부트스트랩 헬퍼.
191
197
  - `createNodeShutdownSignalRegistration()`, `defaultNodeShutdownSignals()`, `registerShutdownSignals()`: 호스트가 명시적으로 시그널 wiring을 제어할 때 쓰는 종료 등록 헬퍼.
192
198
 
193
199
  런타임 애플리케이션 로깅은 CLI lifecycle reporting과 별개입니다. 애플리케이션/런타임 자체가 내는 로그를 바꾸고 싶을 때 `ApplicationLogger`를 설정하세요:
package/README.md CHANGED
@@ -26,7 +26,7 @@ npm install @fluojs/runtime
26
26
  Use this package when you need to:
27
27
  - **Bootstrap a fluo application**: Convert your modules into a running HTTP server or microservice.
28
28
  - **Orchestrate DI and Lifecycle**: Manage module-graph compilation, provider wiring, and application hooks (`onModuleInit`, `onApplicationBootstrap`).
29
- - **Create Standalone Contexts**: Run CLI tasks, migrations, or workers that need DI but not an HTTP server.
29
+ - **Create Standalone Contexts**: Run CLI tasks, scripts, or workers that need DI but not an HTTP server.
30
30
  - **Diagnostic Inspection**: Produce machine-readable platform snapshots for CLI export and Studio-owned graph viewing/rendering.
31
31
 
32
32
  ## Quick Start
@@ -115,7 +115,7 @@ class DatabaseModule {}
115
115
 
116
116
  @Module({
117
117
  imports: [DatabaseModule],
118
- providers: [UsersService], // Can now inject DatabaseService
118
+ providers: [UsersService], // UsersService can inject DatabaseService
119
119
  })
120
120
  class UsersModule {}
121
121
  ```
@@ -144,22 +144,28 @@ class UsersModule {}
144
144
  ## Public API Overview
145
145
 
146
146
  - `fluoFactory`: Lower-camel-case alias for the runtime bootstrap facade used in the package examples.
147
- - `FluoFactory`: Class-based runtime bootstrap facade retained for compatibility and explicit static access.
147
+ - `FluoFactory`: Class-based runtime bootstrap facade with explicit static access.
148
148
  - `Application`: Extends `ApplicationContext` with `listen()`, `dispatch()`, and `state`.
149
- - `ApplicationContext`: Provides `get<T>(token)`, `close()`, and access to `container` and `modules`.
149
+ - `ApplicationContext`: Provides `get<T>(token)`, `close()`, and access to `container`, `modules`, and bootstrap diagnostics.
150
150
  - `LifecycleHooks`: Convenience union covering `OnModuleInit`, `OnApplicationBootstrap`, `OnModuleDestroy`, and `OnApplicationShutdown`.
151
- - `createHealthModule(options)`: Runtime-owned `/health` and `/ready` module factory whose readiness marker follows bootstrap and shutdown lifecycle transitions.
151
+ - `HealthModule.forRoot(options)`: Runtime-owned `/health` and `/ready` module facade whose readiness marker follows bootstrap and shutdown lifecycle transitions.
152
+ - `createHealthModule(options)`: Deprecated compatibility helper for the same runtime health module contract; prefer `HealthModule.forRoot(...)` in application-facing module imports.
152
153
  - `defineModule(cls, metadata)`: Programmatic module definition helper.
153
154
  - `bootstrapApplication(options)`: Lower-level async bootstrap function.
155
+ - `bootstrapModule(...)`: Lower-level module graph bootstrap helper.
156
+ - `createBootstrapTimingDiagnostics(...)`, `createRuntimeDiagnosticsGraph(...)`: Runtime diagnostics helpers for CLI/support tooling.
157
+ - `createRequestAbortContext(...)`, `trackActiveRequestTransaction(...)`, `untrackActiveRequestTransaction(...)`: Request abort and active transaction helpers used by runtime-aware integrations.
154
158
 
155
159
  ## Platform-Specific Subpaths
156
160
 
157
161
  | Subpath | Purpose |
158
162
  | :--- | :--- |
159
163
  | `@fluojs/runtime/node` | Supported Node.js entrypoint for logger factories, Node adapter/bootstrap helpers, and shutdown signal registration. |
160
- | `@fluojs/runtime/web` | Shared Web-standard request/response utilities for Bun, Deno, and Cloudflare Workers. |
161
- | `@fluojs/runtime/internal` | Low-level orchestration helpers and HTTP adapter base logic. |
162
- | `@fluojs/runtime/internal-node` | Node-only internal seam used by adapter/package compatibility layers; prefer `@fluojs/runtime/node` in application code. |
164
+ | `@fluojs/runtime/web` | Shared Web-standard request/response utilities for Bun, Deno, and Cloudflare Workers, including `createWebRequestResponseFactory`, `dispatchWebRequest`, `createWebFrameworkRequest`, and `parseMultipart`. |
165
+ | `@fluojs/runtime/internal` | Token-only internal seam for package integrations. |
166
+ | `@fluojs/runtime/internal-node` | Node-only internal seam for adapter/runtime plumbing; prefer `@fluojs/runtime/node` in application code. |
167
+ | `@fluojs/runtime/internal/http-adapter` | Internal HTTP adapter seam for platform packages. |
168
+ | `@fluojs/runtime/internal/request-response-factory` | Internal request/response factory seam for platform packages. |
163
169
 
164
170
  ### Node-Specific Subpath (`@fluojs/runtime/node`)
165
171
 
@@ -184,10 +190,10 @@ const adapter = createNodeHttpAdapter({
184
190
 
185
191
  For the public Node runtime surface, `maxBodySize` is a byte-count number only. Values such as `'1mb'` are rejected immediately during adapter creation instead of being coerced later.
186
192
 
187
- - `createConsoleApplicationLogger()`: Colorized console logger using `process.stdout`/`process.stderr`. The default remains the historical pretty format. Pass `{ mode: 'minimal' }` for concise `[fluo] LEVEL [context] message` lines, `{ mode: 'silent' }` to suppress runtime logger output, `{ level: 'warn' }` or another threshold to filter lower-severity messages, and `{ color: false }` when you need deterministic non-colored output.
193
+ - `createConsoleApplicationLogger()`: Colorized console logger using `process.stdout`/`process.stderr`. The default remains the pretty format. Pass `{ mode: 'minimal' }` for concise `[fluo] LEVEL [context] message` lines, `{ mode: 'silent' }` to suppress runtime logger output, `{ level: 'warn' }` or another threshold to filter lower-severity messages, and `{ color: false }` when you need deterministic non-colored output.
188
194
  - `createJsonApplicationLogger()`: Structured JSON logger using `process.stdout`/`process.stderr`.
189
195
  - `createNodeHttpAdapter()`: Raw Node `http`/`https` adapter factory for adapter-first runtime setup. The helper normalizes the primary Node request `content-type` before JSON/multipart detection and accepts `maxBodySize` only as numeric bytes.
190
- - `bootstrapNodeApplication()` / `runNodeApplication()`: Node-specific bootstrap helpers used by compatibility packages and direct Node runtime flows.
196
+ - `bootstrapNodeApplication()` / `runNodeApplication()`: Node-specific bootstrap helpers used by direct Node runtime flows.
191
197
  - `createNodeShutdownSignalRegistration()`, `defaultNodeShutdownSignals()`, `registerShutdownSignals()`: Shutdown registration helpers for hosts that need explicit signal wiring.
192
198
 
193
199
  Runtime app logging is separate from CLI lifecycle reporting. Configure `ApplicationLogger` when you want to change logs emitted by the application/runtime itself:
@@ -30,10 +30,23 @@ export interface HealthModuleOptions {
30
30
  */
31
31
  export type ReadinessCheck = () => boolean | Promise<boolean>;
32
32
  /**
33
- * Create health module.
33
+ * Runtime health module facade for application module imports.
34
+ */
35
+ export declare class HealthModule {
36
+ /**
37
+ * Creates a runtime-owned `/health` and `/ready` module.
38
+ *
39
+ * @param options Runtime health endpoint options.
40
+ * @returns A module class that can be imported into an application module.
41
+ */
42
+ static forRoot(options?: HealthModuleOptions): ModuleType;
43
+ }
44
+ /**
45
+ * Creates a runtime-owned `/health` and `/ready` module.
34
46
  *
35
- * @param options The options.
36
- * @returns The create health module result.
47
+ * @deprecated Prefer `HealthModule.forRoot(...)` for application-facing module registration.
48
+ * @param options Runtime health endpoint options.
49
+ * @returns A module class that can be imported into an application module.
37
50
  */
38
51
  export declare function createHealthModule(options?: HealthModuleOptions): ModuleType;
39
52
  //# sourceMappingURL=health.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/health/health.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,GAAG,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,cAAc,KACrD,YAAY,GACZ,mBAAmB,GACnB,OAAO,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CA0EhF"}
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/health/health.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,IAAI,GAAG,aAAa,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,aAAa,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,cAAc,EAAE,cAAc,KACrD,YAAY,GACZ,mBAAmB,GACnB,OAAO,CAAC,YAAY,GAAG,mBAAmB,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAkF9D;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU;CAG9D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,UAAU,CAEhF"}
@@ -26,13 +26,7 @@ import { defineModule } from '../bootstrap.js';
26
26
  * Defines the readiness check type.
27
27
  */
28
28
 
29
- /**
30
- * Create health module.
31
- *
32
- * @param options The options.
33
- * @returns The create health module result.
34
- */
35
- export function createHealthModule(options = {}) {
29
+ function createRuntimeHealthModule(options = {}) {
36
30
  let _initProto, _initClass;
37
31
  const basePath = options.path ?? '';
38
32
  const readinessChecks = [];
@@ -91,7 +85,7 @@ export function createHealthModule(options = {}) {
91
85
  _initClass();
92
86
  }
93
87
  }
94
- class HealthModule {
88
+ class RuntimeHealthModule {
95
89
  static addReadinessCheck(fn) {
96
90
  readinessChecks.push(fn);
97
91
  }
@@ -102,8 +96,37 @@ export function createHealthModule(options = {}) {
102
96
  ready = false;
103
97
  }
104
98
  }
105
- defineModule(HealthModule, {
99
+ Object.defineProperty(RuntimeHealthModule, 'name', {
100
+ value: 'HealthModule'
101
+ });
102
+ defineModule(RuntimeHealthModule, {
106
103
  controllers: [_HealthController]
107
104
  });
108
- return HealthModule;
105
+ return RuntimeHealthModule;
106
+ }
107
+
108
+ /**
109
+ * Runtime health module facade for application module imports.
110
+ */
111
+ export class HealthModule {
112
+ /**
113
+ * Creates a runtime-owned `/health` and `/ready` module.
114
+ *
115
+ * @param options Runtime health endpoint options.
116
+ * @returns A module class that can be imported into an application module.
117
+ */
118
+ static forRoot(options = {}) {
119
+ return createRuntimeHealthModule(options);
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Creates a runtime-owned `/health` and `/ready` module.
125
+ *
126
+ * @deprecated Prefer `HealthModule.forRoot(...)` for application-facing module registration.
127
+ * @param options Runtime health endpoint options.
128
+ * @returns A module class that can be imported into an application module.
129
+ */
130
+ export function createHealthModule(options = {}) {
131
+ return HealthModule.forRoot(options);
109
132
  }
@@ -17,6 +17,15 @@ export interface ConsoleApplicationLoggerOptions {
17
17
  level?: ConsoleApplicationLoggerLevel;
18
18
  /** Override TTY-aware ANSI color detection. */
19
19
  color?: boolean;
20
+ /** Explicit host color environment passed from the application/bootstrap boundary. */
21
+ environment?: ConsoleApplicationLoggerEnvironment;
22
+ }
23
+ /** Host color environment used by `createConsoleApplicationLogger(...)` without reading globals directly. */
24
+ export interface ConsoleApplicationLoggerEnvironment {
25
+ /** Whether `NO_COLOR`-style color suppression is enabled. */
26
+ noColor?: boolean;
27
+ /** `FORCE_COLOR`-style value used to force ANSI color output when truthy. */
28
+ forceColor?: string;
20
29
  }
21
30
  /**
22
31
  * Create console application logger.
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAC/E,iFAAiF;AACjF,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3E,kGAAkG;AAClG,MAAM,WAAW,+BAA+B;IAC9C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,4BAA4B,CAAC;IACpC,8FAA8F;IAC9F,KAAK,CAAC,EAAE,6BAA6B,CAAC;IACtC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA2CD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,+BAAoC,GAAG,iBAAiB,CA0C/G"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,4EAA4E;AAC5E,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAC/E,iFAAiF;AACjF,MAAM,MAAM,4BAA4B,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3E,kGAAkG;AAClG,MAAM,WAAW,+BAA+B;IAC9C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,4BAA4B,CAAC;IACpC,8FAA8F;IAC9F,KAAK,CAAC,EAAE,6BAA6B,CAAC;IACtC,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sFAAsF;IACtF,WAAW,CAAC,EAAE,mCAAmC,CAAC;CACnD;AAED,6GAA6G;AAC7G,MAAM,WAAW,mCAAmC;IAClD,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA2DD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,OAAO,GAAE,+BAAoC,GAAG,iBAAiB,CA2C/G"}
@@ -4,6 +4,8 @@
4
4
 
5
5
  /** Options used to tune the Node console logger without replacing the runtime logger contract. */
6
6
 
7
+ /** Host color environment used by `createConsoleApplicationLogger(...)` without reading globals directly. */
8
+
7
9
  const RESET = '\u001B[0m';
8
10
  const BRIGHT_GREEN = '\u001B[32m';
9
11
  const BRIGHT_RED = '\u001B[31m';
@@ -37,6 +39,18 @@ function formatMinimalLog(level, context, message, color) {
37
39
  function shouldLog(currentLevel, configuredLevel) {
38
40
  return LEVEL_PRIORITY[currentLevel] >= LEVEL_PRIORITY[configuredLevel];
39
41
  }
42
+ function isForceColorEnabled(value) {
43
+ return value !== undefined && value !== '' && value !== '0' && value !== 'false' && value !== 'no' && value !== 'off';
44
+ }
45
+ function shouldUseColor(stream, environment) {
46
+ if (environment.noColor === true) {
47
+ return false;
48
+ }
49
+ if (isForceColorEnabled(environment.forceColor)) {
50
+ return true;
51
+ }
52
+ return Boolean(stream.isTTY);
53
+ }
40
54
 
41
55
  /**
42
56
  * Create console application logger.
@@ -47,6 +61,7 @@ function shouldLog(currentLevel, configuredLevel) {
47
61
  export function createConsoleApplicationLogger(options = {}) {
48
62
  const mode = options.mode ?? 'pretty';
49
63
  const level = options.level ?? 'debug';
64
+ const environment = options.environment ?? {};
50
65
  const format = mode === 'minimal' ? formatMinimalLog : formatLog;
51
66
  if (mode === 'silent') {
52
67
  return {
@@ -59,26 +74,26 @@ export function createConsoleApplicationLogger(options = {}) {
59
74
  return {
60
75
  debug(message, context = 'fluo') {
61
76
  if (shouldLog('debug', level)) {
62
- console.debug(format('DEBUG', context, message, options.color ?? Boolean(process.stdout.isTTY)));
77
+ console.debug(format('DEBUG', context, message, options.color ?? shouldUseColor(process.stdout, environment)));
63
78
  }
64
79
  },
65
80
  error(message, error, context = 'fluo') {
66
81
  if (!shouldLog('error', level)) {
67
82
  return;
68
83
  }
69
- console.error(format('ERROR', context, message, options.color ?? Boolean(process.stderr.isTTY)));
84
+ console.error(format('ERROR', context, message, options.color ?? shouldUseColor(process.stderr, environment)));
70
85
  if (error) {
71
86
  console.error(error);
72
87
  }
73
88
  },
74
89
  log(message, context = 'fluo') {
75
90
  if (shouldLog('log', level)) {
76
- console.log(format('LOG', context, message, options.color ?? Boolean(process.stdout.isTTY)));
91
+ console.log(format('LOG', context, message, options.color ?? shouldUseColor(process.stdout, environment)));
77
92
  }
78
93
  },
79
94
  warn(message, context = 'fluo') {
80
95
  if (shouldLog('warn', level)) {
81
- console.warn(format('WARN', context, message, options.color ?? Boolean(process.stderr.isTTY)));
96
+ console.warn(format('WARN', context, message, options.color ?? shouldUseColor(process.stderr, environment)));
82
97
  }
83
98
  }
84
99
  };
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "module-graph",
10
10
  "orchestration"
11
11
  ],
12
- "version": "1.0.0-beta.10",
12
+ "version": "1.0.0-beta.11",
13
13
  "private": false,
14
14
  "license": "MIT",
15
15
  "repository": {
@@ -67,14 +67,14 @@
67
67
  "dist"
68
68
  ],
69
69
  "dependencies": {
70
- "@fluojs/di": "^1.0.0-beta.6",
71
70
  "@fluojs/config": "^1.0.0-beta.6",
72
- "@fluojs/http": "^1.0.0-beta.9",
73
- "@fluojs/core": "^1.0.0-beta.3"
71
+ "@fluojs/core": "^1.0.0-beta.4",
72
+ "@fluojs/di": "^1.0.0-beta.6",
73
+ "@fluojs/http": "^1.0.0-beta.10"
74
74
  },
75
75
  "devDependencies": {
76
76
  "vitest": "^3.2.4",
77
- "@fluojs/serialization": "^1.0.0-beta.4"
77
+ "@fluojs/serialization": "^1.0.0-beta.5"
78
78
  },
79
79
  "scripts": {
80
80
  "prebuild": "node ../../tooling/scripts/clean-dist.mjs",