react-state-basis 0.3.1 → 0.3.3

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/dist/index.mjs CHANGED
@@ -1,10 +1,24 @@
1
1
  import {
2
2
  basis
3
- } from "./chunk-GEHMQPV4.mjs";
3
+ } from "./chunk-I5ZFRXQP.mjs";
4
4
 
5
- // src/index.ts
6
- import * as ReactNamespace from "react";
7
- import * as ReactDOMNamespace from "react-dom";
5
+ // src/hooks.ts
6
+ import * as React from "react";
7
+ import {
8
+ useState as reactUseState,
9
+ useEffect as reactUseEffect,
10
+ useMemo as reactUseMemo,
11
+ useReducer as reactUseReducer,
12
+ useContext as reactUseContext,
13
+ useSyncExternalStore as reactUseSyncExternalStore,
14
+ createContext as reactCreateContext,
15
+ useRef as reactUseRef,
16
+ useLayoutEffect as reactUseLayoutEffect,
17
+ useCallback as reactUseCallback,
18
+ useTransition as reactUseTransition,
19
+ useDeferredValue as reactUseDeferredValue,
20
+ use as reactUse
21
+ } from "react";
8
22
 
9
23
  // src/core/logger.ts
10
24
  var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined";
@@ -29,7 +43,8 @@ var STYLES = {
29
43
  border-radius: 0 3px 3px 0;
30
44
  `,
31
45
  dim: "color: #e84393; font-weight: bold;",
32
- bold: "font-weight: bold;"
46
+ bold: "font-weight: bold;",
47
+ subText: "color: #636e72; font-size: 11px;"
33
48
  };
34
49
  var parseLabel = (label) => {
35
50
  const parts = label.split(" -> ");
@@ -47,7 +62,7 @@ var logBasis = (message, ...styles) => {
47
62
  };
48
63
  var displayBootLog = (windowSize) => {
49
64
  logBasis(
50
- `%cBasis%cAuditor%c Monitoring State Space | Window: ${windowSize} ticks`,
65
+ `%cBasis%cAuditor%c Structural Relationship Check | Window: ${windowSize} ticks`,
51
66
  STYLES.basis,
52
67
  STYLES.version,
53
68
  "color: #636e72; font-style: italic; margin-left: 8px;"
@@ -58,19 +73,21 @@ var displayRedundancyAlert = (labelA, labelB, sim, totalDimensions) => {
58
73
  const infoB = parseLabel(labelB);
59
74
  const isCrossFile = infoA.file !== infoB.file;
60
75
  if (isWeb) {
61
- console.group(`%c \u{1F4D0} BASIS | DIMENSION COLLAPSE DETECTED `, STYLES.headerRed);
76
+ console.group(`%c \u{1F4D0} BASIS | REDUNDANT STATE PATTERN `, STYLES.headerRed);
62
77
  console.log(`%c\u{1F4CD} Location: %c${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`, STYLES.bold, STYLES.location);
63
78
  console.log(
64
- `%cAnalysis:%c Vectors %c${infoA.name}%c and %c${infoB.name}%c are collinear (redundant).`,
79
+ `%cObservation:%c Variables %c${infoA.name}%c and %c${infoB.name}%c are Synchronized.
80
+ %cThis means one variable is likely redundant and can be deleted to simplify the component.`,
65
81
  STYLES.bold,
66
82
  "",
67
83
  STYLES.label,
68
84
  "",
69
85
  STYLES.label,
70
- ""
86
+ "",
87
+ STYLES.subText
71
88
  );
72
89
  console.log(
73
- `%cHow to fix:%c Project %c${infoB.name}%c as a derived value:
90
+ `%cHow to fix:%c Refactor %c${infoB.name}%c as a Computed Value (Projection):
74
91
  %c// \u{1F6E0}\uFE0F Basis Fix: Remove useState, use useMemo
75
92
  const ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);%c`,
76
93
  "color: #00b894; font-weight: bold;",
@@ -80,16 +97,16 @@ const ${infoB.name} = useMemo(() => deriveFrom(${infoA.name}), [${infoA.name}]);
80
97
  STYLES.codeBlock,
81
98
  ""
82
99
  );
83
- console.groupCollapsed(`%c \u{1F52C} Proof Details `, "color: #636e72; font-size: 10px; cursor: pointer;");
100
+ console.groupCollapsed(`%c \u{1F52C} Proof Details (Mathematical Basis) `, "color: #636e72; font-size: 10px; cursor: pointer;");
84
101
  console.table({
85
102
  "Similarity": `${(sim * 100).toFixed(2)}%`,
86
- "Linear Dependency": "TRUE",
87
- "Rank": totalDimensions - 1
103
+ "Condition": "Collinear Vectors (Dimension Collapse)",
104
+ "Rank Impact": `-1 (Rank: ${totalDimensions - 1})`
88
105
  });
89
106
  console.groupEnd();
90
107
  console.groupEnd();
91
108
  } else {
92
- console.log(`[BASIS] REDUNDANCY DETECTED: ${infoA.name} <-> ${infoB.name} (${(sim * 100).toFixed(0)}% similarity)`);
109
+ console.log(`[BASIS] REDUNDANCY: ${infoA.name} <-> ${infoB.name} (Synchronized Updates)`);
93
110
  console.log(`Location: ${isCrossFile ? `${infoA.file} & ${infoB.file}` : infoA.file}`);
94
111
  }
