react-state-basis 0.1.2 β†’ 0.1.4

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,5 +1,10 @@
1
- [![npm version](https://badge.fury.io/js/react-state-basis.svg)](https://www.npmjs.com/package/react-state-basis)
1
+ <p align="center">
2
+ <img src="./assets/logo.png" width="300" alt="Basis Logo">
3
+ </p>
4
+
5
+ [![npm version](https://img.shields.io/npm/v/react-state-basis.svg?style=flat-square)](https://www.npmjs.com/package/react-state-basis)
2
6
  [![View on GitHub](https://img.shields.io/badge/View_Documentation-GitHub-black?logo=github)](https://github.com/liovic/react-state-basis#readme)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)
3
8
 
4
9
  # πŸ“ REACT-STATE-BASIS
5
10
  ### **Behavioral State Analysis for React**
@@ -214,7 +219,9 @@ In pure Linear Algebra, proving linear independence for $N$ variables requires s
214
219
 
215
220
  To maintain real-time performance, React-State-Basis uses **Cosine Similarity** as a high-speed heuristic ($O(D)$, where $D$ is the vector dimension) to detect **pairwise collinearity**:
216
221
 
217
- $$ \text{similarity} = \cos(\theta) = \frac{\mathbf{A} \cdot \mathbf{B}}{\Vert \mathbf{A} \Vert \Vert \mathbf{B} \Vert} $$
222
+ ```math
223
+ \text{similarity} = \cos(\theta) = \frac{\mathbf{A} \cdot \mathbf{B}}{\Vert \mathbf{A} \Vert \Vert \mathbf{B} \Vert}
224
+ ```
218
225
 
219
226
  If $\cos(\theta) \approx 1.00$, the vectors are collinear (linearly dependent), and the engine triggers a redundancy alert.
220
227
 
@@ -438,6 +445,36 @@ When in doubt, it surfaces potential issues so developers can make informed deci
438
445
 
439
446
  Think of it as an architectural smoke detector-not a fire marshal.
440
447
 
448
+ ---
449
+
450
+ ## πŸ—ΊοΈ Roadmap: The Path to Architectural Rigor
451
+
452
+ React-State-Basis is evolving from a runtime auditor to a complete development infrastructure. Here is the planned trajectory:
453
+
454
+ ### **v0.2.0 - Full Hook Parity (Upcoming)**
455
+ The goal is to make Basis a complete drop-in replacement for the standard React API.
456
+ * **Complete API Coverage:** Adding support for `useRef`, `useCallback`, `useLayoutEffect`, `useTransition`, `useDeferredValue`
457
+ * **Babel Enhancements:** Automated labeling for the entire hook suite to ensure zero-manual-config diagnostics.
458
+ * **Signature Robustness:** Smart disambiguation between dependency arrays and manual labels.
459
+
460
+ ### **v0.3.0 - Modernity & Production Strategy**
461
+ Aligning with the future of React and ensuring zero production cost.
462
+ * **React 19 Support:** Integration of `use()`, `useOptimistic()`, and `useActionState()` into the vector space model.
463
+ * **Zero-Overhead Production:** Implementing **Conditional Exports**. When in production mode, Basis will pass through raw React hooks with zero logic, ensuring no performance penalty.
464
+
465
+ ### **v0.4.0 - Developer Ecosystem & Visuals**
466
+ Tools for better ergonomics and high-level insights.
467
+ * **CLI Utilities (`rsb-init`, `rsb-clean`):** Automated codemods to instantly inject or remove Basis from large codebases. No more manual search-and-replace.
468
+ * **State-Space Visualizer:** A 2D topology map showing "Redundancy Clusters." Visualize your state vectors as physical nodes to identify where the architecture is collapsing.
469
+
470
+ ### **v1.0.0 - Formal Verification**
471
+ * **Architectural Gatekeeping:** CI/CD integration to fail builds on infinite loops or critical dimension collapses.
472
+ * **KPI Tracking:** Long-term monitoring of your application’s **System Efficiency Score**.
473
+
474
+ ---
475
+
476
+ ### πŸ“¬ Get Involved
477
+ If you have an idea for a mathematical heuristic or a DX improvement, feel free to open an issue or a PR.
441
478
 
442
479
  ---
443
480
  *Developed by LP*
package/dist/index.d.mts CHANGED
@@ -20,8 +20,8 @@ declare const __testEngine__: {
20
20
  };
21
21
 
22
22
  declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
23
- declare function useMemo<T>(factory: () => T, deps: DependencyList | undefined, label?: string): T;
24
- declare function useEffect(effect: EffectCallback, deps?: DependencyList, label?: string): void;
23
+ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
24
+ declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
25
25
  declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
26
26
  declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
27
27
  declare function useContext<T>(context: Context<T>): T;
package/dist/index.d.ts CHANGED
@@ -20,8 +20,8 @@ declare const __testEngine__: {
20
20
  };
21
21
 
22
22
  declare function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>];
23
- declare function useMemo<T>(factory: () => T, deps: DependencyList | undefined, label?: string): T;
24
- declare function useEffect(effect: EffectCallback, deps?: DependencyList, label?: string): void;
23
+ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T;
24
+ declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
25
25
  declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
26
26
  declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
27
27
  declare function useContext<T>(context: Context<T>): T;
package/dist/index.js CHANGED
@@ -42,19 +42,16 @@ __export(index_exports, {
42
42
  module.exports = __toCommonJS(index_exports);
43
43
 
44
44
  // src/core/logger.ts
45
+ var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined";
45
46
  var STYLES = {
46
- // Brand Colors
47
47
  basis: "background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;",
48
48
  version: "background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;",
49
- // Headers
50
49
  headerRed: "background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
51
50
  headerBlue: "background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
52
51
  headerGreen: "background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
53
- // Elements
54
52
  label: "background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;",
55
53
  location: "color: #0984e3; font-family: monospace; font-weight: bold;",
56
54
  math: "color: #636e72; font-style: italic; font-family: serif;",
57
- // Code Block
58
55
  codeBlock: `
59
56
  background: #1e1e1e;
60
57
  color: #9cdcfe;
@@ -66,7 +63,6 @@ var STYLES = {
66
63
  line-height: 1.4;
67
64
  border-radius: 0 3px 3px 0;
68
65
  `,
69
- // Highlights
70
66
  dim: "color: #e84393; font-weight: bold;",
71
67
  bold: "font-weight: bold;"
72
68
  };
@@ -77,9 +73,16 @@ var parseLabel = (label) => {
77
73
  name: parts[1] || label
78
74
  };
79
75
  };
76
+ var logBasis = (message, ...styles) => {
77
+ if (isWeb) {
78
+ console.log(message, ...styles);
79
+ } else {
80
+ console.log(message.replace(/%c/g, ""));
81
+ }
82
+ };
80
83
  var displayBootLog = (windowSize) => {
81
- console.log(
82
- `%cBasis%cAuditor v0.1.0%c Monitoring State Space | Window: ${windowSize} ticks`,
84
+ logBasis(
85
+ `%cBasis%cAuditor v0.1.4%c Monitoring State Space | Window: ${windowSize} ticks`,
83
86
  STYLES.basis,
84
87
  STYLES.version,
85
88
  "color: #636e72; font-style: italic; margin-left: 8px;"
@@ -89,87 +92,87 @@ var displayRedundancyAlert = (labelA, labelB, sim, totalDimensions) => {
89
92
  const infoA = parseLabel(labelA);
90
93
  const infoB = parseLabel(labelB);
91
94
  const isCrossFile = infoA.file !== infoB.file;
92
- console.group(`%c \u{1F4D0} BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);
93
- console.log(`%c\u{1F4CD} Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);
94
- console.log(
95
- `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,
96
- STYLES.bold,
97
- "",
98
- STYLES.label,
99
- "",
100
- STYLES.label,
101
- ""
102
- );
103
- console.log(
104
- `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:
95
+ if (isWeb) {
96
+ console.group(`%c \u{1F4D0} BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);
97
+ console.log(`%c\u{1F4CD} Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);
98
+ console.log(
99
+ `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,
100
+ STYLES.bold,
101
+ "",
102
+ STYLES.label,
103
+ "",
104
+ STYLES.label,
105
+ ""
106
+ );
107
+ console.log(
108
+ `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:
105
109
  %c// \u{1F6E0}\uFE0F Basis Fix: Remove useState, use useMemo
106
110
  const ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,
107
- "color: #00b894; font-weight: bold;",
108
- "",
109
- "color: #e84393; font-weight: bold;",
110
- "",
111
- STYLES.codeBlock,
112
- ""
113
- );
114
- console.groupCollapsed(`%c \u{1F52C} Proof Details `, "color: #636e72; font-size: 10px; cursor: pointer;");
115
- console.table({
116
- "Similarity": `${(sim * 100).toFixed(2)}%`,
117
- "Linear Dependency": "TRUE",
118
- "Rank": totalDimensions - 1
119
- });
120
- console.groupEnd();
121
- console.groupEnd();
111
+ "color: #00b894; font-weight: bold;",
112
+ "",
113
+ "color: #e84393; font-weight: bold;",
114
+ "",
115
+ STYLES.codeBlock,
116
+ ""
117
+ );
118
+ console.groupCollapsed(`%c \u{1F52C} Proof Details `, "color: #636e72; font-size: 10px; cursor: pointer;");
119
+ console.table({
120
+ "Similarity": `${(sim * 100).toFixed(2)}%`,
121
+ "Linear Dependency": "TRUE",
122
+ "Rank": totalDimensions - 1
123
+ });
124
+ console.groupEnd();
125
+ console.groupEnd();
126
+ } else {
127
+ console.log(`[BASIS] REDUNDANCY DETECTED: ${infoA.name} <-> ${infoB.name} (${(sim * 100).toFixed(0)}% similarity)`);
128
+ console.log(`Location: ${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`);
129
+ }
122
130
  };
123
131
  var displayCausalHint = (targetLabel, sourceLabel) => {
124
132
  const target = parseLabel(targetLabel);
125
133
  const source = parseLabel(sourceLabel);
126
134
  const isCrossFile = target.file !== source.file;
127
135
  const locationPath = isCrossFile ? `${source.file} \u2794 ${target.file}` : target.file;
128
- console.groupCollapsed(`%c \u{1F4A1} BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);
129
- console.log(`%c\u{1F4CD} Location: %c${locationPath}`, STYLES.bold, STYLES.location);
130
- console.log(
131
- `%cSequence:%c %c${source.name}%c \u2794 Effect \u2794 %c${target.name}%c`,
132
- STYLES.bold,
133
- "",
134
- STYLES.label,
135
- "",
136
- STYLES.label,
137
- ""
138
- );
139
- console.log(
140
- `%cObservation:%c Variable %c${target.name}%c is being manually synchronized.
141
- This creates a %c"Double Render Cycle"%c.`,
142
- STYLES.bold,
143
- "",
144
- STYLES.label,
145
- "",
146
- "color: #d63031; font-weight: bold;",
147
- ""
148
- );
149
- console.log(
150
- `%cHow to fix:%c Use %cuseMemo%c to calculate %c${target.name}%c during render:
151
- %cconst ${target.name} = useMemo(() => computeFrom(${source.name.includes("effect") ? "source" : source.name}), [${source.name.includes("effect") ? "source" : source.name}]);%c`,
152
- "color: #00b894; font-weight: bold;",
153
- "",
154
- "color: #0984e3; font-weight: bold;",
155
- "",
156
- "color: #e84393; font-weight: bold;",
157
- "",
158
- STYLES.codeBlock,
159
- ""
160
- );
161
- console.groupEnd();
136
+ if (isWeb) {
137
+ console.groupCollapsed(`%c \u{1F4A1} BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);
138
+ console.log(`%c\u{1F4CD} Location: %c${locationPath}`, STYLES.bold, STYLES.location);
139
+ console.log(
140
+ `%cSequence:%c %c${source.name}%c \u2794 Effect \u2794 %c${target.name}%c`,
141
+ STYLES.bold,
142
+ "",
143
+ STYLES.label,
144
+ "",
145
+ STYLES.label,
146
+ ""
147
+ );
148
+ console.log(
149
+ `%cObservation:%c Variable %c${target.name}%c is being manually synchronized. This creates a %c"Double Render Cycle"%c.`,
150
+ STYLES.bold,
151
+ "",
152
+ STYLES.label,
153
+ "",
154
+ "color: #d63031; font-weight: bold;",
155
+ ""
156
+ );
157
+ console.groupEnd();
158
+ } else {
159
+ console.log(`[BASIS] CAUSALITY: ${source.name} \u2794 ${target.name} (Double Render Cycle)`);
160
+ }
162
161
  };
163
162
  var displayInfiniteLoop = (label) => {
164
163
  const info = parseLabel(label);
165
- console.group(`%c \u{1F6D1} BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);
166
- console.error(
167
- `Infinite oscillation detected on: %c${info.name}%c
168
- Execution halted to prevent browser thread lock. Check your dependency arrays.`,
169
- "color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;",
170
- ""
171
- );
172
- console.groupEnd();
164
+ if (isWeb) {
165
+ console.group(`%c \u{1F6D1} BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);
166
+ console.error(
167
+ `Infinite oscillation detected on: %c${info.name}%c
168
+ Execution halted to prevent browser thread lock.`,
169
+ "color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;",
170
+ ""
171
+ );
172
+ console.groupEnd();
173
+ } else {
174
+ console.log(`[BASIS CRITICAL] INFINITE LOOP ON: ${info.name}. Execution halted.`);
175
+ }
173
176
  };
174
177
  var displayHealthReport = (history2, similarityFn, threshold) => {
175
178
  const entries = Array.from(history2.entries());
@@ -198,40 +201,45 @@ var displayHealthReport = (history2, similarityFn, threshold) => {
198
201
  });
199
202
  const systemRank = independentCount + clusters.length;
200
203
  const efficiency = systemRank / totalVars * 100;
201
- console.group(`%c \u{1F4CA} BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);
202
- console.log(
203
- `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,
204
- STYLES.bold,
205
- `color: ${efficiency > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
206
- "color: #636e72; font-style: italic;"
207
- );
208
- if (clusters.length > 0) {
209
- console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
210
- clusters.forEach((cluster, idx) => {
211
- const names = cluster.map((l) => parseLabel(l).name).join(" \u27F7 ");
212
- console.log(` %c${idx + 1}%c ${names}`, "background: #e17055; color: white; border-radius: 50%; padding: 0 5px;", "font-family: monospace;");
213
- });
214
- } else {
215
- console.log("%c\u2728 All state variables are linearly independent. Your Basis is optimal.", "color: #00b894; font-weight: bold; margin-top: 10px;");
216
- }
217
- if (totalVars > 0 && totalVars < 15) {
218
- console.groupCollapsed("%cView Full Correlation Matrix", "color: #636e72; font-size: 11px;");
219
- const matrix = {};
220
- entries.forEach(([labelA]) => {
221
- const nameA = parseLabel(labelA).name;
222
- matrix[nameA] = {};
223
- entries.forEach(([labelB]) => {
224
- const nameB = parseLabel(labelB).name;
225
- const sim = similarityFn(history2.get(labelA), history2.get(labelB));
226
- matrix[nameA][nameB] = sim > threshold ? `\u274C ${(sim * 100).toFixed(0)}%` : `\u2705`;
204
+ if (isWeb) {
205
+ console.group(`%c \u{1F4CA} BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);
206
+ console.log(
207
+ `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,
208
+ STYLES.bold,
209
+ `color: ${efficiency > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
210
+ "color: #636e72; font-style: italic;"
211
+ );
212
+ if (clusters.length > 0) {
213
+ console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
214
+ clusters.forEach((cluster, idx) => {
215
+ const names = cluster.map((l) => parseLabel(l).name).join(" \u27F7 ");
216
+ console.log(` %c${idx + 1}%c ${names}`, "background: #e17055; color: white; border-radius: 50%; padding: 0 5px;", "font-family: monospace;");
227
217
  });
228
- });
229
- console.table(matrix);
218
+ } else {
219
+ console.log("%c\u2728 All state variables are linearly independent. Your Basis is optimal.", "color: #00b894; font-weight: bold; margin-top: 10px;");
220
+ }
221
+ if (totalVars > 0 && totalVars < 15) {
222
+ console.groupCollapsed("%cView Full Correlation Matrix", "color: #636e72; font-size: 11px;");
223
+ const matrix = {};
224
+ entries.forEach(([labelA]) => {
225
+ const nameA = parseLabel(labelA).name;
226
+ matrix[nameA] = {};
227
+ entries.forEach(([labelB]) => {
228
+ const nameB = parseLabel(labelB).name;
229
+ const sim = similarityFn(history2.get(labelA), history2.get(labelB));
230
+ matrix[nameA][nameB] = sim > threshold ? `\u274C ${(sim * 100).toFixed(0)}%` : `\u2705`;
231
+ });
232
+ });
233
+ console.table(matrix);
234
+ console.groupEnd();
235
+ }
230
236
  console.groupEnd();
231
237
  } else {
232
- console.log("%c[Note] Matrix hidden due to high dimensionality. Focus on clusters above.", "color: #636e72; font-size: 10px; font-style: italic;");
238
+ console.log(`[BASIS HEALTH] Efficiency: ${efficiency.toFixed(1)}% (Rank: ${systemRank}/${totalVars})`);
239
+ if (clusters.length > 0) {
240
+ console.log(`Redundancy Clusters: ${clusters.length}`);
241
+ }
233
242
  }
234
- console.groupEnd();
235
243
  };
236
244
 
237
245
  // src/core/math.ts
@@ -347,23 +355,27 @@ function useState(initialValue, label) {
347
355
  }, [effectiveLabel]);
348
356
  return [val, setter];
349
357
  }
350
- function useMemo(factory, deps, label) {
351
- const effectiveLabel = label || "anonymous_projection";
358
+ function useMemo(factory, depsOrLabel, label) {
359
+ const isLabelAsSecondArg = typeof depsOrLabel === "string";
360
+ const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
361
+ const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_projection";
352
362
  (0, import_react.useEffect)(() => {
353
363
  if (window._basis_debug !== false) {
354
364
  console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
355
365
  }
356
366
  }, [effectiveLabel]);
357
- return (0, import_react.useMemo)(factory, deps || []);
367
+ return (0, import_react.useMemo)(factory, actualDeps || []);
358
368
  }
359
- function useEffect(effect, deps, label) {
360
- const effectiveLabel = label || "anonymous_effect";
369
+ function useEffect(effect, depsOrLabel, label) {
370
+ const isLabelAsSecondArg = typeof depsOrLabel === "string";
371
+ const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
372
+ const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_effect";
361
373
  (0, import_react.useEffect)(() => {
362
374
  beginEffectTracking(effectiveLabel);
363
375
  const cleanup = effect();
364
376
  endEffectTracking();
365
377
  return cleanup;
366
- }, deps);
378
+ }, actualDeps);
367
379
  }
368
380
  function useReducer(reducer, initialArg, init, label) {
369
381
  const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
@@ -404,13 +416,14 @@ var __test__ = {
404
416
  var import_react2 = require("react");
405
417
  var import_jsx_runtime = require("react/jsx-runtime");
406
418
  var BasisContext = (0, import_react2.createContext)({ debug: false });
419
+ var isWeb2 = typeof window !== "undefined" && typeof window.document !== "undefined";
407
420
  var BasisProvider = ({ children, debug = true }) => {
408
- if (typeof window !== "undefined") {
421
+ if (isWeb2) {
409
422
  window._basis_debug = debug;
410
423
  }
411
424
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(BasisContext.Provider, { value: { debug }, children: [
412
425
  children,
413
- debug && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: {
426
+ debug && isWeb2 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: {
414
427
  position: "fixed",
415
428
  bottom: 10,
416
429
  right: 10,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/core/logger.ts","../src/core/math.ts","../src/core/constants.ts","../src/engine.ts","../src/hooks.ts","../src/context.tsx"],"sourcesContent":["// src/index.ts\n\nexport * from './engine';\nexport * from './hooks';\nexport * from './context';\nexport type { \n ReactNode, \n ReactElement, \n FC, \n PropsWithChildren, \n Context,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties\n} from 'react';","// src/core/logger.ts\n\nconst STYLES = {\n // Brand Colors\n basis: \"background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;\",\n version: \"background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;\",\n\n // Headers\n headerRed: \"background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerBlue: \"background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerGreen: \"background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n\n // Elements\n label: \"background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;\",\n location: \"color: #0984e3; font-family: monospace; font-weight: bold;\",\n math: \"color: #636e72; font-style: italic; font-family: serif;\",\n\n // Code Block\n codeBlock: `\n background: #1e1e1e; \n color: #9cdcfe; \n padding: 8px 12px; \n display: block; \n margin: 4px 0; \n border-left: 3px solid #00b894; \n font-family: 'Fira Code', monospace; \n line-height: 1.4; \n border-radius: 0 3px 3px 0;\n `,\n\n // Highlights\n dim: \"color: #e84393; font-weight: bold;\",\n bold: \"font-weight: bold;\"\n};\n\nconst parseLabel = (label: string) => {\n const parts = label.split(' -> ');\n return {\n file: parts[0] || \"Unknown\",\n name: parts[1] || label\n };\n};\n\nexport const displayBootLog = (windowSize: number) => {\n console.log(\n `%cBasis%cAuditor v0.1.0%c Monitoring State Space | Window: ${windowSize} ticks`,\n STYLES.basis,\n STYLES.version,\n \"color: #636e72; font-style: italic; margin-left: 8px;\"\n );\n};\n\nexport const displayRedundancyAlert = (labelA: string, labelB: string, sim: number, totalDimensions: number) => {\n const infoA = parseLabel(labelA);\n const infoB = parseLabel(labelB);\n const isCrossFile = infoA.file !== infoB.file;\n\n console.group(`%c πŸ“ BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);\n\n console.log(`%cπŸ“ Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);\n\n console.log(\n `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n\n console.log(\n `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:\n%c// πŸ› οΈ Basis Fix: Remove useState, use useMemo\nconst ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n\n console.groupCollapsed(`%c πŸ”¬ Proof Details `, \"color: #636e72; font-size: 10px; cursor: pointer;\");\n console.table({\n \"Similarity\": `${(sim * 100).toFixed(2)}%`,\n \"Linear Dependency\": \"TRUE\",\n \"Rank\": totalDimensions - 1\n });\n console.groupEnd();\n console.groupEnd();\n};\n\nexport const displayCausalHint = (targetLabel: string, sourceLabel: string) => {\n const target = parseLabel(targetLabel);\n const source = parseLabel(sourceLabel);\n\n const isCrossFile = target.file !== source.file;\n const locationPath = isCrossFile\n ? `${source.file} βž” ${target.file}`\n : target.file;\n\n console.groupCollapsed(`%c πŸ’‘ BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);\n\n console.log(`%cπŸ“ Location: %c${locationPath}`, STYLES.bold, STYLES.location);\n\n console.log(\n `%cSequence:%c %c${source.name}%c βž” Effect βž” %c${target.name}%c`,\n STYLES.bold, \"\",\n STYLES.label, \"\",\n STYLES.label, \"\"\n );\n\n console.log(\n `%cObservation:%c Variable %c${target.name}%c is being manually synchronized.\nThis creates a %c\"Double Render Cycle\"%c.`,\n STYLES.bold, \"\", STYLES.label, \"\",\n \"color: #d63031; font-weight: bold;\", \"\"\n );\n\n console.log(\n `%cHow to fix:%c Use %cuseMemo%c to calculate %c${target.name}%c during render:\n%cconst ${target.name} = useMemo(() => computeFrom(${source.name.includes('effect') ? 'source' : source.name}), [${source.name.includes('effect') ? 'source' : source.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #0984e3; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n\n console.groupEnd();\n};\n\nexport const displayInfiniteLoop = (label: string) => {\n const info = parseLabel(label);\n console.group(`%c πŸ›‘ BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);\n console.error(\n `Infinite oscillation detected on: %c${info.name}%c\nExecution halted to prevent browser thread lock. Check your dependency arrays.`,\n \"color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;\", \"\"\n );\n console.groupEnd();\n};\n\nexport const displayHealthReport = (\n history: Map<string, number[]>,\n similarityFn: (A: number[], B: number[]) => number,\n threshold: number\n) => {\n const entries = Array.from(history.entries());\n const totalVars = entries.length;\n if (totalVars === 0) return;\n\n const clusters: string[][] = [];\n const processed = new Set<string>();\n let independentCount = 0;\n\n entries.forEach(([labelA, vecA]) => {\n if (processed.has(labelA)) return;\n\n const currentCluster = [labelA];\n processed.add(labelA);\n\n entries.forEach(([labelB, vecB]) => {\n if (labelA === labelB || processed.has(labelB)) return;\n\n const sim = similarityFn(vecA, vecB);\n if (sim > threshold) {\n currentCluster.push(labelB);\n processed.add(labelB);\n }\n });\n\n if (currentCluster.length > 1) {\n clusters.push(currentCluster);\n } else {\n independentCount++;\n }\n });\n\n const systemRank = independentCount + clusters.length;\n const efficiency = (systemRank / totalVars) * 100;\n\n console.group(`%c πŸ“Š BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);\n\n console.log(\n `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,\n STYLES.bold,\n `color: ${efficiency > 85 ? '#00b894' : '#d63031'}; font-size: 16px; font-weight: bold;`,\n \"color: #636e72; font-style: italic;\"\n );\n\n if (clusters.length > 0) {\n console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, \"font-weight: bold; color: #e17055; margin-top: 10px;\");\n\n clusters.forEach((cluster, idx) => {\n const names = cluster.map(l => parseLabel(l).name).join(' ⟷ ');\n console.log(` %c${idx + 1}%c ${names}`, \"background: #e17055; color: white; border-radius: 50%; padding: 0 5px;\", \"font-family: monospace;\");\n });\n } else {\n console.log(\"%c✨ All state variables are linearly independent. Your Basis is optimal.\", \"color: #00b894; font-weight: bold; margin-top: 10px;\");\n }\n\n if (totalVars > 0 && totalVars < 15) {\n console.groupCollapsed(\"%cView Full Correlation Matrix\", \"color: #636e72; font-size: 11px;\");\n const matrix: any = {};\n entries.forEach(([labelA]) => {\n const nameA = parseLabel(labelA).name;\n matrix[nameA] = {};\n entries.forEach(([labelB]) => {\n const nameB = parseLabel(labelB).name;\n const sim = similarityFn(history.get(labelA)!, history.get(labelB)!);\n matrix[nameA][nameB] = sim > threshold ? `❌ ${(sim * 100).toFixed(0)}%` : `βœ…`;\n });\n });\n console.table(matrix);\n console.groupEnd();\n } else {\n console.log(\"%c[Note] Matrix hidden due to high dimensionality. Focus on clusters above.\", \"color: #636e72; font-size: 10px; font-style: italic;\");\n }\n\n console.groupEnd();\n};","// src/core/math.ts\n\nexport const calculateCosineSimilarity = (A: number[], B: number[]): number => {\n let dot = 0, magA = 0, magB = 0;\n for (let i = 0; i < A.length; i++) {\n dot += A[i] * B[i];\n magA += A[i] * A[i];\n magB += B[i] * B[i];\n }\n return magA && magB ? dot / (Math.sqrt(magA) * Math.sqrt(magB)) : 0;\n};","// src/core/constants.ts\n\nexport const WINDOW_SIZE = 50;\nexport const SIMILARITY_THRESHOLD = 0.88;\nexport const LOOP_THRESHOLD = 25;\nexport const LOOP_WINDOW_MS = 500;\nexport const ANALYSIS_INTERVAL = 5;","// src/engine.ts\n\nimport * as UI from './core/logger';\nimport { calculateCosineSimilarity } from './core/math';\nimport { \n WINDOW_SIZE, \n SIMILARITY_THRESHOLD, \n LOOP_THRESHOLD, \n LOOP_WINDOW_MS, \n ANALYSIS_INTERVAL \n} from './core/constants';\n\nexport const history = new Map<string, number[]>();\nexport const currentTickBatch = new Set<string>();\nlet updateLog: { label: string; ts: number }[] = [];\nlet currentEffectSource: string | null = null; \nlet tick = 0;\nlet isBatching = false;\n\nUI.displayBootLog(WINDOW_SIZE);\n\nconst analyzeBasis = () => {\n const entries = Array.from(history.entries());\n if (entries.length < 2) return;\n\n entries.forEach(([labelA, vecA], i) => {\n entries.slice(i + 1).forEach(([labelB, vecB]) => {\n const sim = calculateCosineSimilarity(vecA, vecB);\n \n if (sim > SIMILARITY_THRESHOLD) {\n UI.displayRedundancyAlert(labelA, labelB, sim, history.size);\n }\n });\n });\n};\n\nexport const printBasisHealthReport = (threshold = 0.5) => {\n UI.displayHealthReport(history, calculateCosineSimilarity, threshold);\n};\n\nexport const beginEffectTracking = (label: string) => { currentEffectSource = label; };\nexport const endEffectTracking = () => { currentEffectSource = null; };\n\nexport const registerVariable = (label: string) => {\n if (!history.has(label)) {\n history.set(label, new Array(WINDOW_SIZE).fill(0));\n }\n};\n\nexport const unregisterVariable = (label: string) => {\n history.delete(label);\n};\n\nexport const recordUpdate = (label: string): boolean => {\n const now = Date.now();\n\n updateLog.push({ label, ts: now });\n updateLog = updateLog.filter(e => now - e.ts < LOOP_WINDOW_MS);\n if (updateLog.filter(e => e.label === label).length > LOOP_THRESHOLD) {\n UI.displayInfiniteLoop(label);\n return false;\n }\n\n if (currentEffectSource && currentEffectSource !== label) {\n UI.displayCausalHint(label, currentEffectSource);\n }\n\n currentTickBatch.add(label);\n\n if (!isBatching) {\n isBatching = true;\n setTimeout(() => {\n tick++;\n history.forEach((vec, l) => {\n vec.shift();\n vec.push(currentTickBatch.has(l) ? 1 : 0);\n });\n\n currentTickBatch.clear();\n isBatching = false;\n \n if (tick % ANALYSIS_INTERVAL === 0) {\n analyzeBasis();\n }\n }, 20);\n }\n\n return true;\n};\n\nif (typeof window !== 'undefined') {\n (window as any).printBasisReport = printBasisHealthReport;\n}\n\nexport const __testEngine__ = {\n history,\n currentTickBatch,\n registerVariable,\n recordUpdate,\n printBasisHealthReport,\n beginEffectTracking,\n endEffectTracking,\n};","// src/hooks.ts\n\nimport { \n useState as reactUseState, \n useEffect as reactUseEffect, \n useMemo as reactUseMemo, \n useReducer as reactUseReducer,\n useContext as reactUseContext,\n createContext as reactCreateContext,\n useCallback \n} from 'react';\n\nimport type { \n Reducer, \n Context,\n Dispatch,\n SetStateAction,\n DependencyList,\n EffectCallback\n} from 'react';\n\nimport { \n registerVariable, \n unregisterVariable, \n recordUpdate, \n beginEffectTracking, \n endEffectTracking \n} from './engine';\n\nimport * as engine from './engine';\n\nexport type { \n ReactNode, \n FC, \n PropsWithChildren, \n Context, \n ReactElement,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties,\n EffectCallback,\n DependencyList\n} from 'react';\n\nexport function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>] {\n const [val, setVal] = reactUseState(initialValue);\n const effectiveLabel = label || 'anonymous_state';\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const setter = useCallback((newValue: SetStateAction<T>) => {\n if (recordUpdate(effectiveLabel)) {\n setVal(newValue);\n }\n }, [effectiveLabel]);\n\n return [val, setter];\n}\n\nexport function useMemo<T>(factory: () => T, deps: DependencyList | undefined, label?: string): T {\n const effectiveLabel = label || 'anonymous_projection';\n \n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Valid Projection: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseMemo(factory, deps || []);\n}\n\nexport function useEffect(effect: EffectCallback, deps?: DependencyList, label?: string) {\n const effectiveLabel = label || 'anonymous_effect';\n\n reactUseEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, deps);\n}\n\nexport function useReducer<S, A, I>(\n reducer: Reducer<S, A>,\n initialArg: I & S,\n init?: any,\n label?: string\n): [S, Dispatch<A>] {\n\n const effectiveLabel = typeof init === 'string' ? init : (label || 'anonymous_reducer');\n\n const reactInit = typeof init === 'function' ? init : undefined;\n\n const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const basisDispatch = useCallback((action: A) => {\n if (recordUpdate(effectiveLabel)) {\n dispatch(action);\n }\n }, [effectiveLabel]);\n\n return [state, basisDispatch];\n}\n\nexport function createContext<T>(defaultValue: T, label?: string): Context<T> {\n const context = reactCreateContext(defaultValue);\n if (label) {\n (context as any)._basis_label = label;\n }\n return context;\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport const __test__ = {\n registerVariable,\n unregisterVariable,\n recordUpdate,\n beginEffectTracking,\n endEffectTracking,\n history: (engine as any).history,\n currentTickBatch: (engine as any).currentTickBatch\n};","// src/context.tsx\n\nimport React, { createContext, useContext, ReactNode } from 'react';\n\nconst BasisContext = createContext({ debug: false });\n\ninterface BasisProviderProps {\n children: ReactNode;\n debug?: boolean;\n}\n\nexport const BasisProvider: React.FC<BasisProviderProps> = ({ children, debug = true }) => {\n if (typeof window !== 'undefined') {\n (window as any)._basis_debug = debug;\n }\n\n return (\n <BasisContext.Provider value={{ debug }}>\n {children}\n {debug && (\n <div style={{ \n position: 'fixed', bottom: 10, right: 10, background: 'black', color: '#0f0', \n padding: '5px 10px', fontSize: '10px', fontFamily: 'monospace', \n border: '1px solid #0f0', zIndex: 99999, borderRadius: '4px', pointerEvents: 'none'\n }}>\n BASIS_ENGINE: ACTIVE\n </div>\n )}\n </BasisContext.Prov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OAAO,aAAa;AAC9B;AAEO,SAAS,cAAiB,cAAiB,OAA4B;AAC5E,QAAM,cAAU,aAAAG,eAAmB,YAAY;AAC/C,MAAI,OAAO;AACT,IAAC,QAAgB,eAAe;AAAA,EAClC;AACA,SAAO;AACT;AAEO,SAAS,WAAc,SAAwB;AACpD,aAAO,aAAAC,YAAgB,OAAO;AAChC;AAEO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACnIA,IAAAC,gBAA4D;AAexD;AAbJ,IAAM,mBAAe,6BAAc,EAAE,OAAO,MAAM,CAAC;AAO5C,IAAM,gBAA8C,CAAC,EAAE,UAAU,QAAQ,KAAK,MAAM;AACzF,MAAI,OAAO,WAAW,aAAa;AACjC,IAAC,OAAe,eAAe;AAAA,EACjC;AAEA,SACE,6CAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC;AAAA;AAAA,IACA,SACC,4CAAC,SAAI,OAAO;AAAA,MACV,UAAU;AAAA,MAAS,QAAQ;AAAA,MAAI,OAAO;AAAA,MAAI,YAAY;AAAA,MAAS,OAAO;AAAA,MACtE,SAAS;AAAA,MAAY,UAAU;AAAA,MAAQ,YAAY;AAAA,MACnD,QAAQ;AAAA,MAAkB,QAAQ;AAAA,MAAO,cAAc;AAAA,MAAO,eAAe;AAAA,IAC/E,GAAG,kCAEH;AAAA,KAEJ;AAEJ;AAEO,IAAM,iBAAiB,UAAM,0BAAW,YAAY;","names":["history","reactUseState","reactUseEffect","reactUseMemo","reactUseReducer","reactCreateContext","reactUseContext","import_react"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/core/logger.ts","../src/core/math.ts","../src/core/constants.ts","../src/engine.ts","../src/hooks.ts","../src/context.tsx"],"sourcesContent":["// src/index.ts\n\nexport * from './engine';\nexport * from './hooks';\nexport * from './context';\nexport type { \n ReactNode, \n ReactElement, \n FC, \n PropsWithChildren, \n Context,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties\n} from 'react';","// src/core/logger.ts\n\nconst isWeb = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nconst STYLES = {\n basis: \"background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;\",\n version: \"background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;\",\n\n headerRed: \"background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerBlue: \"background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerGreen: \"background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n\n label: \"background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;\",\n location: \"color: #0984e3; font-family: monospace; font-weight: bold;\",\n math: \"color: #636e72; font-style: italic; font-family: serif;\",\n\n codeBlock: `\n background: #1e1e1e; \n color: #9cdcfe; \n padding: 8px 12px; \n display: block; \n margin: 4px 0; \n border-left: 3px solid #00b894; \n font-family: 'Fira Code', monospace; \n line-height: 1.4; \n border-radius: 0 3px 3px 0;\n `,\n\n dim: \"color: #e84393; font-weight: bold;\",\n bold: \"font-weight: bold;\"\n};\n\nconst parseLabel = (label: string) => {\n const parts = label.split(' -> ');\n return {\n file: parts[0] || \"Unknown\",\n name: parts[1] || label\n };\n};\n\nconst logBasis = (message: string, ...styles: string[]) => {\n if (isWeb) {\n console.log(message, ...styles);\n } else {\n console.log(message.replace(/%c/g, ''));\n }\n};\n\nexport const displayBootLog = (windowSize: number) => {\n logBasis(\n `%cBasis%cAuditor v0.1.4%c Monitoring State Space | Window: ${windowSize} ticks`,\n STYLES.basis,\n STYLES.version,\n \"color: #636e72; font-style: italic; margin-left: 8px;\"\n );\n};\n\nexport const displayRedundancyAlert = (labelA: string, labelB: string, sim: number, totalDimensions: number) => {\n const infoA = parseLabel(labelA);\n const infoB = parseLabel(labelB);\n const isCrossFile = infoA.file !== infoB.file;\n\n if (isWeb) {\n console.group(`%c πŸ“ BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);\n console.log(`%cπŸ“ Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);\n console.log(\n `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n console.log(\n `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:\n%c// πŸ› οΈ Basis Fix: Remove useState, use useMemo\nconst ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n console.groupCollapsed(`%c πŸ”¬ Proof Details `, \"color: #636e72; font-size: 10px; cursor: pointer;\");\n console.table({\n \"Similarity\": `${(sim * 100).toFixed(2)}%`,\n \"Linear Dependency\": \"TRUE\",\n \"Rank\": totalDimensions - 1\n });\n console.groupEnd();\n console.groupEnd();\n } else {\n console.log(`[BASIS] REDUNDANCY DETECTED: ${infoA.name} <-> ${infoB.name} (${(sim * 100).toFixed(0)}% similarity)`);\n console.log(`Location: ${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`);\n }\n};\n\nexport const displayCausalHint = (targetLabel: string, sourceLabel: string) => {\n const target = parseLabel(targetLabel);\n const source = parseLabel(sourceLabel);\n\n const isCrossFile = target.file !== source.file;\n const locationPath = isCrossFile\n ? `${source.file} βž” ${target.file}`\n : target.file;\n\n if (isWeb) {\n console.groupCollapsed(`%c πŸ’‘ BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);\n console.log(`%cπŸ“ Location: %c${locationPath}`, STYLES.bold, STYLES.location);\n console.log(\n `%cSequence:%c %c${source.name}%c βž” Effect βž” %c${target.name}%c`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n console.log(\n `%cObservation:%c Variable %c${target.name}%c is being manually synchronized. This creates a %c\"Double Render Cycle\"%c.`,\n STYLES.bold, \"\", STYLES.label, \"\", \"color: #d63031; font-weight: bold;\", \"\"\n );\n console.groupEnd();\n } else {\n console.log(`[BASIS] CAUSALITY: ${source.name} βž” ${target.name} (Double Render Cycle)`);\n }\n};\n\nexport const displayInfiniteLoop = (label: string) => {\n const info = parseLabel(label);\n if (isWeb) {\n console.group(`%c πŸ›‘ BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);\n console.error(\n `Infinite oscillation detected on: %c${info.name}%c\\nExecution halted to prevent browser thread lock.`,\n \"color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;\", \"\"\n );\n console.groupEnd();\n } else {\n console.log(`[BASIS CRITICAL] INFINITE LOOP ON: ${info.name}. Execution halted.`);\n }\n};\n\nexport const displayHealthReport = (\n history: Map<string, number[]>,\n similarityFn: (A: number[], B: number[]) => number,\n threshold: number\n) => {\n const entries = Array.from(history.entries());\n const totalVars = entries.length;\n if (totalVars === 0) return;\n\n const clusters: string[][] = [];\n const processed = new Set<string>();\n let independentCount = 0;\n\n entries.forEach(([labelA, vecA]) => {\n if (processed.has(labelA)) return;\n const currentCluster = [labelA];\n processed.add(labelA);\n entries.forEach(([labelB, vecB]) => {\n if (labelA === labelB || processed.has(labelB)) return;\n const sim = similarityFn(vecA, vecB);\n if (sim > threshold) {\n currentCluster.push(labelB);\n processed.add(labelB);\n }\n });\n if (currentCluster.length > 1) {\n clusters.push(currentCluster);\n } else {\n independentCount++;\n }\n });\n\n const systemRank = independentCount + clusters.length;\n const efficiency = (systemRank / totalVars) * 100;\n\n if (isWeb) {\n console.group(`%c πŸ“Š BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);\n console.log(\n `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,\n STYLES.bold,\n `color: ${efficiency > 85 ? '#00b894' : '#d63031'}; font-size: 16px; font-weight: bold;`,\n \"color: #636e72; font-style: italic;\"\n );\n\n if (clusters.length > 0) {\n console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, \"font-weight: bold; color: #e17055; margin-top: 10px;\");\n clusters.forEach((cluster, idx) => {\n const names = cluster.map(l => parseLabel(l).name).join(' ⟷ ');\n console.log(` %c${idx + 1}%c ${names}`, \"background: #e17055; color: white; border-radius: 50%; padding: 0 5px;\", \"font-family: monospace;\");\n });\n } else {\n console.log(\"%c✨ All state variables are linearly independent. Your Basis is optimal.\", \"color: #00b894; font-weight: bold; margin-top: 10px;\");\n }\n\n if (totalVars > 0 && totalVars < 15) {\n console.groupCollapsed(\"%cView Full Correlation Matrix\", \"color: #636e72; font-size: 11px;\");\n const matrix: any = {};\n entries.forEach(([labelA]) => {\n const nameA = parseLabel(labelA).name;\n matrix[nameA] = {};\n entries.forEach(([labelB]) => {\n const nameB = parseLabel(labelB).name;\n const sim = similarityFn(history.get(labelA)!, history.get(labelB)!);\n matrix[nameA][nameB] = sim > threshold ? `❌ ${(sim * 100).toFixed(0)}%` : `βœ…`;\n });\n });\n console.table(matrix);\n console.groupEnd();\n }\n console.groupEnd();\n } else {\n console.log(`[BASIS HEALTH] Efficiency: ${efficiency.toFixed(1)}% (Rank: ${systemRank}/${totalVars})`);\n if (clusters.length > 0) {\n console.log(`Redundancy Clusters: ${clusters.length}`);\n }\n }\n};","// src/core/math.ts\n\nexport const calculateCosineSimilarity = (A: number[], B: number[]): number => {\n let dot = 0, magA = 0, magB = 0;\n for (let i = 0; i < A.length; i++) {\n dot += A[i] * B[i];\n magA += A[i] * A[i];\n magB += B[i] * B[i];\n }\n return magA && magB ? dot / (Math.sqrt(magA) * Math.sqrt(magB)) : 0;\n};","// src/core/constants.ts\n\nexport const WINDOW_SIZE = 50;\nexport const SIMILARITY_THRESHOLD = 0.88;\nexport const LOOP_THRESHOLD = 25;\nexport const LOOP_WINDOW_MS = 500;\nexport const ANALYSIS_INTERVAL = 5;","// src/engine.ts\n\nimport * as UI from './core/logger';\nimport { calculateCosineSimilarity } from './core/math';\nimport { \n WINDOW_SIZE, \n SIMILARITY_THRESHOLD, \n LOOP_THRESHOLD, \n LOOP_WINDOW_MS, \n ANALYSIS_INTERVAL \n} from './core/constants';\n\nexport const history = new Map<string, number[]>();\nexport const currentTickBatch = new Set<string>();\nlet updateLog: { label: string; ts: number }[] = [];\nlet currentEffectSource: string | null = null; \nlet tick = 0;\nlet isBatching = false;\n\nUI.displayBootLog(WINDOW_SIZE);\n\nconst analyzeBasis = () => {\n const entries = Array.from(history.entries());\n if (entries.length < 2) return;\n\n entries.forEach(([labelA, vecA], i) => {\n entries.slice(i + 1).forEach(([labelB, vecB]) => {\n const sim = calculateCosineSimilarity(vecA, vecB);\n \n if (sim > SIMILARITY_THRESHOLD) {\n UI.displayRedundancyAlert(labelA, labelB, sim, history.size);\n }\n });\n });\n};\n\nexport const printBasisHealthReport = (threshold = 0.5) => {\n UI.displayHealthReport(history, calculateCosineSimilarity, threshold);\n};\n\nexport const beginEffectTracking = (label: string) => { currentEffectSource = label; };\nexport const endEffectTracking = () => { currentEffectSource = null; };\n\nexport const registerVariable = (label: string) => {\n if (!history.has(label)) {\n history.set(label, new Array(WINDOW_SIZE).fill(0));\n }\n};\n\nexport const unregisterVariable = (label: string) => {\n history.delete(label);\n};\n\nexport const recordUpdate = (label: string): boolean => {\n const now = Date.now();\n\n updateLog.push({ label, ts: now });\n updateLog = updateLog.filter(e => now - e.ts < LOOP_WINDOW_MS);\n if (updateLog.filter(e => e.label === label).length > LOOP_THRESHOLD) {\n UI.displayInfiniteLoop(label);\n return false;\n }\n\n if (currentEffectSource && currentEffectSource !== label) {\n UI.displayCausalHint(label, currentEffectSource);\n }\n\n currentTickBatch.add(label);\n\n if (!isBatching) {\n isBatching = true;\n setTimeout(() => {\n tick++;\n history.forEach((vec, l) => {\n vec.shift();\n vec.push(currentTickBatch.has(l) ? 1 : 0);\n });\n\n currentTickBatch.clear();\n isBatching = false;\n \n if (tick % ANALYSIS_INTERVAL === 0) {\n analyzeBasis();\n }\n }, 20);\n }\n\n return true;\n};\n\nif (typeof window !== 'undefined') {\n (window as any).printBasisReport = printBasisHealthReport;\n}\n\nexport const __testEngine__ = {\n history,\n currentTickBatch,\n registerVariable,\n recordUpdate,\n printBasisHealthReport,\n beginEffectTracking,\n endEffectTracking,\n};","// src/hooks.ts\n\nimport { \n useState as reactUseState, \n useEffect as reactUseEffect, \n useMemo as reactUseMemo, \n useReducer as reactUseReducer,\n useContext as reactUseContext,\n createContext as reactCreateContext,\n useCallback \n} from 'react';\n\nimport type { \n Reducer, \n Context,\n Dispatch,\n SetStateAction,\n DependencyList,\n EffectCallback\n} from 'react';\n\nimport { \n registerVariable, \n unregisterVariable, \n recordUpdate, \n beginEffectTracking, \n endEffectTracking \n} from './engine';\n\nimport * as engine from './engine';\n\nexport type { \n ReactNode, \n FC, \n PropsWithChildren, \n Context, \n ReactElement,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties,\n EffectCallback,\n DependencyList\n} from 'react';\n\nexport function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>] {\n const [val, setVal] = reactUseState(initialValue);\n const effectiveLabel = label || 'anonymous_state';\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const setter = useCallback((newValue: SetStateAction<T>) => {\n if (recordUpdate(effectiveLabel)) {\n setVal(newValue);\n }\n }, [effectiveLabel]);\n\n return [val, setter];\n}\n\nexport function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n \n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_projection');\n \n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Valid Projection: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseMemo(factory, actualDeps || []);\n}\n\nexport function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string) {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n \n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_effect');\n\n reactUseEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, actualDeps);\n}\n\nexport function useReducer<S, A, I>(\n reducer: Reducer<S, A>,\n initialArg: I & S,\n init?: any,\n label?: string\n): [S, Dispatch<A>] {\n\n const effectiveLabel = typeof init === 'string' ? init : (label || 'anonymous_reducer');\n\n const reactInit = typeof init === 'function' ? init : undefined;\n\n const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const basisDispatch = useCallback((action: A) => {\n if (recordUpdate(effectiveLabel)) {\n dispatch(action);\n }\n }, [effectiveLabel]);\n\n return [state, basisDispatch];\n}\n\nexport function createContext<T>(defaultValue: T, label?: string): Context<T> {\n const context = reactCreateContext(defaultValue);\n if (label) {\n (context as any)._basis_label = label;\n }\n return context;\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport const __test__ = {\n registerVariable,\n unregisterVariable,\n recordUpdate,\n beginEffectTracking,\n endEffectTracking,\n history: (engine as any).history,\n currentTickBatch: (engine as any).currentTickBatch\n};","// src/context.tsx\nimport React, { createContext, useContext, ReactNode } from 'react';\n\nconst BasisContext = createContext({ debug: false });\n\nconst isWeb = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\ninterface BasisProviderProps {\n children: ReactNode;\n debug?: boolean;\n}\n\nexport const BasisProvider: React.FC<BasisProviderProps> = ({ children, debug = true }) => {\n if (isWeb) {\n (window as any)._basis_debug = debug;\n }\n\n return (\n <BasisContext.Provider value={{ debug }}>\n {children}\n {(debug && isWeb) && (\n <div style={{ \n position: 'fixed', bottom: 10, right: 10, background: 'black', color: '#0f0', \n padding: '5px 10px', fontSize: '10px', fontFamily: 'monospace', \n border: '1px solid #0f0', zIndex: 99999, borderRadius: '4px', pointerEvents: 'none'\n }}>\n BASIS_ENGINE: ACTIVE\n </div>\n )}\n </BasisContext.Provider>\n );\n};\n\nexport const useBasisConfig = () => useContext(BasisContext);"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,IAAM,QAAQ,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AAE1E,IAAM,SAAS;AAAA,EACb,OAAO;AAAA,EACP,SAAS;AAAA,EAET,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;AAAA,EAEb,OAAO;AAAA,EACP,UAAU;AAAA,EACV,MAAM;AAAA,EAEN,WAAW;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYX,KAAK;AAAA,EACL,MAAM;AACR;AAEA,IAAM,aAAa,CAAC,UAAkB;AACpC,QAAM,QAAQ,MAAM,MAAM,MAAM;AAChC,SAAO;AAAA,IACL,MAAM,MAAM,CAAC,KAAK;AAAA,IAClB,MAAM,MAAM,CAAC,KAAK;AAAA,EACpB;AACF;AAEA,IAAM,WAAW,CAAC,YAAoB,WAAqB;AACzD,MAAI,OAAO;AACT,YAAQ,IAAI,SAAS,GAAG,MAAM;AAAA,EAChC,OAAO;AACL,YAAQ,IAAI,QAAQ,QAAQ,OAAO,EAAE,CAAC;AAAA,EACxC;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AAEO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC1IA,IAAAC,gBAA4D;AAiBxD;AAfJ,IAAM,mBAAe,6BAAc,EAAE,OAAO,MAAM,CAAC;AAEnD,IAAMC,SAAQ,OAAO,WAAW,eAAe,OAAO,OAAO,aAAa;AAOnE,IAAM,gBAA8C,CAAC,EAAE,UAAU,QAAQ,KAAK,MAAM;AACzF,MAAIA,QAAO;AACT,IAAC,OAAe,eAAe;AAAA,EACjC;AAEA,SACE,6CAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC;AAAA;AAAA,IACC,SAASA,UACT,4CAAC,SAAI,OAAO;AAAA,MACV,UAAU;AAAA,MAAS,QAAQ;AAAA,MAAI,OAAO;AAAA,MAAI,YAAY;AAAA,MAAS,OAAO;AAAA,MACtE,SAAS;AAAA,MAAY,UAAU;AAAA,MAAQ,YAAY;AAAA,MACnD,QAAQ;AAAA,MAAkB,QAAQ;AAAA,MAAO,cAAc;AAAA,MAAO,eAAe;AAAA,IAC/E,GAAG,kCAEH;AAAA,KAEJ;AAEJ;AAEO,IAAM,iBAAiB,UAAM,0BAAW,YAAY;","names":["history","reactUseState","reactUseEffect","reactUseMemo","reactUseReducer","reactCreateContext","reactUseContext","import_react","isWeb"]}
package/dist/index.mjs CHANGED
@@ -1,17 +1,14 @@
1
1
  // src/core/logger.ts
2
+ var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined";
2
3
  var STYLES = {
3
- // Brand Colors
4
4
  basis: "background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;",
5
5
  version: "background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;",
6
- // Headers
7
6
  headerRed: "background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
8
7
  headerBlue: "background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
9
8
  headerGreen: "background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;",
10
- // Elements
11
9
  label: "background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;",
12
10
  location: "color: #0984e3; font-family: monospace; font-weight: bold;",
13
11
  math: "color: #636e72; font-style: italic; font-family: serif;",
14
- // Code Block
15
12
  codeBlock: `
16
13
  background: #1e1e1e;
17
14
  color: #9cdcfe;
@@ -23,7 +20,6 @@ var STYLES = {
23
20
  line-height: 1.4;
24
21
  border-radius: 0 3px 3px 0;
25
22
  `,
26
- // Highlights
27
23
  dim: "color: #e84393; font-weight: bold;",
28
24
  bold: "font-weight: bold;"
29
25
  };
@@ -34,9 +30,16 @@ var parseLabel = (label) => {
34
30
  name: parts[1] || label
35
31
  };
36
32
  };
33
+ var logBasis = (message, ...styles) => {
34
+ if (isWeb) {
35
+ console.log(message, ...styles);
36
+ } else {
37
+ console.log(message.replace(/%c/g, ""));
38
+ }
39
+ };
37
40
  var displayBootLog = (windowSize) => {
38
- console.log(
39
- `%cBasis%cAuditor v0.1.0%c Monitoring State Space | Window: ${windowSize} ticks`,
41
+ logBasis(
42
+ `%cBasis%cAuditor v0.1.4%c Monitoring State Space | Window: ${windowSize} ticks`,
40
43
  STYLES.basis,
41
44
  STYLES.version,
42
45
  "color: #636e72; font-style: italic; margin-left: 8px;"
@@ -46,87 +49,87 @@ var displayRedundancyAlert = (labelA, labelB, sim, totalDimensions) => {
46
49
  const infoA = parseLabel(labelA);
47
50
  const infoB = parseLabel(labelB);
48
51
  const isCrossFile = infoA.file !== infoB.file;
49
- console.group(`%c \u{1F4D0} BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);
50
- console.log(`%c\u{1F4CD} Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);
51
- console.log(
52
- `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,
53
- STYLES.bold,
54
- "",
55
- STYLES.label,
56
- "",
57
- STYLES.label,
58
- ""
59
- );
60
- console.log(
61
- `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:
52
+ if (isWeb) {
53
+ console.group(`%c \u{1F4D0} BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);
54
+ console.log(`%c\u{1F4CD} Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);
55
+ console.log(
56
+ `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,
57
+ STYLES.bold,
58
+ "",
59
+ STYLES.label,
60
+ "",
61
+ STYLES.label,
62
+ ""
63
+ );
64
+ console.log(
65
+ `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:
62
66
  %c// \u{1F6E0}\uFE0F Basis Fix: Remove useState, use useMemo
63
67
  const ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,
64
- "color: #00b894; font-weight: bold;",
65
- "",
66
- "color: #e84393; font-weight: bold;",
67
- "",
68
- STYLES.codeBlock,
69
- ""
70
- );
71
- console.groupCollapsed(`%c \u{1F52C} Proof Details `, "color: #636e72; font-size: 10px; cursor: pointer;");
72
- console.table({
73
- "Similarity": `${(sim * 100).toFixed(2)}%`,
74
- "Linear Dependency": "TRUE",
75
- "Rank": totalDimensions - 1
76
- });
77
- console.groupEnd();
78
- console.groupEnd();
68
+ "color: #00b894; font-weight: bold;",
69
+ "",
70
+ "color: #e84393; font-weight: bold;",
71
+ "",
72
+ STYLES.codeBlock,
73
+ ""
74
+ );
75
+ console.groupCollapsed(`%c \u{1F52C} Proof Details `, "color: #636e72; font-size: 10px; cursor: pointer;");
76
+ console.table({
77
+ "Similarity": `${(sim * 100).toFixed(2)}%`,
78
+ "Linear Dependency": "TRUE",
79
+ "Rank": totalDimensions - 1
80
+ });
81
+ console.groupEnd();
82
+ console.groupEnd();
83
+ } else {
84
+ console.log(`[BASIS] REDUNDANCY DETECTED: ${infoA.name} <-> ${infoB.name} (${(sim * 100).toFixed(0)}% similarity)`);
85
+ console.log(`Location: ${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`);
86
+ }
79
87
  };
80
88
  var displayCausalHint = (targetLabel, sourceLabel) => {
81
89
  const target = parseLabel(targetLabel);
82
90
  const source = parseLabel(sourceLabel);
83
91
  const isCrossFile = target.file !== source.file;
84
92
  const locationPath = isCrossFile ? `${source.file} \u2794 ${target.file}` : target.file;
85
- console.groupCollapsed(`%c \u{1F4A1} BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);
86
- console.log(`%c\u{1F4CD} Location: %c${locationPath}`, STYLES.bold, STYLES.location);
87
- console.log(
88
- `%cSequence:%c %c${source.name}%c \u2794 Effect \u2794 %c${target.name}%c`,
89
- STYLES.bold,
90
- "",
91
- STYLES.label,
92
- "",
93
- STYLES.label,
94
- ""
95
- );
96
- console.log(
97
- `%cObservation:%c Variable %c${target.name}%c is being manually synchronized.
98
- This creates a %c"Double Render Cycle"%c.`,
99
- STYLES.bold,
100
- "",
101
- STYLES.label,
102
- "",
103
- "color: #d63031; font-weight: bold;",
104
- ""
105
- );
106
- console.log(
107
- `%cHow to fix:%c Use %cuseMemo%c to calculate %c${target.name}%c during render:
108
- %cconst ${target.name} = useMemo(() => computeFrom(${source.name.includes("effect") ? "source" : source.name}), [${source.name.includes("effect") ? "source" : source.name}]);%c`,
109
- "color: #00b894; font-weight: bold;",
110
- "",
111
- "color: #0984e3; font-weight: bold;",
112
- "",
113
- "color: #e84393; font-weight: bold;",
114
- "",
115
- STYLES.codeBlock,
116
- ""
117
- );
118
- console.groupEnd();
93
+ if (isWeb) {
94
+ console.groupCollapsed(`%c \u{1F4A1} BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);
95
+ console.log(`%c\u{1F4CD} Location: %c${locationPath}`, STYLES.bold, STYLES.location);
96
+ console.log(
97
+ `%cSequence:%c %c${source.name}%c \u2794 Effect \u2794 %c${target.name}%c`,
98
+ STYLES.bold,
99
+ "",
100
+ STYLES.label,
101
+ "",
102
+ STYLES.label,
103
+ ""
104
+ );
105
+ console.log(
106
+ `%cObservation:%c Variable %c${target.name}%c is being manually synchronized. This creates a %c"Double Render Cycle"%c.`,
107
+ STYLES.bold,
108
+ "",
109
+ STYLES.label,
110
+ "",
111
+ "color: #d63031; font-weight: bold;",
112
+ ""
113
+ );
114
+ console.groupEnd();
115
+ } else {
116
+ console.log(`[BASIS] CAUSALITY: ${source.name} \u2794 ${target.name} (Double Render Cycle)`);
117
+ }
119
118
  };
120
119
  var displayInfiniteLoop = (label) => {
121
120
  const info = parseLabel(label);
122
- console.group(`%c \u{1F6D1} BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);
123
- console.error(
124
- `Infinite oscillation detected on: %c${info.name}%c
125
- Execution halted to prevent browser thread lock. Check your dependency arrays.`,
126
- "color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;",
127
- ""
128
- );
129
- console.groupEnd();
121
+ if (isWeb) {
122
+ console.group(`%c \u{1F6D1} BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);
123
+ console.error(
124
+ `Infinite oscillation detected on: %c${info.name}%c
125
+ Execution halted to prevent browser thread lock.`,
126
+ "color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;",
127
+ ""
128
+ );
129
+ console.groupEnd();
130
+ } else {
131
+ console.log(`[BASIS CRITICAL] INFINITE LOOP ON: ${info.name}. Execution halted.`);
132
+ }
130
133
  };
131
134
  var displayHealthReport = (history2, similarityFn, threshold) => {
132
135
  const entries = Array.from(history2.entries());
@@ -155,40 +158,45 @@ var displayHealthReport = (history2, similarityFn, threshold) => {
155
158
  });
156
159
  const systemRank = independentCount + clusters.length;
157
160
  const efficiency = systemRank / totalVars * 100;
158
- console.group(`%c \u{1F4CA} BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);
159
- console.log(
160
- `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,
161
- STYLES.bold,
162
- `color: ${efficiency > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
163
- "color: #636e72; font-style: italic;"
164
- );
165
- if (clusters.length > 0) {
166
- console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
167
- clusters.forEach((cluster, idx) => {
168
- const names = cluster.map((l) => parseLabel(l).name).join(" \u27F7 ");
169
- console.log(` %c${idx + 1}%c ${names}`, "background: #e17055; color: white; border-radius: 50%; padding: 0 5px;", "font-family: monospace;");
170
- });
171
- } else {
172
- console.log("%c\u2728 All state variables are linearly independent. Your Basis is optimal.", "color: #00b894; font-weight: bold; margin-top: 10px;");
173
- }
174
- if (totalVars > 0 && totalVars < 15) {
175
- console.groupCollapsed("%cView Full Correlation Matrix", "color: #636e72; font-size: 11px;");
176
- const matrix = {};
177
- entries.forEach(([labelA]) => {
178
- const nameA = parseLabel(labelA).name;
179
- matrix[nameA] = {};
180
- entries.forEach(([labelB]) => {
181
- const nameB = parseLabel(labelB).name;
182
- const sim = similarityFn(history2.get(labelA), history2.get(labelB));
183
- matrix[nameA][nameB] = sim > threshold ? `\u274C ${(sim * 100).toFixed(0)}%` : `\u2705`;
161
+ if (isWeb) {
162
+ console.group(`%c \u{1F4CA} BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);
163
+ console.log(
164
+ `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,
165
+ STYLES.bold,
166
+ `color: ${efficiency > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
167
+ "color: #636e72; font-style: italic;"
168
+ );
169
+ if (clusters.length > 0) {
170
+ console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
171
+ clusters.forEach((cluster, idx) => {
172
+ const names = cluster.map((l) => parseLabel(l).name).join(" \u27F7 ");
173
+ console.log(` %c${idx + 1}%c ${names}`, "background: #e17055; color: white; border-radius: 50%; padding: 0 5px;", "font-family: monospace;");
184
174
  });
185
- });
186
- console.table(matrix);
175
+ } else {
176
+ console.log("%c\u2728 All state variables are linearly independent. Your Basis is optimal.", "color: #00b894; font-weight: bold; margin-top: 10px;");
177
+ }
178
+ if (totalVars > 0 && totalVars < 15) {
179
+ console.groupCollapsed("%cView Full Correlation Matrix", "color: #636e72; font-size: 11px;");
180
+ const matrix = {};
181
+ entries.forEach(([labelA]) => {
182
+ const nameA = parseLabel(labelA).name;
183
+ matrix[nameA] = {};
184
+ entries.forEach(([labelB]) => {
185
+ const nameB = parseLabel(labelB).name;
186
+ const sim = similarityFn(history2.get(labelA), history2.get(labelB));
187
+ matrix[nameA][nameB] = sim > threshold ? `\u274C ${(sim * 100).toFixed(0)}%` : `\u2705`;
188
+ });
189
+ });
190
+ console.table(matrix);
191
+ console.groupEnd();
192
+ }
187
193
  console.groupEnd();
188
194
  } else {
189
- console.log("%c[Note] Matrix hidden due to high dimensionality. Focus on clusters above.", "color: #636e72; font-size: 10px; font-style: italic;");
195
+ console.log(`[BASIS HEALTH] Efficiency: ${efficiency.toFixed(1)}% (Rank: ${systemRank}/${totalVars})`);
196
+ if (clusters.length > 0) {
197
+ console.log(`Redundancy Clusters: ${clusters.length}`);
198
+ }
190
199
  }
191
- console.groupEnd();
192
200
  };
193
201
 
194
202
  // src/core/math.ts
@@ -312,23 +320,27 @@ function useState(initialValue, label) {
312
320
  }, [effectiveLabel]);
313
321
  return [val, setter];
314
322
  }
315
- function useMemo(factory, deps, label) {
316
- const effectiveLabel = label || "anonymous_projection";
323
+ function useMemo(factory, depsOrLabel, label) {
324
+ const isLabelAsSecondArg = typeof depsOrLabel === "string";
325
+ const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
326
+ const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_projection";
317
327
  reactUseEffect(() => {
318
328
  if (window._basis_debug !== false) {
319
329
  console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
320
330
  }
321
331
  }, [effectiveLabel]);
322
- return reactUseMemo(factory, deps || []);
332
+ return reactUseMemo(factory, actualDeps || []);
323
333
  }
324
- function useEffect(effect, deps, label) {
325
- const effectiveLabel = label || "anonymous_effect";
334
+ function useEffect(effect, depsOrLabel, label) {
335
+ const isLabelAsSecondArg = typeof depsOrLabel === "string";
336
+ const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
337
+ const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_effect";
326
338
  reactUseEffect(() => {
327
339
  beginEffectTracking(effectiveLabel);
328
340
  const cleanup = effect();
329
341
  endEffectTracking();
330
342
  return cleanup;
331
- }, deps);
343
+ }, actualDeps);
332
344
  }
333
345
  function useReducer(reducer, initialArg, init, label) {
334
346
  const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
@@ -369,13 +381,14 @@ var __test__ = {
369
381
  import { createContext as createContext2, useContext as useContext2 } from "react";
370
382
  import { jsx, jsxs } from "react/jsx-runtime";
371
383
  var BasisContext = createContext2({ debug: false });
384
+ var isWeb2 = typeof window !== "undefined" && typeof window.document !== "undefined";
372
385
  var BasisProvider = ({ children, debug = true }) => {
373
- if (typeof window !== "undefined") {
386
+ if (isWeb2) {
374
387
  window._basis_debug = debug;
375
388
  }
376
389
  return /* @__PURE__ */ jsxs(BasisContext.Provider, { value: { debug }, children: [
377
390
  children,
378
- debug && /* @__PURE__ */ jsx("div", { style: {
391
+ debug && isWeb2 && /* @__PURE__ */ jsx("div", { style: {
379
392
  position: "fixed",
380
393
  bottom: 10,
381
394
  right: 10,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/logger.ts","../src/core/math.ts","../src/core/constants.ts","../src/engine.ts","../src/hooks.ts","../src/context.tsx"],"sourcesContent":["// src/core/logger.ts\n\nconst STYLES = {\n // Brand Colors\n basis: \"background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;\",\n version: \"background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;\",\n\n // Headers\n headerRed: \"background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerBlue: \"background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerGreen: \"background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n\n // Elements\n label: \"background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;\",\n location: \"color: #0984e3; font-family: monospace; font-weight: bold;\",\n math: \"color: #636e72; font-style: italic; font-family: serif;\",\n\n // Code Block\n codeBlock: `\n background: #1e1e1e; \n color: #9cdcfe; \n padding: 8px 12px; \n display: block; \n margin: 4px 0; \n border-left: 3px solid #00b894; \n font-family: 'Fira Code', monospace; \n line-height: 1.4; \n border-radius: 0 3px 3px 0;\n `,\n\n // Highlights\n dim: \"color: #e84393; font-weight: bold;\",\n bold: \"font-weight: bold;\"\n};\n\nconst parseLabel = (label: string) => {\n const parts = label.split(' -> ');\n return {\n file: parts[0] || \"Unknown\",\n name: parts[1] || label\n };\n};\n\nexport const displayBootLog = (windowSize: number) => {\n console.log(\n `%cBasis%cAuditor v0.1.0%c Monitoring State Space | Window: ${windowSize} ticks`,\n STYLES.basis,\n STYLES.version,\n \"color: #636e72; font-style: italic; margin-left: 8px;\"\n );\n};\n\nexport const displayRedundancyAlert = (labelA: string, labelB: string, sim: number, totalDimensions: number) => {\n const infoA = parseLabel(labelA);\n const infoB = parseLabel(labelB);\n const isCrossFile = infoA.file !== infoB.file;\n\n console.group(`%c πŸ“ BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);\n\n console.log(`%cπŸ“ Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);\n\n console.log(\n `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n\n console.log(\n `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:\n%c// πŸ› οΈ Basis Fix: Remove useState, use useMemo\nconst ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n\n console.groupCollapsed(`%c πŸ”¬ Proof Details `, \"color: #636e72; font-size: 10px; cursor: pointer;\");\n console.table({\n \"Similarity\": `${(sim * 100).toFixed(2)}%`,\n \"Linear Dependency\": \"TRUE\",\n \"Rank\": totalDimensions - 1\n });\n console.groupEnd();\n console.groupEnd();\n};\n\nexport const displayCausalHint = (targetLabel: string, sourceLabel: string) => {\n const target = parseLabel(targetLabel);\n const source = parseLabel(sourceLabel);\n\n const isCrossFile = target.file !== source.file;\n const locationPath = isCrossFile\n ? `${source.file} βž” ${target.file}`\n : target.file;\n\n console.groupCollapsed(`%c πŸ’‘ BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);\n\n console.log(`%cπŸ“ Location: %c${locationPath}`, STYLES.bold, STYLES.location);\n\n console.log(\n `%cSequence:%c %c${source.name}%c βž” Effect βž” %c${target.name}%c`,\n STYLES.bold, \"\",\n STYLES.label, \"\",\n STYLES.label, \"\"\n );\n\n console.log(\n `%cObservation:%c Variable %c${target.name}%c is being manually synchronized.\nThis creates a %c\"Double Render Cycle\"%c.`,\n STYLES.bold, \"\", STYLES.label, \"\",\n \"color: #d63031; font-weight: bold;\", \"\"\n );\n\n console.log(\n `%cHow to fix:%c Use %cuseMemo%c to calculate %c${target.name}%c during render:\n%cconst ${target.name} = useMemo(() => computeFrom(${source.name.includes('effect') ? 'source' : source.name}), [${source.name.includes('effect') ? 'source' : source.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #0984e3; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n\n console.groupEnd();\n};\n\nexport const displayInfiniteLoop = (label: string) => {\n const info = parseLabel(label);\n console.group(`%c πŸ›‘ BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);\n console.error(\n `Infinite oscillation detected on: %c${info.name}%c\nExecution halted to prevent browser thread lock. Check your dependency arrays.`,\n \"color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;\", \"\"\n );\n console.groupEnd();\n};\n\nexport const displayHealthReport = (\n history: Map<string, number[]>,\n similarityFn: (A: number[], B: number[]) => number,\n threshold: number\n) => {\n const entries = Array.from(history.entries());\n const totalVars = entries.length;\n if (totalVars === 0) return;\n\n const clusters: string[][] = [];\n const processed = new Set<string>();\n let independentCount = 0;\n\n entries.forEach(([labelA, vecA]) => {\n if (processed.has(labelA)) return;\n\n const currentCluster = [labelA];\n processed.add(labelA);\n\n entries.forEach(([labelB, vecB]) => {\n if (labelA === labelB || processed.has(labelB)) return;\n\n const sim = similarityFn(vecA, vecB);\n if (sim > threshold) {\n currentCluster.push(labelB);\n processed.add(labelB);\n }\n });\n\n if (currentCluster.length > 1) {\n clusters.push(currentCluster);\n } else {\n independentCount++;\n }\n });\n\n const systemRank = independentCount + clusters.length;\n const efficiency = (systemRank / totalVars) * 100;\n\n console.group(`%c πŸ“Š BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);\n\n console.log(\n `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,\n STYLES.bold,\n `color: ${efficiency > 85 ? '#00b894' : '#d63031'}; font-size: 16px; font-weight: bold;`,\n \"color: #636e72; font-style: italic;\"\n );\n\n if (clusters.length > 0) {\n console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, \"font-weight: bold; color: #e17055; margin-top: 10px;\");\n\n clusters.forEach((cluster, idx) => {\n const names = cluster.map(l => parseLabel(l).name).join(' ⟷ ');\n console.log(` %c${idx + 1}%c ${names}`, \"background: #e17055; color: white; border-radius: 50%; padding: 0 5px;\", \"font-family: monospace;\");\n });\n } else {\n console.log(\"%c✨ All state variables are linearly independent. Your Basis is optimal.\", \"color: #00b894; font-weight: bold; margin-top: 10px;\");\n }\n\n if (totalVars > 0 && totalVars < 15) {\n console.groupCollapsed(\"%cView Full Correlation Matrix\", \"color: #636e72; font-size: 11px;\");\n const matrix: any = {};\n entries.forEach(([labelA]) => {\n const nameA = parseLabel(labelA).name;\n matrix[nameA] = {};\n entries.forEach(([labelB]) => {\n const nameB = parseLabel(labelB).name;\n const sim = similarityFn(history.get(labelA)!, history.get(labelB)!);\n matrix[nameA][nameB] = sim > threshold ? `❌ ${(sim * 100).toFixed(0)}%` : `βœ…`;\n });\n });\n console.table(matrix);\n console.groupEnd();\n } else {\n console.log(\"%c[Note] Matrix hidden due to high dimensionality. Focus on clusters above.\", \"color: #636e72; font-size: 10px; font-style: italic;\");\n }\n\n console.groupEnd();\n};","// src/core/math.ts\n\nexport const calculateCosineSimilarity = (A: number[], B: number[]): number => {\n let dot = 0, magA = 0, magB = 0;\n for (let i = 0; i < A.length; i++) {\n dot += A[i] * B[i];\n magA += A[i] * A[i];\n magB += B[i] * B[i];\n }\n return magA && magB ? dot / (Math.sqrt(magA) * Math.sqrt(magB)) : 0;\n};","// src/core/constants.ts\n\nexport const WINDOW_SIZE = 50;\nexport const SIMILARITY_THRESHOLD = 0.88;\nexport const LOOP_THRESHOLD = 25;\nexport const LOOP_WINDOW_MS = 500;\nexport const ANALYSIS_INTERVAL = 5;","// src/engine.ts\n\nimport * as UI from './core/logger';\nimport { calculateCosineSimilarity } from './core/math';\nimport { \n WINDOW_SIZE, \n SIMILARITY_THRESHOLD, \n LOOP_THRESHOLD, \n LOOP_WINDOW_MS, \n ANALYSIS_INTERVAL \n} from './core/constants';\n\nexport const history = new Map<string, number[]>();\nexport const currentTickBatch = new Set<string>();\nlet updateLog: { label: string; ts: number }[] = [];\nlet currentEffectSource: string | null = null; \nlet tick = 0;\nlet isBatching = false;\n\nUI.displayBootLog(WINDOW_SIZE);\n\nconst analyzeBasis = () => {\n const entries = Array.from(history.entries());\n if (entries.length < 2) return;\n\n entries.forEach(([labelA, vecA], i) => {\n entries.slice(i + 1).forEach(([labelB, vecB]) => {\n const sim = calculateCosineSimilarity(vecA, vecB);\n \n if (sim > SIMILARITY_THRESHOLD) {\n UI.displayRedundancyAlert(labelA, labelB, sim, history.size);\n }\n });\n });\n};\n\nexport const printBasisHealthReport = (threshold = 0.5) => {\n UI.displayHealthReport(history, calculateCosineSimilarity, threshold);\n};\n\nexport const beginEffectTracking = (label: string) => { currentEffectSource = label; };\nexport const endEffectTracking = () => { currentEffectSource = null; };\n\nexport const registerVariable = (label: string) => {\n if (!history.has(label)) {\n history.set(label, new Array(WINDOW_SIZE).fill(0));\n }\n};\n\nexport const unregisterVariable = (label: string) => {\n history.delete(label);\n};\n\nexport const recordUpdate = (label: string): boolean => {\n const now = Date.now();\n\n updateLog.push({ label, ts: now });\n updateLog = updateLog.filter(e => now - e.ts < LOOP_WINDOW_MS);\n if (updateLog.filter(e => e.label === label).length > LOOP_THRESHOLD) {\n UI.displayInfiniteLoop(label);\n return false;\n }\n\n if (currentEffectSource && currentEffectSource !== label) {\n UI.displayCausalHint(label, currentEffectSource);\n }\n\n currentTickBatch.add(label);\n\n if (!isBatching) {\n isBatching = true;\n setTimeout(() => {\n tick++;\n history.forEach((vec, l) => {\n vec.shift();\n vec.push(currentTickBatch.has(l) ? 1 : 0);\n });\n\n currentTickBatch.clear();\n isBatching = false;\n \n if (tick % ANALYSIS_INTERVAL === 0) {\n analyzeBasis();\n }\n }, 20);\n }\n\n return true;\n};\n\nif (typeof window !== 'undefined') {\n (window as any).printBasisReport = printBasisHealthReport;\n}\n\nexport const __testEngine__ = {\n history,\n currentTickBatch,\n registerVariable,\n recordUpdate,\n printBasisHealthReport,\n beginEffectTracking,\n endEffectTracking,\n};","// src/hooks.ts\n\nimport { \n useState as reactUseState, \n useEffect as reactUseEffect, \n useMemo as reactUseMemo, \n useReducer as reactUseReducer,\n useContext as reactUseContext,\n createContext as reactCreateContext,\n useCallback \n} from 'react';\n\nimport type { \n Reducer, \n Context,\n Dispatch,\n SetStateAction,\n DependencyList,\n EffectCallback\n} from 'react';\n\nimport { \n registerVariable, \n unregisterVariable, \n recordUpdate, \n beginEffectTracking, \n endEffectTracking \n} from './engine';\n\nimport * as engine from './engine';\n\nexport type { \n ReactNode, \n FC, \n PropsWithChildren, \n Context, \n ReactElement,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties,\n EffectCallback,\n DependencyList\n} from 'react';\n\nexport function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>] {\n const [val, setVal] = reactUseState(initialValue);\n const effectiveLabel = label || 'anonymous_state';\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const setter = useCallback((newValue: SetStateAction<T>) => {\n if (recordUpdate(effectiveLabel)) {\n setVal(newValue);\n }\n }, [effectiveLabel]);\n\n return [val, setter];\n}\n\nexport function useMemo<T>(factory: () => T, deps: DependencyList | undefined, label?: string): T {\n const effectiveLabel = label || 'anonymous_projection';\n \n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Valid Projection: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseMemo(factory, deps || []);\n}\n\nexport function useEffect(effect: EffectCallback, deps?: DependencyList, label?: string) {\n const effectiveLabel = label || 'anonymous_effect';\n\n reactUseEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, deps);\n}\n\nexport function useReducer<S, A, I>(\n reducer: Reducer<S, A>,\n initialArg: I & S,\n init?: any,\n label?: string\n): [S, Dispatch<A>] {\n\n const effectiveLabel = typeof init === 'string' ? init : (label || 'anonymous_reducer');\n\n const reactInit = typeof init === 'function' ? init : undefined;\n\n const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const basisDispatch = useCallback((action: A) => {\n if (recordUpdate(effectiveLabel)) {\n dispatch(action);\n }\n }, [effectiveLabel]);\n\n return [state, basisDispatch];\n}\n\nexport function createContext<T>(defaultValue: T, label?: string): Context<T> {\n const context = reactCreateContext(defaultValue);\n if (label) {\n (context as any)._basis_label = label;\n }\n return context;\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport const __test__ = {\n registerVariable,\n unregisterVariable,\n recordUpdate,\n beginEffectTracking,\n endEffectTracking,\n history: (engine as any).history,\n currentTickBatch: (engine as any).currentTickBatch\n};","// src/context.tsx\n\nimport React, { createContext, useContext, ReactNode } from 'react';\n\nconst BasisContext = createContext({ debug: false });\n\ninterface BasisProviderProps {\n children: ReactNode;\n debug?: boolean;\n}\n\nexport const BasisProvider: React.FC<BasisProviderProps> = ({ children, debug = true }) => {\n if (typeof window !== 'undefined') {\n (window as any)._basis_debug = debug;\n }\n\n return (\n <BasisContext.Provider value={{ debug }}>\n {children}\n {debug && (\n <div style={{ \n position: 'fixed', bottom: 10, right: 10, background: 'black', color: '#0f0', \n padding: '5px 10px', fontSize: '10px', fontFamily: 'monospace', \n border: '1px solid #0f0', zIndex: 99999, borderRadius: '4px', pointerEvents: 'none'\n }}>\n BASIS_ENGINE: ACTIVE\n </div>\n )}\n </BasisContext.Provider>\n );\n};\n\nexport const useBasisConfig = () => useContext(BasisContext);"],"mappings":";AAEA,IAAM,SAAS;AAAA;AAAA,EAEb,OAAO;AAAA,EACP,SAAS;AAAA;AAAA,EAGT,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,aAAa;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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACnIA,SAAgB,iBAAAC,gBAAe,cAAAC,mBAA6B;AAexD,SAGI,KAHJ;AAbJ,IAAM,eAAeD,eAAc,EAAE,OAAO,MAAM,CAAC;AAO5C,IAAM,gBAA8C,CAAC,EAAE,UAAU,QAAQ,KAAK,MAAM;AACzF,MAAI,OAAO,WAAW,aAAa;AACjC,IAAC,OAAe,eAAe;AAAA,EACjC;AAEA,SACE,qBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC;AAAA;AAAA,IACA,SACC,oBAAC,SAAI,OAAO;AAAA,MACV,UAAU;AAAA,MAAS,QAAQ;AAAA,MAAI,OAAO;AAAA,MAAI,YAAY;AAAA,MAAS,OAAO;AAAA,MACtE,SAAS;AAAA,MAAY,UAAU;AAAA,MAAQ,YAAY;AAAA,MACnD,QAAQ;AAAA,MAAkB,QAAQ;AAAA,MAAO,cAAc;AAAA,MAAO,eAAe;AAAA,IAC/E,GAAG,kCAEH;AAAA,KAEJ;AAEJ;AAEO,IAAM,iBAAiB,MAAMC,YAAW,YAAY;","names":["history","createContext","useContext"]}
1
+ {"version":3,"sources":["../src/core/logger.ts","../src/core/math.ts","../src/core/constants.ts","../src/engine.ts","../src/hooks.ts","../src/context.tsx"],"sourcesContent":["// src/core/logger.ts\n\nconst isWeb = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\nconst STYLES = {\n basis: \"background: #6c5ce7; color: white; font-weight: bold; padding: 2px 6px; border-radius: 3px;\",\n version: \"background: #a29bfe; color: #2d3436; padding: 2px 6px; border-radius: 3px; margin-left: -4px;\",\n\n headerRed: \"background: #d63031; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerBlue: \"background: #0984e3; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n headerGreen: \"background: #00b894; color: white; font-weight: bold; padding: 4px 8px; border-radius: 4px;\",\n\n label: \"background: #dfe6e9; color: #2d3436; padding: 0 4px; border-radius: 3px; font-family: monospace; font-weight: bold; border: 1px solid #b2bec3;\",\n location: \"color: #0984e3; font-family: monospace; font-weight: bold;\",\n math: \"color: #636e72; font-style: italic; font-family: serif;\",\n\n codeBlock: `\n background: #1e1e1e; \n color: #9cdcfe; \n padding: 8px 12px; \n display: block; \n margin: 4px 0; \n border-left: 3px solid #00b894; \n font-family: 'Fira Code', monospace; \n line-height: 1.4; \n border-radius: 0 3px 3px 0;\n `,\n\n dim: \"color: #e84393; font-weight: bold;\",\n bold: \"font-weight: bold;\"\n};\n\nconst parseLabel = (label: string) => {\n const parts = label.split(' -> ');\n return {\n file: parts[0] || \"Unknown\",\n name: parts[1] || label\n };\n};\n\nconst logBasis = (message: string, ...styles: string[]) => {\n if (isWeb) {\n console.log(message, ...styles);\n } else {\n console.log(message.replace(/%c/g, ''));\n }\n};\n\nexport const displayBootLog = (windowSize: number) => {\n logBasis(\n `%cBasis%cAuditor v0.1.4%c Monitoring State Space | Window: ${windowSize} ticks`,\n STYLES.basis,\n STYLES.version,\n \"color: #636e72; font-style: italic; margin-left: 8px;\"\n );\n};\n\nexport const displayRedundancyAlert = (labelA: string, labelB: string, sim: number, totalDimensions: number) => {\n const infoA = parseLabel(labelA);\n const infoB = parseLabel(labelB);\n const isCrossFile = infoA.file !== infoB.file;\n\n if (isWeb) {\n console.group(`%c πŸ“ BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);\n console.log(`%cπŸ“ Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);\n console.log(\n `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n console.log(\n `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:\n%c// πŸ› οΈ Basis Fix: Remove useState, use useMemo\nconst ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,\n \"color: #00b894; font-weight: bold;\", \"\",\n \"color: #e84393; font-weight: bold;\", \"\",\n STYLES.codeBlock, \"\"\n );\n console.groupCollapsed(`%c πŸ”¬ Proof Details `, \"color: #636e72; font-size: 10px; cursor: pointer;\");\n console.table({\n \"Similarity\": `${(sim * 100).toFixed(2)}%`,\n \"Linear Dependency\": \"TRUE\",\n \"Rank\": totalDimensions - 1\n });\n console.groupEnd();\n console.groupEnd();\n } else {\n console.log(`[BASIS] REDUNDANCY DETECTED: ${infoA.name} <-> ${infoB.name} (${(sim * 100).toFixed(0)}% similarity)`);\n console.log(`Location: ${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`);\n }\n};\n\nexport const displayCausalHint = (targetLabel: string, sourceLabel: string) => {\n const target = parseLabel(targetLabel);\n const source = parseLabel(sourceLabel);\n\n const isCrossFile = target.file !== source.file;\n const locationPath = isCrossFile\n ? `${source.file} βž” ${target.file}`\n : target.file;\n\n if (isWeb) {\n console.groupCollapsed(`%c πŸ’‘ BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);\n console.log(`%cπŸ“ Location: %c${locationPath}`, STYLES.bold, STYLES.location);\n console.log(\n `%cSequence:%c %c${source.name}%c βž” Effect βž” %c${target.name}%c`,\n STYLES.bold, \"\", STYLES.label, \"\", STYLES.label, \"\"\n );\n console.log(\n `%cObservation:%c Variable %c${target.name}%c is being manually synchronized. This creates a %c\"Double Render Cycle\"%c.`,\n STYLES.bold, \"\", STYLES.label, \"\", \"color: #d63031; font-weight: bold;\", \"\"\n );\n console.groupEnd();\n } else {\n console.log(`[BASIS] CAUSALITY: ${source.name} βž” ${target.name} (Double Render Cycle)`);\n }\n};\n\nexport const displayInfiniteLoop = (label: string) => {\n const info = parseLabel(label);\n if (isWeb) {\n console.group(`%c πŸ›‘ BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);\n console.error(\n `Infinite oscillation detected on: %c${info.name}%c\\nExecution halted to prevent browser thread lock.`,\n \"color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;\", \"\"\n );\n console.groupEnd();\n } else {\n console.log(`[BASIS CRITICAL] INFINITE LOOP ON: ${info.name}. Execution halted.`);\n }\n};\n\nexport const displayHealthReport = (\n history: Map<string, number[]>,\n similarityFn: (A: number[], B: number[]) => number,\n threshold: number\n) => {\n const entries = Array.from(history.entries());\n const totalVars = entries.length;\n if (totalVars === 0) return;\n\n const clusters: string[][] = [];\n const processed = new Set<string>();\n let independentCount = 0;\n\n entries.forEach(([labelA, vecA]) => {\n if (processed.has(labelA)) return;\n const currentCluster = [labelA];\n processed.add(labelA);\n entries.forEach(([labelB, vecB]) => {\n if (labelA === labelB || processed.has(labelB)) return;\n const sim = similarityFn(vecA, vecB);\n if (sim > threshold) {\n currentCluster.push(labelB);\n processed.add(labelB);\n }\n });\n if (currentCluster.length > 1) {\n clusters.push(currentCluster);\n } else {\n independentCount++;\n }\n });\n\n const systemRank = independentCount + clusters.length;\n const efficiency = (systemRank / totalVars) * 100;\n\n if (isWeb) {\n console.group(`%c πŸ“Š BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);\n console.log(\n `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,\n STYLES.bold,\n `color: ${efficiency > 85 ? '#00b894' : '#d63031'}; font-size: 16px; font-weight: bold;`,\n \"color: #636e72; font-style: italic;\"\n );\n\n if (clusters.length > 0) {\n console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, \"font-weight: bold; color: #e17055; margin-top: 10px;\");\n clusters.forEach((cluster, idx) => {\n const names = cluster.map(l => parseLabel(l).name).join(' ⟷ ');\n console.log(` %c${idx + 1}%c ${names}`, \"background: #e17055; color: white; border-radius: 50%; padding: 0 5px;\", \"font-family: monospace;\");\n });\n } else {\n console.log(\"%c✨ All state variables are linearly independent. Your Basis is optimal.\", \"color: #00b894; font-weight: bold; margin-top: 10px;\");\n }\n\n if (totalVars > 0 && totalVars < 15) {\n console.groupCollapsed(\"%cView Full Correlation Matrix\", \"color: #636e72; font-size: 11px;\");\n const matrix: any = {};\n entries.forEach(([labelA]) => {\n const nameA = parseLabel(labelA).name;\n matrix[nameA] = {};\n entries.forEach(([labelB]) => {\n const nameB = parseLabel(labelB).name;\n const sim = similarityFn(history.get(labelA)!, history.get(labelB)!);\n matrix[nameA][nameB] = sim > threshold ? `❌ ${(sim * 100).toFixed(0)}%` : `βœ…`;\n });\n });\n console.table(matrix);\n console.groupEnd();\n }\n console.groupEnd();\n } else {\n console.log(`[BASIS HEALTH] Efficiency: ${efficiency.toFixed(1)}% (Rank: ${systemRank}/${totalVars})`);\n if (clusters.length > 0) {\n console.log(`Redundancy Clusters: ${clusters.length}`);\n }\n }\n};","// src/core/math.ts\n\nexport const calculateCosineSimilarity = (A: number[], B: number[]): number => {\n let dot = 0, magA = 0, magB = 0;\n for (let i = 0; i < A.length; i++) {\n dot += A[i] * B[i];\n magA += A[i] * A[i];\n magB += B[i] * B[i];\n }\n return magA && magB ? dot / (Math.sqrt(magA) * Math.sqrt(magB)) : 0;\n};","// src/core/constants.ts\n\nexport const WINDOW_SIZE = 50;\nexport const SIMILARITY_THRESHOLD = 0.88;\nexport const LOOP_THRESHOLD = 25;\nexport const LOOP_WINDOW_MS = 500;\nexport const ANALYSIS_INTERVAL = 5;","// src/engine.ts\n\nimport * as UI from './core/logger';\nimport { calculateCosineSimilarity } from './core/math';\nimport { \n WINDOW_SIZE, \n SIMILARITY_THRESHOLD, \n LOOP_THRESHOLD, \n LOOP_WINDOW_MS, \n ANALYSIS_INTERVAL \n} from './core/constants';\n\nexport const history = new Map<string, number[]>();\nexport const currentTickBatch = new Set<string>();\nlet updateLog: { label: string; ts: number }[] = [];\nlet currentEffectSource: string | null = null; \nlet tick = 0;\nlet isBatching = false;\n\nUI.displayBootLog(WINDOW_SIZE);\n\nconst analyzeBasis = () => {\n const entries = Array.from(history.entries());\n if (entries.length < 2) return;\n\n entries.forEach(([labelA, vecA], i) => {\n entries.slice(i + 1).forEach(([labelB, vecB]) => {\n const sim = calculateCosineSimilarity(vecA, vecB);\n \n if (sim > SIMILARITY_THRESHOLD) {\n UI.displayRedundancyAlert(labelA, labelB, sim, history.size);\n }\n });\n });\n};\n\nexport const printBasisHealthReport = (threshold = 0.5) => {\n UI.displayHealthReport(history, calculateCosineSimilarity, threshold);\n};\n\nexport const beginEffectTracking = (label: string) => { currentEffectSource = label; };\nexport const endEffectTracking = () => { currentEffectSource = null; };\n\nexport const registerVariable = (label: string) => {\n if (!history.has(label)) {\n history.set(label, new Array(WINDOW_SIZE).fill(0));\n }\n};\n\nexport const unregisterVariable = (label: string) => {\n history.delete(label);\n};\n\nexport const recordUpdate = (label: string): boolean => {\n const now = Date.now();\n\n updateLog.push({ label, ts: now });\n updateLog = updateLog.filter(e => now - e.ts < LOOP_WINDOW_MS);\n if (updateLog.filter(e => e.label === label).length > LOOP_THRESHOLD) {\n UI.displayInfiniteLoop(label);\n return false;\n }\n\n if (currentEffectSource && currentEffectSource !== label) {\n UI.displayCausalHint(label, currentEffectSource);\n }\n\n currentTickBatch.add(label);\n\n if (!isBatching) {\n isBatching = true;\n setTimeout(() => {\n tick++;\n history.forEach((vec, l) => {\n vec.shift();\n vec.push(currentTickBatch.has(l) ? 1 : 0);\n });\n\n currentTickBatch.clear();\n isBatching = false;\n \n if (tick % ANALYSIS_INTERVAL === 0) {\n analyzeBasis();\n }\n }, 20);\n }\n\n return true;\n};\n\nif (typeof window !== 'undefined') {\n (window as any).printBasisReport = printBasisHealthReport;\n}\n\nexport const __testEngine__ = {\n history,\n currentTickBatch,\n registerVariable,\n recordUpdate,\n printBasisHealthReport,\n beginEffectTracking,\n endEffectTracking,\n};","// src/hooks.ts\n\nimport { \n useState as reactUseState, \n useEffect as reactUseEffect, \n useMemo as reactUseMemo, \n useReducer as reactUseReducer,\n useContext as reactUseContext,\n createContext as reactCreateContext,\n useCallback \n} from 'react';\n\nimport type { \n Reducer, \n Context,\n Dispatch,\n SetStateAction,\n DependencyList,\n EffectCallback\n} from 'react';\n\nimport { \n registerVariable, \n unregisterVariable, \n recordUpdate, \n beginEffectTracking, \n endEffectTracking \n} from './engine';\n\nimport * as engine from './engine';\n\nexport type { \n ReactNode, \n FC, \n PropsWithChildren, \n Context, \n ReactElement,\n Dispatch,\n SetStateAction,\n Reducer,\n CSSProperties,\n EffectCallback,\n DependencyList\n} from 'react';\n\nexport function useState<T>(initialValue: T, label?: string): [T, Dispatch<SetStateAction<T>>] {\n const [val, setVal] = reactUseState(initialValue);\n const effectiveLabel = label || 'anonymous_state';\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const setter = useCallback((newValue: SetStateAction<T>) => {\n if (recordUpdate(effectiveLabel)) {\n setVal(newValue);\n }\n }, [effectiveLabel]);\n\n return [val, setter];\n}\n\nexport function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | string, label?: string): T {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n \n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_projection');\n \n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Valid Projection: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseMemo(factory, actualDeps || []);\n}\n\nexport function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string) {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n \n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_effect');\n\n reactUseEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, actualDeps);\n}\n\nexport function useReducer<S, A, I>(\n reducer: Reducer<S, A>,\n initialArg: I & S,\n init?: any,\n label?: string\n): [S, Dispatch<A>] {\n\n const effectiveLabel = typeof init === 'string' ? init : (label || 'anonymous_reducer');\n\n const reactInit = typeof init === 'function' ? init : undefined;\n\n const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);\n\n reactUseEffect(() => {\n registerVariable(effectiveLabel);\n return () => unregisterVariable(effectiveLabel);\n }, [effectiveLabel]);\n\n const basisDispatch = useCallback((action: A) => {\n if (recordUpdate(effectiveLabel)) {\n dispatch(action);\n }\n }, [effectiveLabel]);\n\n return [state, basisDispatch];\n}\n\nexport function createContext<T>(defaultValue: T, label?: string): Context<T> {\n const context = reactCreateContext(defaultValue);\n if (label) {\n (context as any)._basis_label = label;\n }\n return context;\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport const __test__ = {\n registerVariable,\n unregisterVariable,\n recordUpdate,\n beginEffectTracking,\n endEffectTracking,\n history: (engine as any).history,\n currentTickBatch: (engine as any).currentTickBatch\n};","// src/context.tsx\nimport React, { createContext, useContext, ReactNode } from 'react';\n\nconst BasisContext = createContext({ debug: false });\n\nconst isWeb = typeof window !== 'undefined' && typeof window.document !== 'undefined';\n\ninterface BasisProviderProps {\n children: ReactNode;\n debug?: boolean;\n}\n\nexport const BasisProvider: React.FC<BasisProviderProps> = ({ children, debug = true }) => {\n if (isWeb) {\n (window as any)._basis_debug = debug;\n }\n\n return (\n <BasisContext.Provider value={{ debug }}>\n {children}\n {(debug && isWeb) && (\n <div style={{ \n position: 'fixed', bottom: 10, right: 10, background: 'black', color: '#0f0', \n padding: '5px 10px', fontSize: '10px', fontFamily: 'monospace', \n border: '1px solid #0f0', zIndex: 99999, borderRadius: '4px', pointerEvents: 'none'\n }}>\n BASIS_ENGINE: ACTIVE\n </div>\n )}\n </BasisContext.Provider>\n );\n};\n\nexport const useBasisConfig = () => useContext(BasisContext);"],"mappings":";AAEA,IAAM,QAAQ,OAAO,WAAW,eAAe,OA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I,OAAO;AAAA,MAAI,YAAY;AAAA,MAAS,OAAO;AAAA,MACtE,SAAS;AAAA,MAAY,UAAU;AAAA,MAAQ,YAAY;AAAA,MACnD,QAAQ;AAAA,MAAkB,QAAQ;AAAA,MAAO,cAAc;AAAA,MAAO,eAAe;AAAA,IAC/E,GAAG,kCAEH;AAAA,KAEJ;AAEJ;AAEO,IAAM,iBAAiB,MAAMD,YAAW,YAAY;","names":["history","createContext","useContext","isWeb"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-state-basis",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A linear algebra-powered React architectural tool that detects redundant state and synchronization anti-patterns by modeling state transitions as vectors in a basis.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -67,4 +67,4 @@
67
67
  "typescript": "^5.7.0",
68
68
  "vitest": "^4.0.16"
69
69
  }
70
- }
70
+ }