# veryfront/utils

## Import

```ts
import {
  assertCSSPipelineIdentity,
  assertStyleProfileHash,
  awaitAbortable,
  base64urlEncode,
  base64urlEncodeBytes,
  computeCodeHash,
} from "veryfront/utils";
```

## Examples

### Structured logging

```ts
import { serverLogger } from "veryfront/utils";

serverLogger.info("Booting server", { project_id: "proj_123" });
```

## Exports

### Components

| Name                                   | Description                                                                                                                                                                                                                                                                                                        | Source                                                                                             |
| -------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- |
| `BREAKPOINT_LG`                        | Shared breakpoint lg value.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |
| `BREAKPOINT_MD`                        | Shared breakpoint md value.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |
| `BREAKPOINT_SM`                        | Shared breakpoint sm value.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |
| `BREAKPOINT_XL`                        | Shared breakpoint xl value.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |
| `BYTES_PER_KB`                         | Shared bytes per kb value.                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/network.ts)     |
| `DEFAULT_ALLOWED_CDN_HOSTS`            | Default value for allowed cdn hosts.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cdn.ts)         |
| `DEFAULT_BUILD_CONCURRENCY`            | Default value for build concurrency.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/build.ts)       |
| `DEFAULT_DASHBOARD_PORT`               | Default port for development dashboard (matches veryfront.config.ts default)                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/server.ts)      |
| `DEFAULT_LRU_MAX_ENTRIES`              | Default value for lru max entries.                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cache.ts)       |
| `DEV_SERVER_ENDPOINTS`                 | Shared dev server endpoints value.                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/server.ts)      |
| `FORBIDDEN_PATH_PATTERNS`              | Shared forbidden path patterns value.                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/security.ts)    |
| `HASH_SEED_DJB2`                       | Shared hash seed djb2 value.                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hash.ts)        |
| `HASH_SEED_FNV1A`                      | Shared hash seed fnv1 a value.                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hash.ts)        |
| `HMR_CLIENT_RELOAD_DELAY_MS`           | Shared HMR client reload delay ms value.                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_CLOSE_MESSAGE_TOO_LARGE`          | Shared HMR close message too large value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_CLOSE_NORMAL`                     | Shared HMR close normal value.                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_CLOSE_RATE_LIMIT`                 | Shared HMR close rate limit value.                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_MAX_MESSAGE_SIZE_BYTES`           | Shared HMR max message size bytes value.                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_MAX_MESSAGES_PER_MINUTE`          | Shared HMR max messages per minute value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HMR_RATE_LIMIT_WINDOW_MS`             | Shared HMR rate limit window ms value.                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/hmr.ts)         |
| `HTTP_BAD_REQUEST`                     | Shared HTTP bad request value.                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_GIF`          | Shared HTTP content type image gif value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_ICO`          | Shared HTTP content type image ico value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_JPEG`         | Shared HTTP content type image jpeg value.                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_PNG`          | Shared HTTP content type image png value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_SVG`          | Shared HTTP content type image svg value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPE_IMAGE_WEBP`         | Shared HTTP content type image webp value.                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_CONTENT_TYPES`                   | Shared HTTP content types value.                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_MODULE_FETCH_TIMEOUT_MS`         | HTTP module fetch timeout, including cold upstream module generation.                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_NETWORK_CONNECT_TIMEOUT`         | Shared HTTP network connect timeout value.                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_NOT_FOUND`                       | Shared HTTP not found value.                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_NOT_IMPLEMENTED`                 | Shared HTTP not implemented value.                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_OK`                              | Shared HTTP ok value.                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_REDIRECT_FOUND`                  | Shared HTTP redirect found value.                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_SERVER_ERROR`                    | Shared HTTP server error value.                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_STATUS_CLIENT_ERROR_MIN`         | Shared HTTP status client error min value.                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_STATUS_REDIRECT_MIN`             | Shared HTTP status redirect min value.                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_STATUS_SERVER_ERROR_MIN`         | Shared HTTP status server error min value.                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_STATUS_SUCCESS_MIN`              | Shared HTTP status success min value.                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `HTTP_UNAVAILABLE`                     | Shared HTTP unavailable value.                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `IMAGE_OPTIMIZATION`                   | Shared image optimization value.                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/build.ts)       |
| `MAX_BATCH_SIZE`                       | Maximum batch size.                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/limits.ts)      |
| `MAX_CSS_PIPELINE_IDENTITY_CODE_UNITS` | Maximum UTF-16 code units accepted for one complete CSS pipeline identity.                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts) |
| `MAX_CSS_PIPELINE_IDENTITY_UTF8_BYTES` | Maximum encoded UTF-8 bytes accepted for one complete CSS pipeline identity.                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts) |
| `MAX_PATH_LENGTH`                      | Maximum value for path length.                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/security.ts)    |
| `MAX_PATH_TRAVERSAL_DEPTH`             | Maximum value for path traversal depth.                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/security.ts)    |
| `MS_PER_SECOND`                        | Shared ms per second value.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cache.ts)       |
| `PREFETCH_DEFAULT_DELAY_MS`            | Shared prefetch default delay ms value.                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `PREFETCH_DEFAULT_TIMEOUT_MS`          | Shared prefetch default timeout ms value.                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `PREFETCH_MAX_SIZE_BYTES`              | Shared prefetch max size bytes value.                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/http.ts)        |
| `REACT_DEFAULT_VERSION`                | Shared React default version value.                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cdn.ts)         |
| `RESPONSIVE_IMAGE_WIDTH_LG`            | Shared responsive image width lg value.                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/network.ts)     |
| `RESPONSIVE_IMAGE_WIDTHS`              | Shared responsive image widths value.                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/network.ts)     |
| `RSC_MANIFEST_CACHE_TTL_MS`            | Shared RSC manifest cache ttl ms value.                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cache.ts)       |
| `TSX_LAYOUT_MAX_ENTRIES`               | Shared TSX layout max entries value.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cache.ts)       |
| `TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES`   | Per-project cap for the TSX layout component cache. Prevents a single noisy tenant from evicting every other project's cached layouts. Defaults to ceil(TSX\_LAYOUT\_MAX\_ENTRIES / 10) so no one project consumes more than \~10 % of the global budget. Set via TSX\_LAYOUT\_PER\_PROJECT\_MAX\_ENTRIES env var. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cache.ts)       |
| `VERSION`                              | Shared version value.                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/version-constant.ts)      |
| `Z_INDEX_DEV_INDICATOR`                | Shared z index dev indicator value.                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |
| `Z_INDEX_ERROR_OVERLAY`                | Shared z index error overlay value.                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/html.ts)        |

