@picked/client 0.0.11-next.1 → 0.0.12-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +364 -319
- package/dist/esm/plugins/create-experience/index.js +231 -180
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BBz99AXU.js +766 -0
- package/dist/experience-instance-DDsqvl4c.cjs +1 -0
- package/dist/types/client.d.ts +26 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +15 -0
- package/dist/types/entities/action/action.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +14 -1
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/picked.d.ts +10 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +20 -2
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +2 -1
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/experience-instance-DXWLnF-R.cjs +0 -1
- package/dist/experience-instance-XlIuqLrL.js +0 -716
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const a=require("effector"),q=require("@withease/factories"),C=require("./supports-YvpQZxbh.cjs"),I=require("./logger-BsmHUUw1.cjs"),fe=require("./object-BbFTsGh3.cjs");function le(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function N(e){return Array.isArray(e)}function Z(e){return e instanceof Promise}function J(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(le(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function O(e){return`${e}`}const de={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>m(e)>m(t),">=":(e,t)=>m(e)>=m(t),"<":(e,t,r)=>{const n=m(e),s=m(t);if(r===void 0)return n<s;const c=m(r);return n<s&&s<c},"<=":(e,t,r)=>{const n=m(e),s=m(t);if(r===void 0)return n<=s;const c=m(r);return n<=s&&s<=c},"!!":async e=>await A(e),"!":async e=>!await A(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(O(e))!==-1:N(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(O).join(""),substr:(e,t,r)=>{const n=O(e),s=m(t);if(r===void 0)return n.substr(s);const c=m(r);if(c<0){const o=n.substr(s);return o.substr(0,o.length+c)}return n.substr(s,c)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>N(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=O(e);if(n===""||n===".")return this;const s=n.split(".");let c=this;for(const o of s){if(c==null)return r;if(Array.isArray(c)){const u=parseInt(o,10);isNaN(u)?c=c[o]:c=c[u]}else c=c[o]}return c!==void 0?c:r},async missing(...e){const t=N(e[0])?e[0]:e,r=[];for(const n of t){const s=await g({var:n},this);(s===null||s==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!N(r)||!N(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(e){return typeof e!="function"?null:e()},regexp_matches(e,t){let r=e,n="";if(N(e)){const[c,o]=e;r=c,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(O(t))},throw(e){throw new Error(O(e))}};async function g(e,t){if(!e)return e;if(Z(e))return g(await e,t);if(N(e))return Promise.all(e.map(o=>g(o,t)));if(!J(e))return e;const r=pe(e);let n=r?e[r]??[]:[];switch(N(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await A(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const u of n)if(o=await g(u,t),!await A(o))return o;return o}case"or":{let o=null;for(const u of n)if(o=await g(u,t),await A(o))return o;return o}case"map":{const o=await g(n[0],t);return N(o)?await Promise.all(o.map(u=>g(n[1],u))):[]}case"filter":{const o=await g(n[0],t);return N(o)?(await Promise.all(o.map(async d=>{const y=await A(await g(n[1],d));return{item:d,shouldInclude:y}}))).filter(({shouldInclude:d})=>d).map(({item:d})=>d):[]}case"reduce":{const o=await g(n[0],t);if(!N(o))return n.length>2?await g(n[2],t):null;const u=n[1];let y=n.length>2?await g(n[2],t):null;for(const b of o)y=await g(u,{current:b,accumulator:y});return y}case"all":{const o=await g(n[0],t);if(!N(o)||o.length===0)return!1;for(const u of o)if(!await A(await g(n[1],u)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!N(o))return!1;for(const u of o)if(await A(await g(n[1],u)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!N(o))return!0;for(const u of o)if(await A(await g(n[1],u)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return J(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const s=await Promise.all(n.map(o=>g(o,t))),c=r?de[r]:void 0;if(!c)throw new Error(`Unrecognized operation ${r}`);return c.apply(t,s)}async function A(e){return Z(e)?A(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function pe(e){return Object.keys(e)[0]}function ge(e){return!fe.isEmpty(e)}async function ee(e,t,r){const n=e.getStateSnapshot(),s=e.predicates.listStore.getState().reduce((u,d)=>({...u,[d.name]:()=>d.predicate(n)}),{}),c=e.features.listStore.getState().reduce((u,d)=>({...u,[d.id]:async()=>{const{bucket:y}=await d.getBucket();return y}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:s,features:c};return await g(t,o)}function me(e){return!C.supportsWindow()||!C.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}function he(e){if(!C.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:"closed"})}function Se(){return new Promise((e,t)=>{if(!C.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function ye(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const H="picked-root",j="picked-target",we="picked-root";function Ee(e,t){return[...e,{selector:`${we}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const s=me(n.selector).filter(c=>!xe(c,t)&&!te(c,t));return{...n,elements:s}})}function Ne(e,t){return e.flatMap(r=>r.elements.map(n=>be(n,r.placement,t)))}function Ie(e,t){e.classList.add(j),e.classList.add(`${j}-${t}`)}function xe(e,t){return t?e.classList.contains(`${j}-${t}`):e.classList.contains(`${j}`)}function te(e,t){return t?e.classList.contains(`${H}-${t}`):e.classList.contains(H)}function ke(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(H),t.classList.add(`${H}-${e}`),t}function be(e,t,r){let n;const s=ke(r);if(e instanceof Document)n=e.body.appendChild(s);else{switch(t){case"replace":e.replaceWith(s);break;case"before":e.before(s);break;case"after":e.after(s);break;case"prepend":e.prepend(s);break;default:e.append(s);break}n=s}return n}function ve(e){return e.type==="conditional"}function T(e){return e.type==="step"}function Ae(e){return e.type==="experience"}function Q(e){return e.type==="origin"}function Y(e){return e.type==="action"}const ne=(e,t,r,n,s=new Set)=>s.has(r.id)?[]:(s.add(r.id),T(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const u=e.find(d=>d.id===o.destinationNodeId);return u?ne(e,t,u,!1,s):[]})),$e=(e,t,r)=>ne(e,t,r,!0,new Set),re=(e,t,r,n,s=new Set)=>{if(s.has(r.id))return[-1,-1];s.add(r.id);const c=t.filter(d=>d.sourceNodeId===r.id);if(c.length===0)return[0,0];let o=1/0,u=-1/0;for(const d of c){const y=e.find(_=>_.id===d.destinationNodeId);if(!y)continue;const[b,w]=re(e,t,y,!1,new Set(s));b!==-1&&(o=Math.min(o,b+1),u=Math.max(u,w+1))}return o===1/0?[-1,-1]:[o,u]},Fe=(e,t,r)=>re(e,t,r,!0,new Set),oe=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const s=t.filter(u=>u.destinationNodeId===r.id);if(s.length===0)return[-1,-1];let c=1/0,o=-1/0;for(const u of s){const d=e.find(w=>w.id===u.sourceNodeId);if(!d)continue;const[y,b]=oe(e,t,d,new Set(n));y!==-1&&(c=Math.min(c,y+1),o=Math.max(o,b+1))}return c===1/0?[-1,-1]:[c,o]},Be=(e,t,r)=>oe(e,t,r,new Set),ie=e=>e.find(r=>r.type==="origin")||null,V=(e,t,r)=>{if(!e)return ie(t);const n=r.find(c=>c.sourceNodeId===e.id);if(!n)return null;const s=t.find(c=>c.id===n.destinationNodeId);return s||null};async function _e(e,t,r,n){const s=e?"true":"false",c=n.find(o=>o.sourceNodeHandle===s&&o.sourceNodeId===t);return r.find(o=>o.id===(c==null?void 0:c.destinationNodeId))}const W=a.createDomain("experience-instance"),Le=q.createFactory(({client:e,experience:t,target:r})=>{const n=a.createEvent(),s=a.createEvent(),c=a.createEvent(),o=a.createEvent(),u=t.componentStore,d=W.store("transitioning"),y=e.history.entriesStore.map(i=>i.filter(f=>f.experienceId===t.id)),b=y.map(i=>i.filter(f=>T(f.node))),w=y.map(i=>{var f;return((f=i[i.length-1])==null?void 0:f.node)||null}),_=a.attach({source:t.treeStore,effect:async({nodes:i,edges:f},l)=>{if(!l||!Y(l))return;const E=l.action;if(!E){I.logger("warn",`Action node ${l.id} has no action name`);return}const L=e.actions.getByName(E).getState();if(!L){I.logger("warn",`Action '${E}' not registered on client`);const x=f.find(S=>S.sourceNodeId===l.id&&S.sourceNodeHandle==="false");return x?i.find(S=>S.id===x.destinationNodeId):null}if(typeof L.action!="function"){I.logger("warn",`Action '${E}' is not a function`);const x=f.find(S=>S.sourceNodeId===l.id&&S.sourceNodeHandle==="false");return x?i.find(S=>S.id===x.destinationNodeId):null}try{I.logger("info",`Executing action: ${E}`),await L.action();const x=f.find(k=>k.sourceNodeId===l.id&&k.sourceNodeHandle==="true");if(!x)return I.logger("warn",`No 'true' edge found for action node ${l.id}`),null;const S=i.find(k=>k.id===x.destinationNodeId);return I.logger("info",`Action '${E}' succeeded, moving to node ${S==null?void 0:S.id}`),S||null}catch(x){I.logger("warn",`Action '${E}' failed:`,x);const S=f.find(P=>P.sourceNodeId===l.id&&P.sourceNodeHandle==="false");if(!S)return I.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const k=i.find(P=>P.id===S.destinationNodeId);return I.logger("info",`Action '${E}' failed, moving to node ${k==null?void 0:k.id}`),k||null}}}),B=a.combine(t.treeStore,w,({steps:i},f)=>i.find(l=>f&&T(f)&&l.id===f.stepId)||null),p=a.combine(t.treeStore,w,({nodes:i,edges:f},l)=>l?$e(i,f,l):[]),h=a.combine(t.treeStore,w,({nodes:i,edges:f},l)=>l?Be(i,f,l):[-1,-1]),v=a.combine(t.treeStore,w,({nodes:i,edges:f},l)=>l?Fe(i,f,l):[-1,-1]),$=W.store(!0),F=a.createApi($,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,f)=>f});a.sample({source:$,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:t}))}),a.sample({source:$,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:t}))});const M=a.createEffect(async()=>{e.history.back({experienceId:t.id})}),ce=a.attach({source:t.treeStore,effect:async(i,f)=>{const l=i.nodes.find(E=>T(E)&&E.stepId===f);l&&e.history.push({experienceId:t.id,node:l})}}),z=a.attach({source:w,effect:i=>{}}),G=a.attach({source:t.treeStore,effect:async({nodes:i})=>ie(i)}),K=a.attach({source:t.treeStore,effect:async({nodes:i,edges:f},l)=>V(l,i,f)}),U=a.attach({source:t.treeStore,effect:async({nodes:i,edges:f,conditionals:l},E)=>{if(!E)return;const L=l.find(k=>k.id===E.conditionalId);if(!L)return;const x=E.id,S=await ee(e,L.condition);return _e(!!S,x,i,f)}}),ae=a.createEffect(i=>{if(i)return e.launchExperienceById(i.experienceId)}),X=a.attach({source:[w,t.treeStore],effect:async([i,{nodes:f,edges:l}])=>V(i,f,l)}),D=a.attach({source:[w,t.treeStore],effect:async([i,{nodes:f,edges:l}])=>V(i,f,l)}),ue=a.createEffect(i=>{e.history.push({experienceId:t.id,node:i})});return a.split({source:w,match:i=>i?ve(i)?"condition":T(i)?"step":Ae(i)?"launchExperience":Q(i)?"origin":Y(i)?"action":"other":"none",cases:{none:G,origin:K,condition:U,step:z,launchExperience:ae,action:_,__:a.createEvent()}}),a.sample({clock:[U.doneData,K.doneData,G.doneData,D.doneData,X.doneData,_.doneData],filter:Boolean,target:ue}),a.sample({clock:s,target:D}),a.sample({clock:s,source:B,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:t}))}),a.sample({clock:D.done,source:B,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:t}))}),a.sample({clock:D.fail,source:B,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:t}))}),a.sample({clock:c,target:M}),a.sample({clock:o,target:ce}),a.sample({source:a.combine([U.pending,K.pending,G.pending,D.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:d}),a.sample({clock:z.doneData,source:B,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:t}))}),a.sample({source:w,clock:n,filter:i=>i?Q(i):!0,target:X}),n(),{id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:u,stateStore:d,isOpenStore:$,open:F.open,close:F.close,toggleOpen:F.toggle,setOpen:F.set,treeStore:t.treeStore,currentNodeStore:w,currentStepStore:B,nextReachableStepNodesStore:p,stepsToOriginStore:h,stepsToLeafStore:v,goToNextStep:s,goToPreviousStep:c,goToStepById:o,stepsHistoryStore:b}});function se(e){return q.invoke(Le,e)}const Oe=q.createFactory(({client:e})=>{const t=W.store({}),r=a.createEvent(),n=a.createEvent(),s=a.createEvent(),c=a.createApi(t,{register(p,h){const v=[...p[h.experienceId]??[]];return v.push(h),{...p,[h.experienceId]:v}},unregister(p,h){var F;const v=h.experienceId,$=(F=p[v])==null?void 0:F.filter(M=>M!==h);return{...p,[v]:$??[]}}}),o=a.createEffect(({experience:p,target:h})=>se({client:e,experience:p,target:h})),u=a.createEffect(p=>{c.register(p)}),d=a.createEffect(p=>{p.target&&ye(p.target,()=>{s(p)})}),y=a.createEffect(p=>{c.unregister(p)}),b=a.createEffect(p=>{const h=p.componentStore.getState();if(!h){I.logger("warn","No app component registered. Skipping init.");return}const v=h.frameworkStore.getState();if(!v){I.logger("error",`No framework registered for component '${h.name}'. Skipping rendering.`);return}const $=p.target;if(!$){I.logger("error",`No target element registered for experience '${p.experienceId}'. Skipping rendering.`);return}const F=he($);try{v.render(F,h.component,e,p)}catch(M){I.logger("error",M)}});a.sample({clock:r,target:o}),a.sample({clock:s,target:y}),a.sample({clock:o.doneData,target:[u,d,n]}),a.sample({clock:o.doneData,target:e.eventBus.prepend(p=>({type:"experience_initialized",experienceInstance:p}))}),a.sample({clock:n,target:b});function w(p,h){r({experience:p,target:h})}const _=t.map(p=>Object.values(p).flat());function B(p){return t.map(h=>h[p]||[],{skipVoid:!1})}return{spawn:w,getByExperienceId:B,listStore:_}});function Te(e){return q.invoke(Oe,e)}exports.createAppHosts=Ne;exports.createExperienceInstance=se;exports.createExperienceInstanceIndex=Te;exports.domInteractive=Se;exports.evaluateRuleLogic=ee;exports.getTargetElements=Ee;exports.isPickedRoot=te;exports.isRulesLogic=ge;exports.isStepNode=T;exports.tagTargetElement=Ie;
|
package/dist/types/client.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Predicate } from './entities/predicate/predicate';
|
|
2
|
+
import { Action } from './entities/action/action';
|
|
2
3
|
import { Plugin } from './entities/plugin/plugin';
|
|
3
4
|
import { Feature } from './entities/feature/feature';
|
|
4
5
|
export interface CreateClientOptions {
|
|
@@ -31,6 +32,31 @@ export interface CreateClientOptions {
|
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
34
|
predicates?: Record<string, Predicate>;
|
|
35
|
+
/**
|
|
36
|
+
* Register actions to be invoked in experience trees
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* actions: {
|
|
41
|
+
* logEvent({ event, data }) {
|
|
42
|
+
* // custom logic
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
/**
|
|
48
|
+
* Register actions to be invoked in experience trees
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* actions: {
|
|
53
|
+
* logEvent({ event, data }) {
|
|
54
|
+
* // custom logic
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
actions?: Record<string, Action>;
|
|
34
60
|
/**
|
|
35
61
|
* Plugins to extend client functionality
|
|
36
62
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS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,EAAE,MAAM,CAAA;IAEf;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAEtC;;;;;;;;;;;OAWG;IACH;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,CAAA;IAEnE;;;;;;;;;;;;;;;OAeG;IAEH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAA;CACrD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Action = () => void;
|
|
2
|
+
export type ActionsStore = ReturnType<typeof createActionIndexFactory>;
|
|
3
|
+
export interface ActionIndexItem {
|
|
4
|
+
name: string;
|
|
5
|
+
action: Action;
|
|
6
|
+
}
|
|
7
|
+
declare const createActionIndexFactory: () => {
|
|
8
|
+
register: (name: string, action: Action) => void;
|
|
9
|
+
getByName: (name: string) => import('effector').Store<ActionIndexItem | undefined>;
|
|
10
|
+
listStore: import('effector').Store<ActionIndexItem[]>;
|
|
11
|
+
};
|
|
12
|
+
export declare function createActionIndex(): ReturnType<typeof createActionIndexFactory>;
|
|
13
|
+
export declare const setupAction: (name: string, action: Action, actions: ActionsStore) => void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,MAAM,GAAG,MAAM,IAAI,CAAA;AAC/B,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAItE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,QAAA,MAAM,wBAAwB;qBAiBJ,MAAM,UAAU,MAAM,KAAG,IAAI;sBAQ5B,MAAM;;CAS/B,CAAA;AAEF,wBAAgB,iBAAiB,IAAI,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAE/E;AAED,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,YAAY,KAAG,IAEjF,CAAA"}
|
|
@@ -26,6 +26,7 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
26
26
|
component: AdaptedComponent<string, unknown>;
|
|
27
27
|
frameworkStore: import('effector').Store<import('../..').Framework | undefined>;
|
|
28
28
|
} | undefined>;
|
|
29
|
+
actions: ExperienceAction[];
|
|
29
30
|
merge: import('effector').EventCallable<{
|
|
30
31
|
experience: Partial<Experience>;
|
|
31
32
|
strategy: "override";
|
|
@@ -55,6 +56,7 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
55
56
|
component: AdaptedComponent<string, unknown>;
|
|
56
57
|
frameworkStore: import('effector').Store<import('../..').Framework | undefined>;
|
|
57
58
|
} | undefined>;
|
|
59
|
+
actions: ExperienceAction[];
|
|
58
60
|
merge: import('effector').EventCallable<{
|
|
59
61
|
experience: Partial<Experience>;
|
|
60
62
|
strategy: "override";
|
|
@@ -79,6 +81,7 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
79
81
|
component: AdaptedComponent<string, unknown>;
|
|
80
82
|
frameworkStore: import('effector').Store<import('../..').Framework | undefined>;
|
|
81
83
|
} | undefined>;
|
|
84
|
+
actions: ExperienceAction[];
|
|
82
85
|
merge: import('effector').EventCallable<{
|
|
83
86
|
experience: Partial<Experience>;
|
|
84
87
|
strategy: "override";
|
|
@@ -91,7 +94,16 @@ export interface ExperienceStep {
|
|
|
91
94
|
label: string;
|
|
92
95
|
fieldIds: string[];
|
|
93
96
|
}
|
|
94
|
-
export type ExperienceNode = StepNode | ConditionalNode | LaunchExperienceNode | OriginNode;
|
|
97
|
+
export type ExperienceNode = StepNode | ConditionalNode | LaunchExperienceNode | OriginNode | ActionNode;
|
|
98
|
+
export interface ExperienceAction {
|
|
99
|
+
id: string;
|
|
100
|
+
action: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ActionNode extends BaseNode {
|
|
103
|
+
type: 'action';
|
|
104
|
+
action: string;
|
|
105
|
+
position: [number, number];
|
|
106
|
+
}
|
|
95
107
|
export interface BaseNode {
|
|
96
108
|
id: string;
|
|
97
109
|
type: string;
|
|
@@ -133,6 +145,7 @@ export interface Experience {
|
|
|
133
145
|
type: string;
|
|
134
146
|
component?: AdaptedComponent;
|
|
135
147
|
conditionals: ExperienceConditional[];
|
|
148
|
+
actions?: ExperienceAction[];
|
|
136
149
|
decide: LogicRule | undefined;
|
|
137
150
|
edges: ExperienceEdge[];
|
|
138
151
|
nodes: ExperienceNode[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAC3E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAIjE,QAAA,MAAM,uBAAuB,2BACF;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE
|
|
1
|
+
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EAAE,MAAM,CAAA;IACV,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAA;CACjE;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,YAAY,EAAE,qBAAqB,EAAE,CAAA;IACrC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED,eAAO,MAAM,eAAe,GAC1B,YAAY,UAAU,EACtB,iBAAiB,oBAAoB,KACpC,IAEF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,QAAQ,MAAM,EAAE,YAAY,eAAe,SAa/E,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,kBASzD,CAAA;AA0BD,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,EACd,YAAY,eAAe,KAC1B,OAAO,CAAC,OAAO,CA4BjB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAEV,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAGjB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAoB1C,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC5E,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAA;AACtF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,WAAW,EAAE,CAAA;IACvB,SAAS,EAAE,gBAAgB,CAAC,WAAW,CAAC,CAAA;CACzC;AAED,QAAA,MAAM,+BAA+B,oCAKhC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,eAAe,CAAA;IAC3B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoXF,CAAA;AAED,wBAAgB,wBAAwB,CACtC,CAAC,SAAS,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,EAC/D,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAE/D;AAED,QAAA,MAAM,oCAAoC,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;wBAqI7D,eAAe,UAAU,WAAW;4BAQhC,UAAU,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS/C,CAAA;AAEF,wBAAgB,6BAA6B,CAC3C,CAAC,SAAS,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAAC,CAAC,CAAC,EACpE,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,oCAAoC,CAAC,CAEpE"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { StateSnapshot } from './utils/state-snaphot';
|
|
|
7
7
|
import { Predicate } from './entities/predicate/predicate';
|
|
8
8
|
import { Feature } from './entities/feature/feature';
|
|
9
9
|
import { Field } from './entities/field/field';
|
|
10
|
+
import { Action } from './entities/action/action';
|
|
10
11
|
import { Session } from './utils/user-session';
|
|
11
12
|
export declare class Picked {
|
|
12
13
|
static readonly logger: (level: "log" | "warn" | "info" | "error", ...args: Parameters<Console["log"]>) => void;
|
|
@@ -147,6 +148,7 @@ export declare class Picked {
|
|
|
147
148
|
component: AdaptedComponent<string, unknown>;
|
|
148
149
|
frameworkStore: import('effector').Store<Framework | undefined>;
|
|
149
150
|
} | undefined>;
|
|
151
|
+
actions: import('.').ExperienceAction[];
|
|
150
152
|
merge: import('effector').EventCallable<{
|
|
151
153
|
experience: Partial<Experience>;
|
|
152
154
|
strategy: "override";
|
|
@@ -171,6 +173,7 @@ export declare class Picked {
|
|
|
171
173
|
component: AdaptedComponent<string, unknown>;
|
|
172
174
|
frameworkStore: import('effector').Store<Framework | undefined>;
|
|
173
175
|
} | undefined>;
|
|
176
|
+
actions: import('.').ExperienceAction[];
|
|
174
177
|
merge: import('effector').EventCallable<{
|
|
175
178
|
experience: Partial<Experience>;
|
|
176
179
|
strategy: "override";
|
|
@@ -225,6 +228,11 @@ export declare class Picked {
|
|
|
225
228
|
listStore: import('effector').Store<Field[]>;
|
|
226
229
|
getByName: (name: import('.').FieldBase["name"]) => import('effector').Store<Field | null>;
|
|
227
230
|
};
|
|
231
|
+
readonly actions: {
|
|
232
|
+
register: (name: string, action: Action) => void;
|
|
233
|
+
getByName: (name: string) => import('effector').Store<import('./entities/action/action').ActionIndexItem | undefined>;
|
|
234
|
+
listStore: import('effector').Store<import('./entities/action/action').ActionIndexItem[]>;
|
|
235
|
+
};
|
|
228
236
|
constructor(options: CreateClientOptions);
|
|
229
237
|
start(): void;
|
|
230
238
|
registerFramework(framework: Framework): void;
|
|
@@ -233,12 +241,14 @@ export declare class Picked {
|
|
|
233
241
|
registerFeature(name: string, feature: Feature): void;
|
|
234
242
|
registerPredicate(name: string, predicate: Predicate): void;
|
|
235
243
|
registerField(field: Field): void;
|
|
244
|
+
registerAction(name: string, action: Action): void;
|
|
236
245
|
registerExperience(experience: Experience): void;
|
|
237
246
|
getStateSnapshot(): StateSnapshot;
|
|
238
247
|
launchExperienceById(experienceId: string): Promise<void>;
|
|
239
248
|
private setupPlugins;
|
|
240
249
|
private setupFeatures;
|
|
241
250
|
private setupPredicates;
|
|
251
|
+
private setupActions;
|
|
242
252
|
getPluginConfig(pluginName: string): PluginConfigIndex[string] | Record<string, unknown>;
|
|
243
253
|
}
|
|
244
254
|
//# sourceMappingURL=picked.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,UAAU,EAIhB,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AAGvC,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAMzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB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eAAe;IAgBvB,OAAO,CAAC,YAAY;IAgBpB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGzF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Experience, ExperienceConditional, ExperienceEdge, ExperienceNode, ExperienceStep, ExperienceTarget } from '../../entities/experience/experience';
|
|
1
|
+
import { ActionNode, Experience, ExperienceConditional, ExperienceEdge, ExperienceNode, ExperienceStep, ExperienceTarget } from '../../entities/experience/experience';
|
|
2
2
|
import { AdaptedComponent } from '../../entities/component/component';
|
|
3
3
|
import { LogicRule } from '../../logic-engine';
|
|
4
4
|
import { Field, FieldBooleanMultiple, FieldBooleanSingular, FieldNumberMultiple, FieldNumberSingular, FieldTextMultiple, FieldTextSingular } from '../../entities/field/field';
|
|
@@ -22,7 +22,19 @@ export interface CreateStepOptions {
|
|
|
22
22
|
label: string;
|
|
23
23
|
fields?: SerializableField[];
|
|
24
24
|
}
|
|
25
|
-
export type SerializableNode = SerializableStepNode | SerializableConditionalNode | SerializableLaunchExperienceNode | SerializableOriginNode;
|
|
25
|
+
export type SerializableNode = SerializableStepNode | SerializableConditionalNode | SerializableLaunchExperienceNode | SerializableOriginNode | SerializableActionNode;
|
|
26
|
+
export interface SerializableActionNode extends SerializableBaseNode {
|
|
27
|
+
type: 'action';
|
|
28
|
+
action: string;
|
|
29
|
+
addNext: (nodeable: Nodeable) => undefined;
|
|
30
|
+
onSuccess: (nodeable: Nodeable) => undefined;
|
|
31
|
+
onFail: (nodeable: Nodeable) => undefined;
|
|
32
|
+
serialize: () => Serialized<ActionNode>;
|
|
33
|
+
}
|
|
34
|
+
export interface CreateActionOptions {
|
|
35
|
+
action: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const createAction: (actionOptions: CreateActionOptions, experience: SerializableExperience) => SerializableActionNode;
|
|
26
38
|
export interface SerializableBaseNode {
|
|
27
39
|
id: string;
|
|
28
40
|
experience: SerializableExperience;
|
|
@@ -55,6 +67,9 @@ export type CreateNodeOptions = {
|
|
|
55
67
|
} | {
|
|
56
68
|
experience: SerializableExperience;
|
|
57
69
|
type: 'experience';
|
|
70
|
+
} | {
|
|
71
|
+
action: SerializableActionNode;
|
|
72
|
+
type: 'action';
|
|
58
73
|
};
|
|
59
74
|
export interface SerializableEdge {
|
|
60
75
|
id: string;
|
|
@@ -140,6 +155,9 @@ export interface SerializableExperience {
|
|
|
140
155
|
node: SerializableNode | null;
|
|
141
156
|
}) => SerializableExperience;
|
|
142
157
|
addField: (fieldOptions: CreateFieldOptions | SerializableField, step?: SerializableStep) => SerializableField;
|
|
158
|
+
addAction: (actionOptions: CreateActionOptions | SerializableActionNode, after?: {
|
|
159
|
+
node: SerializableNode | null;
|
|
160
|
+
}) => SerializableActionNode;
|
|
143
161
|
serialize: () => Serialized<Experience>;
|
|
144
162
|
}
|
|
145
163
|
export interface CreateExperienceOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9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AQ,oBAAoB;IAC5E,IAAI,EAAE,YAAY,CAAA;IAClB,mBAAmB,EAAE,sBAAsB,CAAA;CAC5C;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,IAAI,EAAE,QAAQ,CAAA;CACf;AAED,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,WAAW,EAAE,uBAAuB,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,UAAU,EAAE,sBAAsB,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"create-experience.d.ts","sourceRoot":"","sources":["../../../../src/plugins/create-experience/create-experience.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAEV,UAAU,EACV,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,cAAc,EACd,gBAAgB,EAGjB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEhE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,iBAAiB,EAAE,CAAA;IAC3B,UAAU,E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ACtC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,CAAA;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAA;IAC3B,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,UAAU,GAAG,IAAI,CAC3B,gBAAgB,EACd,UAAU,GACV,iBAAiB,GACjB,mBAAmB,GACnB,MAAM,GACN,WAAW,GACX,UAAU,GACV,YAAY,CACf,GAAG;IACF,QAAQ,EAAE,CAAC,mBAAmB,EAAE,kBAAkB,GAAG,iBAAiB,KAAK,IAAI,CAAA;CAChF,CAAA;AAED,eAAO,MAAM,UAAU,GAAI,aAAa,iBAAiB,KAAG,UAgB3D,CAAA;AAED,eAAO,MAAM,kBAAkB,GAC7B,aAAa,iBAAiB,GAAG,UAAU,EAC3C,YAAY,sBAAsB,KACjC,gBA+BF,CAAA;AAID,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBA+EF,CAAA;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,iBAAiB,EAC9B,YAAY,sBAAsB,KACjC,gBAkBF,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,oBAAoB,wBAAwB,EAC5C,YAAY,sBAAsB,KACjC,uBA0CF,CAAA;AAED,eAAO,MAAM,WAAW,GAAI,cAAc,kBAAkB,KAAG,iBAiN9D,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAI,YAAY,uBAAuB,KAAG,sBAsLtE,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ConditionalNode, ExperienceNode, LaunchExperienceNode, OriginNode, StepNode } from '../entities/experience/experience';
|
|
1
|
+
import { ConditionalNode, ExperienceNode, LaunchExperienceNode, OriginNode, StepNode, ActionNode } from '../entities/experience/experience';
|
|
2
2
|
export declare function isConditionNode(node: ExperienceNode): node is ConditionalNode;
|
|
3
3
|
export declare function isStepNode(node: ExperienceNode): node is StepNode;
|
|
4
4
|
export declare function isLaunchExperienceNode(node: ExperienceNode): node is LaunchExperienceNode;
|
|
5
5
|
export declare function isOriginNode(node: ExperienceNode): node is OriginNode;
|
|
6
|
+
export declare function isActionNode(node: ExperienceNode): node is ActionNode;
|
|
6
7
|
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/utils/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,QAAQ,
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../../src/utils/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,QAAQ,EACR,UAAU,EACX,MAAM,mCAAmC,CAAA;AAE1C,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,eAAe,CAE7E;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,QAAQ,CAEjE;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,oBAAoB,CAEzF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,UAAU,CAErE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,IAAI,UAAU,CAErE"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const a=require("effector"),D=require("@withease/factories"),F=require("./supports-YvpQZxbh.cjs"),M=require("./logger-BsmHUUw1.cjs"),ce=require("./object-BbFTsGh3.cjs");function ae(e){return typeof e=="number"&&!isNaN(e)}function T(e){return typeof e=="string"}function w(e){return Array.isArray(e)}function z(e){return e instanceof Promise}function V(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function g(e){if(ae(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function A(e){return`${e}`}const ue={"==":(e,t)=>e==t,"===":(e,t)=>e===t,"!=":(e,t)=>e!=t,"!==":(e,t)=>e!==t,">":(e,t)=>g(e)>g(t),">=":(e,t)=>g(e)>=g(t),"<":(e,t,r)=>{const n=g(e),i=g(t);if(r===void 0)return n<i;const c=g(r);return n<i&&i<c},"<=":(e,t,r)=>{const n=g(e),i=g(t);if(r===void 0)return n<=i;const c=g(r);return n<=i&&i<=c},"!!":async e=>await I(e),"!":async e=>!await I(e),"%":(e,t)=>g(e)%g(t),log:e=>(console.log(e),e),in:(e,t)=>t?T(t)?t.indexOf(A(e))!==-1:w(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(A).join(""),substr:(e,t,r)=>{const n=A(e),i=g(t);if(r===void 0)return n.substr(i);const c=g(r);if(c<0){const o=n.substr(i);return o.substr(0,o.length+c)}return n.substr(i,c)},"+":(...e)=>e.reduce((t,r)=>g(t)+g(r),0),"*":(...e)=>e.reduce((t,r)=>g(t)*g(r),1),"-":(e,t)=>{const r=g(e);return t===void 0?-r:r-g(t)},"/":(e,t)=>g(e)/g(t),min:(...e)=>Math.min(...e.map(g)),max:(...e)=>Math.max(...e.map(g)),merge:(...e)=>e.reduce((t,r)=>w(r)?t.concat(r):t.concat([r]),[]),var(e,t){const r=arguments.length>1?t:null;if(e===""||e==="."||e===null||e===void 0)return this;if(typeof e=="number"&&Array.isArray(this))return e>=0&&e<this.length?this[e]:r;const n=A(e);if(n===""||n===".")return this;const i=n.split(".");let c=this;for(const o of i){if(c==null)return r;if(Array.isArray(c)){const u=parseInt(o,10);isNaN(u)?c=c[o]:c=c[u]}else c=c[o]}return c!==void 0?c:r},async missing(...e){const t=w(e[0])?e[0]:e,r=[];for(const n of t){const i=await d({var:n},this);(i===null||i==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await d({missing:t},this);if(!w(r)||!w(t))return[];const n=r.filter(T);return t.filter(T).length-n.length>=g(e)?[]:n},invoke(e){return typeof e!="function"?null:e()},regexp_matches(e,t){let r=e,n="";if(w(e)){const[c,o]=e;r=c,n=o}return!T(r)||!T(n)?!1:new RegExp(r,n).test(A(t))},throw(e){throw new Error(A(e))}};async function d(e,t){if(!e)return e;if(z(e))return d(await e,t);if(w(e))return Promise.all(e.map(o=>d(o,t)));if(!V(e))return e;const r=fe(e);let n=r?e[r]??[]:[];switch(w(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await I(await d(n[o],t)))return d(n[o+1],t);return n.length%2===1?d(n[n.length-1],t):null;case"and":{let o=null;for(const u of n)if(o=await d(u,t),!await I(o))return o;return o}case"or":{let o=null;for(const u of n)if(o=await d(u,t),await I(o))return o;return o}case"map":{const o=await d(n[0],t);return w(o)?await Promise.all(o.map(u=>d(n[1],u))):[]}case"filter":{const o=await d(n[0],t);return w(o)?(await Promise.all(o.map(async f=>{const S=await I(await d(n[1],f));return{item:f,shouldInclude:S}}))).filter(({shouldInclude:f})=>f).map(({item:f})=>f):[]}case"reduce":{const o=await d(n[0],t);if(!w(o))return n.length>2?await d(n[2],t):null;const u=n[1];let S=n.length>2?await d(n[2],t):null;for(const x of o)S=await d(u,{current:x,accumulator:S});return S}case"all":{const o=await d(n[0],t);if(!w(o)||o.length===0)return!1;for(const u of o)if(!await I(await d(n[1],u)))return!1;return!0}case"some":{const o=await d(n[0],t);if(!w(o))return!1;for(const u of o)if(await I(await d(n[1],u)))return!0;return!1}case"none":{const o=await d(n[0],t);if(!w(o))return!0;for(const u of o)if(await I(await d(n[1],u)))return!1;return!0}case"catch":try{return await d(n[0],t)}catch(o){return V(o)?await d(o,t):n[1]?await d(n[1],o):o instanceof Error?o.message:o}}const i=await Promise.all(n.map(o=>d(o,t))),c=r?ue[r]:void 0;if(!c)throw new Error(`Unrecognized operation ${r}`);return c.apply(t,i)}async function I(e){return z(e)?I(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function fe(e){return Object.keys(e)[0]}function le(e){return!ce.isEmpty(e)}async function X(e,t,r){const n=e.getStateSnapshot(),i=e.predicates.listStore.getState().reduce((u,f)=>({...u,[f.name]:()=>f.predicate(n)}),{}),c=e.features.listStore.getState().reduce((u,f)=>({...u,[f.id]:async()=>{const{bucket:S}=await f.getBucket();return S}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:i,features:c};return await d(t,o)}function pe(e){return!F.supportsWindow()||!F.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}function de(e){if(!F.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:"closed"})}function ge(){return new Promise((e,t)=>{if(!F.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function me(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const O="picked-root",R="picked-target",he="picked-root";function Se(e,t){return[...e,{selector:`${he}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const i=pe(n.selector).filter(c=>!Ee(c,t)&&!J(c,t));return{...n,elements:i}})}function ye(e,t){return e.flatMap(r=>r.elements.map(n=>Ie(n,r.placement,t)))}function we(e,t){e.classList.add(R),e.classList.add(`${R}-${t}`)}function Ee(e,t){return t?e.classList.contains(`${R}-${t}`):e.classList.contains(`${R}`)}function J(e,t){return t?e.classList.contains(`${O}-${t}`):e.classList.contains(O)}function xe(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(O),t.classList.add(`${O}-${e}`),t}function Ie(e,t,r){let n;const i=xe(r);if(e instanceof Document)n=e.body.appendChild(i);else{switch(t){case"replace":e.replaceWith(i);break;case"before":e.before(i);break;case"after":e.after(i);break;case"prepend":e.prepend(i);break;default:e.append(i);break}n=i}return n}function ke(e){return e.type==="conditional"}function _(e){return e.type==="step"}function Ne(e){return e.type==="experience"}function W(e){return e.type==="origin"}const Q=(e,t,r,n,i=new Set)=>i.has(r.id)?[]:(i.add(r.id),_(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const u=e.find(f=>f.id===o.destinationNodeId);return u?Q(e,t,u,!1,i):[]})),be=(e,t,r)=>Q(e,t,r,!0,new Set),Y=(e,t,r,n,i=new Set)=>{if(i.has(r.id))return[-1,-1];i.add(r.id);const c=t.filter(f=>f.sourceNodeId===r.id);if(c.length===0)return[0,0];let o=1/0,u=-1/0;for(const f of c){const S=e.find(k=>k.id===f.destinationNodeId);if(!S)continue;const[x,y]=Y(e,t,S,!1,new Set(i));x!==-1&&(o=Math.min(o,x+1),u=Math.max(u,y+1))}return o===1/0?[-1,-1]:[o,u]},ve=(e,t,r)=>Y(e,t,r,!0,new Set),Z=(e,t,r,n=new Set)=>{if(n.has(r.id))return[-1,-1];if(n.add(r.id),r.type==="origin")return[0,0];const i=t.filter(u=>u.destinationNodeId===r.id);if(i.length===0)return[-1,-1];let c=1/0,o=-1/0;for(const u of i){const f=e.find(y=>y.id===u.sourceNodeId);if(!f)continue;const[S,x]=Z(e,t,f,new Set(n));S!==-1&&(c=Math.min(c,S+1),o=Math.max(o,x+1))}return c===1/0?[-1,-1]:[c,o]},Ae=(e,t,r)=>Z(e,t,r,new Set),ee=e=>e.find(r=>r.type==="origin")||null,j=(e,t,r)=>{if(!e)return ee(t);const n=r.find(c=>c.sourceNodeId===e.id);if(!n)return null;const i=t.find(c=>c.id===n.destinationNodeId);return i||null};async function _e(e,t,r,n){const i=e?"true":"false",c=n.find(o=>o.sourceNodeHandle===i&&o.sourceNodeId===t);return r.find(o=>o.id===(c==null?void 0:c.destinationNodeId))}const q=a.createDomain("experience-instance"),Be=D.createFactory(({client:e,experience:t,target:r})=>{const n=a.createEvent(),i=a.createEvent(),c=a.createEvent(),o=a.createEvent(),u=t.componentStore,f=q.store("transitioning"),S=e.history.entriesStore.map(s=>s.filter(p=>p.experienceId===t.id)),x=S.map(s=>s.filter(p=>_(p.node))),y=S.map(s=>{var p;return((p=s[s.length-1])==null?void 0:p.node)||null}),k=a.combine(t.treeStore,y,({steps:s},p)=>s.find(m=>p&&_(p)&&m.id===p.stepId)||null),P=a.combine(t.treeStore,y,({nodes:s,edges:p},m)=>m?be(s,p,m):[]),l=a.combine(t.treeStore,y,({nodes:s,edges:p},m)=>m?Ae(s,p,m):[-1,-1]),h=a.combine(t.treeStore,y,({nodes:s,edges:p},m)=>m?ve(s,p,m):[-1,-1]),E=q.store(!0),N=a.createApi(E,{open:()=>!0,close:()=>!1,toggle:s=>!s,set:(s,p)=>p});a.sample({source:E,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:t}))}),a.sample({source:E,filter:s=>!s,target:e.eventBus.prepend(()=>({type:"experience_close",experience:t}))});const b=a.createEffect(async()=>{e.history.back({experienceId:t.id})}),B=a.attach({source:t.treeStore,effect:async(s,p)=>{const m=s.nodes.find(v=>_(v)&&v.stepId===p);m&&e.history.push({experienceId:t.id,node:m})}}),G=a.attach({source:y,effect:s=>{}}),$=a.attach({source:t.treeStore,effect:async({nodes:s})=>ee(s)}),C=a.attach({source:t.treeStore,effect:async({nodes:s,edges:p},m)=>j(m,s,p)}),H=a.attach({source:t.treeStore,effect:async({nodes:s,edges:p,conditionals:m},v)=>{if(!v)return;const U=m.find(ie=>ie.id===v.conditionalId);if(!U)return;const oe=v.id,se=await X(e,U.condition);return _e(!!se,oe,s,p)}}),ne=a.createEffect(s=>{if(s)return e.launchExperienceById(s.experienceId)}),K=a.attach({source:[y,t.treeStore],effect:async([s,{nodes:p,edges:m}])=>j(s,p,m)}),L=a.attach({source:[y,t.treeStore],effect:async([s,{nodes:p,edges:m}])=>j(s,p,m)}),re=a.createEffect(s=>{e.history.push({experienceId:t.id,node:s})});return a.split({source:y,match:s=>s?ke(s)?"condition":_(s)?"step":Ne(s)?"launchExperience":W(s)?"origin":"other":"none",cases:{none:$,origin:C,condition:H,step:G,launchExperience:ne,__:a.createEvent()}}),a.sample({clock:[H.doneData,C.doneData,$.doneData,L.doneData,K.doneData],filter:Boolean,target:re}),a.sample({clock:i,target:L}),a.sample({clock:i,source:k,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit",step:s,experience:t}))}),a.sample({clock:L.done,source:k,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_success",step:s,experience:t}))}),a.sample({clock:L.fail,source:k,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_error",step:s,experience:t}))}),a.sample({clock:c,target:b}),a.sample({clock:o,target:B}),a.sample({source:a.combine([H.pending,C.pending,$.pending,L.pending]),fn:s=>s.some(Boolean)?"transitioning":"ready",target:f}),a.sample({clock:G.doneData,source:k,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_enter",step:s,experience:t}))}),a.sample({source:y,clock:n,filter:s=>s?W(s):!0,target:K}),n(),{id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:u,stateStore:f,isOpenStore:E,open:N.open,close:N.close,toggleOpen:N.toggle,setOpen:N.set,treeStore:t.treeStore,currentNodeStore:y,currentStepStore:k,nextReachableStepNodesStore:P,stepsToOriginStore:l,stepsToLeafStore:h,goToNextStep:i,goToPreviousStep:c,goToStepById:o,stepsHistoryStore:x}});function te(e){return D.invoke(Be,e)}const Le=D.createFactory(({client:e})=>{const t=q.store({}),r=a.createEvent(),n=a.createEvent(),i=a.createEvent(),c=a.createApi(t,{register(l,h){const E=[...l[h.experienceId]??[]];return E.push(h),{...l,[h.experienceId]:E}},unregister(l,h){var b;const E=h.experienceId,N=(b=l[E])==null?void 0:b.filter(B=>B!==h);return{...l,[E]:N??[]}}}),o=a.createEffect(({experience:l,target:h})=>te({client:e,experience:l,target:h})),u=a.createEffect(l=>{c.register(l)}),f=a.createEffect(l=>{l.target&&me(l.target,()=>{i(l)})}),S=a.createEffect(l=>{c.unregister(l)}),x=a.createEffect(l=>{const h=l.componentStore.getState();if(!h){M.logger("warn","No app component registered. Skipping init.");return}const E=h.frameworkStore.getState();if(!E){M.logger("error",`No framework registered for component '${h.name}'. Skipping rendering.`);return}const N=l.target;if(!N){M.logger("error",`No target element registered for experience '${l.experienceId}'. Skipping rendering.`);return}const b=de(N);try{E.render(b,h.component,e,l)}catch(B){M.logger("error",B)}});a.sample({clock:r,target:o}),a.sample({clock:i,target:S}),a.sample({clock:o.doneData,target:[u,f,n]}),a.sample({clock:o.doneData,target:e.eventBus.prepend(l=>({type:"experience_initialized",experienceInstance:l}))}),a.sample({clock:n,target:x});function y(l,h){r({experience:l,target:h})}const k=t.map(l=>Object.values(l).flat());function P(l){return t.map(h=>h[l]||[],{skipVoid:!1})}return{spawn:y,getByExperienceId:P,listStore:k}});function Te(e){return D.invoke(Le,e)}exports.createAppHosts=ye;exports.createExperienceInstance=te;exports.createExperienceInstanceIndex=Te;exports.domInteractive=ge;exports.evaluateRuleLogic=X;exports.getTargetElements=Se;exports.isPickedRoot=J;exports.isRulesLogic=le;exports.isStepNode=_;exports.tagTargetElement=we;
|