Skip to content

Commit a8d1e89

Browse files
committed
second version after solid-ui-core introduced
1 parent aa1358b commit a8d1e89

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## What this is
6+
7+
`solid-ui` is a UI library for building Solid (decentralized web) applications. It provides HTML5 widgets that connect to Solid pods via RDF/LDP protocols. The library exposes a global `window.UI` object in the browser with modules for forms, chat, ACL management, and general widgets.
8+
9+
## Commands
10+
11+
```bash
12+
npm run build # Full build: clean → version → lib → types → dev → dist → storybook
13+
npm run build-lib # Babel transpile src/ → lib/
14+
npm run build-types # Generate TypeScript declarations
15+
npm run watch # Watch mode (Babel only)
16+
17+
npm run lint # ESLint src/**/*.{js,ts} and test/**/*.ts
18+
npm run lint-fix # ESLint with auto-fix
19+
20+
npm test # build-version + lint + jest (also runs pre-push hook)
21+
npm run jest # Jest only, no lint
22+
npm test test/unit/chat/infinite.test.ts # Single test file
23+
npm run coverage # Jest with coverage → coverage/lcov-report/index.html
24+
25+
npm run storybook # Storybook dev server on port 6006
26+
npm run doc # TypeDoc API docs → Documentation/api/
27+
```
28+
29+
Git hooks (Husky): pre-commit runs lint-staged; pre-push runs `npm test`.
30+
31+
## Architecture
32+
33+
**Entry point:** `src/index.ts` — exports the main `UI` object bundled for UMD (browser + CommonJS).
34+
35+
**Key modules:**
36+
37+
| Path | Role |
38+
|------|------|
39+
| `src/widgets/` | Core UI components: buttons, forms, `peoplePicker`, `multiSelect`, drag-and-drop |
40+
| `src/forms/` | Form rendering engine for the W3C UI vocabulary (`http://www.w3.org/ns/ui`) |
41+
| `src/chat/` | Chat UI: infinite message area, message tools, encryption |
42+
| `src/acl/` | ACL management: reading/writing WebACL resources, permission UI |
43+
| `src/login/` | Authentication flow (delegates to `solid-logic`) |
44+
| `src/utils/` | Helpers including `keyHelpers` (crypto/ACL utilities) |
45+
| `src/matrix/` | Matrix/spreadsheet views |
46+
| `src/table.js` | Table pane rendering |
47+
| `src/pad.ts` | Collaborative pad widget |
48+
| `src/icons/` | ~130 SVG icons |
49+
| `src/stories/` | Storybook stories |
50+
51+
**Data layer:** The library relies on `solid-logic` for the RDF store (`store`) and authentication (`authn`). RDF namespaces come from `solid-namespace`. Widgets read/write RDF data through `rdflib` quad-store APIs — no REST calls are made directly; all persistence goes through the store.
52+
53+
## solid-ui-core
54+
55+
Pure utility modules (namespaces, style, debug, logging, icons, key helpers) live in a separate package at `../solid-ui-core/` (repo: `github.com/solidos/solid-ui-core`). They are imported here as `solid-ui-core`.
56+
57+
**Local development:** After editing solid-ui-core, run `npm run build-lib` there, then tests here will pick up the changes via the npm link. The link is set up with `npm link solid-ui-core` from this directory.
58+
59+
**Critical:** `solid-logic` and `rdflib` must not exist inside `node_modules/solid-ui-core/node_modules/` — npm 7 sometimes auto-installs peer deps there, which creates duplicate store instances. Delete them if they appear.
60+
61+
**Jest mocking:** When mocking solid-ui-core modules in tests, use the package alias form:
62+
```ts
63+
jest.mock('solid-ui-core/utils/keyHelpers/otherHelpers', () => { ... })
64+
```
65+
Not the raw `node_modules/solid-ui-core/src/...ts` path — that never intercepts the compiled `require()` calls.
66+
67+
**Build outputs:**
68+
- `lib/` — Babel-transpiled CommonJS modules (npm consumers)
69+
- `dist/solid-ui.js` / `solid-ui.min.js` — UMD bundles (browser `<script>` tag)
70+
- Type declarations alongside `lib/`
71+
72+
## Testing
73+
74+
Tests live in `test/unit/`. Jest runs in a custom jsdom environment (`jest-environment-jsdom.js`) that patches `cuid2` compatibility. Setup file: `test/helpers/setup.ts`. Custom matchers: `test/custom-matchers/`.
75+
76+
TypeScript is transpiled by `ts-jest`. HTTP is mocked with `nock`. DOM testing uses Testing Library.
77+
78+
## Forms subsystem
79+
80+
The forms subsystem (`src/forms/`) implements the W3C UI vocabulary and deserves special attention — see `Documentation/FormsReadme.md` for its data model and field types. Form fields are defined by RDF triples; the renderer walks the graph to produce HTML.
81+
82+
## Version
83+
84+
Version is auto-generated into `src/versionInfo.ts` by `timestamp.sh` as part of the build. Do not edit that file manually.

0 commit comments

Comments
 (0)