Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
3327 commits
Select commit Hold shift + click to select a range
1e22f03
Downgrade react because of remirror getting this error:
freekh Jan 24, 2026
c517790
Update Flexsearch types after bump
freekh Jan 24, 2026
c93eaee
Fix scrollbar thumb color
freekh Jan 24, 2026
26d0fa4
Fix scrollarea in searchfield + styling
freekh Jan 24, 2026
9e8caf1
Cleanup classes in search
freekh Jan 24, 2026
6601785
Fix disabled attribute to be data-[disabled=true]
freekh Jan 24, 2026
23741c9
Fix search autofocus and positioning above trigger
freekh Jan 25, 2026
315f698
Filter instead of search
freekh Jan 25, 2026
8f2524b
Factor out SearchResultsList, fixed overflow issues
freekh Jan 25, 2026
913d906
Add more mockdata and stories
freekh Jan 25, 2026
3be54be
Use PreviewWithRender in search results
freekh Jan 25, 2026
94cadcf
Improve Search UX
freekh Jan 25, 2026
9f9fad1
Format
freekh Jan 25, 2026
cab158a
Lint
freekh Jan 25, 2026
3dfb412
Prettier
freekh Jan 25, 2026
87a727e
Use worker thread for searching
freekh Jan 25, 2026
970ab98
Merge pull request #407 from valbuild/ui-refactor-val-provider
freekh Jan 25, 2026
2663be4
Merge pull request #408 from valbuild/worker-search
freekh Jan 25, 2026
1ba7e6a
Terser logic...
freekh Jan 25, 2026
862f606
Fix warning where accordion goes from uncontrolled to controlled
freekh Jan 25, 2026
f99cef7
Replace old NavMenu with NavMenuV2
freekh Jan 25, 2026
b13b0a9
Prettier
freekh Jan 25, 2026
fec2c38
Make s.route default for anchor elements in richtext
freekh Jan 25, 2026
0de08e1
Add explicit example with anchor element in richtext
freekh Jan 25, 2026
b32271c
Fix richtext styling and add story for richtext editor
freekh Jan 25, 2026
4804daa
Fix missing caret color for richtext editor
freekh Jan 25, 2026
cfe5a5d
Fix double clicking, inserting links in richtext editor
freekh Jan 26, 2026
3d586f2
Fix overlay z-index
freekh Jan 26, 2026
e071cba
Make the popover anchor itself to link element...
freekh Jan 26, 2026
4b4456f
Fixed search on home page
freekh Jan 28, 2026
e070a5c
Fix router state not updating when navigating /val
freekh Jan 28, 2026
d36c4bb
Rm todo
freekh Jan 28, 2026
f217105
Fix resolve patch path so that ValPath resolves validation errors ins…
freekh Jan 28, 2026
1705654
Lint
freekh Jan 28, 2026
3a5b2b7
Prettier
freekh Jan 28, 2026
357bc64
Merge pull request #409 from valbuild/richtext-anchor-is-route
freekh Jan 28, 2026
4240d12
Changeset
freekh Jan 30, 2026
37fd68a
Remove unused package-lock
freekh Jan 30, 2026
4fc48fe
Remove beta from docs!
freekh Jan 30, 2026
4388daa
Exclude test packages from changeset
freekh Jan 30, 2026
fbe01df
Version Packages
github-actions[bot] Jan 30, 2026
a0f8cf1
Merge pull request #410 from valbuild/changeset-release/main
freekh Jan 30, 2026
d42e27a
Fix check that caused app UI to not load because of search.worker
freekh Jan 30, 2026
9025fd8
Version Packages
github-actions[bot] Jan 30, 2026
f9681a7
Merge pull request #411 from valbuild/changeset-release/main
freekh Jan 30, 2026
92f5b9a
Add externalUrlPage router
freekh Jan 30, 2026
66b768c
Rename externalUrlPage => externalPageRouter
freekh Jan 30, 2026
5047987
Add exclude_patches query param to /sources/~
freekh Jan 30, 2026
ade3ffc
Changeset
freekh Jan 31, 2026
b355ad6
Fix typecheck error
freekh Mar 21, 2026
b7fccf3
Format
freekh Mar 21, 2026
42b64a9
Fix example validation
freekh Mar 21, 2026
5e6b260
Fix ellipsis position in NavMenu
freekh Mar 21, 2026
d715579
Fix issues related to stale patch data since all-patches did not inva…
freekh Mar 21, 2026
d9e4a4d
Highlight fields that has changes
freekh Mar 21, 2026
32bdc25
Fix issue where undo all displays 1 patches before going to 0
freekh Mar 22, 2026
322a648
Refactor out get initials function
freekh Mar 24, 2026
be27e9a
Add list of authors of pending patches to fields
freekh Mar 24, 2026
9b54a80
Rm console.log
freekh Mar 24, 2026
14aff74
Align sizes to avoir layout shifts
freekh Mar 24, 2026
a7661f7
Add story for field patch authors
freekh Mar 24, 2026
acbc9fc
Fix scrolling for field patch authors
freekh Mar 24, 2026
6263c90
Make code editor font size 16 to avoid zoom on iOS - use nicer font
freekh Mar 24, 2026
0463ae6
Add field path authors to module
freekh Mar 24, 2026
6bf81cb
Remove borders on field (a bit much)
freekh Mar 24, 2026
1c18cca
Prettier
freekh Mar 25, 2026
83d6ecb
Fix border on patch authors
freekh Mar 25, 2026
b064266
Changeset
freekh Mar 25, 2026
df5c8a0
Fix dependency array
freekh Mar 25, 2026
7c11040
Re-render on all patches
freekh Mar 25, 2026
f8d7128
Fix cache error
freekh Mar 25, 2026
94761b7
Merge pull request #414 from valbuild/show-pending-patches
freekh Mar 25, 2026
1b9b3c3
Remove test jest command in build script
freekh Mar 22, 2026
0f47b1b
Show date next avatar to clearly indicate it reprensents changes
freekh Mar 25, 2026
b03f49d
Version Packages
github-actions[bot] Mar 25, 2026
d19d004
Merge pull request #412 from valbuild/changeset-release/main
freekh Mar 25, 2026
62a30de
Fix broken theme
freekh Mar 30, 2026
6df9922
Fix broken mutation on frozen containers
freekh Mar 30, 2026
45107ae
Show error in overlay instead of infinite loading on errors
freekh Mar 30, 2026
95de8bf
Fix broken link preview url
freekh Mar 31, 2026
71714b4
Improve search results
freekh Mar 31, 2026
222431d
Improve message in search
freekh Mar 31, 2026
f5a0c29
Fix validation for string
freekh Mar 31, 2026
71529af
Update changed field author component
freekh Apr 1, 2026
8473ac7
Format
freekh Apr 1, 2026
a87a3ed
Stable sort deployments by creation date before rendering
freekh Apr 1, 2026
8bb3f67
Add base schema for files and images
freekh Feb 4, 2026
e3884fe
Add file gallery component
freekh Feb 4, 2026
f01ed12
Update gallery components
freekh Feb 5, 2026
0a0236f
Enrich c.image and c.file with metadata from s.images and s.files
freekh Feb 7, 2026
0cc9c7f
Support for enriched metadata for remote as well
freekh Feb 7, 2026
379a9b1
Add agent rules
freekh Feb 13, 2026
6fee4a7
Align types after adding s.files and s.images
freekh Feb 13, 2026
9e12901
Fix minor issue related to new files / images
freekh Feb 20, 2026
fb86693
Add media picker, gallery components
freekh Feb 23, 2026
91bf2eb
Fix example
freekh Feb 23, 2026
2b4dcd6
Refactor s.files and s.images to use RecordSchema
freekh Feb 23, 2026
e9dc181
Align types after refactor of Internal.getSource
freekh Feb 23, 2026
de4d791
Fix missing moduleMetadata when calling nullable
freekh Feb 24, 2026
75fa30b
Update val.modules with media.val
freekh Feb 24, 2026
df1db47
Upload images / files to referenced modules
freekh Feb 25, 2026
5fa6d4e
Show a clear error if referenced module is missing in val.modules
freekh Feb 25, 2026
ecbb7ee
Limit the amount of s.file s.image referenced modules
freekh Feb 26, 2026
6e25516
Use accept if s.file / s.image is referenced module
freekh Feb 26, 2026
48ba715
Refactor file and image schemas to use referencedModule instead of mo…
freekh Feb 27, 2026
a0259ae
Add useFilePatchIds hook and integrate it into FileField and ImageFie…
freekh Feb 27, 2026
b5e6c65
Fix urls in media picker used in ImageField and FileField
freekh Feb 27, 2026
10de1e6
Fix open file properties in file gallery
freekh Feb 28, 2026
946c15c
Fix file module gallery
freekh Mar 1, 2026
5a64ba3
Update file gallery, image / file field
freekh Mar 4, 2026
3da79a8
Refactor keys of and referenced files
freekh Mar 5, 2026
f826b41
Use referenced files in FilePropertiesModal
freekh Mar 5, 2026
7e16bb1
Show tooltip if delete file is disabled
freekh Mar 5, 2026
db94dc2
Remove unsightly border in explorer
freekh Mar 5, 2026
f8b40a0
Improve validation testability
freekh Mar 7, 2026
1da47d0
Implement remote val for cli validate
freekh Mar 7, 2026
cc143be
Add runValidation test with validation error
freekh Mar 9, 2026
19658d7
Add runValidation test with image with fix
freekh Mar 9, 2026
f9aa948
Add fixable errors in run validation
freekh Mar 10, 2026
4c439d9
Add basic gallery run validation tests
freekh Mar 10, 2026
e4d32ec
Add second test gallery
freekh Mar 10, 2026
74f9690
Fail if s.files / s.images directory has files that are not tracked
freekh Mar 10, 2026
905ec99
Add validation tests for galleries with missing tracked files and inc…
freekh Mar 12, 2026
7464f45
Add test to remove missing tracked file entry from gallery when fix i…
freekh Mar 12, 2026
f6813fd
Add fixes for media gallery to serialization
freekh Apr 1, 2026
7a70b5c
Handle images and files check-unique-folder and check-all-files...
freekh Apr 2, 2026
ba18067
Improve UI of nav menu
freekh Apr 2, 2026
85d9da1
Fix site map chevron not opening if page had children
freekh Apr 2, 2026
ef4431c
Nicer look - remove bg on sitemap section if selected
freekh Apr 2, 2026
0a756d5
Fix routing to children inside the FileGallery
freekh Apr 2, 2026
6f63fe1
Increase size of grid view items
freekh Apr 2, 2026
2c432e2
Add author patching support to FileGallery and ModuleGallery components
freekh Apr 11, 2026
3a16dc4
Add FieldPatchAuthors component to display author patches in FileProp…
freekh Apr 11, 2026
87c66b2
Make patch_id reserved (used by media gallery atm)
freekh Apr 12, 2026
7c7e37d
Rm console.log
freekh Apr 12, 2026
3c77782
Fix broken remote for module gallery images
freekh Apr 12, 2026
30d35d9
Improve error message
freekh Apr 12, 2026
3c94a19
Minor perf improvement (avoid reg ex)
freekh Apr 12, 2026
699978e
Fix module gallery remote files
freekh Apr 12, 2026
556641e
Add progress bar to upload
freekh Apr 12, 2026
96bfe33
Drag and Drop support for module gallery
freekh Apr 13, 2026
edc35b0
Fix broken fg-error-secondary color
freekh Apr 13, 2026
d0aba87
Prettier
freekh Apr 15, 2026
f568237
Lint
freekh Apr 15, 2026
43a16a4
Fix missing prop
freekh Apr 15, 2026
3ef414d
Changeset
freekh Apr 15, 2026
d7583c4
Fix broken tests (after adding check-unique-folder / check-all-files)
freekh Apr 15, 2026
e8f1b96
Rm console.log
freekh Apr 15, 2026
f442aba
Fix broken tests (after adding check-unique-folder / check-all-files)
freekh Apr 15, 2026
073647b
Prettier
freekh Apr 15, 2026
41a1d65
Fix false-positive path boundary check in media gallery validation
freekh Apr 15, 2026
7b7a570
Remove debug console.log from removeFromNode
freekh Apr 15, 2026
c8c6684
Guard GalleryUploadTarget against empty modulePaths
freekh Apr 15, 2026
7b224dd
Fix FileGallery index lookup and modal state desyncs
freekh Apr 15, 2026
f5a161d
Replace as any cast with typed assertion in injectMetadataIntoSource
freekh Apr 15, 2026
bf381fc
Fix falsy-value skip and Json type mismatch in traverseSchemas
freekh Apr 15, 2026
591865c
Restore visible fg-error-secondary colors in light theme
freekh Apr 15, 2026
f465700
Merge pull request #413 from valbuild/files-gallery
freekh Apr 15, 2026
22798d7
Version Packages
github-actions[bot] Apr 15, 2026
a736667
Merge pull request #416 from valbuild/changeset-release/main
freekh Apr 16, 2026
b56a905
Add AI Chat component
freekh Mar 10, 2026
1d51ea5
Use actual web socket for messages
freekh Mar 10, 2026
f4cf358
Fix AI message receptions
freekh Mar 15, 2026
b2e6559
Fix broken classes in ai chat
freekh Mar 15, 2026
404eb16
Update ai chat height, fix connected status
freekh Mar 15, 2026
c75a33f
Add tool support
freekh Mar 15, 2026
789114c
Add WIP search AI tool
freekh Mar 17, 2026
6c7d4c0
Add error handling for AI messages in useAI and define AIErrorMessage…
freekh Apr 16, 2026
2b58991
Refactor message sending logic to return success status and handle er…
freekh Apr 16, 2026
93c0bd6
Typecheck
freekh Apr 16, 2026
59e3b73
Add validation tool
freekh Apr 16, 2026
70ba771
Typecheck
freekh Apr 16, 2026
1c69e6d
Add create patch tool
freekh Apr 16, 2026
11d2db9
External sites instead of External Pages
freekh Apr 16, 2026
278f64f
Implement AI chat functionality in DraftChanges and Layout components
freekh Apr 16, 2026
4f426ce
Add 'get_source' tool and update WebSocket stat interval
freekh Apr 16, 2026
6024a1a
Update CREATE_PATCH_TOOL description for RFC 6902 format clarification
freekh Apr 16, 2026
35d19a8
Improve system context and patch context
freekh Apr 16, 2026
259a7c0
AI Chat is now on right hand side
freekh Apr 16, 2026
38cc861
Add session and connection IDs for improved tracking in useAI and use…
freekh Apr 16, 2026
a7c19b0
Add tool activity tracking to AIChat and useAI hooks
freekh Apr 16, 2026
b572a03
Add "New Chat" functionality to AIChat and integrate session manageme…
freekh Apr 16, 2026
c04e93a
Enhance search functionality with pagination support and total result…
freekh Apr 16, 2026
15d27dc
Add navigate_to tool for user navigation in AIChat
freekh Apr 16, 2026
52f3606
Refactor DraftChanges and ToolsMenu components to remove loadingStatu…
freekh Apr 16, 2026
9552f5e
Add new tools for user information retrieval in useAI hook and update…
freekh Apr 16, 2026
820be87
Enhance navigation functionality in useAI hook by resolving source pa…
freekh Apr 16, 2026
decf4a7
Add new tools for retrieving patches and current date/time in useAI hook
freekh Apr 16, 2026
93af0e7
Add a way to revert changes (useful in particular for AI changes)
freekh Apr 17, 2026
44c3498
Add session management features to AIChat and ToolsMenu components
freekh Apr 17, 2026
d7b3928
Coerce AI to try to fix validation errors
freekh Apr 17, 2026
7045fc9
Refactor BreadcrumbItem class assignment for dynamic max-width handling
freekh Apr 17, 2026
be5c3fe
Add sessionId handling across multiple components and update TypeScri…
freekh Apr 22, 2026
0fc917c
Add AI Chat component to ValOverlay and manage chat state
freekh Apr 22, 2026
82aeb35
Add missing session id
freekh Apr 22, 2026
930a35f
Implement getSourcePathFromRoute function and integrate with AI tools
freekh Apr 22, 2026
9891430
Fix deprecations in tsconfig
freekh Apr 22, 2026
6a2a751
Refactor AI tools: rename and update context retrieval, enhance getSo…
freekh Apr 23, 2026
984521c
Use AI agents instead of direct prompts...
freekh Apr 23, 2026
c71ad8f
refactor: remove WebSocket message handling from useAISearch and useA…
freekh Apr 23, 2026
df2d5ba
Fix both richtext schema and sidebar drag (accidentally added together)
freekh Apr 23, 2026
0132464
Give AI the chance to validate keys and routes (skip all other types)
freekh Apr 23, 2026
e7c43e1
Fix broken test
freekh Apr 23, 2026
ce0754e
Make sure we do not forget to add fixes to blocking validation errors…
freekh Apr 23, 2026
54fa572
Add option to revert last change in error handling component
freekh Apr 23, 2026
cfd529b
Avoid Remirror throwing on empty nodes
freekh Apr 23, 2026
e81ab3c
Avoid errors when AI (for example) creates nodes insides of richtext
freekh Apr 23, 2026
3ae2c9a
Enhance error handling in AIChat and useAI components to include erro…
freekh Apr 24, 2026
80370ae
Remove unnecessary whitespace and debug log in useStatus function
freekh Apr 24, 2026
eb52fe9
Remove unused configuration variable from ChatWindow component
freekh Apr 24, 2026
75f2041
Remove debug logs from assistant message handling in AIChat component
freekh Apr 24, 2026
f57b77c
Add AI chat configuration with suggestions, title, and description
freekh Apr 24, 2026
9b3d159
Implement session restoration feature to load the most recent session…
freekh Apr 24, 2026
ed6e51e
Add optional 'disabled' property to chat configuration and update rel…
freekh Apr 24, 2026
eba3c2b
Remove session restoration logic from ChatWindow component
freekh Apr 24, 2026
0e6b50d
Show search in home again
freekh Apr 24, 2026
b1130ba
Minor context / tool updates
freekh Apr 24, 2026
2bbbe89
Make ai chat opt-in only and mark it as experimental
freekh Apr 24, 2026
63fabb7
Make ai chat work in fs mode as well
freekh Apr 24, 2026
8a40eb8
Use PAT to identify user in fs mode
freekh Apr 24, 2026
6235f43
Do not show user icon in fs mode
freekh Apr 24, 2026
eb6867f
Auto-fixed lint and format errors
freekh Apr 24, 2026
b7f72ca
Changeset
freekh Apr 27, 2026
9282325
Hide user icon at bottom of nav menu unless http mode
freekh Apr 27, 2026
72546a5
Merge pull request #417 from valbuild/ai-v0
freekh Apr 27, 2026
39fddb9
Version Packages
github-actions[bot] Apr 27, 2026
c559de9
Merge pull request #418 from valbuild/changeset-release/main
freekh Apr 27, 2026
b8ea6d9
Add file upload functionality to AIChat component and related hooks
freekh Apr 29, 2026
132a65c
Make the AI chat not disappear on lost connection after it has connected
freekh Apr 29, 2026
338bc49
Enhance AI message handling to support text and image content types
freekh Apr 29, 2026
42936db
Add AI session image to patch file functionality with API and UI inte…
freekh Apr 29, 2026
16c4ad9
Refactor AI session image handling to include metadata in patch file …
freekh May 9, 2026
6bfd510
Refactor async execution in useAI hook to improve readability and err…
freekh May 9, 2026
4669a56
Enhance AI session image handling by adding metadata support and impr…
freekh May 9, 2026
d112705
Refactor image conversion tools and patch building
freekh May 9, 2026
fc1ad76
Add functionality to remove image entries from gallery with correspon…
freekh May 9, 2026
dda112d
feat: implement session key expansion for image and file patches
freekh May 9, 2026
731ccf1
feat: update AI session image handling to support multiple files and …
freekh May 9, 2026
473c219
fix: update error status codes for project configuration and authenti…
freekh May 9, 2026
d049c97
feat: add tsx as a devDependency for improved TypeScript support
freekh May 9, 2026
c9f0ebc
feat: enhance API request handling with query parameters and improved…
freekh May 9, 2026
ac608cf
feat: add authentication error handling and update AIChat component t…
freekh May 9, 2026
60f2392
Fix fs / local AI image uploads
freekh May 12, 2026
6d89afe
Fix local AI images
freekh May 13, 2026
3187fd3
Fix missing deserialize options
freekh May 13, 2026
0cb9657
Changeset
freekh May 13, 2026
8033d6d
Merge pull request #420 from valbuild/ai-v1
freekh May 13, 2026
31c69af
Version Packages
github-actions[bot] May 13, 2026
0e8beb1
Merge pull request #421 from valbuild/changeset-release/main
freekh May 13, 2026
15bd779
Hide `typescript` import from consumer bundlers
freekh May 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
204 changes: 204 additions & 0 deletions .agent/rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
# Val Codebase Instructions

