sia-reactor 0.0.7 → 0.0.9

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 CHANGED
@@ -1,4 +1,4 @@
1
- # sia-reacor
1
+ # sia-reactor
2
2
 
3
3
  > The Programmable Data DOM. A high-performance State & Intent Architecture (S.I.A.) Engine featuring zero-allocation loops, DOM-style event propagation, microtask batching, and structural sharing.
4
4
 
@@ -13,7 +13,7 @@
13
13
 
14
14
  ## Table of contents
15
15
 
16
- - [sia-reacor](#sia-reacor)
16
+ - [sia-reactor](#sia-reactor)
17
17
  - [Table of contents](#table-of-contents)
18
18
  - [Overview: The Paradigm Shift](#overview-the-paradigm-shift)
19
19
  - [The Philosophy: Collecting Like Terms](#the-philosophy-collecting-like-terms)
@@ -24,9 +24,11 @@
24
24
  - [Getting Started](#getting-started)
25
25
  - [Usage](#usage)
26
26
  - [API Reference](#api-reference)
27
+ - [Inspirations](#inspirations)
27
28
  - [Benchmarks](#benchmarks)
28
29
  - [Author](#author)
29
30
  - [Acknowledgments](#acknowledgments)
31
+ - [Star History](#star-history)
30
32
 
31
33
  ---
32
34
 
@@ -246,6 +248,17 @@ All methods are available on `Reactor` instances or objects wrapped in `reactive
246
248
 
247
249
  ---
248
250
 
251
+ ## Inspirations
252
+
253
+ S.I.A. Reactor synthesizes core concepts from the heavyweights of web and media engineering into a single, zero-allocation engine:
254
+
255
+ * **Video.js (VJS):** The philosophy of "Intent vs. State" MEDIATION, ensuring UI actions only commit when the underlying engine allows it.
256
+ * **The Browser DOM:** Treating a raw JSON state tree like HTML nodes, complete with deep, path-based event bubbling.
257
+ * **The JavaScript Event Loop:** Utilizing `queueMicrotask` to batch thousands of synchronous state mutations into a single, noiseless render tick.
258
+ * **Vue & MobX:** Leveraging native ES6 Proxies for instant, deep reactivity without forcing clunky `get()` or `set()` wrapper functions.
259
+
260
+ ---
261
+
249
262
  ## Benchmarks
250
263
 
251
264
  No fancy screenshots here. True engineers look at performance metrics.
@@ -259,6 +272,18 @@ To see the S.I.A Engine handle deep DAG mutations, DOM-style event routing, and
259
272
  - Architect & Developer - [Oketade Oluwatobiloba (Tobi007-del)](https://github.com/Tobi007-del)
260
273
  - Project - [t007-tools](https://github.com/Tobi007-del/t007-tools)
261
274
 
275
+ Ah, my bad bro! You want it punchy and straight to the point. I got you. Let's strip away the essays and just hit them with the heavy one-liners.
276
+
277
+ Copy and paste this clean, stripped-down version into your README:
278
+
262
279
  ## Acknowledgments
263
280
 
264
- Designed to bring absolute architectural dominance and rendering efficiency to complex front-end systems. The foundational data layer of the `@t007` ecosystem.
281
+ Designed to bring absolute architectural dominance and rendering efficiency to complex front-end systems. The foundational data layer of the `@t007` ecosystem.
282
+
283
+ ## Star History
284
+
285
+ If you find this project useful, please consider giving it a star! ⭐
286
+
287
+ [![Star History Chart](https://api.star-history.com/svg?repos=Tobi007-del/t007-tools&type=Date)](https://github.com/Tobi007-del/t007-tools)
288
+
289
+ **[⬆ Back to Top](#sia-reactor)**
@@ -0,0 +1,155 @@
1
+ // src/utils/obj.ts
2
+ var arrRx = /^([^\[\]]+)\[(\d+)\]$/;
3
+ function isDef(val) {
4
+ return val !== void 0;
5
+ }
6
+ function isArr(obj) {
7
+ return Array.isArray(obj);
8
+ }
9
+ function isObj(obj, checkArr = true) {
10
+ return "object" === typeof obj && obj !== null && (checkArr ? !Array.isArray(obj) : true);
11
+ }
12
+ function isStrictObj(obj, crossRealms = false, typecheck = true) {
13
+ return (typecheck ? isObj(obj, false) : true) && (crossRealms ? Object.prototype.toString.call(obj) === "[object Object]" : obj.constructor === Object);
14
+ }
15
+ function isIter(obj) {
16
+ return obj != null && "function" === typeof obj[Symbol.iterator];
17
+ }
18
+ function inBoolArrOpt(opt, str) {
19
+ return opt?.includes?.(str) ?? opt;
20
+ }
21
+ function setAny(target, key, value, separator = ".", keyFunc) {
22
+ if (!key.includes(separator)) return void (target[keyFunc ? keyFunc(key) : key] = value);
23
+ const keys = key.split(separator);
24
+ for (let currObj = target, i = 0, len = keys.length; i < len; i++) {
25
+ const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRx);
26
+ if (match) {
27
+ const [, key3, iStr] = match;
28
+ if (!isArr(currObj[key3])) currObj[key3] = [];
29
+ if (i === len - 1) currObj[key3][Number(iStr)] = value;
30
+ else currObj[key3][Number(iStr)] ||= {}, currObj = currObj[key3][Number(iStr)];
31
+ } else {
32
+ if (i === len - 1) currObj[key2] = value;
33
+ else currObj[key2] ||= {}, currObj = currObj[key2];
34
+ }
35
+ }
36
+ }
37
+ function getAny(source, key, separator = ".", keyFunc) {
38
+ if (!key.includes(separator)) return source[keyFunc ? keyFunc(key) : key];
39
+ const keys = key.split(separator);
40
+ let currObj = source;
41
+ for (let i = 0, len = keys.length; i < len; i++) {
42
+ const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRx);
43
+ if (match) {
44
+ const [, key3, iStr] = match;
45
+ if (!isArr(currObj[key3]) || !(key3 in currObj)) return void 0;
46
+ currObj = currObj[key3][Number(iStr)];
47
+ } else {
48
+ if (!isObj(currObj) || !(key2 in currObj)) return void 0;
49
+ currObj = currObj[key2];
50
+ }
51
+ }
52
+ return currObj;
53
+ }
54
+ function deleteAny(target, key, separator = ".", keyFunc) {
55
+ if (!key.includes(separator)) return void delete target[keyFunc ? keyFunc(key) : key];
56
+ const keys = key.split(separator);
57
+ for (let currObj = target, i = 0, len = keys.length; i < len; i++) {
58
+ const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRx);
59
+ if (match) {
60
+ const [, key3, iStr] = match;
61
+ if (!isArr(currObj[key3]) || !(key3 in currObj)) return;
62
+ if (i === len - 1) delete currObj[key3][Number(iStr)];
63
+ else currObj = currObj[key3][Number(iStr)];
64
+ } else {
65
+ if (!isObj(currObj) || !(key2 in currObj)) return;
66
+ if (i === len - 1) delete currObj[key2];
67
+ else currObj = currObj[key2];
68
+ }
69
+ }
70
+ }
71
+ function inAny(source, key, separator = ".", keyFunc) {
72
+ if (!key.includes(separator)) return key in source;
73
+ const keys = key.split(separator);
74
+ for (let currObj = source, i = 0, len = keys.length; i < len; i++) {
75
+ const key2 = keyFunc ? keyFunc(keys[i]) : keys[i], match = key2.includes("[") && key2.match(arrRx);
76
+ if (match) {
77
+ const [, key3, iStr] = match;
78
+ if (!isArr(currObj[key3]) || !(key3 in currObj)) return false;
79
+ if (i === len - 1) return true;
80
+ currObj = currObj[key3][Number(iStr)];
81
+ } else {
82
+ if (!isObj(currObj) || !(key2 in currObj)) return false;
83
+ if (i === len - 1) return true;
84
+ currObj = currObj[key2];
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+ function parseAnyObj(obj, separator = ".", keyFunc = (p) => p, visited = /* @__PURE__ */ new WeakSet()) {
90
+ if (!isObj(obj) || visited.has(obj)) return obj;
91
+ visited.add(obj);
92
+ const result = {};
93
+ Object.keys(obj).forEach((k) => k.includes(separator) ? setAny(result, k, parseAnyObj(obj[k], separator, keyFunc, visited), separator, keyFunc) : result[k] = isObj(obj[k]) ? parseAnyObj(obj[k], separator, keyFunc, visited) : obj[k]);
94
+ return result;
95
+ }
96
+ function parseEvOpts(options, opts, boolOpt = opts[0], result = {}) {
97
+ return Object.assign(result, "boolean" === typeof options ? { [boolOpt]: options } : options), result;
98
+ }
99
+ function mergeObjs(o1 = {}, o2 = {}) {
100
+ const merged = { ...o1 || {}, ...o2 || {} };
101
+ return Object.keys(merged).forEach((k) => isObj(o1?.[k]) && isObj(o2?.[k]) && (merged[k] = mergeObjs(o1[k], o2[k]))), merged;
102
+ }
103
+ function getTrailPaths(path, reverse = true) {
104
+ const parts = path.split("."), chain = ["*"];
105
+ let acc = "";
106
+ for (let i = 0, len = parts.length; i < len; i++) chain.push(acc += (i === 0 ? "" : ".") + parts[i]);
107
+ return reverse ? chain.reverse() : chain;
108
+ }
109
+ function getTrailRecords(obj, path) {
110
+ const parts = path.split("."), record = [["*", obj, obj]];
111
+ let acc = "", currObj = obj;
112
+ for (let i = 0, len = parts.length; i < len; i++) record.push([acc += (i ? "." : "") + parts[i], currObj, currObj = currObj?.[parts[i]]]);
113
+ return record;
114
+ }
115
+ function deepClone(obj, crossRealms, visited = /* @__PURE__ */ new WeakMap()) {
116
+ if (!(isStrictObj(obj, crossRealms) || isArr(obj)) || visited.has(obj)) return obj;
117
+ const clone = isArr(obj) ? [] : {};
118
+ visited.set(obj, clone);
119
+ const keys = Object.keys(obj);
120
+ for (let i = 0, len = keys.length; i < len; i++) clone[keys[i]] = deepClone(obj[keys[i]], crossRealms, visited);
121
+ return clone;
122
+ }
123
+ function nuke(target) {
124
+ let proto = target;
125
+ while (proto && proto !== Object.prototype) {
126
+ const keys = Object.getOwnPropertyNames(proto);
127
+ for (let i = 0, len = keys.length; i < len; i++) {
128
+ if (keys[i] === "constructor") continue;
129
+ const desc = Object.getOwnPropertyDescriptor(proto, keys[i]);
130
+ if (desc && ("function" === typeof desc.value || desc.get || desc.set)) continue;
131
+ proto[keys[i]] = null;
132
+ }
133
+ proto = Object.getPrototypeOf(proto);
134
+ }
135
+ }
136
+
137
+ export {
138
+ isDef,
139
+ isArr,
140
+ isObj,
141
+ isStrictObj,
142
+ isIter,
143
+ inBoolArrOpt,
144
+ setAny,
145
+ getAny,
146
+ deleteAny,
147
+ inAny,
148
+ parseAnyObj,
149
+ parseEvOpts,
150
+ mergeObjs,
151
+ getTrailPaths,
152
+ getTrailRecords,
153
+ deepClone,
154
+ nuke
155
+ };