recoil-next 0.1.0 → 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 ADDED
@@ -0,0 +1,93 @@
1
+ # Recoil Next
2
+
3
+ A continuation of Facebook's Recoil state management library for React, maintained by the community after Meta discontinued the project.
4
+
5
+ ## Overview
6
+
7
+ Recoil Next provides state management for React apps. It provides several capabilities that are difficult to achieve with React alone, while being compatible with the newest features of React.
8
+
9
+ ## Key Features
10
+
11
+ - **Minimal and Reactish**: Recoil works and thinks like React. Add some to your app and get going.
12
+ - **Data-Flow Graph**: Derived data and asynchronous queries are tamed with pure functions and efficient subscriptions.
13
+ - **Cross-App Observation**: Implement persistence, routing, time-travel debugging, or undo by observing all state changes across your app, without impairing code-splitting.
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install recoil-next
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ```jsx
24
+ import React from 'react';
25
+ import { RecoilRoot, atom, useRecoilState } from 'recoil-next';
26
+
27
+ const textState = atom({
28
+ key: 'textState',
29
+ default: '',
30
+ });
31
+
32
+ function App() {
33
+ return (
34
+ <RecoilRoot>
35
+ <CharacterCounter />
36
+ </RecoilRoot>
37
+ );
38
+ }
39
+
40
+ function CharacterCounter() {
41
+ const [text, setText] = useRecoilState(textState);
42
+
43
+ return (
44
+ <div>
45
+ <input type="text" value={text} onChange={(e) => setText(e.target.value)} />
46
+ <p>Character count: {text.length}</p>
47
+ </div>
48
+ );
49
+ }
50
+ ```
51
+
52
+ ## API Reference
53
+
54
+ ### Core Concepts
55
+
56
+ - **Atoms**: Units of state that components can subscribe to
57
+ - **Selectors**: Pure functions that derive state from atoms or other selectors
58
+ - **RecoilRoot**: Provides context for Recoil state
59
+
60
+ ### Hooks
61
+
62
+ - `useRecoilState(state)` - Returns a tuple of the state value and setter
63
+ - `useRecoilValue(state)` - Returns the state value
64
+ - `useSetRecoilState(state)` - Returns the state setter function
65
+ - `useResetRecoilState(state)` - Returns a function to reset state to default
66
+
67
+ ## Migration from Recoil
68
+
69
+ This library is a drop-in replacement for the original Recoil library. Simply replace your import:
70
+
71
+ ```jsx
72
+ // Before
73
+ import { RecoilRoot, atom, useRecoilState } from 'recoil';
74
+
75
+ // After
76
+ import { RecoilRoot, atom, useRecoilState } from 'recoil-next';
77
+ ```
78
+
79
+ ## Requirements
80
+
81
+ - React 18.0.0 or later
82
+
83
+ ## License
84
+
85
+ MIT
86
+
87
+ ## Contributing
88
+
89
+ Contributions are welcome! Please feel free to submit a Pull Request.
90
+
91
+ ## Community
92
+
93
+ This is a community-maintained continuation of the original Recoil project. We aim to maintain compatibility while adding new features and improvements.
package/dist/index.cjs CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var jsxRuntime = require('react/jsx-runtime');
3
4
  var React = require('react');
4
5
  var reactDom = require('react-dom');
5
6
 
@@ -452,437 +453,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
452
453
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
453
454
  };
454
455
 