Instructions for AI assistants working with the Val content management system codebase.

## General rules

1. Never add @ts-expect-error unless explicitly being allowed to do so
2. Never use as any unless explicitly being allowed to do so
3. Ask if you need to use type assertions (`as Something`) - we try to avoid those

## Type System Architecture

### Core Type Hierarchy

Val has a dual type system: **Source** types define data shape, **Selector** types is the user facing types.

```
Source (data) → Selector (access)
─────────────────────────────────────────────
ImageSource → ImageSelector
FileSource<M> → FileSelector<M>
RemoteSource<M> → GenericSelector
RichTextSource<O> → RichTextSelector<O>
SourceObject → ObjectSelector<T>
SourceArray → ArraySelector<T>
string/number/boolean → StringSelector/NumberSelector/BooleanSelector
```

### Key Type Definitions

**Source** (`packages/core/src/source/index.ts`):

```typescript
export type Source =
| SourcePrimitive // string | number | boolean | null
| SourceObject // { [key: string]: Source }
| SourceArray // readonly Source[]
| RemoteSource
| FileSource
| ImageSource
| RichTextSource<RichTextOptions>;
```

**SelectorSource** (`packages/core/src/selector/index.ts`):

```typescript
export type SelectorSource =
| SourcePrimitive
| undefined
| readonly SelectorSource[]
| { [key: string]: SelectorSource }
| ImageSource
| FileSource
| RemoteSource
| RichTextSource<AllRichTextOptions>
| GenericSelector<Source>;
```