### Functions

| Name                                  | Description                                                                                                                                                                                                                                                                                                                                           | Source                                                                                              |
| ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `assertCSSPipelineIdentity`           | Validate and return an immutable string snapshot for cache or wire use.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts)  |
| `assertStyleProfileHash`              | Validate and return the canonical style-scope profile SHA-256 identity.                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts)  |
| `awaitAbortable`                      | Await a value while allowing cancellation to win even when the producer ignores its signal.                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/abort.ts)                  |
| `base64urlEncode`                     | Encode a string as unpadded base64url.                                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/base64url.ts)              |
| `base64urlEncodeBytes`                | Encode raw bytes as unpadded base64url.                                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/base64url.ts)              |
| `computeCodeHash`                     | Compute a bundle hash from fixed-field raw UTF-16 code-unit framing.                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `computeHash`                         | Compute the lowercase hex SHA-256 digest of a UTF-8 string.                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `computeHashBytes`                    | Compute the lowercase hex SHA-256 digest of raw bytes.                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `computeIntegrity`                    | Compute integrity.                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/import-lockfile.ts)        |
| `createAbortError`                    | Convert an arbitrary abort reason into the framework's stable Error shape.                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/abort.ts)                  |
| `createLockfileManager`               | Create lockfile manager.                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/import-lockfile.ts)        |
| `createRunUserLogger`                 | Create run user logger.                                                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `createSubscriberSet`                 | Create a subscriber set: the canonical subscribe/notify observable used across modules. Notification iterates a snapshot, so a listener that unsubscribes (itself or others) mid-notify is safe, and listener errors are isolated (routed to `onListenerError` when provided, otherwise swallowed).                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/subscriber-set.ts)         |
| `encodeBase64`                        | Encode a string as standard base64. Latin-1 input (all code points <= 0xFF) is encoded with btoa's binary-string semantics; input outside Latin-1 falls back to UTF-8 bytes. Callers that need guaranteed UTF-8 bytes regardless of input (e.g. data: URLs decoded as UTF-8) should use `encodeBase64Bytes(new TextEncoder().encode(value))` instead. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/base64url.ts)              |
| `encodeBase64Bytes`                   | Encode raw bytes as standard base64.                                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/base64url.ts)              |
| `endRequest`                          | Request payload for end.                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/perf-timer.ts)             |
| `fnv1aHash`                           | FNV-1a hash for strings - returns hex string                                                                                                                                                                                                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `getBaseLogger`                       | Get an immutable base logger without request context awareness.                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts)           |
| `getBundleManifestStore`              | Return bundle manifest store.                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/bundle-manifest.ts)        |
| `getDenoStdNodeBase`                  | Return Deno std node base.                                                                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cdn.ts)          |
| `getLockfileEntryForBuild`            | Read a lockfile entry on a build or dev-server hot path.                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/import-lockfile.ts)        |
| `getReactImportMap`                   | Return React import map.                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/cdn.ts)          |
| `hasBunRuntime`                       | Check whether Bun runtime is present.                                                                                                                                                                                                                                                                                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `hasDenoRuntime`                      | Check whether Deno runtime is present.                                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `hasNodeProcess`                      | Check whether node process is present.                                                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `hasProjectIdentityControlCharacters` | Whether a string contains a Unicode Cc control code point.                                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/project-identity.ts)       |
| `isCanonicalProjectSlug`              | Whether a normalized value is a canonical hosted project slug.                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/project-identity.ts)       |
| `isCompiledBinary`                    | Detect if the code is running in a compiled Deno binary                                                                                                                                                                                                                                                                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/platform.ts)               |
| `isCSSPipelineIdentity`               | Whether a value is safe to compare, encode, and persist as a CSS pipeline identity.                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts)  |
| `isEnabled`                           | Check whether request performance timing is enabled.                                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/perf-timer.ts)             |
| `isRSCEnabled`                        | Check whether RSC is enabled.                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/feature-flags.ts)          |
| `isStyleProfileHash`                  | Whether a value is the canonical style-scope profile SHA-256 identity.                                                                                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/css-artifact-identity.ts)  |
| `isTruthyEnvValue`                    |                                                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/constants/env.ts)          |
| `isWithinDirectory`                   |                                                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/path-utils.ts)             |
| `memoize`                             | Memoize.                                                                                                                                                                                                                                                                                                                                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/memoize.ts)                |
| `memoizeAsync`                        | Memoize async.                                                                                                                                                                                                                                                                                                                                        | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/memoize.ts)                |
| `memoizeHash`                         | FNV-1a hash algorithm for fast, framed cache key generation. 10-15x faster than JSON.stringify() and uses 70-80% less memory.                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/memoize.ts)                |
| `normalizePath`                       | Normalizes path.                                                                                                                                                                                                                                                                                                                                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/path-utils.ts)             |
| `parallelMap`                         | Run parallel map.                                                                                                                                                                                                                                                                                                                                     | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/parallel.ts)               |
| `redactForSerialization`              | Returns a JSON-safe redacted snapshot of `context`. Sensitive keys are masked, nested values are traversed, BigInts become decimal strings, non-finite numbers become `null`, and unsupported or unreadable values fail closed. Objects with `toJSON` are snapshotted exactly once before redaction.                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/redact.ts)          |
| `redactSensitive`                     | Returns a redacted copy of `context` while preserving the established source and runtime value shapes. Any property whose key is `isSensitiveKey` is replaced with `REDACTED`; nested records and arrays are traversed, while primitives and scalar-serializing objects retain their original types. The input is never mutated.                      | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/redact.ts)          |
| `runWithRequestContextAsync`          | Run with request context async.                                                                                                                                                                                                                                                                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `safeJsonParse`                       | Parse `value` as JSON without throwing; failures return `{ ok: false, error }` so callers handle them without a surrounding try/catch.                                                                                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/json.ts)                   |
| `sanitizeUrlCredentials`              | Strip credentials from URL-shaped strings so they can be safely emitted in free-form text (error messages, stacks, lifted `request_url` fields). Unlike `redactSensitive`, which is key-based, this scrubs secrets embedded in the *value* itself:                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/redact.ts)          |
| `sanitizeUrlForSpan`                  | Return the URL form safe to attach to observability span attributes.                                                                                                                                                                                                                                                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/redact.ts)          |
| `setLockfileEntryForBuild`            | Persist a lockfile entry from a build or dev-server hot path.                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/import-lockfile.ts)        |
| `shortHash`                           | Create short hash.                                                                                                                                                                                                                                                                                                                                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `simpleHash`                          | Create simple hash.                                                                                                                                                                                                                                                                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `sleep`                               | Return a promise that resolves after `ms` milliseconds. If `abortSignal` is already aborted, throws `abortSignal.reason` synchronously. If it aborts while waiting, rejects with `abortSignal.reason`.                                                                                                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/sleep.ts)                  |
| `startRequest`                        | Request payload for start.                                                                                                                                                                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/perf-timer.ts)             |
| `startTimer`                          | Starts timer.                                                                                                                                                                                                                                                                                                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/perf-timer.ts)             |
| `throwIfAborted`                      | Throw the normalized abort reason when a signal has already been aborted.                                                                                                                                                                                                                                                                             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/abort.ts)                  |
| `timeAsync`                           | Time async.                                                                                                                                                                                                                                                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/perf-timer.ts)             |

