@gajae-code/utils 0.11.7 → 0.11.8

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.
@@ -66,3 +66,7 @@ export declare function isBunTestRuntime(): boolean;
66
66
  */
67
67
  export declare function isCompiledBinary(): boolean;
68
68
  export declare function $flag(name: string, def?: boolean): boolean;
69
+ /** Resolve the first flag among keys that has a set value (GJC-first, PI fallback). Matches $flag semantics per key. */
70
+ export declare function $pickflag(...keys: string[]): boolean;
71
+ /** Resolve the first positive integer among keys, else defaultValue (GJC-first). Set-but-invalid keys are skipped. */
72
+ export declare function $pickenvpos(keys: string[], defaultValue: number): number;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@gajae-code/utils",
4
- "version": "0.11.7",
4
+ "version": "0.11.8",
5
5
  "description": "Shared utilities for pi packages",
6
6
  "homepage": "https://gajae-code.com",
7
7
  "author": "Yeachan-Heo",
@@ -31,7 +31,7 @@
31
31
  "fmt": "biome format --write ."
32
32
  },
33
33
  "dependencies": {
34
- "@gajae-code/natives": "0.11.7",
34
+ "@gajae-code/natives": "0.11.8",
35
35
  "beautiful-mermaid": "^1.1.3",
36
36
  "handlebars": "^4.7.9",
37
37
  "winston": "^3.19.0",
package/src/env.ts CHANGED
@@ -279,3 +279,23 @@ export function $flag(name: string, def: boolean = false): boolean {
279
279
  // would silently read as false while only `FOO=TRUE`/`FOO=1` worked.
280
280
  return TRUTHY[value.toUpperCase()] === true;
281
281
  }
282
+
283
+ /** Resolve the first flag among keys that has a set value (GJC-first, PI fallback). Matches $flag semantics per key. */
284
+ export function $pickflag(...keys: string[]): boolean {
285
+ for (const key of keys) {
286
+ const value = $env[key]?.trim();
287
+ if (value) return TRUTHY[value.toUpperCase()] === true;
288
+ }
289
+ return false;
290
+ }
291
+
292
+ /** Resolve the first positive integer among keys, else defaultValue (GJC-first). Set-but-invalid keys are skipped. */
293
+ export function $pickenvpos(keys: string[], defaultValue: number): number {
294
+ for (const key of keys) {
295
+ const raw = $env[key]?.trim();
296
+ if (!raw) continue;
297
+ const parsed = Number.parseInt(raw, 10);
298
+ if (!Number.isNaN(parsed) && parsed > 0) return parsed;
299
+ }
300
+ return defaultValue;
301
+ }
package/src/logger.ts CHANGED
@@ -410,7 +410,10 @@ function printModuleLoadSummary(loads: Span[], depth: number, lines: string[]):
410
410
  }
411
411
  const wall = unionEnd > unionStart ? unionEnd - unionStart : 0;
412
412
  lines.push(`${childIndent}(modules): ${loads.length} loaded, wall ${fmtMs(wall)}, sum ${fmtMs(totalSelf)}`);
413
- const showAll = process.env.PI_TIMING === "full";
413
+ // Resolve GJC-first with PI fallback inline (no ./env import) so this
414
+ // foundational logger stays off the env module's dependency graph, which the
415
+ // tab-worker native-free runtime contract (issue-2598-repro) walks.
416
+ const showAll = (process.env.GJC_TIMING?.trim() || process.env.PI_TIMING?.trim()) === "full";
414
417
  const sorted = [...loads].sort((a, b) => durationOf(b) - durationOf(a));
415
418
  const visible = showAll ? sorted : sorted.slice(0, MODULE_LOAD_VERBOSE_TOP);
416
419
  for (const span of visible) {