react-intent-engine-z 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function r(t,e,n,r){return new(n||(n=Promise))(function(o,u){function i(t){try{c(r.next(t))}catch(t){u(t)}}function a(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,a)}c((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,o=0,u=e.length;o<u;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var i=t.createContext(null);function a(){var e=t.useContext(i);if(!e)throw new Error("Missing IntentProvider");return e}function c(t){var e={exports:{}};return t(e,e.exports),e.exports}var s="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},l=n.default.useState,f=n.default.useEffect,d=n.default.useLayoutEffect,p=n.default.useDebugValue;function v(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!s(t,n)}catch(t){return!0}}var S="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=l({inst:{value:n,getSnapshot:e}}),o=r[0].inst,u=r[1];return d(function(){o.value=n,o.getSnapshot=e,v(o)&&u({inst:o})},[t,n,e]),f(function(){return v(o)&&u({inst:o}),t(function(){v(o)&&u({inst:o})})},[t]),p(n),n},y={useSyncExternalStore:void 0!==n.default.useSyncExternalStore?n.default.useSyncExternalStore:S},h=c(function(t,e){"production"!==process.env.NODE_ENV&&function(){function t(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!o(t,n)}catch(t){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=n.default,o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},u=r.useState,i=r.useEffect,a=r.useLayoutEffect,c=r.useDebugValue,s=!1,l=!1,f="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(e,n){s||void 0===r.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var f=n();if(!l){var d=n();o(f,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var p=(d=u({inst:{value:f,getSnapshot:n}}))[0].inst,v=d[1];return a(function(){p.value=f,p.getSnapshot=n,t(p)&&v({inst:p})},[e,f,n]),i(function(){return t(p)&&v({inst:p}),e(function(){t(p)&&v({inst:p})})},[e]),c(f),f};e.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:f,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),_=c(function(t){"production"===process.env.NODE_ENV?t.exports=y:t.exports=h});exports.IntentProvider=function(t){var e=t.engine,r=t.children;return n.default.createElement(i.Provider,{value:e},r)},exports.createIntentEngine=function(t){var e,n,i,a,c,s,l=(i=t.initialState,a=structuredClone(i),c=new Set,{getState:function(){return a},setState:function(t){a=t(a),c.forEach(function(t){return t()})},subscribe:function(t){return c.add(t),function(){return c.delete(t)}}}),f=null!==(e=t.effects)&&void 0!==e?e:{},d=new Map,p=new Map,v=new Map,S=(s=null!==(n=t.middleware)&&void 0!==n?n:[],function(t,e){var n=-1;return function u(i){return r(this,void 0,void 0,function(){var r;return o(this,function(o){if(i<=n)throw new Error("next() called twice");return n=i,(r=s[i])?[2,r(t,function(){return u(i+1)})]:[2,e()]})})}(0)});return{emit:function t(e){var n;return r(this,void 0,void 0,function(){var u,i=this;return o(this,function(a){switch(a.label){case 0:return u=function(t,e,n){return{get:function(e){return e.split(".").reduce(function(t,e){return null==t?void 0:t[e]},t.getState())},set:function(e,n){t.setState(function(t){for(var r,o=structuredClone(t),u=e.split("."),i=o,a=0;a<u.length-1;a++)i=i[r=u[a]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:e,effects:n}}(l,t,f),(null===(n=p.get(e.type))||void 0===n?void 0:n.some(function(t){return!t(u)}))?[2]:(v.set(e.type,"pending"),[4,S(e,function(){return r(i,void 0,void 0,function(){var t,n,r;return o(this,function(o){switch(o.label){case 0:t=0,n=null!==(r=d.get(e.type))&&void 0!==r?r:[],o.label=1;case 1:return t<n.length?[4,(0,n[t])(e,u)]:[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})})]);case 1:return a.sent(),v.set(e.type,"success"),[2]}})})},on:function(t,e){var n;d.set(t,u(u([],null!==(n=d.get(t))&&void 0!==n?n:[],!0),[e],!1))},guard:function(t,e){var n;p.set(t,u(u([],null!==(n=p.get(t))&&void 0!==n?n:[],!0),[e],!1))},store:l,getStatus:function(t){var e;return null!==(e=v.get(t))&&void 0!==e?e:"idle"}}},exports.useEngine=a,exports.useIntent=function(){var t=a();return function(e){return t.emit(e)}},exports.useIntentState=function(t){var e=a();return _.useSyncExternalStore(function(n){return e.store.subscribe(t,n)},function(){return e.store.getState(t)})},exports.useIntentStatus=function(t){return a().getStatus(t)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var n=e(t);function r(t,e,n,r){return new(n||(n=Promise))(function(o,u){function i(t){try{c(r.next(t))}catch(t){u(t)}}function a(t){try{c(r.throw(t))}catch(t){u(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,a)}c((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=e.call(t,u)}catch(t){a=[6,t],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,o=0,u=e.length;o<u;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var i=t.createContext(null);function a(){var e=t.useContext(i);if(!e)throw new Error("Missing IntentProvider");return e}function c(t){var e={exports:{}};return t(e,e.exports),e.exports}var s="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},f=n.default.useState,l=n.default.useEffect,d=n.default.useLayoutEffect,p=n.default.useDebugValue;function v(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!s(t,n)}catch(t){return!0}}var S="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=f({inst:{value:n,getSnapshot:e}}),o=r[0].inst,u=r[1];return d(function(){o.value=n,o.getSnapshot=e,v(o)&&u({inst:o})},[t,n,e]),l(function(){return v(o)&&u({inst:o}),t(function(){v(o)&&u({inst:o})})},[t]),p(n),n},y={useSyncExternalStore:void 0!==n.default.useSyncExternalStore?n.default.useSyncExternalStore:S},h=c(function(t,e){"production"!==process.env.NODE_ENV&&function(){function t(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!o(t,n)}catch(t){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=n.default,o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},u=r.useState,i=r.useEffect,a=r.useLayoutEffect,c=r.useDebugValue,s=!1,f=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(e,n){s||void 0===r.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var l=n();if(!f){var d=n();o(l,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var p=(d=u({inst:{value:l,getSnapshot:n}}))[0].inst,v=d[1];return a(function(){p.value=l,p.getSnapshot=n,t(p)&&v({inst:p})},[e,l,n]),i(function(){return t(p)&&v({inst:p}),e(function(){t(p)&&v({inst:p})})},[e]),c(l),l};e.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),_=c(function(t){"production"===process.env.NODE_ENV?t.exports=y:t.exports=h});exports.IntentProvider=function(t){var e=t.engine,r=t.children;return n.default.createElement(i.Provider,{value:e},r)},exports.createIntentEngine=function(t){var e,n,i,a,c,s,f=(i=t.initialState,a=structuredClone(i),c=new Set,{getState:function(){return a},setState:function(t){a=t(a),c.forEach(function(t){return t()})},subscribe:function(t){return c.add(t),function(){return c.delete(t)}}}),l=null!==(e=t.effects)&&void 0!==e?e:{},d=new Map,p=new Map,v=new Map,S=(s=null!==(n=t.middleware)&&void 0!==n?n:[],function(t,e){var n=-1;return function u(i){return r(this,void 0,void 0,function(){var r;return o(this,function(o){if(i<=n)throw new Error("next() called twice");return n=i,(r=s[i])?[2,r(t,function(){return u(i+1)})]:[2,e()]})})}(0)});return{emit:function t(e){var n;return r(this,void 0,void 0,function(){var u,i=this;return o(this,function(a){switch(a.label){case 0:return u=function(t,e,n){return{get:function(e){return e.split(".").reduce(function(t,e){return null==t?void 0:t[e]},t.getState())},set:function(e,n){t.setState(function(t){for(var r,o=structuredClone(t),u=e.split("."),i=o,a=0;a<u.length-1;a++)i=i[r=u[a]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:e,effects:n}}(f,t,l),(null===(n=p.get(e.type))||void 0===n?void 0:n.some(function(t){return!t(u)}))?[2]:(v.set(e.type,"pending"),[4,S(e,function(){return r(i,void 0,void 0,function(){var t,n,r;return o(this,function(o){switch(o.label){case 0:t=0,n=null!==(r=d.get(e.type))&&void 0!==r?r:[],o.label=1;case 1:return t<n.length?[4,(0,n[t])(e,u)]:[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})})]);case 1:return a.sent(),v.set(e.type,"success"),[2]}})})},on:function(t,e){var n;d.set(t,u(u([],null!==(n=d.get(t))&&void 0!==n?n:[],!0),[e],!1))},guard:function(t,e){var n;p.set(t,u(u([],null!==(n=p.get(t))&&void 0!==n?n:[],!0),[e],!1))},store:f,getStatus:function(t){var e;return null!==(e=v.get(t))&&void 0!==e?e:"idle"}}},exports.useEngine=a,exports.useIntent=function(){var t=a();return function(e){return t.emit(e)}},exports.useIntentState=function(e){var n=a(),r=t.useRef();return _.useSyncExternalStore(n.store.subscribe,function(){var t=e(n.store.getState());return Object.is(t,r.current)?r.current:(r.current=t,t)})},exports.useIntentStatus=function(t){var e=a();return _.useSyncExternalStore(function(n){return e.subscribeStatus(t,n)},function(){return e.getStatus(t)})};
@@ -1 +1 @@
1
- import t,{createContext as e,useContext as n}from"react";function r(t,e,n,r){return new(n||(n=Promise))(function(o,u){function i(t){try{a(r.next(t))}catch(t){u(t)}}function c(t){try{a(r.throw(t))}catch(t){u(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,c)}a((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=e.call(t,u)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function u(t,e,n){if(n||2===arguments.length)for(var r,o=0,u=e.length;o<u;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function i(t){var e,n,i,c,a,s,l=(i=t.initialState,c=structuredClone(i),a=new Set,{getState:function(){return c},setState:function(t){c=t(c),a.forEach(function(t){return t()})},subscribe:function(t){return a.add(t),function(){return a.delete(t)}}}),f=null!==(e=t.effects)&&void 0!==e?e:{},d=new Map,p=new Map,v=new Map,S=(s=null!==(n=t.middleware)&&void 0!==n?n:[],function(t,e){var n=-1;return function u(i){return r(this,void 0,void 0,function(){var r;return o(this,function(o){if(i<=n)throw new Error("next() called twice");return n=i,(r=s[i])?[2,r(t,function(){return u(i+1)})]:[2,e()]})})}(0)});return{emit:function t(e){var n;return r(this,void 0,void 0,function(){var u,i=this;return o(this,function(c){switch(c.label){case 0:return u=function(t,e,n){return{get:function(e){return e.split(".").reduce(function(t,e){return null==t?void 0:t[e]},t.getState())},set:function(e,n){t.setState(function(t){for(var r,o=structuredClone(t),u=e.split("."),i=o,c=0;c<u.length-1;c++)i=i[r=u[c]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:e,effects:n}}(l,t,f),(null===(n=p.get(e.type))||void 0===n?void 0:n.some(function(t){return!t(u)}))?[2]:(v.set(e.type,"pending"),[4,S(e,function(){return r(i,void 0,void 0,function(){var t,n,r;return o(this,function(o){switch(o.label){case 0:t=0,n=null!==(r=d.get(e.type))&&void 0!==r?r:[],o.label=1;case 1:return t<n.length?[4,(0,n[t])(e,u)]:[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})})]);case 1:return c.sent(),v.set(e.type,"success"),[2]}})})},on:function(t,e){var n;d.set(t,u(u([],null!==(n=d.get(t))&&void 0!==n?n:[],!0),[e],!1))},guard:function(t,e){var n;p.set(t,u(u([],null!==(n=p.get(t))&&void 0!==n?n:[],!0),[e],!1))},store:l,getStatus:function(t){var e;return null!==(e=v.get(t))&&void 0!==e?e:"idle"}}}"function"==typeof SuppressedError&&SuppressedError;var c=e(null);function a(e){var n=e.engine,r=e.children;return t.createElement(c.Provider,{value:n},r)}function s(){var t=n(c);if(!t)throw new Error("Missing IntentProvider");return t}function l(){var t=s();return function(e){return t.emit(e)}}function f(t){var e={exports:{}};return t(e,e.exports),e.exports}var d="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},p=t.useState,v=t.useEffect,S=t.useLayoutEffect,h=t.useDebugValue;function y(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!d(t,n)}catch(t){return!0}}var _="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=p({inst:{value:n,getSnapshot:e}}),o=r[0].inst,u=r[1];return S(function(){o.value=n,o.getSnapshot=e,y(o)&&u({inst:o})},[t,n,e]),v(function(){return y(o)&&u({inst:o}),t(function(){y(o)&&u({inst:o})})},[t]),h(n),n},E={useSyncExternalStore:void 0!==t.useSyncExternalStore?t.useSyncExternalStore:_},O=f(function(e,n){"production"!==process.env.NODE_ENV&&function(){function e(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!o(t,n)}catch(t){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=t,o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},u=r.useState,i=r.useEffect,c=r.useLayoutEffect,a=r.useDebugValue,s=!1,l=!1,f="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,n){s||void 0===r.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var f=n();if(!l){var d=n();o(f,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var p=(d=u({inst:{value:f,getSnapshot:n}}))[0].inst,v=d[1];return c(function(){p.value=f,p.getSnapshot=n,e(p)&&v({inst:p})},[t,f,n]),i(function(){return e(p)&&v({inst:p}),t(function(){e(p)&&v({inst:p})})},[t]),a(f),f};n.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:f,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),g=f(function(t){"production"===process.env.NODE_ENV?t.exports=E:t.exports=O});function w(t){var e=s();return g.useSyncExternalStore(function(n){return e.store.subscribe(t,n)},function(){return e.store.getState(t)})}function b(t){return s().getStatus(t)}export{a as IntentProvider,i as createIntentEngine,s as useEngine,l as useIntent,w as useIntentState,b as useIntentStatus};
1
+ import t,{createContext as e,useContext as n,useRef as r}from"react";function o(t,e,n,r){return new(n||(n=Promise))(function(o,u){function i(t){try{a(r.next(t))}catch(t){u(t)}}function c(t){try{a(r.throw(t))}catch(t){u(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,c)}a((r=r.apply(t,e||[])).next())})}function u(t,e){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=e.call(t,u)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}function i(t,e,n){if(n||2===arguments.length)for(var r,o=0,u=e.length;o<u;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}function c(t){var e,n,r,c,a,s,l=(r=t.initialState,c=structuredClone(r),a=new Set,{getState:function(){return c},setState:function(t){c=t(c),a.forEach(function(t){return t()})},subscribe:function(t){return a.add(t),function(){return a.delete(t)}}}),f=null!==(e=t.effects)&&void 0!==e?e:{},d=new Map,p=new Map,v=new Map,S=(s=null!==(n=t.middleware)&&void 0!==n?n:[],function(t,e){var n=-1;return function r(i){return o(this,void 0,void 0,function(){var o;return u(this,function(u){if(i<=n)throw new Error("next() called twice");return n=i,(o=s[i])?[2,o(t,function(){return r(i+1)})]:[2,e()]})})}(0)});return{emit:function t(e){var n;return o(this,void 0,void 0,function(){var r,i=this;return u(this,function(c){switch(c.label){case 0:return r=function(t,e,n){return{get:function(e){return e.split(".").reduce(function(t,e){return null==t?void 0:t[e]},t.getState())},set:function(e,n){t.setState(function(t){for(var r,o=structuredClone(t),u=e.split("."),i=o,c=0;c<u.length-1;c++)i=i[r=u[c]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:e,effects:n}}(l,t,f),(null===(n=p.get(e.type))||void 0===n?void 0:n.some(function(t){return!t(r)}))?[2]:(v.set(e.type,"pending"),[4,S(e,function(){return o(i,void 0,void 0,function(){var t,n,o;return u(this,function(u){switch(u.label){case 0:t=0,n=null!==(o=d.get(e.type))&&void 0!==o?o:[],u.label=1;case 1:return t<n.length?[4,(0,n[t])(e,r)]:[3,4];case 2:u.sent(),u.label=3;case 3:return t++,[3,1];case 4:return[2]}})})})]);case 1:return c.sent(),v.set(e.type,"success"),[2]}})})},on:function(t,e){var n;d.set(t,i(i([],null!==(n=d.get(t))&&void 0!==n?n:[],!0),[e],!1))},guard:function(t,e){var n;p.set(t,i(i([],null!==(n=p.get(t))&&void 0!==n?n:[],!0),[e],!1))},store:l,getStatus:function(t){var e;return null!==(e=v.get(t))&&void 0!==e?e:"idle"}}}"function"==typeof SuppressedError&&SuppressedError;var a=e(null);function s(e){var n=e.engine,r=e.children;return t.createElement(a.Provider,{value:n},r)}function l(){var t=n(a);if(!t)throw new Error("Missing IntentProvider");return t}function f(){var t=l();return function(e){return t.emit(e)}}function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var p="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},v=t.useState,S=t.useEffect,y=t.useLayoutEffect,h=t.useDebugValue;function _(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!p(t,n)}catch(t){return!0}}var E="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=v({inst:{value:n,getSnapshot:e}}),o=r[0].inst,u=r[1];return y(function(){o.value=n,o.getSnapshot=e,_(o)&&u({inst:o})},[t,n,e]),S(function(){return _(o)&&u({inst:o}),t(function(){_(o)&&u({inst:o})})},[t]),h(n),n},O={useSyncExternalStore:void 0!==t.useSyncExternalStore?t.useSyncExternalStore:E},g=d(function(e,n){"production"!==process.env.NODE_ENV&&function(){function e(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!o(t,n)}catch(t){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=t,o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},u=r.useState,i=r.useEffect,c=r.useLayoutEffect,a=r.useDebugValue,s=!1,l=!1,f="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,n){s||void 0===r.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var f=n();if(!l){var d=n();o(f,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}var p=(d=u({inst:{value:f,getSnapshot:n}}))[0].inst,v=d[1];return c(function(){p.value=f,p.getSnapshot=n,e(p)&&v({inst:p})},[t,f,n]),i(function(){return e(p)&&v({inst:p}),t(function(){e(p)&&v({inst:p})})},[t]),a(f),f};n.useSyncExternalStore=void 0!==r.useSyncExternalStore?r.useSyncExternalStore:f,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),w=d(function(t){"production"===process.env.NODE_ENV?t.exports=O:t.exports=g});function b(t){var e=l(),n=r();return w.useSyncExternalStore(e.store.subscribe,function(){var r=t(e.store.getState());return Object.is(r,n.current)?n.current:(n.current=r,r)})}function x(t){var e=l();return w.useSyncExternalStore(function(n){return e.subscribeStatus(t,n)},function(){return e.getStatus(t)})}export{s as IntentProvider,c as createIntentEngine,l as useEngine,f as useIntent,b as useIntentState,x as useIntentStatus};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactIntentEngine={},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t,n,r){return new(n||(n=Promise))(function(o,u){function i(e){try{c(r.next(e))}catch(e){u(e)}}function a(e){try{c(r.throw(e))}catch(e){u(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,a)}c((r=r.apply(e,t||[])).next())})}function u(e,t){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=t.createContext(null);function c(){var e=t.useContext(a);if(!e)throw new Error("Missing IntentProvider");return e}function s(e){var t={exports:{}};return e(t,t.exports),t.exports}var f="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},l=r.default.useState,d=r.default.useEffect,p=r.default.useLayoutEffect,v=r.default.useDebugValue;function y(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!f(e,n)}catch(e){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=l({inst:{value:n,getSnapshot:t}}),o=r[0].inst,u=r[1];return p(function(){o.value=n,o.getSnapshot=t,y(o)&&u({inst:o})},[e,n,t]),d(function(){return y(o)&&u({inst:o}),e(function(){y(o)&&u({inst:o})})},[e]),v(n),n},S={useSyncExternalStore:void 0!==r.default.useSyncExternalStore?r.default.useSyncExternalStore:h},_=s(function(e,t){"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=r.default,o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},u=n.useState,i=n.useEffect,a=n.useLayoutEffect,c=n.useDebugValue,s=!1,f=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,r){s||void 0===n.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var l=r();if(!f){var d=r();o(l,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var p=(d=u({inst:{value:l,getSnapshot:r}}))[0].inst,v=d[1];return a(function(){p.value=l,p.getSnapshot=r,e(p)&&v({inst:p})},[t,l,r]),i(function(){return e(p)&&v({inst:p}),t(function(){e(p)&&v({inst:p})})},[t]),c(l),l};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),g=s(function(e){"production"===process.env.NODE_ENV?e.exports=S:e.exports=_});e.IntentProvider=function(e){var t=e.engine,n=e.children;return r.default.createElement(a.Provider,{value:t},n)},e.createIntentEngine=function(e){var t,n,r,a,c,s,f=(r=e.initialState,a=structuredClone(r),c=new Set,{getState:function(){return a},setState:function(e){a=e(a),c.forEach(function(e){return e()})},subscribe:function(e){return c.add(e),function(){return c.delete(e)}}}),l=null!==(t=e.effects)&&void 0!==t?t:{},d=new Map,p=new Map,v=new Map,y=(s=null!==(n=e.middleware)&&void 0!==n?n:[],function(e,t){var n=-1;return function r(i){return o(this,void 0,void 0,function(){var o;return u(this,function(u){if(i<=n)throw new Error("next() called twice");return n=i,(o=s[i])?[2,o(e,function(){return r(i+1)})]:[2,t()]})})}(0)});return{emit:function e(t){var n;return o(this,void 0,void 0,function(){var r,i=this;return u(this,function(a){switch(a.label){case 0:return r=function(e,t,n){return{get:function(t){return t.split(".").reduce(function(e,t){return null==e?void 0:e[t]},e.getState())},set:function(t,n){e.setState(function(e){for(var r,o=structuredClone(e),u=t.split("."),i=o,a=0;a<u.length-1;a++)i=i[r=u[a]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:t,effects:n}}(f,e,l),(null===(n=p.get(t.type))||void 0===n?void 0:n.some(function(e){return!e(r)}))?[2]:(v.set(t.type,"pending"),[4,y(t,function(){return o(i,void 0,void 0,function(){var e,n,o;return u(this,function(u){switch(u.label){case 0:e=0,n=null!==(o=d.get(t.type))&&void 0!==o?o:[],u.label=1;case 1:return e<n.length?[4,(0,n[e])(t,r)]:[3,4];case 2:u.sent(),u.label=3;case 3:return e++,[3,1];case 4:return[2]}})})})]);case 1:return a.sent(),v.set(t.type,"success"),[2]}})})},on:function(e,t){var n;d.set(e,i(i([],null!==(n=d.get(e))&&void 0!==n?n:[],!0),[t],!1))},guard:function(e,t){var n;p.set(e,i(i([],null!==(n=p.get(e))&&void 0!==n?n:[],!0),[t],!1))},store:f,getStatus:function(e){var t;return null!==(t=v.get(e))&&void 0!==t?t:"idle"}}},e.useEngine=c,e.useIntent=function(){var e=c();return function(t){return e.emit(t)}},e.useIntentState=function(e){var t=c();return g.useSyncExternalStore(function(n){return t.store.subscribe(e,n)},function(){return t.store.getState(e)})},e.useIntentStatus=function(e){return c().getStatus(e)},Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactIntentEngine={},e.React)}(this,function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t,n,r){return new(n||(n=Promise))(function(o,u){function i(e){try{c(r.next(e))}catch(e){u(e)}}function a(e){try{c(r.throw(e))}catch(e){u(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,a)}c((r=r.apply(e,t||[])).next())})}function u(e,t){var n,r,o,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(u=0)),u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,o=0,u=t.length;o<u;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var a=t.createContext(null);function c(){var e=t.useContext(a);if(!e)throw new Error("Missing IntentProvider");return e}function s(e){var t={exports:{}};return e(t,t.exports),t.exports}var f="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},l=r.default.useState,d=r.default.useEffect,p=r.default.useLayoutEffect,v=r.default.useDebugValue;function y(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!f(e,n)}catch(e){return!0}}var S="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),r=l({inst:{value:n,getSnapshot:t}}),o=r[0].inst,u=r[1];return p(function(){o.value=n,o.getSnapshot=t,y(o)&&u({inst:o})},[e,n,t]),d(function(){return y(o)&&u({inst:o}),e(function(){y(o)&&u({inst:o})})},[e]),v(n),n},h={useSyncExternalStore:void 0!==r.default.useSyncExternalStore?r.default.useSyncExternalStore:S},_=s(function(e,t){"production"!==process.env.NODE_ENV&&function(){function e(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=r.default,o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},u=n.useState,i=n.useEffect,a=n.useLayoutEffect,c=n.useDebugValue,s=!1,f=!1,l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(t,r){s||void 0===n.startTransition||(s=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var l=r();if(!f){var d=r();o(l,d)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}var p=(d=u({inst:{value:l,getSnapshot:r}}))[0].inst,v=d[1];return a(function(){p.value=l,p.getSnapshot=r,e(p)&&v({inst:p})},[t,l,r]),i(function(){return e(p)&&v({inst:p}),t(function(){e(p)&&v({inst:p})})},[t]),c(l),l};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:l,"undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()}),E=s(function(e){"production"===process.env.NODE_ENV?e.exports=h:e.exports=_});e.IntentProvider=function(e){var t=e.engine,n=e.children;return r.default.createElement(a.Provider,{value:t},n)},e.createIntentEngine=function(e){var t,n,r,a,c,s,f=(r=e.initialState,a=structuredClone(r),c=new Set,{getState:function(){return a},setState:function(e){a=e(a),c.forEach(function(e){return e()})},subscribe:function(e){return c.add(e),function(){return c.delete(e)}}}),l=null!==(t=e.effects)&&void 0!==t?t:{},d=new Map,p=new Map,v=new Map,y=(s=null!==(n=e.middleware)&&void 0!==n?n:[],function(e,t){var n=-1;return function r(i){return o(this,void 0,void 0,function(){var o;return u(this,function(u){if(i<=n)throw new Error("next() called twice");return n=i,(o=s[i])?[2,o(e,function(){return r(i+1)})]:[2,t()]})})}(0)});return{emit:function e(t){var n;return o(this,void 0,void 0,function(){var r,i=this;return u(this,function(a){switch(a.label){case 0:return r=function(e,t,n){return{get:function(t){return t.split(".").reduce(function(e,t){return null==e?void 0:e[t]},e.getState())},set:function(t,n){e.setState(function(e){for(var r,o=structuredClone(e),u=t.split("."),i=o,a=0;a<u.length-1;a++)i=i[r=u[a]]||(i[r]={});return i[u.at(-1)]=n,o})},emit:t,effects:n}}(f,e,l),(null===(n=p.get(t.type))||void 0===n?void 0:n.some(function(e){return!e(r)}))?[2]:(v.set(t.type,"pending"),[4,y(t,function(){return o(i,void 0,void 0,function(){var e,n,o;return u(this,function(u){switch(u.label){case 0:e=0,n=null!==(o=d.get(t.type))&&void 0!==o?o:[],u.label=1;case 1:return e<n.length?[4,(0,n[e])(t,r)]:[3,4];case 2:u.sent(),u.label=3;case 3:return e++,[3,1];case 4:return[2]}})})})]);case 1:return a.sent(),v.set(t.type,"success"),[2]}})})},on:function(e,t){var n;d.set(e,i(i([],null!==(n=d.get(e))&&void 0!==n?n:[],!0),[t],!1))},guard:function(e,t){var n;p.set(e,i(i([],null!==(n=p.get(e))&&void 0!==n?n:[],!0),[t],!1))},store:f,getStatus:function(e){var t;return null!==(t=v.get(e))&&void 0!==t?t:"idle"}}},e.useEngine=c,e.useIntent=function(){var e=c();return function(t){return e.emit(t)}},e.useIntentState=function(e){var n=c(),r=t.useRef();return E.useSyncExternalStore(n.store.subscribe,function(){var t=e(n.store.getState());return Object.is(t,r.current)?r.current:(r.current=t,t)})},e.useIntentStatus=function(e){var t=c();return E.useSyncExternalStore(function(n){return t.subscribeStatus(e,n)},function(){return t.getStatus(e)})},Object.defineProperty(e,"__esModule",{value:!0})});
@@ -1 +1 @@
1
- export declare function useIntentState<T = any>(intentType: string): T | undefined;
1
+ export declare function useIntentState<T>(selector: (state: any) => T): T;
@@ -1 +1 @@
1
- export declare function useIntentStatus(type: string): any;
1
+ export declare function useIntentStatus(intentType: string): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-intent-engine-z",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Intent-first orchestration engine for React applications",
5
5
  "license": "MIT",
6
6
  "author": "Delpi.Kye",