Skip to content

Ts codeblock#161

Merged
yamcodes merged 14 commits intomainfrom
ts-codeblock
Sep 14, 2025
Merged

Ts codeblock#161
yamcodes merged 14 commits intomainfrom
ts-codeblock

Conversation

@yamcodes
Copy link
Owner

@yamcodes yamcodes commented Sep 14, 2025

Summary by CodeRabbit

  • New Features

    • Added a default module export alias and a named ArkEnvError export for simpler imports.
  • Documentation

    • Enabled Twoslash-driven, themed code examples across docs; improved JSDoc; removed an outdated guide.
    • Quickstart/import examples upgraded for multi-file Twoslash demos; example env schema updated (some fields now required; API_URL validation removed).
  • Style

    • Loaded Twoslash global styles, added max-height for Twoslash popovers, and enabled smooth scrolling.
  • Refactor

    • Reorganized site/build configuration and Sentry options; middleware now excludes /monitoring.
  • Tests

    • Strengthened plugin tests with stricter typing and richer test context.
  • Chores

    • Added runtime dependencies to support MDX/Twoslash and related tooling.

…es and enhance Next.js configuration

- Added `fumadocs-twoslash` and `twoslash` dependencies in `package.json` for improved documentation support.
- Updated `pnpm-lock.yaml` to reflect new versions and peer dependencies for `twoslash`.
- Modified `next.config.ts` to include `twoslash` and `typescript` in `serverExternalPackages` for better server-side handling.
- Added `import-in-the-middle` dependency in `package.json` for improved module handling.
- Updated `pnpm-lock.yaml` to include the new dependency version.
- Enhanced `source.config.ts` to integrate `fumadocs-twoslash` for better code documentation support.
- Included `twoslash.css` in global styles for consistent theming.
- Modified documentation page to utilize `fumadocs-twoslash` for interactive code examples.
@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2025

🦋 Changeset detected

Latest commit: 2d7ea5a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
arkenv Patch
@arkenv/vite-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
arkenv Ready Ready Preview Comment Sep 14, 2025 9:45pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 14, 2025

Warning

Rate limit exceeded

@yamcodes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 12 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between c5ede3d and 2d7ea5a.

📒 Files selected for processing (1)
  • apps/www/app/styles/base.css (1 hunks)

Walkthrough

Adds a default export alias arkenv and a named export ArkEnvError in the arkenv package; integrates ArkType/Twoslash into the docs MDX pipeline (transformers, styles, deps); adjusts many MDX docs and examples; refactors Next/Sentry config; and applies assorted small test, middleware, layout, and CSS tweaks.

Changes

Cohort / File(s) Summary
Arkenv exports & docs
packages/arkenv/src/index.ts, packages/arkenv/src/create-env.ts, packages/arkenv/README.md, .changeset/all-ghosts-worry.md, .changeset/some-bikes-film.md
Adds default export alias arkenv (alias of createEnv) and named export ArkEnvError; updates createEnv JSDoc @throws to reference ArkEnvError; README fence switched to ts twoslash; changeset entries added.
Site Twoslash / ArkType integration
apps/www/source.config.ts, apps/www/app/docs/[[...slug]]/page.tsx, apps/www/app/globals.css, apps/www/app/styles/base.css, apps/www/package.json
Integrates transformerTwoslash (ArkType) into MDX processing with custom filterNode and error-lens rewrites, adds file-system types cache, exposes Twoslash MDX components, imports twoslash CSS, adds .fd-twoslash-popover rule, and adds runtime deps (arkenv, fumadocs-twoslash, twoslash, shiki, etc.).
Next.js + Sentry config refactor
apps/www/next.config.ts
Separates MDX/Next config and Sentry build options into typed config and sentryConfig; composes withSentryConfig(createMDX()(config), sentryConfig); adds serverExternalPackages, cleanDistDir, and stricter typings.
Documentation content changes
apps/www/content/docs/...
apps/www/content/docs/examples.mdx, apps/www/content/docs/guides/environment-configuration.mdx, apps/www/content/docs/integrations/import-guide.mdx, apps/www/content/docs/quickstart.mdx, apps/www/content/docs/guides/type-function.mdx
Many fences switched to twoslash, added sample imports and cross-file twoslash markers, normalized headings/capitalization, deleted type-function.mdx, and adjusted the example env schema: removed API_URL custom validation, made ENABLE_BETA_FEATURES, MAINTENANCE_MODE, ALLOWED_ORIGINS required, and removed default for ALLOWED_ORIGINS.
Vite plugin test
packages/vite-plugin/src/index.test.ts
Adds explicit typing for imported arkenv mock; invokes plugin config hook with richer this-context and build params to ensure createEnv is called.
Middleware matcher change
apps/www/middleware.ts
Updates Next.js middleware config.matcher to exclude /monitoring (from "/:path*" to "/((?!monitoring).*)").
Playground and layout minor edits
apps/playgrounds/node/index.ts, apps/www/app/layout.tsx
Reorders NODE_ENV entry in playground config; adds data-scroll-behavior="smooth" attribute on <html> in layout.
Misc content/formatting
apps/www/content/docs/examples.mdx, packages/arkenv/README.md
Trailing newline and presentation-only changes; documentation fences updated to twoslash.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Browser as User
  participant Next as Next.js
  participant MDX as MDX renderer
  participant Rehype as rehype-code
  participant Twoslash as transformerTwoslash
  participant TypesCache as FileSystemTypesCache
  participant Shiki as Shiki/Themes

  Browser->>Next: Request page
  Next->>MDX: Render MDX
  MDX->>Rehype: Process code blocks
  Rehype->>Twoslash: Invoke transformerTwoslash (ArkType options)
  Twoslash->>TypesCache: Resolve/read types
  Twoslash-->>Rehype: Annotated HTML (hovers/errors)
  Rehype->>Shiki: Apply light/dark highlighting
  Shiki-->>MDX: Themed code HTML
  MDX-->>Next: Rendered page (includes Twoslash UI & CSS)
  Next-->>Browser: Serve HTML/CSS