### Classes

| Name        | Description           | Source                                                                               |
| ----------- | --------------------- | ------------------------------------------------------------------------------------ |
| `MemoCache` | Implement memo cache. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/memoize.ts) |

### Types

| Name                  | Description                                                                                | Source                                                                                              |
| --------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| `BundleCode`          | Public API contract for bundle code.                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/bundle-manifest.ts)        |
| `BundleMetadata`      | Public API contract for bundle metadata.                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/bundle-manifest.ts)        |
| `GlobalWithBun`       | Public API contract for global with Bun.                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `GlobalWithDeno`      | Public API contract for global with Deno.                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `GlobalWithProcess`   | Public API contract for global with process.                                               | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/runtime-guards.ts)         |
| `HashBundleCode`      | Source bundle content used for hash computation.                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/hash-utils.ts)             |
| `LockfileManager`     | Public API contract for lockfile manager.                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/import-lockfile.ts)        |
| `LogEntry`            | Structured log entry for JSON output. Fields are designed for easy Grafana/Loki filtering. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `Logger`              | Public API contract for logger.                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `RedactedValue`       |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/redact.ts)          |
| `RequestContext`      | Context for request.                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `SafeJsonParseResult` | Tagged-union result of `safeJsonParse`; narrow via the `ok` discriminant.                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/json.ts)                   |
| `SubscriberSet`       | Listener registry returned by `createSubscriberSet`.                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/subscriber-set.ts)         |