95
112
  };
@@ -99,7 +116,7 @@ var displayCausalHint = (targetLabel, sourceLabel) => {
99
116
  const isCrossFile = target.file !== source.file;
100
117
  const locationPath = isCrossFile ? `${source.file} \u2794 ${target.file}` : target.file;
101
118
  if (isWeb) {
102
- console.groupCollapsed(`%c \u{1F4A1} BASIS | CAUSALITY (Sequential Update) `, STYLES.headerBlue);
119
+ console.groupCollapsed(`%c \u{1F4A1} BASIS | SYNC LEAK (Double Render Cycle) `, STYLES.headerBlue);
103
120
  console.log(`%c\u{1F4CD} Location: %c${locationPath}`, STYLES.bold, STYLES.location);
104
121
  console.log(
105
122
  `%cSequence:%c %c${source.name}%c \u2794 Effect \u2794 %c${target.name}%c`,
@@ -111,7 +128,8 @@ var displayCausalHint = (targetLabel, sourceLabel) => {
111
128
  ""
112
129
  );
113
130
  console.log(
114
- `%cObservation:%c Variable %c${target.name}%c is being manually synchronized. This creates a %c"Double Render Cycle"%c.`,
131
+ `%cObservation:%c Variable %c${target.name}%c is being manually synchronized from its source.
132
+ This creates a %cDouble Render Cycle%c (Performance Cost). Consider using useMemo or lifting state.`,
115
133
  STYLES.bold,
116
134
  "",
117
135
  STYLES.label,
@@ -121,7 +139,7 @@ var displayCausalHint = (targetLabel, sourceLabel) => {
121
139
  );
122
140
  console.groupEnd();
123
141
  } else {
124
- console.log(`[BASIS] CAUSALITY: ${source.name} \u2794 ${target.name} (Double Render Cycle)`);
142
+ console.log(`[BASIS] SYNC LEAK: ${source.name} \u2794 ${target.name} (Double Render)`);
125
143
  }
126
144
  };
127
145
  var displayInfiniteLoop = (label) => {
@@ -130,13 +148,13 @@ var displayInfiniteLoop = (label) => {
130
148
  console.group(`%c \u{1F6D1} BASIS CRITICAL | CIRCUIT BREAKER `, STYLES.headerRed);
131
149
  console.error(
132
150
  `Infinite oscillation detected on: %c${info.name}%c
133
- Execution halted to prevent browser thread lock.`,
151
+ Execution halted to prevent browser thread lock. Check for circular useEffect dependencies.`,
134
152
  "color: white; background: #d63031; padding: 2px 4px; border-radius: 3px;",
135
153
  ""
136
154
  );
137
155
  console.groupEnd();
138
156
  } else {
139
- console.log(`[BASIS CRITICAL] INFINITE LOOP ON: ${info.name}. Execution halted.`);
157
+ console.log(`[BASIS CRITICAL] CIRCUIT BREAKER: ${info.name}. Execution halted.`);
140
158
  }
141
159
  };
142
160
  var displayHealthReport = (history2, similarityFn, threshold) => {
@@ -165,23 +183,24 @@ var displayHealthReport = (history2, similarityFn, threshold) => {
165
183
  }
166
184
  });
167
185
  const systemRank = independentCount + clusters.length;
168
- const efficiency = systemRank / totalVars * 100;
186
+ const healthScore = systemRank / totalVars * 100;
169
187
  if (isWeb) {
170
- console.group(`%c \u{1F4CA} BASIS | SYSTEM HEALTH REPORT `, STYLES.headerGreen);
188
+ console.group(`%c \u{1F4CA} BASIS | ARCHITECTURAL HEALTH REPORT `, STYLES.headerGreen);
171
189
  console.log(
172
- `%cBasis Efficiency: %c${efficiency.toFixed(1)}% %c(Rank: ${systemRank}/${totalVars})`,
190
+ `%cArchitectural Health Score: %c${healthScore.toFixed(1)}% %c(State Distribution: ${systemRank}/${totalVars})`,
173
191
  STYLES.bold,
174
- `color: ${efficiency > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
192
+ `color: ${healthScore > 85 ? "#00b894" : "#d63031"}; font-size: 16px; font-weight: bold;`,
175
193
  "color: #636e72; font-style: italic;"
176
194
  );
177
195
  if (clusters.length > 0) {
178
- console.log(`%cDetected ${clusters.length} Redundancy Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
196
+ console.log(`%cDetected ${clusters.length} Synchronized Update Clusters:`, "font-weight: bold; color: #e17055; margin-top: 10px;");
179
197
  clusters.forEach((cluster, idx) => {
180
198
  const names = cluster.map((l) => parseLabel(l).name).join(" \u27F7 ");
181
199
  console.log(` %c${idx + 1}%c ${names}`, "background: #e17055; color: white; border-radius: 50%; padding: 0 5px;", "font-family: monospace;");
182
200
  });
201
+ console.log("%c\u{1F4A1} Action: Variables in a cluster move together. Try refactoring them into a single state object or use useMemo for derived values.", STYLES.subText);
183
202
  } else {
184
- console.log("%c\u2728 All state variables are linearly independent. Your Basis is optimal.", "color: #00b894; font-weight: bold; margin-top: 10px;");
203
+ console.log("%c\u2728 All state variables have optimal distribution. Your Basis is healthy.", "color: #00b894; font-weight: bold; margin-top: 10px;");
185
204
  }
186
205
  if (totalVars > 0 && totalVars < 15) {
187
206
  console.groupCollapsed("%cView Full Correlation Matrix", "color: #636e72; font-size: 11px;");
@@ -200,10 +219,7 @@ var displayHealthReport = (history2, similarityFn, threshold) => {
200
219
  }
201
220
  console.groupEnd();
202
221
  } else {
203
- console.log(`[BASIS HEALTH] Efficiency: ${efficiency.toFixed(1)}% (Rank: ${systemRank}/${totalVars})`);
204
- if (clusters.length > 0) {
205
- console.log(`Redundancy Clusters: ${clusters.length}`);
206
- }
222
+ console.log(`[BASIS HEALTH] Score: ${healthScore.toFixed(1)}% (State Distribution: ${systemRank}/${totalVars})`);
207
223
  }
208
224
  };
209
225
 
@@ -345,11 +361,134 @@ var __testEngine__ = {
345
361
  endEffectTracking
346
362
  };
347
363
 
364
+ // src/hooks.ts
365
+ function useState(initialState, label) {
366
+ const [val, setVal] = reactUseState(initialState);
367
+ const effectiveLabel = label || "anonymous_state";
368
+ reactUseEffect(() => {
369
+ registerVariable(effectiveLabel);
370
+ return () => unregisterVariable(effectiveLabel);
371
+ }, [effectiveLabel]);
372
+ const setter = reactUseCallback((newValue) => {
373
+ if (recordUpdate(effectiveLabel)) setVal(newValue);
374
+ }, [effectiveLabel, setVal]);
375
+ return [val, setter];
376
+ }
377
+ function useRef(initialValue, _label) {
378
+ return reactUseRef(initialValue);
379
+ }
380
+ function useReducer(reducer, initialArg, init, label) {
381
+ const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
382
+ const reactInit = typeof init === "function" ? init : void 0;
383
+ const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);
384
+ reactUseEffect(() => {
385
+ registerVariable(effectiveLabel);
386
+ return () => unregisterVariable(effectiveLabel);
387
+ }, [effectiveLabel]);
388
+ const basisDispatch = reactUseCallback((action) => {
389
+ if (recordUpdate(effectiveLabel)) dispatch(action);
390
+ }, [effectiveLabel, dispatch]);
391
+ return [state, basisDispatch];
392
+ }
393
+ function useMemo(factory, deps, label) {
394
+ const effectiveLabel = label || "anonymous_projection";
395
+ reactUseEffect(() => {
396
+ if (config.debug) console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
397
+ }, [effectiveLabel]);
398
+ return reactUseMemo(factory, deps || []);
399
+ }
400
+ function useCallback(callback, deps, label) {
401
+ const effectiveLabel = label || "anonymous_callback";
402
+ reactUseEffect(() => {
403
+ if (config.debug) console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
404
+ }, [effectiveLabel]);
405
+ return reactUseCallback(callback, deps);
406
+ }
407
+ function useEffect(effect, deps, label) {
408
+ const effectiveLabel = label || "anonymous_effect";
409
+ reactUseEffect(() => {
410
+ beginEffectTracking(effectiveLabel);
411
+ const cleanup = effect();
412
+ endEffectTracking();
413
+ return cleanup;
414
+ }, deps);
415
+ }
416
+ function useLayoutEffect(effect, deps, label) {
417
+ const effectiveLabel = label || "anonymous_layout_effect";
418
+ reactUseLayoutEffect(() => {
419
+ beginEffectTracking(effectiveLabel);
420
+ const cleanup = effect();
421
+ endEffectTracking();
422
+ return cleanup;
423
+ }, deps);
424
+ }
425
+ function useTransition(_label) {
426
+ const [isPending, startTransition] = reactUseTransition();
427
+ const effectiveLabel = _label || "anonymous_transition";
428
+ const basisStartTransition = (callback) => {
429
+ if (config.debug) console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
430
+ startTransition(callback);
431
+ };
432
+ return [isPending, basisStartTransition];
433
+ }
434
+ function useDeferredValue(value, initialValueOrLabel, label) {
435
+ const isLabelAsSecondArg = typeof initialValueOrLabel === "string" && label === void 0;
436
+ const actualInitialValue = isLabelAsSecondArg ? void 0 : initialValueOrLabel;
437
+ const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
438
+ const deferredValue = reactUseDeferredValue(value, actualInitialValue);
439
+ reactUseEffect(() => {
440
+ if (config.debug && value !== deferredValue) console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
441
+ }, [value, deferredValue, effectiveLabel]);
442
+ return deferredValue;
443
+ }
444
+ var useId2 = (label) => React.useId();
445
+ var useDebugValue2 = React.useDebugValue;
446
+ var useImperativeHandle2 = React.useImperativeHandle;
447
+ var useInsertionEffect2 = React.useInsertionEffect;
448
+ var useSyncExternalStore = reactUseSyncExternalStore;
449
+ function use(usable) {
450
+ return reactUse(usable);
451
+ }
452
+ function useOptimistic2(passthrough, reducer, label) {
453
+ const effectiveLabel = label || "anonymous_optimistic";
454
+ reactUseEffect(() => {
455
+ registerVariable(effectiveLabel);
456
+ return () => unregisterVariable(effectiveLabel);
457
+ }, [effectiveLabel]);
458
+ const [state, reactAddOptimistic] = React.useOptimistic(passthrough, reducer);
459
+ const addOptimistic = reactUseCallback((payload) => {
460
+ if (recordUpdate(effectiveLabel)) {
461
+ reactAddOptimistic(payload);
462
+ }
463
+ }, [effectiveLabel, reactAddOptimistic]);
464
+ return [state, addOptimistic];
465
+ }
466
+ function useActionState2(action, initialState, permalink, label) {
467
+ const isLabelAsThirdArg = typeof permalink === "string" && label === void 0;
468
+ const actualPermalink = isLabelAsThirdArg ? void 0 : permalink;
469
+ const effectiveLabel = isLabelAsThirdArg ? permalink : label || "anonymous_action_state";
470
+ const [state, reactDispatch, isPending] = React.useActionState(
471
+ action,
472
+ initialState,
473
+ actualPermalink
474
+ );
475
+ reactUseEffect(() => {
476
+ registerVariable(effectiveLabel);
477
+ return () => unregisterVariable(effectiveLabel);
478
+ }, [effectiveLabel]);
479
+ const basisDispatch = reactUseCallback((payload) => {
480
+ if (recordUpdate(effectiveLabel)) {
481
+ reactDispatch(payload);
482
+ }
483
+ }, [effectiveLabel, reactDispatch]);
484
+ return [state, basisDispatch, isPending];
485
+ }
486
+
348
487
  // src/context.tsx
349
- import { createContext, useContext, useLayoutEffect } from "react";
488
+ import { createContext, useContext, useLayoutEffect as useLayoutEffect2 } from "react";
350
489
 
351
490
  // src/ui/BasisHUD.tsx
352
- import { useEffect, useRef, useState } from "react";
491
+ import { useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
353
492
 
354
493
  // src/ui/config.ts
355
494
  var HUD_DIMENSIONS = {
@@ -391,9 +530,9 @@ var getHUDContainerStyle = (isExpanded) => ({
391
530
  // src/ui/BasisHUD.tsx
392
531
  import { jsx, jsxs } from "react/jsx-runtime";
393
532
  var BasisHUD = () => {
394
- const [isExpanded, setIsExpanded] = useState(false);
395
- const canvasRef = useRef(null);
396
- useEffect(() => {
533
+ const [isExpanded, setIsExpanded] = useState2(false);
534
+ const canvasRef = useRef2(null);
535
+ useEffect2(() => {
397
536
  if (!isExpanded) return;
398
537
  let animationFrame;
399
538
  const draw = () => {
@@ -502,7 +641,7 @@ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
502
641
  var BasisContext = createContext({ debug: false });
503
642
  var isWeb2 = typeof window !== "undefined" && typeof window.document !== "undefined";
504
643
  var BasisProvider = ({ children, debug = true }) => {
505
- useLayoutEffect(() => {
644
+ useLayoutEffect2(() => {
506
645
  configureBasis({ debug });
507
646
  if (isWeb2) {
508
647
  window._basis_debug = debug;
@@ -514,230 +653,28 @@ var BasisProvider = ({ children, debug = true }) => {
514
653
  ] });
515
654
  };
516
655
  var useBasisConfig = () => useContext(BasisContext);
517
-
518
- // src/hooks.ts
519
- import * as React3 from "react";
520
- import {
521
- useState as reactUseState,
522
- useEffect as reactUseEffect,
523
- useMemo as reactUseMemo,
524
- useReducer as reactUseReducer,
525
- useContext as reactUseContext,
526
- useSyncExternalStore as reactUseSyncExternalStore,
527
- createContext as reactCreateContext,
528
- useRef as reactUseRef,
529
- useLayoutEffect as reactUseLayoutEffect,
530
- useCallback as reactUseCallback,
531
- useTransition as reactUseTransition,
532
- useDeferredValue as reactUseDeferredValue,
533
- use as reactUse
534
- } from "react";
535
- function useState2(initialState, label) {
536
- const [val, setVal] = reactUseState(initialState);
537
- const effectiveLabel = label || "anonymous_state";
538
- reactUseEffect(() => {
539
- registerVariable(effectiveLabel);
540
- return () => unregisterVariable(effectiveLabel);
541
- }, [effectiveLabel]);
542
- const setter = reactUseCallback((newValue) => {
543
- if (recordUpdate(effectiveLabel)) setVal(newValue);
544
- }, [effectiveLabel, setVal]);
545
- return [val, setter];
546
- }
547
- function useRef2(initialValue, _label) {
548
- return reactUseRef(initialValue);
549
- }
550
- function useReducer(reducer, initialArg, init, label) {
551
- const effectiveLabel = typeof init === "string" ? init : label || "anonymous_reducer";
552
- const reactInit = typeof init === "function" ? init : void 0;
553
- const [state, dispatch] = reactUseReducer(reducer, initialArg, reactInit);
554
- reactUseEffect(() => {
555
- registerVariable(effectiveLabel);
556
- return () => unregisterVariable(effectiveLabel);
557
- }, [effectiveLabel]);
558
- const basisDispatch = reactUseCallback((action) => {
559
- if (recordUpdate(effectiveLabel)) dispatch(action);
560
- }, [effectiveLabel, dispatch]);
561
- return [state, basisDispatch];
562
- }
563
- function useMemo(factory, deps, label) {
564
- const effectiveLabel = label || "anonymous_projection";
565
- reactUseEffect(() => {
566
- if (config.debug) console.log(`%c [Basis] Valid Projection: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
567
- }, [effectiveLabel]);
568
- return reactUseMemo(factory, deps || []);
569
- }
570
- function useCallback(callback, deps, label) {
571
- const effectiveLabel = label || "anonymous_callback";
572
- reactUseEffect(() => {
573
- if (config.debug) console.log(`%c [Basis] Stable Callback: "${effectiveLabel}" `, "color: #2ecc71; font-weight: bold;");
574
- }, [effectiveLabel]);
575
- return reactUseCallback(callback, deps);
576
- }
577
- function useEffect2(effect, deps, label) {
578
- const effectiveLabel = label || "anonymous_effect";
579
- reactUseEffect(() => {
580
- beginEffectTracking(effectiveLabel);
581
- const cleanup = effect();
582
- endEffectTracking();
583
- return cleanup;
584
- }, deps);
585
- }
586
- function useLayoutEffect2(effect, deps, label) {
587
- const effectiveLabel = label || "anonymous_layout_effect";
588
- reactUseLayoutEffect(() => {
589
- beginEffectTracking(effectiveLabel);
590
- const cleanup = effect();
591
- endEffectTracking();
592
- return cleanup;
593
- }, deps);
594
- }
595
- function useTransition(_label) {
596
- const [isPending, startTransition3] = reactUseTransition();
597
- const effectiveLabel = _label || "anonymous_transition";
598
- const basisStartTransition = (callback) => {
599
- if (config.debug) console.log(`%c [Basis] Transition Started: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
600
- startTransition3(callback);
601
- };
602
- return [isPending, basisStartTransition];
603
- }
604
- function useDeferredValue(value, initialValueOrLabel, label) {
605
- const isLabelAsSecondArg = typeof initialValueOrLabel === "string" && label === void 0;
606
- const actualInitialValue = isLabelAsSecondArg ? void 0 : initialValueOrLabel;
607
- const effectiveLabel = isLabelAsSecondArg ? initialValueOrLabel : label || "anonymous_deferred";
608
- const deferredValue = reactUseDeferredValue(value, actualInitialValue);
609
- reactUseEffect(() => {
610
- if (config.debug && value !== deferredValue) console.log(`%c [Basis] Value Deferred: "${effectiveLabel}" `, "color: #e67e22; font-weight: bold;");
611
- }, [value, deferredValue, effectiveLabel]);
612
- return deferredValue;
613
- }
614
- function createContext2(defaultValue, label) {
615
- const context = reactCreateContext(defaultValue);
616
- if (label) context._basis_label = label;
617
- return context;
618
- }
619
- var useContext2 = reactUseContext;
620
- var useId2 = (label) => React3.useId();
621
- var useDebugValue2 = React3.useDebugValue;
622
- var useImperativeHandle2 = React3.useImperativeHandle;
623
- var useInsertionEffect2 = React3.useInsertionEffect;
624
- var useSyncExternalStore = reactUseSyncExternalStore;
625
- function use(usable) {
626
- return reactUse(usable);
627
- }
628
- function useOptimistic2(passthrough, reducer, label) {
629
- const effectiveLabel = label || "anonymous_optimistic";
630
- reactUseEffect(() => {
631
- registerVariable(effectiveLabel);
632
- return () => unregisterVariable(effectiveLabel);
633
- }, [effectiveLabel]);
634
- const [state, reactAddOptimistic] = React3.useOptimistic(passthrough, reducer);
635
- const addOptimistic = reactUseCallback((payload) => {
636
- if (recordUpdate(effectiveLabel)) {
637
- reactAddOptimistic(payload);
638
- }
639
- }, [effectiveLabel, reactAddOptimistic]);
640
- return [state, addOptimistic];
641
- }
642
- function useActionState2(action, initialState, permalink, label) {
643
- const isLabelAsThirdArg = typeof permalink === "string" && label === void 0;
644
- const actualPermalink = isLabelAsThirdArg ? void 0 : permalink;
645
- const effectiveLabel = isLabelAsThirdArg ? permalink : label || "anonymous_action_state";
646
- const [state, reactDispatch, isPending] = React3.useActionState(
647
- action,
648
- initialState,
649
- actualPermalink
650
- );
651
- reactUseEffect(() => {
652
- registerVariable(effectiveLabel);
653
- return () => unregisterVariable(effectiveLabel);
654
- }, [effectiveLabel]);
655
- const basisDispatch = reactUseCallback((payload) => {
656
- if (recordUpdate(effectiveLabel)) {
657
- reactDispatch(payload);
658
- }
659
- }, [effectiveLabel, reactDispatch]);
660
- return [state, basisDispatch, isPending];
661
- }
662
- var __test__ = { registerVariable, unregisterVariable, recordUpdate, beginEffectTracking, endEffectTracking, history, currentTickBatch };
663
-
664
- // src/index.ts
665
- var Children2 = ReactNamespace.Children;
666
- var Component2 = ReactNamespace.Component;
667
- var Fragment2 = ReactNamespace.Fragment;
668
- var Profiler2 = ReactNamespace.Profiler;
669
- var PureComponent2 = ReactNamespace.PureComponent;
670
- var StrictMode2 = ReactNamespace.StrictMode;
671
- var Suspense2 = ReactNamespace.Suspense;
672
- var cloneElement2 = ReactNamespace.cloneElement;
673
- var createElement2 = ReactNamespace.createElement;
674
- var createRef2 = ReactNamespace.createRef;
675
- var forwardRef2 = ReactNamespace.forwardRef;
676
- var isValidElement2 = ReactNamespace.isValidElement;
677
- var lazy2 = ReactNamespace.lazy;
678
- var memo2 = ReactNamespace.memo;
679
- var startTransition2 = ReactNamespace.startTransition;
680
- var version2 = ReactNamespace.version;
681
- var RD = ReactDOMNamespace;
682
- var createPortal = RD.createPortal;
683
- var flushSync = RD.flushSync;
684
- var unstable_batchedUpdates = RD.unstable_batchedUpdates;
685
- var index_default = ReactNamespace;
686
656
  export {
687
657
  BasisProvider,
688
- Children2 as Children,
689
- Component2 as Component,
690
- Fragment2 as Fragment,
691
- Profiler2 as Profiler,
692
- PureComponent2 as PureComponent,
693
- ReactNamespace as React,
694
- StrictMode2 as StrictMode,
695
- Suspense2 as Suspense,
696
- __testEngine__,
697
- __test__,
698
658
  basis,
699
- beginEffectTracking,
700
- cloneElement2 as cloneElement,
701
- config,
702
659
  configureBasis,
703
- createContext2 as createContext,
704
- createElement2 as createElement,
705
- createPortal,
706
- createRef2 as createRef,
707
- currentTickBatch,
708
- index_default as default,
709
- endEffectTracking,
710
- flushSync,
711
- forwardRef2 as forwardRef,
712
- history,
713
- isValidElement2 as isValidElement,
714
- lazy2 as lazy,
715
- memo2 as memo,
716
660
  printBasisHealthReport,
717
- recordUpdate,
718
- registerVariable,
719
- startTransition2 as startTransition,
720
- unregisterVariable,
721
- unstable_batchedUpdates,
722
661
  use,
723
662
  useActionState2 as useActionState,
724
663
  useBasisConfig,
725
664
  useCallback,
726
- useContext2 as useContext,
727
665
  useDebugValue2 as useDebugValue,
728
666
  useDeferredValue,
729
- useEffect2 as useEffect,
667
+ useEffect,
730
668
  useId2 as useId,
731
669
  useImperativeHandle2 as useImperativeHandle,
732
670
  useInsertionEffect2 as useInsertionEffect,
733
- useLayoutEffect2 as useLayoutEffect,
671
+ useLayoutEffect,
734
672
  useMemo,
735
673
  useOptimistic2 as useOptimistic,
736
674
  useReducer,
737
- useRef2 as useRef,
738
- useState2 as useState,
675
+ useRef,
676
+ useState,
739
677
  useSyncExternalStore,
740
- useTransition,
741
- version2 as version
678
+ useTransition
742
679
  };
743
680
  //# sourceMappingURL=index.mjs.map