@picked/client 0.0.46 → 0.0.47-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 +2 -2
- package/dist/cjs/plugins/web-components/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +533 -505
- package/dist/esm/plugins/web-components/index.js +5 -5
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-D_Mwuzb4.cjs → experience-instance-BsXG5XJ4.cjs} +1 -1
- package/dist/{experience-instance-CU_pYPyd.js → experience-instance-fvSEb72i.js} +24 -25
- package/dist/types/entities/experience/experience.d.ts +50 -1
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +2 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/exports.d.ts +1 -1
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/picked.d.ts +37 -4
- package/dist/types/picked.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as o, k as i } from "../../../supports-8YT4QKI7.js";
|
|
2
2
|
const p = () => ({
|
|
3
3
|
name: "web-components",
|
|
4
4
|
setup: (e) => {
|
|
5
|
-
if (!
|
|
5
|
+
if (!o() || !i())
|
|
6
6
|
return;
|
|
7
7
|
const n = "picked-root";
|
|
8
8
|
if (window.customElements.get(n))
|
|
9
9
|
return;
|
|
10
|
-
class
|
|
10
|
+
class s extends HTMLElement {
|
|
11
11
|
connectedCallback() {
|
|
12
12
|
const t = this.getAttribute("experience-id");
|
|
13
|
-
e.isReady && t && e.
|
|
13
|
+
e.isReady && t && e.experiences.launch({ id: t });
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
window.customElements.define(n,
|
|
16
|
+
window.customElements.define(n, s);
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
export {
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
|
|
2
|
-
import { h as F } from "../../experience-instance-
|
|
2
|
+
import { h as F } from "../../experience-instance-fvSEb72i.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("effector"),W=require("@withease/factories"),j=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),xe=require("./object-BbFTsGh3.cjs");function Ne(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function x(e){return Array.isArray(e)}function ue(e){return e instanceof Promise}function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(Ne(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function M(e){return`${e}`}const Ie={"==":(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),c=m(t);if(r===void 0)return n<c;const a=m(r);return n<c&&c<a},"<=":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<=c;const a=m(r);return n<=c&&c<=a},"!!":async e=>await v(e),"!":async e=>!await v(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(M(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(M).join(""),substr:(e,t,r)=>{const n=M(e),c=m(t);if(r===void 0)return n.substr(c);const a=m(r);if(a<0){const o=n.substr(c);return o.substr(0,o.length+a)}return n.substr(c,a)},"+":(...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)=>x(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=M(e);if(n===""||n===".")return this;const c=n.split(".");let a=this;for(const o of c){if(a==null)return r;if(Array.isArray(a)){const f=parseInt(o,10);isNaN(f)?a=a[o]:a=a[f]}else a=a[o]}return a!==void 0?a:r},async missing(...e){const t=x(e[0])?e[0]:e,r=[];for(const n of t){const c=await g({var:n},this);(c===null||c==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!x(r)||!x(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(x(e)){const[a,o]=e;r=a,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(M(t))},throw(e){throw new Error(M(e))}};async function g(e,t){if(!e)return e;if(ue(e))return g(await e,t);if(x(e))return Promise.all(e.map(o=>g(o,t)));if(!ie(e))return e;const r=ke(e);let n=r?e[r]??[]:[];switch(x(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await v(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 f of n)if(o=await g(f,t),!await v(o))return o;return o}case"or":{let o=null;for(const f of n)if(o=await g(f,t),await v(o))return o;return o}case"map":{const o=await g(n[0],t);return x(o)?await Promise.all(o.map(f=>g(n[1],f))):[]}case"filter":{const o=await g(n[0],t);return x(o)?(await Promise.all(o.map(async p=>{const h=await v(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!x(o))return n.length>2?await g(n[2],t):null;const f=n[1];let h=n.length>2?await g(n[2],t):null;for(const k of o)h=await g(f,{current:k,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!x(o)||o.length===0)return!1;for(const f of o)if(!await v(await g(n[1],f)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!x(o))return!1;for(const f of o)if(await v(await g(n[1],f)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!x(o))return!0;for(const f of o)if(await v(await g(n[1],f)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return ie(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const c=await Promise.all(n.map(o=>g(o,t))),a=r?Ie[r]:void 0;if(!a)throw new Error(`Unrecognized operation ${r}`);return a.apply(t,c)}async function v(e){return ue(e)?v(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function ke(e){return Object.keys(e)[0]}function fe(e){return!xe.isEmpty(e)}async function Y(e,t,r){const n=e.getStateSnapshot(),c=e.predicates.listStore.getState().reduce((f,p)=>({...f,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),a=e.features.listStore.getState().reduce((f,p)=>({...f,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),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:c,features:a};return await g(t,o)}function ve(e){return!j.supportsWindow()||!j.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const be="open";function Ae(e){if(!j.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:be})}function Oe(){return new Promise((e,t)=>{if(!j.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Fe(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const q="picked-root",U="picked-target",Be="picked-root";function _e(e,t){return[...e,{selector:`${Be}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const c=ve(n.selector).filter(a=>!Me(a,t)&&!le(a,t));return{...n,elements:c}})}function $e(e,t){return e.flatMap(r=>r.elements.map(n=>De(n,r.placement,t)))}function Te(e,t){e.classList.add(U),e.classList.add(`${U}-${t}`)}function Me(e,t){return t?e.classList.contains(`${U}-${t}`):e.classList.contains(`${U}`)}function le(e,t){return t?e.classList.contains(`${q}-${t}`):e.classList.contains(q)}function Le(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(q),t.classList.add(`${q}-${e}`),t}function De(e,t,r){let n;const c=Le(r);if(e instanceof Document)n=e.body.appendChild(c);else{switch(t){case"replace":e.replaceWith(c);break;case"before":e.before(c);break;case"after":e.after(c);break;case"prepend":e.prepend(c);break;default:e.append(c);break}n=c}return n}function se(e){return e.type==="conditional"}function B(e){return e.type==="step"}function ce(e){return e.type==="experience"}function J(e){return e.type==="origin"}function ae(e){return e.type==="action"}const de=(e,t,r,n,c=new Set)=>c.has(r.id)?[]:(c.add(r.id),B(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const f=e.find(p=>p.id===o.destinationNodeId);return f?de(e,t,f,!1,c):[]})),Re=(e,t,r)=>de(e,t,r,!0,new Set),pe=(e,t,r,n,c=new Set)=>{if(c.has(r.id))return[-1,-1];c.add(r.id);const a=t.filter(p=>p.sourceNodeId===r.id);if(a.length===0)return[0,0];let o=1/0,f=-1/0;for(const p of a){const h=e.find(_=>_.id===p.destinationNodeId);if(!h)continue;const[k,A]=pe(e,t,h,!1,new Set(c));k!==-1&&(o=Math.min(o,k+1),f=Math.max(f,A+1))}return o===1/0?[-1,-1]:[o,f]},Pe=(e,t,r)=>pe(e,t,r,!0,new Set),ge=(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 c=t.filter(f=>f.destinationNodeId===r.id);if(c.length===0)return[-1,-1];let a=1/0,o=-1/0;for(const f of c){const p=e.find(A=>A.id===f.sourceNodeId);if(!p)continue;const[h,k]=ge(e,t,p,new Set(n));h!==-1&&(a=Math.min(a,h+1),o=Math.max(o,k+1))}return a===1/0?[-1,-1]:[a,o]},He=(e,t,r)=>ge(e,t,r,new Set),me=e=>e.find(r=>r.type==="origin")||null,Q=(e,t,r)=>{if(!e)return me(t);const n=r.find(a=>a.sourceNodeId===e.id);if(!n)return null;const c=t.find(a=>a.id===n.destinationNodeId);return c||null};async function Ce(e,t,r,n){const c=e?"true":"false",a=n.find(o=>o.sourceNodeHandle===c&&o.sourceNodeId===t);return r.find(o=>o.id===a?.destinationNodeId)}const Z=s.createDomain("experience-instance"),je=W.createFactory(({client:e,experience:t,target:r,options:n})=>{const c=s.createEvent(),a=s.createEvent(),o=s.createEvent(),f=s.createEvent(),p=s.createEvent(),h=s.createEvent(),k=t.componentStore,A=Z.store("transitioning"),_=e.history.entriesStore.map(i=>i.filter(d=>d.experienceId===t.id)),P=_.map(i=>i.filter(d=>B(d.node))),u=_.map(i=>i.at(-1)?.node||null),S=s.combine(t.treeStore,u,({steps:i},d)=>i.find(l=>d&&B(d)&&l.id===d.stepId)||null),E=s.combine(t.treeStore,P,({steps:i},d)=>{const l=d.at(-2);if(!l||!B(l.node))return null;const y=l.node;return i.find(O=>O.id===y.stepId)||null}),$=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Re(i,d,l):[]),L=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?He(i,d,l):[-1,-1]),G=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Pe(i,d,l):[-1,-1]),T=Z.store(!1),H=s.createApi(T,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,d)=>d}),he=s.createEffect(async()=>{e.history.back({experienceId:t.id})}),ye=s.attach({source:t.treeStore,effect:async(i,d)=>{const l=i.nodes.find(y=>B(y)&&y.stepId===d);l&&e.history.push({experienceId:t.id,node:l})}}),ee=s.attach({source:u,effect:i=>{}}),K=s.attach({source:t.treeStore,effect:async({nodes:i})=>me(i)}),V=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(J(l))return Q(l,i,d)}}),z=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d,conditionals:l},y)=>{if(!se(y))return;const O=l.find(b=>b.id===y.conditionalId);if(!O)return;const I=y.id,w=await Y(e,O.condition);return Ce(!!w,I,i,d)}}),te=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(!ae(l))return;const y=l.action;if(!y){N.logger("warn",`Action node ${l.id} has no action name`);return}const O=e.actions.getByName(y).getState();if(!O){N.logger("warn",`Action '${y}' not registered on client`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}if(typeof O.action!="function"){N.logger("warn",`Action '${y}' is not a function`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}try{N.logger("info",`Executing action: ${y}`),await O.action(y);const I=d.find(b=>b.sourceNodeId===l.id&&b.sourceNodeHandle==="true");if(!I)return N.logger("warn",`No 'true' edge found for action node ${l.id}`),null;const w=i.find(b=>b.id===I.destinationNodeId);return N.logger("info",`Action '${y}' succeeded, moving to node ${w?.id}`),w||null}catch(I){N.logger("warn",`Action '${y}' failed:`,I);const w=d.find(C=>C.sourceNodeId===l.id&&C.sourceNodeHandle==="false");if(!w)return N.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const b=i.find(C=>C.id===w.destinationNodeId);return N.logger("info",`Action '${y}' failed, moving to node ${b?.id}`),b||null}}}),we=s.createEffect(i=>{if(ce(i))return e.launchExperienceById(i.experienceId)}),ne=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),D=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),Ee=s.createEffect(i=>{e.history.push({experienceId:t.id,node:i})}),re=s.attach({source:t.configStore,effect:async({initializeOpenLogic:i})=>n?.initialiseOpen!==void 0?n.initialiseOpen:fe(i)?!!await Y(e,i):i??!1}),F=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:k,stateStore:A,isOpenStore:T,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,fieldsStore:t.fieldsStore,currentNodeStore:u,currentStepStore:S,previousStepStore:E,nextReachableStepNodesStore:$,stepsToOriginStore:L,stepsToLeafStore:G,goToNextStep:a,goToPreviousStep:o,goToStepById:f,stepsHistoryStore:P}),X=s.createEvent(),oe=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:K}),s.sample({clock:X,filter:i=>i!==null,target:oe}),s.split({source:oe,match:i=>se(i)?"condition":B(i)?"step":ce(i)?"launchExperience":J(i)?"origin":ae(i)?"action":"other",cases:{origin:V,condition:z,step:ee,launchExperience:we,action:te,__:s.createEvent()}}),s.sample({clock:[z.doneData,V.doneData,K.doneData,D.doneData,ne.doneData,te.doneData],filter:Boolean,target:Ee}),s.sample({clock:a,target:D}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:F}))}),s.sample({clock:D.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:F}))}),s.sample({clock:D.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:F}))}),s.sample({clock:o,target:he}),s.sample({clock:f,target:ye}),s.sample({source:s.combine([z.pending,V.pending,K.pending,D.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:A}),s.sample({clock:ee.doneData,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:F}))}),s.sample({clock:h,target:re}),s.sample({source:re.doneData,fn:Boolean,target:T}),s.sample({source:u,clock:c,filter:i=>i?J(i):!0,target:ne}),s.sample({source:T,filter:Boolean,target:c}),s.sample({source:T,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:F}))}),s.sample({source:T,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:F}))}),s.sample({clock:p,target:[h]}),p(),F});function Se(e){return W.invoke(je,e)}const qe=W.createFactory(({client:e})=>{const t=Z.store({}),r=s.createEvent(),n=s.createEvent(),c=s.createEvent(),a=s.createApi(t,{register(u,S){const E=[...u[S.experienceId]??[]];return E.push(S),{...u,[S.experienceId]:E}},unregister(u,S){const E=S.experienceId,$=u[E]?.filter(L=>L!==S);return{...u,[E]:$??[]}}}),o=s.createEffect(({experience:u,target:S,options:E})=>Se({client:e,experience:u,target:S,options:E})),f=s.createEffect(u=>{a.register(u)}),p=s.createEffect(u=>{u.target&&Fe(u.target,()=>{c(u)})}),h=s.createEffect(u=>{a.unregister(u)}),k=s.createEffect(u=>{const S=u.componentStore.getState();if(!S){N.logger("warn","No app component registered. Skipping init.");return}const E=S.frameworkStore.getState();if(!E){N.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const $=u.target;if(!$){N.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const L=Ae($);try{E.render(L,S.component,e,u)}catch(G){N.logger("error",G)}});s.sample({clock:r,target:o}),s.sample({clock:c,target:h}),s.sample({clock:o.doneData,target:[f,p,n]}),s.sample({clock:o.doneData,target:e.eventBus.prepend(u=>({type:"experience_initialize",experience:u}))}),s.sample({clock:n,target:k});function A(u,S,E){r({experience:u,target:S,options:E})}const _=t.map(u=>Object.values(u).flat());function P(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:A,getByExperienceId:P,listStore:_}});function Ue(e){return W.invoke(qe,e)}exports.createAppHosts=$e;exports.createExperienceInstance=Se;exports.createExperienceInstanceIndex=Ue;exports.domInteractive=Oe;exports.evaluateRuleLogic=Y;exports.getTargetElements=_e;exports.isPickedRoot=le;exports.isRulesLogic=fe;exports.isStepNode=B;exports.tagTargetElement=Te;
|
|
1
|
+
"use strict";const s=require("effector"),W=require("@withease/factories"),j=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),xe=require("./object-BbFTsGh3.cjs");function Ne(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function x(e){return Array.isArray(e)}function ue(e){return e instanceof Promise}function ie(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(Ne(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function M(e){return`${e}`}const Ie={"==":(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),c=m(t);if(r===void 0)return n<c;const a=m(r);return n<c&&c<a},"<=":(e,t,r)=>{const n=m(e),c=m(t);if(r===void 0)return n<=c;const a=m(r);return n<=c&&c<=a},"!!":async e=>await v(e),"!":async e=>!await v(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(M(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(M).join(""),substr:(e,t,r)=>{const n=M(e),c=m(t);if(r===void 0)return n.substr(c);const a=m(r);if(a<0){const o=n.substr(c);return o.substr(0,o.length+a)}return n.substr(c,a)},"+":(...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)=>x(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=M(e);if(n===""||n===".")return this;const c=n.split(".");let a=this;for(const o of c){if(a==null)return r;if(Array.isArray(a)){const f=parseInt(o,10);isNaN(f)?a=a[o]:a=a[f]}else a=a[o]}return a!==void 0?a:r},async missing(...e){const t=x(e[0])?e[0]:e,r=[];for(const n of t){const c=await g({var:n},this);(c===null||c==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!x(r)||!x(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(...e){const[t,...r]=e;return typeof t!="function"?null:Reflect.apply(t,null,r)},regexp_matches(e,t){let r=e,n="";if(x(e)){const[a,o]=e;r=a,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(M(t))},throw(e){throw new Error(M(e))}};async function g(e,t){if(!e)return e;if(ue(e))return g(await e,t);if(x(e))return Promise.all(e.map(o=>g(o,t)));if(!ie(e))return e;const r=ke(e);let n=r?e[r]??[]:[];switch(x(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await v(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 f of n)if(o=await g(f,t),!await v(o))return o;return o}case"or":{let o=null;for(const f of n)if(o=await g(f,t),await v(o))return o;return o}case"map":{const o=await g(n[0],t);return x(o)?await Promise.all(o.map(f=>g(n[1],f))):[]}case"filter":{const o=await g(n[0],t);return x(o)?(await Promise.all(o.map(async p=>{const h=await v(await g(n[1],p));return{item:p,shouldInclude:h}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!x(o))return n.length>2?await g(n[2],t):null;const f=n[1];let h=n.length>2?await g(n[2],t):null;for(const k of o)h=await g(f,{current:k,accumulator:h});return h}case"all":{const o=await g(n[0],t);if(!x(o)||o.length===0)return!1;for(const f of o)if(!await v(await g(n[1],f)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!x(o))return!1;for(const f of o)if(await v(await g(n[1],f)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!x(o))return!0;for(const f of o)if(await v(await g(n[1],f)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return ie(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const c=await Promise.all(n.map(o=>g(o,t))),a=r?Ie[r]:void 0;if(!a)throw new Error(`Unrecognized operation ${r}`);return a.apply(t,c)}async function v(e){return ue(e)?v(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function ke(e){return Object.keys(e)[0]}function fe(e){return!xe.isEmpty(e)}async function Y(e,t,r){const n=e.getStateSnapshot(),c=e.predicates.listStore.getState().reduce((f,p)=>({...f,[p.name]:(...h)=>p.predicate({...n,args:h})}),{}),a=e.features.listStore.getState().reduce((f,p)=>({...f,[p.id]:async()=>{const{bucket:h}=await p.getBucket();return h}}),{}),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:c,features:a};return await g(t,o)}function ve(e){return!j.supportsWindow()||!j.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const be="open";function Ae(e){if(!j.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:be})}function Oe(){return new Promise((e,t)=>{if(!j.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Fe(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const q="picked-root",U="picked-target",Be="picked-root";function _e(e,t){return[...e,{selector:`${Be}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const c=ve(n.selector).filter(a=>!Me(a,t)&&!le(a,t));return{...n,elements:c}})}function $e(e,t){return e.flatMap(r=>r.elements.map(n=>De(n,r.placement,t)))}function Te(e,t){e.classList.add(U),e.classList.add(`${U}-${t}`)}function Me(e,t){return t?e.classList.contains(`${U}-${t}`):e.classList.contains(`${U}`)}function le(e,t){return t?e.classList.contains(`${q}-${t}`):e.classList.contains(q)}function Le(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(q),t.classList.add(`${q}-${e}`),t}function De(e,t,r){let n;const c=Le(r);if(e instanceof Document)n=e.body.appendChild(c);else{switch(t){case"replace":e.replaceWith(c);break;case"before":e.before(c);break;case"after":e.after(c);break;case"prepend":e.prepend(c);break;default:e.append(c);break}n=c}return n}function se(e){return e.type==="conditional"}function B(e){return e.type==="step"}function ce(e){return e.type==="experience"}function J(e){return e.type==="origin"}function ae(e){return e.type==="action"}const de=(e,t,r,n,c=new Set)=>c.has(r.id)?[]:(c.add(r.id),B(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const f=e.find(p=>p.id===o.destinationNodeId);return f?de(e,t,f,!1,c):[]})),Re=(e,t,r)=>de(e,t,r,!0,new Set),pe=(e,t,r,n,c=new Set)=>{if(c.has(r.id))return[-1,-1];c.add(r.id);const a=t.filter(p=>p.sourceNodeId===r.id);if(a.length===0)return[0,0];let o=1/0,f=-1/0;for(const p of a){const h=e.find(_=>_.id===p.destinationNodeId);if(!h)continue;const[k,A]=pe(e,t,h,!1,new Set(c));k!==-1&&(o=Math.min(o,k+1),f=Math.max(f,A+1))}return o===1/0?[-1,-1]:[o,f]},Pe=(e,t,r)=>pe(e,t,r,!0,new Set),ge=(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 c=t.filter(f=>f.destinationNodeId===r.id);if(c.length===0)return[-1,-1];let a=1/0,o=-1/0;for(const f of c){const p=e.find(A=>A.id===f.sourceNodeId);if(!p)continue;const[h,k]=ge(e,t,p,new Set(n));h!==-1&&(a=Math.min(a,h+1),o=Math.max(o,k+1))}return a===1/0?[-1,-1]:[a,o]},He=(e,t,r)=>ge(e,t,r,new Set),me=e=>e.find(r=>r.type==="origin")||null,Q=(e,t,r)=>{if(!e)return me(t);const n=r.find(a=>a.sourceNodeId===e.id);if(!n)return null;const c=t.find(a=>a.id===n.destinationNodeId);return c||null};async function Ce(e,t,r,n){const c=e?"true":"false",a=n.find(o=>o.sourceNodeHandle===c&&o.sourceNodeId===t);return r.find(o=>o.id===a?.destinationNodeId)}const Z=s.createDomain("experience-instance"),je=W.createFactory(({client:e,experience:t,target:r,options:n})=>{const c=s.createEvent(),a=s.createEvent(),o=s.createEvent(),f=s.createEvent(),p=s.createEvent(),h=s.createEvent(),k=t.componentStore,A=Z.store("transitioning"),_=e.history.entriesStore.map(i=>i.filter(d=>d.experienceId===t.id)),P=_.map(i=>i.filter(d=>B(d.node))),u=_.map(i=>i.at(-1)?.node||null),S=s.combine(t.treeStore,u,({steps:i},d)=>i.find(l=>d&&B(d)&&l.id===d.stepId)||null),E=s.combine(t.treeStore,P,({steps:i},d)=>{const l=d.at(-2);if(!l||!B(l.node))return null;const y=l.node;return i.find(O=>O.id===y.stepId)||null}),$=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Re(i,d,l):[]),L=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?He(i,d,l):[-1,-1]),G=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Pe(i,d,l):[-1,-1]),T=Z.store(!1),H=s.createApi(T,{open:()=>!0,close:()=>!1,toggle:i=>!i,set:(i,d)=>d}),he=s.createEffect(async()=>{e.history.back({experienceId:t.id})}),ye=s.attach({source:t.treeStore,effect:async(i,d)=>{const l=i.nodes.find(y=>B(y)&&y.stepId===d);l&&e.history.push({experienceId:t.id,node:l})}}),ee=s.attach({source:u,effect:i=>{}}),K=s.attach({source:t.treeStore,effect:async({nodes:i})=>me(i)}),V=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(J(l))return Q(l,i,d)}}),z=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d,conditionals:l},y)=>{if(!se(y))return;const O=l.find(b=>b.id===y.conditionalId);if(!O)return;const I=y.id,w=await Y(e,O.condition);return Ce(!!w,I,i,d)}}),te=s.attach({source:t.treeStore,effect:async({nodes:i,edges:d},l)=>{if(!ae(l))return;const y=l.action;if(!y){N.logger("warn",`Action node ${l.id} has no action name`);return}const O=e.actions.getByName(y).getState();if(!O){N.logger("warn",`Action '${y}' not registered on client`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}if(typeof O.action!="function"){N.logger("warn",`Action '${y}' is not a function`);const I=d.find(w=>w.sourceNodeId===l.id&&w.sourceNodeHandle==="false");return I?i.find(w=>w.id===I.destinationNodeId):null}try{N.logger("info",`Executing action: ${y}`),await O.action(y);const I=d.find(b=>b.sourceNodeId===l.id&&b.sourceNodeHandle==="true");if(!I)return N.logger("warn",`No 'true' edge found for action node ${l.id}`),null;const w=i.find(b=>b.id===I.destinationNodeId);return N.logger("info",`Action '${y}' succeeded, moving to node ${w?.id}`),w||null}catch(I){N.logger("warn",`Action '${y}' failed:`,I);const w=d.find(C=>C.sourceNodeId===l.id&&C.sourceNodeHandle==="false");if(!w)return N.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const b=i.find(C=>C.id===w.destinationNodeId);return N.logger("info",`Action '${y}' failed, moving to node ${b?.id}`),b||null}}}),we=s.createEffect(i=>{ce(i)&&e.experiences.launch({id:i.experienceId})}),ne=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),D=s.attach({source:[u,t.treeStore],effect:async([i,{nodes:d,edges:l}])=>Q(i,d,l)}),Ee=s.createEffect(i=>{e.history.push({experienceId:t.id,node:i})}),re=s.attach({source:t.configStore,effect:async({initializeOpenLogic:i})=>n?.initialiseOpen!==void 0?n.initialiseOpen:fe(i)?!!await Y(e,i):i??!1}),F=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:k,stateStore:A,isOpenStore:T,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,fieldsStore:t.fieldsStore,currentNodeStore:u,currentStepStore:S,previousStepStore:E,nextReachableStepNodesStore:$,stepsToOriginStore:L,stepsToLeafStore:G,goToNextStep:a,goToPreviousStep:o,goToStepById:f,stepsHistoryStore:P}),X=s.createEvent(),oe=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:K}),s.sample({clock:X,filter:i=>i!==null,target:oe}),s.split({source:oe,match:i=>se(i)?"condition":B(i)?"step":ce(i)?"launchExperience":J(i)?"origin":ae(i)?"action":"other",cases:{origin:V,condition:z,step:ee,launchExperience:we,action:te,__:s.createEvent()}}),s.sample({clock:[z.doneData,V.doneData,K.doneData,D.doneData,ne.doneData,te.doneData],filter:Boolean,target:Ee}),s.sample({clock:a,target:D}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:F}))}),s.sample({clock:D.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:F}))}),s.sample({clock:D.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:F}))}),s.sample({clock:o,target:he}),s.sample({clock:f,target:ye}),s.sample({source:s.combine([z.pending,V.pending,K.pending,D.pending]),fn:i=>i.some(Boolean)?"transitioning":"ready",target:A}),s.sample({clock:ee.doneData,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_enter",step:i,experience:F}))}),s.sample({clock:h,target:re}),s.sample({source:re.doneData,fn:Boolean,target:T}),s.sample({source:u,clock:c,filter:i=>i?J(i):!0,target:ne}),s.sample({source:T,filter:Boolean,target:c}),s.sample({source:T,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:F}))}),s.sample({source:T,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:F}))}),s.sample({clock:p,target:[h]}),p(),F});function Se(e){return W.invoke(je,e)}const qe=W.createFactory(({client:e})=>{const t=Z.store({}),r=s.createEvent(),n=s.createEvent(),c=s.createEvent(),a=s.createApi(t,{register(u,S){const E=[...u[S.experienceId]??[]];return E.push(S),{...u,[S.experienceId]:E}},unregister(u,S){const E=S.experienceId,$=u[E]?.filter(L=>L!==S);return{...u,[E]:$??[]}}}),o=s.createEffect(({experience:u,target:S,options:E})=>Se({client:e,experience:u,target:S,options:E})),f=s.createEffect(u=>{a.register(u)}),p=s.createEffect(u=>{u.target&&Fe(u.target,()=>{c(u)})}),h=s.createEffect(u=>{a.unregister(u)}),k=s.createEffect(u=>{const S=u.componentStore.getState();if(!S){N.logger("warn","No app component registered. Skipping init.");return}const E=S.frameworkStore.getState();if(!E){N.logger("error",`No framework registered for component '${S.name}'. Skipping rendering.`);return}const $=u.target;if(!$){N.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const L=Ae($);try{E.render(L,S.component,e,u)}catch(G){N.logger("error",G)}});s.sample({clock:r,target:o}),s.sample({clock:c,target:h}),s.sample({clock:o.doneData,target:[f,p,n]}),s.sample({clock:o.doneData,target:e.eventBus.prepend(u=>({type:"experience_initialize",experience:u}))}),s.sample({clock:n,target:k});function A(u,S,E){r({experience:u,target:S,options:E})}const _=t.map(u=>Object.values(u).flat());function P(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:A,getByExperienceId:P,listStore:_}});function Ue(e){return W.invoke(qe,e)}exports.createAppHosts=$e;exports.createExperienceInstance=Se;exports.createExperienceInstanceIndex=Ue;exports.domInteractive=Oe;exports.evaluateRuleLogic=Y;exports.getTargetElements=_e;exports.isPickedRoot=le;exports.isRulesLogic=fe;exports.isStepNode=B;exports.tagTargetElement=Te;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createDomain as kt, createEvent as k, combine as D, createApi as lt, createEffect as _, attach as O, sample as m, split as bt } from "effector";
|
|
2
2
|
import { createFactory as dt, invoke as pt } from "@withease/factories";
|
|
3
|
-
import {
|
|
3
|
+
import { a as vt, s as gt, j as At } from "./supports-8YT4QKI7.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
5
5
|
import { i as Ot } from "./object-JwZ58NOH.js";
|
|
6
|
-
function
|
|
6
|
+
function Ft(t) {
|
|
7
7
|
return typeof t == "number" && !isNaN(t);
|
|
8
8
|
}
|
|
9
9
|
function j(t) {
|
|
@@ -19,14 +19,14 @@ function st(t) {
|
|
|
19
19
|
return typeof t == "object" && t !== null && !Array.isArray(t) && Object.keys(t).length === 1;
|
|
20
20
|
}
|
|
21
21
|
function g(t) {
|
|
22
|
-
if (
|
|
22
|
+
if (Ft(t)) return t;
|
|
23
23
|
const e = parseFloat(`${t}`);
|
|
24
24
|
return isNaN(e) ? 0 : e;
|
|
25
25
|
}
|
|
26
26
|
function R(t) {
|
|
27
27
|
return `${t}`;
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const Bt = {
|
|
30
30
|
// eslint-disable-next-line eqeqeq
|
|
31
31
|
"==": (t, e) => t == e,
|
|
32
32
|
"===": (t, e) => t === e,
|
|
@@ -220,7 +220,7 @@ async function p(t, e) {
|
|
|
220
220
|
return st(o) ? await p(o, e) : n[1] ? await p(n[1], o) : o instanceof Error ? o.message : o;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
const s = await Promise.all(n.map((o) => p(o, e))), a = r ?
|
|
223
|
+
const s = await Promise.all(n.map((o) => p(o, e))), a = r ? Bt[r] : void 0;
|
|
224
224
|
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
225
225
|
return a.apply(e, s);
|
|
226
226
|
}
|
|
@@ -263,13 +263,13 @@ async function at(t, e, r) {
|
|
|
263
263
|
return await p(e, o);
|
|
264
264
|
}
|
|
265
265
|
function Mt(t) {
|
|
266
|
-
return !
|
|
266
|
+
return !vt() || !gt() ? [] : Array.from(window.document.querySelectorAll(t)).filter(
|
|
267
267
|
(e) => e instanceof HTMLElement
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
const Tt = "open";
|
|
271
271
|
function Lt(t) {
|
|
272
|
-
if (!
|
|
272
|
+
if (!At())
|
|
273
273
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
274
274
|
return t.attachShadow({ mode: Tt });
|
|
275
275
|
}
|
|
@@ -377,14 +377,14 @@ const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
377
377
|
for (const d of a) {
|
|
378
378
|
const y = t.find((M) => M.id === d.destinationNodeId);
|
|
379
379
|
if (!y) continue;
|
|
380
|
-
const [b,
|
|
380
|
+
const [b, F] = yt(
|
|
381
381
|
t,
|
|
382
382
|
e,
|
|
383
383
|
y,
|
|
384
384
|
!1,
|
|
385
385
|
new Set(s)
|
|
386
386
|
);
|
|
387
|
-
b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u,
|
|
387
|
+
b !== -1 && (o = Math.min(o, b + 1), u = Math.max(u, F + 1));
|
|
388
388
|
}
|
|
389
389
|
return o === 1 / 0 ? [-1, -1] : [o, u];
|
|
390
390
|
}, Wt = (t, e, r) => yt(t, e, r, !0, /* @__PURE__ */ new Set()), ht = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
@@ -394,7 +394,7 @@ const St = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
394
394
|
if (s.length === 0) return [-1, -1];
|
|
395
395
|
let a = 1 / 0, o = -1 / 0;
|
|
396
396
|
for (const u of s) {
|
|
397
|
-
const d = t.find((
|
|
397
|
+
const d = t.find((F) => F.id === u.sourceNodeId);
|
|
398
398
|
if (!d) continue;
|
|
399
399
|
const [y, b] = ht(
|
|
400
400
|
t,
|
|
@@ -427,7 +427,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
427
427
|
target: r,
|
|
428
428
|
options: n
|
|
429
429
|
}) => {
|
|
430
|
-
const s = k(), a = k(), o = k(), u = k(), d = k(), y = k(), b = e.componentStore,
|
|
430
|
+
const s = k(), a = k(), o = k(), u = k(), d = k(), y = k(), b = e.componentStore, F = tt.store("transitioning"), M = t.history.entriesStore.map((i) => i.filter((l) => l.experienceId === e.id)), U = M.map((i) => i.filter((l) => P(l.node))), c = M.map((i) => i.at(-1)?.node || null), S = D(
|
|
431
431
|
e.treeStore,
|
|
432
432
|
c,
|
|
433
433
|
({ steps: i }, l) => i.find((f) => l && P(l) && f.id === l.stepId) || null
|
|
@@ -439,7 +439,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
439
439
|
if (!f || !P(f.node))
|
|
440
440
|
return null;
|
|
441
441
|
const h = f.node;
|
|
442
|
-
return i.find((
|
|
442
|
+
return i.find((B) => B.id === h.stepId) || null;
|
|
443
443
|
}
|
|
444
444
|
), T = D(
|
|
445
445
|
e.treeStore,
|
|
@@ -484,10 +484,10 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
484
484
|
effect: async ({ nodes: i, edges: l, conditionals: f }, h) => {
|
|
485
485
|
if (!ct(h))
|
|
486
486
|
return;
|
|
487
|
-
const
|
|
488
|
-
if (!
|
|
487
|
+
const B = f.find((A) => A.id === h.conditionalId);
|
|
488
|
+
if (!B)
|
|
489
489
|
return;
|
|
490
|
-
const E = h.id, w = await at(t,
|
|
490
|
+
const E = h.id, w = await at(t, B.condition);
|
|
491
491
|
return Kt(!!w, E, i, l);
|
|
492
492
|
}
|
|
493
493
|
}), nt = O({
|
|
@@ -500,15 +500,15 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
500
500
|
I("warn", `Action node ${f.id} has no action name`);
|
|
501
501
|
return;
|
|
502
502
|
}
|
|
503
|
-
const
|
|
504
|
-
if (!
|
|
503
|
+
const B = t.actions.getByName(h).getState();
|
|
504
|
+
if (!B) {
|
|
505
505
|
I("warn", `Action '${h}' not registered on client`);
|
|
506
506
|
const E = l.find(
|
|
507
507
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
508
508
|
);
|
|
509
509
|
return E ? i.find((w) => w.id === E.destinationNodeId) : null;
|
|
510
510
|
}
|
|
511
|
-
if (typeof
|
|
511
|
+
if (typeof B.action != "function") {
|
|
512
512
|
I("warn", `Action '${h}' is not a function`);
|
|
513
513
|
const E = l.find(
|
|
514
514
|
(w) => w.sourceNodeId === f.id && w.sourceNodeHandle === "false"
|
|
@@ -516,7 +516,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
516
516
|
return E ? i.find((w) => w.id === E.destinationNodeId) : null;
|
|
517
517
|
}
|
|
518
518
|
try {
|
|
519
|
-
I("info", `Executing action: ${h}`), await
|
|
519
|
+
I("info", `Executing action: ${h}`), await B.action(h);
|
|
520
520
|
const E = l.find(
|
|
521
521
|
(A) => A.sourceNodeId === f.id && A.sourceNodeHandle === "true"
|
|
522
522
|
);
|
|
@@ -536,8 +536,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
}), It = _((i) => {
|
|
539
|
-
|
|
540
|
-
return t.launchExperienceById(i.experienceId);
|
|
539
|
+
ut(i) && t.experiences.launch({ id: i.experienceId });
|
|
541
540
|
}), rt = O({
|
|
542
541
|
source: [c, e.treeStore],
|
|
543
542
|
effect: async ([i, { nodes: l, edges: f }]) => Z(i, l, f)
|
|
@@ -557,7 +556,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
557
556
|
target: r,
|
|
558
557
|
componentStore: b,
|
|
559
558
|
// state
|
|
560
|
-
stateStore:
|
|
559
|
+
stateStore: F,
|
|
561
560
|
// open close
|
|
562
561
|
isOpenStore: L,
|
|
563
562
|
open: W.open,
|
|
@@ -653,7 +652,7 @@ const tt = kt("experience-instance"), Vt = dt(
|
|
|
653
652
|
H.pending
|
|
654
653
|
]),
|
|
655
654
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
656
|
-
target:
|
|
655
|
+
target: F
|
|
657
656
|
}), m({
|
|
658
657
|
clock: et.doneData,
|
|
659
658
|
source: S,
|
|
@@ -790,7 +789,7 @@ const zt = dt(({ client: t }) => {
|
|
|
790
789
|
clock: n,
|
|
791
790
|
target: b
|
|
792
791
|
});
|
|
793
|
-
function
|
|
792
|
+
function F(c, S, x) {
|
|
794
793
|
r({ experience: c, target: S, options: x });
|
|
795
794
|
}
|
|
796
795
|
const M = e.map((c) => Object.values(c).flat());
|
|
@@ -798,7 +797,7 @@ const zt = dt(({ client: t }) => {
|
|
|
798
797
|
return e.map((S) => S[c] || [], { skipVoid: !1 });
|
|
799
798
|
}
|
|
800
799
|
return {
|
|
801
|
-
spawn:
|
|
800
|
+
spawn: F,
|
|
802
801
|
getByExperienceId: U,
|
|
803
802
|
listStore: M
|
|
804
803
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AdaptedComponent } from '../component/component';
|
|
2
|
-
import {
|
|
2
|
+
import { Picked } from '../../picked';
|
|
3
3
|
import { LogicRule, LogicValue } from '../../logic-engine';
|
|
4
4
|
import { Field } from '../field/field';
|
|
5
5
|
export type ExperiencesListStore = ReturnType<typeof createExperienceIndex>;
|
|
@@ -34,10 +34,48 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
34
34
|
}>;
|
|
35
35
|
};
|
|
36
36
|
export declare function createExperience<T extends Parameters<typeof createExperienceFactory>[0]>(params: T): ReturnType<typeof createExperienceFactory>;
|
|
37
|
+
/** Options for launching an experience. */
|
|
38
|
+
export interface LaunchExperienceOptions {
|
|
39
|
+
/** When true, the experience will be opened immediately after initialization. */
|
|
40
|
+
initialiseOpen?: boolean;
|
|
41
|
+
/** When true, the experience's condition logic is skipped and it is launched unconditionally. */
|
|
42
|
+
bypassCondition?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** Options for opening an experience. Same as {@link LaunchExperienceOptions} without `initialiseOpen`. */
|
|
45
|
+
export type OpenExperienceOptions = Omit<LaunchExperienceOptions, 'initialiseOpen'>;
|
|
37
46
|
declare const createExperienceIndexFactory: ({ client }: {
|
|
38
47
|
client: Picked;
|
|
39
48
|
}) => {
|
|
49
|
+
/** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
|
|
40
50
|
register: (experience: Experience) => void;
|
|
51
|
+
/** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
|
|
52
|
+
get: (id: Experience["id"]) => import('effector').Store<{
|
|
53
|
+
id: string;
|
|
54
|
+
configStore: import('effector').Store<{
|
|
55
|
+
name: string;
|
|
56
|
+
decisionLogic: string | number | boolean | import('../../logic-engine').LogicArray | import('../../logic-engine').LogicObject | (() => LogicValue) | Promise<import('../../logic-engine').SyncLogicValue> | undefined;
|
|
57
|
+
targetSelectors: ExperienceTarget[];
|
|
58
|
+
initializeOpenLogic: LogicValue | LogicRule;
|
|
59
|
+
}>;
|
|
60
|
+
treeStore: import('effector').Store<{
|
|
61
|
+
steps: ExperienceStep[];
|
|
62
|
+
nodes: ExperienceNode[];
|
|
63
|
+
edges: ExperienceEdge[];
|
|
64
|
+
conditionals: ExperienceConditional[];
|
|
65
|
+
}>;
|
|
66
|
+
fieldsStore: import('effector').Store<Field[]>;
|
|
67
|
+
componentStore: import('effector').Store<{
|
|
68
|
+
name: string;
|
|
69
|
+
component: AdaptedComponent<string, unknown>;
|
|
70
|
+
frameworkStore: import('effector').Store<import('../..').Framework | undefined>;
|
|
71
|
+
} | undefined>;
|
|
72
|
+
actions: ExperienceAction[];
|
|
73
|
+
merge: import('effector').EventCallable<{
|
|
74
|
+
experience: Partial<Experience>;
|
|
75
|
+
strategy: "override";
|
|
76
|
+
}>;
|
|
77
|
+
} | undefined>;
|
|
78
|
+
/** @deprecated Use `experiences.get(id)` instead. */
|
|
41
79
|
getById: (id: Experience["id"]) => import('effector').Store<{
|
|
42
80
|
id: string;
|
|
43
81
|
configStore: import('effector').Store<{
|
|
@@ -64,6 +102,17 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
64
102
|
strategy: "override";
|
|
65
103
|
}>;
|
|
66
104
|
} | undefined>;
|
|
105
|
+
/** Effector effect that launches an experience by ID, creating instances for each DOM target. */
|
|
106
|
+
launch: import('effector').Effect<{
|
|
107
|
+
id: string;
|
|
108
|
+
options?: LaunchExperienceOptions;
|
|
109
|
+
}, void, Error>;
|
|
110
|
+
/** Effector effect that opens an experience's existing instances, or launches it with `initialiseOpen` if none exist. */
|
|
111
|
+
open: import('effector').Effect<{
|
|
112
|
+
id: string;
|
|
113
|
+
options?: OpenExperienceOptions;
|
|
114
|
+
}, void, Error>;
|
|
115
|
+
/** Derived store containing all registered experiences as an array. */
|
|
67
116
|
listStore: import('effector').Store<{
|
|
68
117
|
id: string;
|
|
69
118
|
configStore: import('effector').Store<{
|
|
@@ -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,
|
|
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;AAG1C,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAE/D,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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
2
|
-
import { Experience, ExperienceNode, ExperienceStep, ExperienceStore, ExperienceTarget } from '../experience/experience';
|
|
3
|
-
import {
|
|
2
|
+
import { Experience, ExperienceNode, ExperienceStep, ExperienceStore, ExperienceTarget, LaunchExperienceOptions } from '../experience/experience';
|
|
3
|
+
import { Picked } from '../../picked';
|
|
4
4
|
import { HistoryEntry } from '../history/history';
|
|
5
5
|
export interface ExperienceInstance {
|
|
6
6
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"experience-instance.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience-instance/experience-instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAGlB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAiB1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAItD,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAA;IACV,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAA;IAC9B,WAAW,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IAC3C,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;IAC/B,cAAc,EAAE,eAAe,CAAC,gBAAgB,CAAC,CAAA;IACjD,UAAU,EAAE,KAAK,CAAC,eAAe,GAAG,OAAO,CAAC,CAAA;IAC5C,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IAC3B,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;IACzB,KAAK,EAAE,a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+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;wBA+I1E,eAAe,UACnB,WAAW,YACT,uBAAuB;4BASJ,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/exports.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CreateClientOptions } from './client';
|
|
2
2
|
import { Picked } from './picked';
|
|
3
|
-
export type { LaunchExperienceOptions } from './picked';
|
|
4
3
|
export { isPickedRoot } from './utils/dom';
|
|
5
4
|
export * from './utils/supports';
|
|
6
5
|
export * from './utils/storage';
|
|
@@ -16,4 +15,5 @@ export { lazyComponent, isLazyLoader } from './entities/component/lazyComponent'
|
|
|
16
15
|
* @returns The initialized Picked client instance
|
|
17
16
|
*/
|
|
18
17
|
export declare const createClient: (options: CreateClientOptions) => Picked;
|
|
18
|
+
export type { LaunchExperienceOptions, OpenExperienceOptions, } from './entities/experience/experience';
|
|
19
19
|
//# sourceMappingURL=exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,
|
|
1
|
+
{"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,mBAAmB,iBAAiB,CAAA;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAA;AAEhF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,mBAAmB,WAIxD,CAAA;AAED,YAAY,EACV,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,kCAAkC,CAAA"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Experience } from './entities/experience/experience';
|
|
1
|
+
import { Experience, LaunchExperienceOptions } from './entities/experience/experience';
|
|
2
2
|
import { Plugin, PluginConfigIndex } from './entities/plugin/plugin';
|
|
3
3
|
import { CreateClientOptions } from './client';
|
|
4
4
|
import { AdaptableComponents, AdaptedComponent } from './entities/component/component';
|
|
@@ -11,9 +11,6 @@ import { Field } from './entities/field/field';
|
|
|
11
11
|
import { Action } from './entities/action/action';
|
|
12
12
|
import { SessionStore } from './utils/user-session';
|
|
13
13
|
import { LogicRule } from './logic-engine';
|
|
14
|
-
export interface LaunchExperienceOptions {
|
|
15
|
-
initialiseOpen?: boolean;
|
|
16
|
-
}
|
|
17
14
|
export declare class Picked {
|
|
18
15
|
static readonly logger: (level: "log" | "warn" | "info" | "error", ...args: Parameters<Console["log"]>) => void;
|
|
19
16
|
private readonly options;
|
|
@@ -68,6 +65,32 @@ export declare class Picked {
|
|
|
68
65
|
};
|
|
69
66
|
readonly experiences: {
|
|
70
67
|
register: (experience: Experience) => void;
|
|
68
|
+
get: (id: Experience["id"]) => import('effector').Store<{
|
|
69
|
+
id: string;
|
|
70
|
+
configStore: import('effector').Store<{
|
|
71
|
+
name: string;
|
|
72
|
+
decisionLogic: string | number | boolean | import('./logic-engine').LogicArray | import('./logic-engine').LogicObject | (() => import('./logic-engine').LogicValue) | Promise<import('./logic-engine').SyncLogicValue> | undefined;
|
|
73
|
+
targetSelectors: import('.').ExperienceTarget[];
|
|
74
|
+
initializeOpenLogic: import('./logic-engine').LogicValue | LogicRule;
|
|
75
|
+
}>;
|
|
76
|
+
treeStore: import('effector').Store<{
|
|
77
|
+
steps: import('.').ExperienceStep[];
|
|
78
|
+
nodes: import('.').ExperienceNode[];
|
|
79
|
+
edges: import('.').ExperienceEdge[];
|
|
80
|
+
conditionals: import('.').ExperienceConditional[];
|
|
81
|
+
}>;
|
|
82
|
+
fieldsStore: import('effector').Store<Field[]>;
|
|
83
|
+
componentStore: import('effector').Store<{
|
|
84
|
+
name: string;
|
|
85
|
+
component: AdaptedComponent<string, unknown>;
|
|
86
|
+
frameworkStore: import('effector').Store<Framework | undefined>;
|
|
87
|
+
} | undefined>;
|
|
88
|
+
actions: import('.').ExperienceAction[];
|
|
89
|
+
merge: import('effector').EventCallable<{
|
|
90
|
+
experience: Partial<Experience>;
|
|
91
|
+
strategy: "override";
|
|
92
|
+
}>;
|
|
93
|
+
} | undefined>;
|
|
71
94
|
getById: (id: Experience["id"]) => import('effector').Store<{
|
|
72
95
|
id: string;
|
|
73
96
|
configStore: import('effector').Store<{
|
|
@@ -94,6 +117,14 @@ export declare class Picked {
|
|
|
94
117
|
strategy: "override";
|
|
95
118
|
}>;
|
|
96
119
|
} | undefined>;
|
|
120
|
+
launch: import('effector').Effect<{
|
|
121
|
+
id: string;
|
|
122
|
+
options?: LaunchExperienceOptions;
|
|
123
|
+
}, void, Error>;
|
|
124
|
+
open: import('effector').Effect<{
|
|
125
|
+
id: string;
|
|
126
|
+
options?: import('./exports').OpenExperienceOptions;
|
|
127
|
+
}, void, Error>;
|
|
97
128
|
listStore: import('effector').Store<{
|
|
98
129
|
id: string;
|
|
99
130
|
configStore: import('effector').Store<{
|
|
@@ -193,7 +224,9 @@ export declare class Picked {
|
|
|
193
224
|
registerAction: (name: string, action: Action) => void;
|
|
194
225
|
registerExperience: (experience: Experience) => void;
|
|
195
226
|
getStateSnapshot: () => StateSnapshot;
|
|
227
|
+
/** @deprecated Use `client.experiences.launch({ id: experienceId })` instead. */
|
|
196
228
|
launchExperienceById: (experienceId: string, options?: LaunchExperienceOptions) => Promise<void>;
|
|
229
|
+
/** @deprecated Use `client.experiences.open({ id: experienceId })` instead. */
|
|
197
230
|
openExperienceById: (experienceId: string) => Promise<void>;
|
|
198
231
|
private runPluginStartHooks;
|
|
199
232
|
private evaluateGate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,UAAU,EAEf,KAAK,uBAAuB,EAE7B,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;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