**GenericSelector** (`packages/core/src/selector/index.ts`):

```typescript
class GenericSelector<T extends Source> {
[GetSource]: T; // The actual source value
[GetSchema]: Schema<T> | undefined; // Schema for validation
[Path]: SourcePath | undefined; // Path in the module tree
[ValError]: Error | undefined; // Type errors
}
```

### CRITICAL: Adding New Source Types

When adding a new source type, it **MUST** be added to BOTH unions:

1. `Source` in `packages/core/src/source/index.ts`
2. `SelectorSource` in `packages/core/src/selector/index.ts`

Additionally: 3. Create selector type in `packages/core/src/selector/{name}.ts` 4. Add mapping in `Selector<T>` conditional type in `packages/core/src/selector/index.ts`

### FORBIDDEN: Type Intersection Hacks

**NEVER** use type intersections (`&`) to force a type to satisfy constraints:

```typescript
// ❌ WRONG - This is a hack that hides the real problem
export type RichTextSelector<O> = GenericSelector<RichTextSource<O> & Source>;

// ✅ CORRECT - Add missing types to SelectorSource union
export type SelectorSource =
| ...existing types...
| ImageSource // Add missing type here
```

If you see `Type 'X' does not satisfy the constraint 'Source'`, the fix is almost always adding a type to `SelectorSource`, NOT using intersections.

## Schema System

### Schema-Source Relationship

Each Schema class validates and types its corresponding Source type:

| Schema | Source | Factory |
| ------------------- | ------------------- | --------------------- |
| `ImageSchema<T>` | `ImageSource` | `s.image()` |
| `FileSchema<T>` | `FileSource` | `s.file()` |
| `RichTextSchema<O>` | `RichTextSource<O>` | `s.richtext(options)` |
| `ObjectSchema<T>` | `SourceObject` | `s.object({...})` |
| `ArraySchema<T>` | `SourceArray` | `s.array(schema)` |

## Module System

### c.define() Pattern

```typescript
c.define(
"/content/page.val.ts", // Module path
s.object({...}), // Schema
{ ... } // Source data matching schema
)
```

### Source Constructors

```typescript
c.image("/public/val/logo.png", {
width: 100,
height: 100,
mimeType: "image/png",
});
c.file("/public/val/doc.pdf", { mimeType: "application/pdf" });
c.remote("https://...", { mimeType: "image/jpeg" });
```

## UI Architecture

### Shadow DOM Isolation

The Val UI runs inside a Shadow DOM for CSS/JS isolation from the host page:

```typescript
// packages/ui/spa/components/ShadowRoot.tsx
const root = node.attachShadow({ mode: "open" });
// ID: "val-shadow-root"
```

