You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-27Lines changed: 65 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,43 +7,81 @@ A reactive entity←component framework that feels home in the shadows 🧛
7
7
8
8
## Introduction 👀
9
9
10
-
TODO ..
10
+
The **Shadow Objects Framework** is a reactive 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 your application.
11
11
12
-
## ⚙️ Local Dev Setup
12
+
Key features include:
13
13
14
-
This is a monorepo based on [nx](https://nx.dev/) and [pnpm](https://pnpm.io/).
14
+
-**Decoupled Logic**: Business logic resides in "Shadow Objects" separate from UI components.
15
+
-**Entity-Component System**: Mirrors the view hierarchy (DOM) with a tree of Entities.
16
+
-**Reactivity**: Built on signals and effects for automatic state synchronization.
17
+
-**Context System**: Hierarchical dependency injection similar to React Context.
15
18
16
-
First, install dependencies with ...
19
+
For a detailed deep dive into the architecture and API, please refer to the [**Shadow Objects Documentation**](packages/shadow-objects/README.md).
17
20
18
-
```sh
19
-
$ pnpm install
20
-
```
21
-
You will also need to install the _playwright_ browser bundles _chromium_ and _firefox_ once in the [./packages/shadow-objects-e2e/](./packages/shadow-objects-e2e/) directory
This repository is a monorepo managed with [nx](https://nx.dev/) and [pnpm](https://pnpm.io/).
28
24
29
-
After that you can build the framework and run all the tests with ..
25
+
| Package | Description |
26
+
| :--- | :--- |
27
+
|**[`shadow-objects`](packages/shadow-objects/)**| The core framework library. |
28
+
|**[`shae-offscreen-canvas`](packages/shae-offscreen-canvas/)**| A custom HTML element implementing an **offscreen canvas**, built with shadow-objects. |
29
+
|**[`shadow-objects-testing`](packages/shadow-objects-testing/)**| Functional and integration tests for the framework. |
30
+
|**[`shadow-objects-e2e`](packages/shadow-objects-e2e/)**| End-to-end tests using [Playwright](https://playwright.dev/). |
30
31
31
-
```sh
32
-
$ pnpm cbt # => clean build test
33
-
```
32
+
## ⚙️ Development Setup
34
33
35
-
A first demo can simply be started with `pnpm start`. This is very useful to see if everything works. The demo shows functions from the optional `shae-offscreen-canvas` library.
34
+
### Prerequisites
36
35
37
-
## 📖 Packages
36
+
-**Node.js**: >=20.12.2
37
+
-**pnpm**: >=9.1.2
38
38
39
-
| package | description |
40
-
|-|-|
41
-
|[`shadow-objects`](packages/shadow-objects/)| the main framework |
42
-
|[`shae-offscreen-canvas`](packages/shae-offscreen-canvas/)| an **offscreen canvas** as custom html **element** based on shadow-objects |
The E2E tests require Playwright browsers to be installed manually.
50
+
51
+
```sh
52
+
cd packages/shadow-objects-e2e
53
+
pnpm exec playwright install chromium firefox
54
+
cd ../..
55
+
```
56
+
57
+
### Common Tasks
58
+
59
+
- **Build & Test All:**
60
+
Run a clean build and all tests (unit, functional, e2e) across the workspace.
61
+
62
+
```sh
63
+
pnpm cbt
64
+
```
65
+
*(Alias for`pnpm run-s clean build test`)*
66
+
67
+
- **Start Demo:**
68
+
Launch the `shae-offscreen-canvas` demo to see the framework in action.
69
+
70
+
```sh
71
+
pnpm start
72
+
```
73
+
74
+
- **Run Tests:**
75
+
```sh
76
+
pnpm test# Run all tests
77
+
pnpm test:ci # Run tests excluding E2E (faster)
78
+
```
79
+
80
+
- **Linting:**
81
+
```sh
82
+
pnpm lint
83
+
```
45
84
46
85
- - -
47
86
48
-
> 🔎 This project does not currently use a separate issue tracking system; instead, TODO, FIXME, and XXX issues are written directly as comments in the source code, without any further indirection.
49
-
> An overview of open issues can be found in [TODO.md](TODO.md).
87
+
> 🔎 **Note:** This project tracks tasks directly in the source code using `TODO`, `FIXME`, and `XXX` comments. See [TODO.md](TODO.md) for an auto-generated overview.
The **Shadow Objects Framework** is a library for managing application state and logic that runs "in the dark" (in a worker or separate context), mirroring a view hierarchy (like the DOM). It decouples business logic and state management from the UI rendering layer.
3
+
The **Shadow Objects Framework** is a reactive 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 your application.
4
+
5
+
> [!WARNING]
6
+
> 🚀 This is a highly experimental framework that is slowly maturing. Use at your own risk. 🔥
5
7
6
8
## Core Concepts
7
9
@@ -29,77 +31,143 @@ The **Registry** maps **Tokens** to **Shadow Object Constructors**.
29
31
-**Routes**: Defines rules for composing multiple Shadow Objects. For example, a token can "route" to other tokens, causing multiple Shadow Objects to be instantiated for a single Entity.
30
32
-**Conditional Routing**: Routes can be triggered based on the presence of specific "truthy" properties on the Entity (e.g., `@myProp` routes only if `myProp` is set).
31
33
32
-
## Lifecycle
34
+
---
33
35
34
-
1.**Creation**: When an Entity is created (e.g., a Web Component connects), the Kernel looks up its Token in the Registry.
35
-
2.**Instantiation**: The Kernel instantiates all Shadow Objects associated with that Token (and its routes).
36
-
3.**Execution**: The Shadow Object function runs, setting up signals, effects, and context providers.
37
-
4.**Updates**:
38
-
***Properties**: When view properties change, the Entity's signals update, triggering any dependent effects in the Shadow Object.
39
-
***Context**: If a parent Entity changes a provided context, child Shadow Objects consuming that context automatically update.
40
-
5.**Destruction**: When an Entity is removed or its Token changes, the Kernel destroys the associated Shadow Objects, cleaning up all signals and effects.
36
+
## Developer Guide
37
+
38
+
### 1. Defining Shadow Objects
41
39
42
-
## API: Writing Shadow Objects
40
+
You can define a Shadow Object as a **Function** or a **Class**. Both receive a `ShadowObjectParams` object containing the API methods.
43
41
44
-
Shadow Objects are defined as functions (or classes) that receive a `ShadowObjectParams` object.
1.**Creation**: When an Entity is created (e.g., `<shae-ent>` connects), the Kernel looks up its Token in the Registry.
163
+
2.**Instantiation**: The Kernel instantiates all Shadow Objects associated with that Token (and its routes).
164
+
3.**Execution**: The Shadow Object function runs, setting up signals, effects, and context providers.
165
+
4.**Updates**:
166
+
***Properties**: When view properties change, the Entity's signals update, triggering any dependent effects in the Shadow Object.
167
+
***Context**: If a parent Entity changes a provided context, child Shadow Objects consuming that context automatically update.
168
+
5.**Destruction**: When an Entity is removed or its Token changes, the Kernel destroys the associated Shadow Objects, cleaning up all signals and effects.
169
+
170
+
### Architecture Diagram
103
171
104
172
```mermaid
105
173
graph TD
@@ -122,3 +190,11 @@ graph TD
122
190
Logic -->|Updates| Signals
123
191
Signals -->|Triggers| Effects
124
192
```
193
+
194
+
### Further Reading
195
+
196
+
For deep dives into specific subsystems:
197
+
198
+
-[**ShadowEnv**](src/view/README.md): The environment wrapper.
0 commit comments