455
- function getDefaultExportFromCjs (x) {
456
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
457
- }
458
-
459
- var jsxRuntime = {exports: {}};
460
-
461
- var reactJsxRuntime_production = {};
462
-
463
- /**
464
- * @license React
465
- * react-jsx-runtime.production.js
466
- *
467
- * Copyright (c) Meta Platforms, Inc. and affiliates.
468
- *
469
- * This source code is licensed under the MIT license found in the
470
- * LICENSE file in the root directory of this source tree.
471
- */
472
-
473
- var hasRequiredReactJsxRuntime_production;
474
-
475
- function requireReactJsxRuntime_production () {
476
- if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
477
- hasRequiredReactJsxRuntime_production = 1;
478
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
479
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
480
- function jsxProd(type, config, maybeKey) {
481
- var key = null;
482
- void 0 !== maybeKey && (key = "" + maybeKey);
483
- void 0 !== config.key && (key = "" + config.key);
484
- if ("key" in config) {
485
- maybeKey = {};
486
- for (var propName in config)
487
- "key" !== propName && (maybeKey[propName] = config[propName]);
488
- } else maybeKey = config;
489
- config = maybeKey.ref;
490
- return {
491
- $$typeof: REACT_ELEMENT_TYPE,
492
- type: type,
493
- key: key,
494
- ref: void 0 !== config ? config : null,
495
- props: maybeKey
496
- };
497
- }
498
- reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
499
- reactJsxRuntime_production.jsx = jsxProd;
500
- reactJsxRuntime_production.jsxs = jsxProd;
501
- return reactJsxRuntime_production;
502
- }
503
-
504
- var reactJsxRuntime_development = {};
505
-
506
- /**
507
- * @license React
508
- * react-jsx-runtime.development.js
509
- *
510
- * Copyright (c) Meta Platforms, Inc. and affiliates.
511
- *
512
- * This source code is licensed under the MIT license found in the
513
- * LICENSE file in the root directory of this source tree.
514
- */
515
-
516
- var hasRequiredReactJsxRuntime_development;
517
-
518
- function requireReactJsxRuntime_development () {
519
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
520
- hasRequiredReactJsxRuntime_development = 1;
521
- "production" !== process.env.NODE_ENV &&
522
- (function () {
523
- function getComponentNameFromType(type) {
524
- if (null == type) return null;
525
- if ("function" === typeof type)
526
- return type.$$typeof === REACT_CLIENT_REFERENCE
527
- ? null
528
- : type.displayName || type.name || null;
529
- if ("string" === typeof type) return type;
530
- switch (type) {
531
- case REACT_FRAGMENT_TYPE:
532
- return "Fragment";
533
- case REACT_PROFILER_TYPE:
534
- return "Profiler";
535
- case REACT_STRICT_MODE_TYPE:
536
- return "StrictMode";
537
- case REACT_SUSPENSE_TYPE:
538
- return "Suspense";
539
- case REACT_SUSPENSE_LIST_TYPE:
540
- return "SuspenseList";
541
- case REACT_ACTIVITY_TYPE:
542
- return "Activity";
543
- }
544
- if ("object" === typeof type)
545
- switch (
546
- ("number" === typeof type.tag &&
547
- console.error(
548
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
549
- ),
550
- type.$$typeof)
551
- ) {
552
- case REACT_PORTAL_TYPE:
553
- return "Portal";
554
- case REACT_CONTEXT_TYPE:
555
- return (type.displayName || "Context") + ".Provider";
556
- case REACT_CONSUMER_TYPE:
557
- return (type._context.displayName || "Context") + ".Consumer";
558
- case REACT_FORWARD_REF_TYPE:
559
- var innerType = type.render;
560
- type = type.displayName;
561
- type ||
562
- ((type = innerType.displayName || innerType.name || ""),
563
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
564
- return type;
565
- case REACT_MEMO_TYPE:
566
- return (
567
- (innerType = type.displayName || null),
568
- null !== innerType
569
- ? innerType
570
- : getComponentNameFromType(type.type) || "Memo"
571
- );
572
- case REACT_LAZY_TYPE:
573
- innerType = type._payload;
574
- type = type._init;
575
- try {
576
- return getComponentNameFromType(type(innerType));
577
- } catch (x) {}
578
- }
579
- return null;
580
- }
581
- function testStringCoercion(value) {
582
- return "" + value;
583
- }
584
- function checkKeyStringCoercion(value) {
585
- try {
586
- testStringCoercion(value);
587
- var JSCompiler_inline_result = !1;
588
- } catch (e) {
589
- JSCompiler_inline_result = true;
590
- }
591
- if (JSCompiler_inline_result) {
592
- JSCompiler_inline_result = console;
593
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
594
- var JSCompiler_inline_result$jscomp$0 =
595
- ("function" === typeof Symbol &&
596
- Symbol.toStringTag &&
597
- value[Symbol.toStringTag]) ||
598
- value.constructor.name ||
599
- "Object";
600
- JSCompiler_temp_const.call(
601
- JSCompiler_inline_result,
602
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
603
- JSCompiler_inline_result$jscomp$0
604
- );
605
- return testStringCoercion(value);
606
- }
607
- }
608
- function getTaskName(type) {
609
- if (type === REACT_FRAGMENT_TYPE) return "<>";
610
- if (
611
- "object" === typeof type &&
612
- null !== type &&
613
- type.$$typeof === REACT_LAZY_TYPE
614
- )
615
- return "<...>";
616
- try {
617
- var name = getComponentNameFromType(type);
618
- return name ? "<" + name + ">" : "<...>";
619
- } catch (x) {
620
- return "<...>";
621
- }
622
- }
623
- function getOwner() {
624
- var dispatcher = ReactSharedInternals.A;
625
- return null === dispatcher ? null : dispatcher.getOwner();
626
- }
627
- function UnknownOwner() {
628
- return Error("react-stack-top-frame");
629
- }
630
- function hasValidKey(config) {
631
- if (hasOwnProperty.call(config, "key")) {
632
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
633
- if (getter && getter.isReactWarning) return false;
634
- }
635
- return void 0 !== config.key;
636
- }
637
- function defineKeyPropWarningGetter(props, displayName) {
638
- function warnAboutAccessingKey() {
639
- specialPropKeyWarningShown ||
640
- ((specialPropKeyWarningShown = true),
641
- console.error(
642
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
643
- displayName
644
- ));
645
- }
646
- warnAboutAccessingKey.isReactWarning = true;
647
- Object.defineProperty(props, "key", {
648
- get: warnAboutAccessingKey,
649
- configurable: true
650
- });
651
- }
652
- function elementRefGetterWithDeprecationWarning() {
653
- var componentName = getComponentNameFromType(this.type);
654
- didWarnAboutElementRef[componentName] ||
655
- ((didWarnAboutElementRef[componentName] = true),
656
- console.error(
657
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
658
- ));
659
- componentName = this.props.ref;
660
- return void 0 !== componentName ? componentName : null;
661
- }
662
- function ReactElement(
663
- type,
664
- key,
665
- self,
666
- source,
667
- owner,
668
- props,
669
- debugStack,
670
- debugTask
671
- ) {
672
- self = props.ref;
673
- type = {
674
- $$typeof: REACT_ELEMENT_TYPE,
675
- type: type,
676
- key: key,
677
- props: props,
678
- _owner: owner
679
- };
680
- null !== (void 0 !== self ? self : null)
681
- ? Object.defineProperty(type, "ref", {
682
- enumerable: false,
683
- get: elementRefGetterWithDeprecationWarning
684
- })
685
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
686
- type._store = {};
687
- Object.defineProperty(type._store, "validated", {
688
- configurable: false,
689
- enumerable: false,
690
- writable: true,
691
- value: 0
692
- });
693
- Object.defineProperty(type, "_debugInfo", {
694
- configurable: false,
695
- enumerable: false,
696
- writable: true,
697
- value: null
698
- });
699
- Object.defineProperty(type, "_debugStack", {
700
- configurable: false,
701
- enumerable: false,
702
- writable: true,
703
- value: debugStack
704
- });
705
- Object.defineProperty(type, "_debugTask", {
706
- configurable: false,
707
- enumerable: false,
708
- writable: true,
709
- value: debugTask
710
- });
711
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
712
- return type;
713
- }
714
- function jsxDEVImpl(
715
- type,
716
- config,
717
- maybeKey,
718
- isStaticChildren,
719
- source,
720
- self,
721
- debugStack,
722
- debugTask
723
- ) {
724
- var children = config.children;
725
- if (void 0 !== children)
726
- if (isStaticChildren)
727
- if (isArrayImpl(children)) {
728
- for (
729
- isStaticChildren = 0;
730
- isStaticChildren < children.length;
731
- isStaticChildren++
732
- )
733
- validateChildKeys(children[isStaticChildren]);
734
- Object.freeze && Object.freeze(children);
735
- } else
736
- console.error(
737
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
738
- );
739
- else validateChildKeys(children);
740
- if (hasOwnProperty.call(config, "key")) {
741
- children = getComponentNameFromType(type);
742
- var keys = Object.keys(config).filter(function (k) {
743
- return "key" !== k;
744
- });
745
- isStaticChildren =
746
- 0 < keys.length
747
- ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
748
- : "{key: someKey}";
749
- didWarnAboutKeySpread[children + isStaticChildren] ||
750
- ((keys =
751
- 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
752
- console.error(
753
- 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
754
- isStaticChildren,
755
- children,
756
- keys,
757
- children
758
- ),
759
- (didWarnAboutKeySpread[children + isStaticChildren] = true));
760
- }
761
- children = null;
762
- void 0 !== maybeKey &&
763
- (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
764
- hasValidKey(config) &&
765
- (checkKeyStringCoercion(config.key), (children = "" + config.key));
766
- if ("key" in config) {
767
- maybeKey = {};
768
- for (var propName in config)
769
- "key" !== propName && (maybeKey[propName] = config[propName]);
770
- } else maybeKey = config;
771
- children &&
772
- defineKeyPropWarningGetter(
773
- maybeKey,
774
- "function" === typeof type
775
- ? type.displayName || type.name || "Unknown"
776
- : type
777
- );
778
- return ReactElement(
779
- type,
780
- children,
781
- self,
782
- source,
783
- getOwner(),
784
- maybeKey,
785
- debugStack,
786
- debugTask
787
- );
788
- }
789
- function validateChildKeys(node) {
790
- "object" === typeof node &&
791
- null !== node &&
792
- node.$$typeof === REACT_ELEMENT_TYPE &&
793
- node._store &&
794
- (node._store.validated = 1);
795
- }
796
- var React$1 = React,
797
- REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
798
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
799
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
800
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
801
- REACT_PROFILER_TYPE = Symbol.for("react.profiler");
802
- var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
803
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
804
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
805
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
806
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
807
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
808
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
809
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
810
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
811
- ReactSharedInternals =
812
- React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
813
- hasOwnProperty = Object.prototype.hasOwnProperty,
814
- isArrayImpl = Array.isArray,
815
- createTask = console.createTask
816
- ? console.createTask
817
- : function () {
818
- return null;
819
- };
820
- React$1 = {
821
- "react-stack-bottom-frame": function (callStackForError) {
822
- return callStackForError();
823
- }
824
- };
825
- var specialPropKeyWarningShown;
826
- var didWarnAboutElementRef = {};
827
- var unknownOwnerDebugStack = React$1["react-stack-bottom-frame"].bind(
828
- React$1,
829
- UnknownOwner
830
- )();
831
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
832
- var didWarnAboutKeySpread = {};
833
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
834
- reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
835
- var trackActualOwner =
836
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
837
- return jsxDEVImpl(
838
- type,
839
- config,
840
- maybeKey,
841
- false,
842
- source,
843
- self,
844
- trackActualOwner
845
- ? Error("react-stack-top-frame")
846
- : unknownOwnerDebugStack,
847
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
848
- );
849
- };
850
- reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
851
- var trackActualOwner =
852
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
853
- return jsxDEVImpl(
854
- type,
855
- config,
856
- maybeKey,
857
- true,
858
- source,
859
- self,
860
- trackActualOwner
861
- ? Error("react-stack-top-frame")
862
- : unknownOwnerDebugStack,
863
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
864
- );
865
- };
866
- })();
867
- return reactJsxRuntime_development;
868
- }
869
-
870
- var hasRequiredJsxRuntime;
871
-
872
- function requireJsxRuntime () {
873
- if (hasRequiredJsxRuntime) return jsxRuntime.exports;
874
- hasRequiredJsxRuntime = 1;
875
-
876
- if (process.env.NODE_ENV === 'production') {
877
- jsxRuntime.exports = requireReactJsxRuntime_production();
878
- } else {
879
- jsxRuntime.exports = requireReactJsxRuntime_development();
880
- }
881
- return jsxRuntime.exports;
882
- }
883
-
884
- var jsxRuntimeExports = requireJsxRuntime();
885
-
886
456
  /**
887
457
  * TypeScript port of Recoil_unionSets.js
888
458
  */
@@ -1660,6 +1230,10 @@ function batchUpdates(callback) {
1660
1230
  });
