@stackflow/react
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -1,2 +0,2 @@ | ||
import React from "react"; | ||
import type React from "react"; | ||
export declare type ActivityComponentType<T extends { | ||
@@ -3,0 +3,0 @@ [K in keyof T]: string | undefined; |
/// <reference types="react" /> | ||
import { Activity } from "@stackflow/core"; | ||
import type { Activity } from "@stackflow/core"; | ||
export declare const ActivityContext: import("react").Context<Activity>; |
@@ -1,2 +0,2 @@ | ||
import { Activity } from "@stackflow/core"; | ||
import type { Activity } from "@stackflow/core"; | ||
import React from "react"; | ||
@@ -3,0 +3,0 @@ interface ActivityProviderProps { |
@@ -1,4 +0,4 @@ | ||
import { ActivityComponentType } from "./activity"; | ||
import type { ActivityComponentType } from "./activity"; | ||
export declare type BaseActivities = { | ||
[activityName: string]: ActivityComponentType<any>; | ||
}; |
/// <reference types="react" /> | ||
import { AggregateOutput, DispatchEvent } from "@stackflow/core"; | ||
import type { AggregateOutput, DispatchEvent } from "@stackflow/core"; | ||
export interface CoreActionsContextValue { | ||
@@ -4,0 +4,0 @@ getStack: () => AggregateOutput; |
import React from "react"; | ||
import { BaseActivities } from "../BaseActivities"; | ||
import type { BaseActivities } from "../BaseActivities"; | ||
export interface CoreProviderProps { | ||
@@ -4,0 +4,0 @@ activities: BaseActivities; |
/// <reference types="react" /> | ||
import { AggregateOutput } from "@stackflow/core"; | ||
import type { AggregateOutput } from "@stackflow/core"; | ||
export declare const CoreStateContext: import("react").Context<AggregateOutput>; |
@@ -1,3 +0,3 @@ | ||
import { PoppedEvent, PushedEvent, ReplacedEvent } from "@stackflow/core/dist/event-types"; | ||
import { BaseDomainEvent } from "@stackflow/core/dist/event-types/_base"; | ||
import type { PoppedEvent, PushedEvent, ReplacedEvent } from "@stackflow/core/dist/event-types"; | ||
import type { BaseDomainEvent } from "@stackflow/core/dist/event-types/_base"; | ||
export declare const useCoreActions: () => { | ||
@@ -4,0 +4,0 @@ dispatchEvent: import("@stackflow/core").DispatchEvent; |
@@ -1,3 +0,3 @@ | ||
import React from "react"; | ||
import type React from "react"; | ||
declare const EffectManager: React.FC; | ||
export default EffectManager; |
@@ -1,2 +0,2 @@ | ||
var Bt=Object.create;var O=Object.defineProperty,Nt=Object.defineProperties,Mt=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,Ht=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Y=(t,e,o)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,p=(t,e)=>{for(var o in e||(e={}))Z.call(e,o)&&Y(t,o,e[o]);if(X)for(var o of X(e))Vt.call(e,o)&&Y(t,o,e[o]);return t},A=(t,e)=>Nt(t,Ft(e));var qt=(t,e)=>{for(var o in e)O(t,o,{get:e[o],enumerable:!0})},tt=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ut(e))!Z.call(t,s)&&s!==o&&O(t,s,{get:()=>e[s],enumerable:!(i=Mt(e,s))||i.enumerable});return t};var l=(t,e,o)=>(o=t!=null?Bt(Ht(t)):{},tt(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t)),Kt=t=>tt(O({},"__esModule",{value:!0}),t);var Zt={};qt(Zt,{stackflow:()=>Yt,useActions:()=>J,useActivity:()=>Gt,useActivityParams:()=>Lt,useActivityPreloadRef:()=>Wt,useInitContext:()=>b,useStack:()=>_t});module.exports=Kt(Zt);var ot=require("react");var et=require("react"),g=(0,et.createContext)(null);var Gt=()=>(0,ot.useContext)(g);var rt=require("react");function Lt(){return(0,rt.useContext)(g).params}var it=require("react");function Wt(){return(0,it.useContext)(g).preloadRef}var at=l(require("react"));var nt=require("react"),M=(0,nt.createContext)({});function b(){return at.default.useContext(M)}var ct=require("react");var st=require("react"),F=(0,st.createContext)(null);var _t=()=>(0,ct.useContext)(F);var S=l(require("react"));var k=require("@stackflow/core"),v=l(require("react")),kt=l(require("react-fast-compare"));var pt=l(require("react"));var U=require("react"),mt=l(require("react-fast-compare"));function H(t){let e=(0,U.useRef)(t),o=e.current,i=(0,mt.default)(o,t);return(0,U.useEffect)(()=>{i||(e.current=t)}),i?o:t}var ft=({children:t,value:e})=>pt.default.createElement(g.Provider,{value:H(e)},t);var ut=require("@stackflow/core");function B(){return(0,ut.id)()}var vt=l(require("react"));var dt=({children:t,value:e})=>vt.default.createElement(M.Provider,{value:e},t);var lt=require("react"),V=(0,lt.createContext)(null);var xt=l(require("react"));var Pt=({children:t,value:e})=>xt.default.createElement(V.Provider,{value:e},t);var Ct=require("react");function y(){return(0,Ct.useContext)(V)}var At=require("react"),q=(0,At.createContext)(null);var yt=require("react"),K=(0,yt.createContext)(null);var jt=1e3,Jt=jt/60,Et=({transitionDuration:t,initialActivity:e,activities:o,children:i})=>{let s=y(),m=b(),n=(0,v.useMemo)(()=>{let C=new Date().getTime()-t,f=e?(0,k.makeEvent)("Pushed",{activityId:B(),activityName:e({initContext:m}),params:{},eventDate:C,skipEnterActiveState:!1}):null,P=s.reduce((N,_)=>{var $,Q;return(Q=($=_.overrideInitialPushedEvent)==null?void 0:$.call(_,{pushedEvent:N}))!=null?Q:N},f);!!P&&!!f&&P.id!==f.id&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${f.activityName}" in the "stackflow" is ignored.`);let w=P;w||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 bt=Object.keys(o).map(N=>(0,k.makeEvent)("ActivityRegistered",{activityName:N,eventDate:C})),z=[(0,k.makeEvent)("Initialized",{transitionDuration:t,eventDate:C}),...bt];return w&&z.push(w),z},[]),c=(0,v.useMemo)(()=>(0,k.aggregate)(n,new Date().getTime()),[]),[a,r]=(0,v.useState)(()=>c),u=(0,v.useRef)(n),d=(0,v.useRef)(c),x=(0,v.useCallback)(()=>d.current,[d]),R=(0,v.useCallback)((C,f)=>{let P=(0,k.makeEvent)(C,f),T=[...u.current,P];u.current=T,r((0,k.aggregate)(T,new Date().getTime()))},[u,r]);return(0,v.useEffect)(()=>{let C=setInterval(()=>{let f=u.current,P=(0,k.aggregate)(f,new Date().getTime());(0,kt.default)(a,P)||(r(P),d.current=P),P.globalTransitionState==="idle"&&clearInterval(C)},Jt);return()=>{clearInterval(C)}},[u,a,r]),v.default.createElement(K.Provider,{value:a},v.default.createElement(q.Provider,{value:(0,v.useMemo)(()=>({getStack:x,dispatchEvent:R}),[x,R])},i))};var E=l(require("react"));var St=t=>JSON.parse(JSON.stringify(t)),G=()=>{let t=y(),e=b(),{dispatchEvent:o,getStack:i}=E.default.useContext(q),s=(0,E.useCallback)(r=>{let{isPrevented:u,params:d}=a("PUSHED",r);u||o("Pushed",p({},d))},[o]),m=(0,E.useCallback)(r=>{let{isPrevented:u,params:d}=a("REPLACED",r);u||o("Replaced",p({},d))},[o]),n=(0,E.useCallback)(r=>{let u=r!=null?r:{},{isPrevented:d,params:x}=a("POPPED",u);d||o("Popped",p({},x))},[o]),c=(0,E.useMemo)(()=>({dispatchEvent:o,getStack:i,push:s,replace:m,pop:n}),[o,i,s,m,n]),a=(0,E.useCallback)((r,u)=>{let d=!1,x=St(u),R=()=>{d=!0},C=f=>{x=St(f)};return t.forEach(f=>{var P,T,w;switch(r){case"PUSHED":(P=f.onBeforePush)==null||P.call(f,{actionParams:x,actions:A(p({},c),{preventDefault:R,overrideActionParams:C})});break;case"REPLACED":(T=f.onBeforeReplace)==null||T.call(f,{actionParams:x,actions:A(p({},c),{preventDefault:R,overrideActionParams:C})});break;case"POPPED":(w=f.onBeforePop)==null||w.call(f,{actionParams:x,actions:A(p({},c),{preventDefault:R,overrideActionParams:C})});break;default:break}}),{isPrevented:d,params:x}},[t,e]);return c};var gt=l(require("react"));var D=()=>gt.default.useContext(K);var ht=require("@stackflow/core"),h=require("react");var zt=()=>{let t=y(),e=D(),o=G(),i=(0,h.useCallback)(n=>{t.forEach(c=>{var a;(a=c.onInit)==null||a.call(c,n)})},[]),s=(0,h.useCallback)(({actions:n,effect:c})=>{switch(c._TAG){case"PUSHED":{t.forEach(a=>{var r;return(r=a.onPushed)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"POPPED":{t.forEach(a=>{var r;return(r=a.onPopped)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"REPLACED":{t.forEach(a=>{var r;return(r=a.onReplaced)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"%SOMETHING_CHANGED%":{t.forEach(a=>{var r;return(r=a.onChanged)==null?void 0:r.call(a,{actions:n,effect:c})});break}default:break}},[]);(0,h.useEffect)(()=>{i==null||i({actions:o})},[]);let m=(0,h.useRef)(e);return(0,h.useEffect)(()=>{let n=m.current;(n?(0,ht.produceEffects)(n,e):[]).forEach(a=>{s({actions:o,effect:a})}),m.current=p({},e)},[e]),null},Rt=zt;var I=l(require("react"));var L=l(require("react"));var Tt=l(require("react"));var wt=({children:t,value:e})=>Tt.default.createElement(F.Provider,{value:H(e)},t);var $t=({activities:t,plugin:e})=>{let o=D(),i=y();return e.render({stack:A(p({},o),{render(s){let m=p(p({},o),s);return{activities:m.activities.map(n=>A(p({},n),{key:n.id,render(c){let a=t[n.name],r=L.default.createElement(a,{params:n.params});return i.forEach(u=>{var d,x;r=(x=(d=u.wrapActivity)==null?void 0:d.call(u,{activity:A(p({},n),{render:()=>r})}))!=null?x:r}),L.default.createElement(wt,{value:m},L.default.createElement(ft,{key:n.id,value:p(p({},n),c)},r))}}))}}})})},Dt=$t;var Qt=({activities:t})=>{let e=D(),o=y(),i=o.filter(m=>!!m.render);(0,I.useEffect)(()=>{i.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.`)},[i]);let s=I.default.createElement(I.default.Fragment,null,i.map(m=>I.default.createElement(Dt,{activities:t,key:m.key,plugin:m})));return o.forEach(m=>{var n,c;s=(c=(n=m.wrapStack)==null?void 0:n.call(m,{stack:A(p({},e),{render(){return s}})}))!=null?c:s}),s},It=Qt;var W=l(require("react"));function j(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}var Ot,Xt=(Ot=W.default.useTransition)!=null?Ot:()=>[!1,t=>t()];function J(){let t=G(),[e,o]=Xt();return(0,W.useMemo)(()=>({pending:e,push(i,s,m){e||o(()=>{t.push({activityId:B(),activityName:i,params:s,skipEnterActiveState:j(m).skipActiveState})})},replace(i,s,m){e||o(()=>{t.replace({activityId:B(),activityName:i,params:s,skipEnterActiveState:j(m).skipActiveState})})},pop(i){e||o(()=>{t.pop({skipExitActiveState:j(i).skipActiveState})})}}),[t.push,t.replace,t.pop,e,o])}function Yt(t){let e=Object.entries(t.activities).reduce((o,[i,s])=>A(p({},o),{[i]:S.default.memo(s)}),{});return{Stack(o){var s;let i=(0,S.useMemo)(()=>{var m;return((m=t.plugins)!=null?m:[]).reduce((n,c)=>[...n,...Array.isArray(c)?c:[c]],[]).map(n=>n({initContext:o.initContext}))},[]);return S.default.createElement(dt,{value:(s=o.initContext)!=null?s:{}},S.default.createElement(Pt,{value:i},S.default.createElement(Et,{activities:e,initialActivity:t.initialActivity,transitionDuration:t.transitionDuration},S.default.createElement(It,{activities:e}),S.default.createElement(Rt,null))))},useFlow:J}} | ||
"use strict";var Bt=Object.create;var O=Object.defineProperty,Nt=Object.defineProperties,Mt=Object.getOwnPropertyDescriptor,Ft=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertyNames,X=Object.getOwnPropertySymbols,Ht=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Y=(t,e,o)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,m=(t,e)=>{for(var o in e||(e={}))Z.call(e,o)&&Y(t,o,e[o]);if(X)for(var o of X(e))Vt.call(e,o)&&Y(t,o,e[o]);return t},C=(t,e)=>Nt(t,Ft(e));var qt=(t,e)=>{for(var o in e)O(t,o,{get:e[o],enumerable:!0})},tt=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Ut(e))!Z.call(t,s)&&s!==o&&O(t,s,{get:()=>e[s],enumerable:!(i=Mt(e,s))||i.enumerable});return t};var d=(t,e,o)=>(o=t!=null?Bt(Ht(t)):{},tt(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t)),Kt=t=>tt(O({},"__esModule",{value:!0}),t);var Zt={};qt(Zt,{stackflow:()=>Yt,useActions:()=>J,useActivity:()=>_t,useActivityParams:()=>Gt,useActivityPreloadRef:()=>Lt,useInitContext:()=>b,useStack:()=>Wt});module.exports=Kt(Zt);var ot=require("react");var et=require("react"),g=(0,et.createContext)(null);var _t=()=>(0,ot.useContext)(g);var rt=require("react");function Gt(){return(0,rt.useContext)(g).params}var it=require("react");function Lt(){return(0,it.useContext)(g).preloadRef}var at=d(require("react"));var nt=require("react"),M=(0,nt.createContext)({});function b(){return at.default.useContext(M)}var ct=require("react");var st=require("react"),F=(0,st.createContext)(null);var Wt=()=>(0,ct.useContext)(F);var E=d(require("react"));var A=require("@stackflow/core"),v=d(require("react")),At=d(require("react-fast-compare"));var mt=d(require("react"));var U=require("react"),pt=d(require("react-fast-compare"));function H(t){let e=(0,U.useRef)(t),o=e.current,i=(0,pt.default)(o,t);return(0,U.useEffect)(()=>{i||(e.current=t)}),i?o:t}var ft=({children:t,value:e})=>mt.default.createElement(g.Provider,{value:H(e)},t);var ut=require("@stackflow/core");function B(){return(0,ut.id)()}var vt=d(require("react"));var lt=({children:t,value:e})=>vt.default.createElement(M.Provider,{value:e},t);var dt=require("react"),V=(0,dt.createContext)(null);var xt=d(require("react"));var Pt=({children:t,value:e})=>xt.default.createElement(V.Provider,{value:e},t);var yt=require("react");function k(){return(0,yt.useContext)(V)}var Ct=require("react"),q=(0,Ct.createContext)(null);var kt=require("react"),K=(0,kt.createContext)(null);var jt=1e3,Jt=jt/60,St=({transitionDuration:t,initialActivity:e,activities:o,children:i})=>{let s=k(),p=b(),n=(0,v.useMemo)(()=>{let y=new Date().getTime()-t,f=e?(0,A.makeEvent)("Pushed",{activityId:B(),activityName:e({initContext:p}),params:{},eventDate:y,skipEnterActiveState:!1}):null,P=s.reduce((N,W)=>{var $,Q;return(Q=($=W.overrideInitialPushedEvent)==null?void 0:$.call(W,{pushedEvent:N}))!=null?Q:N},f);!!P&&!!f&&P.id!==f.id&&console.warn(`Stackflow - Some plugin overrides an "initialActivity" option. The "initialActivity" option you set to "${f.activityName}" in the "stackflow" is ignored.`);let T=P;T||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 bt=Object.keys(o).map(N=>(0,A.makeEvent)("ActivityRegistered",{activityName:N,eventDate:y})),z=[(0,A.makeEvent)("Initialized",{transitionDuration:t,eventDate:y}),...bt];return T&&z.push(T),z},[]),c=(0,v.useMemo)(()=>(0,A.aggregate)(n,new Date().getTime()),[]),[a,r]=(0,v.useState)(()=>c),u=(0,v.useRef)(n),l=(0,v.useRef)(c),x=(0,v.useCallback)(()=>l.current,[l]),h=(0,v.useCallback)((y,f)=>{let P=(0,A.makeEvent)(y,f),w=[...u.current,P];u.current=w,r((0,A.aggregate)(w,new Date().getTime()))},[u,r]);return(0,v.useEffect)(()=>{let y=setInterval(()=>{let f=u.current,P=(0,A.aggregate)(f,new Date().getTime());(0,At.default)(a,P)||(r(P),l.current=P),P.globalTransitionState==="idle"&&clearInterval(y)},Jt);return()=>{clearInterval(y)}},[u,a,r]),v.default.createElement(K.Provider,{value:a},v.default.createElement(q.Provider,{value:(0,v.useMemo)(()=>({getStack:x,dispatchEvent:h}),[x,h])},i))};var S=d(require("react"));var Et=t=>JSON.parse(JSON.stringify(t)),_=()=>{let t=k(),e=b(),{dispatchEvent:o,getStack:i}=S.default.useContext(q),s=(0,S.useCallback)(r=>{let{isPrevented:u,params:l}=a("PUSHED",r);u||o("Pushed",m({},l))},[o]),p=(0,S.useCallback)(r=>{let{isPrevented:u,params:l}=a("REPLACED",r);u||o("Replaced",m({},l))},[o]),n=(0,S.useCallback)(r=>{let u=r!=null?r:{},{isPrevented:l,params:x}=a("POPPED",u);l||o("Popped",m({},x))},[o]),c=(0,S.useMemo)(()=>({dispatchEvent:o,getStack:i,push:s,replace:p,pop:n}),[o,i,s,p,n]),a=(0,S.useCallback)((r,u)=>{let l=!1,x=Et(u),h=()=>{l=!0},y=f=>{x=Et(f)};return t.forEach(f=>{var P,w,T;switch(r){case"PUSHED":(P=f.onBeforePush)==null||P.call(f,{actionParams:x,actions:C(m({},c),{preventDefault:h,overrideActionParams:y})});break;case"REPLACED":(w=f.onBeforeReplace)==null||w.call(f,{actionParams:x,actions:C(m({},c),{preventDefault:h,overrideActionParams:y})});break;case"POPPED":(T=f.onBeforePop)==null||T.call(f,{actionParams:x,actions:C(m({},c),{preventDefault:h,overrideActionParams:y})});break;default:break}}),{isPrevented:l,params:x}},[t,e]);return c};var gt=d(require("react"));var D=()=>gt.default.useContext(K);var Rt=require("@stackflow/core"),R=require("react");var zt=()=>{let t=k(),e=D(),o=_(),i=(0,R.useCallback)(n=>{t.forEach(c=>{var a;(a=c.onInit)==null||a.call(c,n)})},[]),s=(0,R.useCallback)(({actions:n,effect:c})=>{switch(c._TAG){case"PUSHED":{t.forEach(a=>{var r;return(r=a.onPushed)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"POPPED":{t.forEach(a=>{var r;return(r=a.onPopped)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"REPLACED":{t.forEach(a=>{var r;return(r=a.onReplaced)==null?void 0:r.call(a,{actions:n,effect:c})});break}case"%SOMETHING_CHANGED%":{t.forEach(a=>{var r;return(r=a.onChanged)==null?void 0:r.call(a,{actions:n,effect:c})});break}default:break}},[]);(0,R.useEffect)(()=>{i==null||i({actions:o})},[]);let p=(0,R.useRef)(e);return(0,R.useEffect)(()=>{let n=p.current;(n?(0,Rt.produceEffects)(n,e):[]).forEach(a=>{s({actions:o,effect:a})}),p.current=m({},e)},[e]),null},ht=zt;var I=d(require("react"));var G=d(require("react"));var wt=d(require("react"));var Tt=({children:t,value:e})=>wt.default.createElement(F.Provider,{value:H(e)},t);var $t=({activities:t,plugin:e})=>{let o=D(),i=k();return e.render({stack:C(m({},o),{render(s){let p=m(m({},o),s);return{activities:p.activities.map(n=>C(m({},n),{key:n.id,render(c){let a=t[n.name],r=G.default.createElement(a,{params:n.params});return i.forEach(u=>{var l,x;r=(x=(l=u.wrapActivity)==null?void 0:l.call(u,{activity:C(m({},n),{render:()=>r})}))!=null?x:r}),G.default.createElement(Tt,{value:p},G.default.createElement(ft,{key:n.id,value:m(m({},n),c)},r))}}))}}})})},Dt=$t;var Qt=({activities:t})=>{let e=D(),o=k(),i=o.filter(p=>!!p.render);(0,I.useEffect)(()=>{i.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.`)},[i]);let s=I.default.createElement(I.default.Fragment,null,i.map(p=>I.default.createElement(Dt,{activities:t,key:p.key,plugin:p})));return o.forEach(p=>{var n,c;s=(c=(n=p.wrapStack)==null?void 0:n.call(p,{stack:C(m({},e),{render(){return s}})}))!=null?c:s}),s},It=Qt;var L=d(require("react"));function j(t){return t?t.animate===void 0||t.animate==null?{skipActiveState:!1}:{skipActiveState:!t.animate}:{skipActiveState:!1}}var Ot,Xt=(Ot=L.default.useTransition)!=null?Ot:()=>[!1,t=>t()];function J(){let t=_(),[e,o]=Xt();return(0,L.useMemo)(()=>({pending:e,push(i,s,p){e||o(()=>{t.push({activityId:B(),activityName:i,params:s,skipEnterActiveState:j(p).skipActiveState})})},replace(i,s,p){e||o(()=>{t.replace({activityId:B(),activityName:i,params:s,skipEnterActiveState:j(p).skipActiveState})})},pop(i){e||o(()=>{t.pop({skipExitActiveState:j(i).skipActiveState})})}}),[t.push,t.replace,t.pop,e,o])}function Yt(t){let e=Object.entries(t.activities).reduce((o,[i,s])=>C(m({},o),{[i]:E.default.memo(s)}),{});return{Stack(o){var s;let i=(0,E.useMemo)(()=>{var p;return((p=t.plugins)!=null?p:[]).reduce((n,c)=>[...n,...Array.isArray(c)?c:[c]],[]).map(n=>n({initContext:o.initContext}))},[]);return E.default.createElement(lt,{value:(s=o.initContext)!=null?s:{}},E.default.createElement(Pt,{value:i},E.default.createElement(St,{activities:e,initialActivity:t.initialActivity,transitionDuration:t.transitionDuration},E.default.createElement(It,{activities:e}),E.default.createElement(ht,null))))},useFlow:J}} | ||
//# sourceMappingURL=index.js.map |
import React from "react"; | ||
import { BaseActivities } from "./BaseActivities"; | ||
import type { BaseActivities } from "./BaseActivities"; | ||
interface MainRendererProps { | ||
@@ -4,0 +4,0 @@ activities: BaseActivities; |
import React from "react"; | ||
import { BaseActivities } from "./BaseActivities"; | ||
import { StackflowReactPlugin } from "./StackflowReactPlugin"; | ||
import { WithRequired } from "./utils"; | ||
import type { BaseActivities } from "./BaseActivities"; | ||
import type { StackflowReactPlugin } from "./StackflowReactPlugin"; | ||
import type { WithRequired } from "./utils"; | ||
interface PluginRendererProps { | ||
@@ -6,0 +6,0 @@ activities: BaseActivities; |
/// <reference types="react" /> | ||
import { StackflowReactPlugin } from "../StackflowReactPlugin"; | ||
import type { StackflowReactPlugin } from "../StackflowReactPlugin"; | ||
export declare type PluginsContextValue = Array<ReturnType<StackflowReactPlugin>>; | ||
export declare const PluginsContext: import("react").Context<PluginsContextValue>; |
import React from "react"; | ||
import { PluginsContextValue } from "./PluginsContext"; | ||
import type { PluginsContextValue } from "./PluginsContext"; | ||
interface PluginsProviderProps { | ||
@@ -4,0 +4,0 @@ children: React.ReactNode; |
/// <reference types="react" /> | ||
import { AggregateOutput } from "@stackflow/core"; | ||
import type { AggregateOutput } from "@stackflow/core"; | ||
export declare const StackContext: import("react").Context<AggregateOutput>; |
@@ -1,2 +0,2 @@ | ||
import { AggregateOutput } from "@stackflow/core"; | ||
import type { AggregateOutput } from "@stackflow/core"; | ||
import React from "react"; | ||
@@ -3,0 +3,0 @@ interface StackProviderProps { |
import React from "react"; | ||
import { BaseActivities } from "./BaseActivities"; | ||
import { StackflowReactPlugin } from "./StackflowReactPlugin"; | ||
import { UseActionsOutputType } from "./useActions"; | ||
import type { BaseActivities } from "./BaseActivities"; | ||
import type { StackflowReactPlugin } from "./StackflowReactPlugin"; | ||
import type { UseActionsOutputType } from "./useActions"; | ||
export declare type StackProps<C extends {} = {}> = { | ||
@@ -6,0 +6,0 @@ /** |
@@ -1,3 +0,3 @@ | ||
import { Activity, AggregateOutput, StackflowPlugin } from "@stackflow/core"; | ||
import React from "react"; | ||
import type { Activity, AggregateOutput, StackflowPlugin } from "@stackflow/core"; | ||
import type React from "react"; | ||
export declare type StackflowReactPlugin<T = never> = (args: { | ||
@@ -4,0 +4,0 @@ initContext: any; |
@@ -1,3 +0,3 @@ | ||
import { ActivityComponentType } from "./activity"; | ||
import { BaseActivities } from "./BaseActivities"; | ||
import type { ActivityComponentType } from "./activity"; | ||
import type { BaseActivities } from "./BaseActivities"; | ||
export declare type UseActionsOutputType<T extends BaseActivities> = { | ||
@@ -4,0 +4,0 @@ /** |
{ | ||
"name": "@stackflow/react", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
@@ -30,4 +30,6 @@ "exports": { | ||
"devDependencies": { | ||
"@stackflow/core": "^0.8.0", | ||
"@stackflow/core": "^0.9.0", | ||
"@stackflow/esbuild-config": "^0.9.0", | ||
"@types/react": "^18.0.9", | ||
"esbuild": "^0.14.51", | ||
"react": "^18.1.0", | ||
@@ -51,3 +53,3 @@ "rimraf": "^3.0.2", | ||
}, | ||
"gitHead": "7f51b2258bf53ceef0d2790eb7b6c637c824b3ab" | ||
"gitHead": "08a85d01e5183758bf061ecbb671ae87ed73fef2" | ||
} |
@@ -1,4 +0,4 @@ | ||
import { Activity } from "@stackflow/core"; | ||
import type { Activity } from "@stackflow/core"; | ||
import { createContext } from "react"; | ||
export const ActivityContext = createContext<Activity>(null as any); |
@@ -1,2 +0,2 @@ | ||
import { ActivityComponentType } from "./activity"; | ||
import type { ActivityComponentType } from "./activity"; | ||
@@ -3,0 +3,0 @@ export type BaseActivities = { |
@@ -1,2 +0,2 @@ | ||
import { AggregateOutput, DispatchEvent } from "@stackflow/core"; | ||
import type { AggregateOutput, DispatchEvent } from "@stackflow/core"; | ||
import { createContext } from "react"; | ||
@@ -3,0 +3,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { AggregateOutput } from "@stackflow/core"; | ||
import type { AggregateOutput } from "@stackflow/core"; | ||
import { createContext } from "react"; | ||
export const CoreStateContext = createContext<AggregateOutput>(null as any); |
@@ -1,3 +0,3 @@ | ||
import { Effect } from "@stackflow/core"; | ||
import { | ||
import type { Effect } from "@stackflow/core"; | ||
import type { | ||
PoppedEvent, | ||
@@ -7,3 +7,3 @@ PushedEvent, | ||
} from "@stackflow/core/dist/event-types"; | ||
import { BaseDomainEvent } from "@stackflow/core/dist/event-types/_base"; | ||
import type { BaseDomainEvent } from "@stackflow/core/dist/event-types/_base"; | ||
import React, { useCallback, useMemo } from "react"; | ||
@@ -10,0 +10,0 @@ |
@@ -1,4 +0,4 @@ | ||
import { AggregateOutput } from "@stackflow/core"; | ||
import type { AggregateOutput } from "@stackflow/core"; | ||
import { createContext } from "react"; | ||
export const StackContext = createContext<AggregateOutput>(null as any); |
@@ -1,3 +0,7 @@ | ||
import { Activity, AggregateOutput, StackflowPlugin } from "@stackflow/core"; | ||
import React from "react"; | ||
import type { | ||
Activity, | ||
AggregateOutput, | ||
StackflowPlugin, | ||
} from "@stackflow/core"; | ||
import type React from "react"; | ||
@@ -4,0 +8,0 @@ export type StackflowReactPlugin<T = never> = (args: { initContext: any }) => { |
import React, { useMemo } from "react"; | ||
import { ActivityComponentType, makeActivityId } from "./activity"; | ||
import { BaseActivities } from "./BaseActivities"; | ||
import type { ActivityComponentType } from "./activity"; | ||
import { makeActivityId } from "./activity"; | ||
import type { BaseActivities } from "./BaseActivities"; | ||
import { useCoreActions } from "./core"; | ||
@@ -6,0 +7,0 @@ |
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134905
7
81
1195