sia-reactor 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Read [Chronicles](https://github.com/Tobi007-del/tmg-media-player/blob/main/CHRO
|
|
|
39
39
|
- **I just need to use this fast**:
|
|
40
40
|
Jump directly to [Getting Started](#getting-started) and [API Reference](#api-reference).
|
|
41
41
|
|
|
42
|
-
###
|
|
42
|
+
### Quick Overview
|
|
43
43
|
|
|
44
44
|
`sia-reactor` treats nested data like a programmable evented tree.
|
|
45
45
|
|
|
@@ -52,8 +52,8 @@ Jump directly to [Getting Started](#getting-started) and [API Reference](#api-re
|
|
|
52
52
|
Semantic split recommendation:
|
|
53
53
|
- `intent`: async/delayed requests.
|
|
54
54
|
- `state`: granted facts.
|
|
55
|
-
- `settings/config`: immediate user prefs.
|
|
56
|
-
- `status`: read-only system facts.
|
|
55
|
+
- `settings/config (custom)`: immediate user prefs.
|
|
56
|
+
- `status (custom)`: read-only system facts.
|
|
57
57
|
|
|
58
58
|
```javascript
|
|
59
59
|
import { reactive, intent } from 'sia-reactor';
|
|
@@ -137,16 +137,41 @@ state.set("player.volume", (val) => Math.min(val, 100));
|
|
|
137
137
|
state.on("player.volume", (e) => console.log(e.value));
|
|
138
138
|
|
|
139
139
|
state.player.volume = 150; // Triggers mediation, clamps to 100, fires listener.
|
|
140
|
+
state.__Reactor__ // Reference to the underlying reactor
|
|
140
141
|
```
|
|
141
142
|
|
|
142
143
|
Alternatively, you can instantiate the `Reactor` class directly to keep the API separate from your data:
|
|
143
144
|
```javascript
|
|
144
145
|
const reactor = new Reactor({ player: { volume: 50 } }, { debug: true, referenceTracking: true });
|
|
145
146
|
reactor.core.player.volume = 100;
|
|
146
|
-
const state = reactive(reactor); // Methods are now attached to the core and returned.
|
|
147
|
-
state.__Reactor__ // Reference to the underlying reactor
|
|
148
147
|
```
|
|
149
148
|
|
|
149
|
+
### Core Methods
|
|
150
|
+
|
|
151
|
+
All methods are available on `Reactor` instances or objects wrapped in `reactive()`.
|
|
152
|
+
|
|
153
|
+
#### **Mediators (Synchronous Gatekeepers)**
|
|
154
|
+
- **`set(path, callback, options)`**: Intercept memory writes. Return a value to modify it, or return `TERMINATOR` to block the write entirely.
|
|
155
|
+
- **`get(path, callback, options)`**: Intercept and format data during retrieval.
|
|
156
|
+
- **`delete(path, callback, options)`**: Intercept property deletion.
|
|
157
|
+
|
|
158
|
+
#### **Watchers (Synchronous Observers)**
|
|
159
|
+
- **`watch(path, callback, options)`**: Fires instantly after a mutation. Use strictly for critical internal engine syncing.
|
|
160
|
+
|
|
161
|
+
#### **Listeners (Asynchronous/Batched UI Observers)**
|
|
162
|
+
- **`on(path, callback, options)`**: Attach DOM-style event listeners. Supports `{ capture: true, depth: 1, once: true, immediate: true }`.
|
|
163
|
+
- **`once(path, callback, options)`**: Fires once and self-destructs.
|
|
164
|
+
- **`off(path, callback, options)`**: Removes a listener.
|
|
165
|
+
|
|
166
|
+
#### **Lifecycle & Utilities**
|
|
167
|
+
- **`tick(path)`**: Forces a synchronous flush of the batch queue for a specific path.
|
|
168
|
+
- **`stall(task)` / `nostall(task)`**: Manually stall the queue to wait for calculations before rendering.
|
|
169
|
+
- **`cascade(eventOrPayload, objectSafe)`**: Manually trigger deep-object event waves, bypassing strict unchanged-proxy traps. Perfect for dumping massive API payloads into the tree, `objectSafe` merges `value` with `oldValue`.
|
|
170
|
+
- **`snapshot(raw)`**: Generates a strict, structurally-shared, un-proxied clone of the current state tree.
|
|
171
|
+
- **`plugIn(new ReactorPlugin(config))`**: Allows extended behaviour with external logic.
|
|
172
|
+
- **`reset()`**: Clears all records bringing everything back to a clean slate.
|
|
173
|
+
- **`destroy()`**: Last resort destruction, nukes everything by nullifying it's properties for full disposal.
|
|
174
|
+
|
|
150
175
|
### Reactor Build Options
|
|
151
176
|
|
|
152
177
|
These are some core build options accepted by `new Reactor(core, build)` and `reactive(core, build)`.
|
|
@@ -181,32 +206,6 @@ const data = reactive({
|
|
|
181
206
|
});
|
|
182
207
|
```
|
|
183
208
|
|
|
184
|
-
### Core Methods
|
|
185
|
-
|
|
186
|
-
All methods are available on `Reactor` instances or objects wrapped in `reactive()`.
|
|
187
|
-
|
|
188
|
-
#### **Mediators (Synchronous Gatekeepers)**
|
|
189
|
-
- **`set(path, callback, options)`**: Intercept memory writes. Return a value to modify it, or return `TERMINATOR` to block the write entirely.
|
|
190
|
-
- **`get(path, callback, options)`**: Intercept and format data during retrieval.
|
|
191
|
-
- **`delete(path, callback, options)`**: Intercept property deletion.
|
|
192
|
-
|
|
193
|
-
#### **Watchers (Synchronous Observers)**
|
|
194
|
-
- **`watch(path, callback, options)`**: Fires instantly after a mutation. Use strictly for critical internal engine syncing.
|
|
195
|
-
|
|
196
|
-
#### **Listeners (Asynchronous/Batched UI Observers)**
|
|
197
|
-
- **`on(path, callback, options)`**: Attach DOM-style event listeners. Supports `{ capture: true, depth: 1, once: true, immediate: true }`.
|
|
198
|
-
- **`once(path, callback, options)`**: Fires once and self-destructs.
|
|
199
|
-
- **`off(path, callback, options)`**: Removes a listener.
|
|
200
|
-
|
|
201
|
-
#### **Lifecycle & Utilities**
|
|
202
|
-
- **`tick(path)`**: Forces a synchronous flush of the batch queue for a specific path.
|
|
203
|
-
- **`stall(task)` / `nostall(task)`**: Manually stall the queue to wait for calculations before rendering.
|
|
204
|
-
- **`cascade(eventOrPayload, objectSafe)`**: Manually trigger deep-object event waves, bypassing strict unchanged-proxy traps. Perfect for dumping massive API payloads into the tree, `objectSafe` merges `value` with `oldValue`.
|
|
205
|
-
- **`snapshot(raw)`**: Generates a strict, structurally-shared, un-proxied clone of the current state tree.
|
|
206
|
-
- **`plugIn(new ReactorPlugin(config))`**: Allows extended behaviour with external logic.
|
|
207
|
-
- **`reset()`**: Clears all records bringing everything back to a clean slate.
|
|
208
|
-
- **`destroy()`**: Last resort destruction, nukes everything by nullifying it's properties for full disposal.
|
|
209
|
-
|
|
210
209
|
### Plugins: The Extension Port
|
|
211
210
|
|
|
212
211
|
The `Reactor` is designed to be a lightweight core. Extended capabilities are attached via Plugins. It ships with a suite of built-in plugins for common architectural needs. like a Persist and TimeTravel plugin.
|
|
@@ -455,7 +454,7 @@ S.I.A. Reactor synthesizes core concepts from the heavyweights of web and media
|
|
|
455
454
|
* **Video.js (VJS):** The philosophy of "Intent vs. State" MEDIATION, ensuring UI actions only commit when the underlying engine allows it.
|
|
456
455
|
* **The Browser DOM:** Treating a raw JSON state tree like HTML nodes, complete with deep, path-based event bubbling.
|
|
457
456
|
* **The JavaScript Event Loop:** Utilizing `queueMicrotask` to batch thousands of synchronous state mutations into a single, noiseless render tick.
|
|
458
|
-
* **Vue &
|
|
457
|
+
* **Vue, MobX & Valtio:** Leveraging native ES6 Proxies for instant, deep reactivity without forcing clunky `get()` or `set()` wrapper functions.
|
|
459
458
|
|
|
460
459
|
---
|
|
461
460
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sia-reactor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "The Programmable Data DOM. A high-performance State Intent Architecture (S.I.A.) Engine with zero-allocation loops, event propagation, and structural sharing.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|