Skip to content

Commit c0051c2

Browse files
refactor(host): Group capability slices under src/main/.
1 parent 9b2fe7b commit c0051c2

27 files changed

Lines changed: 31 additions & 25 deletions

host/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ Official JS modules for [Edge Python](https://edgepython.com) exposing host APIs
77
```
88
├── dom
99
│ └── src
10+
│ ├── index.js
11+
│ └── main
1012
├── network
1113
│ └── src
14+
│ ├── index.js
15+
│ └── main
1216
├── storage
1317
│ └── src
18+
│ ├── index.js
19+
│ └── main
1420
├── time
1521
│ └── src
22+
│ ├── index.js
23+
│ └── main
1624
└── tests
1725
```
1826

host/dom/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,7 @@ Each fires a payload through `receive()` per entry with observer-specific fields
146146
`animate(node, keyframes_json, options_json, msg?)`, `animation_play`, `animation_pause`, `animation_cancel`, `animation_finish`, `animation_reverse`, `animation_dispose`.
147147

148148
```python
149-
animate(query("#spinner"),
150-
'[{"transform": "rotate(0deg)"}, {"transform": "rotate(360deg)"}]',
151-
'{"duration": 1000, "iterations": "Infinity"}')
149+
animate(query("#spinner"), '[{"transform": "rotate(0deg)"}, {"transform": "rotate(360deg)"}]', '{"duration": 1000, "iterations": "Infinity"}')
152150
```
153151

154152
Works on HTML and SVG. Returns a handle. With a `msg`, a `{msg, animation_handle, ok}` payload fires via `receive()` on finish. Handle auto-disposes on finish or cancel; for `iterations: "Infinity"` call `animation_dispose(h)` when done.
@@ -199,7 +197,7 @@ Payload: `{msg, where, error, stack?}`. `where` identifies the call site (`event
199197

200198
## How it works
201199

202-
Factory `(ctx) => handlers`. `src/state.js` opens a fresh closure per `createWorker` with handle tables (`nodes`, `bindings`, `files`, observers, animations), `alloc` / `node` / `allocList` helpers, and `cleanSubtree`. Eight handler slices (`tree`, `style`, `events`, `forms`, `observers`, `animations`, `media`, `platform`) each return an object literal of handlers closing over the shared state; `src/index.js` composes them with `Object.assign` and wraps async callbacks with `emitError` so failures surface via `bind_global_error`. Adding a handler is one entry in one slice.
200+
Factory `(ctx) => handlers`. `src/main/state.js` opens a fresh closure per `createWorker` with handle tables (`nodes`, `bindings`, `files`, observers, animations), `alloc` / `node` / `allocList` helpers, and `cleanSubtree`. Eight handler slices in `src/main/` (`tree`, `style`, `events`, `forms`, `observers`, `animations`, `media`, `platform`) each return an object literal of handlers closing over the shared state; `src/index.js` composes them with `Object.assign` and wraps async callbacks with `emitError` so failures surface via `bind_global_error`. Adding a handler is one entry in one slice.
203201

204202
## Performance
205203

host/dom/src/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/* Factory consumed by `createWorker({ mainThreadModules: { dom } })`. Composes all handler slices over a shared `state`. */
22

3-
import { makeState } from './state.js';
4-
import tree from './tree.js';
5-
import style from './style.js';
6-
import events from './events.js';
7-
import forms from './forms.js';
8-
import observers from './observers.js';
9-
import animations from './animations.js';
10-
import media from './media.js';
11-
import platform from './platform.js';
3+
import { makeState } from './main/state.js';
4+
import tree from './main/tree.js';
5+
import style from './main/style.js';
6+
import events from './main/events.js';
7+
import forms from './main/forms.js';
8+
import observers from './main/observers.js';
9+
import animations from './main/animations.js';
10+
import media from './main/media.js';
11+
import platform from './main/platform.js';
1212

1313
export const dom = (ctx) => {
1414
const state = makeState();

0 commit comments

Comments
 (0)