### Constants

| Name             | Description | Source                                                                                    |
| ---------------- | ----------- | ----------------------------------------------------------------------------------------- |
| `agentLogger`    |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `bundlerLogger`  |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `cliLogger`      |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `logger`         |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `rendererLogger` |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `serverLogger`   |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |

## Deep imports

These import paths group focused functionality under this module. Each is a separate barrel; import only what you need.

### `veryfront/utils/logger`

Utils Logger

```ts
import { colorize, createRequestLogger, createRunUserLogger } from "veryfront/utils/logger";
```

#### Components

| Name            | Description                                                                                                                                                                | Source                                                                                         |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `ANSI`          |                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)       |
| `LEVEL_COLORS`  |                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)       |
| `LEVEL_GLYPHS`  |                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)       |
| `LogComponents` | Canonical component names for structured logging.                                                                                                                          | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/components.ts) |
| `PREFIX_WIDTH`  |                                                                                                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)       |
| `TAG_WIDTH`     | Shared logger formatting utilities. This module contains pure formatting functions with no external dependencies, enabling reuse between the main logger and proxy logger. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)       |

#### Functions

| Name                         | Description                                                                                               | Source                                                                                              |
| ---------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| `colorize`                   | Apply ANSI color codes to text if enabled.                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `createRequestLogger`        | Create a logger for a specific request context. Useful for binding request-specific metadata to all logs. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `createRunUserLogger`        | Create run user logger.                                                                                   | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `formatContextText`          | Format context and error as indented key=value pairs. Filters out undefined values for cleaner output.    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `formatErrorText`            | Format a serialized error for text output.                                                                | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `formatTimestamp`            | Format a timestamp as HH:MM:SS.                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `formatValue`                | Format a value for log output (handles strings, numbers, booleans, objects).                              | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `getBaseLogger`              | Get an immutable base logger without request context awareness.                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts)           |
| `getDefaultLevel`            | Determine the log level based on environment variables. Exported for testing purposes.                    | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `getRequestContext`          |                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `getRequestLogger`           |                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `isRecord`                   | Check if value is a non-null, non-array object (plain record).                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `normalizeText`              | Normalize whitespace in text (collapse multiple spaces to single space).                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `padTag`                     | Pad or truncate a tag to fixed width for aligned output.                                                  | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `runWithRequestContext`      |                                                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `runWithRequestContextAsync` | Run with request context async.                                                                           | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `serializeError`             | Serialize an error object for structured logging.                                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `truncateText`               | Truncate text to maxLength, adding ellipsis if truncated.                                                 | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |

#### Types

| Name               | Description                                                                                | Source                                                                                              |
| ------------------ | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| `LogComponent`     |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/components.ts)      |
| `LogEntry`         | Structured log entry for JSON output. Fields are designed for easy Grafana/Loki filtering. | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `LogFormat`        |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `Logger`           | Public API contract for logger.                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `LogLevel`         |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `LogLevelName`     |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |
| `LogRecordEmitter` |                                                                                            | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/logger.ts)          |
| `RequestContext`   | Context for request.                                                                       | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/request-context.ts) |
| `SerializedError`  | Serialized error structure for structured logging.                                         | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/core.ts)            |

#### Constants

| Name             | Description | Source                                                                                    |
| ---------------- | ----------- | ----------------------------------------------------------------------------------------- |
| `agentLogger`    |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `bundlerLogger`  |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `cliLogger`      |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `logger`         |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `proxyLogger`    |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `rendererLogger` |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
| `serverLogger`   |             | [source](https://github.com/veryfront/veryfront-code/blob/main/src/utils/logger/index.ts) |
