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.mjs
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import * as ReactNamespace from "react";
|
|
3
|
+
import * as ReactDOMNamespace from "react-dom";
|
|
4
|
+
|
|
1
5
|
// src/core/logger.ts
|
|
2
6
|
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
3
7
|
var STYLES = {
|
|
@@ -39,7 +43,7 @@ var logBasis = (message, ...styles) => {
|
|
|
39
43
|
};
|
|
40
44
|
var displayBootLog = (windowSize) => {
|
|
41
45
|
logBasis(
|
|
42
|
-
`%cBasis%cAuditor
|
|
46
|
+
`%cBasis%cAuditor%c Monitoring State Space | Window: ${windowSize} ticks`,
|
|
43
47
|
STYLES.basis,
|
|
44
48
|
STYLES.version,
|
|
45
49
|
"color: #636e72; font-style: italic; margin-left: 8px;"
|
|
@@ -218,6 +222,7 @@ var LOOP_WINDOW_MS = 500;
|
|
|
218
222
|
var ANALYSIS_INTERVAL = 5;
|
|
219
223
|
|
|
220
224
|
// src/engine.ts
|
|
225
|
+
var redundantLabels = /* @__PURE__ */ new Set();
|
|
221
226
|
var config = {
|
|
222
227
|
debug: false
|
|
223
228
|
};
|
|
@@ -239,14 +244,18 @@ var analyzeBasis = () => {
|
|
|
239
244
|
if (!config.debug) return;
|
|
240
245
|
const entries = Array.from(history.entries());
|
|
241
246
|
if (entries.length < 2) return;
|
|
247
|
+
const newRedundant = /* @__PURE__ */ new Set();
|
|
242
248
|
entries.forEach(([labelA, vecA], i) => {
|
|
243
249
|
entries.slice(i + 1).forEach(([labelB, vecB]) => {
|
|
244
250
|
const sim = calculateCosineSimilarity(vecA, vecB);
|
|
245
251
|
if (sim > SIMILARITY_THRESHOLD) {
|
|
252
|
+
newRedundant.add(labelA);
|
|
253
|
+
newRedundant.add(labelB);
|
|
246
254
|
displayRedundancyAlert(labelA, labelB, sim, history.size);
|
|
247
255
|
}
|
|
248
256
|
});
|
|
249
257
|
});
|
|
258
|
+
redundantLabels = newRedundant;
|
|
250
259
|
};
|
|
251
260
|
var printBasisHealthReport = (threshold = 0.5) => {
|
|
252
261
|
if (!config.debug) {
|
|
@@ -315,39 +324,208 @@ var __testEngine__ = {
|
|
|
315
324
|
endEffectTracking
|
|
316
325
|
};
|
|
317
326
|
|
|
327
|
+
// src/context.tsx
|
|
328
|
+
import { createContext, useContext, useLayoutEffect } from "react";
|
|
329
|
+
|
|
330
|
+
// src/ui/BasisHUD.tsx
|
|
331
|
+
import { useEffect, useRef, useState } from "react";
|
|
332
|
+
|
|
333
|
+
// src/ui/config.ts
|
|
334
|
+
var HUD_DIMENSIONS = {
|
|
335
|
+
WINDOW_SIZE,
|
|
336
|
+
ROW_HEIGHT: 16,
|
|
337
|
+
COL_WIDTH: 5,
|
|
338
|
+
LABEL_WIDTH: 100,
|
|
339
|
+
PADDING: 10,
|
|
340
|
+
RADIUS: 1.5
|
|
341
|
+
};
|
|
342
|
+
var HUD_THEME = {
|
|
343
|
+
bg: "rgba(15, 23, 42, 0.95)",
|
|
344
|
+
border: "#334155",
|
|
345
|
+
header: "#8b5cf6",
|
|
346
|
+
text: "#f1f5f9",
|
|
347
|
+
textDim: "#94a3b8",
|
|
348
|
+
success: "#10b981",
|
|
349
|
+
error: "#ef4444",
|
|
350
|
+
grid: "#1e293b"
|
|
351
|
+
};
|
|
352
|
+
var getHUDContainerStyle = (isExpanded) => ({
|
|
353
|
+
position: "fixed",
|
|
354
|
+
bottom: "20px",
|
|
355
|
+
right: "20px",
|
|
356
|
+
backgroundColor: HUD_THEME.bg,
|
|
357
|
+
border: `1px solid ${HUD_THEME.border}`,
|
|
358
|
+
borderRadius: "12px",
|
|
359
|
+
backdropFilter: "blur(8px)",
|
|
360
|
+
boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3)",
|
|
361
|
+
zIndex: 999999,
|
|
362
|
+
overflow: "hidden",
|
|
363
|
+
width: isExpanded ? "380px" : "130px",
|
|
364
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
365
|
+
cursor: "pointer",
|
|
366
|
+
userSelect: "none",
|
|
367
|
+
WebkitUserSelect: "none"
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// src/ui/BasisHUD.tsx
|
|
371
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
372
|
+
var BasisHUD = () => {
|
|
373
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
374
|
+
const canvasRef = useRef(null);
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
if (!isExpanded) return;
|
|
377
|
+
let animationFrame;
|
|
378
|
+
const draw = () => {
|
|
379
|
+
const canvas = canvasRef.current;
|
|
380
|
+
if (!canvas) return;
|
|
381
|
+
const ctx = canvas.getContext("2d");
|
|
382
|
+
if (!ctx) return;
|
|
383
|
+
const entries = Array.from(history.entries());
|
|
384
|
+
const dpr = window.devicePixelRatio || 1;
|
|
385
|
+
const rawWidth = HUD_DIMENSIONS.WINDOW_SIZE * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.LABEL_WIDTH + HUD_DIMENSIONS.PADDING * 2;
|
|
386
|
+
const rawHeight = Math.max(entries.length * HUD_DIMENSIONS.ROW_HEIGHT + HUD_DIMENSIONS.PADDING * 2, 60);
|
|
387
|
+
updateCanvasSize(canvas, rawWidth, rawHeight, dpr);
|
|
388
|
+
ctx.save();
|
|
389
|
+
ctx.scale(dpr, dpr);
|
|
390
|
+
ctx.clearRect(0, 0, rawWidth, rawHeight);
|
|
391
|
+
if (entries.length === 0) {
|
|
392
|
+
renderEmptyState(ctx);
|
|
393
|
+
} else {
|
|
394
|
+
renderMatrix(ctx, entries);
|
|
395
|
+
}
|
|
396
|
+
ctx.restore();
|
|
397
|
+
animationFrame = requestAnimationFrame(draw);
|
|
398
|
+
};
|
|
399
|
+
draw();
|
|
400
|
+
return () => cancelAnimationFrame(animationFrame);
|
|
401
|
+
}, [isExpanded]);
|
|
402
|
+
return /* @__PURE__ */ jsxs("div", { style: getHUDContainerStyle(isExpanded), onClick: () => setIsExpanded(!isExpanded), children: [
|
|
403
|
+
/* @__PURE__ */ jsx(HUDHeader, { isExpanded }),
|
|
404
|
+
isExpanded && /* @__PURE__ */ jsxs("div", { style: { padding: "10px 14px 15px 14px" }, children: [
|
|
405
|
+
/* @__PURE__ */ jsx("canvas", { ref: canvasRef, style: { display: "block" } }),
|
|
406
|
+
/* @__PURE__ */ jsx(HUDFooter, {})
|
|
407
|
+
] })
|
|
408
|
+
] });
|
|
409
|
+
};
|
|
410
|
+
function updateCanvasSize(canvas, w, h, dpr) {
|
|
411
|
+
const targetW = Math.floor(w * dpr);
|
|
412
|
+
const targetH = Math.floor(h * dpr);
|
|
413
|
+
if (canvas.width !== targetW || canvas.height !== targetH) {
|
|
414
|
+
canvas.width = targetW;
|
|
415
|
+
canvas.height = targetH;
|
|
416
|
+
canvas.style.width = `${w}px`;
|
|
417
|
+
canvas.style.height = `${h}px`;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function renderEmptyState(ctx) {
|
|
421
|
+
ctx.fillStyle = HUD_THEME.textDim;
|
|
422
|
+
ctx.font = "11px Inter, sans-serif";
|
|
423
|
+
ctx.fillText("Waiting for state transitions...", HUD_DIMENSIONS.PADDING, 30);
|
|
424
|
+
}
|
|
425
|
+
function renderMatrix(ctx, entries) {
|
|
426
|
+
entries.forEach(([label, vector], rowIndex) => {
|
|
427
|
+
const y = rowIndex * HUD_DIMENSIONS.ROW_HEIGHT + HUD_DIMENSIONS.PADDING;
|
|
428
|
+
const stateName = label.split(" -> ")[1] || label;
|
|
429
|
+
const isRedundant = redundantLabels.has(label);
|
|
430
|
+
vector.forEach((bit, colIndex) => {
|
|
431
|
+
const x = colIndex * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.PADDING;
|
|
432
|
+
ctx.fillStyle = bit === 1 ? isRedundant ? HUD_THEME.error : HUD_THEME.success : HUD_THEME.grid;
|
|
433
|
+
const w = HUD_DIMENSIONS.COL_WIDTH - 1.5;
|
|
434
|
+
const h = HUD_DIMENSIONS.ROW_HEIGHT - 4;
|
|
435
|
+
if (ctx.roundRect) {
|
|
436
|
+
ctx.beginPath();
|
|
437
|
+
ctx.roundRect(x, y, w, h, HUD_DIMENSIONS.RADIUS);
|
|
438
|
+
ctx.fill();
|
|
439
|
+
} else {
|
|
440
|
+
ctx.fillRect(x, y, w, h);
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
const textX = HUD_DIMENSIONS.WINDOW_SIZE * HUD_DIMENSIONS.COL_WIDTH + HUD_DIMENSIONS.PADDING + 10;
|
|
444
|
+
ctx.fillStyle = isRedundant ? HUD_THEME.error : HUD_THEME.text;
|
|
445
|
+
ctx.font = `${isRedundant ? "600" : "400"} 11px Inter, Menlo, monospace`;
|
|
446
|
+
const cleanName = isRedundant ? `! ${stateName}` : stateName;
|
|
447
|
+
const truncatedName = cleanName.length > 18 ? cleanName.substring(0, 16) + ".." : cleanName;
|
|
448
|
+
ctx.fillText(truncatedName, textX, y + 9);
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
var HUDHeader = ({ isExpanded }) => /* @__PURE__ */ jsxs("div", { style: {
|
|
452
|
+
padding: "10px 14px",
|
|
453
|
+
backgroundColor: isExpanded ? HUD_THEME.header : "transparent",
|
|
454
|
+
color: isExpanded ? "white" : HUD_THEME.header,
|
|
455
|
+
fontWeight: 600,
|
|
456
|
+
fontSize: "11px",
|
|
457
|
+
letterSpacing: "0.05em",
|
|
458
|
+
display: "flex",
|
|
459
|
+
justifyContent: "space-between",
|
|
460
|
+
alignItems: "center",
|
|
461
|
+
transition: "background 0.3s"
|
|
462
|
+
}, children: [
|
|
463
|
+
/* @__PURE__ */ jsx("span", { children: isExpanded ? "STATE BASIS MATRIX" : "\u{1F4D0} BASIS ACTIVE" }),
|
|
464
|
+
isExpanded && /* @__PURE__ */ jsx("span", { style: { opacity: 0.8, fontSize: "9px" }, children: "R50" })
|
|
465
|
+
] });
|
|
466
|
+
var HUDFooter = () => /* @__PURE__ */ jsxs("div", { style: {
|
|
467
|
+
marginTop: "12px",
|
|
468
|
+
paddingTop: "8px",
|
|
469
|
+
borderTop: `1px solid ${HUD_THEME.grid}`,
|
|
470
|
+
color: HUD_THEME.textDim,
|
|
471
|
+
fontSize: "9px",
|
|
472
|
+
display: "flex",
|
|
473
|
+
justifyContent: "space-between"
|
|
474
|
+
}, children: [
|
|
475
|
+
/* @__PURE__ */ jsx("span", { children: "LINEAR DEPENDENCY AUDIT" }),
|
|
476
|
+
/* @__PURE__ */ jsx("span", { children: "THRESHOLD 0.88" })
|
|
477
|
+
] });
|
|
478
|
+
|
|
479
|
+
// src/context.tsx
|
|
480
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
481
|
+
var BasisContext = createContext({ debug: false });
|
|
482
|
+
var isWeb2 = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
483
|
+
var BasisProvider = ({ children, debug = true }) => {
|
|
484
|
+
useLayoutEffect(() => {
|
|
485
|
+
configureBasis({ debug });
|
|
486
|
+
if (isWeb2) {
|
|
487
|
+
window._basis_debug = debug;
|
|
488
|
+
}
|
|
489
|
+
}, [debug]);
|
|
490
|
+
return /* @__PURE__ */ jsxs2(BasisContext.Provider, { value: { debug }, children: [
|
|
491
|
+
children,
|
|
492
|
+
debug && isWeb2 && /* @__PURE__ */ jsx2(BasisHUD, {})
|
|
493
|
+
] });
|
|
494
|
+
};
|
|
495
|
+
var useBasisConfig = () => useContext(BasisContext);
|
|
496
|
+
|
|
318
497
|
// src/hooks.ts
|
|
498
|
+
import * as React3 from "react";
|
|
319
499
|
import {
|
|
320
500
|
useState as reactUseState,
|
|
321
501
|
useEffect as reactUseEffect,
|
|
322
502
|
useMemo as reactUseMemo,
|
|
323
503
|
useReducer as reactUseReducer,
|
|
324
504
|
useContext as reactUseContext,
|
|
505
|
+
useSyncExternalStore as reactUseSyncExternalStore,
|
|
325
506
|
createContext as reactCreateContext,
|
|
326
507
|
useRef as reactUseRef,
|
|
327
508
|
useLayoutEffect as reactUseLayoutEffect,
|
|
328
509
|
useCallback as reactUseCallback,
|
|
329
|
-
useId as reactUseId,
|
|
330
|
-
useDebugValue as reactUseDebugValue,
|
|
331
|
-
useImperativeHandle as reactUseImperativeHandle,
|
|
332
|
-
useInsertionEffect as reactUseInsertionEffect,
|
|
333
|
-
useSyncExternalStore as reactUseSyncExternalStore,
|
|
334
510
|
useTransition as reactUseTransition,
|
|
335
|
-
useDeferredValue as reactUseDeferredValue
|
|
511
|
+
useDeferredValue as reactUseDeferredValue,
|
|
512
|
+
use as reactUse
|
|
336
513
|
} from "react";
|
|
337
|
-
function
|
|
338
|
-
const [val, setVal] = reactUseState(
|
|
514
|
+
function useState2(initialState, label) {
|
|
515
|
+
const [val, setVal] = reactUseState(initialState);
|
|
339
516
|
const effectiveLabel = label || "anonymous_state";
|
|
340
517
|
reactUseEffect(() => {
|
|
341
518
|
registerVariable(effectiveLabel);
|
|
342
519
|
return () => unregisterVariable(effectiveLabel);
|
|
343
520
|
}, [effectiveLabel]);
|
|
344
521
|
const setter = reactUseCallback((newValue) => {
|
|
345
|
-
if (recordUpdate(effectiveLabel))
|
|
346
|
-
|
|
347
|
-
}
|
|
348
|
-
}, [effectiveLabel]);
|
|
522
|
+
if (recordUpdate(effectiveLabel)) setVal(newValue);
|
|
523
|
+
}, [effectiveLabel, setVal]);
|
|
349
524
|
return [val, setter];
|
|
350
525
|
}
|
|
526
|
+
function useRef2(initialValue, _label) {
|
|
527
|
+
return reactUseRef(initialValue);
|
|
528
|
+
}
|
|
351
529
|
function useReducer(reducer, initialArg, init, label) {
|
|
352
530
|
const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
|
|
353
531
|
const reactInit = typeof init === "function" ? init : void 0;
|
|
@@ -357,69 +535,48 @@ function useReducer(reducer, initialArg, init, label) {
|
|
|
357
535
|
return () => unregisterVariable(effectiveLabel);
|
|
358
536
|
}, [effectiveLabel]);
|
|
359
537
|
const basisDispatch = reactUseCallback((action) => {
|
|
360
|
-
if (recordUpdate(effectiveLabel))
|
|
361
|
-
|
|
362
|
-
}
|
|
363
|
-
}, [effectiveLabel]);
|
|
538
|
+
if (recordUpdate(effectiveLabel)) dispatch(action);
|
|
539
|
+
}, [effectiveLabel, dispatch]);
|
|
364
540
|
return [state, basisDispatch];
|
|
365
541
|
}
|
|
366
|
-
function useMemo(factory,
|
|
367
|
-
const
|
|
368
|
-
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
369
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_projection";
|
|
542
|
+
function useMemo(factory, deps, label) {
|
|
543
|
+
const effectiveLabel = label || "anonymous_projection";
|
|
370
544
|
reactUseEffect(() => {
|
|
371
|
-
if (config.debug) {
|
|
372
|
-
console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
373
|
-
}
|
|
545
|
+
if (config.debug) console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
374
546
|
}, [effectiveLabel]);
|
|
375
|
-
return reactUseMemo(factory,
|
|
547
|
+
return reactUseMemo(factory, deps || []);
|
|
376
548
|
}
|
|
377
|
-
function useCallback(callback,
|
|
378
|
-
const
|
|
379
|
-
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
380
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_callback";
|
|
549
|
+
function useCallback(callback, deps, label) {
|
|
550
|
+
const effectiveLabel = label || "anonymous_callback";
|
|
381
551
|
reactUseEffect(() => {
|
|
382
|
-
if (config.debug) {
|
|
383
|
-
console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
384
|
-
}
|
|
552
|
+
if (config.debug) console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
|
|
385
553
|
}, [effectiveLabel]);
|
|
386
|
-
return reactUseCallback(callback,
|
|
554
|
+
return reactUseCallback(callback, deps);
|
|
387
555
|
}
|
|
388
|
-
function
|
|
389
|
-
const
|
|
390
|
-
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
391
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_effect";
|
|
556
|
+
function useEffect2(effect, deps, label) {
|
|
557
|
+
const effectiveLabel = label || "anonymous_effect";
|
|
392
558
|
reactUseEffect(() => {
|
|
393
559
|
beginEffectTracking(effectiveLabel);
|
|
394
560
|
const cleanup = effect();
|
|
395
561
|
endEffectTracking();
|
|
396
562
|
return cleanup;
|
|
397
|
-
},
|
|
563
|
+
}, deps);
|
|
398
564
|
}
|
|
399
|
-
function
|
|
400
|
-
const
|
|
401
|
-
const actualDeps = isLabelAsSecondArg ? void 0 : depsOrLabel;
|
|
402
|
-
const effectiveLabel = isLabelAsSecondArg ? depsOrLabel : label || "anonymous_layout_effect";
|
|
565
|
+
function useLayoutEffect2(effect, deps, label) {
|
|
566
|
+
const effectiveLabel = label || "anonymous_layout_effect";
|
|
403
567
|
reactUseLayoutEffect(() => {
|
|
404
568
|
beginEffectTracking(effectiveLabel);
|
|
405
569
|
const cleanup = effect();
|
|
406
570
|
endEffectTracking();
|
|
407
571
|
return cleanup;
|
|
408
|
-
},
|
|
409
|
-
}
|
|
410
|
-
function useInsertionEffect(effect, deps, _label) {
|
|
411
|
-
return reactUseInsertionEffect(effect, deps);
|
|
572
|
+
}, deps);
|
|
412
573
|
}
|
|
413
574
|
function useTransition(_label) {
|
|
414
|
-
const [isPending,
|
|
575
|
+
const [isPending, startTransition3] = reactUseTransition();
|
|
415
576
|
const effectiveLabel = _label || "anonymous_transition";
|
|
416
577
|
const basisStartTransition = (callback) => {
|
|
417
|
-
if (config.debug) {
|
|
418
|
-
|
|
419
|
-
}
|
|
420
|
-
startTransition(() => {
|
|
421
|
-
callback();
|
|
422
|
-
});
|
|
578
|
+
if (config.debug) console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
579
|
+
startTransition3(callback);
|
|
423
580
|
};
|
|
424
581
|
return [isPending, basisStartTransition];
|
|
425
582
|
}
|
|
@@ -429,108 +586,132 @@ function useDeferredValue(value, initialValueOrLabel, label) {
|
|
|
429
586
|
const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
|
|
430
587
|
const deferredValue = reactUseDeferredValue(value, actualInitialValue);
|
|
431
588
|
reactUseEffect(() => {
|
|
432
|
-
if (config.debug && value !== deferredValue) {
|
|
433
|
-
console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
434
|
-
}
|
|
589
|
+
if (config.debug && value !== deferredValue) console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
|
|
435
590
|
}, [value, deferredValue, effectiveLabel]);
|
|
436
591
|
return deferredValue;
|
|
437
592
|
}
|
|
438
|
-
function
|
|
439
|
-
return reactUseRef(initialValue);
|
|
440
|
-
}
|
|
441
|
-
function createContext(defaultValue, label) {
|
|
593
|
+
function createContext2(defaultValue, label) {
|
|
442
594
|
const context = reactCreateContext(defaultValue);
|
|
443
|
-
if (label)
|
|
444
|
-
context._basis_label = label;
|
|
445
|
-
}
|
|
595
|
+
if (label) context._basis_label = label;
|
|
446
596
|
return context;
|
|
447
597
|
}
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
598
|
+
var useContext2 = reactUseContext;
|
|
599
|
+
var useId2 = (label) => React3.useId();
|
|
600
|
+
var useDebugValue2 = React3.useDebugValue;
|
|
601
|
+
var useImperativeHandle2 = React3.useImperativeHandle;
|
|
602
|
+
var useInsertionEffect2 = React3.useInsertionEffect;
|
|
603
|
+
var useSyncExternalStore = reactUseSyncExternalStore;
|
|
604
|
+
function use(usable) {
|
|
605
|
+
return reactUse(usable);
|
|
453
606
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
607
|
+
function useOptimistic2(passthrough, reducer, label) {
|
|
608
|
+
const effectiveLabel = label || "anonymous_optimistic";
|
|
609
|
+
reactUseEffect(() => {
|
|
610
|
+
registerVariable(effectiveLabel);
|
|
611
|
+
return () => unregisterVariable(effectiveLabel);
|
|
612
|
+
}, [effectiveLabel]);
|
|
613
|
+
const [state, reactAddOptimistic] = React3.useOptimistic(passthrough, reducer);
|
|
614
|
+
const addOptimistic = reactUseCallback((payload) => {
|
|
615
|
+
if (recordUpdate(effectiveLabel)) {
|
|
616
|
+
reactAddOptimistic(payload);
|
|
617
|
+
}
|
|
618
|
+
}, [effectiveLabel, reactAddOptimistic]);
|
|
619
|
+
return [state, addOptimistic];
|
|
459
620
|
}
|
|
460
|
-
function
|
|
461
|
-
|
|
621
|
+
function useActionState2(action, initialState, permalink, label) {
|
|
622
|
+
const isLabelAsThirdArg = typeof permalink === "string" && label === void 0;
|
|
623
|
+
const actualPermalink = isLabelAsThirdArg ? void 0 : permalink;
|
|
624
|
+
const effectiveLabel = isLabelAsThirdArg ? permalink : label || "anonymous_action_state";
|
|
625
|
+
const [state, reactDispatch, isPending] = React3.useActionState(
|
|
626
|
+
action,
|
|
627
|
+
initialState,
|
|
628
|
+
actualPermalink
|
|
629
|
+
);
|
|
630
|
+
reactUseEffect(() => {
|
|
631
|
+
registerVariable(effectiveLabel);
|
|
632
|
+
return () => unregisterVariable(effectiveLabel);
|
|
633
|
+
}, [effectiveLabel]);
|
|
634
|
+
const basisDispatch = reactUseCallback((payload) => {
|
|
635
|
+
if (recordUpdate(effectiveLabel)) {
|
|
636
|
+
reactDispatch(payload);
|
|
637
|
+
}
|
|
638
|
+
}, [effectiveLabel, reactDispatch]);
|
|
639
|
+
return [state, basisDispatch, isPending];
|
|
462
640
|
}
|
|
463
|
-
var __test__ = {
|
|
464
|
-
registerVariable,
|
|
465
|
-
unregisterVariable,
|
|
466
|
-
recordUpdate,
|
|
467
|
-
beginEffectTracking,
|
|
468
|
-
endEffectTracking,
|
|
469
|
-
history,
|
|
470
|
-
currentTickBatch
|
|
471
|
-
};
|
|
641
|
+
var __test__ = { registerVariable, unregisterVariable, recordUpdate, beginEffectTracking, endEffectTracking, history, currentTickBatch };
|
|
472
642
|
|
|
473
|
-
// src/
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
var
|
|
477
|
-
var
|
|
478
|
-
var
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
padding: "5px 10px",
|
|
494
|
-
fontSize: "10px",
|
|
495
|
-
fontFamily: "monospace",
|
|
496
|
-
border: "1px solid #0f0",
|
|
497
|
-
zIndex: 99999,
|
|
498
|
-
borderRadius: "4px",
|
|
499
|
-
pointerEvents: "none"
|
|
500
|
-
}, children: "BASIS_ENGINE: ACTIVE" })
|
|
501
|
-
] });
|
|
502
|
-
};
|
|
503
|
-
var useBasisConfig = () => useContext2(BasisContext);
|
|
643
|
+
// src/index.ts
|
|
644
|
+
var Children2 = ReactNamespace.Children;
|
|
645
|
+
var Component2 = ReactNamespace.Component;
|
|
646
|
+
var Fragment2 = ReactNamespace.Fragment;
|
|
647
|
+
var Profiler2 = ReactNamespace.Profiler;
|
|
648
|
+
var PureComponent2 = ReactNamespace.PureComponent;
|
|
649
|
+
var StrictMode2 = ReactNamespace.StrictMode;
|
|
650
|
+
var Suspense2 = ReactNamespace.Suspense;
|
|
651
|
+
var cloneElement2 = ReactNamespace.cloneElement;
|
|
652
|
+
var createRef2 = ReactNamespace.createRef;
|
|
653
|
+
var forwardRef2 = ReactNamespace.forwardRef;
|
|
654
|
+
var isValidElement2 = ReactNamespace.isValidElement;
|
|
655
|
+
var lazy2 = ReactNamespace.lazy;
|
|
656
|
+
var memo2 = ReactNamespace.memo;
|
|
657
|
+
var startTransition2 = ReactNamespace.startTransition;
|
|
658
|
+
var version2 = ReactNamespace.version;
|
|
659
|
+
var RD = ReactDOMNamespace;
|
|
660
|
+
var createPortal = RD.createPortal;
|
|
661
|
+
var flushSync = RD.flushSync;
|
|
662
|
+
var index_default = ReactNamespace;
|
|
504
663
|
export {
|
|
505
664
|
BasisProvider,
|
|
665
|
+
Children2 as Children,
|
|
666
|
+
Component2 as Component,
|
|
667
|
+
Fragment2 as Fragment,
|
|
668
|
+
Profiler2 as Profiler,
|
|
669
|
+
PureComponent2 as PureComponent,
|
|
670
|
+
ReactNamespace as React,
|
|
671
|
+
StrictMode2 as StrictMode,
|
|
672
|
+
Suspense2 as Suspense,
|
|
506
673
|
__testEngine__,
|
|
507
674
|
__test__,
|
|
508
675
|
beginEffectTracking,
|
|
676
|
+
cloneElement2 as cloneElement,
|
|
509
677
|
config,
|
|
510
678
|
configureBasis,
|
|
511
|
-
createContext,
|
|
679
|
+
createContext2 as createContext,
|
|
680
|
+
createPortal,
|
|
681
|
+
createRef2 as createRef,
|
|
512
682
|
currentTickBatch,
|
|
683
|
+
index_default as default,
|
|
513
684
|
endEffectTracking,
|
|
685
|
+
flushSync,
|
|
686
|
+
forwardRef2 as forwardRef,
|
|
514
687
|
history,
|
|
688
|
+
isValidElement2 as isValidElement,
|
|
689
|
+
lazy2 as lazy,
|
|
690
|
+
memo2 as memo,
|
|
515
691
|
printBasisHealthReport,
|
|
516
692
|
recordUpdate,
|
|
517
693
|
registerVariable,
|
|
694
|
+
startTransition2 as startTransition,
|
|
518
695
|
unregisterVariable,
|
|
696
|
+
use,
|
|
697
|
+
useActionState2 as useActionState,
|
|
519
698
|
useBasisConfig,
|
|
520
699
|
useCallback,
|
|
521
|
-
useContext,
|
|
522
|
-
useDebugValue,
|
|
700
|
+
useContext2 as useContext,
|
|
701
|
+
useDebugValue2 as useDebugValue,
|
|
523
702
|
useDeferredValue,
|
|
524
|
-
useEffect,
|
|
525
|
-
useId,
|
|
526
|
-
useImperativeHandle,
|
|
527
|
-
useInsertionEffect,
|
|
528
|
-
useLayoutEffect,
|
|
703
|
+
useEffect2 as useEffect,
|
|
704
|
+
useId2 as useId,
|
|
705
|
+
useImperativeHandle2 as useImperativeHandle,
|
|
706
|
+
useInsertionEffect2 as useInsertionEffect,
|
|
707
|
+
useLayoutEffect2 as useLayoutEffect,
|
|
529
708
|
useMemo,
|
|
709
|
+
useOptimistic2 as useOptimistic,
|
|
530
710
|
useReducer,
|
|
531
|
-
useRef,
|
|
532
|
-
useState,
|
|
711
|
+
useRef2 as useRef,
|
|
712
|
+
useState2 as useState,
|
|
533
713
|
useSyncExternalStore,
|
|
534
|
-
useTransition
|
|
714
|
+
useTransition,
|
|
715
|
+
version2 as version
|
|
535
716
|
};
|
|
536
717
|
//# sourceMappingURL=index.mjs.map
|