1661
1231
  }
1662
1232
 
1233
+ function getDefaultExportFromCjs (x) {
1234
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1235
+ }
1236
+
1663
1237
  var hamt$1 = {exports: {}};
1664
1238
 
1665
1239
  var hasRequiredHamt;
@@ -3414,7 +2988,7 @@ children, skipCircularDependencyDetection_DANGEROUS, }) {
3414
2988
  }
3415
2989
  };
3416
2990
  }, [storeRef]);
3417
- return (jsxRuntimeExports.jsxs(AppContext.Provider, { value: storeRef, children: [jsxRuntimeExports.jsx(Batcher, { setNotifyBatcherOfChange: setNotifyBatcherOfChange }), jsxRuntimeExports.jsx(React.Suspense, { fallback: jsxRuntimeExports.jsx(RecoilSuspenseWarning, {}), children: children })] }));
2991
+ return (jsxRuntime.jsxs(AppContext.Provider, { value: storeRef, children: [jsxRuntime.jsx(Batcher, { setNotifyBatcherOfChange: setNotifyBatcherOfChange }), jsxRuntime.jsx(React.Suspense, { fallback: jsxRuntime.jsx(RecoilSuspenseWarning, {}), children: children })] }));
3418
2992
  }
3419
2993
  function RecoilRoot(props) {
3420
2994
  const { override, store } = props, propsExceptOverride = __rest(props, ["override", "store"]);
@@ -3426,7 +3000,7 @@ function RecoilRoot(props) {
3426
3000
  }
3427
3001
  // Map `store` prop to `store_INTERNAL` for backward compatibility
3428
3002
  const internalProps = Object.assign(Object.assign({}, propsExceptOverride), { store_INTERNAL: propsExceptOverride.store_INTERNAL || store });
3429
- return jsxRuntimeExports.jsx(RecoilRoot_INTERNAL, Object.assign({}, internalProps));
3003
+ return jsxRuntime.jsx(RecoilRoot_INTERNAL, Object.assign({}, internalProps));
3430
3004
  }