Loading
sequenceDiagram
  autonumber
  participant Vite as Vite runtime
  participant Plugin as PluginInstance
  participant Env as arkenv.createEnv

  Vite->>Plugin: call config({}, { mode, command }) with context
  alt plugin has config fn
    Plugin->>Env: createEnv(...)
    Env-->>Plugin: returns env or throws ArkEnvError
    Plugin-->>Vite: merged config
  else
    Plugin-->>Vite: no-op
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Export createEnv as the default export #136 — Directly modifies packages/arkenv/src/index.ts export surface; relates to the default export alias and export changes in this PR.
  • Integration docs #154 — Adds or documents default import usage (import arkenv from 'arkenv'); related to the new default export alias.
  • Docs improvements #155 — Documentation/examples referencing default import and ArkEnvError; directly overlaps with the new exports and docs edits.

Poem

I hopped through code with whiskers bright,
Named a fault ArkEnvError tonight.
Twoslash sparks and docs that gleam,
Types and hops and a coder's dream.
Merge the patch — I nibble a byte! 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title "Ts codeblock" is terse and vague and does not clearly summarise the primary changes in the branch; while the PR includes many Twoslash/TypeScript code-block and MDX/doc updates, it also contains package API and config changes (adding a default arkenv export and ArkEnvError, MDX/Twoslash integration, config updates), so the current title does not give a teammate a clear view of the main change or scope. Please replace the title with a concise, descriptive sentence that highlights the main change (for example, "Enable ts twoslash code blocks and integrate Twoslash tooling in docs") or, if the API/config changes are primary, use a title like "Add default arkenv export and ArkEnvError; integrate Twoslash docs"; alternatively split documentation and API/config changes into separate PRs and name each accordingly.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added docs Improvements or additions to documentation www Improvements or additions to arkenv.js.org labels Sep 14, 2025
- Added `arkenv` as a workspace dependency in `package.json` for better local development.
- Updated `pnpm-lock.yaml` to include the new `require-in-the-middle` dependency.
- Exported `ArkEnvError` from `arkenv` for improved error handling in environment variable validation.
- Modified `create-env.ts` documentation to clarify error throwing behavior.
- Enhanced `source.config.ts` to utilize a file system types cache for `fumadocs-twoslash` transformers.
- Improved the JSDoc comments for `arkenv` and `createEnv` to provide more detailed descriptions, enhancing code documentation clarity.
@github-actions github-actions bot added the arkenv Changes to the `arkenv` npm package. label Sep 14, 2025
- Introduced `arkdark` as a new dependency in `pnpm-lock.yaml` for improved functionality.
- Updated `index.ts` to simplify the import of `arkenv`.
- Enhanced `source.config.ts` to utilize `arkdark` package.json for better documentation integration.
- Added CSS styles for Twoslash code blocks to improve user experience.
- Removed outdated `type-function.mdx` documentation file to streamline content.
- Added `@fumadocs/mdx-remote` and `shiki` as new dependencies in `package.json` for improved documentation features.
- Updated `pnpm-lock.yaml` to reflect the new versions and peer dependencies.
- Enhanced `next.config.ts` to include `ts-morph` in `serverExternalPackages` for better server-side handling.
- Modified layout component to include a smooth scroll behavior attribute for improved user experience.
@github-actions github-actions bot added @arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv tests This issue or PR is about adding, removing or changing tests labels Sep 14, 2025
…arity

