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.25 to 0.16.1-alpha.30

2

dist/index.js

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

"use strict";var Pt=Object.create;var h=Object.defineProperty,St=Object.defineProperties,xt=Object.getOwnPropertyDescriptor,kt=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,Ct=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty,Tt=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))Tt.call(e,i)&&Y(t,i,e[i]);return t},d=(t,e)=>St(t,kt(e));var ht=(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 s of gt(e))!Z.call(t,s)&&s!==i&&h(t,s,{get:()=>e[s],enumerable:!(r=xt(e,s))||r.enumerable});return t};var m=(t,e,i)=>(i=t!=null?Pt(Ct(t)):{},_(e||!t||!t.__esModule?h(i,"default",{value:t,enumerable:!0}):i,t)),Rt=t=>_(h({},"__esModule",{value:!0}),t);var Dt={};ht(Dt,{stackflow:()=>Nt,useActions:()=>$,useActivity:()=>wt,useActivityParams:()=>Et,useStack:()=>Ot,useStepActions:()=>G});module.exports=Rt(Dt);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 wt=()=>(0,it.useContext)(R);var ot=require("react");function Et(){return(0,ot.useContext)(R).params}var nt=require("react");var B=m(require("react"));var q=(0,B.createContext)(null),rt=({children:t,value:e})=>B.default.createElement(q.Provider,{value:I(e)},t);var Ot=()=>(0,nt.useContext)(q);var T=require("@stackflow/core"),l=m(require("react"));var at=require("@stackflow/core");function y(){return(0,at.id)()}var st=require("@stackflow/core");function g(){return(0,st.id)()}var f=m(require("react")),W=(0,f.createContext)(null),z=(0,f.createContext)(null),ct,It=(ct=f.default.startTransition)!=null?ct:t=>t(),pt=({coreStore:t,children:e})=>{let[i,r]=(0,f.useState)(t.actions.getStack());return(0,f.useEffect)(()=>t.subscribe(()=>{It(()=>{r(t.actions.getStack())})}),[]),f.default.createElement(z.Provider,{value:i},f.default.createElement(W.Provider,{value:t.actions},e))};var ut=m(require("react"));var b=()=>ut.default.useContext(W);var mt=m(require("react"));var F=()=>mt.default.useContext(z);var C=m(require("react"));var w=m(require("react"));var N=m(require("react")),V=(0,N.createContext)(null),lt=({children:t,value:e})=>N.default.createElement(V.Provider,{value:e},t);var ft=require("react");function D(){return(0,ft.useContext)(V)}var Ut=({activities:t,plugin:e})=>{let i=F(),r=D();return e.render({stack:d(u({},i),{render(s){let c=u(u({},i),s);return{activities:c.activities.map(o=>d(u({},o),{key:o.id,render(v){let E=t[o.name],S;if("component"in E){let{component:A}=E;S=w.default.createElement(A,{params:o.params})}else S=w.default.createElement(E,{params:o.params});return r.forEach(A=>{var n,a;S=(a=(n=A.wrapActivity)==null?void 0:n.call(A,{activity:d(u({},o),{render:()=>S})}))!=null?a:S}),w.default.createElement(rt,{value:c},w.default.createElement(et,{key:o.id,value:u(u({},o),v)},S))}}))}}})})},vt=Ut;var Bt=({activities:t})=>{let e=F(),i=D(),r=i.filter(c=>!!c.render);(0,C.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 s=C.default.createElement(C.default.Fragment,null,r.map(c=>C.default.createElement(vt,{key:c.key,activities:t,plugin:c})));return i.forEach(c=>{var o,v;s=(v=(o=c.wrapStack)==null?void 0:o.call(c,{stack:d(u({},e),{render(){return s}})}))!=null?v:s}),s},dt=Bt;var M=m(require("react"));function j(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}var yt,bt=(yt=M.default.useTransition)!=null?yt:()=>[!1,t=>t()];function $(){let t=b(),[e,i]=bt();return(0,M.useMemo)(()=>({pending:e,push(r,s,c){let o=y();return t.push({activityId:o,activityName:r,activityParams:s,skipEnterActiveState:j(c).skipActiveState}),{activityId:o}},replace(r,s,c){var v;let o=y();return t.replace({activityId:(v=c==null?void 0:c.activityId)!=null?v:y(),activityName:r,activityParams:s,skipEnterActiveState:j(c).skipActiveState}),{activityId:o}},pop(r){t.pop({skipExitActiveState:j(r).skipActiveState})}}),[t.push,t.replace,t.pop,e,i])}var K=m(require("react"));var At,Ft=(At=K.default.useTransition)!=null?At:()=>[!1,t=>t()],G=()=>{let t=b(),[e,i]=Ft();return(0,K.useMemo)(()=>({pending:e,stepPush(r){let s=g();t.stepPush({stepId:s,stepParams:r})},stepReplace(r){let s=g();t.stepReplace({stepId:s,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 Nt(t){var A;let e=((A=t.plugins)!=null?A:[]).flat(1/0).map(n=>n),i=e.map(n=>n()),r=new Date().getTime()-t.transitionDuration,s=(0,T.makeEvent)("Initialized",{transitionDuration:t.transitionDuration,eventDate:r}),c=Object.entries(t.activities).map(([n,a])=>(0,T.makeEvent)("ActivityRegistered",u({activityName:n,eventDate:r},"component"in a?{activityParamsSchema:a.paramsSchema}:null))),o=(0,T.createCoreStore)({initialEvents:[s,...c],plugins:e}),v=Object.entries(t.activities).reduce((n,[a,p])=>"component"in p?d(u({},n),{[a]:{paramsSchema:p.paramsSchema,component:p.component}}):d(u({},n),{[a]:l.default.memo(p)}),{});return typeof window!="undefined"&&window.document.documentElement.style.setProperty("--stackflow-transition-duration",`${t.transitionDuration}ms`),{Stack:n=>{let a=(0,l.useMemo)(()=>t.initialActivity?[(0,T.makeEvent)("Pushed",{activityId:y(),activityName:t.initialActivity(),activityParams:{},eventDate:r,skipEnterActiveState:!1})]:[],[]),p=(0,l.useMemo)(()=>i.reduce((P,k)=>{var J,L,Q;return(Q=(L=k.overrideInitialEvents)==null?void 0:L.call(k,{initialEvents:P,initialContext:(J=n.initialContext)!=null?J:{}}))!=null?Q:P},a),[]);(0,l.useMemo)(()=>{p.forEach(P=>{o.actions.dispatchEvent(P.name,P)})},[]);let x=p.length>0&&a.length>0&&p!==a;return(0,l.useEffect)(()=>{x&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${a[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.initialize()},[]),l.default.createElement(lt,{value:i},l.default.createElement(pt,{coreStore:o},l.default.createElement(dt,{activities:v})))},useFlow:$,useStepFlow:G,actions:{dispatchEvent(n,a){return o.actions.dispatchEvent(n,a)},getStack(){return o.actions.getStack()},push(n,a,p){let x=y();return o.actions.push({activityId:x,activityName:n,activityParams:a,skipEnterActiveState:H(p).skipActiveState}),{activityId:x}},replace(n,a,p){var P,k;let x=(P=p==null?void 0:p.activityId)!=null?P:y();return o.actions.replace({activityId:(k=p==null?void 0:p.activityId)!=null?k:y(),activityName:n,activityParams:a,skipEnterActiveState:H(p).skipActiveState}),{activityId:x}},pop(n){return o.actions.pop({skipExitActiveState:H(n).skipActiveState})},stepPush(n){let a=g();return o.actions.stepPush({stepId:a,stepParams:n})},stepReplace(n){let a=g();return o.actions.stepReplace({stepId:a,stepParams:n})},stepPop(){return o.actions.stepPop({})}}}}
"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}}
//# sourceMappingURL=index.js.map

@@ -47,2 +47,6 @@ import type { StackflowActions } from "@stackflow/core";

actions: Pick<StackflowActions, "dispatchEvent" | "getStack"> & Pick<UseActionsOutputType<T>, "push" | "pop" | "replace"> & Pick<UseStepActionsOutputType<{}>, "stepPush" | "stepReplace" | "stepPop">;
/**
* Return activities
*/
activities: T;
};

@@ -49,0 +53,0 @@ /**

{
"name": "@stackflow/react",
"version": "0.16.1-alpha.25+aefbbff0",
"version": "0.16.1-alpha.30+38ae3d02",
"license": "MIT",

@@ -27,9 +27,11 @@ "exports": {

"dependencies": {
"react-fast-compare": "^3.2.0"
"react-fast-compare": "^3.2.0",
"use-sync-external-store": "^1.2.0"
},
"devDependencies": {
"@stackflow/core": "^0.16.0",
"@stackflow/core": "^0.16.1-alpha.30+38ae3d02",
"@stackflow/esbuild-config": "^0.16.0",
"@stackflow/eslint-config": "^0.16.0",
"@types/react": "^18.0.9",
"@types/use-sync-external-store": "^0.0.3",
"@typescript-eslint/eslint-plugin": "^5.32.0",

@@ -65,3 +67,3 @@ "@typescript-eslint/parser": "^5.20.0",

},
"gitHead": "aefbbff04966f43c6bba7e9df5f2773d6fde02e7"
"gitHead": "38ae3d02dbf6ee33e349bc85d6a46f9e7f350402"
}

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

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