**Implications:**

- CSS must target `:host` (not `:root`) for shadow DOM styles
- External stylesheets must be loaded inside the shadow root
- `document.querySelector` won't find elements inside shadow DOM
- Use `shadowRoot.querySelector` or React refs instead

### CSS Architecture

```css
/* packages/ui/spa/index.css */
@layer base {
:host, /* Shadow DOM */
:root {
/* Regular DOM fallback */
--background: ...;
--foreground: ...;
}
}
```

- Dark mode: `[data-mode="dark"]` selector
- CSS loaded via `/api/val/static/{VERSION}/spa/index.css`
- Event `val-css-loaded` dispatched when styles are ready

### Tailwind Configuration

```javascript
// packages/ui/tailwind.config.js
darkMode: ["class", '[data-mode="dark"]'];
```

Custom color tokens map to CSS variables (e.g., `bg-background` → `var(--background)`).

## Testing

Run tests from root dir with:

```bash
pnpm test # All tests
pnpm test packages/core/src/... # Specific test file
pnpm run -r typecheck # Type checking
pnpm lint
pnpm format
```

### Test rules

1. Never "fix" an issue by changing the test file
2. Prefer to define test data in a type-safe manner using `s` and `c` from `initVal`. Search for examples.

## Common Fixes

### "Type 'X' does not satisfy constraint 'Source'"

