@quantajs/react 2.0.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 QuantaJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.cjs ADDED
@@ -0,0 +1,52 @@
1
+ /*! MIT License
2
+
3
+ Copyright (c) 2025 QuantaJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ */
23
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("react"),W=require("@quantajs/core");function Z(c,l){return j.useSyncExternalStore(c.subscribe,()=>l?l(c):c,()=>l?l(c):c)}const ee=j.createContext(null);function je(){const c=j.useContext(ee);if(!c)throw new Error("useQuantaContext must be used within a QuantaProvider");return c}function pr(c){const{store:l}=je();return c?Z(l,c):Z(l)}function br(c,l,k,E){const R=j.useRef();return R.current||(R.current=W.createStore(c,{state:l,getters:k,actions:E})),R.current}var q={exports:{}},I={};/**
24
+ * @license React
25
+ * react-jsx-runtime.production.min.js
26
+ *
27
+ * Copyright (c) Facebook, Inc. and its affiliates.
28
+ *
29
+ * This source code is licensed under the MIT license found in the
30
+ * LICENSE file in the root directory of this source tree.
31
+ */var Ce;function gr(){if(Ce)return I;Ce=1;var c=j,l=Symbol.for("react.element"),k=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,R=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,Y={key:!0,ref:!0,__self:!0,__source:!0};function D(m,d,P){var g,h={},S=null,L=null;P!==void 0&&(S=""+P),d.key!==void 0&&(S=""+d.key),d.ref!==void 0&&(L=d.ref);for(g in d)E.call(d,g)&&!Y.hasOwnProperty(g)&&(h[g]=d[g]);if(m&&m.defaultProps)for(g in d=m.defaultProps,d)h[g]===void 0&&(h[g]=d[g]);return{$$typeof:l,type:m,key:S,ref:L,props:h,_owner:R.current}}return I.Fragment=k,I.jsx=D,I.jsxs=D,I}var $={};/**
32
+ * @license React
33
+ * react-jsx-runtime.development.js
34
+ *
35
+ * Copyright (c) Facebook, Inc. and its affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */var we;function yr(){return we||(we=1,process.env.NODE_ENV!=="production"&&function(){var c=j,l=Symbol.for("react.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),Y=Symbol.for("react.profiler"),D=Symbol.for("react.provider"),m=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),L=Symbol.for("react.offscreen"),re=Symbol.iterator,ke="@@iterator";function De(e){if(e===null||typeof e!="object")return null;var r=re&&e[re]||e[ke];return typeof r=="function"?r:null}var C=c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];Fe("error",e,t)}}function Fe(e,r,t){{var n=C.ReactDebugCurrentFrame,i=n.getStackAddendum();i!==""&&(r+="%s",t=t.concat([i]));var u=t.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var Ae=!1,Ie=!1,$e=!1,We=!1,Ye=!1,te;te=Symbol.for("react.module.reference");function Le(e){return!!(typeof e=="string"||typeof e=="function"||e===E||e===Y||Ye||e===R||e===P||e===g||We||e===L||Ae||Ie||$e||typeof e=="object"&&e!==null&&(e.$$typeof===S||e.$$typeof===h||e.$$typeof===D||e.$$typeof===m||e.$$typeof===d||e.$$typeof===te||e.getModuleId!==void 0))}function Me(e,r,t){var n=e.displayName;if(n)return n;var i=r.displayName||r.name||"";return i!==""?t+"("+i+")":t}function ne(e){return e.displayName||"Context"}function _(e){if(e==null)return null;if(typeof e.tag=="number"&&v("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case k:return"Portal";case Y:return"Profiler";case R:return"StrictMode";case P:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case m:var r=e;return ne(r)+".Consumer";case D:var t=e;return ne(t._context)+".Provider";case d:return Me(e,e.render,"ForwardRef");case h:var n=e.displayName||null;return n!==null?n:_(e.type)||"Memo";case S:{var i=e,u=i._payload,o=i._init;try{return _(o(u))}catch{return null}}}return null}var T=Object.assign,F=0,ae,oe,ie,ue,se,fe,ce;function le(){}le.__reactDisabledLog=!0;function Ve(){{if(F===0){ae=console.log,oe=console.info,ie=console.warn,ue=console.error,se=console.group,fe=console.groupCollapsed,ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:le,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}F++}}function Ue(){{if(F--,F===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:T({},e,{value:ae}),info:T({},e,{value:oe}),warn:T({},e,{value:ie}),error:T({},e,{value:ue}),group:T({},e,{value:se}),groupCollapsed:T({},e,{value:fe}),groupEnd:T({},e,{value:ce})})}F<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var J=C.ReactCurrentDispatcher,Q;function M(e,r,t){{if(Q===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Q=n&&n[1]||""}return`
40
+ `+Q+e}}var B=!1,V;{var Ne=typeof WeakMap=="function"?WeakMap:Map;V=new Ne}function de(e,r){if(!e||B)return"";{var t=V.get(e);if(t!==void 0)return t}var n;B=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=J.current,J.current=null,Ve();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(b){n=b}Reflect.construct(e,[],o)}else{try{o.call()}catch(b){n=b}e.call(o.prototype)}}else{try{throw Error()}catch(b){n=b}e()}}catch(b){if(b&&n&&typeof b.stack=="string"){for(var a=b.stack.split(`
41
+ `),p=n.stack.split(`
42
+ `),s=a.length-1,f=p.length-1;s>=1&&f>=0&&a[s]!==p[f];)f--;for(;s>=1&&f>=0;s--,f--)if(a[s]!==p[f]){if(s!==1||f!==1)do if(s--,f--,f<0||a[s]!==p[f]){var y=`
43
+ `+a[s].replace(" at new "," at ");return e.displayName&&y.includes("<anonymous>")&&(y=y.replace("<anonymous>",e.displayName)),typeof e=="function"&&V.set(e,y),y}while(s>=1&&f>=0);break}}}finally{B=!1,J.current=u,Ue(),Error.prepareStackTrace=i}var x=e?e.displayName||e.name:"",O=x?M(x):"";return typeof e=="function"&&V.set(e,O),O}function qe(e,r,t){return de(e,!1)}function Je(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function U(e,r,t){if(e==null)return"";if(typeof e=="function")return de(e,Je(e));if(typeof e=="string")return M(e);switch(e){case P:return M("Suspense");case g:return M("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return qe(e.render);case h:return U(e.type,r,t);case S:{var n=e,i=n._payload,u=n._init;try{return U(u(i),r,t)}catch{}}}return""}var A=Object.prototype.hasOwnProperty,ve={},pe=C.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,t=U(e.type,e._source,r?r.type:null);pe.setExtraStackFrame(t)}else pe.setExtraStackFrame(null)}function Qe(e,r,t,n,i){{var u=Function.call.bind(A);for(var o in e)if(u(e,o)){var a=void 0;try{if(typeof e[o]!="function"){var p=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}a=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(s){a=s}a&&!(a instanceof Error)&&(N(i),v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof a),N(null)),a instanceof Error&&!(a.message in ve)&&(ve[a.message]=!0,N(i),v("Failed %s type: %s",t,a.message),N(null))}}}var Be=Array.isArray;function K(e){return Be(e)}function Ke(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Ge(e){try{return be(e),!1}catch{return!0}}function be(e){return""+e}function ge(e){if(Ge(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ke(e)),be(e)}var ye=C.ReactCurrentOwner,ze={key:!0,ref:!0,__self:!0,__source:!0},he,Ee;function Xe(e){if(A.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function He(e){if(A.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ze(e,r){typeof e.ref=="string"&&ye.current}function er(e,r){{var t=function(){he||(he=!0,v("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function rr(e,r){{var t=function(){Ee||(Ee=!0,v("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var tr=function(e,r,t,n,i,u,o){var a={$$typeof:l,type:e,key:r,ref:t,props:o,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function nr(e,r,t,n,i){{var u,o={},a=null,p=null;t!==void 0&&(ge(t),a=""+t),He(r)&&(ge(r.key),a=""+r.key),Xe(r)&&(p=r.ref,Ze(r,i));for(u in r)A.call(r,u)&&!ze.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var s=e.defaultProps;for(u in s)o[u]===void 0&&(o[u]=s[u])}if(a||p){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&er(o,f),p&&rr(o,f)}return tr(e,a,p,i,n,ye.current,o)}}var G=C.ReactCurrentOwner,Re=C.ReactDebugCurrentFrame;function w(e){if(e){var r=e._owner,t=U(e.type,e._source,r?r.type:null);Re.setExtraStackFrame(t)}else Re.setExtraStackFrame(null)}var z;z=!1;function X(e){return typeof e=="object"&&e!==null&&e.$$typeof===l}function _e(){{if(G.current){var e=_(G.current.type);if(e)return`
44
+
45
+ Check the render method of \``+e+"`."}return""}}function ar(e){return""}var me={};function or(e){{var r=_e();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
46
+
47
+ Check the top-level render call using <`+t+">.")}return r}}function Se(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=or(r);if(me[t])return;me[t]=!0;var n="";e&&e._owner&&e._owner!==G.current&&(n=" It was passed a child from "+_(e._owner.type)+"."),w(e),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),w(null)}}function Te(e,r){{if(typeof e!="object")return;if(K(e))for(var t=0;t<e.length;t++){var n=e[t];X(n)&&Se(n,r)}else if(X(e))e._store&&(e._store.validated=!0);else if(e){var i=De(e);if(typeof i=="function"&&i!==e.entries)for(var u=i.call(e),o;!(o=u.next()).done;)X(o.value)&&Se(o.value,r)}}}function ir(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===h))t=r.propTypes;else return;if(t){var n=_(r);Qe(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!z){z=!0;var i=_(r);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",i||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ur(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){w(e),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),w(null);break}}e.ref!==null&&(w(e),v("Invalid attribute `ref` supplied to `React.Fragment`."),w(null))}}var Oe={};function Pe(e,r,t,n,i,u){{var o=Le(e);if(!o){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var p=ar();p?a+=p:a+=_e();var s;e===null?s="null":K(e)?s="array":e!==void 0&&e.$$typeof===l?(s="<"+(_(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,a)}var f=nr(e,r,t,i,u);if(f==null)return f;if(o){var y=r.children;if(y!==void 0)if(n)if(K(y)){for(var x=0;x<y.length;x++)Te(y[x],e);Object.freeze&&Object.freeze(y)}else v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Te(y,e)}if(A.call(r,"key")){var O=_(e),b=Object.keys(r).filter(function(vr){return vr!=="key"}),H=b.length>0?"{key: someKey, "+b.join(": ..., ")+": ...}":"{key: someKey}";if(!Oe[O+H]){var dr=b.length>0?"{"+b.join(": ..., ")+": ...}":"{}";v(`A props object containing a "key" prop is being spread into JSX:
48
+ let props = %s;
49
+ <%s {...props} />
50
+ React keys must be passed directly to JSX without using spread:
51
+ let props = %s;
52
+ <%s key={someKey} {...props} />`,H,O,dr,O),Oe[O+H]=!0}}return e===E?ur(f):ir(f),f}}function sr(e,r,t){return Pe(e,r,t,!0)}function fr(e,r,t){return Pe(e,r,t,!1)}var cr=fr,lr=sr;$.Fragment=E,$.jsx=cr,$.jsxs=lr}()),$}var xe;function hr(){return xe||(xe=1,process.env.NODE_ENV==="production"?q.exports=gr():q.exports=yr()),q.exports}var Er=hr();function Rr({store:c,children:l}){return Er.jsx(ee.Provider,{value:{store:c},children:l})}Object.defineProperty(exports,"computed",{enumerable:!0,get:()=>W.computed});Object.defineProperty(exports,"createStore",{enumerable:!0,get:()=>W.createStore});Object.defineProperty(exports,"reactive",{enumerable:!0,get:()=>W.reactive});Object.defineProperty(exports,"watch",{enumerable:!0,get:()=>W.watch});exports.QuantaContext=ee;exports.QuantaProvider=Rr;exports.useCreateStore=br;exports.useQuantaContext=je;exports.useQuantaStore=Z;exports.useStore=pr;
@@ -0,0 +1,81 @@
1
+ import { ActionDefinition } from '@quantajs/core';
2
+ import { computed } from '@quantajs/core';
3
+ import { Context } from 'react';
4
+ import { createStore } from '@quantajs/core';
5
+ import { GetterDefinition } from '@quantajs/core';
6
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
7
+ import { reactive } from '@quantajs/core';
8
+ import { ReactNode } from 'react';
9
+ import { StateDefinition } from '@quantajs/core';
10
+ import { Store } from '@quantajs/core';
11
+ import { StoreInstance } from '@quantajs/core';
12
+ import { StoreSubscriber } from '@quantajs/core';
13
+ import { watch } from '@quantajs/core';
14
+
15
+ export { ActionDefinition }
16
+
17
+ export { computed }
18
+
19
+ export { createStore }
20
+
21
+ export { GetterDefinition }
22
+
23
+ export declare const QuantaContext: Context<QuantaContextValue | null>;
24
+
25
+ declare interface QuantaContextValue {
26
+ store: StoreInstance<any, any, any>;
27
+ }
28
+
29
+ /**
30
+ * Provider component that makes a QuantaJS store available to all child components
31
+ * @param store - The QuantaJS store instance to provide
32
+ * @param children - Child components that can access the store
33
+ */
34
+ export declare function QuantaProvider({ store, children }: QuantaProviderProps): JSX_2.Element;
35
+
36
+ declare interface QuantaProviderProps {
37
+ store: StoreInstance<any, any, any>;
38
+ children: ReactNode;
39
+ }
40
+
41
+ export { reactive }
42
+
43
+ export { StateDefinition }
44
+
45
+ export { Store }
46
+
47
+ export { StoreInstance }
48
+
49
+ export { StoreSubscriber }
50
+
51
+ /**
52
+ * Hook to create a QuantaJS store instance within a React component
53
+ * Creates store only once and reuses it across re-renders
54
+ */
55
+ export declare function useCreateStore<S extends object, G extends object = {}, A extends Record<string, (...args: any[]) => any> = {}>(name: string, state: StateDefinition<S>, getters?: GetterDefinition<S, G>, actions?: ActionDefinition<S, G, A>): StoreInstance<S, G, A>;
56
+
57
+ /**
58
+ * Hook to access the QuantaJS store from the context
59
+ * @returns The store instance from the nearest QuantaProvider
60
+ * @throws Error if used outside of QuantaProvider
61
+ */
62
+ export declare function useQuantaContext(): QuantaContextValue;
63
+
64
+ /**
65
+ * Hook to subscribe to a QuantaJS store and get reactive updates
66
+ * Simple implementation that relies on QuantaJS core's reactivity system
67
+ */
68
+ export declare function useQuantaStore<S extends object, G extends object, A extends object>(store: StoreInstance<S, G, A>): StoreInstance<S, G, A>;
69
+
70
+ export declare function useQuantaStore<S extends object, G extends object, A extends object, T = any>(store: StoreInstance<S, G, A>, selector: (store: StoreInstance<S, G, A>) => T): T;
71
+
72
+ /**
73
+ * Hook to access and subscribe to the QuantaJS store from context
74
+ * @param selector - Optional selector function to pick specific parts of the store
75
+ * @returns The store instance or selected value that updates reactively
76
+ */
77
+ export declare function useStore<T = any>(selector?: (store: StoreInstance<any, any, any>) => T): T extends undefined ? StoreInstance<any, any, any> : T;
78
+
79
+ export { watch }
80
+
81
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,693 @@
1
+ /*! MIT License
2
+
3
+ Copyright (c) 2025 QuantaJS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+ */
23
+ import Pe, { useSyncExternalStore as vr, createContext as dr, useContext as pr, useRef as gr } from "react";
24
+ import { createStore as Er } from "@quantajs/core";
25
+ import { computed as xr, createStore as jr, reactive as kr, watch as Dr } from "@quantajs/core";
26
+ function Te(l, c) {
27
+ return vr(
28
+ l.subscribe,
29
+ () => c ? c(l) : l,
30
+ () => c ? c(l) : l
31
+ );
32
+ }
33
+ const we = dr(null);
34
+ function br() {
35
+ const l = pr(we);
36
+ if (!l)
37
+ throw new Error(
38
+ "useQuantaContext must be used within a QuantaProvider"
39
+ );
40
+ return l;
41
+ }
42
+ function Sr(l) {
43
+ const { store: c } = br();
44
+ return l ? Te(c, l) : Te(c);
45
+ }
46
+ function Cr(l, c, j, R) {
47
+ const y = gr();
48
+ return y.current || (y.current = Er(l, { state: c, getters: j, actions: R })), y.current;
49
+ }
50
+ var U = { exports: {} }, A = {};
51
+ /**
52
+ * @license React
53
+ * react-jsx-runtime.production.min.js
54
+ *
55
+ * Copyright (c) Facebook, Inc. and its affiliates.
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE file in the root directory of this source tree.
59
+ */
60
+ var Se;
61
+ function hr() {
62
+ if (Se) return A;
63
+ Se = 1;
64
+ var l = Pe, c = Symbol.for("react.element"), j = Symbol.for("react.fragment"), R = Object.prototype.hasOwnProperty, y = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, $ = { key: !0, ref: !0, __self: !0, __source: !0 };
65
+ function k(m, v, O) {
66
+ var E, h = {}, T = null, W = null;
67
+ O !== void 0 && (T = "" + O), v.key !== void 0 && (T = "" + v.key), v.ref !== void 0 && (W = v.ref);
68
+ for (E in v) R.call(v, E) && !$.hasOwnProperty(E) && (h[E] = v[E]);
69
+ if (m && m.defaultProps) for (E in v = m.defaultProps, v) h[E] === void 0 && (h[E] = v[E]);
70
+ return { $$typeof: c, type: m, key: T, ref: W, props: h, _owner: y.current };
71
+ }
72
+ return A.Fragment = j, A.jsx = k, A.jsxs = k, A;
73
+ }
74
+ var I = {};
75
+ /**
76
+ * @license React
77
+ * react-jsx-runtime.development.js
78
+ *
79
+ * Copyright (c) Facebook, Inc. and its affiliates.
80
+ *
81
+ * This source code is licensed under the MIT license found in the
82
+ * LICENSE file in the root directory of this source tree.
83
+ */
84
+ var Ce;
85
+ function Rr() {
86
+ return Ce || (Ce = 1, process.env.NODE_ENV !== "production" && function() {
87
+ var l = Pe, c = Symbol.for("react.element"), j = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), y = Symbol.for("react.strict_mode"), $ = Symbol.for("react.profiler"), k = Symbol.for("react.provider"), m = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), E = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), T = Symbol.for("react.lazy"), W = Symbol.for("react.offscreen"), X = Symbol.iterator, xe = "@@iterator";
88
+ function je(e) {
89
+ if (e === null || typeof e != "object")
90
+ return null;
91
+ var r = X && e[X] || e[xe];
92
+ return typeof r == "function" ? r : null;
93
+ }
94
+ var P = l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
95
+ function d(e) {
96
+ {
97
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
98
+ t[n - 1] = arguments[n];
99
+ ke("error", e, t);
100
+ }
101
+ }
102
+ function ke(e, r, t) {
103
+ {
104
+ var n = P.ReactDebugCurrentFrame, i = n.getStackAddendum();
105
+ i !== "" && (r += "%s", t = t.concat([i]));
106
+ var u = t.map(function(o) {
107
+ return String(o);
108
+ });
109
+ u.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, u);
110
+ }
111
+ }
112
+ var De = !1, Fe = !1, Ae = !1, Ie = !1, $e = !1, H;
113
+ H = Symbol.for("react.module.reference");
114
+ function We(e) {
115
+ return !!(typeof e == "string" || typeof e == "function" || e === R || e === $ || $e || e === y || e === O || e === E || Ie || e === W || De || Fe || Ae || typeof e == "object" && e !== null && (e.$$typeof === T || e.$$typeof === h || e.$$typeof === k || e.$$typeof === m || e.$$typeof === v || // This needs to include all possible module reference object
116
+ // types supported by any Flight configuration anywhere since
117
+ // we don't know which Flight build this will end up being used
118
+ // with.
119
+ e.$$typeof === H || e.getModuleId !== void 0));
120
+ }
121
+ function Ye(e, r, t) {
122
+ var n = e.displayName;
123
+ if (n)
124
+ return n;
125
+ var i = r.displayName || r.name || "";
126
+ return i !== "" ? t + "(" + i + ")" : t;
127
+ }
128
+ function Z(e) {
129
+ return e.displayName || "Context";
130
+ }
131
+ function _(e) {
132
+ if (e == null)
133
+ return null;
134
+ if (typeof e.tag == "number" && d("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
135
+ return e.displayName || e.name || null;
136
+ if (typeof e == "string")
137
+ return e;
138
+ switch (e) {
139
+ case R:
140
+ return "Fragment";
141
+ case j:
142
+ return "Portal";
143
+ case $:
144
+ return "Profiler";
145
+ case y:
146
+ return "StrictMode";
147
+ case O:
148
+ return "Suspense";
149
+ case E:
150
+ return "SuspenseList";
151
+ }
152
+ if (typeof e == "object")
153
+ switch (e.$$typeof) {
154
+ case m:
155
+ var r = e;
156
+ return Z(r) + ".Consumer";
157
+ case k:
158
+ var t = e;
159
+ return Z(t._context) + ".Provider";
160
+ case v:
161
+ return Ye(e, e.render, "ForwardRef");
162
+ case h:
163
+ var n = e.displayName || null;
164
+ return n !== null ? n : _(e.type) || "Memo";
165
+ case T: {
166
+ var i = e, u = i._payload, o = i._init;
167
+ try {
168
+ return _(o(u));
169
+ } catch {
170
+ return null;
171
+ }
172
+ }
173
+ }
174
+ return null;
175
+ }
176
+ var S = Object.assign, D = 0, ee, re, te, ne, ae, oe, ie;
177
+ function ue() {
178
+ }
179
+ ue.__reactDisabledLog = !0;
180
+ function Le() {
181
+ {
182
+ if (D === 0) {
183
+ ee = console.log, re = console.info, te = console.warn, ne = console.error, ae = console.group, oe = console.groupCollapsed, ie = console.groupEnd;
184
+ var e = {
185
+ configurable: !0,
186
+ enumerable: !0,
187
+ value: ue,
188
+ writable: !0
189
+ };
190
+ Object.defineProperties(console, {
191
+ info: e,
192
+ log: e,
193
+ warn: e,
194
+ error: e,
195
+ group: e,
196
+ groupCollapsed: e,
197
+ groupEnd: e
198
+ });
199
+ }
200
+ D++;
201
+ }
202
+ }
203
+ function Ve() {
204
+ {
205
+ if (D--, D === 0) {
206
+ var e = {
207
+ configurable: !0,
208
+ enumerable: !0,
209
+ writable: !0
210
+ };
211
+ Object.defineProperties(console, {
212
+ log: S({}, e, {
213
+ value: ee
214
+ }),
215
+ info: S({}, e, {
216
+ value: re
217
+ }),
218
+ warn: S({}, e, {
219
+ value: te
220
+ }),
221
+ error: S({}, e, {
222
+ value: ne
223
+ }),
224
+ group: S({}, e, {
225
+ value: ae
226
+ }),
227
+ groupCollapsed: S({}, e, {
228
+ value: oe
229
+ }),
230
+ groupEnd: S({}, e, {
231
+ value: ie
232
+ })
233
+ });
234
+ }
235
+ D < 0 && d("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
236
+ }
237
+ }
238
+ var N = P.ReactCurrentDispatcher, J;
239
+ function Y(e, r, t) {
240
+ {
241
+ if (J === void 0)
242
+ try {
243
+ throw Error();
244
+ } catch (i) {
245
+ var n = i.stack.trim().match(/\n( *(at )?)/);
246
+ J = n && n[1] || "";
247
+ }
248
+ return `
249
+ ` + J + e;
250
+ }
251
+ }
252
+ var q = !1, L;
253
+ {
254
+ var Me = typeof WeakMap == "function" ? WeakMap : Map;
255
+ L = new Me();
256
+ }
257
+ function se(e, r) {
258
+ if (!e || q)
259
+ return "";
260
+ {
261
+ var t = L.get(e);
262
+ if (t !== void 0)
263
+ return t;
264
+ }
265
+ var n;
266
+ q = !0;
267
+ var i = Error.prepareStackTrace;
268
+ Error.prepareStackTrace = void 0;
269
+ var u;
270
+ u = N.current, N.current = null, Le();
271
+ try {
272
+ if (r) {
273
+ var o = function() {
274
+ throw Error();
275
+ };
276
+ if (Object.defineProperty(o.prototype, "props", {
277
+ set: function() {
278
+ throw Error();
279
+ }
280
+ }), typeof Reflect == "object" && Reflect.construct) {
281
+ try {
282
+ Reflect.construct(o, []);
283
+ } catch (g) {
284
+ n = g;
285
+ }
286
+ Reflect.construct(e, [], o);
287
+ } else {
288
+ try {
289
+ o.call();
290
+ } catch (g) {
291
+ n = g;
292
+ }
293
+ e.call(o.prototype);
294
+ }
295
+ } else {
296
+ try {
297
+ throw Error();
298
+ } catch (g) {
299
+ n = g;
300
+ }
301
+ e();
302
+ }
303
+ } catch (g) {
304
+ if (g && n && typeof g.stack == "string") {
305
+ for (var a = g.stack.split(`
306
+ `), p = n.stack.split(`
307
+ `), s = a.length - 1, f = p.length - 1; s >= 1 && f >= 0 && a[s] !== p[f]; )
308
+ f--;
309
+ for (; s >= 1 && f >= 0; s--, f--)
310
+ if (a[s] !== p[f]) {
311
+ if (s !== 1 || f !== 1)
312
+ do
313
+ if (s--, f--, f < 0 || a[s] !== p[f]) {
314
+ var b = `
315
+ ` + a[s].replace(" at new ", " at ");
316
+ return e.displayName && b.includes("<anonymous>") && (b = b.replace("<anonymous>", e.displayName)), typeof e == "function" && L.set(e, b), b;
317
+ }
318
+ while (s >= 1 && f >= 0);
319
+ break;
320
+ }
321
+ }
322
+ } finally {
323
+ q = !1, N.current = u, Ve(), Error.prepareStackTrace = i;
324
+ }
325
+ var x = e ? e.displayName || e.name : "", C = x ? Y(x) : "";
326
+ return typeof e == "function" && L.set(e, C), C;
327
+ }
328
+ function Ue(e, r, t) {
329
+ return se(e, !1);
330
+ }
331
+ function Ne(e) {
332
+ var r = e.prototype;
333
+ return !!(r && r.isReactComponent);
334
+ }
335
+ function V(e, r, t) {
336
+ if (e == null)
337
+ return "";
338
+ if (typeof e == "function")
339
+ return se(e, Ne(e));
340
+ if (typeof e == "string")
341
+ return Y(e);
342
+ switch (e) {
343
+ case O:
344
+ return Y("Suspense");
345
+ case E:
346
+ return Y("SuspenseList");
347
+ }
348
+ if (typeof e == "object")
349
+ switch (e.$$typeof) {
350
+ case v:
351
+ return Ue(e.render);
352
+ case h:
353
+ return V(e.type, r, t);
354
+ case T: {
355
+ var n = e, i = n._payload, u = n._init;
356
+ try {
357
+ return V(u(i), r, t);
358
+ } catch {
359
+ }
360
+ }
361
+ }
362
+ return "";
363
+ }
364
+ var F = Object.prototype.hasOwnProperty, fe = {}, le = P.ReactDebugCurrentFrame;
365
+ function M(e) {
366
+ if (e) {
367
+ var r = e._owner, t = V(e.type, e._source, r ? r.type : null);
368
+ le.setExtraStackFrame(t);
369
+ } else
370
+ le.setExtraStackFrame(null);
371
+ }
372
+ function Je(e, r, t, n, i) {
373
+ {
374
+ var u = Function.call.bind(F);
375
+ for (var o in e)
376
+ if (u(e, o)) {
377
+ var a = void 0;
378
+ try {
379
+ if (typeof e[o] != "function") {
380
+ var p = Error((n || "React class") + ": " + t + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
381
+ throw p.name = "Invariant Violation", p;
382
+ }
383
+ a = e[o](r, o, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
384
+ } catch (s) {
385
+ a = s;
386
+ }
387
+ a && !(a instanceof Error) && (M(i), d("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, o, typeof a), M(null)), a instanceof Error && !(a.message in fe) && (fe[a.message] = !0, M(i), d("Failed %s type: %s", t, a.message), M(null));
388
+ }
389
+ }
390
+ }
391
+ var qe = Array.isArray;
392
+ function B(e) {
393
+ return qe(e);
394
+ }
395
+ function Be(e) {
396
+ {
397
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
398
+ return t;
399
+ }
400
+ }
401
+ function Ke(e) {
402
+ try {
403
+ return ce(e), !1;
404
+ } catch {
405
+ return !0;
406
+ }
407
+ }
408
+ function ce(e) {
409
+ return "" + e;
410
+ }
411
+ function ve(e) {
412
+ if (Ke(e))
413
+ return d("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Be(e)), ce(e);
414
+ }
415
+ var de = P.ReactCurrentOwner, Ge = {
416
+ key: !0,
417
+ ref: !0,
418
+ __self: !0,
419
+ __source: !0
420
+ }, pe, ge;
421
+ function Qe(e) {
422
+ if (F.call(e, "ref")) {
423
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
424
+ if (r && r.isReactWarning)
425
+ return !1;
426
+ }
427
+ return e.ref !== void 0;
428
+ }
429
+ function ze(e) {
430
+ if (F.call(e, "key")) {
431
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
432
+ if (r && r.isReactWarning)
433
+ return !1;
434
+ }
435
+ return e.key !== void 0;
436
+ }
437
+ function Xe(e, r) {
438
+ typeof e.ref == "string" && de.current;
439
+ }
440
+ function He(e, r) {
441
+ {
442
+ var t = function() {
443
+ pe || (pe = !0, d("%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://reactjs.org/link/special-props)", r));
444
+ };
445
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
446
+ get: t,
447
+ configurable: !0
448
+ });
449
+ }
450
+ }
451
+ function Ze(e, r) {
452
+ {
453
+ var t = function() {
454
+ ge || (ge = !0, d("%s: `ref` 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://reactjs.org/link/special-props)", r));
455
+ };
456
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
457
+ get: t,
458
+ configurable: !0
459
+ });
460
+ }
461
+ }
462
+ var er = function(e, r, t, n, i, u, o) {
463
+ var a = {
464
+ // This tag allows us to uniquely identify this as a React Element
465
+ $$typeof: c,
466
+ // Built-in properties that belong on the element
467
+ type: e,
468
+ key: r,
469
+ ref: t,
470
+ props: o,
471
+ // Record the component responsible for creating this element.
472
+ _owner: u
473
+ };
474
+ return a._store = {}, Object.defineProperty(a._store, "validated", {
475
+ configurable: !1,
476
+ enumerable: !1,
477
+ writable: !0,
478
+ value: !1
479
+ }), Object.defineProperty(a, "_self", {
480
+ configurable: !1,
481
+ enumerable: !1,
482
+ writable: !1,
483
+ value: n
484
+ }), Object.defineProperty(a, "_source", {
485
+ configurable: !1,
486
+ enumerable: !1,
487
+ writable: !1,
488
+ value: i
489
+ }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
490
+ };
491
+ function rr(e, r, t, n, i) {
492
+ {
493
+ var u, o = {}, a = null, p = null;
494
+ t !== void 0 && (ve(t), a = "" + t), ze(r) && (ve(r.key), a = "" + r.key), Qe(r) && (p = r.ref, Xe(r, i));
495
+ for (u in r)
496
+ F.call(r, u) && !Ge.hasOwnProperty(u) && (o[u] = r[u]);
497
+ if (e && e.defaultProps) {
498
+ var s = e.defaultProps;
499
+ for (u in s)
500
+ o[u] === void 0 && (o[u] = s[u]);
501
+ }
502
+ if (a || p) {
503
+ var f = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
504
+ a && He(o, f), p && Ze(o, f);
505
+ }
506
+ return er(e, a, p, i, n, de.current, o);
507
+ }
508
+ }
509
+ var K = P.ReactCurrentOwner, Ee = P.ReactDebugCurrentFrame;
510
+ function w(e) {
511
+ if (e) {
512
+ var r = e._owner, t = V(e.type, e._source, r ? r.type : null);
513
+ Ee.setExtraStackFrame(t);
514
+ } else
515
+ Ee.setExtraStackFrame(null);
516
+ }
517
+ var G;
518
+ G = !1;
519
+ function Q(e) {
520
+ return typeof e == "object" && e !== null && e.$$typeof === c;
521
+ }
522
+ function be() {
523
+ {
524
+ if (K.current) {
525
+ var e = _(K.current.type);
526
+ if (e)
527
+ return `
528
+
529
+ Check the render method of \`` + e + "`.";
530
+ }
531
+ return "";
532
+ }
533
+ }
534
+ function tr(e) {
535
+ return "";
536
+ }
537
+ var he = {};
538
+ function nr(e) {
539
+ {
540
+ var r = be();
541
+ if (!r) {
542
+ var t = typeof e == "string" ? e : e.displayName || e.name;
543
+ t && (r = `
544
+
545
+ Check the top-level render call using <` + t + ">.");
546
+ }
547
+ return r;
548
+ }
549
+ }
550
+ function Re(e, r) {
551
+ {
552
+ if (!e._store || e._store.validated || e.key != null)
553
+ return;
554
+ e._store.validated = !0;
555
+ var t = nr(r);
556
+ if (he[t])
557
+ return;
558
+ he[t] = !0;
559
+ var n = "";
560
+ e && e._owner && e._owner !== K.current && (n = " It was passed a child from " + _(e._owner.type) + "."), w(e), d('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), w(null);
561
+ }
562
+ }
563
+ function ye(e, r) {
564
+ {
565
+ if (typeof e != "object")
566
+ return;
567
+ if (B(e))
568
+ for (var t = 0; t < e.length; t++) {
569
+ var n = e[t];
570
+ Q(n) && Re(n, r);
571
+ }
572
+ else if (Q(e))
573
+ e._store && (e._store.validated = !0);
574
+ else if (e) {
575
+ var i = je(e);
576
+ if (typeof i == "function" && i !== e.entries)
577
+ for (var u = i.call(e), o; !(o = u.next()).done; )
578
+ Q(o.value) && Re(o.value, r);
579
+ }
580
+ }
581
+ }
582
+ function ar(e) {
583
+ {
584
+ var r = e.type;
585
+ if (r == null || typeof r == "string")
586
+ return;
587
+ var t;
588
+ if (typeof r == "function")
589
+ t = r.propTypes;
590
+ else if (typeof r == "object" && (r.$$typeof === v || // Note: Memo only checks outer props here.
591
+ // Inner props are checked in the reconciler.
592
+ r.$$typeof === h))
593
+ t = r.propTypes;
594
+ else
595
+ return;
596
+ if (t) {
597
+ var n = _(r);
598
+ Je(t, e.props, "prop", n, e);
599
+ } else if (r.PropTypes !== void 0 && !G) {
600
+ G = !0;
601
+ var i = _(r);
602
+ d("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i || "Unknown");
603
+ }
604
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && d("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
605
+ }
606
+ }
607
+ function or(e) {
608
+ {
609
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
610
+ var n = r[t];
611
+ if (n !== "children" && n !== "key") {
612
+ w(e), d("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), w(null);
613
+ break;
614
+ }
615
+ }
616
+ e.ref !== null && (w(e), d("Invalid attribute `ref` supplied to `React.Fragment`."), w(null));
617
+ }
618
+ }
619
+ var _e = {};
620
+ function me(e, r, t, n, i, u) {
621
+ {
622
+ var o = We(e);
623
+ if (!o) {
624
+ var a = "";
625
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (a += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
626
+ var p = tr();
627
+ p ? a += p : a += be();
628
+ var s;
629
+ e === null ? s = "null" : B(e) ? s = "array" : e !== void 0 && e.$$typeof === c ? (s = "<" + (_(e.type) || "Unknown") + " />", a = " Did you accidentally export a JSX literal instead of a component?") : s = typeof e, d("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", s, a);
630
+ }
631
+ var f = rr(e, r, t, i, u);
632
+ if (f == null)
633
+ return f;
634
+ if (o) {
635
+ var b = r.children;
636
+ if (b !== void 0)
637
+ if (n)
638
+ if (B(b)) {
639
+ for (var x = 0; x < b.length; x++)
640
+ ye(b[x], e);
641
+ Object.freeze && Object.freeze(b);
642
+ } else
643
+ d("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
644
+ else
645
+ ye(b, e);
646
+ }
647
+ if (F.call(r, "key")) {
648
+ var C = _(e), g = Object.keys(r).filter(function(cr) {
649
+ return cr !== "key";
650
+ }), z = g.length > 0 ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}";
651
+ if (!_e[C + z]) {
652
+ var lr = g.length > 0 ? "{" + g.join(": ..., ") + ": ...}" : "{}";
653
+ d(`A props object containing a "key" prop is being spread into JSX:
654
+ let props = %s;
655
+ <%s {...props} />
656
+ React keys must be passed directly to JSX without using spread:
657
+ let props = %s;
658
+ <%s key={someKey} {...props} />`, z, C, lr, C), _e[C + z] = !0;
659
+ }
660
+ }
661
+ return e === R ? or(f) : ar(f), f;
662
+ }
663
+ }
664
+ function ir(e, r, t) {
665
+ return me(e, r, t, !0);
666
+ }
667
+ function ur(e, r, t) {
668
+ return me(e, r, t, !1);
669
+ }
670
+ var sr = ur, fr = ir;
671
+ I.Fragment = R, I.jsx = sr, I.jsxs = fr;
672
+ }()), I;
673
+ }
674
+ var Oe;
675
+ function yr() {
676
+ return Oe || (Oe = 1, process.env.NODE_ENV === "production" ? U.exports = hr() : U.exports = Rr()), U.exports;
677
+ }
678
+ var _r = yr();
679
+ function Or({ store: l, children: c }) {
680
+ return /* @__PURE__ */ _r.jsx(we.Provider, { value: { store: l }, children: c });
681
+ }
682
+ export {
683
+ we as QuantaContext,
684
+ Or as QuantaProvider,
685
+ xr as computed,
686
+ jr as createStore,
687
+ kr as reactive,
688
+ Cr as useCreateStore,
689
+ br as useQuantaContext,
690
+ Te as useQuantaStore,
691
+ Sr as useStore,
692
+ Dr as watch
693
+ };
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@quantajs/react",
3
+ "private": false,
4
+ "author": {
5
+ "name": "Jeel Gajera",
6
+ "url": "https://github.com/JeelGajera"
7
+ },
8
+ "description": "React integration for QuantaJS - A compact, scalable, and developer-friendly state management library for React applications.",
9
+ "keywords": [
10
+ "quantajs",
11
+ "quanta",
12
+ "state-management",
13
+ "reactivity",
14
+ "react",
15
+ "hooks"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/quanta-js/quanta.git"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/quanta-js/quanta/issues"
23
+ },
24
+ "homepage": "https://quantajs.com",
25
+ "version": "2.0.0-beta.1",
26
+ "type": "module",
27
+ "license": "MIT",
28
+ "main": "./dist/index.js",
29
+ "module": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "import": "./dist/index.js",
35
+ "require": "./dist/index.cjs"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist"
40
+ ],
41
+ "sideEffects": false,
42
+ "peerDependencies": {
43
+ "react": ">=16.8.0"
44
+ },
45
+ "dependencies": {
46
+ "@quantajs/core": "2.0.0-beta.1"
47
+ },
48
+ "devDependencies": {
49
+ "@types/react": "^18.3.12",
50
+ "react": "^18.3.1"
51
+ },
52
+ "scripts": {
53
+ "dev": "npm run format && npm run lint:fix && npm run build",
54
+ "build": "npm run clean && vite build",
55
+ "preview": "vite preview",
56
+ "clean": "rimraf dist",
57
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
58
+ "lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
59
+ "format": "prettier --write \"src/**/*.{ts,tsx}\""
60
+ }
61
+ }
package/readme.md ADDED
@@ -0,0 +1,133 @@
1
+ # @quantajs/react
2
+
3
+ ![Logo](https://raw.githubusercontent.com/quanta-js/quanta/master/assets/quantajs_banner.png)
4
+
5
+ React integration for QuantaJS - A compact, scalable, and developer-friendly state management library for React applications.
6
+
7
+ ## 🚀 Features
8
+
9
+ ✅ **React Optimized** – Built specifically for React applications
10
+ ✅ **Performance First** – Uses `useSyncExternalStore` for efficient updates
11
+ ✅ **Type-Safe** – Full TypeScript support with proper inference
12
+ ✅ **Flexible** – Multiple usage patterns (Provider, Direct, Selectors)
13
+ ✅ **QuantaJS Core** – Direct access to reactive, computed, and watch
14
+
15
+ ## 📦 Installation
16
+
17
+ ```sh
18
+ npm install @quantajs/react @quantajs/core
19
+ # or
20
+ yarn add @quantajs/react @quantajs/core
21
+ # or
22
+ pnpm add @quantajs/react @quantajs/core
23
+ ```
24
+
25
+ ## ⚡ Quick Start
26
+
27
+ ### Basic Counter Example
28
+
29
+ ```tsx
30
+ import React from 'react';
31
+ import { createStore, QuantaProvider, useStore } from '@quantajs/react';
32
+
33
+ // Create store
34
+ const counterStore = createStore('counter', {
35
+ state: () => ({ count: 0 }),
36
+ getters: {
37
+ doubleCount: (state) => state.count * 2
38
+ },
39
+ actions: {
40
+ increment() { this.count++; },
41
+ decrement() { this.count--; }
42
+ }
43
+ });
44
+
45
+ // Component
46
+ function Counter() {
47
+ const store = useStore();
48
+
49
+ return (
50
+ <div>
51
+ <p>Count: {store.count}</p>
52
+ <p>Double: {store.doubleCount}</p>
53
+ <button onClick={() => store.increment()}>+</button>
54
+ <button onClick={() => store.decrement()}>-</button>
55
+ </div>
56
+ );
57
+ }
58
+
59
+ // App
60
+ function App() {
61
+ return (
62
+ <QuantaProvider store={counterStore}>
63
+ <Counter />
64
+ </QuantaProvider>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ### With Selectors (Performance)
70
+
71
+ ```tsx
72
+ import { useQuantaStore } from '@quantajs/react';
73
+
74
+ function CounterDisplay() {
75
+ // Only re-render when count changes
76
+ const count = useQuantaStore(counterStore, store => store.count);
77
+
78
+ return <p>Count: {count}</p>;
79
+ }
80
+ ```
81
+
82
+ ### Component-Scoped Store
83
+
84
+ ```tsx
85
+ import { useCreateStore } from '@quantajs/react';
86
+
87
+ function TodoComponent() {
88
+ const todoStore = useCreateStore(
89
+ 'todos',
90
+ () => ({ todos: [] }),
91
+ undefined,
92
+ {
93
+ addTodo(text: string) {
94
+ this.todos.push({ id: Date.now(), text, done: false });
95
+ }
96
+ }
97
+ );
98
+
99
+ return (
100
+ <div>
101
+ <button onClick={() => todoStore.addTodo('New task')}>
102
+ Add Todo
103
+ </button>
104
+ <p>Todos: {todoStore.todos.length}</p>
105
+ </div>
106
+ );
107
+ }
108
+ ```
109
+
110
+ ## 🔧 API
111
+
112
+ ### Hooks
113
+ - `useQuantaStore(store, selector?)` - Subscribe to store with optional selector
114
+ - `useStore(selector?)` - Access store from QuantaProvider context
115
+ - `useCreateStore(name, state, getters?, actions?)` - Create component-scoped store
116
+
117
+ ### Components
118
+ - `<QuantaProvider store={store}>` - Provide store to child components
119
+
120
+ ### Core Features
121
+ - `createStore`, `reactive`, `computed`, `watch` - Re-exported from @quantajs/core
122
+
123
+ ## 📜 License
124
+
125
+ This project is licensed under the MIT [License](https://github.com/quanta-js/quanta/blob/main/LICENSE) - see the LICENSE file for details.
126
+
127
+ ## 💬 Contributing
128
+
129
+ We welcome contributions! Feel free to open issues, submit PRs, or suggest improvements.
130
+
131
+ ## ⭐ Support
132
+
133
+ If you find this library useful, consider giving it a ⭐ star on [GitHub](https://github.com/quanta-js/quanta)!