3431
3005
  function useRecoilStoreID() {
3432
3006
  return useStoreRef().current.storeID;
@@ -3920,7 +3494,7 @@ function useRecoilBridgeAcrossReactRoots() {
3920
3494
  return React.useMemo(() => {
3921
3495
  // eslint-disable-next-line no-shadow
3922
3496
  function RecoilBridge({ children }) {
3923
- return jsxRuntimeExports.jsx(RecoilRoot, { store: store, children: children });
3497
+ return jsxRuntime.jsx(RecoilRoot, { store: store, children: children });
3924
3498
  }
3925
3499
  return RecoilBridge;
3926
3500
  }, [store]);
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
1
2
  import React, { useRef, createContext, useContext, useCallback, useEffect, Suspense, useState, useMemo, useSyncExternalStore as useSyncExternalStore$1 } from 'react';
2
3
  import { unstable_batchedUpdates } from 'react-dom';
3
4
 
@@ -450,437 +451,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
450
451
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
451
452
  };
452
453
 
453
- function getDefaultExportFromCjs (x) {
454
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
455
- }
456
-
457
- var jsxRuntime = {exports: {}};
458
-
459
- var reactJsxRuntime_production = {};
460
-
461
- /**
462
- * @license React
463
- * react-jsx-runtime.production.js
464
- *
465
- * Copyright (c) Meta Platforms, Inc. and affiliates.
466
- *
467
- * This source code is licensed under the MIT license found in the
468
- * LICENSE file in the root directory of this source tree.
469
- */
470
-
471
- var hasRequiredReactJsxRuntime_production;
472
-
473
- function requireReactJsxRuntime_production () {
474
- if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
475
- hasRequiredReactJsxRuntime_production = 1;
476
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
477
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
478
- function jsxProd(type, config, maybeKey) {
479
- var key = null;
480
- void 0 !== maybeKey && (key = "" + maybeKey);
481
- void 0 !== config.key && (key = "" + config.key);
482
- if ("key" in config) {
483
- maybeKey = {};
484
- for (var propName in config)
485
- "key" !== propName && (maybeKey[propName] = config[propName]);
486
- } else maybeKey = config;
487
- config = maybeKey.ref;
488
- return {
489
- $$typeof: REACT_ELEMENT_TYPE,
490
- type: type,
491
- key: key,
492
- ref: void 0 !== config ? config : null,
493
- props: maybeKey
494
- };
495
- }
496
- reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
497
- reactJsxRuntime_production.jsx = jsxProd;
498
- reactJsxRuntime_production.jsxs = jsxProd;
499
- return reactJsxRuntime_production;
500
- }
501
-
502
- var reactJsxRuntime_development = {};
503
-
504
- /**
505
- * @license React
506
- * react-jsx-runtime.development.js
507
- *
508
- * Copyright (c) Meta Platforms, Inc. and affiliates.
509
- *
510
- * This source code is licensed under the MIT license found in the
511
- * LICENSE file in the root directory of this source tree.
512
- */
513
-
514
- var hasRequiredReactJsxRuntime_development;
515
-
516
- function requireReactJsxRuntime_development () {
517
- if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
518
- hasRequiredReactJsxRuntime_development = 1;
519
- "production" !== process.env.NODE_ENV &&
520
- (function () {
521
- function getComponentNameFromType(type) {
522
- if (null == type) return null;
523
- if ("function" === typeof type)
524
- return type.$$typeof === REACT_CLIENT_REFERENCE
525
- ? null
526
- : type.displayName || type.name || null;
527
- if ("string" === typeof type) return type;
528
- switch (type) {
529
- case REACT_FRAGMENT_TYPE:
530
- return "Fragment";
531
- case REACT_PROFILER_TYPE:
532
- return "Profiler";
533
- case REACT_STRICT_MODE_TYPE:
534
- return "StrictMode";
535
- case REACT_SUSPENSE_TYPE:
536
- return "Suspense";
537
- case REACT_SUSPENSE_LIST_TYPE:
538
- return "SuspenseList";
539
- case REACT_ACTIVITY_TYPE:
540
- return "Activity";
541
- }
542
- if ("object" === typeof type)
543
- switch (
544
- ("number" === typeof type.tag &&
545
- console.error(
546
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
547
- ),
548
- type.$$typeof)
549
- ) {
550
- case REACT_PORTAL_TYPE:
551
- return "Portal";
552
- case REACT_CONTEXT_TYPE:
553
- return (type.displayName || "Context") + ".Provider";
554
- case REACT_CONSUMER_TYPE:
555
- return (type._context.displayName || "Context") + ".Consumer";
556
- case REACT_FORWARD_REF_TYPE:
557
- var innerType = type.render;
558
- type = type.displayName;
559
- type ||
560
- ((type = innerType.displayName || innerType.name || ""),
561
- (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
562
- return type;
563
- case REACT_MEMO_TYPE:
564
- return (
565
- (innerType = type.displayName || null),
566
- null !== innerType
567
- ? innerType
568
- : getComponentNameFromType(type.type) || "Memo"
569
- );
570
- case REACT_LAZY_TYPE:
571
- innerType = type._payload;
572
- type = type._init;
573
- try {
574
- return getComponentNameFromType(type(innerType));
575
- } catch (x) {}
576
- }
577
- return null;
578
- }
579
- function testStringCoercion(value) {
580
- return "" + value;
581
- }
582
- function checkKeyStringCoercion(value) {
583
- try {
584
- testStringCoercion(value);
585
- var JSCompiler_inline_result = !1;
586
- } catch (e) {
587
- JSCompiler_inline_result = true;
588
- }
589
- if (JSCompiler_inline_result) {
590
- JSCompiler_inline_result = console;
591
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
592
- var JSCompiler_inline_result$jscomp$0 =
593
- ("function" === typeof Symbol &&
594
- Symbol.toStringTag &&
595
- value[Symbol.toStringTag]) ||
596
- value.constructor.name ||
597
- "Object";
598
- JSCompiler_temp_const.call(
599
- JSCompiler_inline_result,
600
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
601
- JSCompiler_inline_result$jscomp$0
602
- );
603
- return testStringCoercion(value);
604
- }
605
- }
606
- function getTaskName(type) {
607
- if (type === REACT_FRAGMENT_TYPE) return "<>";
608
- if (
609
- "object" === typeof type &&
610
- null !== type &&
611
- type.$$typeof === REACT_LAZY_TYPE
612
- )
613
- return "<...>";
614
- try {
615
- var name = getComponentNameFromType(type);
616
- return name ? "<" + name + ">" : "<...>";
617
- } catch (x) {
618
- return "<...>";
619
- }
620
- }
621
- function getOwner() {
622
- var dispatcher = ReactSharedInternals.A;
623
- return null === dispatcher ? null : dispatcher.getOwner();
624
- }
625
- function UnknownOwner() {
626
- return Error("react-stack-top-frame");
627
- }
628
- function hasValidKey(config) {
629
- if (hasOwnProperty.call(config, "key")) {
630
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
631
- if (getter && getter.isReactWarning) return false;
632
- }
633
- return void 0 !== config.key;
634
- }
635
- function defineKeyPropWarningGetter(props, displayName) {
636
- function warnAboutAccessingKey() {
637
- specialPropKeyWarningShown ||
638
- ((specialPropKeyWarningShown = true),
639
- console.error(
640
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
641
- displayName
642
- ));
643
- }
644
- warnAboutAccessingKey.isReactWarning = true;
645
- Object.defineProperty(props, "key", {
646
- get: warnAboutAccessingKey,
647
- configurable: true
648
- });
649
- }
650
- function elementRefGetterWithDeprecationWarning() {
651
- var componentName = getComponentNameFromType(this.type);
652
- didWarnAboutElementRef[componentName] ||
653
- ((didWarnAboutElementRef[componentName] = true),
654
- console.error(
655
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
656
- ));
657
- componentName = this.props.ref;
658
- return void 0 !== componentName ? componentName : null;
659
- }
660
- function ReactElement(
661
- type,
662
- key,
663
- self,
664
- source,
665
- owner,
666
- props,
667
- debugStack,
668
- debugTask
669
- ) {
670
- self = props.ref;
671
- type = {
672
- $$typeof: REACT_ELEMENT_TYPE,
673
- type: type,
674
- key: key,
675
- props: props,
676
- _owner: owner
677
- };
678
- null !== (void 0 !== self ? self : null)
679
- ? Object.defineProperty(type, "ref", {
680
- enumerable: false,
681
- get: elementRefGetterWithDeprecationWarning
682
- })
683
- : Object.defineProperty(type, "ref", { enumerable: false, value: null });
684
- type._store = {};
685
- Object.defineProperty(type._store, "validated", {
686
- configurable: false,
687
- enumerable: false,
688
- writable: true,
689
- value: 0
690
- });
691
- Object.defineProperty(type, "_debugInfo", {
692
- configurable: false,
693
- enumerable: false,
694
- writable: true,
695
- value: null
696
- });
697
- Object.defineProperty(type, "_debugStack", {
698
- configurable: false,
699
- enumerable: false,
700
- writable: true,
701
- value: debugStack
702
- });
703
- Object.defineProperty(type, "_debugTask", {
704
- configurable: false,
705
- enumerable: false,
706
- writable: true,
707
- value: debugTask
708
- });
709
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
710
- return type;
711
- }
712
- function jsxDEVImpl(
713
- type,
714
- config,
715
- maybeKey,
716
- isStaticChildren,
717
- source,
718
- self,
719
- debugStack,
720
- debugTask
721
- ) {
722
- var children = config.children;
723
- if (void 0 !== children)
724
- if (isStaticChildren)
725
- if (isArrayImpl(children)) {
726
- for (
727
- isStaticChildren = 0;
728
- isStaticChildren < children.length;
729
- isStaticChildren++
730
- )
731
- validateChildKeys(children[isStaticChildren]);
732
- Object.freeze && Object.freeze(children);
733
- } else
734
- console.error(
735
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
736
- );
737
- else validateChildKeys(children);
738
- if (hasOwnProperty.call(config, "key")) {
739
- children = getComponentNameFromType(type);
740
- var keys = Object.keys(config).filter(function (k) {
741
- return "key" !== k;
742
- });
743
- isStaticChildren =
744
- 0 < keys.length
745
- ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
746
- : "{key: someKey}";
747
- didWarnAboutKeySpread[children + isStaticChildren] ||
748
- ((keys =
749
- 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
750
- console.error(
751
- 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
752
- isStaticChildren,
753
- children,
754
- keys,
755
- children
756
- ),
757
- (didWarnAboutKeySpread[children + isStaticChildren] = true));
758
- }
759
- children = null;
760
- void 0 !== maybeKey &&
761
- (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
762
- hasValidKey(config) &&
763
- (checkKeyStringCoercion(config.key), (children = "" + config.key));
764
- if ("key" in config) {
765
- maybeKey = {};
766
- for (var propName in config)
767
- "key" !== propName && (maybeKey[propName] = config[propName]);
768
- } else maybeKey = config;
769
- children &&
770
- defineKeyPropWarningGetter(
771
- maybeKey,
772
- "function" === typeof type
773
- ? type.displayName || type.name || "Unknown"
774
- : type
775
- );
776
- return ReactElement(
777
- type,
778
- children,
779
- self,
780
- source,
781
- getOwner(),
782
- maybeKey,
783
- debugStack,
784
- debugTask
785
- );
786
- }
787
- function validateChildKeys(node) {
788
- "object" === typeof node &&
789
- null !== node &&
790
- node.$$typeof === REACT_ELEMENT_TYPE &&
791
- node._store &&
792
- (node._store.validated = 1);
793
- }
794
- var React$1 = React,
795
- REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
796
- REACT_PORTAL_TYPE = Symbol.for("react.portal"),
797
- REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
798
- REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
799
- REACT_PROFILER_TYPE = Symbol.for("react.profiler");
800
- var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
801
- REACT_CONTEXT_TYPE = Symbol.for("react.context"),
802
- REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
803
- REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
804
- REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
805
- REACT_MEMO_TYPE = Symbol.for("react.memo"),
806
- REACT_LAZY_TYPE = Symbol.for("react.lazy"),
807
- REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
808
- REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
809
- ReactSharedInternals =
810
- React$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
811
- hasOwnProperty = Object.prototype.hasOwnProperty,
812
- isArrayImpl = Array.isArray,
813
- createTask = console.createTask
814
- ? console.createTask
815
- : function () {
816
- return null;
817
- };
818
- React$1 = {
819
- "react-stack-bottom-frame": function (callStackForError) {
820
- return callStackForError();
821
- }
822
- };
823
- var specialPropKeyWarningShown;
824
- var didWarnAboutElementRef = {};
825
- var unknownOwnerDebugStack = React$1["react-stack-bottom-frame"].bind(
826
- React$1,
827
- UnknownOwner
828
- )();
829
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
830
- var didWarnAboutKeySpread = {};
831
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
832
- reactJsxRuntime_development.jsx = function (type, config, maybeKey, source, self) {
833
- var trackActualOwner =
834
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
835
- return jsxDEVImpl(
836
- type,
837
- config,
838
- maybeKey,
839
- false,
840
- source,
841
- self,
842
- trackActualOwner
843
- ? Error("react-stack-top-frame")
844
- : unknownOwnerDebugStack,
845
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
846
- );
847
- };
848
- reactJsxRuntime_development.jsxs = function (type, config, maybeKey, source, self) {
849
- var trackActualOwner =
850
- 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
851
- return jsxDEVImpl(
852
- type,
853
- config,
854
- maybeKey,
855
- true,
856
- source,
857
- self,
858
- trackActualOwner
859
- ? Error("react-stack-top-frame")
860
- : unknownOwnerDebugStack,
861
- trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
862
- );
863
- };
864
- })();
865
- return reactJsxRuntime_development;
866
- }
867
-
868
- var hasRequiredJsxRuntime;
869
-
870
- function requireJsxRuntime () {
871
- if (hasRequiredJsxRuntime) return jsxRuntime.exports;
872
- hasRequiredJsxRuntime = 1;
873
-
874
- if (process.env.NODE_ENV === 'production') {
875
- jsxRuntime.exports = requireReactJsxRuntime_production();
876
- } else {
877
- jsxRuntime.exports = requireReactJsxRuntime_development();
878
- }
879
- return jsxRuntime.exports;
880
- }
881
-
882
- var jsxRuntimeExports = requireJsxRuntime();
883
-
884
454
  /**
885
455
  * TypeScript port of Recoil_unionSets.js
886
456
  */
@@ -1658,6 +1228,10 @@ function batchUpdates(callback) {
1658
1228
  });
1659
1229
  }
1660
1230
 
1231
+ function getDefaultExportFromCjs (x) {
1232
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1233
+ }
1234
+
1661
1235
  var hamt$1 = {exports: {}};
1662
1236
 
1663
1237
  var hasRequiredHamt;
@@ -3412,7 +2986,7 @@ children, skipCircularDependencyDetection_DANGEROUS, }) {
3412
2986
  }
3413
2987
  };