→ Add the type to `SelectorSource` union in `packages/core/src/selector/index.ts`

### "Property 'X' does not exist on type 'never'"

→ Check if all variants are handled in conditional types (especially in `ImageNode`, `RichTextSource`)
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": false,
"commit": false,
"fixed": [],
"linked": [["@valbuild/*"]],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["example-*", "val-test-*"]
}
5 changes: 5 additions & 0 deletions .changeset/typescript-bundler-opaque.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@valbuild/server": patch
---

Make the internal `typescript` import bundler-opaque (via `node:module`'s `createRequire`). This prevents webpack and Turbopack from tracing into TypeScript's `lib/typescript.js` and emitting "Can't resolve 'source-map-support'" warnings when consumers build Next.js apps that depend on `@valbuild/server` (directly or via `@valbuild/next`). No runtime or API changes.
1 change: 1 addition & 0 deletions .claude/CLAUDE.md
1 change: 1 addition & 0 deletions .cursor/rules/val-rules.md
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
94 changes: 94 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Check
on: push
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
format:
name: Check format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run format
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run build
build-next:
name: Build Next.js example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run build
working-directory: examples/next
typecheck:
name: Typecheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm run -r typecheck
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
- uses: actions/setup-node@v3
with:
node-version-file: ".nvmrc"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- run: pnpm test
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
id-token: write # Required for OIDC
contents: write # Required for changesets to commit/push
pull-requests: write # Required for changesets to create version PRs
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
- uses: pnpm/action-setup@v2
with:
version: 10
- run: pnpm install --frozen-lockfile
- uses: changesets/action@v1
with:
publish: pnpm run release
version: pnpm run version-packages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_CONFIG_PROVENANCE: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ node_modules/
.next
dist
tsconfig.tsbuildinfo
.envrc
.tmp
.DS_Store
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tsconfig.tsbuildinfo
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v24
Loading
Loading