- Changed code block language from `typescript` to `ts` in multiple documentation files for uniformity.
- Added a newline at the end of the `examples.mdx` file to adhere to formatting standards.
- Updated code block titles and formatting in `quickstart.mdx` and `environment-configuration.mdx` for improved readability.
- Standardized section headings to follow consistent capitalization rules across the documentation.
- Added example code for environment variable validation in `quickstart.mdx` to illustrate usage of `arkenv` more effectively.
- Changed the type definition of "ALLOWED_ORIGINS" from an array to a string array for clarity and correctness in environment variable configuration.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/www/content/docs/integrations/import-guide.mdx (1)

7-14: Guide update LGTM — update internal links to new path

apps/www/content/docs/quickstart.mdx still links to /docs/guides/import-options; change both occurrences to /docs/integrations/import-guide (lines 57, 129).

apps/www/content/docs/quickstart.mdx (1)

37-54: Standardize Twoslash fences to ts and update moved import-options link

  • Replace occurrences of "typescript" twoslash fences with "ts" in:

    • apps/www/content/docs/quickstart.mdx — line 101
    • apps/www/content/docs/guides/environment-configuration.mdx — lines 179, 201, 227
  • Update links in apps/www/content/docs/quickstart.mdx (lines 57, 129) from "/docs/guides/import-options" to "/docs/integrations/import-guide" (target file: apps/www/content/docs/integrations/import-guide.mdx).

🧹 Nitpick comments (11)
apps/www/app/layout.tsx (1)

35-35: Remove unused data attribute or document its consumer.

data-scroll-behavior="smooth" has no effect by itself and we already set smooth scrolling via CSS (guarded by prefers-reduced-motion). If not read by any script, drop it.

Apply this diff:

-			data-scroll-behavior="smooth"
.changeset/some-bikes-film.md (1)

5-8: Clarify the patch note.

Consider mentioning that Twoslash docs/examples were aligned and that JSDoc now references ArkEnvError where applicable, for clearer release notes.

apps/www/package.json (1)

30-31: Ensure server-only usage for module hook deps.

import-in-the-middle and require-in-the-middle should never be included in client bundles. Confirm they’re imported only on the server (dynamic import or conditional paths) and excluded from client code.

If helpful, I can scan the repo for any client-side imports of these packages.

apps/www/app/styles/base.css (1)

25-36: Cap heights: consider making values configurable.

Hard-coded 400px/300px may be cramped on small screens and excessive on large. Suggest using CSS vars or clamp() so we can tune per theme/layout.

Example:

