# @scalar/helpers

## 0.8.2

### Patch Changes

- [#9449](https://github.com/scalar/scalar/pull/9449): Replace the CommonJS-only `cookie` dependency with an in-repo ESM `serializeCookie` helper

## 0.8.1

### Patch Changes

- [#9377](https://github.com/scalar/scalar/pull/9377): fix: prevent the browser from freezing when pretty-printing deeply shared object graphs (e.g. the "Show Schema" toggle on recursive OpenAPI schemas). `prettyPrintJson` now always collapses repeated references instead of fully expanding every shared subtree, which previously grew exponentially.

## 0.8.0

### Minor Changes

- [#9211](https://github.com/scalar/scalar/pull/9211): feat: add compareVersions and serializeReleaseNotes helpers
- [#9211](https://github.com/scalar/scalar/pull/9211): feat: support media attachments for the changelog modal
- [#9211](https://github.com/scalar/scalar/pull/9211): feat(helpers): add `setValueAtPath` for path-array-based nested object writes

### Patch Changes

- [#9211](https://github.com/scalar/scalar/pull/9211): fix(api-client): block invalid request URLs before send and surface `buildRequest` failures as results

  Request construction now treats a bad merged URL as a first-class failure instead of throwing deep inside helpers. After `mergeUrls`, `resolveRequestFactoryUrl` rejects incomplete targets when strict mode applies: relative URLs, an empty server base, or path strings that still contain unresolved `{{variable}}` placeholders. Callers may set `allowMissingRequestServerBase` where a full absolute URL is intentionally optional (for example the embedded modal layout in `OperationBlock`, or API Reference `onBeforeRequest` hooks that build against the document origin).

  `buildRequest` returns a `Result` (`ok` / `err`) with stable error codes such as `MISSING_REQUEST_SERVER_BASE`, `INVALID_REQUEST_FACTORY_URL`, and `BUILD_REQUEST_FAILED` for unexpected synchronous failures. Those failures are wrapped with `safeRun` from `@scalar/helpers`, which logs to `console.error` and maps throws to a string message on the result. The API Reference plugin path logs and skips `onBeforeRequest` when a preview request cannot be built, so user hooks never run against a half-built fetch payload.

  Downstream packages (`api-client`, `api-reference`, `scalar-app` where applicable) unwrap the result, show toasts or logs, and avoid calling `sendRequest` until the URL is valid.

- [#9211](https://github.com/scalar/scalar/pull/9211): fix(helpers): show friendly error message for relative / non-http URLs in the API client
- [#9211](https://github.com/scalar/scalar/pull/9211): feat: better server extraction from partial urls
- [#9211](https://github.com/scalar/scalar/pull/9211): fix(api-client): request body content types — OpenAPI extras, MIME labels, and "Other" without auto Content-Type

  The request body dropdown lists built-in types first, then any additional media types from the OpenAPI operation. Labels use the MIME essence (no `charset` in the label). The **Other** option is available again for a raw body: it does **not** add an automatic `Content-Type` header (users can set one manually). Code snippets avoid injecting `Content-Type: other`.

  `getDefaultHeaders` and `filterDisabledDefaultHeaders` are exported from `@scalar/workspace-store/request-example`; the API client uses them for code snippets instead of a duplicate helper.

- [#9211](https://github.com/scalar/scalar/pull/9211): feat(helpers): add `normalizationForm` and `stripAccents` options to `slugify` and `slugger`
  - `normalizationForm` (`'NFC' | 'NFD' | 'NFKC' | 'NFKD'`, default `'NFC'`) passes the chosen form to `String.prototype.normalize()` before slugifying.
  - `stripAccents` (`boolean`, default `false`) decomposes accented letters via NFD and removes all Unicode combining marks so e.g. `"Crème Brûlée"` becomes `"creme-brulee"`. Takes precedence over `normalizationForm`.

- [#9211](https://github.com/scalar/scalar/pull/9211): fix: forward selected forbidden headers via `X-Scalar-*` when proxying

  Browsers strip selected forbidden headers from outgoing requests. When using the Scalar proxy (or running in Electron), we now rewrite a small allowlist (`Date`, `DNT`, and `Referer`) to `X-Scalar-*` headers so the proxy can forward the intended upstream headers without opening support for the full forbidden-header set.

- [#9211](https://github.com/scalar/scalar/pull/9211): Add `@scalar/helpers/theme/load-css-variables` for parsing Scalar theme CSS into light/dark custom property maps (moved from scalar-app).

## 0.7.0

### Minor Changes

- [#9063](https://github.com/scalar/scalar/pull/9063): feat: add compareVersions and serializeReleaseNotes helpers
- [#9167](https://github.com/scalar/scalar/pull/9167): feat: support media attachments for the changelog modal
- [#9055](https://github.com/scalar/scalar/pull/9055): feat(helpers): add `setValueAtPath` for path-array-based nested object writes

### Patch Changes

- [#9184](https://github.com/scalar/scalar/pull/9184): fix(api-client): block invalid request URLs before send and surface `buildRequest` failures as results

  Request construction now treats a bad merged URL as a first-class failure instead of throwing deep inside helpers. After `mergeUrls`, `resolveRequestFactoryUrl` rejects incomplete targets when strict mode applies: relative URLs, an empty server base, or path strings that still contain unresolved `{{variable}}` placeholders. Callers may set `allowMissingRequestServerBase` where a full absolute URL is intentionally optional (for example the embedded modal layout in `OperationBlock`, or API Reference `onBeforeRequest` hooks that build against the document origin).

  `buildRequest` returns a `Result` (`ok` / `err`) with stable error codes such as `MISSING_REQUEST_SERVER_BASE`, `INVALID_REQUEST_FACTORY_URL`, and `BUILD_REQUEST_FAILED` for unexpected synchronous failures. Those failures are wrapped with `safeRun` from `@scalar/helpers`, which logs to `console.error` and maps throws to a string message on the result. The API Reference plugin path logs and skips `onBeforeRequest` when a preview request cannot be built, so user hooks never run against a half-built fetch payload.

  Downstream packages (`api-client`, `api-reference`, `scalar-app` where applicable) unwrap the result, show toasts or logs, and avoid calling `sendRequest` until the URL is valid.

- [#9157](https://github.com/scalar/scalar/pull/9157): fix(helpers): show friendly error message for relative / non-http URLs in the API client
- [#9200](https://github.com/scalar/scalar/pull/9200): feat: better server extraction from partial urls
- [#9134](https://github.com/scalar/scalar/pull/9134): fix(api-client): request body content types — OpenAPI extras, MIME labels, and "Other" without auto Content-Type

  The request body dropdown lists built-in types first, then any additional media types from the OpenAPI operation. Labels use the MIME essence (no `charset` in the label). The **Other** option is available again for a raw body: it does **not** add an automatic `Content-Type` header (users can set one manually). Code snippets avoid injecting `Content-Type: other`.

  `getDefaultHeaders` and `filterDisabledDefaultHeaders` are exported from `@scalar/workspace-store/request-example`; the API client uses them for code snippets instead of a duplicate helper.

- [#9151](https://github.com/scalar/scalar/pull/9151): feat(helpers): add `normalizationForm` and `stripAccents` options to `slugify` and `slugger`
  - `normalizationForm` (`'NFC' | 'NFD' | 'NFKC' | 'NFKD'`, default `'NFC'`) passes the chosen form to `String.prototype.normalize()` before slugifying.
  - `stripAccents` (`boolean`, default `false`) decomposes accented letters via NFD and removes all Unicode combining marks so e.g. `"Crème Brûlée"` becomes `"creme-brulee"`. Takes precedence over `normalizationForm`.

- [#9035](https://github.com/scalar/scalar/pull/9035): fix: forward selected forbidden headers via `X-Scalar-*` when proxying

  Browsers strip selected forbidden headers from outgoing requests. When using the Scalar proxy (or running in Electron), we now rewrite a small allowlist (`Date`, `DNT`, and `Referer`) to `X-Scalar-*` headers so the proxy can forward the intended upstream headers without opening support for the full forbidden-header set.

- [#9133](https://github.com/scalar/scalar/pull/9133): Add `@scalar/helpers/theme/load-css-variables` for parsing Scalar theme CSS into light/dark custom property maps (moved from scalar-app).

## 0.6.0

### Minor Changes

- [#9050](https://github.com/scalar/scalar/pull/9050): feat: better support for error as values

## 0.5.5

### Patch Changes

- [#9023](https://github.com/scalar/scalar/pull/9023): chore: use homemade slugger

## 0.5.4

### Patch Changes

- [#9043](https://github.com/scalar/scalar/pull/9043): chore: move test documents to cdn

## 0.5.3

### Patch Changes

- [#8971](https://github.com/scalar/scalar/pull/8971): feat(helpers): add a helper playwright utilities

## 0.5.2

### Patch Changes

- [#8952](https://github.com/scalar/scalar/pull/8952): Export shared Scalar custom header constants from `@scalar/helpers/http/scalar-headers` and consume them in request build/send flows.

## 0.5.1

### Patch Changes

- [#8911](https://github.com/scalar/scalar/pull/8911): feat: switch from Request to RequestPayload to support body with GET

## 0.5.0

### Minor Changes

- [#8632](https://github.com/scalar/scalar/pull/8632): feat: support generation of random data

### Patch Changes

- [#8735](https://github.com/scalar/scalar/pull/8735): fix: replace direct cjs mime and curl dependencies with local implementations
- [#8735](https://github.com/scalar/scalar/pull/8735): Skip empty MIME parameter values and remove a stale Nuxt optimizeDeps entry for `highlightjs-curl`.
- [#8825](https://github.com/scalar/scalar/pull/8825): chore: moving files around in preparation for the big deletion of client v1
- [#8850](https://github.com/scalar/scalar/pull/8850): chore: remove entities, zod and the parser from oas-utils

## 0.4.3

### Patch Changes

- [#8692](https://github.com/scalar/scalar/pull/8692): feat: replace pretty-bytes dependency with internal helper
- [#8555](https://github.com/scalar/scalar/pull/8555): feat: add getMarkdownHeadings utility

## 0.4.2

### Patch Changes

- [#8466](https://github.com/scalar/scalar/pull/8466): chore: new build pipeline

## 0.4.1

### Patch Changes

- [#8420](https://github.com/scalar/scalar/pull/8420): fix TypeScript access to navigator.userAgentData in isMacOS without ts-expect-error

## 0.4.0

### Minor Changes

- [#8336](https://github.com/scalar/scalar/pull/8336): feat: support flushing any pending operations

## 0.3.0

### Minor Changes

- [#8322](https://github.com/scalar/scalar/pull/8322): chore: bump required node version to >=22 (LTS)

## 0.2.18

### Patch Changes

- [#8314](https://github.com/scalar/scalar/pull/8314): chore: limit concurrent operations while migrating workspaces

## 0.2.17

### Patch Changes

- [#8310](https://github.com/scalar/scalar/pull/8310): refactor: move helpers to the helpers package to share primitive helpers

## 0.2.16

### Patch Changes

- [#8248](https://github.com/scalar/scalar/pull/8248): fix: local storage migration script

## 0.2.15

### Patch Changes

- [#8212](https://github.com/scalar/scalar/pull/8212): chore: version bump

## 0.2.14

### Patch Changes

- [#8207](https://github.com/scalar/scalar/pull/8207): chore: version bump

## 0.2.13

### Patch Changes

- [#7826](https://github.com/scalar/scalar/pull/7826): feat: added migrator for v1 local storage to v2 indexdb

## 0.2.12

### Patch Changes

- [#8178](https://github.com/scalar/scalar/pull/8178): chore: package bump due to ci failure

## 0.2.11

### Patch Changes

- [#8016](https://github.com/scalar/scalar/pull/8016): feat: move history and auth into their own store

## 0.2.10

### Patch Changes

- [#7963](https://github.com/scalar/scalar/pull/7963): feat: unify is-object helpers

## 0.2.9

### Patch Changes

- [#7894](https://github.com/scalar/scalar/pull/7894): fix: the import and export of redirect to proxy

## 0.2.8

### Patch Changes

- [#7751](https://github.com/scalar/scalar/pull/7751): fix: auth persistence

## 0.2.7

### Patch Changes

- [#7720](https://github.com/scalar/scalar/pull/7720): feat: escape XML in json2xml

## 0.2.6

### Patch Changes

- [#7661](https://github.com/scalar/scalar/pull/7661): fix: all issues for client modal v2 preparation

## 0.2.5

### Patch Changes

- [#7605](https://github.com/scalar/scalar/pull/7605): fix: all issues for client modal v2 preparation

## 0.2.4

### Patch Changes

- [#7581](https://github.com/scalar/scalar/pull/7581): fix: npm publish job
- [#7567](https://github.com/scalar/scalar/pull/7567): feat: add code samples to client v2

## 0.2.3

### Patch Changes

- [#7575](https://github.com/scalar/scalar/pull/7575): feat: add support for object examples + hide body when empty

## 0.2.2

### Patch Changes

- [#7467](https://github.com/scalar/scalar/pull/7467) [`f7c24e4`](https://github.com/scalar/scalar/commit/f7c24e4995580649dbc3cb87007a683f5dd91f7c) Thanks [@amritk](https://github.com/amritk)! - feat: client v2 handle path change with routing and conflict

## 0.2.1

### Patch Changes

- [#7489](https://github.com/scalar/scalar/pull/7489) [`21aa62e`](https://github.com/scalar/scalar/commit/21aa62e2ebdd262cb5aa53658c3b659736660722) Thanks [@amritk](https://github.com/amritk)! - feat: added new helpers for building client v2 requests

## 0.2.0

### Minor Changes

- [#7477](https://github.com/scalar/scalar/pull/7477) [`9ec8adf`](https://github.com/scalar/scalar/commit/9ec8adfea017333dee5bc3949104232f7dc57f4a) Thanks [@DemonHa](https://github.com/DemonHa)! - fix: correctly sort documents on the workspace

## 0.1.3

### Patch Changes

- [#7387](https://github.com/scalar/scalar/pull/7387) [`bfd814a`](https://github.com/scalar/scalar/commit/bfd814a4219660face190041cc4845182b56ab03) Thanks [@geoffgscott](https://github.com/geoffgscott)! - hotfix: patch exports from build tooling bug

- [#7416](https://github.com/scalar/scalar/pull/7416) [`86f028d`](https://github.com/scalar/scalar/commit/86f028deb0b456f923edd261f5f4b0fa9b616b7d) Thanks [@amritk](https://github.com/amritk)! - feat: add update method to client v2

## 0.1.2

### Patch Changes

- [#7392](https://github.com/scalar/scalar/pull/7392) [`d86f1d6`](https://github.com/scalar/scalar/commit/d86f1d6911ecbca70b011a2a0efb6d6e0eca59bb) Thanks [@amritk](https://github.com/amritk)! - fix: move away from wasm hashing algo

- [#7348](https://github.com/scalar/scalar/pull/7348) [`cded2d6`](https://github.com/scalar/scalar/commit/cded2d6c087418c3c44731d344d0827a87b78b74) Thanks [@hwkr](https://github.com/hwkr)! - feat(components): add ScalarWrappingText component

## 0.1.1

### Patch Changes

- [#7289](https://github.com/scalar/scalar/pull/7289) [`9c9dbba`](https://github.com/scalar/scalar/commit/9c9dbbaa940667303f0ace59469fd78c2a741937) Thanks [@amritk](https://github.com/amritk)! - feat: move debounce to helpers and add max wait

- [#7252](https://github.com/scalar/scalar/pull/7252) [`4bec1ba`](https://github.com/scalar/scalar/commit/4bec1ba332e919c4ee32dcfbfb07bd8ee42c4d74) Thanks [@hwkr](https://github.com/hwkr)! - fix(api-reference): improve wrapping of long strings

## 0.1.0

### Minor Changes

- [#7235](https://github.com/scalar/scalar/pull/7235) [`c1ecd0c`](https://github.com/scalar/scalar/commit/c1ecd0c6096f3fbe2e3d8ad3794ea718bb6bce66) Thanks [@marcalexiei](https://github.com/marcalexiei)! - feat(helpers): add `node:path` polyfill

### Patch Changes

- [#7266](https://github.com/scalar/scalar/pull/7266) [`fddf294`](https://github.com/scalar/scalar/commit/fddf294b00dd8c9eb5c713c338f2ec6e3f62523d) Thanks [@amritk](https://github.com/amritk)! - fix: remove useage of crypto.subtle in all contexts

## 0.0.13

### Patch Changes

- [#7129](https://github.com/scalar/scalar/pull/7129) [`6ec8c29`](https://github.com/scalar/scalar/commit/6ec8c299d912111b029e8058979d00968b70691a) Thanks [@geoffgscott](https://github.com/geoffgscott)! - Simplify ApiReferences state management and migrate to new shared sidebar component. Eliminates the useSidebar and useNav hooks in favour of event bubbling and centralized state management in ApiReference.vue

## 0.0.12

### Patch Changes

- 3f6d0b9: fix(helpers): `scrollToId` is not an async function

## 0.0.11

### Patch Changes

- bff46e5: feat: don’t use proxy for reserved tlds

## 0.0.10

### Patch Changes

- 821717b: refactor: schema rendering

## 0.0.9

### Patch Changes

- 98c55d0: feat: better xml rendering
- 0e747c7: fix: initial scroll to id lands in random positions

## 0.0.8

### Patch Changes

- 66b18fc: feat: update the references to handle $refs from the magic proxy

## 0.0.7

### Patch Changes

- c0d6793: feat: ensure we use the path routing base path for relative document url resolution
- f3d0216: feat: lazy loading v1.5

## 0.0.6

### Patch Changes

- 2d7f995: refactor: use more common straight apostrophe ' instead of the real apostrophe ’

## 0.0.5

### Patch Changes

- 23b150b: fix: operation to har helper with real world usecases

## 0.0.4

### Patch Changes

- 221e35f: feat: added webhooks

## 0.0.3

### Patch Changes

- 8bc9f20: fix(helpers): ensure .js extension is emitted for imports

## 0.0.2

### Patch Changes

- 8165b3b: feat(helpers): added new helpers package
