Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackflow/react

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackflow/react - npm Package Compare versions

Comparing version 0.16.1-alpha.30 to 0.16.1-alpha.34

2

dist/index.js

@@ -1,2 +0,2 @@

"use strict";var xt=Object.create;var h=Object.defineProperty,St=Object.defineProperties,kt=Object.getOwnPropertyDescriptor,gt=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,Tt=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var Y=(t,e,i)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,u=(t,e)=>{for(var i in e||(e={}))Z.call(e,i)&&Y(t,i,e[i]);if(X)for(var i of X(e))ht.call(e,i)&&Y(t,i,e[i]);return t},v=(t,e)=>St(t,gt(e));var Rt=(t,e)=>{for(var i in e)h(t,i,{get:e[i],enumerable:!0})},_=(t,e,i,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ct(e))!Z.call(t,a)&&a!==i&&h(t,a,{get:()=>e[a],enumerable:!(r=kt(e,a))||r.enumerable});return t};var m=(t,e,i)=>(i=t!=null?xt(Tt(t)):{},_(e||!t||!t.__esModule?h(i,"default",{value:t,enumerable:!0}):i,t)),wt=t=>_(h({},"__esModule",{value:!0}),t);var Mt={};Rt(Mt,{stackflow:()=>Ft,useActions:()=>$,useActivity:()=>Et,useActivityParams:()=>Ot,useStack:()=>It,useStepActions:()=>G});module.exports=wt(Mt);var it=require("react");var U=m(require("react"));var O=require("react"),tt=m(require("react-fast-compare"));function I(t){let e=(0,O.useRef)(t),i=e.current,r=(0,tt.default)(i,t);return(0,O.useEffect)(()=>{r||(e.current=t)}),r?i:t}var R=(0,U.createContext)(null),et=({children:t,value:e})=>U.default.createElement(R.Provider,{value:I(e)},t);var Et=()=>(0,it.useContext)(R);var ot=require("react");function Ot(){return(0,ot.useContext)(R).params}var nt=require("react");var B=m(require("react"));var V=(0,B.createContext)(null),rt=({children:t,value:e})=>B.default.createElement(V.Provider,{value:I(e)},t);var It=()=>(0,nt.useContext)(V);var C=require("@stackflow/core"),l=m(require("react"));var at=require("@stackflow/core");function d(){return(0,at.id)()}var st=require("@stackflow/core");function k(){return(0,st.id)()}var P=m(require("react")),pt=require("use-sync-external-store/shim"),q=(0,P.createContext)(null),W=(0,P.createContext)(null),ct,Ut=(ct=P.default.useDeferredValue)!=null?ct:t=>t,ut=({coreStore:t,children:e})=>{let i=(0,pt.useSyncExternalStore)(t.subscribe,t.actions.getStack,t.actions.getStack),r=Ut(i);return P.default.createElement(W.Provider,{value:r},P.default.createElement(q.Provider,{value:t.actions},e))};var mt=m(require("react"));var b=()=>mt.default.useContext(q);var lt=m(require("react"));var D=()=>lt.default.useContext(W);var g=m(require("react"));var w=m(require("react"));var N=m(require("react")),j=(0,N.createContext)(null),ft=({children:t,value:e})=>N.default.createElement(j.Provider,{value:e},t);var vt=require("react");function F(){return(0,vt.useContext)(j)}var Bt=({activities:t,plugin:e})=>{let i=D(),r=F();return e.render({stack:v(u({},i),{render(a){let c=u(u({},i),a);return{activities:c.activities.map(o=>v(u({},o),{key:o.id,render(f){let E=t[o.name],A;if("component"in E){let{component:y}=E;A=w.default.createElement(y,{params:o.params})}else A=w.default.createElement(E,{params:o.params});return r.forEach(y=>{var n,s;A=(s=(n=y.wrapActivity)==null?void 0:n.call(y,{activity:v(u({},o),{render:()=>A})}))!=null?s:A}),w.default.createElement(rt,{value:c},w.default.createElement(et,{key:o.id,value:u(u({},o),f)},A))}}))}}})})},dt=Bt;var bt=({activities:t})=>{let e=D(),i=F(),r=i.filter(c=>!!c.render);(0,g.useEffect)(()=>{r.length===0&&console.warn(`Stackflow - There is no rendering plugin, so "<Stack />" doesn't render anything. If you want to render some UI, use "@stackflow/plugin-renderer-basic" or add another rendering plugin.`)},[r]);let a=g.default.createElement(g.default.Fragment,null,r.map(c=>g.default.createElement(dt,{key:c.key,activities:t,plugin:c})));return i.forEach(c=>{var o,f;a=(f=(o=c.wrapStack)==null?void 0:o.call(c,{stack:v(u({},e),{render(){return a}})}))!=null?f:a}),a},yt=bt;var M=m(require("react"));function z(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}var At,Dt=(At=M.default.useTransition)!=null?At:()=>[!1,t=>t()];function $(){let t=b(),[e,i]=Dt();return(0,M.useMemo)(()=>({pending:e,push(r,a,c){let o=d();return t.push({activityId:o,activityName:r,activityParams:a,skipEnterActiveState:z(c).skipActiveState}),{activityId:o}},replace(r,a,c){var f;let o=d();return t.replace({activityId:(f=c==null?void 0:c.activityId)!=null?f:d(),activityName:r,activityParams:a,skipEnterActiveState:z(c).skipActiveState}),{activityId:o}},pop(r){t.pop({skipExitActiveState:z(r).skipActiveState})}}),[t.push,t.replace,t.pop,e,i])}var K=m(require("react"));var Pt,Nt=(Pt=K.default.useTransition)!=null?Pt:()=>[!1,t=>t()],G=()=>{let t=b(),[e,i]=Nt();return(0,K.useMemo)(()=>({pending:e,stepPush(r){let a=k();t.stepPush({stepId:a,stepParams:r})},stepReplace(r){let a=k();t.stepReplace({stepId:a,stepParams:r})},stepPop(){t.stepPop({})}}),[t.stepPush,t.stepReplace,t.stepPop,e,i])};function H(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}function Ft(t){var y;let e=((y=t.plugins)!=null?y:[]).flat(1/0).map(n=>n),i=e.map(n=>n()),r=new Date().getTime()-t.transitionDuration,a=(0,C.makeEvent)("Initialized",{transitionDuration:t.transitionDuration,eventDate:r}),c=Object.entries(t.activities).map(([n,s])=>(0,C.makeEvent)("ActivityRegistered",u({activityName:n,eventDate:r},"component"in s?{activityParamsSchema:s.paramsSchema}:null))),o=(0,C.createCoreStore)({initialEvents:[a,...c],plugins:e}),f=Object.entries(t.activities).reduce((n,[s,p])=>"component"in p?v(u({},n),{[s]:{paramsSchema:p.paramsSchema,component:p.component}}):v(u({},n),{[s]:l.default.memo(p)}),{});return typeof window!="undefined"&&window.document.documentElement.style.setProperty("--stackflow-transition-duration",`${t.transitionDuration}ms`),{Stack:n=>{let s=(0,l.useMemo)(()=>t.initialActivity?[(0,C.makeEvent)("Pushed",{activityId:d(),activityName:t.initialActivity(),activityParams:{},eventDate:r,skipEnterActiveState:!1})]:[],[]),p=(0,l.useMemo)(()=>i.reduce((T,S)=>{var J,L,Q;return(Q=(L=S.overrideInitialEvents)==null?void 0:L.call(S,{initialEvents:T,initialContext:(J=n.initialContext)!=null?J:{}}))!=null?Q:T},s),[]);(0,l.useMemo)(()=>{o.setInitialEvents([a,...c,...p])},[]);let x=p.length>0&&s.length>0&&p!==s;return(0,l.useEffect)(()=>{x&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${s[0].activityName}" in the "stackflow" is ignored.`),p.length===0&&console.warn("Stackflow - There is no initial activity. If you want to set the initial activity, add the `initialActivity` option of the `stackflow()` function or add a plugin that sets the initial activity. (e.g. `@stackflow/plugin-history-sync`)")},[]),(0,l.useEffect)(()=>{o.start()},[]),l.default.createElement(ft,{value:i},l.default.createElement(ut,{coreStore:o},l.default.createElement(yt,{activities:f})))},useFlow:$,useStepFlow:G,actions:{dispatchEvent(n,s){return o.actions.dispatchEvent(n,s)},getStack(){return o.actions.getStack()},push(n,s,p){let x=d();return o.actions.push({activityId:x,activityName:n,activityParams:s,skipEnterActiveState:H(p).skipActiveState}),{activityId:x}},replace(n,s,p){var T,S;let x=(T=p==null?void 0:p.activityId)!=null?T:d();return o.actions.replace({activityId:(S=p==null?void 0:p.activityId)!=null?S:d(),activityName:n,activityParams:s,skipEnterActiveState:H(p).skipActiveState}),{activityId:x}},pop(n){return o.actions.pop({skipExitActiveState:H(n).skipActiveState})},stepPush(n){let s=k();return o.actions.stepPush({stepId:s,stepParams:n})},stepReplace(n){let s=k();return o.actions.stepReplace({stepId:s,stepParams:n})},stepPop(){return o.actions.stepPop({})}},activities:t.activities}}
"use strict";var kt=Object.create;var R=Object.defineProperty,gt=Object.defineProperties,Ct=Object.getOwnPropertyDescriptor,Tt=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertyNames,Z=Object.getOwnPropertySymbols,Rt=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var _=(t,e,i)=>e in t?R(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,m=(t,e)=>{for(var i in e||(e={}))tt.call(e,i)&&_(t,i,e[i]);if(Z)for(var i of Z(e))wt.call(e,i)&&_(t,i,e[i]);return t},v=(t,e)=>gt(t,Tt(e));var Et=(t,e)=>{for(var i in e)R(t,i,{get:e[i],enumerable:!0})},et=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ht(e))!tt.call(t,s)&&s!==i&&R(t,s,{get:()=>e[s],enumerable:!(n=Ct(e,s))||n.enumerable});return t};var f=(t,e,i)=>(i=t!=null?kt(Rt(t)):{},et(e||!t||!t.__esModule?R(i,"default",{value:t,enumerable:!0}):i,t)),Ot=t=>et(R({},"__esModule",{value:!0}),t);var Vt={};Et(Vt,{stackflow:()=>Kt,useActions:()=>H,useActivity:()=>It,useActivityParams:()=>Ut,useStack:()=>Bt,useStepActions:()=>J});module.exports=Ot(Vt);var rt=require("react");var B=f(require("react"));var I=require("react"),it=f(require("react-fast-compare"));function U(t){let e=(0,I.useRef)(t),i=e.current,n=(0,it.default)(i,t);return(0,I.useEffect)(()=>{n||(e.current=t)}),n?i:t}var w=(0,B.createContext)(null),ot=({children:t,value:e})=>B.default.createElement(w.Provider,{value:U(e)},t);var It=()=>(0,rt.useContext)(w);var nt=require("react");function Ut(){return(0,nt.useContext)(w).params}var st=require("react");var b=f(require("react"));var W=(0,b.createContext)(null),at=({children:t,value:e})=>b.default.createElement(W.Provider,{value:U(e)},t);var Bt=()=>(0,st.useContext)(W);var P=require("@stackflow/core"),y=f(require("react"));var ct=require("@stackflow/core");function d(){return(0,ct.id)()}var pt=require("@stackflow/core");function g(){return(0,pt.id)()}var x=f(require("react")),mt=require("use-sync-external-store/shim"),j=(0,x.createContext)(null),z=(0,x.createContext)(null),ut,bt=(ut=x.default.useDeferredValue)!=null?ut:t=>t,lt=({coreStore:t,children:e})=>{let i=(0,mt.useSyncExternalStore)(t.subscribe,t.actions.getStack,t.actions.getStack),n=bt(i);return x.default.createElement(z.Provider,{value:n},x.default.createElement(j.Provider,{value:t.actions},e))};var ft=f(require("react"));var D=()=>ft.default.useContext(j);var vt=f(require("react"));var N=()=>vt.default.useContext(z);var C=f(require("react"));var E=f(require("react"));var F=f(require("react")),$=(0,F.createContext)(null),dt=({children:t,value:e})=>F.default.createElement($.Provider,{value:e},t);var yt=require("react");function M(){return(0,yt.useContext)($)}var Dt=({activities:t,plugin:e})=>{let i=N(),n=M();return e.render({stack:v(m({},i),{render(s){let c=m(m({},i),s);return{activities:c.activities.map(p=>v(m({},p),{key:p.id,render(u){let O=t[p.name],S;if("component"in O){let{component:A}=O;S=E.default.createElement(A,{params:p.params})}else S=E.default.createElement(O,{params:p.params});return n.forEach(A=>{var o,a;S=(a=(o=A.wrapActivity)==null?void 0:o.call(A,{activity:v(m({},p),{render:()=>S})}))!=null?a:S}),E.default.createElement(at,{value:c},E.default.createElement(ot,{key:p.id,value:m(m({},p),u)},S))}}))}}})})},At=Dt;var Nt=({activities:t})=>{let e=N(),i=M(),n=i.filter(c=>!!c.render);(0,C.useEffect)(()=>{n.length===0&&console.warn(`Stackflow - There is no rendering plugin, so "<Stack />" doesn't render anything. If you want to render some UI, use "@stackflow/plugin-renderer-basic" or add another rendering plugin.`)},[n]);let s=C.default.createElement(C.default.Fragment,null,n.map(c=>C.default.createElement(At,{key:c.key,activities:t,plugin:c})));return i.forEach(c=>{var p,u;s=(u=(p=c.wrapStack)==null?void 0:p.call(c,{stack:v(m({},e),{render(){return s}})}))!=null?u:s}),s},Pt=Nt;var K=f(require("react"));function G(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}var St,Ft=(St=K.default.useTransition)!=null?St:()=>[!1,t=>t()];function H(){let t=D(),[e,i]=Ft();return(0,K.useMemo)(()=>({pending:e,push(n,s,c){let p=d();return t.push({activityId:p,activityName:n,activityParams:s,skipEnterActiveState:G(c).skipActiveState}),{activityId:p}},replace(n,s,c){var u;let p=d();return t.replace({activityId:(u=c==null?void 0:c.activityId)!=null?u:d(),activityName:n,activityParams:s,skipEnterActiveState:G(c).skipActiveState}),{activityId:p}},pop(n){t.pop({skipExitActiveState:G(n).skipActiveState})}}),[t.push,t.replace,t.pop,e,i])}var V=f(require("react"));var xt,Mt=(xt=V.default.useTransition)!=null?xt:()=>[!1,t=>t()],J=()=>{let t=D(),[e,i]=Mt();return(0,V.useMemo)(()=>({pending:e,stepPush(n){let s=g();t.stepPush({stepId:s,stepParams:n})},stepReplace(n){let s=g();t.stepReplace({stepId:s,stepParams:n})},stepPop(){t.stepPop({})}}),[t.stepPush,t.stepReplace,t.stepPop,e,i])};function L(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}function Kt(t){var A;let e=((A=t.plugins)!=null?A:[]).flat(1/0).map(o=>o),i=e.map(o=>o()),n=Object.entries(t.activities).reduce((o,[a,r])=>"component"in r?v(m({},o),{[a]:{paramsSchema:r.paramsSchema,component:r.component}}):v(m({},o),{[a]:y.default.memo(r)}),{}),s=()=>new Date().getTime()-t.transitionDuration,c=()=>{let o=(0,P.makeEvent)("Initialized",{transitionDuration:t.transitionDuration,eventDate:s()}),a=Object.entries(n).map(([r,l])=>(0,P.makeEvent)("ActivityRegistered",m({activityName:r,eventDate:s()},"component"in l?{activityParamsSchema:l.paramsSchema}:null)));return[o,...a]},p=(0,P.aggregate)(c(),new Date().getTime()),u={value:null};return typeof window!="undefined"&&window.document.documentElement.style.setProperty("--stackflow-transition-duration",`${t.transitionDuration}ms`),{Stack:o=>{let a=(0,y.useMemo)(()=>{let r=t.initialActivity?[(0,P.makeEvent)("Pushed",{activityId:d(),activityName:t.initialActivity(),activityParams:{},eventDate:s(),skipEnterActiveState:!1})]:[],l=i.reduce((h,q)=>{var Q,X,Y;return(Y=(X=q.overrideInitialEvents)==null?void 0:X.call(q,{initialEvents:h,initialContext:(Q=o.initialContext)!=null?Q:{}}))!=null?Y:h},r);l.length>0&&r.length>0&&l!==r&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${r[0].activityName}" in the "stackflow" is ignored.`),l.length===0&&console.warn("Stackflow - There is no initial activity. If you want to set the initial activity, add the `initialActivity` option of the `stackflow()` function or add a plugin that sets the initial activity. (e.g. `@stackflow/plugin-history-sync`)");let T=(0,P.createCoreStore)({initialEvents:[...c(),...l],plugins:e});return u.value=T,T},[]);return(0,y.useEffect)(()=>{a.init()},[a]),y.default.createElement(dt,{value:i},y.default.createElement(lt,{coreStore:a},y.default.createElement(Pt,{activities:n})))},useFlow:H,useStepFlow:J,actions:{dispatchEvent(o,a){var r;return(r=u.value)==null?void 0:r.actions.dispatchEvent(o,a)},getStack(){var o,a;return(a=(o=u.value)==null?void 0:o.actions.getStack())!=null?a:p},push(o,a,r){var k;let l=d();return(k=u.value)==null||k.actions.push({activityId:l,activityName:o,activityParams:a,skipEnterActiveState:L(r).skipActiveState}),{activityId:l}},replace(o,a,r){var k,T,h;let l=(k=r==null?void 0:r.activityId)!=null?k:d();return(h=u.value)==null||h.actions.replace({activityId:(T=r==null?void 0:r.activityId)!=null?T:d(),activityName:o,activityParams:a,skipEnterActiveState:L(r).skipActiveState}),{activityId:l}},pop(o){var a;return(a=u.value)==null?void 0:a.actions.pop({skipExitActiveState:L(o).skipActiveState})},stepPush(o){var r;let a=g();return(r=u.value)==null?void 0:r.actions.stepPush({stepId:a,stepParams:o})},stepReplace(o){var r;let a=g();return(r=u.value)==null?void 0:r.actions.stepReplace({stepId:a,stepParams:o})},stepPop(){var o;return(o=u.value)==null?void 0:o.actions.stepPop({})}},activities:n}}
//# sourceMappingURL=index.js.map
{
"name": "@stackflow/react",
"version": "0.16.1-alpha.30+38ae3d02",
"version": "0.16.1-alpha.34+118e2bdb",
"license": "MIT",

@@ -31,3 +31,3 @@ "exports": {

"devDependencies": {
"@stackflow/core": "^0.16.1-alpha.30+38ae3d02",
"@stackflow/core": "^0.16.1-alpha.34+118e2bdb",
"@stackflow/esbuild-config": "^0.16.0",

@@ -67,3 +67,3 @@ "@stackflow/eslint-config": "^0.16.0",

},
"gitHead": "38ae3d02dbf6ee33e349bc85d6a46f9e7f350402"
"gitHead": "118e2bdb6197a7c73654fc1f9d23fa0dd3d2c744"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc