@quantajs/react 2.0.0-beta.1 → 2.0.0-beta.2

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.cjs CHANGED
@@ -20,33 +20,25 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
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={};/**
23
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react"),T=require("@quantajs/core");function A(t,o){return v.useSyncExternalStore(t.subscribe,()=>o?o(t):t,()=>o?o(t):t)}const g=v.createContext({stores:{}});function q(){const t=v.useContext(g);if(!t)throw new Error("useQuantaContext must be used within a QuantaProvider");return t}function ae(t,o){const{stores:f}=q(),c=f[t];if(!c)throw new Error(`Store with name "${t}" does not exist in the context.`);return o?A(c,o):A(c)}function ue(t,o,f,c){const s=v.useRef();return s.current||(s.current=T.createStore(t,{state:o,getters:f,actions:c})),s.current}var S={exports:{}},R={};/**
24
24
  * @license React
25
- * react-jsx-runtime.production.min.js
25
+ * react-jsx-runtime.production.js
26
26
  *
27
- * Copyright (c) Facebook, Inc. and its affiliates.
27
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
28
28
  *
29
29
  * This source code is licensed under the MIT license found in the
30
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 $={};/**
31
+ */var L;function se(){if(L)return R;L=1;var t=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function f(c,s,i){var b=null;if(i!==void 0&&(b=""+i),s.key!==void 0&&(b=""+s.key),"key"in s){i={};for(var E in s)E!=="key"&&(i[E]=s[E])}else i=s;return s=i.ref,{$$typeof:t,type:c,key:b,ref:s!==void 0?s:null,props:i}}return R.Fragment=o,R.jsx=f,R.jsxs=f,R}var _={};/**
32
32
  * @license React
33
33
  * react-jsx-runtime.development.js
34
34
  *
35
- * Copyright (c) Facebook, Inc. and its affiliates.
35
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
36
36
  *
37
37
  * This source code is licensed under the MIT license found in the
38
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:
39
+ */var Q;function ce(){return Q||(Q=1,process.env.NODE_ENV!=="production"&&function(){function t(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case G:return"Profiler";case V:return"StrictMode";case Z:return"Suspense";case K:return"SuspenseList";case re:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case z:return"Portal";case B:return(e.displayName||"Context")+".Provider";case X:return(e._context.displayName||"Context")+".Consumer";case H:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:t(e.type)||"Memo";case N:r=e._payload,e=e._init;try{return t(e(r))}catch{}}return null}function o(e){return""+e}function f(e){try{o(e);var r=!1}catch{r=!0}if(r){r=console;var n=r.error,a=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",a),o(e)}}function c(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===N)return"<...>";try{var r=t(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function s(){var e=P.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function b(e){if(Y.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function n(){$||($=!0,console.error("%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)",r))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}function U(){var e=t(this.type);return I[e]||(I[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function J(e,r,n,a,d,l,x,w){return n=l.ref,e={$$typeof:C,type:e,key:r,props:l,_owner:d},(n!==void 0?n:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:U}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:w}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function h(e,r,n,a,d,l,x,w){var u=r.children;if(u!==void 0)if(a)if(ne(u)){for(a=0;a<u.length;a++)y(u[a]);Object.freeze&&Object.freeze(u)}else console.error("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 y(u);if(Y.call(r,"key")){u=t(e);var m=Object.keys(r).filter(function(oe){return oe!=="key"});a=0<m.length?"{key: someKey, "+m.join(": ..., ")+": ...}":"{key: someKey}",M[u+a]||(m=0<m.length?"{"+m.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
48
40
  let props = %s;
49
41
  <%s {...props} />
50
42
  React keys must be passed directly to JSX without using spread:
51
43
  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;
44
+ <%s key={someKey} {...props} />`,a,u,m,u),M[u+a]=!0)}if(u=null,n!==void 0&&(f(n),u=""+n),b(r)&&(f(r.key),u=""+r.key),"key"in r){n={};for(var j in r)j!=="key"&&(n[j]=r[j])}else n=r;return u&&E(n,typeof e=="function"?e.displayName||e.name||"Unknown":e),J(e,u,l,d,s(),n,x,w)}function y(e){typeof e=="object"&&e!==null&&e.$$typeof===C&&e._store&&(e._store.validated=1)}var p=v,C=Symbol.for("react.transitional.element"),z=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),G=Symbol.for("react.profiler"),X=Symbol.for("react.consumer"),B=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),P=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=Object.prototype.hasOwnProperty,ne=Array.isArray,k=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var $,I={},F=p.react_stack_bottom_frame.bind(p,i)(),D=k(c(i)),M={};_.Fragment=O,_.jsx=function(e,r,n,a,d){var l=1e4>P.recentlyCreatedOwnerStacks++;return h(e,r,n,!1,a,d,l?Error("react-stack-top-frame"):F,l?k(c(e)):D)},_.jsxs=function(e,r,n,a,d){var l=1e4>P.recentlyCreatedOwnerStacks++;return h(e,r,n,!0,a,d,l?Error("react-stack-top-frame"):F,l?k(c(e)):D)}}()),_}var W;function ie(){return W||(W=1,process.env.NODE_ENV==="production"?S.exports=se():S.exports=ce()),S.exports}var le=ie();function fe({stores:t,children:o}){return le.jsx(g.Provider,{value:{stores:t},children:o})}Object.defineProperty(exports,"computed",{enumerable:!0,get:()=>T.computed});Object.defineProperty(exports,"createStore",{enumerable:!0,get:()=>T.createStore});Object.defineProperty(exports,"reactive",{enumerable:!0,get:()=>T.reactive});Object.defineProperty(exports,"watch",{enumerable:!0,get:()=>T.watch});exports.QuantaContext=g;exports.QuantaProvider=fe;exports.useCreateStore=ue;exports.useQuantaContext=q;exports.useQuantaStore=A;exports.useStore=ae;
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { computed } from '@quantajs/core';
3
3
  import { Context } from 'react';
4
4
  import { createStore } from '@quantajs/core';
5
5
  import { GetterDefinition } from '@quantajs/core';
6
- import { JSX as JSX_2 } from 'react/jsx-runtime';
6
+ import { JSX } from 'react/jsx-runtime';
7
7
  import { reactive } from '@quantajs/core';
8
8
  import { ReactNode } from 'react';
9
9
  import { StateDefinition } from '@quantajs/core';
@@ -20,21 +20,25 @@ export { createStore }
20
20
 
21
21
  export { GetterDefinition }
22
22
 
23
- export declare const QuantaContext: Context<QuantaContextValue | null>;
23
+ export declare const QuantaContext: Context<QuantaContextValue>;
24
24
 
25
25
  declare interface QuantaContextValue {
26
- store: StoreInstance<any, any, any>;
26
+ stores: {
27
+ [name: string]: StoreInstance<any, any, any>;
28
+ };
27
29
  }
28
30
 
29
31
  /**
30
32
  * 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
+ * @param stores - The QuantaJS stores instances to provide
34
+ * @param children - Child components that can access the stores
33
35
  */
34
- export declare function QuantaProvider({ store, children }: QuantaProviderProps): JSX_2.Element;
36
+ export declare function QuantaProvider({ stores, children }: QuantaProviderProps): JSX.Element;
35
37
 
36
38
  declare interface QuantaProviderProps {
37
- store: StoreInstance<any, any, any>;
39
+ stores: {
40
+ [key: string]: StoreInstance<any, any, any>;
41
+ };
38
42
  children: ReactNode;
39
43
  }
40
44
 
@@ -71,10 +75,11 @@ export declare function useQuantaStore<S extends object, G extends object, A ext
71
75
 
72
76
  /**
73
77
  * Hook to access and subscribe to the QuantaJS store from context
78
+ * @param name - The name of the store to access
74
79
  * @param selector - Optional selector function to pick specific parts of the store
75
80
  * @returns The store instance or selected value that updates reactively
76
81
  */
77
- export declare function useStore<T = any>(selector?: (store: StoreInstance<any, any, any>) => T): T extends undefined ? StoreInstance<any, any, any> : T;
82
+ export declare function useStore<T = any>(name: string, selector?: (store: StoreInstance<any, any, any>) => T): T extends undefined ? StoreInstance<any, any, any> : T;
78
83
 
79
84
  export { watch }
80
85
 
package/dist/index.js CHANGED
@@ -20,674 +20,329 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
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
23
+ import te, { useSyncExternalStore as ne, createContext as oe, useContext as ae, useRef as ue } from "react";
24
+ import { createStore as se } from "@quantajs/core";
25
+ import { computed as pe, createStore as Se, reactive as ke, watch as xe } from "@quantajs/core";
26
+ function I(t, o) {
27
+ return ne(
28
+ t.subscribe,
29
+ () => o ? o(t) : t,
30
+ () => o ? o(t) : t
31
31
  );
32
32
  }
33
- const we = dr(null);
34
- function br() {
35
- const l = pr(we);
36
- if (!l)
33
+ const M = oe({ stores: {} });
34
+ function ce() {
35
+ const t = ae(M);
36
+ if (!t)
37
37
  throw new Error(
38
38
  "useQuantaContext must be used within a QuantaProvider"
39
39
  );
40
- return l;
40
+ return t;
41
41
  }
42
- function Sr(l) {
43
- const { store: c } = br();
44
- return l ? Te(c, l) : Te(c);
42
+ function Re(t, o) {
43
+ const { stores: f } = ce(), c = f[t];
44
+ if (!c)
45
+ throw new Error(
46
+ `Store with name "${t}" does not exist in the context.`
47
+ );
48
+ return o ? I(c, o) : I(c);
45
49
  }
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;
50
+ function _e(t, o, f, c) {
51
+ const s = ue();
52
+ return s.current || (s.current = se(t, { state: o, getters: f, actions: c })), s.current;
49
53
  }
50
- var U = { exports: {} }, A = {};
54
+ var T = { exports: {} }, _ = {};
51
55
  /**
52
56
  * @license React
53
- * react-jsx-runtime.production.min.js
57
+ * react-jsx-runtime.production.js
54
58
  *
55
- * Copyright (c) Facebook, Inc. and its affiliates.
59
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
56
60
  *
57
61
  * This source code is licensed under the MIT license found in the
58
62
  * LICENSE file in the root directory of this source tree.
59
63
  */
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 };
64
+ var F;
65
+ function ie() {
66
+ if (F) return _;
67
+ F = 1;
68
+ var t = Symbol.for("react.transitional.element"), o = Symbol.for("react.fragment");
69
+ function f(c, s, i) {
70
+ var E = null;
71
+ if (i !== void 0 && (E = "" + i), s.key !== void 0 && (E = "" + s.key), "key" in s) {
72
+ i = {};
73
+ for (var R in s)
74
+ R !== "key" && (i[R] = s[R]);
75
+ } else i = s;
76
+ return s = i.ref, {
77
+ $$typeof: t,
78
+ type: c,
79
+ key: E,
80
+ ref: s !== void 0 ? s : null,
81
+ props: i
82
+ };
71
83
  }
72
- return A.Fragment = j, A.jsx = k, A.jsxs = k, A;
84
+ return _.Fragment = o, _.jsx = f, _.jsxs = f, _;
73
85
  }
74
- var I = {};
86
+ var b = {};
75
87
  /**
76
88
  * @license React
77
89
  * react-jsx-runtime.development.js
78
90
  *
79
- * Copyright (c) Facebook, Inc. and its affiliates.
91
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
80
92
  *
81
93
  * This source code is licensed under the MIT license found in the
82
94
  * LICENSE file in the root directory of this source tree.
83
95
  */
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;
96
+ var D;
97
+ function le() {
98
+ return D || (D = 1, process.env.NODE_ENV !== "production" && function() {
99
+ function t(e) {
100
+ if (e == null) return null;
101
+ if (typeof e == "function")
102
+ return e.$$typeof === K ? null : e.displayName || e.name || null;
103
+ if (typeof e == "string") return e;
138
104
  switch (e) {
139
- case R:
105
+ case p:
140
106
  return "Fragment";
141
- case j:
142
- return "Portal";
143
- case $:
107
+ case z:
144
108
  return "Profiler";
145
- case y:
109
+ case J:
146
110
  return "StrictMode";
147
- case O:
111
+ case X:
148
112
  return "Suspense";
149
- case E:
113
+ case B:
150
114
  return "SuspenseList";
115
+ case Z:
116
+ return "Activity";
151
117
  }
152
118
  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;
119
+ switch (typeof e.tag == "number" && console.error(
120
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
121
+ ), e.$$typeof) {
122
+ case q:
123
+ return "Portal";
124
+ case V:
125
+ return (e.displayName || "Context") + ".Provider";
126
+ case Q:
127
+ return (e._context.displayName || "Context") + ".Consumer";
128
+ case G:
129
+ var r = e.render;
130
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
131
+ case H:
132
+ return r = e.displayName || null, r !== null ? r : t(e.type) || "Memo";
133
+ case j:
134
+ r = e._payload, e = e._init;
167
135
  try {
168
- return _(o(u));
136
+ return t(e(r));
169
137
  } catch {
170
- return null;
171
138
  }
172
- }
173
139
  }
174
140
  return null;
175
141
  }
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();
142
+ function o(e) {
143
+ return "" + e;
256
144
  }
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();
145
+ function f(e) {
271
146
  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
- }
147
+ o(e);
148
+ var r = !1;
149
+ } catch {
150
+ r = !0;
389
151
  }
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;
152
+ if (r) {
153
+ r = console;
154
+ var n = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
155
+ return n.call(
156
+ r,
157
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
158
+ a
159
+ ), o(e);
399
160
  }
400
161
  }
401
- function Ke(e) {
162
+ function c(e) {
163
+ if (e === p) return "<>";
164
+ if (typeof e == "object" && e !== null && e.$$typeof === j)
165
+ return "<...>";
402
166
  try {
403
- return ce(e), !1;
167
+ var r = t(e);
168
+ return r ? "<" + r + ">" : "<...>";
404
169
  } catch {
405
- return !0;
170
+ return "<...>";
406
171
  }
407
172
  }
408
- function ce(e) {
409
- return "" + e;
173
+ function s() {
174
+ var e = S.A;
175
+ return e === null ? null : e.getOwner();
410
176
  }
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);
177
+ function i() {
178
+ return Error("react-stack-top-frame");
414
179
  }
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")) {
180
+ function E(e) {
181
+ if (g.call(e, "key")) {
431
182
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
432
- if (r && r.isReactWarning)
433
- return !1;
183
+ if (r && r.isReactWarning) return !1;
434
184
  }
435
185
  return e.key !== void 0;
436
186
  }
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
- });
187
+ function R(e, r) {
188
+ function n() {
189
+ y || (y = !0, console.error(
190
+ "%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)",
191
+ r
192
+ ));
460
193
  }
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
194
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
195
+ get: n,
196
+ configurable: !0
197
+ });
198
+ }
199
+ function W() {
200
+ var e = t(this.type);
201
+ return C[e] || (C[e] = !0, console.error(
202
+ "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."
203
+ )), e = this.props.ref, e !== void 0 ? e : null;
204
+ }
205
+ function U(e, r, n, a, d, l, x, w) {
206
+ return n = l.ref, e = {
207
+ $$typeof: h,
467
208
  type: e,
468
209
  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", {
210
+ props: l,
211
+ _owner: d
212
+ }, (n !== void 0 ? n : null) !== null ? Object.defineProperty(e, "ref", {
213
+ enumerable: !1,
214
+ get: W
215
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
475
216
  configurable: !1,
476
217
  enumerable: !1,
477
218
  writable: !0,
478
- value: !1
479
- }), Object.defineProperty(a, "_self", {
219
+ value: 0
220
+ }), Object.defineProperty(e, "_debugInfo", {
480
221
  configurable: !1,
481
222
  enumerable: !1,
482
- writable: !1,
483
- value: n
484
- }), Object.defineProperty(a, "_source", {
223
+ writable: !0,
224
+ value: null
225
+ }), Object.defineProperty(e, "_debugStack", {
485
226
  configurable: !1,
486
227
  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:
228
+ writable: !0,
229
+ value: x
230
+ }), Object.defineProperty(e, "_debugTask", {
231
+ configurable: !1,
232
+ enumerable: !1,
233
+ writable: !0,
234
+ value: w
235
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
236
+ }
237
+ function P(e, r, n, a, d, l, x, w) {
238
+ var u = r.children;
239
+ if (u !== void 0)
240
+ if (a)
241
+ if (ee(u)) {
242
+ for (a = 0; a < u.length; a++)
243
+ A(u[a]);
244
+ Object.freeze && Object.freeze(u);
245
+ } else
246
+ console.error(
247
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
248
+ );
249
+ else A(u);
250
+ if (g.call(r, "key")) {
251
+ u = t(e);
252
+ var m = Object.keys(r).filter(function(re) {
253
+ return re !== "key";
254
+ });
255
+ a = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", $[u + a] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error(
256
+ `A props object containing a "key" prop is being spread into JSX:
654
257
  let props = %s;
655
258
  <%s {...props} />
656
259
  React keys must be passed directly to JSX without using spread:
657
260
  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;
261
+ <%s key={someKey} {...props} />`,
262
+ a,
263
+ u,
264
+ m,
265
+ u
266
+ ), $[u + a] = !0);
662
267
  }
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;
268
+ if (u = null, n !== void 0 && (f(n), u = "" + n), E(r) && (f(r.key), u = "" + r.key), "key" in r) {
269
+ n = {};
270
+ for (var O in r)
271
+ O !== "key" && (n[O] = r[O]);
272
+ } else n = r;
273
+ return u && R(
274
+ n,
275
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
276
+ ), U(
277
+ e,
278
+ u,
279
+ l,
280
+ d,
281
+ s(),
282
+ n,
283
+ x,
284
+ w
285
+ );
286
+ }
287
+ function A(e) {
288
+ typeof e == "object" && e !== null && e.$$typeof === h && e._store && (e._store.validated = 1);
289
+ }
290
+ var v = te, h = Symbol.for("react.transitional.element"), q = Symbol.for("react.portal"), p = Symbol.for("react.fragment"), J = Symbol.for("react.strict_mode"), z = Symbol.for("react.profiler"), Q = Symbol.for("react.consumer"), V = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), X = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), H = Symbol.for("react.memo"), j = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), K = Symbol.for("react.client.reference"), S = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, g = Object.prototype.hasOwnProperty, ee = Array.isArray, k = console.createTask ? console.createTask : function() {
291
+ return null;
292
+ };
293
+ v = {
294
+ react_stack_bottom_frame: function(e) {
295
+ return e();
296
+ }
297
+ };
298
+ var y, C = {}, N = v.react_stack_bottom_frame.bind(
299
+ v,
300
+ i
301
+ )(), Y = k(c(i)), $ = {};
302
+ b.Fragment = p, b.jsx = function(e, r, n, a, d) {
303
+ var l = 1e4 > S.recentlyCreatedOwnerStacks++;
304
+ return P(
305
+ e,
306
+ r,
307
+ n,
308
+ !1,
309
+ a,
310
+ d,
311
+ l ? Error("react-stack-top-frame") : N,
312
+ l ? k(c(e)) : Y
313
+ );
314
+ }, b.jsxs = function(e, r, n, a, d) {
315
+ var l = 1e4 > S.recentlyCreatedOwnerStacks++;
316
+ return P(
317
+ e,
318
+ r,
319
+ n,
320
+ !0,
321
+ a,
322
+ d,
323
+ l ? Error("react-stack-top-frame") : N,
324
+ l ? k(c(e)) : Y
325
+ );
326
+ };
327
+ }()), b;
673
328
  }
674
- var Oe;
675
- function yr() {
676
- return Oe || (Oe = 1, process.env.NODE_ENV === "production" ? U.exports = hr() : U.exports = Rr()), U.exports;
329
+ var L;
330
+ function fe() {
331
+ return L || (L = 1, process.env.NODE_ENV === "production" ? T.exports = ie() : T.exports = le()), T.exports;
677
332
  }
678
- var _r = yr();
679
- function Or({ store: l, children: c }) {
680
- return /* @__PURE__ */ _r.jsx(we.Provider, { value: { store: l }, children: c });
333
+ var de = fe();
334
+ function be({ stores: t, children: o }) {
335
+ return /* @__PURE__ */ de.jsx(M.Provider, { value: { stores: t }, children: o });
681
336
  }
682
337
  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
338
+ M as QuantaContext,
339
+ be as QuantaProvider,
340
+ pe as computed,
341
+ Se as createStore,
342
+ ke as reactive,
343
+ _e as useCreateStore,
344
+ ce as useQuantaContext,
345
+ I as useQuantaStore,
346
+ Re as useStore,
347
+ xe as watch
693
348
  };
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "url": "https://github.com/quanta-js/quanta/issues"
23
23
  },
24
24
  "homepage": "https://quantajs.com",
25
- "version": "2.0.0-beta.1",
25
+ "version": "2.0.0-beta.2",
26
26
  "type": "module",
27
27
  "license": "MIT",
28
28
  "main": "./dist/index.js",
@@ -43,11 +43,15 @@
43
43
  "react": ">=16.8.0"
44
44
  },
45
45
  "dependencies": {
46
- "@quantajs/core": "2.0.0-beta.1"
46
+ "@quantajs/core": "2.0.0-beta.2"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/react": "^18.3.12",
50
- "react": "^18.3.1"
49
+ "@types/react": "^19.1.9",
50
+ "react": "^19.1.1"
51
+ },
52
+ "publishConfig": {
53
+ "access": "public",
54
+ "registry": "https://registry.npmjs.org/"
51
55
  },
52
56
  "scripts": {
53
57
  "dev": "npm run format && npm run lint:fix && npm run build",
package/readme.md CHANGED
@@ -32,37 +32,41 @@ import { createStore, QuantaProvider, useStore } from '@quantajs/react';
32
32
 
33
33
  // Create store
34
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
- }
35
+ state: () => ({ count: 0 }),
36
+ getters: {
37
+ doubleCount: (state) => state.count * 2,
38
+ },
39
+ actions: {
40
+ increment() {
41
+ this.count++;
42
+ },
43
+ decrement() {
44
+ this.count--;
45
+ },
46
+ },
43
47
  });
44
48
 
45
49
  // Component
46
50
  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
- );
51
+ const store = useStore();
52
+
53
+ return (
54
+ <div>
55
+ <p>Count: {store.count}</p>
56
+ <p>Double: {store.doubleCount}</p>
57
+ <button onClick={() => store.increment()}>+</button>
58
+ <button onClick={() => store.decrement()}>-</button>
59
+ </div>
60
+ );
57
61
  }
58
62
 
59
63
  // App
60
64
  function App() {
61
- return (
62
- <QuantaProvider store={counterStore}>
63
- <Counter />
64
- </QuantaProvider>
65
- );
65
+ return (
66
+ <QuantaProvider store={counterStore}>
67
+ <Counter />
68
+ </QuantaProvider>
69
+ );
66
70
  }
67
71
  ```
68
72
 
@@ -72,10 +76,10 @@ function App() {
72
76
  import { useQuantaStore } from '@quantajs/react';
73
77
 
74
78
  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
+ // Only re-render when count changes
80
+ const count = useQuantaStore(counterStore, (store) => store.count);
81
+
82
+ return <p>Count: {count}</p>;
79
83
  }
80
84
  ```
81
85
 
@@ -85,39 +89,42 @@ function CounterDisplay() {
85
89
  import { useCreateStore } from '@quantajs/react';
86
90
 
87
91
  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
- );
92
+ const todoStore = useCreateStore(
93
+ 'todos',
94
+ () => ({ todos: [] }),
95
+ undefined,
96
+ {
97
+ addTodo(text: string) {
98
+ this.todos.push({ id: Date.now(), text, done: false });
99
+ },
100
+ },
101
+ );
102
+
103
+ return (
104
+ <div>
105
+ <button onClick={() => todoStore.addTodo('New task')}>
106
+ Add Todo
107
+ </button>
108
+ <p>Todos: {todoStore.todos.length}</p>
109
+ </div>
110
+ );
107
111
  }
108
112
  ```
109
113
 
110
114
  ## 🔧 API
111
115
 
112
116
  ### Hooks
117
+
113
118
  - `useQuantaStore(store, selector?)` - Subscribe to store with optional selector
114
119
  - `useStore(selector?)` - Access store from QuantaProvider context
115
120
  - `useCreateStore(name, state, getters?, actions?)` - Create component-scoped store
116
121
 
117
122
  ### Components
123
+
118
124
  - `<QuantaProvider store={store}>` - Provide store to child components
119
125
 
120
126
  ### Core Features
127
+
121
128
  - `createStore`, `reactive`, `computed`, `watch` - Re-exported from @quantajs/core
122
129
 
123
130
  ## 📜 License