3414
2988
  }, [storeRef]);
3415
- return (jsxRuntimeExports.jsxs(AppContext.Provider, { value: storeRef, children: [jsxRuntimeExports.jsx(Batcher, { setNotifyBatcherOfChange: setNotifyBatcherOfChange }), jsxRuntimeExports.jsx(Suspense, { fallback: jsxRuntimeExports.jsx(RecoilSuspenseWarning, {}), children: children })] }));
2989
+ return (jsxs(AppContext.Provider, { value: storeRef, children: [jsx(Batcher, { setNotifyBatcherOfChange: setNotifyBatcherOfChange }), jsx(Suspense, { fallback: jsx(RecoilSuspenseWarning, {}), children: children })] }));
3416
2990
  }
3417
2991
  function RecoilRoot(props) {
3418
2992
  const { override, store } = props, propsExceptOverride = __rest(props, ["override", "store"]);
@@ -3424,7 +2998,7 @@ function RecoilRoot(props) {
3424
2998
  }
3425
2999
  // Map `store` prop to `store_INTERNAL` for backward compatibility
3426
3000
  const internalProps = Object.assign(Object.assign({}, propsExceptOverride), { store_INTERNAL: propsExceptOverride.store_INTERNAL || store });
3427
- return jsxRuntimeExports.jsx(RecoilRoot_INTERNAL, Object.assign({}, internalProps));
3001
+ return jsx(RecoilRoot_INTERNAL, Object.assign({}, internalProps));
3428
3002
  }
