react-state-basis 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -33
- package/dist/index.d.mts +60 -25
- package/dist/index.d.ts +60 -25
- package/dist/index.js +347 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -126
- package/dist/index.mjs.map +1 -1
- package/dist/jsx-dev-runtime.d.mts +2 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +33 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-dev-runtime.mjs +7 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.mts +1 -0
- package/dist/jsx-runtime.d.ts +1 -0
- package/dist/jsx-runtime.js +35 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime.mjs +8 -0
- package/dist/jsx-runtime.mjs.map +1 -0
- package/dist/plugin.js +4 -1
- package/package.json +9 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,43 +17,75 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
33
|
BasisProvider: () => BasisProvider,
|
|
34
|
+
Children: () => Children2,
|
|
35
|
+
Component: () => Component2,
|
|
36
|
+
Fragment: () => Fragment2,
|
|
37
|
+
Profiler: () => Profiler2,
|
|
38
|
+
PureComponent: () => PureComponent2,
|
|
39
|
+
React: () => ReactNamespace,
|
|
40
|
+
StrictMode: () => StrictMode2,
|
|
41
|
+
Suspense: () => Suspense2,
|
|
24
42
|
__testEngine__: () => __testEngine__,
|
|
25
43
|
__test__: () => __test__,
|
|
26
44
|
beginEffectTracking: () => beginEffectTracking,
|
|
45
|
+
cloneElement: () => cloneElement2,
|
|
27
46
|
config: () => config,
|
|
28
47
|
configureBasis: () => configureBasis,
|
|
29
|
-
createContext: () =>
|
|
48
|
+
createContext: () => createContext2,
|
|
49
|
+
createPortal: () => createPortal,
|
|
50
|
+
createRef: () => createRef2,
|
|
30
51
|
currentTickBatch: () => currentTickBatch,
|
|
52
|
+
default: () => index_default,
|
|
31
53
|
endEffectTracking: () => endEffectTracking,
|
|
54
|
+
flushSync: () => flushSync,
|
|
55
|
+
forwardRef: () => forwardRef2,
|
|
32
56
|
history: () => history,
|
|
57
|
+
isValidElement: () => isValidElement2,
|
|
58
|
+
lazy: () => lazy2,
|
|
59
|
+
memo: () => memo2,
|
|
33
60
|
printBasisHealthReport: () => printBasisHealthReport,
|
|
34
61
|
recordUpdate: () => recordUpdate,
|
|
35
62
|
registerVariable: () => registerVariable,
|
|
63
|
+
startTransition: () => startTransition2,
|
|
36
64
|
unregisterVariable: () => unregisterVariable,
|
|
65
|
+
use: () => use,
|
|
66
|
+
useActionState: () => useActionState2,
|
|
37
67
|
useBasisConfig: () => useBasisConfig,
|
|
38
68
|
useCallback: () => useCallback,
|
|
39
|
-
useContext: () =>
|
|
40
|
-
useDebugValue: () =>
|
|
69
|
+
useContext: () => useContext2,
|
|
70
|
+
useDebugValue: () => useDebugValue2,
|
|
41
71
|
useDeferredValue: () => useDeferredValue,
|
|
42
|
-
useEffect: () =>
|
|
43
|
-
useId: () =>
|
|
44
|
-
useImperativeHandle: () =>
|
|
45
|
-
useInsertionEffect: () =>
|
|
46
|
-
useLayoutEffect: () =>
|
|
72
|
+
useEffect: () => useEffect2,
|
|
73
|
+
useId: () => useId2,
|
|
74
|
+
useImperativeHandle: () => useImperativeHandle2,
|
|
75
|
+
useInsertionEffect: () => useInsertionEffect2,
|
|
76
|
+
useLayoutEffect: () => useLayoutEffect2,
|
|
47
77
|
useMemo: () => useMemo,
|
|
78
|
+
useOptimistic: () => useOptimistic2,
|
|
48
79
|
useReducer: () => useReducer,
|
|
49
|
-
useRef: () =>
|
|
50
|
-
useState: () =>
|
|
80
|
+
useRef: () => useRef2,
|
|
81
|
+
useState: () => useState2,
|
|
51
82
|
useSyncExternalStore: () => useSyncExternalStore,
|
|
52
|
-
useTransition: () => useTransition
|
|
83
|
+
useTransition: () => useTransition,
|
|
84
|
+
version: () => version2
|
|
53
85
|
});
|
|
54
86
|
module.exports = __toCommonJS(index_exports);
|
|
87
|
+
var ReactNamespace = __toESM(require("react"));
|
|
88
|
+
var ReactDOMNamespace = __toESM(require("react-dom"));
|
|
55
89
|
|
|
56
90
|
// src/core/logger.ts
|
|
57
91
|
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
@@ -94,7 +128,7 @@ var logBasis = (message, ...styles) => {
|
|
|
94
128
|
};
|
|
95
129
|
var displayBootLog = (windowSize) => {
|
|
96
130
|
logBasis(
|
|
97
|
-
`%cBasis%cAuditor
|
|
131
|
+
`%cBasis%cAuditor%c Monitoring State Space | Window: ${windowSize} ticks`,
|
|
98
132
|
STYLES.basis,
|
|
99
133
|
STYLES.version,
|
|
100
134
|
"color: #636e72; font-style: italic; margin-left: 8px;"
|
|
@@ -273,6 +307,7 @@ var LOOP_WINDOW_MS = 500;
|
|
|
273
307
|
var ANALYSIS_INTERVAL = 5;
|
|
274
308
|
|
|
275
309
|
// src/engine.ts
|
|
310
|
+
var redundantLabels = /* @__PURE__ */ new Set();
|
|
276
311
|
var config = {
|
|
277
312
|
debug: false
|
|
278
313
|
};
|
|
@@ -294,14 +329,18 @@ var analyzeBasis = () => {
|
|
|
294
329
|
if (!config.debug) return;
|
|
295
330
|
const entries = Array.from(history.entries());
|
|
296
331
|
if (entries.length < 2) return;
|
|
332
|
+
const newRedundant = /* @__PURE__ */ new Set();
|
|
297
333
|
entries.forEach(([labelA, vecA], i) => {
|
|
298
334
|
entries.slice(i + 1).forEach(([labelB, vecB]) => {
|
|
299
335
|
const sim = calculateCosineSimilarity(vecA, vecB);
|
|
300
336
|
if (sim > SIMILARITY_THRESHOLD) {
|
|
337
|
+
newRedundant.add(labelA);
|
|
338
|
+
newRedundant.add(labelB);
|
|
301
339
|
displayRedundancyAlert(labelA, labelB, sim, history.size);
|
|
302
340
|
}
|
|
303
341
|
});
|
|
304
342
|
});
|
|
343
|
+
redundantLabels = newRedundant;
|
|
305
344
|
};
|
|
306
345
|
var printBasisHealthReport = (threshold = 0.5) => {
|
|
307
346
|
if (!config.debug) {
|
|
@@ -370,94 +409,245 @@ var __testEngine__ = {
|
|
|
370
409
|
endEffectTracking
|
|
371
410
|
};
|
|
372
411
|
|
|
373
|
-
// src/
|
|
412
|
+
// src/context.tsx
|
|
413
|
+
var import_react2 = require("react");
|
|
414
|
+
|
|
415
|
+
// src/ui/BasisHUD.tsx
|
|
374
416
|
var import_react = require("react");
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
417
|
+
|
|
418
|
+
// src/ui/config.ts
|
|
419
|
+
var HUD_DIMENSIONS = {
|
|
420
|
+
WINDOW_SIZE,
|
|
421
|
+
ROW_HEIGHT: 16,
|
|
422
|
+
COL_WIDTH: 5,
|
|
423
|
+
LABEL_WIDTH: 100,
|
|
424
|
+
PADDING: 10,
|
|
425
|
+
RADIUS: 1.5
|
|
426
|
+
};
|
|
427
|
+
var HUD_THEME = {
|
|
428
|
+
bg: "rgba(15, 23, 42, 0.95)",
|
|
429
|
+
border: "#334155",
|
|
430
|
+
header: "#8b5cf6",
|
|
431
|
+
text: "#f1f5f9",
|
|
432
|
+
textDim: "#94a3b8",
|
|
433
|
+
success: "#10b981",
|
|
434
|
+
error: "#ef4444",
|
|
435
|
+
grid: "#1e293b"
|
|
436
|
+
};
|
|
437
|
+
var getHUDContainerStyle = (isExpanded) => ({
|
|
438
|
+
position: "fixed",
|
|
439
|
+
bottom: "20px",
|
|
440
|
+
right: "20px",
|
|
441
|
+
backgroundColor: HUD_THEME.bg,
|
|
442
|
+
border: `1px solid ${HUD_THEME.border}`,
|
|
443
|
+
borderRadius: "12px",
|
|
444
|
+
backdropFilter: "blur(8px)",
|
|
445
|
+
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3)",
|
|
446
|
+
zIndex: 999999,
|
|
447
|
+
overflow: "hidden",
|
|
448
|
+
width: isExpanded ? "380px" : "130px",
|
|
449
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
450
|
+
cursor: "pointer",
|
|
451
|
+
userSelect: "none",
|
|
452
|
+
WebkitUserSelect: "none"
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
// src/ui/BasisHUD.tsx
|
|
456
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
457
|
+
var BasisHUD = () => {
|
|
458
|
+
const [isExpanded, setIsExpanded] = (0, import_react.useState)(false);
|
|
459
|
+
const canvasRef = (0, import_react.useRef)(null);
|
|
378
460
|
(0, import_react.useEffect)(() => {
|
|
461
|
+
if (!isExpanded) return;
|
|
462
|
+
let animationFrame;
|
|
463
|
+
const draw = () => {
|
|
464
|
+
const canvas = canvasRef.current;
|
|
465
|
+
if (!canvas) return;
|
|
466
|
+
const ctx = canvas.getContext("2d");
|
|
467
|
+
if (!ctx) return;
|
|
468
|
+
const entries = Array.from(history.entries());
|
|
469
|
+
const dpr = window.devicePixelRatio || 1;
|
|
470
|
+
const rawWidth = HUD_DIMENSIONS.WINDOW_SIZE * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.LABEL_WIDTH + HUD_DIMENSIONS.PADDING * 2;
|
|
471
|
+
const rawHeight = Math.max(entries.length * HUD_DIMENSIONS.ROW_HEIGHT + HUD_DIMENSIONS.PADDING * 2, 60);
|
|
472
|
+
updateCanvasSize(canvas, rawWidth, rawHeight, dpr);
|
|
473
|
+
ctx.save();
|
|
474
|
+
ctx.scale(dpr, dpr);
|
|
475
|
+
ctx.clearRect(0, 0, rawWidth, rawHeight);
|
|
476
|
+
if (entries.length === 0) {
|
|
477
|
+
renderEmptyState(ctx);
|
|
478
|
+
} else {
|
|
479
|
+
renderMatrix(ctx, entries);
|
|
480
|
+
}
|
|
481
|
+
ctx.restore();
|
|
482
|
+
animationFrame = requestAnimationFrame(draw);
|
|
483
|
+
};
|
|
484
|
+
draw();
|
|
485
|
+
return () => cancelAnimationFrame(animationFrame);
|
|
486
|
+
}, [isExpanded]);
|
|
487
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: getHUDContainerStyle(isExpanded), onClick: () => setIsExpanded(!isExpanded), children: [
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HUDHeader, { isExpanded }),
|
|
489
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: "10px 14px 15px 14px" }, children: [
|
|
490
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("canvas", { ref: canvasRef, style: { display: "block" } }),
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HUDFooter, {})
|
|
492
|
+
] })
|
|
493
|
+
] });
|
|
494
|
+
};
|
|
495
|
+
function updateCanvasSize(canvas, w, h, dpr) {
|
|
496
|
+
const targetW = Math.floor(w * dpr);
|
|
497
|
+
const targetH = Math.floor(h * dpr);
|
|
498
|
+
if (canvas.width !== targetW || canvas.height !== targetH) {
|
|
499
|
+
canvas.width = targetW;
|
|
500
|
+
canvas.height = targetH;
|
|
501
|
+
canvas.style.width = `${w}px`;
|
|
502
|
+
canvas.style.height = `${h}px`;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
function renderEmptyState(ctx) {
|
|
506
|
+
ctx.fillStyle = HUD_THEME.textDim;
|
|
507
|
+
ctx.font = "11px Inter, sans-serif";
|
|
508
|
+
ctx.fillText("Waiting for state transitions...", HUD_DIMENSIONS.PADDING, 30);
|
|
509
|
+
}
|
|
510
|
+
function renderMatrix(ctx, entries) {
|
|
511
|
+
entries.forEach(([label, vector], rowIndex) => {
|
|
512
|
+
const y = rowIndex * HUD_DIMENSIONS.ROW_HEIGHT + HUD_DIMENSIONS.PADDING;
|
|
513
|
+
const stateName = label.split(" -> ")[1] || label;
|
|
514
|
+
const isRedundant = redundantLabels.has(label);
|
|
515
|
+
vector.forEach((bit, colIndex) => {
|
|
516
|
+
const x = colIndex * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.PADDING;
|
|
517
|
+
ctx.fillStyle = bit === 1 ? isRedundant ? HUD_THEME.error : HUD_THEME.success : HUD_THEME.grid;
|
|
518
|
+
const w = HUD_DIMENSIONS.COL_WIDTH - 1.5;
|
|
519
|
+
const h = HUD_DIMENSIONS.ROW_HEIGHT - 4;
|
|
520
|
+
if (ctx.roundRect) {
|
|
521
|
+
ctx.beginPath();
|
|
522
|
+
ctx.roundRect(x, y, w, h, HUD_DIMENSIONS.RADIUS);
|
|
523
|
+
ctx.fill();
|
|
524
|
+
} else {
|
|
525
|
+
ctx.fillRect(x, y, w, h);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
const textX = HUD_DIMENSIONS.WINDOW_SIZE * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.PADDING + 10;
|
|
529
|
+
ctx.fillStyle = isRedundant ? HUD_THEME.error : HUD_THEME.text;
|
|
530
|
+
ctx.font = `${isRedundant ? "600" : "400"} 11px Inter, Menlo, monospace`;
|
|
531
|
+
const cleanName = isRedundant ? `! ${stateName}` : stateName;
|
|
532
|
+
const truncatedName = cleanName.length > 18 ? cleanName.substring(0, 16) + ".." : cleanName;
|
|
533
|
+
ctx.fillText(truncatedName, textX, y + 9);
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
var HUDHeader = ({ isExpanded }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: {
|
|
537
|
+
padding: "10px 14px",
|
|
538
|
+
backgroundColor: isExpanded ? HUD_THEME.header : "transparent",
|
|
539
|
+
color: isExpanded ? "white" : HUD_THEME.header,
|
|
540
|
+
fontWeight: 600,
|
|
541
|
+
fontSize: "11px",
|
|
542
|
+
letterSpacing: "0.05em",
|
|
543
|
+
display: "flex",
|
|
544
|
+
justifyContent: "space-between",
|
|
545
|
+
alignItems: "center",
|
|
546
|
+
transition: "background 0.3s"
|
|
547
|
+
}, children: [
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: isExpanded ? "STATE BASIS MATRIX" : "\u{1F4D0} BASIS ACTIVE" }),
|
|
549
|
+
isExpanded && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { opacity: 0.8, fontSize: "9px" }, children: "R50" })
|
|
550
|
+
] });
|
|
551
|
+
var HUDFooter = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: {
|
|
552
|
+
marginTop: "12px",
|
|
553
|
+
paddingTop: "8px",
|
|
554
|
+
borderTop: `1px solid ${HUD_THEME.grid}`,
|
|
555
|
+
color: HUD_THEME.textDim,
|
|
556
|
+
fontSize: "9px",
|
|
557
|
+
display: "flex",
|
|
558
|
+
justifyContent: "space-between"
|
|
559
|
+
}, children: [
|
|
560
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "LINEAR DEPENDENCY AUDIT" }),
|
|
561
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "THRESHOLD 0.88" })
|
|
562
|
+
] });
|
|
563
|
+
|
|
564
|
+
// src/context.tsx
|
|
565
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
566
|
+
var BasisContext = (0, import_react2.createContext)({ debug: false });
|
|
567
|
+
var isWeb2 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
568
|
+
var BasisProvider = ({ children, debug = true }) => {
|
|
569
|
+
(0, import_react2.useLayoutEffect)(() => {
|
|
570
|
+
configureBasis({ debug });
|
|
571
|
+
if (isWeb2) {
|
|
572
|
+
window._basis_debug = debug;
|
|
573
|
+
}
|
|
574
|
+
}, [debug]);
|
|
575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(BasisContext.Provider, { value: { debug }, children: [
|
|
576
|
+
children,
|
|
577
|
+
debug && isWeb2 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(BasisHUD, {})
|
|
578
|
+
] });
|
|
579
|
+
};
|
|
580
|
+
var useBasisConfig = () => (0, import_react2.useContext)(BasisContext);
|
|
581
|
+
|
|
582
|
+
// src/hooks.ts
|
|
583
|
+
var React3 = __toESM(require("react"));
|
|
584
|
+
var import_react3 = require("react");
|
|
585
|
+
function useState2(initialState, label) {
|
|
586
|
+
const [val, setVal] = (0, import_react3.useState)(initialState);
|
|
587
|
+
const effectiveLabel = label || "anonymous_state";
|
|
588
|
+
(0, import_react3.useEffect)(() => {
|
|
379
589
|
registerVariable(effectiveLabel);
|
|
380
590
|
return () => unregisterVariable(effectiveLabel);
|
|
381
591
|
}, [effectiveLabel]);
|
|
382
|
-
const setter = (0,
|
|
383
|
-
if (recordUpdate(effectiveLabel))
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
}, [effectiveLabel]);
|
|
592
|
+
const setter = (0, import_react3.useCallback)((newValue) => {
|
|
593
|
+
if (recordUpdate(effectiveLabel)) setVal(newValue);
|
|
594
|
+
}, [effectiveLabel, setVal]);
|
|
387
595
|
return [val, setter];
|
|
388
596
|
}
|
|
597
|
+
function useRef2(initialValue, _label) {
|
|
598
|
+
return (0, import_react3.useRef)(initialValue);
|
|
599
|
+
}
|
|
389
600
|
function useReducer(reducer, initialArg, init, label) {
|
|
390
601
|
const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
|
|
391
602
|
const reactInit = typeof init === "function" ? init : void 0;
|
|
392
|
-
const [state, dispatch] = (0,
|
|
393
|
-
(0,
|
|
603
|
+
const [state, dispatch] = (0, import_react3.useReducer)(reducer, initialArg, reactInit);
|
|
604
|
+
(0, import_react3.useEffect)(() => {
|
|
394
605
|
registerVariable(effectiveLabel);
|
|
395
606
|
return () => unregisterVariable(effectiveLabel);
|
|
396
607
|
}, [effectiveLabel]);
|
|
397
|
-
const basisDispatch = (0,
|
|
398
|
-
if (recordUpdate(effectiveLabel))
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
}, [effectiveLabel]);
|
|
608
|
+
const basisDispatch = (0, import_react3.useCallback)((action) => {
|
|
609
|
+
if (recordUpdate(effectiveLabel)) dispatch(action);
|
|
610
|
+
}, [effectiveLabel, dispatch]);
|
|
402
611
|
return [state, basisDispatch];
|
|
403
612
|
}
|
|
404
|
-
function useMemo(factory,
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
(0, import_react.useEffect)(() => {
|
|
409
|
-
if (config.debug) {
|
|
410
|
-
console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
411
|
-
}
|
|
613
|
+
function useMemo(factory, deps, label) {
|
|
614
|
+
const effectiveLabel = label || "anonymous_projection";
|
|
615
|
+
(0, import_react3.useEffect)(() => {
|
|
616
|
+
if (config.debug) console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
412
617
|
}, [effectiveLabel]);
|
|
413
|
-
return (0,
|
|
618
|
+
return (0, import_react3.useMemo)(factory, deps || []);
|
|
414
619
|
}
|
|
415
|
-
function useCallback(callback,
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
(0, import_react.useEffect)(() => {
|
|
420
|
-
if (config.debug) {
|
|
421
|
-
console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
422
|
-
}
|
|
620
|
+
function useCallback(callback, deps, label) {
|
|
621
|
+
const effectiveLabel = label || "anonymous_callback";
|
|
622
|
+
(0, import_react3.useEffect)(() => {
|
|
623
|
+
if (config.debug) console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
423
624
|
}, [effectiveLabel]);
|
|
424
|
-
return (0,
|
|
625
|
+
return (0, import_react3.useCallback)(callback, deps);
|
|
425
626
|
}
|
|
426
|
-
function
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_effect";
|
|
430
|
-
(0, import_react.useEffect)(() => {
|
|
627
|
+
function useEffect2(effect, deps, label) {
|
|
628
|
+
const effectiveLabel = label || "anonymous_effect";
|
|
629
|
+
(0, import_react3.useEffect)(() => {
|
|
431
630
|
beginEffectTracking(effectiveLabel);
|
|
432
631
|
const cleanup = effect();
|
|
433
632
|
endEffectTracking();
|
|
434
633
|
return cleanup;
|
|
435
|
-
},
|
|
634
|
+
}, deps);
|
|
436
635
|
}
|
|
437
|
-
function
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_layout_effect";
|
|
441
|
-
(0, import_react.useLayoutEffect)(() => {
|
|
636
|
+
function useLayoutEffect2(effect, deps, label) {
|
|
637
|
+
const effectiveLabel = label || "anonymous_layout_effect";
|
|
638
|
+
(0, import_react3.useLayoutEffect)(() => {
|
|
442
639
|
beginEffectTracking(effectiveLabel);
|
|
443
640
|
const cleanup = effect();
|
|
444
641
|
endEffectTracking();
|
|
445
642
|
return cleanup;
|
|
446
|
-
},
|
|
447
|
-
}
|
|
448
|
-
function useInsertionEffect(effect, deps, _label) {
|
|
449
|
-
return (0, import_react.useInsertionEffect)(effect, deps);
|
|
643
|
+
}, deps);
|
|
450
644
|
}
|
|
451
645
|
function useTransition(_label) {
|
|
452
|
-
const [isPending,
|
|
646
|
+
const [isPending, startTransition3] = (0, import_react3.useTransition)();
|
|
453
647
|
const effectiveLabel = _label || "anonymous_transition";
|
|
454
648
|
const basisStartTransition = (callback) => {
|
|
455
|
-
if (config.debug) {
|
|
456
|
-
|
|
457
|
-
}
|
|
458
|
-
startTransition(() => {
|
|
459
|
-
callback();
|
|
460
|
-
});
|
|
649
|
+
if (config.debug) console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
650
|
+
startTransition3(callback);
|
|
461
651
|
};
|
|
462
652
|
return [isPending, basisStartTransition];
|
|
463
653
|
}
|
|
@@ -465,96 +655,117 @@ function useDeferredValue(value, initialValueOrLabel, label) {
|
|
|
465
655
|
const isLabelAsSecondArg = typeof initialValueOrLabel === "string" && label === void 0;
|
|
466
656
|
const actualInitialValue = isLabelAsSecondArg ? void 0 : initialValueOrLabel;
|
|
467
657
|
const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
|
|
468
|
-
const deferredValue = (0,
|
|
469
|
-
(0,
|
|
470
|
-
if (config.debug && value !== deferredValue) {
|
|
471
|
-
console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
472
|
-
}
|
|
658
|
+
const deferredValue = (0, import_react3.useDeferredValue)(value, actualInitialValue);
|
|
659
|
+
(0, import_react3.useEffect)(() => {
|
|
660
|
+
if (config.debug && value !== deferredValue) console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
473
661
|
}, [value, deferredValue, effectiveLabel]);
|
|
474
662
|
return deferredValue;
|
|
475
663
|
}
|
|
476
|
-
function
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
function createContext(defaultValue, label) {
|
|
480
|
-
const context = (0, import_react.createContext)(defaultValue);
|
|
481
|
-
if (label) {
|
|
482
|
-
context._basis_label = label;
|
|
483
|
-
}
|
|
664
|
+
function createContext2(defaultValue, label) {
|
|
665
|
+
const context = (0, import_react3.createContext)(defaultValue);
|
|
666
|
+
if (label) context._basis_label = label;
|
|
484
667
|
return context;
|
|
485
668
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
669
|
+
var useContext2 = import_react3.useContext;
|
|
670
|
+
var useId2 = (label) => React3.useId();
|
|
671
|
+
var useDebugValue2 = React3.useDebugValue;
|
|
672
|
+
var useImperativeHandle2 = React3.useImperativeHandle;
|
|
673
|
+
var useInsertionEffect2 = React3.useInsertionEffect;
|
|
674
|
+
var useSyncExternalStore = import_react3.useSyncExternalStore;
|
|
675
|
+
function use(usable) {
|
|
676
|
+
return (0, import_react3.use)(usable);
|
|
491
677
|
}
|
|
492
|
-
function
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
678
|
+
function useOptimistic2(passthrough, reducer, label) {
|
|
679
|
+
const effectiveLabel = label || "anonymous_optimistic";
|
|
680
|
+
(0, import_react3.useEffect)(() => {
|
|
681
|
+
registerVariable(effectiveLabel);
|
|
682
|
+
return () => unregisterVariable(effectiveLabel);
|
|
683
|
+
}, [effectiveLabel]);
|
|
684
|
+
const [state, reactAddOptimistic] = React3.useOptimistic(passthrough, reducer);
|
|
685
|
+
const addOptimistic = (0, import_react3.useCallback)((payload) => {
|
|
686
|
+
if (recordUpdate(effectiveLabel)) {
|
|
687
|
+
reactAddOptimistic(payload);
|
|
688
|
+
}
|
|
689
|
+
}, [effectiveLabel, reactAddOptimistic]);
|
|
690
|
+
return [state, addOptimistic];
|
|
497
691
|
}
|
|
498
|
-
function
|
|
499
|
-
|
|
692
|
+
function useActionState2(action, initialState, permalink, label) {
|
|
693
|
+
const isLabelAsThirdArg = typeof permalink === "string" && label === void 0;
|
|
694
|
+
const actualPermalink = isLabelAsThirdArg ? void 0 : permalink;
|
|
695
|
+
const effectiveLabel = isLabelAsThirdArg ? permalink : label || "anonymous_action_state";
|
|
696
|
+
const [state, reactDispatch, isPending] = React3.useActionState(
|
|
697
|
+
action,
|
|
698
|
+
initialState,
|
|
699
|
+
actualPermalink
|
|
700
|
+
);
|
|
701
|
+
(0, import_react3.useEffect)(() => {
|
|
702
|
+
registerVariable(effectiveLabel);
|
|
703
|
+
return () => unregisterVariable(effectiveLabel);
|
|
704
|
+
}, [effectiveLabel]);
|
|
705
|
+
const basisDispatch = (0, import_react3.useCallback)((payload) => {
|
|
706
|
+
if (recordUpdate(effectiveLabel)) {
|
|
707
|
+
reactDispatch(payload);
|
|
708
|
+
}
|
|
709
|
+
}, [effectiveLabel, reactDispatch]);
|
|
710
|
+
return [state, basisDispatch, isPending];
|
|
500
711
|
}
|
|
501
|
-
var __test__ = {
|
|
502
|
-
registerVariable,
|
|
503
|
-
unregisterVariable,
|
|
504
|
-
recordUpdate,
|
|
505
|
-
beginEffectTracking,
|
|
506
|
-
endEffectTracking,
|
|
507
|
-
history,
|
|
508
|
-
currentTickBatch
|
|
509
|
-
};
|
|
712
|
+
var __test__ = { registerVariable, unregisterVariable, recordUpdate, beginEffectTracking, endEffectTracking, history, currentTickBatch };
|
|
510
713
|
|
|
511
|
-
// src/
|
|
512
|
-
var
|
|
513
|
-
var
|
|
514
|
-
var
|
|
515
|
-
var
|
|
516
|
-
var
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
padding: "5px 10px",
|
|
532
|
-
fontSize: "10px",
|
|
533
|
-
fontFamily: "monospace",
|
|
534
|
-
border: "1px solid #0f0",
|
|
535
|
-
zIndex: 99999,
|
|
536
|
-
borderRadius: "4px",
|
|
537
|
-
pointerEvents: "none"
|
|
538
|
-
}, children: "BASIS_ENGINE: ACTIVE" })
|
|
539
|
-
] });
|
|
540
|
-
};
|
|
541
|
-
var useBasisConfig = () => (0, import_react2.useContext)(BasisContext);
|
|
714
|
+
// src/index.ts
|
|
715
|
+
var Children2 = ReactNamespace.Children;
|
|
716
|
+
var Component2 = ReactNamespace.Component;
|
|
717
|
+
var Fragment2 = ReactNamespace.Fragment;
|
|
718
|
+
var Profiler2 = ReactNamespace.Profiler;
|
|
719
|
+
var PureComponent2 = ReactNamespace.PureComponent;
|
|
720
|
+
var StrictMode2 = ReactNamespace.StrictMode;
|
|
721
|
+
var Suspense2 = ReactNamespace.Suspense;
|
|
722
|
+
var cloneElement2 = ReactNamespace.cloneElement;
|
|
723
|
+
var createRef2 = ReactNamespace.createRef;
|
|
724
|
+
var forwardRef2 = ReactNamespace.forwardRef;
|
|
725
|
+
var isValidElement2 = ReactNamespace.isValidElement;
|
|
726
|
+
var lazy2 = ReactNamespace.lazy;
|
|
727
|
+
var memo2 = ReactNamespace.memo;
|
|
728
|
+
var startTransition2 = ReactNamespace.startTransition;
|
|
729
|
+
var version2 = ReactNamespace.version;
|
|
730
|
+
var RD = ReactDOMNamespace;
|
|
731
|
+
var createPortal = RD.createPortal;
|
|
732
|
+
var flushSync = RD.flushSync;
|
|
733
|
+
var index_default = ReactNamespace;
|
|
542
734
|
// Annotate the CommonJS export names for ESM import in node:
|
|
543
735
|
0 && (module.exports = {
|
|
544
736
|
BasisProvider,
|
|
737
|
+
Children,
|
|
738
|
+
Component,
|
|
739
|
+
Fragment,
|
|
740
|
+
Profiler,
|
|
741
|
+
PureComponent,
|
|
742
|
+
React,
|
|
743
|
+
StrictMode,
|
|
744
|
+
Suspense,
|
|
545
745
|
__testEngine__,
|
|
546
746
|
__test__,
|
|
547
747
|
beginEffectTracking,
|
|
748
|
+
cloneElement,
|
|
548
749
|
config,
|
|
549
750
|
configureBasis,
|
|
550
751
|
createContext,
|
|
752
|
+
createPortal,
|
|
753
|
+
createRef,
|
|
551
754
|
currentTickBatch,
|
|
552
755
|
endEffectTracking,
|
|
756
|
+
flushSync,
|
|
757
|
+
forwardRef,
|
|
553
758
|
history,
|
|
759
|
+
isValidElement,
|
|
760
|
+
lazy,
|
|
761
|
+
memo,
|
|
554
762
|
printBasisHealthReport,
|
|
555
763
|
recordUpdate,
|
|
556
764
|
registerVariable,
|
|
765
|
+
startTransition,
|
|
557
766
|
unregisterVariable,
|
|
767
|
+
use,
|
|
768
|
+
useActionState,
|
|
558
769
|
useBasisConfig,
|
|
559
770
|
useCallback,
|
|
560
771
|
useContext,
|
|
@@ -566,10 +777,12 @@ var useBasisConfig = () => (0, import_react2.useContext)(BasisContext);
|
|
|
566
777
|
useInsertionEffect,
|
|
567
778
|
useLayoutEffect,
|
|
568
779
|
useMemo,
|
|
780
|
+
useOptimistic,
|
|
569
781
|
useReducer,
|
|
570
782
|
useRef,
|
|
571
783
|
useState,
|
|
572
784
|
useSyncExternalStore,
|
|
573
|
-
useTransition
|
|
785
|
+
useTransition,
|
|
786
|
+
version
|
|
574
787
|
});
|
|
575
788
|
//# sourceMappingURL=index.js.map
|