@picked/client 0.0.1-dev.1773729274420 → 0.0.1-dev.1773804563218
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/{api-47L967ES.cjs → api-C90ugp6M.cjs} +1 -1
- package/dist/{api-DuHeVrL4.js → api-CQ1Lb-dB.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +738 -742
- package/dist/esm/plugins/create-experience/index.js +359 -286
- package/dist/esm/plugins/dynamic-experiences/index.js +146 -80
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +46 -51
- package/dist/esm/plugins/single-page-app/index.js +24 -24
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DTyL1fNb.js → experience-instance-8P1fJuPC.js} +306 -312
- package/dist/experience-instance-Bi3-1tP5.cjs +1 -0
- package/dist/object-BbFTsGh3.cjs +1 -0
- package/dist/{object-CJssU1Pm.js → object-JwZ58NOH.js} +1 -1
- package/dist/storage-Be5xWNPC.cjs +1 -0
- package/dist/{storage-B2d81EOI.js → storage-Co_LbKr_.js} +30 -35
- package/dist/types/entities/action/action.d.ts +2 -5
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/condition/condition.d.ts +17 -0
- package/dist/types/entities/condition/condition.d.ts.map +1 -0
- package/dist/types/entities/experience/experience.d.ts +46 -31
- 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/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +23 -52
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts +9 -7
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +20 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +8 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +41 -32
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +70 -43
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/index.d.ts +1 -1
- package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +20 -5
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +46 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +1 -2
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +3 -0
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +2 -2
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +1 -0
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +1 -2
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/key.d.ts +12 -0
- package/dist/types/utils/key.d.ts.map +1 -0
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +3 -3
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +2 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +8 -0
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +2 -16
- package/dist/experience-instance-BX0aqKsC.cjs +0 -1
- package/dist/object-mwaxtjLG.cjs +0 -1
- package/dist/storage-58NoTSsc.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const s=require("effector"),U=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 P(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 L(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?P(t)?t.indexOf(L(e))!==-1:x(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(L).join(""),substr:(e,t,r)=>{const n=L(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=L(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(P);return t.filter(P).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!P(r)||!P(n)?!1:new RegExp(r,n).test(L(t))},throw(e){throw new Error(L(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",K="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(K),e.classList.add(`${K}-${t}`)}function Me(e,t){return t?e.classList.contains(`${K}-${t}`):e.classList.contains(`${K}`)}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 _(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),_(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]},Ce=(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 He(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=U.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)),C=$.map(i=>i.filter(d=>_(d.node))),u=$.map(i=>i.at(-1)?.node||null),S=s.combine(e.steps.listStore,u,(i,d)=>i.find(l=>d&&_(d)&&l.key===d.stepKey)||null),E=s.combine(e.steps.listStore,C,(i,d)=>{const l=d.at(-2);if(!l||!_(l.node))return null;const y=l.node;return i.find(O=>O.key===y.stepKey)||null}),T=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Re(i,d,l):[]),D=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Ce(i,d,l):[-1,-1]),W=s.combine(t.treeStore,u,({nodes:i,edges:d},l)=>l?Pe(i,d,l):[-1,-1]),M=Z.store(!1),H=s.createApi(M,{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=>_(y)&&y.stepKey===d);l&&e.history.push({experienceId:t.id,node:l})}}),ee=s.attach({source:u,effect:i=>{}}),G=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,conditions:l},y)=>{if(!se(y))return;const O=y.conditionId??y.conditionalId,w=e.conditions.listStore.getState().find(F=>F.id===O)?.condition??l.find(F=>F.id===O)?.condition;if(!w)return;const b=await Y(e,w);return He(!!b,y.id,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(F=>F.sourceNodeId===l.id&&F.sourceNodeHandle==="false");if(!w)return N.logger("warn",`No 'false' edge found for action node ${l.id}`),null;const b=i.find(F=>F.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)}),R=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}),B=Object.freeze({id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:k,stateStore:A,isOpenStore:M,open:H.open,close:H.close,toggleOpen:H.toggle,setOpen:H.set,treeStore:t.treeStore,currentNodeStore:u,currentStepStore:S,previousStepStore:E,nextReachableStepNodesStore:T,stepsToOriginStore:D,stepsToLeafStore:W,goToNextStep:a,goToPreviousStep:o,goToStepById:f,stepsHistoryStore:C}),X=s.createEvent(),oe=s.createEvent();return s.sample({source:u,target:X}),s.sample({clock:X,filter:i=>i===null,target:G}),s.sample({clock:X,filter:i=>i!==null,target:oe}),s.split({source:oe,match:i=>se(i)?"condition":_(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,G.doneData,R.doneData,ne.doneData,te.doneData],filter:Boolean,target:Ee}),s.sample({clock:a,target:R}),s.sample({clock:a,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit",step:i,experience:B}))}),s.sample({clock:R.done,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_success",step:i,experience:B}))}),s.sample({clock:R.fail,source:S,filter:Boolean,target:e.eventBus.prepend(i=>({type:"step_submit_error",step:i,experience:B}))}),s.sample({clock:o,target:he}),s.sample({clock:f,target:ye}),s.sample({source:s.combine([z.pending,V.pending,G.pending,R.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:B}))}),s.sample({clock:h,target:re}),s.sample({source:re.doneData,fn:Boolean,target:M}),s.sample({source:u,clock:c,filter:i=>i?J(i):!0,target:ne}),s.sample({source:M,filter:Boolean,target:c}),s.sample({source:M,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:B}))}),s.sample({source:M,filter:i=>!i,target:e.eventBus.prepend(()=>({type:"experience_close",experience:B}))}),s.sample({clock:p,target:[h]}),p(),B});function Se(e){return U.invoke(je,e)}const qe=U.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,T=u[E]?.filter(D=>D!==S);return{...u,[E]:T??[]}}}),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 T=u.target;if(!T){N.logger("error",`No target element registered for experience '${u.experienceId}'. Skipping rendering.`);return}const D=Ae(T);try{E.render(D,S.component,e,u)}catch(W){N.logger("error",W)}});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 C(u){return t.map(S=>S[u]||[],{skipVoid:!1})}return{spawn:A,getByExperienceId:C,listStore:$}});function Ke(e){return U.invoke(qe,e)}exports.createAppHosts=$e;exports.createExperienceInstance=Se;exports.createExperienceInstanceIndex=Ke;exports.domInteractive=Oe;exports.evaluateRuleLogic=Y;exports.getTargetElements=_e;exports.isPickedRoot=le;exports.isRulesLogic=fe;exports.isStepNode=_;exports.tagTargetElement=Te;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function c(t,e,n){if(!(e in t))return;const o=t[e];if(typeof o!="function")throw new Error(`Expected '${String(e)}' to be a function`);const r=n(o);p(r,o),t[e]=r}function i(t,e,n){Object.defineProperty(t,e,{enumerable:!1,value:n,writable:!0,configurable:!0})}function p(t,e){const n=e.prototype||{};t.prototype=e.prototype=n,i(t,"__picked_original",e)}function u(t){return t===void 0||typeof t=="object"&&t!==null&&t.constructor===Object&&Object.keys(t).length===0}exports.isEmpty=u;exports.patchMethod=c;
|
|
@@ -17,7 +17,7 @@ function c(t, e, n) {
|
|
|
17
17
|
}
|
|
18
18
|
function i(t, e) {
|
|
19
19
|
const n = e.prototype || {};
|
|
20
|
-
|
|
20
|
+
t.prototype = e.prototype = n, c(t, "__picked_original", e);
|
|
21
21
|
}
|
|
22
22
|
function u(t) {
|
|
23
23
|
return t === void 0 || typeof t == "object" && t !== null && t.constructor === Object && Object.keys(t).length === 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=e=>btoa([...e].map(t=>String.fromCharCode(t.charCodeAt(0)^7)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function w(e,t="global",o){let r="pckd";if(t==="experience"){if(!o)throw new Error("Experience instance is required to scope storage to an experience");r=`${r}:${o.experienceId}`}return{_:`${r}:${p(e)}`,scope:t}}const a=new Map;function m(e,t){const o=a.get(e._);o&&o.forEach(r=>r(e,t))}function S(e,t,o,r){const i=o==="local"?localStorage:sessionStorage,c=typeof t!="string"?JSON.stringify(t):t;if(i.setItem(e._,c),typeof r=="number"){const s=new Date(Date.now()+r).toISOString();i.setItem(`${e._}:expires-at`,s)}m(e,o)}function b(e,t){const o=t==="local"?localStorage:sessionStorage;o.removeItem(e._),o.removeItem(`${e._}:expires-at`),m(e,t)}function f(e,t,o,r){const i=t==="local"?localStorage:sessionStorage;function c(s){s.storageArea===i&&s.key===e._&&r(o(e))}function l(s,n){n===t&&r(o(s))}return window.addEventListener("storage",c),a.has(e._)||a.set(e._,new Set),a.get(e._).add(l),function(){window.removeEventListener("storage",c);const n=a.get(e._);n&&(n.delete(l),n.size===0&&a.delete(e._))}}function g(e,t){const o=t==="local"?localStorage:sessionStorage,r=o.getItem(e._),i=o.getItem(`${e._}:expires-at`),c=(n,u)=>S(e,n,t,u),l=()=>b(e,t),s=n=>f(e,t,u=>g(u,t),n);if(i){const n=new Date,u=new Date(i);if(n>u)return b(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:c,remove:l,subscribe:s}}return{isSet(){return r!==null},text(){return r},json(){return r?JSON.parse(r):null},boolean(){return r?r==="true":null},set:c,remove:l,subscribe:s}}const d={get(e){return g(e,"session")},set(e,t,o){S(e,t,"session",o)},remove(e){b(e,"session")},subscribe(e,t){return f(e,"session",this.get,t)}},_={get(e){return g(e,"local")},set(e,t,o){S(e,t,"local",o)},remove(e){b(e,"local")},subscribe(e,t){return f(e,"local",this.get,t)}};exports.createStorageKey=w;exports.localStore=_;exports.sessionStore=d;exports.subscribe=f;
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
const m = (e) => (
|
|
2
|
-
// eslint-disable-next-line no-bitwise -- XOR cipher for cookie consent banner detection avoidance
|
|
3
|
-
btoa([...e].map((t) => String.fromCharCode(t.charCodeAt(0) ^ 7)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "")
|
|
4
|
-
);
|
|
1
|
+
const m = (e) => btoa([...e].map((t) => String.fromCharCode(t.charCodeAt(0) ^ 7)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
5
2
|
function w(e, t = "global", o) {
|
|
6
|
-
let
|
|
3
|
+
let r = "pckd";
|
|
7
4
|
if (t === "experience") {
|
|
8
5
|
if (!o)
|
|
9
6
|
throw new Error("Experience instance is required to scope storage to an experience");
|
|
10
|
-
|
|
7
|
+
r = `${r}:${o.experienceId}`;
|
|
11
8
|
}
|
|
12
|
-
return { _: `${
|
|
9
|
+
return { _: `${r}:${m(e)}`, scope: t };
|
|
13
10
|
}
|
|
14
|
-
const
|
|
11
|
+
const l = /* @__PURE__ */ new Map();
|
|
15
12
|
function p(e, t) {
|
|
16
|
-
const o =
|
|
17
|
-
o && o.forEach((
|
|
13
|
+
const o = l.get(e._);
|
|
14
|
+
o && o.forEach((r) => r(e, t));
|
|
18
15
|
}
|
|
19
|
-
function b(e, t, o,
|
|
16
|
+
function b(e, t, o, r) {
|
|
20
17
|
const i = o === "local" ? localStorage : sessionStorage, c = typeof t != "string" ? JSON.stringify(t) : t;
|
|
21
|
-
if (i.setItem(e._, c), typeof
|
|
22
|
-
const
|
|
23
|
-
i.setItem(`${e._}:expires-at`,
|
|
18
|
+
if (i.setItem(e._, c), typeof r == "number") {
|
|
19
|
+
const s = new Date(Date.now() + r).toISOString();
|
|
20
|
+
i.setItem(`${e._}:expires-at`, s);
|
|
24
21
|
}
|
|
25
22
|
p(e, o);
|
|
26
23
|
}
|
|
@@ -28,53 +25,51 @@ function f(e, t) {
|
|
|
28
25
|
const o = t === "local" ? localStorage : sessionStorage;
|
|
29
26
|
o.removeItem(e._), o.removeItem(`${e._}:expires-at`), p(e, t);
|
|
30
27
|
}
|
|
31
|
-
function S(e, t, o,
|
|
28
|
+
function S(e, t, o, r) {
|
|
32
29
|
const i = t === "local" ? localStorage : sessionStorage;
|
|
33
|
-
function c(
|
|
34
|
-
|
|
30
|
+
function c(s) {
|
|
31
|
+
s.storageArea === i && s.key === e._ && r(o(e));
|
|
35
32
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
33
|
+
function a(s, n) {
|
|
34
|
+
n === t && r(o(s));
|
|
38
35
|
}
|
|
39
|
-
window.addEventListener("storage", c),
|
|
40
|
-
const a = u.get(e._);
|
|
41
|
-
return a && a.add(l), function() {
|
|
36
|
+
return window.addEventListener("storage", c), l.has(e._) || l.set(e._, /* @__PURE__ */ new Set()), l.get(e._).add(a), function() {
|
|
42
37
|
window.removeEventListener("storage", c);
|
|
43
|
-
const
|
|
44
|
-
|
|
38
|
+
const n = l.get(e._);
|
|
39
|
+
n && (n.delete(a), n.size === 0 && l.delete(e._));
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
function g(e, t) {
|
|
48
|
-
const o = t === "local" ? localStorage : sessionStorage,
|
|
43
|
+
const o = t === "local" ? localStorage : sessionStorage, r = o.getItem(e._), i = o.getItem(`${e._}:expires-at`), c = (n, u) => b(e, n, t, u), a = () => f(e, t), s = (n) => S(e, t, (u) => g(u, t), n);
|
|
49
44
|
if (i) {
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
45
|
+
const n = /* @__PURE__ */ new Date(), u = new Date(i);
|
|
46
|
+
if (n > u)
|
|
52
47
|
return f(e, t), {
|
|
53
48
|
isSet: () => !1,
|
|
54
49
|
text: () => null,
|
|
55
50
|
json: () => null,
|
|
56
51
|
boolean: () => null,
|
|
57
52
|
set: c,
|
|
58
|
-
remove:
|
|
59
|
-
subscribe:
|
|
53
|
+
remove: a,
|
|
54
|
+
subscribe: s
|
|
60
55
|
};
|
|
61
56
|
}
|
|
62
57
|
return {
|
|
63
58
|
isSet() {
|
|
64
|
-
return
|
|
59
|
+
return r !== null;
|
|
65
60
|
},
|
|
66
61
|
text() {
|
|
67
|
-
return
|
|
62
|
+
return r;
|
|
68
63
|
},
|
|
69
64
|
json() {
|
|
70
|
-
return
|
|
65
|
+
return r ? JSON.parse(r) : null;
|
|
71
66
|
},
|
|
72
67
|
boolean() {
|
|
73
|
-
return
|
|
68
|
+
return r ? r === "true" : null;
|
|
74
69
|
},
|
|
75
70
|
set: c,
|
|
76
|
-
remove:
|
|
77
|
-
subscribe:
|
|
71
|
+
remove: a,
|
|
72
|
+
subscribe: s
|
|
78
73
|
};
|
|
79
74
|
}
|
|
80
75
|
const d = {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { Store } from 'effector';
|
|
2
|
-
import { Picked } from '../../picked';
|
|
3
2
|
export type Action = <T = void>(params?: T) => void;
|
|
4
3
|
export type ActionsStore = ReturnType<typeof createActionIndexFactory>;
|
|
5
4
|
export interface ActionIndexItem {
|
|
6
5
|
name: string;
|
|
7
6
|
action: Action;
|
|
8
7
|
}
|
|
9
|
-
declare const createActionIndexFactory: (
|
|
10
|
-
client: Picked;
|
|
11
|
-
}) => {
|
|
8
|
+
declare const createActionIndexFactory: () => {
|
|
12
9
|
register: (name: string, action: Action) => void;
|
|
13
10
|
getByName: (name: string) => Store<ActionIndexItem | undefined>;
|
|
14
11
|
listStore: Store<ActionIndexItem[]>;
|
|
15
12
|
getEvokableAction: (actionName: string) => Store<(<T = void>(params?: T) => void) | undefined>;
|
|
16
13
|
};
|
|
17
|
-
export declare function createActionIndex
|
|
14
|
+
export declare function createActionIndex(): ReturnType<typeof createActionIndexFactory>;
|
|
18
15
|
export declare const setupAction: (name: string, action: Action, actions: ActionsStore) => void;
|
|
19
16
|
export {};
|
|
20
17
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/entities/action/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAG9D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAA;AACnD,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;;oCAIQ,MAAM,KAAG,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAgBnG,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LogicRule } from '../../logic-engine';
|
|
2
|
+
export type ConditionsStore = ReturnType<typeof createConditionIndex>;
|
|
3
|
+
export interface Condition {
|
|
4
|
+
id: string;
|
|
5
|
+
key: string;
|
|
6
|
+
name: string;
|
|
7
|
+
condition: LogicRule;
|
|
8
|
+
}
|
|
9
|
+
declare const createConditionIndexFactory: () => {
|
|
10
|
+
register: (condition: Condition) => void;
|
|
11
|
+
getById: (id: Condition["id"]) => import('effector').Store<Condition | null>;
|
|
12
|
+
getByKey: (key: Condition["key"]) => import('effector').Store<Condition | null>;
|
|
13
|
+
listStore: import('effector').Store<Condition[]>;
|
|
14
|
+
};
|
|
15
|
+
export declare function createConditionIndex(): ReturnType<typeof createConditionIndexFactory>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../../../src/entities/condition/condition.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAIrE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,SAAS,CAAA;CACrB;AAGD,QAAA,MAAM,2BAA2B;0BAcF,SAAS,KAAG,IAAI;kBAQxB,SAAS,CAAC,IAAI,CAAC;oBAIb,SAAS,CAAC,KAAK,CAAC;;CAYvC,CAAA;AAEF,wBAAgB,oBAAoB,IAAI,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAErF"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AdaptedComponent } from '../component/component';
|
|
2
2
|
import { Picked } from '../../picked';
|
|
3
3
|
import { LogicRule, LogicValue } from '../../logic-engine';
|
|
4
|
-
import { Field } from '../field/field';
|
|
5
4
|
export type ExperiencesListStore = ReturnType<typeof createExperienceIndex>;
|
|
6
5
|
export type ExperienceStore = ReturnType<typeof createExperience>;
|
|
7
6
|
declare const createExperienceFactory: ({ client, experience }: {
|
|
@@ -9,6 +8,8 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
9
8
|
experience: Experience;
|
|
10
9
|
}) => {
|
|
11
10
|
id: string;
|
|
11
|
+
key: string | undefined;
|
|
12
|
+
name: string;
|
|
12
13
|
configStore: import('effector').Store<{
|
|
13
14
|
name: string;
|
|
14
15
|
decisionLogic: LogicValue | LogicRule;
|
|
@@ -16,12 +17,11 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
16
17
|
initializeOpenLogic: LogicValue | LogicRule;
|
|
17
18
|
}>;
|
|
18
19
|
treeStore: import('effector').Store<{
|
|
19
|
-
steps:
|
|
20
|
+
steps: string[];
|
|
20
21
|
nodes: ExperienceNode[];
|
|
21
22
|
edges: ExperienceEdge[];
|
|
22
|
-
|
|
23
|
+
conditions: ExperienceCondition[];
|
|
23
24
|
}>;
|
|
24
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
25
25
|
componentStore: import('effector').Store<{
|
|
26
26
|
name: string;
|
|
27
27
|
component: AdaptedComponent<string, unknown>;
|
|
@@ -35,6 +35,7 @@ declare const createExperienceFactory: ({ client, experience }: {
|
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Creates an Effector store for a single experience.
|
|
38
|
+
*
|
|
38
39
|
* @param params - The client instance and experience data.
|
|
39
40
|
* @returns An experience store with config, tree, fields, and component sub-stores.
|
|
40
41
|
* @example
|
|
@@ -57,9 +58,11 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
57
58
|
}) => {
|
|
58
59
|
/** Registers an experience in the index. If an experience with the same ID already exists, it is merged. */
|
|
59
60
|
register: (experience: Experience) => void;
|
|
60
|
-
/** Returns a derived store for an experience by its ID. The store value is `undefined` when no match exists. */
|
|
61
|
-
get: (
|
|
61
|
+
/** Returns a derived store for an experience by its ID or key. The store value is `undefined` when no match exists. */
|
|
62
|
+
get: (idOrKey: string) => import('effector').Store<{
|
|
62
63
|
id: string;
|
|
64
|
+
key: string | undefined;
|
|
65
|
+
name: string;
|
|
63
66
|
configStore: import('effector').Store<{
|
|
64
67
|
name: string;
|
|
65
68
|
decisionLogic: LogicValue | LogicRule;
|
|
@@ -67,12 +70,11 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
67
70
|
initializeOpenLogic: LogicValue | LogicRule;
|
|
68
71
|
}>;
|
|
69
72
|
treeStore: import('effector').Store<{
|
|
70
|
-
steps:
|
|
73
|
+
steps: string[];
|
|
71
74
|
nodes: ExperienceNode[];
|
|
72
75
|
edges: ExperienceEdge[];
|
|
73
|
-
|
|
76
|
+
conditions: ExperienceCondition[];
|
|
74
77
|
}>;
|
|
75
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
76
78
|
componentStore: import('effector').Store<{
|
|
77
79
|
name: string;
|
|
78
80
|
component: AdaptedComponent<string, unknown>;
|
|
@@ -85,8 +87,10 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
85
87
|
}>;
|
|
86
88
|
} | undefined>;
|
|
87
89
|
/** @deprecated Use `experiences.get(id)` instead. */
|
|
88
|
-
getById: (
|
|
90
|
+
getById: (idOrKey: string) => import('effector').Store<{
|
|
89
91
|
id: string;
|
|
92
|
+
key: string | undefined;
|
|
93
|
+
name: string;
|
|
90
94
|
configStore: import('effector').Store<{
|
|
91
95
|
name: string;
|
|
92
96
|
decisionLogic: LogicValue | LogicRule;
|
|
@@ -94,12 +98,11 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
94
98
|
initializeOpenLogic: LogicValue | LogicRule;
|
|
95
99
|
}>;
|
|
96
100
|
treeStore: import('effector').Store<{
|
|
97
|
-
steps:
|
|
101
|
+
steps: string[];
|
|
98
102
|
nodes: ExperienceNode[];
|
|
99
103
|
edges: ExperienceEdge[];
|
|
100
|
-
|
|
104
|
+
conditions: ExperienceCondition[];
|
|
101
105
|
}>;
|
|
102
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
103
106
|
componentStore: import('effector').Store<{
|
|
104
107
|
name: string;
|
|
105
108
|
component: AdaptedComponent<string, unknown>;
|
|
@@ -111,7 +114,7 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
111
114
|
strategy: "override";
|
|
112
115
|
}>;
|
|
113
116
|
} | undefined>;
|
|
114
|
-
/** Effector effect that launches an experience by ID, creating instances for each DOM target. */
|
|
117
|
+
/** Effector effect that launches an experience by ID or key, creating instances for each DOM target. */
|
|
115
118
|
launch: import('effector').Effect<{
|
|
116
119
|
id: string;
|
|
117
120
|
options?: LaunchExperienceOptions;
|
|
@@ -124,6 +127,8 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
124
127
|
/** Derived store containing all registered experiences as an array. */
|
|
125
128
|
listStore: import('effector').Store<{
|
|
126
129
|
id: string;
|
|
130
|
+
key: string | undefined;
|
|
131
|
+
name: string;
|
|
127
132
|
configStore: import('effector').Store<{
|
|
128
133
|
name: string;
|
|
129
134
|
decisionLogic: LogicValue | LogicRule;
|
|
@@ -131,12 +136,11 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
131
136
|
initializeOpenLogic: LogicValue | LogicRule;
|
|
132
137
|
}>;
|
|
133
138
|
treeStore: import('effector').Store<{
|
|
134
|
-
steps:
|
|
139
|
+
steps: string[];
|
|
135
140
|
nodes: ExperienceNode[];
|
|
136
141
|
edges: ExperienceEdge[];
|
|
137
|
-
|
|
142
|
+
conditions: ExperienceCondition[];
|
|
138
143
|
}>;
|
|
139
|
-
fieldsStore: import('effector').Store<Field[]>;
|
|
140
144
|
componentStore: import('effector').Store<{
|
|
141
145
|
name: string;
|
|
142
146
|
component: AdaptedComponent<string, unknown>;
|
|
@@ -151,6 +155,7 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
151
155
|
};
|
|
152
156
|
/**
|
|
153
157
|
* Creates an Effector-based index for registering and retrieving experiences.
|
|
158
|
+
*
|
|
154
159
|
* @param params - The client instance.
|
|
155
160
|
* @returns An experience index with register, get, launch, and open methods.
|
|
156
161
|
* @example
|
|
@@ -159,12 +164,7 @@ declare const createExperienceIndexFactory: ({ client }: {
|
|
|
159
164
|
* ```
|
|
160
165
|
*/
|
|
161
166
|
export declare function createExperienceIndex<T extends Parameters<typeof createExperienceIndexFactory>[0]>(params: T): ReturnType<typeof createExperienceIndexFactory>;
|
|
162
|
-
export
|
|
163
|
-
id: string;
|
|
164
|
-
label: string;
|
|
165
|
-
fieldIds: string[];
|
|
166
|
-
}
|
|
167
|
-
export type ExperienceNode = StepNode | ConditionalNode | LaunchExperienceNode | OriginNode | ActionNode;
|
|
167
|
+
export type ExperienceNode = StepNode | ConditionNode | LaunchExperienceNode | OriginNode | ActionNode;
|
|
168
168
|
export interface ExperienceAction {
|
|
169
169
|
id: string;
|
|
170
170
|
action: string;
|
|
@@ -179,13 +179,19 @@ export interface BaseNode {
|
|
|
179
179
|
}
|
|
180
180
|
export interface StepNode extends BaseNode {
|
|
181
181
|
type: 'step';
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
stepKey: string;
|
|
183
|
+
name?: string;
|
|
184
|
+
/** @deprecated Use `name` instead. Populated for backwards compatibility. */
|
|
185
|
+
label?: string;
|
|
184
186
|
}
|
|
185
|
-
export interface
|
|
187
|
+
export interface ConditionNode extends BaseNode {
|
|
186
188
|
type: 'conditional';
|
|
187
|
-
|
|
189
|
+
conditionId?: string;
|
|
190
|
+
/** @deprecated Use `conditionId` instead. */
|
|
191
|
+
conditionalId?: string;
|
|
188
192
|
}
|
|
193
|
+
/** @deprecated Use {@link ConditionNode} instead. */
|
|
194
|
+
export type ConditionalNode = ConditionNode;
|
|
189
195
|
export interface LaunchExperienceNode extends BaseNode {
|
|
190
196
|
type: 'experience';
|
|
191
197
|
experienceId: string;
|
|
@@ -199,39 +205,48 @@ export interface ExperienceEdge {
|
|
|
199
205
|
destinationNodeId: string;
|
|
200
206
|
sourceNodeHandle?: string;
|
|
201
207
|
}
|
|
202
|
-
export interface
|
|
208
|
+
export interface ExperienceCondition {
|
|
203
209
|
id: string;
|
|
204
210
|
label?: string;
|
|
205
211
|
condition: LogicRule;
|
|
206
212
|
}
|
|
213
|
+
/** @deprecated Use {@link ExperienceCondition} instead. */
|
|
214
|
+
export type ExperienceConditional = ExperienceCondition;
|
|
207
215
|
export interface ExperienceTarget {
|
|
208
216
|
selector: string;
|
|
209
217
|
placement: 'replace' | 'append' | 'prepend' | 'before' | 'after';
|
|
210
218
|
}
|
|
211
219
|
export interface Experience {
|
|
212
220
|
id: string;
|
|
221
|
+
key?: string;
|
|
213
222
|
name: string;
|
|
214
223
|
componentName?: string;
|
|
215
224
|
component?: AdaptedComponent;
|
|
216
|
-
|
|
225
|
+
/** Inline condition definitions for this experience's flow nodes. */
|
|
226
|
+
conditions?: ExperienceCondition[];
|
|
227
|
+
/** @deprecated Use `conditions` instead. */
|
|
228
|
+
conditionals?: ExperienceCondition[];
|
|
217
229
|
initializeOpen?: LogicRule | LogicValue;
|
|
218
230
|
actions?: ExperienceAction[];
|
|
231
|
+
/** Decision logic that controls whether this experience is initialised. */
|
|
219
232
|
condition?: LogicRule | LogicValue;
|
|
220
233
|
edges: ExperienceEdge[];
|
|
221
234
|
nodes: ExperienceNode[];
|
|
222
|
-
|
|
223
|
-
steps:
|
|
235
|
+
/** Step IDs referencing steps in the global step registry (client.steps). */
|
|
236
|
+
steps: string[];
|
|
224
237
|
targets: ExperienceTarget[];
|
|
225
238
|
}
|
|
226
239
|
export declare const setupExperience: (experience: Experience, experienceStore: ExperiencesListStore) => void;
|
|
227
240
|
/**
|
|
228
241
|
* Initializes an experience for each target that exists in the DOM.
|
|
242
|
+
*
|
|
229
243
|
* @param client - The Picked client instance.
|
|
230
244
|
* @param experience - The experience store to initialise.
|
|
231
245
|
*/
|
|
232
246
|
export declare const initialiseExperience: (client: Picked, experience: ExperienceStore, options?: LaunchExperienceOptions) => void;
|
|
233
247
|
/**
|
|
234
248
|
* Conditionally initializes experiences.
|
|
249
|
+
*
|
|
235
250
|
* @param client - The Picked client instance.
|
|
236
251
|
*/
|
|
237
252
|
export declare const initialiseExperiences: (client: Picked) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAGA,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;
|
|
1
|
+
{"version":3,"file":"experience.d.ts","sourceRoot":"","sources":["../../../../src/entities/experience/experience.ts"],"names":[],"mappings":"AAGA,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;AAG/D,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;;;;;;;;;;;;;;;;;;;;;;;oBAIjB,OAAO,CAAC,UAAU,CAAC;kBAAY,UAAU;;CAgE5F,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,uBAAuB,CAA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S,GAAG,QAAQ,GAAG,OAAO,CAAA;CACjE;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,qEAAqE;IACrE,UAAU,CAAC,EAAE,mBAAmB,EAAE,CAAA;IAClC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAA;IACpC,cAAc,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IACvC,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC5B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;IAClC,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,KAAK,EAAE,cAAc,EAAE,CAAA;IACvB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,gBAAgB,EAAE,CAAA;CAC5B;AAED,eAAO,MAAM,eAAe,GAC1B,YAAY,UAAU,EACtB,iBAAiB,oBAAoB,KACpC,IAEF,CAAA;AAED;;;;;GAKG;AAEH,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,MAAM,EACd,YAAY,eAAe,EAC3B,UAAU,uBAAuB,SAkBlC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,kBASzD,CAAA;AAmBD,eAAO,MAAM,0BAA0B,GACrC,QAAQ,MAAM,EACd,YAAY,eAAe,KAC1B,OAAO,CAAC,OAAO,CAiCjB,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EventCallable, Store } from 'effector';
|
|
2
|
-
import { Experience, ExperienceNode,
|
|
2
|
+
import { Experience, ExperienceNode, ExperienceStore, ExperienceTarget, LaunchExperienceOptions } from '../experience/experience';
|
|
3
|
+
import { ExperienceStep } from '../step/step';
|
|
3
4
|
import { Picked } from '../../picked';
|
|
4
5
|
import { HistoryEntry } from '../history/history';
|
|
5
6
|
export interface ExperienceInstance {
|
|
@@ -15,7 +16,6 @@ export interface ExperienceInstance {
|
|
|
15
16
|
toggleOpen: EventCallable<void>;
|
|
16
17
|
setOpen: EventCallable<boolean>;
|
|
17
18
|
treeStore: ExperienceStore['treeStore'];
|
|
18
|
-
fieldsStore: ExperienceStore['fieldsStore'];
|
|
19
19
|
currentNodeStore: Store<ExperienceNode | null>;
|
|
20
20
|
currentStepStore: Store<ExperienceStep | null>;
|
|
21
21
|
previousStepStore: Store<ExperienceStep | null>;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClD,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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A;AAK3E,QAAA,MAAM,yBAAyB,eAA8B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE;mBAgBvD,MAAM,WAAW,OAAO,KAAG,IAAI;kBAwMhC,MAAM;sBAOF,MAAM;;sCAKhB,MAAM,KAClB,KAAK,CAAC,MAAM,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;CA2CrD,CAAA;AAEF,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAC1F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAE9C;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,SAAS,OAAO,EAAE,UAAU,aAAa,SAEnF,CAAA"}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { Store } from 'effector';
|
|
2
|
-
import {
|
|
3
|
-
import { Picked } from '../../picked';
|
|
2
|
+
import { LogicRule } from '../../logic-engine';
|
|
4
3
|
export type FieldsStore = ReturnType<typeof createFieldIndex>;
|
|
5
|
-
export type FieldOptionsStatus = 'idle' | 'loading' | 'resolved' | 'error' | 'waiting';
|
|
6
4
|
export type PrimitiveFieldValue = string | number | boolean | null;
|
|
7
|
-
export type FieldOptionValue = string | number | boolean;
|
|
8
|
-
export interface FieldOption<T = FieldOptionValue> {
|
|
9
|
-
id?: string;
|
|
10
|
-
label: string;
|
|
11
|
-
description?: string;
|
|
12
|
-
value: T;
|
|
13
|
-
condition?: LogicRule;
|
|
14
|
-
}
|
|
15
|
-
export type FieldOptionArray<T = FieldOptionValue> = FieldOption<T>[];
|
|
16
|
-
export type FieldOptions<T = FieldOptionValue> = FieldOptionArray<T> | LogicRule;
|
|
17
5
|
/**
|
|
18
6
|
* JSON-serializable value type for object fields.
|
|
19
7
|
* Recursively defines all valid JSON-serializable structures.
|
|
@@ -22,8 +10,10 @@ export type JsonValue = string | number | boolean | null | {
|
|
|
22
10
|
[key: string]: JsonValue;
|
|
23
11
|
} | JsonValue[];
|
|
24
12
|
export type FieldValue = PrimitiveFieldValue | PrimitiveFieldValue[] | JsonValue | JsonValue[];
|
|
25
|
-
export interface FieldBase<TOptionValue =
|
|
13
|
+
export interface FieldBase<TOptionValue = PrimitiveFieldValue> {
|
|
26
14
|
id: string;
|
|
15
|
+
/** Stable kebab-case identifier used for lookups across API versions. */
|
|
16
|
+
key: string;
|
|
27
17
|
name: string;
|
|
28
18
|
label: string;
|
|
29
19
|
type: 'text' | 'number' | 'object' | 'boolean';
|
|
@@ -31,6 +21,8 @@ export interface FieldBase<TOptionValue = JsonValue> {
|
|
|
31
21
|
required: boolean;
|
|
32
22
|
defaultValue?: FieldValue;
|
|
33
23
|
condition?: LogicRule;
|
|
24
|
+
/** References a global condition by key. Takes precedence over inline `condition`. */
|
|
25
|
+
conditionKey?: string;
|
|
34
26
|
placeholder?: string;
|
|
35
27
|
description?: string;
|
|
36
28
|
helpText?: string;
|
|
@@ -39,16 +31,13 @@ export interface FieldBase<TOptionValue = JsonValue> {
|
|
|
39
31
|
doNotTrackValue?: boolean;
|
|
40
32
|
doNotStoreValue?: boolean;
|
|
41
33
|
};
|
|
42
|
-
options?:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
* options: { if: [{ '==': [{ var: 'responses.city-selector-field' }, 'sydney'] }, { invoke: { var: 'actions.fetchSydneyEmployees' } }, ...] }
|
|
50
|
-
*/
|
|
51
|
-
dependsOn?: string[];
|
|
34
|
+
options?: {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
value: TOptionValue;
|
|
39
|
+
condition?: LogicRule;
|
|
40
|
+
}[] | null;
|
|
52
41
|
}
|
|
53
42
|
export interface FieldTextSingular extends FieldBase<string> {
|
|
54
43
|
type: 'text';
|
|
@@ -91,36 +80,18 @@ export interface FieldBooleanMultiple extends FieldBase<boolean> {
|
|
|
91
80
|
defaultValue?: boolean[];
|
|
92
81
|
}
|
|
93
82
|
export type Field = FieldTextSingular | FieldTextMultiple | FieldNumberSingular | FieldNumberMultiple | FieldObjectSingular | FieldObjectMultiple | FieldBooleanSingular | FieldBooleanMultiple;
|
|
94
|
-
|
|
95
|
-
* A field enriched with its runtime options resolution state.
|
|
96
|
-
* Returned by getById, getByName, and listStore — status is always present.
|
|
97
|
-
*/
|
|
98
|
-
export type FieldWithStatus = Field & {
|
|
99
|
-
status: FieldOptionsStatus;
|
|
100
|
-
options: FieldOptionArray<JsonValue> | null;
|
|
101
|
-
error?: string;
|
|
102
|
-
};
|
|
103
|
-
declare const createFieldIndexFactory: ({ client }: {
|
|
104
|
-
client?: Picked;
|
|
105
|
-
}) => {
|
|
83
|
+
declare const createFieldIndexFactory: () => {
|
|
106
84
|
register: (field: Field) => void;
|
|
107
|
-
update: (
|
|
108
|
-
getById: (id: FieldBase["id"]) => Store<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
force?: boolean;
|
|
113
|
-
context?: LogicObject;
|
|
114
|
-
}) => void;
|
|
115
|
-
resolveAll: (fieldIds: string[], opts?: {
|
|
116
|
-
force?: boolean;
|
|
117
|
-
context?: LogicObject;
|
|
118
|
-
}) => void;
|
|
119
|
-
setWaiting: import('effector').EventCallable<string>;
|
|
85
|
+
update: (fieldKeyOrId: FieldBase["key"], updates: Partial<Field>) => void;
|
|
86
|
+
getById: (id: FieldBase["id"]) => Store<Field | null>;
|
|
87
|
+
getByKey: (key: FieldBase["key"]) => Store<Field | null>;
|
|
88
|
+
listStore: Store<Field[]>;
|
|
89
|
+
getByName: (name: FieldBase["name"]) => Store<Field | null>;
|
|
120
90
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
export declare function createFieldIndex(): ReturnType<typeof createFieldIndexFactory>;
|
|
124
95
|
export declare const setupField: (field: Field, fields: FieldsStore) => void;
|
|
125
96
|
export {};
|
|
126
97
|
//# sourceMappingURL=field.d.ts.map
|