Skip to content

Commit e917e8c

Browse files
Copilothuangyiirene
andcommitted
Update documentation with correct package names
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent f926bbf commit e917e8c

5 files changed

Lines changed: 183 additions & 101 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@ This project is organized as a Monorepo:
172172

173173
| Package | Description |
174174
| --- | --- |
175-
| **`@object-ui/types`** | The protocol definitions. Pure TypeScript interfaces. |
176-
| **`@object-ui/core`** | The logic engine. Data scoping, validation, evaluation. |
177-
| **`@object-ui/react`** | The React framework adapter. |
175+
| **`@object-ui/core`** | Core logic, types, and validation. Zero React dependencies. |
176+
| **`@object-ui/react`** | The React framework adapter with SchemaRenderer. |
178177
| **`@object-ui/components`** | The standard UI library implementation (Shadcn + Tailwind). |
179-
| **`@object-ui/plugin-*`** | Lazy-loaded complex components (e.g., AG Grid, Monaco). |
178+
| **`@object-ui/designer`** | Visual schema editor for building UIs without code. |
180179

181180
---
182181

docs/api/core.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Core API
22

3-
The `@object-ui/core` package (also published as `@object-ui/protocol`) provides the foundational type definitions and schemas for Object UI.
3+
The `@object-ui/core` package provides the foundational type definitions, schemas, and core logic for Object UI.
4+
5+
This package is **framework-agnostic** with zero React dependencies, making it suitable for use in Node.js environments, build tools, or other frameworks.
46

57
## Installation
68

79
```bash
8-
npm install @object-ui/protocol
10+
npm install @object-ui/core
911
```
1012

1113
## Type Definitions
@@ -19,7 +21,7 @@ import type {
1921
FormSchema,
2022
ViewSchema,
2123
ComponentSchema
22-
} from '@object-ui/protocol'
24+
} from '@object-ui/core'
2325
```
2426

2527
### BaseSchema
@@ -82,7 +84,7 @@ interface InputSchema extends BaseSchema {
8284
### Using Zod
8385

8486
```typescript
85-
import { PageSchema } from '@object-ui/protocol'
87+
import { PageSchema } from '@object-ui/core'
8688
import { z } from 'zod'
8789

8890
const pageValidator = z.object({
@@ -100,18 +102,38 @@ const result = pageValidator.safeParse(mySchema)
100102
### Type Guards
101103

102104
```typescript
103-
import { isPageSchema, isFormSchema } from '@object-ui/protocol'
105+
import { isPageSchema, isFormSchema } from '@object-ui/core'
104106

105107
if (isPageSchema(schema)) {
106108
// TypeScript knows schema is PageSchema
107109
console.log(schema.title)
108110
}
109111
```
110112

111-
## API Reference
113+
## Component Registry
114+
115+
The core package provides a framework-agnostic component registry:
116+
117+
```typescript
118+
import { ComponentRegistry } from '@object-ui/core'
119+
120+
const registry = new ComponentRegistry()
121+
registry.register('button', buttonMetadata)
122+
```
112123

113-
Full API documentation coming soon.
124+
## Data Scope
125+
126+
Data scope management for expression evaluation:
127+
128+
```typescript
129+
import { DataScope } from '@object-ui/core'
130+
131+
const scope = new DataScope({ user: { name: 'John' } })
132+
const value = scope.get('user.name') // 'John'
133+
```
134+
135+
## API Reference
114136

115-
For now, see:
116-
- [GitHub Repository](https://github.com/objectql/objectui/tree/main/packages/protocol)
117-
- [TypeScript Definitions](https://github.com/objectql/objectui/blob/main/packages/protocol/src/types)
137+
For detailed API documentation, see:
138+
- [GitHub Repository](https://github.com/objectql/objectui/tree/main/packages/core)
139+
- [TypeScript Definitions](https://github.com/objectql/objectui/blob/main/packages/core/src/index.ts)

docs/guide/installation.md

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ Object UI is distributed as several packages:
1616

1717
| Package | Description | Required |
1818
|---------|-------------|----------|
19-
| `@object-ui/protocol` | Type definitions and schemas | Yes |
20-
| `@object-ui/renderer` | The core compiler that turns JSON into React | Yes |
21-
| `@object-ui/ui` | The visual component library (Shadcn extended) | Yes |
19+
| `@object-ui/core` | Core logic, types, and validation (Zero React dependencies) | Yes |
20+
| `@object-ui/react` | React bindings and SchemaRenderer component | Yes |
21+
| `@object-ui/components` | Standard UI library with Shadcn + Tailwind components | Yes |
2222
| `@object-ui/designer` | Visual schema editor and builder | Optional |
2323

2424
## Basic Installation
@@ -28,29 +28,17 @@ To get started, install the core packages:
2828
::: code-group
2929

3030
```bash [npm]
31-
npm install @object-ui/renderer @object-ui/ui @object-ui/protocol
31+
npm install @object-ui/react @object-ui/components
3232
```
3333

3434
```bash [pnpm]
35-
pnpm add @object-ui/renderer @object-ui/ui @object-ui/protocol
36-
```
37-
38-
```bash [yarn]
39-
yarn add @object-ui/renderer @object-ui/ui @object-ui/protocol
40-
```
41-
42-
:::bash [npm]
43-
npm install @object-ui/react @object-ui/components
35+
pnpm add @object-ui/react @object-ui/components
4436
```
4537

4638
```bash [yarn]
4739
yarn add @object-ui/react @object-ui/components
4840
```
4941

50-
```bash [pnpm]
51-
pnpm add @object-ui/react @object-ui/components
52-
```
53-
5442
:::
5543

5644
## Setup Steps
@@ -158,19 +146,19 @@ Create React App requires no special configuration.
158146
For TypeScript type definitions:
159147

160148
```bash
161-
npm install @object-ui/protocol
149+
npm install @object-ui/core
162150
```
163151

164152
```typescript
165-
import type { PageSchema, FormSchema } from '@object-ui/protocol'
153+
import type { PageSchema, FormSchema } from '@object-ui/core'
166154
```
167155

168-
### Engine
156+
### Designer
169157

170-
For advanced state management and data handling:
158+
For visual schema editing:
171159

172160
```bash
173-
npm install @object-ui/engine
161+
npm install @object-ui/designer
174162
```
175163

176164
## Verification

docs/spec/project-structure.md

Lines changed: 133 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,157 @@
1-
# AI-Driven Project Structure
1+
# Project Structure
22

3-
This document defines the directory structure designed to facilitate AI-driven development. The goal is to establish a deterministic 1:1 mapping between the ObjectQL specifications (in `docs/objectql`) and the source code.
3+
This document defines the current directory structure of Object UI, designed for clarity and AI-driven development.
44

55
## 1. Top-Level Structure (Monorepo)
66

77
We use a standard Monorepo structure managed by `pnpm`.
88

99
```
1010
/
11-
├── apps/ # End-user applications
12-
│ ├── design-studio/ # The visual designer (Next.js/Vite)
13-
│ └── docs/ # Documentation site
14-
├── packages/ # Shared libraries
15-
│ ├── protocol/ # (New) Pure Metadata Definitions & Types
16-
│ ├── engine/ # (New) The Core Logic (State, Data, Expressions)
17-
│ ├── ui/ # (New) The Atomic Component Library (Shadcn + Tailwind)
18-
│ └── renderer/ # (Renamed from react) The Schema->React Transformer
19-
├── docs/
20-
│ ├── objectql/ # The Source of Truth (Specs)
21-
│ └── spec/ # Technical Specs
11+
├── examples/ # Example applications
12+
│ ├── prototype/ # Main prototype/demo app
13+
│ └── designer-demo/ # Designer demonstration
14+
├── packages/ # Shared libraries
15+
│ ├── core/ # Core logic, types, and validation (Zero React)
16+
│ ├── react/ # React bindings and SchemaRenderer
17+
│ ├── components/ # Standard UI components (Shadcn + Tailwind)
18+
│ └── designer/ # Visual schema editor
19+
├── docs/ # Documentation site (VitePress)
20+
│ ├── .vitepress/ # VitePress configuration
21+
│ ├── guide/ # User guides
22+
│ ├── api/ # API documentation
23+
│ ├── protocol/ # Protocol specifications
24+
│ └── spec/ # Technical specifications
25+
└── .github/ # GitHub workflows and configurations
2226
```
2327

2428
## 2. Package Responsibilities
2529

26-
### `@object-ui/protocol` (was `core`)
27-
**Goal**: Define the "Language" of ObjectQL.
28-
**Mapping**: `docs/objectql/*.md``packages/protocol/src/*.ts`
30+
### `@object-ui/core`
31+
**Goal**: The "Brain" - Core logic with zero React dependencies.
32+
**Tech**: Pure TypeScript + Zod + Lodash
2933

30-
* `src/types/object.ts` (Defines ObjectConfig)
31-
* `src/types/field.ts` (Defines FieldConfig)
32-
* `src/types/view.ts` (Defines ViewConfig)
33-
* `src/types/page.ts` (Defines PageConfig)
34-
* `src/utils/validator.ts` (Zod schemas for runtime validation)
34+
**Contents**:
35+
- `src/types/` - TypeScript type definitions (schemas, components)
36+
- `src/registry/` - Component registry system
37+
- `src/data-scope/` - Data scope and expression evaluation
38+
- `src/validators/` - Zod validation schemas
3539

36-
### `@object-ui/engine` (was `react` internals)
37-
**Goal**: The "Brain". Headless logic for handling data.
40+
**Key Principle**: This package can run in Node.js or any JavaScript environment.
3841

39-
* `src/store/` (Zustand stores for Object data)
40-
* `src/data-source/` (React Query wrappers)
41-
* `src/expressions/` (Expression evaluator)
42-
* `src/context/` (DataScope implementation)
42+
### `@object-ui/react`
43+
**Goal**: The "Glue" - React bindings and renderer.
44+
**Tech**: React 18+ with Hooks
4345

44-
### `@object-ui/ui` (was `components`)
45-
**Goal**: The "Look". Dumb, stateless UI atoms.
46-
**Tech**: Radix UI + Tailwind + Shadcn.
47-
48-
* `src/primitives/` (Button, Input, Dialog)
49-
* `src/layout/` (Grid, Stack, Card)
46+
**Structure**:
47+
```
48+
src/
49+
├── SchemaRenderer.tsx # Main renderer component
50+
├── hooks/ # React hooks
51+
│ ├── useRenderer.ts
52+
│ ├── useDataScope.ts
53+
│ └── useRegistry.ts
54+
└── context/ # React Context providers
55+
├── RendererContext.tsx
56+
└── DataScopeContext.tsx
57+
```
5058

51-
### `@object-ui/renderer` (was `react` public)
52-
**Goal**: The "Compiler". Turns Metadata into UI.
53-
**Structure**: Strictly organized by Schema Type.
59+
### `@object-ui/components`
60+
**Goal**: The "Body" - Standard UI implementation.
61+
**Tech**: Shadcn UI + Radix UI + Tailwind CSS
5462

63+
**Structure**:
5564
```
5665
src/
57-
├── renderers/
58-
│ ├── page/
59-
│ │ ├── PageRenderer.tsx
60-
│ │ └── index.ts
61-
│ ├── object/
62-
│ │ ├── ObjectFormRenderer.tsx
63-
│ │ ├── ObjectTableRenderer.tsx
64-
│ │ └── ...
65-
│ ├── view/
66-
│ │ ├── ViewRenderer.tsx (Dispatcher)
67-
│ │ ├── ListView.tsx
68-
│ │ ├── KanbanView.tsx
69-
│ │ └── ...
70-
│ └── field/
71-
│ ├── FieldRenderer.tsx (Dispatcher)
72-
│ ├── StringField.tsx
73-
│ └── SelectField.tsx
74-
├── registry.ts # Maps types to renderers
75-
└── SchemaRenderer.tsx # Entry point
66+
├── ui/ # Base Shadcn components
67+
│ ├── button.tsx
68+
│ ├── input.tsx
69+
│ ├── select.tsx
70+
│ └── ...
71+
├── renderers/ # Object UI component renderers
72+
│ ├── basic/ # Basic components
73+
│ ├── form/ # Form components
74+
│ ├── layout/ # Layout components
75+
│ └── data-display/ # Data display components
76+
└── index.ts # Public exports
77+
```
78+
79+
### `@object-ui/designer`
80+
**Goal**: The "Tool" - Visual schema editor.
81+
**Tech**: React + Drag-and-Drop
82+
83+
**Contents**:
84+
- `src/Designer.tsx` - Main designer component
85+
- `src/Canvas.tsx` - Visual editing canvas
86+
- `src/ComponentPalette.tsx` - Component library browser
87+
- `src/PropertyPanel.tsx` - Property editor
88+
- `src/Toolbar.tsx` - Actions toolbar
89+
- `src/context/` - Designer state management
90+
91+
## 3. Development Workflow
92+
93+
### Adding a New Component
94+
95+
When implementing a new component:
96+
97+
1. **Define Types** in `packages/core/src/types/`
98+
```typescript
99+
export interface MyComponentSchema extends BaseSchema {
100+
type: 'my-component'
101+
// ... component-specific properties
102+
}
103+
```
104+
105+
2. **Create UI Component** in `packages/components/src/ui/` (if needed)
106+
```tsx
107+
// Base Shadcn component
108+
export function MyComponent({ ... }) { ... }
109+
```
110+
111+
3. **Create Renderer** in `packages/components/src/renderers/`
112+
```tsx
113+
export function MyComponentRenderer({ schema, ...props }) {
114+
return <MyComponent {...props} {...schema} />
115+
}
116+
```
117+
118+
4. **Register** in `packages/components/src/index.ts`
119+
```typescript
120+
registry.register('my-component', MyComponentRenderer)
121+
```
122+
123+
### Package Dependencies
124+
125+
```
126+
designer
127+
128+
components ──→ react ──→ core
129+
↓ ↓
130+
ui components types & logic
76131
```
77132

78-
## 3. Workflow for AI
133+
**Dependency Rules**:
134+
- `core`: NO dependencies on React or any UI framework
135+
- `react`: Depends on `core`, peer depends on React
136+
- `components`: Depends on `core` + `react` + Shadcn/Radix
137+
- `designer`: Depends on `components`
79138

80-
When asked to "Implement the View spec":
139+
## 4. File Naming Conventions
81140

82-
1. **Read** `docs/objectql/view.md`.
83-
2. **Define** `packages/protocol/src/types/view.ts`.
84-
3. **Create** `packages/renderer/src/renderers/view/ViewRenderer.tsx`.
85-
4. **Register** it in `packages/renderer/src/registry.ts`.
141+
- **Components**: PascalCase with `.tsx` extension (e.g., `Button.tsx`)
142+
- **Hooks**: camelCase starting with `use` (e.g., `useRenderer.ts`)
143+
- **Types**: PascalCase with `.ts` extension (e.g., `Schema.ts`)
144+
- **Utilities**: camelCase with `.ts` extension (e.g., `registry.ts`)
145+
146+
## 5. Import Aliases
147+
148+
When working within the monorepo, use workspace protocol:
149+
150+
```typescript
151+
// In packages/react
152+
import { BaseSchema } from '@object-ui/core'
153+
154+
// In packages/components
155+
import { SchemaRenderer } from '@object-ui/react'
156+
import type { ButtonSchema } from '@object-ui/core'
157+
```

0 commit comments

Comments
 (0)