react-state-basis 0.1.4 ā 0.2.0
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 +13 -1
- package/dist/index.d.mts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +89 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -2
- package/dist/index.mjs.map +1 -1
- package/dist/plugin.js +23 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,7 +149,19 @@ Replace your standard React hook imports with `react-state-basis`. This allows t
|
|
|
149
149
|
// import { useState, useEffect } from 'react';
|
|
150
150
|
|
|
151
151
|
// ā
To this:
|
|
152
|
-
import {
|
|
152
|
+
import {
|
|
153
|
+
useState,
|
|
154
|
+
useEffect,
|
|
155
|
+
useMemo,
|
|
156
|
+
useCallback,
|
|
157
|
+
useContext,
|
|
158
|
+
useRef,
|
|
159
|
+
useLayoutEffect,
|
|
160
|
+
useId,
|
|
161
|
+
useSyncExternalStore,
|
|
162
|
+
useDeferredValue,
|
|
163
|
+
useTransition
|
|
164
|
+
} from 'react-state-basis';
|
|
153
165
|
|
|
154
166
|
function MyComponent() {
|
|
155
167
|
const [data, setData] = useState([]); // Automatically vectorized and tracked
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { Dispatch, SetStateAction, DependencyList, EffectCallback, Reducer, Context, ReactNode } from 'react';
|
|
2
3
|
export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
|
|
3
4
|
|
|
4
5
|
declare const history: Map<string, number[]>;
|
|
@@ -24,7 +25,17 @@ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | str
|
|
|
24
25
|
declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
25
26
|
declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
|
|
26
27
|
declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
|
|
28
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
29
|
+
declare function useRef<T>(initialValue: T, _label?: string): react.RefObject<T>;
|
|
30
|
+
declare function useLayoutEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
27
31
|
declare function useContext<T>(context: Context<T>): T;
|
|
32
|
+
declare function useId(_label?: string): string;
|
|
33
|
+
declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
|
|
34
|
+
declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
|
|
35
|
+
declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
|
|
36
|
+
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
37
|
+
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
38
|
+
declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
|
|
28
39
|
declare const __test__: {
|
|
29
40
|
registerVariable: (label: string) => void;
|
|
30
41
|
unregisterVariable: (label: string) => void;
|
|
@@ -39,9 +50,9 @@ interface BasisProviderProps {
|
|
|
39
50
|
children: ReactNode;
|
|
40
51
|
debug?: boolean;
|
|
41
52
|
}
|
|
42
|
-
declare const BasisProvider:
|
|
53
|
+
declare const BasisProvider: react__default.FC<BasisProviderProps>;
|
|
43
54
|
declare const useBasisConfig: () => {
|
|
44
55
|
debug: boolean;
|
|
45
56
|
};
|
|
46
57
|
|
|
47
|
-
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useContext, useEffect, useMemo, useReducer, useState };
|
|
58
|
+
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default, { Dispatch, SetStateAction, DependencyList, EffectCallback, Reducer, Context, ReactNode } from 'react';
|
|
2
3
|
export { CSSProperties, Context, DependencyList, Dispatch, EffectCallback, FC, PropsWithChildren, ReactElement, ReactNode, Reducer, SetStateAction } from 'react';
|
|
3
4
|
|
|
4
5
|
declare const history: Map<string, number[]>;
|
|
@@ -24,7 +25,17 @@ declare function useMemo<T>(factory: () => T, depsOrLabel?: DependencyList | str
|
|
|
24
25
|
declare function useEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
25
26
|
declare function useReducer<S, A, I>(reducer: Reducer<S, A>, initialArg: I & S, init?: any, label?: string): [S, Dispatch<A>];
|
|
26
27
|
declare function createContext<T>(defaultValue: T, label?: string): Context<T>;
|
|
28
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, depsOrLabel?: DependencyList | string, label?: string): T;
|
|
29
|
+
declare function useRef<T>(initialValue: T, _label?: string): react.RefObject<T>;
|
|
30
|
+
declare function useLayoutEffect(effect: EffectCallback, depsOrLabel?: DependencyList | string, label?: string): void;
|
|
27
31
|
declare function useContext<T>(context: Context<T>): T;
|
|
32
|
+
declare function useId(_label?: string): string;
|
|
33
|
+
declare function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void;
|
|
34
|
+
declare function useImperativeHandle<T, R extends T>(ref: React.Ref<T> | undefined, init: () => R, deps?: DependencyList, _label?: string): void;
|
|
35
|
+
declare function useInsertionEffect(effect: EffectCallback, deps?: DependencyList, _label?: string): void;
|
|
36
|
+
declare function useTransition(_label?: string): [boolean, (callback: () => void) => void];
|
|
37
|
+
declare function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T;
|
|
38
|
+
declare function useSyncExternalStore<Snapshot>(subscribe: (onStoreChange: () => void) => () => void, getSnapshot: () => Snapshot, getServerSnapshot?: () => Snapshot, _label?: string): Snapshot;
|
|
28
39
|
declare const __test__: {
|
|
29
40
|
registerVariable: (label: string) => void;
|
|
30
41
|
unregisterVariable: (label: string) => void;
|
|
@@ -39,9 +50,9 @@ interface BasisProviderProps {
|
|
|
39
50
|
children: ReactNode;
|
|
40
51
|
debug?: boolean;
|
|
41
52
|
}
|
|
42
|
-
declare const BasisProvider:
|
|
53
|
+
declare const BasisProvider: react__default.FC<BasisProviderProps>;
|
|
43
54
|
declare const useBasisConfig: () => {
|
|
44
55
|
debug: boolean;
|
|
45
56
|
};
|
|
46
57
|
|
|
47
|
-
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useContext, useEffect, useMemo, useReducer, useState };
|
|
58
|
+
export { BasisProvider, __testEngine__, __test__, beginEffectTracking, createContext, currentTickBatch, endEffectTracking, history, printBasisHealthReport, recordUpdate, registerVariable, unregisterVariable, useBasisConfig, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore, useTransition };
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,21 @@ __export(index_exports, {
|
|
|
33
33
|
registerVariable: () => registerVariable,
|
|
34
34
|
unregisterVariable: () => unregisterVariable,
|
|
35
35
|
useBasisConfig: () => useBasisConfig,
|
|
36
|
+
useCallback: () => useCallback,
|
|
36
37
|
useContext: () => useContext,
|
|
38
|
+
useDebugValue: () => useDebugValue,
|
|
39
|
+
useDeferredValue: () => useDeferredValue,
|
|
37
40
|
useEffect: () => useEffect,
|
|
41
|
+
useId: () => useId,
|
|
42
|
+
useImperativeHandle: () => useImperativeHandle,
|
|
43
|
+
useInsertionEffect: () => useInsertionEffect,
|
|
44
|
+
useLayoutEffect: () => useLayoutEffect,
|
|
38
45
|
useMemo: () => useMemo,
|
|
39
46
|
useReducer: () => useReducer,
|
|
40
|
-
|
|
47
|
+
useRef: () => useRef,
|
|
48
|
+
useState: () => useState,
|
|
49
|
+
useSyncExternalStore: () => useSyncExternalStore,
|
|
50
|
+
useTransition: () => useTransition
|
|
41
51
|
});
|
|
42
52
|
module.exports = __toCommonJS(index_exports);
|
|
43
53
|
|
|
@@ -348,7 +358,7 @@ function useState(initialValue, label) {
|
|
|
348
358
|
registerVariable(effectiveLabel);
|
|
349
359
|
return () => unregisterVariable(effectiveLabel);
|
|
350
360
|
}, [effectiveLabel]);
|
|
351
|
-
const setter =
|
|
361
|
+
const setter = useCallback((newValue) => {
|
|
352
362
|
if (recordUpdate(effectiveLabel)) {
|
|
353
363
|
setVal(newValue);
|
|
354
364
|
}
|
|
@@ -385,7 +395,7 @@ function useReducer(reducer, initialArg, init, label) {
|
|
|
385
395
|
registerVariable(effectiveLabel);
|
|
386
396
|
return () => unregisterVariable(effectiveLabel);
|
|
387
397
|
}, [effectiveLabel]);
|
|
388
|
-
const basisDispatch =
|
|
398
|
+
const basisDispatch = useCallback((action) => {
|
|
389
399
|
if (recordUpdate(effectiveLabel)) {
|
|
390
400
|
dispatch(action);
|
|
391
401
|
}
|
|
@@ -399,9 +409,74 @@ function createContext(defaultValue, label) {
|
|
|
399
409
|
}
|
|
400
410
|
return context;
|
|
401
411
|
}
|
|
412
|
+
function useCallback(callback, depsOrLabel, label) {
|
|
413
|
+
const isLabelAsSecondArg = typeof depsOrLabel === "string";
|
|
414
|
+
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
415
|
+
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_callback";
|
|
416
|
+
(0, import_react.useEffect)(() => {
|
|
417
|
+
if (window._basis_debug !== false) {
|
|
418
|
+
console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
419
|
+
}
|
|
420
|
+
}, [effectiveLabel]);
|
|
421
|
+
return (0, import_react.useCallback)(callback, actualDeps || []);
|
|
422
|
+
}
|
|
423
|
+
function useRef(initialValue, _label) {
|
|
424
|
+
return (0, import_react.useRef)(initialValue);
|
|
425
|
+
}
|
|
426
|
+
function useLayoutEffect(effect, depsOrLabel, label) {
|
|
427
|
+
const isLabelAsSecondArg = typeof depsOrLabel === "string";
|
|
428
|
+
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
429
|
+
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_layout_effect";
|
|
430
|
+
(0, import_react.useLayoutEffect)(() => {
|
|
431
|
+
beginEffectTracking(effectiveLabel);
|
|
432
|
+
const cleanup = effect();
|
|
433
|
+
endEffectTracking();
|
|
434
|
+
return cleanup;
|
|
435
|
+
}, actualDeps);
|
|
436
|
+
}
|
|
402
437
|
function useContext(context) {
|
|
403
438
|
return (0, import_react.useContext)(context);
|
|
404
439
|
}
|
|
440
|
+
function useId(_label) {
|
|
441
|
+
return (0, import_react.useId)();
|
|
442
|
+
}
|
|
443
|
+
function useDebugValue(value, formatter, _label) {
|
|
444
|
+
return (0, import_react.useDebugValue)(value, formatter);
|
|
445
|
+
}
|
|
446
|
+
function useImperativeHandle(ref, init, deps, _label) {
|
|
447
|
+
return (0, import_react.useImperativeHandle)(ref, init, deps);
|
|
448
|
+
}
|
|
449
|
+
function useInsertionEffect(effect, deps, _label) {
|
|
450
|
+
return (0, import_react.useInsertionEffect)(effect, deps);
|
|
451
|
+
}
|
|
452
|
+
function useTransition(_label) {
|
|
453
|
+
const [isPending, startTransition] = (0, import_react.useTransition)();
|
|
454
|
+
const effectiveLabel = _label || "anonymous_transition";
|
|
455
|
+
const basisStartTransition = (callback) => {
|
|
456
|
+
if (window._basis_debug !== false) {
|
|
457
|
+
console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
458
|
+
}
|
|
459
|
+
startTransition(() => {
|
|
460
|
+
callback();
|
|
461
|
+
});
|
|
462
|
+
};
|
|
463
|
+
return [isPending, basisStartTransition];
|
|
464
|
+
}
|
|
465
|
+
function useDeferredValue(value, initialValueOrLabel, label) {
|
|
466
|
+
const isLabelAsSecondArg = typeof initialValueOrLabel === "string" && label === void 0;
|
|
467
|
+
const actualInitialValue = isLabelAsSecondArg ? void 0 : initialValueOrLabel;
|
|
468
|
+
const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
|
|
469
|
+
const deferredValue = (0, import_react.useDeferredValue)(value, actualInitialValue);
|
|
470
|
+
(0, import_react.useEffect)(() => {
|
|
471
|
+
if (window._basis_debug !== false && value !== deferredValue) {
|
|
472
|
+
console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
473
|
+
}
|
|
474
|
+
}, [value, deferredValue, effectiveLabel]);
|
|
475
|
+
return deferredValue;
|
|
476
|
+
}
|
|
477
|
+
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot, _label) {
|
|
478
|
+
return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
|
|
479
|
+
}
|
|
405
480
|
var __test__ = {
|
|
406
481
|
registerVariable,
|
|
407
482
|
unregisterVariable,
|
|
@@ -455,10 +530,20 @@ var useBasisConfig = () => (0, import_react2.useContext)(BasisContext);
|
|
|
455
530
|
registerVariable,
|
|
456
531
|
unregisterVariable,
|
|
457
532
|
useBasisConfig,
|
|
533
|
+
useCallback,
|
|
458
534
|
useContext,
|
|
535
|
+
useDebugValue,
|
|
536
|
+
useDeferredValue,
|
|
459
537
|
useEffect,
|
|
538
|
+
useId,
|
|
539
|
+
useImperativeHandle,
|
|
540
|
+
useInsertionEffect,
|
|
541
|
+
useLayoutEffect,
|
|
460
542
|
useMemo,
|
|
461
543
|
useReducer,
|
|
462
|
-
|
|
544
|
+
useRef,
|
|
545
|
+
useState,
|
|
546
|
+
useSyncExternalStore,
|
|
547
|
+
useTransition
|
|
463
548
|
});
|
|
464
549
|
//# sourceMappingURL=index.js.map
|
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 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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AEJ;AAEJ;AAEO,IAAM,iBAAiB,UAAM,0BAAW,YAAY;","names":["history","reactUseState","reactUseEffect","reactUseMemo","reactUseReducer","reactCreateContext","reactUseContext","import_react","isWeb"]}
|
|
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 useRef as reactUseRef,\n useLayoutEffect as reactUseLayoutEffect,\n useCallback as reactUseCallback,\n useId as reactUseId,\n useDebugValue as reactUseDebugValue,\n useImperativeHandle as reactUseImperativeHandle,\n useInsertionEffect as reactUseInsertionEffect,\n useSyncExternalStore as reactUseSyncExternalStore,\n useTransition as reactUseTransition, \n useDeferredValue as reactUseDeferredValue \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 useCallback<T extends (...args: any[]) => any>(\n callback: T,\n depsOrLabel?: DependencyList | string,\n label?: string\n): T {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_callback');\n\n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Stable Callback: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseCallback(callback, actualDeps || []);\n}\n\nexport function useRef<T>(initialValue: T, _label?: string) {\n return reactUseRef(initialValue);\n}\n\nexport function useLayoutEffect(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_layout_effect');\n\n reactUseLayoutEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, actualDeps);\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport function useId(_label?: string): string {\n return reactUseId();\n}\n\nexport function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void {\n return reactUseDebugValue(value, formatter);\n}\n\nexport function useImperativeHandle<T, R extends T>(\n ref: React.Ref<T> | undefined,\n init: () => R,\n deps?: DependencyList,\n _label?: string\n): void {\n return reactUseImperativeHandle(ref, init, deps);\n}\n\nexport function useInsertionEffect(\n effect: EffectCallback,\n deps?: DependencyList,\n _label?: string\n): void {\n return reactUseInsertionEffect(effect, deps);\n}\n\nexport function useTransition(_label?: string): [boolean, (callback: () => void) => void] {\n const [isPending, startTransition] = reactUseTransition();\n const effectiveLabel = _label || 'anonymous_transition';\n\n const basisStartTransition = (callback: () => void) => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Transition Started: \"${effectiveLabel}\" `, \"color: #e67e22; font-weight: bold;\");\n }\n \n startTransition(() => {\n callback();\n });\n };\n\n return [isPending, basisStartTransition];\n}\n\nexport function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T {\n const isLabelAsSecondArg = typeof initialValueOrLabel === 'string' && label === undefined;\n \n const actualInitialValue = isLabelAsSecondArg ? undefined : initialValueOrLabel as T;\n const effectiveLabel = isLabelAsSecondArg ? (initialValueOrLabel as string) : (label || 'anonymous_deferred');\n\n const deferredValue = reactUseDeferredValue(value, actualInitialValue);\n\n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false && value !== deferredValue) {\n console.log(`%c [Basis] Value Deferred: \"${effectiveLabel}\" `, \"color: #e67e22; font-weight: bold;\");\n }\n }, [value, deferredValue, effectiveLabel]);\n\n return deferredValue;\n}\n\nexport function useSyncExternalStore<Snapshot>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n _label?: string\n): Snapshot {\n return reactUseSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\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;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,Q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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","reactUseCallback","reactUseRef","reactUseLayoutEffect","reactUseContext","reactUseId","reactUseDebugValue","reactUseImperativeHandle","reactUseInsertionEffect","reactUseTransition","reactUseDeferredValue","reactUseSyncExternalStore","import_react","isWeb"]}
|
package/dist/index.mjs
CHANGED
|
@@ -304,7 +304,16 @@ import {
|
|
|
304
304
|
useReducer as reactUseReducer,
|
|
305
305
|
useContext as reactUseContext,
|
|
306
306
|
createContext as reactCreateContext,
|
|
307
|
-
|
|
307
|
+
useRef as reactUseRef,
|
|
308
|
+
useLayoutEffect as reactUseLayoutEffect,
|
|
309
|
+
useCallback as reactUseCallback,
|
|
310
|
+
useId as reactUseId,
|
|
311
|
+
useDebugValue as reactUseDebugValue,
|
|
312
|
+
useImperativeHandle as reactUseImperativeHandle,
|
|
313
|
+
useInsertionEffect as reactUseInsertionEffect,
|
|
314
|
+
useSyncExternalStore as reactUseSyncExternalStore,
|
|
315
|
+
useTransition as reactUseTransition,
|
|
316
|
+
useDeferredValue as reactUseDeferredValue
|
|
308
317
|
} from "react";
|
|
309
318
|
function useState(initialValue, label) {
|
|
310
319
|
const [val, setVal] = reactUseState(initialValue);
|
|
@@ -364,9 +373,74 @@ function createContext(defaultValue, label) {
|
|
|
364
373
|
}
|
|
365
374
|
return context;
|
|
366
375
|
}
|
|
376
|
+
function useCallback(callback, depsOrLabel, label) {
|
|
377
|
+
const isLabelAsSecondArg = typeof depsOrLabel === "string";
|
|
378
|
+
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
379
|
+
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_callback";
|
|
380
|
+
reactUseEffect(() => {
|
|
381
|
+
if (window._basis_debug !== false) {
|
|
382
|
+
console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
383
|
+
}
|
|
384
|
+
}, [effectiveLabel]);
|
|
385
|
+
return reactUseCallback(callback, actualDeps || []);
|
|
386
|
+
}
|
|
387
|
+
function useRef(initialValue, _label) {
|
|
388
|
+
return reactUseRef(initialValue);
|
|
389
|
+
}
|
|
390
|
+
function useLayoutEffect(effect, depsOrLabel, label) {
|
|
391
|
+
const isLabelAsSecondArg = typeof depsOrLabel === "string";
|
|
392
|
+
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
393
|
+
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_layout_effect";
|
|
394
|
+
reactUseLayoutEffect(() => {
|
|
395
|
+
beginEffectTracking(effectiveLabel);
|
|
396
|
+
const cleanup = effect();
|
|
397
|
+
endEffectTracking();
|
|
398
|
+
return cleanup;
|
|
399
|
+
}, actualDeps);
|
|
400
|
+
}
|
|
367
401
|
function useContext(context) {
|
|
368
402
|
return reactUseContext(context);
|
|
369
403
|
}
|
|
404
|
+
function useId(_label) {
|
|
405
|
+
return reactUseId();
|
|
406
|
+
}
|
|
407
|
+
function useDebugValue(value, formatter, _label) {
|
|
408
|
+
return reactUseDebugValue(value, formatter);
|
|
409
|
+
}
|
|
410
|
+
function useImperativeHandle(ref, init, deps, _label) {
|
|
411
|
+
return reactUseImperativeHandle(ref, init, deps);
|
|
412
|
+
}
|
|
413
|
+
function useInsertionEffect(effect, deps, _label) {
|
|
414
|
+
return reactUseInsertionEffect(effect, deps);
|
|
415
|
+
}
|
|
416
|
+
function useTransition(_label) {
|
|
417
|
+
const [isPending, startTransition] = reactUseTransition();
|
|
418
|
+
const effectiveLabel = _label || "anonymous_transition";
|
|
419
|
+
const basisStartTransition = (callback) => {
|
|
420
|
+
if (window._basis_debug !== false) {
|
|
421
|
+
console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
422
|
+
}
|
|
423
|
+
startTransition(() => {
|
|
424
|
+
callback();
|
|
425
|
+
});
|
|
426
|
+
};
|
|
427
|
+
return [isPending, basisStartTransition];
|
|
428
|
+
}
|
|
429
|
+
function useDeferredValue(value, initialValueOrLabel, label) {
|
|
430
|
+
const isLabelAsSecondArg = typeof initialValueOrLabel === "string" && label === void 0;
|
|
431
|
+
const actualInitialValue = isLabelAsSecondArg ? void 0 : initialValueOrLabel;
|
|
432
|
+
const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
|
|
433
|
+
const deferredValue = reactUseDeferredValue(value, actualInitialValue);
|
|
434
|
+
reactUseEffect(() => {
|
|
435
|
+
if (window._basis_debug !== false && value !== deferredValue) {
|
|
436
|
+
console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
437
|
+
}
|
|
438
|
+
}, [value, deferredValue, effectiveLabel]);
|
|
439
|
+
return deferredValue;
|
|
440
|
+
}
|
|
441
|
+
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot, _label) {
|
|
442
|
+
return reactUseSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
443
|
+
}
|
|
370
444
|
var __test__ = {
|
|
371
445
|
registerVariable,
|
|
372
446
|
unregisterVariable,
|
|
@@ -419,10 +493,20 @@ export {
|
|
|
419
493
|
registerVariable,
|
|
420
494
|
unregisterVariable,
|
|
421
495
|
useBasisConfig,
|
|
496
|
+
useCallback,
|
|
422
497
|
useContext,
|
|
498
|
+
useDebugValue,
|
|
499
|
+
useDeferredValue,
|
|
423
500
|
useEffect,
|
|
501
|
+
useId,
|
|
502
|
+
useImperativeHandle,
|
|
503
|
+
useInsertionEffect,
|
|
504
|
+
useLayoutEffect,
|
|
424
505
|
useMemo,
|
|
425
506
|
useReducer,
|
|
426
|
-
|
|
507
|
+
useRef,
|
|
508
|
+
useState,
|
|
509
|
+
useSyncExternalStore,
|
|
510
|
+
useTransition
|
|
427
511
|
};
|
|
428
512
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -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 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,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,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;AACA,SAAO;AACT;AAEO,SAAS,WAAc,SAAwB;AACpD,SAAO,gBAAgB,OAAO;AAChC;AAEO,IAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC1IA,SAAgB,iBAAAC,gBAAe,cAAAC,mBAA6B;AAiBxD,SAGI,KAHJ;AAfJ,IAAM,eAAeD,eAAc,EAAE,OAAO,MAAM,CAAC;AAEnD,IAAME,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,qBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC;AAAA;AAAA,IACC,SAASA,UACT,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,MAAMD,YAAW,YAAY;","names":["history","createContext","useContext","isWeb"]}
|
|
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 useRef as reactUseRef,\n useLayoutEffect as reactUseLayoutEffect,\n useCallback as reactUseCallback,\n useId as reactUseId,\n useDebugValue as reactUseDebugValue,\n useImperativeHandle as reactUseImperativeHandle,\n useInsertionEffect as reactUseInsertionEffect,\n useSyncExternalStore as reactUseSyncExternalStore,\n useTransition as reactUseTransition, \n useDeferredValue as reactUseDeferredValue \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 useCallback<T extends (...args: any[]) => any>(\n callback: T,\n depsOrLabel?: DependencyList | string,\n label?: string\n): T {\n const isLabelAsSecondArg = typeof depsOrLabel === 'string';\n const actualDeps = isLabelAsSecondArg ? undefined : (depsOrLabel as DependencyList);\n const effectiveLabel = isLabelAsSecondArg ? (depsOrLabel as string) : (label || 'anonymous_callback');\n\n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Stable Callback: \"${effectiveLabel}\" `, \"color: #2ecc71; font-weight: bold;\");\n }\n }, [effectiveLabel]);\n\n return reactUseCallback(callback, actualDeps || []);\n}\n\nexport function useRef<T>(initialValue: T, _label?: string) {\n return reactUseRef(initialValue);\n}\n\nexport function useLayoutEffect(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_layout_effect');\n\n reactUseLayoutEffect(() => {\n beginEffectTracking(effectiveLabel);\n const cleanup = effect();\n endEffectTracking();\n return cleanup;\n }, actualDeps);\n}\n\nexport function useContext<T>(context: Context<T>): T {\n return reactUseContext(context);\n}\n\nexport function useId(_label?: string): string {\n return reactUseId();\n}\n\nexport function useDebugValue<T>(value: T, formatter?: (value: T) => any, _label?: string): void {\n return reactUseDebugValue(value, formatter);\n}\n\nexport function useImperativeHandle<T, R extends T>(\n ref: React.Ref<T> | undefined,\n init: () => R,\n deps?: DependencyList,\n _label?: string\n): void {\n return reactUseImperativeHandle(ref, init, deps);\n}\n\nexport function useInsertionEffect(\n effect: EffectCallback,\n deps?: DependencyList,\n _label?: string\n): void {\n return reactUseInsertionEffect(effect, deps);\n}\n\nexport function useTransition(_label?: string): [boolean, (callback: () => void) => void] {\n const [isPending, startTransition] = reactUseTransition();\n const effectiveLabel = _label || 'anonymous_transition';\n\n const basisStartTransition = (callback: () => void) => {\n if ((window as any)._basis_debug !== false) {\n console.log(`%c [Basis] Transition Started: \"${effectiveLabel}\" `, \"color: #e67e22; font-weight: bold;\");\n }\n \n startTransition(() => {\n callback();\n });\n };\n\n return [isPending, basisStartTransition];\n}\n\nexport function useDeferredValue<T>(value: T, initialValueOrLabel?: T | string, label?: string): T {\n const isLabelAsSecondArg = typeof initialValueOrLabel === 'string' && label === undefined;\n \n const actualInitialValue = isLabelAsSecondArg ? undefined : initialValueOrLabel as T;\n const effectiveLabel = isLabelAsSecondArg ? (initialValueOrLabel as string) : (label || 'anonymous_deferred');\n\n const deferredValue = reactUseDeferredValue(value, actualInitialValue);\n\n reactUseEffect(() => {\n if ((window as any)._basis_debug !== false && value !== deferredValue) {\n console.log(`%c [Basis] Value Deferred: \"${effectiveLabel}\" `, \"color: #e67e22; font-weight: bold;\");\n }\n }, [value, deferredValue, effectiveLabel]);\n\n return deferredValue;\n}\n\nexport function useSyncExternalStore<Snapshot>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => Snapshot,\n getServerSnapshot?: () => Snapshot,\n _label?: string\n): Snapshot {\n return reactUseSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\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,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;AA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AW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;AC3PA,SAAgB,iBAAAC,gBAAe,cAAAC,mBAA6B;AAiBxD,SAGI,KAHJ;AAfJ,IAAM,eAAeD,eAAc,EAAE,OAAO,MAAM,CAAC;AAEnD,IAAME,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,qBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,MAAM,GACnC;AAAA;AAAA,IACC,SAASA,UACT,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,MAAMD,YAAW,YAAY;","names":["history","createContext","useContext","isWeb"]}
|
package/dist/plugin.js
CHANGED
|
@@ -14,7 +14,23 @@ module.exports = function(babel) {
|
|
|
14
14
|
} else if (t.isMemberExpression(p.node.callee) && t.isIdentifier(p.node.callee.property)) {
|
|
15
15
|
calleeName = p.node.callee.property.name;
|
|
16
16
|
}
|
|
17
|
-
const targetFunctions = [
|
|
17
|
+
const targetFunctions = [
|
|
18
|
+
"useState",
|
|
19
|
+
"useMemo",
|
|
20
|
+
"useEffect",
|
|
21
|
+
"useReducer",
|
|
22
|
+
"createContext",
|
|
23
|
+
"useRef",
|
|
24
|
+
"useLayoutEffect",
|
|
25
|
+
"useCallback",
|
|
26
|
+
"useId",
|
|
27
|
+
"useImperativeHandle",
|
|
28
|
+
"useInsertionEffect",
|
|
29
|
+
"useDebugValue",
|
|
30
|
+
"useSyncExternalStore",
|
|
31
|
+
"useTransition",
|
|
32
|
+
"useDeferredValue"
|
|
33
|
+
];
|
|
18
34
|
if (!calleeName || !targetFunctions.includes(calleeName)) return;
|
|
19
35
|
const filePath = state.file.opts.filename || "UnknownFile";
|
|
20
36
|
const fileName = path.basename(filePath);
|
|
@@ -26,21 +42,24 @@ module.exports = function(babel) {
|
|
|
26
42
|
} else if (t.isIdentifier(id)) {
|
|
27
43
|
varName = id.name;
|
|
28
44
|
}
|
|
29
|
-
} else if (calleeName === "useEffect") {
|
|
45
|
+
} else if (calleeName === "useEffect" || calleeName === "useLayoutEffect" || calleeName === "useInsertionEffect") {
|
|
30
46
|
varName = `effect_L${p.node.loc?.start.line || "unknown"}`;
|
|
31
47
|
}
|
|
32
48
|
const uniqueLabel = `${fileName} -> ${varName}`;
|
|
33
49
|
const args = p.node.arguments;
|
|
34
|
-
if (
|
|
50
|
+
if (["useState", "createContext", "useRef", "useId", "useDebugValue", "useDeferredValue", "useTransition"].includes(calleeName)) {
|
|
35
51
|
if (args.length === 0) args.push(t.identifier("undefined"));
|
|
36
52
|
if (args.length === 1) args.push(t.stringLiteral(uniqueLabel));
|
|
37
|
-
} else if (
|
|
53
|
+
} else if (["useEffect", "useMemo", "useLayoutEffect", "useInsertionEffect", "useCallback"].includes(calleeName)) {
|
|
38
54
|
if (args.length === 1) args.push(t.identifier("undefined"));
|
|
39
55
|
if (args.length === 2) args.push(t.stringLiteral(uniqueLabel));
|
|
40
56
|
} else if (calleeName === "useReducer") {
|
|
41
57
|
if (args.length === 2 || args.length === 3) {
|
|
42
58
|
args.push(t.stringLiteral(uniqueLabel));
|
|
43
59
|
}
|
|
60
|
+
} else if (["useSyncExternalStore", "useImperativeHandle"].includes(calleeName)) {
|
|
61
|
+
if (args.length === 2) args.push(t.identifier("undefined"));
|
|
62
|
+
if (args.length === 3) args.push(t.stringLiteral(uniqueLabel));
|
|
44
63
|
}
|
|
45
64
|
}
|
|
46
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-state-basis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
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",
|