3429
3003
  function useRecoilStoreID() {
3430
3004
  return useStoreRef().current.storeID;
@@ -3918,7 +3492,7 @@ function useRecoilBridgeAcrossReactRoots() {
3918
3492
  return useMemo(() => {
3919
3493
  // eslint-disable-next-line no-shadow
3920
3494
  function RecoilBridge({ children }) {
3921
- return jsxRuntimeExports.jsx(RecoilRoot, { store: store, children: children });
3495
+ return jsx(RecoilRoot, { store: store, children: children });
3922
3496
  }
3923
3497
  return RecoilBridge;
3924
3498
  }, [store]);
package/package.json CHANGED
@@ -1,68 +1,67 @@
1
1
  {
2
- "name": "recoil-next",
3
- "version": "0.1.0",
4
- "description": "TypeScript rewrite of Recoil Next",
5
- "keywords": ["recoil", "react", "state-management", "typescript"],
6
- "author": "Mutesa Cedric",
7
- "license": "MIT",
8
- "repository": {
9
- "type": "git",
10
- "url": "https://github.com/Mutesa-Cedric/Recoil-next.git"
11
- },
12
- "main": "dist/index.cjs",
13
- "module": "dist/index.mjs",
14
- "types": "dist/index.d.ts",
15
- "exports": {
16
- ".": {
17
- "import": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.mjs"
20
- },
21
- "require": {
22
- "types": "./dist/index.d.cts",
23
- "default": "./dist/index.cjs"
24
- }
25
- }
26
- },
27
- "files": [
28
- "dist"
29
- ],
30
- "scripts": {
31
- "prebuild": "echo \"declare module 'hamt_plus';\" > hamt_plus.d.ts",
32
- "build": "rollup -c",
33
- "test": "vitest",
34
- "test:ui": "vitest --ui",
35
- "test:run": "vitest run",
36
- "lint": "eslint \"src/**/*.{ts,tsx}\"",
37
- "format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
38
- "typecheck": "tsc --noEmit"
39
- },
40
- "peerDependencies": {
41
- "react": ">=18"
42
- },
43
- "devDependencies": {
44
- "@rollup/plugin-node-resolve": "^16.0.1",
45
- "@rollup/plugin-typescript": "^12.1.4",
46
- "@testing-library/jest-dom": "^6.6.3",
47
- "@testing-library/react": "^16.3.0",
48
- "@types/node": "^18.15.3",
49
- "@types/react": "^18.2.39",
50
- "@types/react-dom": "^18.2.14",
51
- "@typescript-eslint/eslint-plugin": "^8.36.0",
52
- "@vitest/ui": "^2.1.8",
53
- "eslint-config-prettier": "^10.1.5",
54
- "eslint-plugin-prettier": "^5.5.1",
55
- "hamt_plus": "^1.0.2",
56
- "@types/hamt_plus": "^1.0.0",
57
- "jsdom": "^26.1.0",
58
- "react-test-renderer": "^19.1.0",
59
- "rollup": "^4.0.0",
60
- "rollup-plugin-dts": "^6.2.1",
61
- "tslib": "^2.6.0",
62
- "typescript": "^5.4.2",
63
- "vitest": "^2.1.8"
64
- },
65
- "dependencies": {
66
- "@rollup/plugin-commonjs": "^28.0.6"
2
+ "name": "recoil-next",
3
+ "version": "0.2.0",
4
+ "description": "Continuation of Recoil - A state management library for React",
5
+ "author": {
6
+ "name": "Mutesa Cedric",
7
+ "email": "mutesacedric@gmail.com",
8
+ "url": "https://github.com/Mutesa-Cedric"
9
+ },
10
+ "keywords": [
11
+ "recoil",
12
+ "state-management",
13
+ "react",
14
+ "state-management-library"
15
+ ],
16
+ "main": "dist/index.cjs",
17
+ "module": "dist/index.mjs",
18
+ "types": "dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.mjs",
23
+ "require": "./dist/index.cjs"
67
24
  }
25
+ },
26
+ "files": [
27
+ "dist/"
28
+ ],
29
+ "peerDependencies": {
30
+ "react": ">=18"
31
+ },
32
+ "dependencies": {
33
+ "hamt_plus": "^1.0.2"
34
+ },
35
+ "devDependencies": {
36
+ "@rollup/plugin-commonjs": "^28.0.6",
37
+ "@rollup/plugin-node-resolve": "^16.0.1",
38
+ "@rollup/plugin-typescript": "^12.1.4",
39
+ "@testing-library/jest-dom": "^6.6.3",
40
+ "@testing-library/react": "^16.3.0",
41
+ "@types/hamt_plus": "^1.0.0",
42
+ "@types/node": "^18.15.3",
43
+ "@types/react": "^18.2.39",
44
+ "@types/react-dom": "^18.2.14",
45
+ "@typescript-eslint/eslint-plugin": "^8.36.0",
46
+ "@vitest/ui": "^2.1.8",
47
+ "bumpp": "^10.2.2",
48
+ "eslint-config-prettier": "^10.1.5",
49
+ "eslint-plugin-prettier": "^5.5.1",
50
+ "jsdom": "^26.1.0",
51
+ "react-test-renderer": "^19.1.0",
52
+ "rollup": "^4.0.0",
53
+ "rollup-plugin-dts": "^6.2.1",
54
+ "tslib": "^2.6.0",
55
+ "typescript": "^5.4.2",
56
+ "vitest": "^2.1.8"
57
+ },
58
+ "repository": "https://github.com/Mutesa-Cedric/Recoil-next.git",
59
+ "license": "MIT",
60
+ "scripts": {
61
+ "build": "rollup -c",
62
+ "test": "vitest",
63
+ "test:run": "vitest run",
64
+ "typecheck": "tsc --noEmit",
65
+ "release": "bumpp && npm publish"
66
+ }
68
67
  }