-pre.twoslash {
-  max-height: 400px;
+pre.twoslash {
+  --twoslash-max-h: 400px;
+  max-height: var(--twoslash-max-h);
   overflow-y: auto;
   overflow-x: auto;
 }
-.twoslash .twoslash-type-source {
-  max-height: 300px;
+.twoslash .twoslash-type-source {
+  --twoslash-src-max-h: 300px;
+  max-height: var(--twoslash-src-max-h);
   overflow-y: auto;
 }
apps/www/content/docs/quickstart.mdx (1)

101-112: Switch fence to ts for Twoslash.

Use ts to ensure Twoslash transforms always apply.

-```typescript title="database.ts" twoslash
+```ts title="database.ts" twoslash
apps/www/content/docs/guides/environment-configuration.mdx (1)

231-234: Clarify optional vs required semantics for defaults.

In ArkType DSL, providing a default (= false) makes the key effectively optional even without ?. If you intend them optional, add ?; if required, remove the defaults. Pick one to avoid confusion.

Option A (optional via ? + default):

-  "ENABLE_BETA_FEATURES": 'boolean = false',
-  "MAINTENANCE_MODE": 'boolean = false',
-  "ALLOWED_ORIGINS": 'string[]'
+  "ENABLE_BETA_FEATURES?": 'boolean = false',
+  "MAINTENANCE_MODE?": 'boolean = false',
+  "ALLOWED_ORIGINS?": 'string[]'

Option B (required, no defaults):

-  "ENABLE_BETA_FEATURES": 'boolean = false',
-  "MAINTENANCE_MODE": 'boolean = false',
+  "ENABLE_BETA_FEATURES": 'boolean',
+  "MAINTENANCE_MODE": 'boolean',
   "ALLOWED_ORIGINS": 'string[]'
.changeset/all-ghosts-worry.md (1)

5-11: Include the default export alias in the changeset.

The package now also adds a default export alias arkenv; document it for consumers.

-Export `ArkEnvError`
+Export `ArkEnvError` and add default export alias `arkenv`
@@
 You can now import `ArkEnvError` from `arkenv`:
@@
 import { ArkEnvError } from "arkenv";

+And use the default export alias:
+
+ts +import arkenv from "arkenv"; +


</blockquote></details>
<details>
<summary>packages/vite-plugin/src/index.test.ts (1)</summary><blockquote>

`103-121`: **Strengthen assertions in the config‑hook test.**

Add a call‑count assertion to catch accidental multiple invocations.


```diff
-        }
-
-        expect(mockCreateEnv).toHaveBeenCalledWith(
+        }
+
+        expect(mockCreateEnv).toHaveBeenCalledTimes(1);
+        expect(mockCreateEnv).toHaveBeenCalledWith(
           { VITE_TEST: "string" },
           expect.any(Object),
         );

Optional: add a failure‑path test by making mockCreateEnv throw and asserting the hook surfaces the error via this.error or by throwing—depending on plugin behavior.

apps/www/source.config.ts (3)

41-44: Avoid config ambiguity: define explicitTrigger in one place

You set explicitTrigger: false in options but override to true at callsite. Drop the first to avoid confusion.

-const arktypeTwoslashOptions = {
-  explicitTrigger: false,
+const arktypeTwoslashOptions = {
   langs: ["ts", "js"],
   twoslashOptions: {

Also applies to: 171-175


95-99: Narrow the “ any” replacement to avoid false positives

Bound the replacement to common TS contexts to avoid altering arbitrary prose fragments.

-          node.text = node.text.replaceAll(" any", " ...");
+          node.text = node.text.replaceAll(/([:=]\s*)any\b/gu, "$1...");

8-9: Reuse the FS types cache

Instantiate once to avoid redundant cache objects during config eval.

 import { createFileSystemTypesCache } from "fumadocs-twoslash/cache-fs";
+const typesCache = createFileSystemTypesCache();

 ...
-        transformerTwoslash({
+        transformerTwoslash({
           ...arktypeTwoslashOptions,
-          typesCache: createFileSystemTypesCache(),
+          typesCache,
           explicitTrigger: true,
         }),

Also applies to: 171-174

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16f02f1 and fa707c8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (19)
  • .changeset/all-ghosts-worry.md (1 hunks)
  • .changeset/some-bikes-film.md (1 hunks)
  • apps/playgrounds/node/index.ts (1 hunks)
  • apps/www/app/docs/[[...slug]]/page.tsx (2 hunks)
  • apps/www/app/globals.css (1 hunks)
  • apps/www/app/layout.tsx (1 hunks)
  • apps/www/app/styles/base.css (1 hunks)
  • apps/www/content/docs/examples.mdx (1 hunks)
  • apps/www/content/docs/guides/environment-configuration.mdx (10 hunks)
  • apps/www/content/docs/guides/type-function.mdx (0 hunks)
  • apps/www/content/docs/integrations/import-guide.mdx (1 hunks)
  • apps/www/content/docs/quickstart.mdx (2 hunks)
  • apps/www/next.config.ts (1 hunks)
  • apps/www/package.json (1 hunks)
  • apps/www/source.config.ts (1 hunks)
  • packages/arkenv/README.md (1 hunks)
  • packages/arkenv/src/create-env.ts (1 hunks)
  • packages/arkenv/src/index.ts (1 hunks)
  • packages/vite-plugin/src/index.test.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • apps/www/content/docs/guides/type-function.mdx
🧰 Additional context used
📓 Path-based instructions (2)
**/README.md

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Document environment requirements in README files

Files:

  • packages/arkenv/README.md
**/*.test.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.test.ts: Place tests alongside source files and use the .test.ts suffix (e.g., create-env.test.ts, types.test.ts, errors.test.ts, utils.test.ts)
Use Vitest's describe/it structure in tests
Test both success and failure cases for environment validation and utilities
Mock process.env to cover different environment scenarios in tests
In tests, save and restore process.env in setup/teardown (beforeEach/afterEach) to avoid leakage between cases
Verify both runtime behavior and TypeScript types in tests

Files:

  • packages/vite-plugin/src/index.test.ts
🧠 Learnings (4)
📚 Learning: 2025-09-12T06:23:45.454Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.454Z
Learning: Applies to **/*.test.ts : Mock process.env to cover different environment scenarios in tests

Applied to files:

  • packages/vite-plugin/src/index.test.ts
  • apps/www/content/docs/quickstart.mdx
📚 Learning: 2025-09-12T06:23:45.454Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.454Z
Learning: Applies to **/*.test.ts : In tests, save and restore process.env in setup/teardown (beforeEach/afterEach) to avoid leakage between cases

Applied to files:

  • packages/vite-plugin/src/index.test.ts
📚 Learning: 2025-09-12T06:23:45.454Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.454Z
Learning: Applies to **/*.test.ts : Test both success and failure cases for environment validation and utilities

Applied to files:

  • packages/vite-plugin/src/index.test.ts
  • apps/www/content/docs/guides/environment-configuration.mdx
📚 Learning: 2025-09-12T06:23:45.454Z
Learnt from: CR
PR: yamcodes/arkenv#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-12T06:23:45.454Z
Learning: Group related environment variables into logical schemas

Applied to files:

  • apps/www/content/docs/quickstart.mdx
🧬 Code graph analysis (2)
packages/arkenv/src/index.ts (1)
packages/arkenv/src/create-env.ts (1)
  • createEnv (16-29)
apps/www/next.config.ts (1)
apps/www/middleware.ts (1)
  • config (17-19)
🪛 ast-grep (0.38.6)
apps/www/source.config.ts

[warning] 132-132: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(transformation.matcher)
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)


[warning] 143-143: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\$${groupIndex}, "gu")
Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]
- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html

(regexp-from-variable)

🔇 Additional comments (14)
apps/www/content/docs/examples.mdx (1)

13-13: No-op content change is fine.

Trailing newline after is harmless and improves POSIX tooling compatibility.

packages/arkenv/README.md (1)

32-47: Good: enable Twoslash for the example.

This aligns the README with the docs site and keeps examples type-checked. Also, the README already documents environment requirements (TS ≥5.1; Node/Bun/Vite versions), satisfying our guideline for README files.

apps/playgrounds/node/index.ts (1)

4-4: LGTM: key reorder only.

No behavioral change; reads cleanly with NODE_ENV first.

apps/www/package.json (1)

28-29: Verify Twoslash/Shiki impact on bundle size.

Twoslash and Shiki can be heavy. Make sure they’re only used where needed (build/MDX processing or server) and not pulled into the default client path.

Also applies to: 38-42

apps/www/app/globals.css (1)

9-9: Import order: ensure our overrides win.

If twoslash.css defines overlapping rules, importing it after base.css may override our caps. Prefer importing twoslash.css before base.css so our utility overrides take precedence.

Apply this diff:

-@import "./styles/base.css";
-@import "fumadocs-twoslash/twoslash.css";
+@import "fumadocs-twoslash/twoslash.css";
+@import "./styles/base.css";
apps/www/content/docs/guides/environment-configuration.mdx (1)

179-193: Twoslash upgrade LGTM.

The validation snippet reads well and matches the library API.

packages/arkenv/src/create-env.ts (1)

14-15: JSDoc @throws phrasing LGTM.

The inline link to ArkEnvError improves discoverability without changing runtime.

apps/www/app/docs/[[...slug]]/page.tsx (2)

1-1: Twoslash UI import LGTM.

Importing the namespace keeps the MDX mapping tidy.


59-60: Good precedence: Twoslash spread after pre.

Spreading ...Twoslash last lets Twoslash override codeblock renderers as needed.

packages/vite-plugin/src/index.test.ts (1)

21-23: Typed mock extraction LGTM.

The cast yields proper IntelliSense on mockCreateEnv.

packages/arkenv/src/index.ts (2)

5-9: Default export alias documentation LGTM.

Clear JSDoc; keeps named exports intact.


14-14: Public error export LGTM.

Re‑exporting ArkEnvError aligns with docs and changeset (once updated).

apps/www/next.config.ts (1)

6-11: Typed split of Next and Sentry configs is clean

Good separation, correct satisfies assertions, and appropriate serverExternalPackages.

apps/www/source.config.ts (1)

165-177: MDX + Twoslash integration looks solid — arkdark verified

Theme mapping, transformer order, and cache wiring LGTM; apps/www/package.json lists arkdark at ^5.4.2.

- Modified the matcher configuration in `middleware.ts` to prevent routing for paths that include "monitoring", enhancing request handling.
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/www/middleware.ts (3)

18-19: Exclude /monitoring from middleware: LGTM; consider anchoring to avoid accidental over‑match.

This pattern will also skip routes like /monitoring-foo. If you intend to exclude only /monitoring and its subpaths, add a boundary.

-  matcher: "/((?!monitoring).*)",
+  matcher: "/((?!monitoring(?:/|$)).*)",

8-13: X-Frame-Options: ALLOW-FROM is obsolete; rely on frame-ancestors.

Modern browsers ignore ALLOW-FROM. Since you already set a strict frame-ancestors, drop XFO to avoid confusion and header conflicts.

   response.headers.set(
     "Content-Security-Policy",
     `frame-ancestors 'self' https://stackblitz.com https://*.stackblitz.com`,
   );
-  response.headers.set("X-Frame-Options", "ALLOW-FROM https://stackblitz.com");
+  // X-Frame-Options is deprecated and ALLOW-FROM is unsupported; CSP frame-ancestors covers this.
+  // If legacy browser support is unnecessary, omit X-Frame-Options entirely.

18-19: Optional: exclude static and API paths to reduce middleware overhead.

If these headers are only meaningful for HTML documents, consider excluding common non-HTML paths.

-  matcher: "/((?!monitoring).*)",
+  matcher: "/((?!api|_next/static|_next/image|favicon.ico|monitoring).*)",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa707c8 and 52ac9cc.

📒 Files selected for processing (1)
  • apps/www/middleware.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test-build

- Removed outdated styles for `pre.twoslash` and replaced them with a new class `.fd-twoslash-popover` to set a maximum height of 160px, enhancing the display of Twoslash code blocks.
- Added !important to the max-height property of the .fd-twoslash-popover class in base.css to ensure consistent display of Twoslash code blocks across different contexts.
- Changed the class name from `.fd-twoslash-popover` to `.twoslash .fd-scroll-component` in base.css to enhance the organization of Twoslash styles and maintain consistent maximum height settings for code blocks.
- Renamed the class from `.fd-scroll-component` to `.fd-scroll-container` in base.css to align with naming conventions and improve clarity in the Twoslash styling structure.
@yamcodes yamcodes merged commit 221f9ef into main Sep 14, 2025
8 checks passed
@yamcodes yamcodes deleted the ts-codeblock branch September 14, 2025 22:00
@github-actions github-actions bot mentioned this pull request Sep 14, 2025
yamcodes pushed a commit that referenced this pull request Sep 14, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## arkenv@0.7.1

### Patch Changes

- Export `ArkEnvError`
_[`#161`](#161)
[`221f9ef`](221f9ef)
[@yamcodes](https://github.com/yamcodes)_

    You can now import `ArkEnvError` from `arkenv`:

    ```ts
    import { ArkEnvError } from "arkenv";
    ```

- Improve JSDoc _[`#161`](#161)
[`221f9ef`](221f9ef)
[@yamcodes](https://github.com/yamcodes)_

    The JSDoc for `arkenv` and `createEnv` is now more descriptive.

## @arkenv/vite-plugin@0.0.11

### Patch Changes

<details><summary>Updated 1 dependency</summary>

<small>


[`221f9ef`](221f9ef)
[`221f9ef`](221f9ef)

</small>

-   `arkenv@0.7.1`

</details>

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Sep 23, 2025
yamcodes pushed a commit that referenced this pull request Nov 10, 2025
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| [arkenv](https://arkenv.js.org)
([source](https://redirect.github.com/yamcodes/arkenv)) | [`0.7.0` ->
`0.7.3`](https://renovatebot.com/diffs/npm/arkenv/0.7.0/0.7.3) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/arkenv/0.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/arkenv/0.7.0/0.7.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>yamcodes/arkenv (arkenv)</summary>

###
[`v0.7.3`](https://redirect.github.com/yamcodes/arkenv/releases/tag/arkenv%400.7.3)

[Compare
Source](https://redirect.github.com/yamcodes/arkenv/compare/arkenv@0.7.2...arkenv@0.7.3)

##### Patch Changes

- #### Automatic boolean string conversion
*[`#218`](https://redirect.github.com/yamcodes/arkenv/pull/218)
[`e554e2b`](https://redirect.github.com/yamcodes/arkenv/commit/e554e2b41aab1b8e29d873982ea587c069f4732d)
[@&#8203;yamcodes](https://redirect.github.com/yamcodes)*

The `boolean` type now accepts `"true"`/`"false"` strings from
environment variables and converts them to actual boolean values. This
also works with boolean defaults.

  Example:

  ```ts
  import arkenv from "arkenv";

  const env = arkenv({
    DEBUG: "boolean",
    ENABLE_FEATURE: "boolean = true",
  });

  console.log(env.DEBUG);
  console.log(env.ENABLE_FEATURE);
  ```

  Result:

  ```sh
  ❯ DEBUG=true npx tsx index.ts
  true
  true
  ```

###
[`v0.7.2`](https://redirect.github.com/yamcodes/arkenv/releases/tag/arkenv%400.7.2)

[Compare
Source](https://redirect.github.com/yamcodes/arkenv/compare/arkenv@0.7.1...arkenv@0.7.2)

##### Patch Changes

- #### Support array defaults using type().default() syntax
*[`#199`](https://redirect.github.com/yamcodes/arkenv/pull/199)
[`e50dba1`](https://redirect.github.com/yamcodes/arkenv/commit/e50dba1f19418f8fc007dc786df1172067e3d07c)
[@&#8203;copilot-swe-agent](https://redirect.github.com/apps/copilot-swe-agent)*

Fix to an issue where `type("array[]").default(() => [...])` syntax was
not accepted by `createEnv` due to overly restrictive type constraints.
The function now accepts any string-keyed record while still maintaining
type safety through ArkType's validation system.

  ##### New Features

- Array defaults to empty using `type("string[]").default(() => [])`
syntax
  - Support for complex array types with defaults
  - Mixed schemas combining string-based and type-based defaults

  ##### Example

  ```typescript
  const env = arkenv({
    ALLOWED_ORIGINS: type("string[]").default(() => ["localhost"]),
    FEATURE_FLAGS: type("string[]").default(() => []),
    PORT: "number.port",
  });
  ```

###
[`v0.7.1`](https://redirect.github.com/yamcodes/arkenv/releases/tag/arkenv%400.7.1)

[Compare
Source](https://redirect.github.com/yamcodes/arkenv/compare/arkenv@0.7.0...arkenv@0.7.1)

##### Patch Changes

- Export `ArkEnvError`
*[`#161`](https://redirect.github.com/yamcodes/arkenv/pull/161)
[`221f9ef`](https://redirect.github.com/yamcodes/arkenv/commit/221f9efdef65691b0c5155b12ec460404dddbe82)
[@&#8203;yamcodes](https://redirect.github.com/yamcodes)*

  You can now import `ArkEnvError` from `arkenv`:

  ```ts
  import { ArkEnvError } from "arkenv";
  ```

- Improve JSDoc
*[`#161`](https://redirect.github.com/yamcodes/arkenv/pull/161)
[`221f9ef`](https://redirect.github.com/yamcodes/arkenv/commit/221f9efdef65691b0c5155b12ec460404dddbe82)
[@&#8203;yamcodes](https://redirect.github.com/yamcodes)*

  The JSDoc for `arkenv` and `createEnv` is now more descriptive.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "on friday" (UTC), Automerge - At any
time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/yamcodes/arkenv).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNTkuNCIsInVwZGF0ZWRJblZlciI6IjQxLjE1OS40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@coderabbitai coderabbitai bot mentioned this pull request Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@arkenv/vite-plugin Issues or Pull Requests involving the Vite plugin for ArkEnv arkenv Changes to the `arkenv` npm package. docs Improvements or additions to documentation tests This issue or PR is about adding, removing or changing tests www Improvements or additions to arkenv.js.org

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant