Skip to content

Commit 8685fb9

Browse files
committed
add copilot instructions
1 parent 30b758c commit 8685fb9

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Shadow Objects Framework
2+
3+
The **Shadow Objects Framework** is a library designed to decouple business logic and state management from the UI rendering layer. It runs application logic "in the dark" (e.g., in a web worker), mirroring the view hierarchy of the application.
4+
5+
## Core Concepts
6+
7+
### Entities
8+
An **Entity** is the fundamental unit representing a node in the hierarchy, mirroring a view component (like a DOM element or Web Component). Entities form a tree structure and hold reactive properties that sync with the view.
9+
10+
### Shadow Objects
11+
A **Shadow Object** is a functional unit of logic attached to an Entity. It contains state, effects, and business logic. Shadow Objects are automatically created and destroyed based on the Entity's lifecycle and configuration.
12+
13+
### The Kernel
14+
The **Kernel** manages the lifecycle of Entities and Shadow Objects. It handles the creation, destruction, and hierarchy updates, and orchestrates communication between the View (UI) and the Shadow World.
15+
16+
### The Registry
17+
The **Registry** maps **Tokens** (strings identifying logic) to **Shadow Object Constructors**. It defines how Entities are associated with specific logic and supports routing rules.
18+
19+
## API Overview
20+
21+
Shadow Objects are defined as functions or classes receiving a `ShadowObjectParams` object. Key methods include:
22+
23+
- **`useProperty(name)`**: Read a reactive property from the View.
24+
- **`useContext(name)`**: Consume a context value provided by a parent Entity.
25+
- **`provideContext(name, value)`**: Provide a context value to descendant Entities.
26+
- **`useResource(factory, cleanup)`**: Manage resources with automatic cleanup.
27+
- **`createEffect(callback)`**: Run side effects when signals change.
28+
- **`on(event, callback)`**: Listen for events on the Entity.
29+
30+
## Project Structure
31+
32+
- Main library: `@packages/shadow-objects/`
33+
- Deployment package: `@spearwolf/shadow-objects`
34+
35+
## Documentation Guidelines
36+
37+
When generating or modifying documentation:
38+
- Always use **English**.
39+
- Always use **Markdown** format.
40+
- Use simple sentences and a clear writing style, consistent with standard technical documentation practices.
41+

0 commit comments

Comments
 (0)