@picked/client 0.0.1-dev.1763966324978 → 0.0.1-dev.1764090824933
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +766 -150
- package/dist/esm/plugins/single-page-app/index.js +3 -3
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/plugins/window-object/index.js +1 -1
- package/dist/esm/server/index.js +7 -7
- package/dist/experience-instance-BpQMqclI.cjs +1 -0
- package/dist/{experience-instance-CeuHLrdL.js → experience-instance-CMrX6QA2.js} +90 -89
- package/dist/{supports-DBMT17KZ.js → supports-BjhuLJ8z.js} +10 -10
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/package.json +1 -7
- package/dist/cjs/plugins/shopify/index.js +0 -1
- package/dist/esm/plugins/shopify/index.js +0 -123
- package/dist/experience-instance-B2l_MG7I.cjs +0 -1
- package/dist/types/plugins/shopify/global-obj.d.ts +0 -49
- package/dist/types/plugins/shopify/global-obj.d.ts.map +0 -1
- package/dist/types/plugins/shopify/index.d.ts +0 -6
- package/dist/types/plugins/shopify/index.d.ts.map +0 -1
- package/dist/types/plugins/shopify/picked-config.d.ts +0 -103
- package/dist/types/plugins/shopify/picked-config.d.ts.map +0 -1
- package/dist/types/plugins/shopify/plugin.d.ts +0 -3
- package/dist/types/plugins/shopify/plugin.d.ts.map +0 -1
- package/dist/types/plugins/shopify/predicates.d.ts +0 -42
- package/dist/types/plugins/shopify/predicates.d.ts.map +0 -1
- package/dist/user-session-CuJzmUIs.cjs +0 -1
- package/dist/user-session-G1Im7kCK.js +0 -644
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as f, G as c,
|
|
1
|
+
import { a as f, G as c, f as m } from "../../../supports-BjhuLJ8z.js";
|
|
2
2
|
import { p as a } from "../../../object-JwZ58NOH.js";
|
|
3
3
|
const o = c;
|
|
4
4
|
let s;
|
|
5
|
-
const
|
|
5
|
+
const d = (r) => ({
|
|
6
6
|
name: "single-page-app",
|
|
7
7
|
setup: (n) => {
|
|
8
8
|
r.instrumentHistory && f() && h(() => {
|
|
@@ -33,5 +33,5 @@ function h(r) {
|
|
|
33
33
|
a(o.history, "pushState", n), a(o.history, "replaceState", n);
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
d as singlePageAppPlugin
|
|
37
37
|
};
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createEvent as i, createStore as
|
|
2
|
-
import {
|
|
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-CMrX6QA2.js";
|
|
3
3
|
function R() {
|
|
4
4
|
let c, p;
|
|
5
5
|
return {
|
|
@@ -11,19 +11,19 @@ function R() {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
function w(c, p) {
|
|
14
|
-
const { promise: g, resolve: t } = R(), o = i(), s = i(), l = i(), m = i(), d = i(), I = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x =
|
|
14
|
+
const { promise: g, resolve: t } = R(), o = i(), s = i(), l = i(), m = i(), d = i(), I = c.experiences.listStore.map((e) => e.map((r) => F({ client: c, experience: r }))), x = v({
|
|
15
15
|
currentExperienceIndex: 0,
|
|
16
16
|
renderedExperiences: [],
|
|
17
17
|
isComplete: !1
|
|
18
|
-
}), f =
|
|
18
|
+
}), f = C(
|
|
19
19
|
async ({
|
|
20
20
|
experience: e,
|
|
21
21
|
availableRenderers: r,
|
|
22
|
-
startRendererIndex:
|
|
22
|
+
startRendererIndex: h = 0
|
|
23
23
|
}) => {
|
|
24
24
|
if (!e)
|
|
25
25
|
return null;
|
|
26
|
-
for (let a =
|
|
26
|
+
for (let a = h; a < r.length; a++) {
|
|
27
27
|
const u = r[a], E = e.componentStore.getState();
|
|
28
28
|
if (E && (u != null && u.isValidComponent(E.component)))
|
|
29
29
|
return { rendered: await u.render(E.component, c, e), rendererIndex: a };
|
|
@@ -75,7 +75,7 @@ function w(c, p) {
|
|
|
75
75
|
filter: ({ experiences: e, state: r }) => r.currentExperienceIndex >= e.length,
|
|
76
76
|
target: m
|
|
77
77
|
});
|
|
78
|
-
const k =
|
|
78
|
+
const k = S({
|
|
79
79
|
source: x,
|
|
80
80
|
effect: (e) => {
|
|
81
81
|
e.isComplete && t(e.renderedExperiences);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const i=require("effector"),q=require("@withease/factories"),H=require("./supports-YvpQZxbh.cjs"),N=require("./logger-BsmHUUw1.cjs"),ge=require("./object-BbFTsGh3.cjs");function me(e){return typeof e=="number"&&!isNaN(e)}function R(e){return typeof e=="string"}function E(e){return Array.isArray(e)}function ne(e){return e instanceof Promise}function Z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length===1}function m(e){if(me(e))return e;const t=parseFloat(`${e}`);return isNaN(t)?0:t}function T(e){return`${e}`}const he={"==":(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),a=m(t);if(r===void 0)return n<a;const c=m(r);return n<a&&a<c},"<=":(e,t,r)=>{const n=m(e),a=m(t);if(r===void 0)return n<=a;const c=m(r);return n<=a&&a<=c},"!!":async e=>await O(e),"!":async e=>!await O(e),"%":(e,t)=>m(e)%m(t),log:e=>(console.log(e),e),in:(e,t)=>t?R(t)?t.indexOf(T(e))!==-1:E(t)?t.includes(e):!1:!1,cat:(...e)=>e.map(T).join(""),substr:(e,t,r)=>{const n=T(e),a=m(t);if(r===void 0)return n.substr(a);const c=m(r);if(c<0){const o=n.substr(a);return o.substr(0,o.length+c)}return n.substr(a,c)},"+":(...e)=>e.reduce((t,r)=>m(t)+m(r),0),"*":(...e)=>e.reduce((t,r)=>m(t)*m(r),1),"-":(e,t)=>{const r=m(e);return t===void 0?-r:r-m(t)},"/":(e,t)=>m(e)/m(t),min:(...e)=>Math.min(...e.map(m)),max:(...e)=>Math.max(...e.map(m)),merge:(...e)=>e.reduce((t,r)=>E(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=T(e);if(n===""||n===".")return this;const a=n.split(".");let c=this;for(const o of a){if(c==null)return r;if(Array.isArray(c)){const u=parseInt(o,10);isNaN(u)?c=c[o]:c=c[u]}else c=c[o]}return c!==void 0?c:r},async missing(...e){const t=E(e[0])?e[0]:e,r=[];for(const n of t){const a=await g({var:n},this);(a===null||a==="")&&r.push(`${n}`)}return r},async missing_some(e,t){const r=await g({missing:t},this);if(!E(r)||!E(t))return[];const n=r.filter(R);return t.filter(R).length-n.length>=m(e)?[]:n},invoke(e){return typeof e!="function"?null:e()},regexp_matches(e,t){let r=e,n="";if(E(e)){const[c,o]=e;r=c,n=o}return!R(r)||!R(n)?!1:new RegExp(r,n).test(T(t))},throw(e){throw new Error(T(e))}};async function g(e,t){if(!e)return e;if(ne(e))return g(await e,t);if(E(e))return Promise.all(e.map(o=>g(o,t)));if(!Z(e))return e;const r=Se(e);let n=r?e[r]??[]:[];switch(E(n)||(n=[n]),r){case"if":case"?:":for(let o=0;o<n.length-1;o+=2)if(await O(await g(n[o],t)))return g(n[o+1],t);return n.length%2===1?g(n[n.length-1],t):null;case"and":{let o=null;for(const u of n)if(o=await g(u,t),!await O(o))return o;return o}case"or":{let o=null;for(const u of n)if(o=await g(u,t),await O(o))return o;return o}case"map":{const o=await g(n[0],t);return E(o)?await Promise.all(o.map(u=>g(n[1],u))):[]}case"filter":{const o=await g(n[0],t);return E(o)?(await Promise.all(o.map(async p=>{const y=await O(await g(n[1],p));return{item:p,shouldInclude:y}}))).filter(({shouldInclude:p})=>p).map(({item:p})=>p):[]}case"reduce":{const o=await g(n[0],t);if(!E(o))return n.length>2?await g(n[2],t):null;const u=n[1];let y=n.length>2?await g(n[2],t):null;for(const k of o)y=await g(u,{current:k,accumulator:y});return y}case"all":{const o=await g(n[0],t);if(!E(o)||o.length===0)return!1;for(const u of o)if(!await O(await g(n[1],u)))return!1;return!0}case"some":{const o=await g(n[0],t);if(!E(o))return!1;for(const u of o)if(await O(await g(n[1],u)))return!0;return!1}case"none":{const o=await g(n[0],t);if(!E(o))return!0;for(const u of o)if(await O(await g(n[1],u)))return!1;return!0}case"catch":try{return await g(n[0],t)}catch(o){return Z(o)?await g(o,t):n[1]?await g(n[1],o):o instanceof Error?o.message:o}}const a=await Promise.all(n.map(o=>g(o,t))),c=r?he[r]:void 0;if(!c)throw new Error(`Unrecognized operation ${r}`);return c.apply(t,a)}async function O(e){return ne(e)?O(await e):!(Array.isArray(e)&&e.length===0)&&!!e}function Se(e){return Object.keys(e)[0]}function re(e){return!ge.isEmpty(e)}async function V(e,t,r){const n=e.getStateSnapshot(),a=e.predicates.listStore.getState().reduce((u,p)=>({...u,[p.name]:()=>p.predicate(n)}),{}),c=e.features.listStore.getState().reduce((u,p)=>({...u,[p.id]:async()=>{const{bucket:y}=await p.getBucket();return y}}),{}),o={...r,responses:e.responses.getAllStore.getState(),location:typeof n.location=="object"?{hash:n.location.hash,host:n.location.host,hostname:n.location.hostname,href:n.location.href,origin:n.location.origin,pathname:n.location.pathname,port:n.location.port,protocol:n.location.protocol,search:n.location.search}:void 0,predicates:a,features:c};return await g(t,o)}function ye(e){return!H.supportsWindow()||!H.supportsDocument()?[]:Array.from(window.document.querySelectorAll(e)).filter(t=>t instanceof HTMLElement)}const we="open";function Ee(e){if(!H.supportsShadowRoot())throw new Error("Shadow DOM is not supported in this environment");return e.attachShadow({mode:we})}function Ne(){return new Promise((e,t)=>{if(!H.supportsDocument()){t();return}document.readyState!=="loading"?e():document.addEventListener("readystatechange",()=>e(),{once:!0})})}function Ie(e,t){const r=new MutationObserver(n=>{document.contains(e)||(r.disconnect(),t())});r.observe(document.body,{childList:!0,subtree:!0})}const C="picked-root",j="picked-target",xe="picked-root";function ke(e,t){return[...e,{selector:`${xe}[experience-id="${t}"]`,placement:"replace"}].flatMap(n=>{const a=ye(n.selector).filter(c=>!Ae(c,t)&&!oe(c,t));return{...n,elements:a}})}function ve(e,t){return e.flatMap(r=>r.elements.map(n=>Be(n,r.placement,t)))}function be(e,t){e.classList.add(j),e.classList.add(`${j}-${t}`)}function Ae(e,t){return t?e.classList.contains(`${j}-${t}`):e.classList.contains(`${j}`)}function oe(e,t){return t?e.classList.contains(`${C}-${t}`):e.classList.contains(C)}function Oe(e){const t=document.createElement("div");return t.style.display="block",t.classList.add(C),t.classList.add(`${C}-${e}`),t}function Be(e,t,r){let n;const a=Oe(r);if(e instanceof Document)n=e.body.appendChild(a);else{switch(t){case"replace":e.replaceWith(a);break;case"before":e.before(a);break;case"after":e.after(a);break;case"prepend":e.prepend(a);break;default:e.append(a);break}n=a}return n}function Fe(e){return e.type==="conditional"}function M(e){return e.type==="step"}function _e(e){return e.type==="experience"}function ee(e){return e.type==="origin"}function te(e){return e.type==="action"}const se=(e,t,r,n,a=new Set)=>a.has(r.id)?[]:(a.add(r.id),M(r)&&!n?[r]:t.filter(o=>o.sourceNodeId===r.id).flatMap(o=>{const u=e.find(p=>p.id===o.destinationNodeId);return u?se(e,t,u,!1,a):[]})),$e=(e,t,r)=>se(e,t,r,!0,new Set),ie=(e,t,r,n,a=new Set)=>{if(a.has(r.id))return[-1,-1];a.add(r.id);const c=t.filter(p=>p.sourceNodeId===r.id);if(c.length===0)return[0,0];let o=1/0,u=-1/0;for(const p of c){const y=e.find(L=>L.id===p.destinationNodeId);if(!y)continue;const[k,B]=ie(e,t,y,!1,new Set(a));k!==-1&&(o=Math.min(o,k+1),u=Math.max(u,B+1))}return o===1/0?[-1,-1]:[o,u]},Te=(e,t,r)=>ie(e,t,r,!0,new Set),ae=(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 a=t.filter(u=>u.destinationNodeId===r.id);if(a.length===0)return[-1,-1];let c=1/0,o=-1/0;for(const u of a){const p=e.find(B=>B.id===u.sourceNodeId);if(!p)continue;const[y,k]=ae(e,t,p,new Set(n));y!==-1&&(c=Math.min(c,y+1),o=Math.max(o,k+1))}return c===1/0?[-1,-1]:[c,o]},Me=(e,t,r)=>ae(e,t,r,new Set),ce=e=>e.find(r=>r.type==="origin")||null,U=(e,t,r)=>{if(!e)return ce(t);const n=r.find(c=>c.sourceNodeId===e.id);if(!n)return null;const a=t.find(c=>c.id===n.destinationNodeId);return a||null};async function Le(e,t,r,n){const a=e?"true":"false",c=n.find(o=>o.sourceNodeHandle===a&&o.sourceNodeId===t);return r.find(o=>o.id===(c==null?void 0:c.destinationNodeId))}const X=i.createDomain("experience-instance"),De=q.createFactory(({client:e,experience:t,target:r})=>{const n=i.createEvent(),a=i.createEvent(),c=i.createEvent(),o=i.createEvent(),u=i.createEvent(),p=i.createEvent(),y=t.componentStore,k=X.store("transitioning"),B=e.history.entriesStore.map(s=>s.filter(l=>l.experienceId===t.id)),L=B.map(s=>s.filter(l=>M(l.node))),I=B.map(s=>{var l;return((l=s[s.length-1])==null?void 0:l.node)||null}),f=i.combine(t.treeStore,I,({steps:s},l)=>s.find(d=>l&&M(l)&&d.id===l.stepId)||null),h=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?$e(s,l,d):[]),A=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?Me(s,l,d):[-1,-1]),_=i.combine(t.treeStore,I,({nodes:s,edges:l},d)=>d?Te(s,l,d):[-1,-1]),v=X.store(!1),F=i.createApi(v,{open:()=>!0,close:()=>!1,toggle:s=>!s,set:(s,l)=>l}),fe=i.createEffect(async()=>{e.history.back({experienceId:t.id})}),le=i.attach({source:t.treeStore,effect:async(s,l)=>{const d=s.nodes.find(w=>M(w)&&w.stepId===l);d&&e.history.push({experienceId:t.id,node:d})}}),z=i.attach({source:I,effect:s=>{}}),W=i.attach({source:t.treeStore,effect:async({nodes:s})=>ce(s)}),G=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l},d)=>U(d,s,l)}),K=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l,conditionals:d},w)=>{if(!w)return;const $=d.find(b=>b.id===w.conditionalId);if(!$)return;const x=w.id,S=await V(e,$.condition);return Le(!!S,x,s,l)}}),J=i.attach({source:t.treeStore,effect:async({nodes:s,edges:l},d)=>{if(!d||!te(d))return;const w=d.action;if(!w){N.logger("warn",`Action node ${d.id} has no action name`);return}const $=e.actions.getByName(w).getState();if(!$){N.logger("warn",`Action '${w}' not registered on client`);const x=l.find(S=>S.sourceNodeId===d.id&&S.sourceNodeHandle==="false");return x?s.find(S=>S.id===x.destinationNodeId):null}if(typeof $.action!="function"){N.logger("warn",`Action '${w}' is not a function`);const x=l.find(S=>S.sourceNodeId===d.id&&S.sourceNodeHandle==="false");return x?s.find(S=>S.id===x.destinationNodeId):null}try{N.logger("info",`Executing action: ${w}`),await $.action();const x=l.find(b=>b.sourceNodeId===d.id&&b.sourceNodeHandle==="true");if(!x)return N.logger("warn",`No 'true' edge found for action node ${d.id}`),null;const S=s.find(b=>b.id===x.destinationNodeId);return N.logger("info",`Action '${w}' succeeded, moving to node ${S==null?void 0:S.id}`),S||null}catch(x){N.logger("warn",`Action '${w}' failed:`,x);const S=l.find(P=>P.sourceNodeId===d.id&&P.sourceNodeHandle==="false");if(!S)return N.logger("warn",`No 'false' edge found for action node ${d.id}`),null;const b=s.find(P=>P.id===S.destinationNodeId);return N.logger("info",`Action '${w}' failed, moving to node ${b==null?void 0:b.id}`),b||null}}}),de=i.createEffect(s=>{if(s)return e.launchExperienceById(s.experienceId)}),Q=i.attach({source:[I,t.treeStore],effect:async([s,{nodes:l,edges:d}])=>U(s,l,d)}),D=i.attach({source:[I,t.treeStore],effect:async([s,{nodes:l,edges:d}])=>U(s,l,d)}),pe=i.createEffect(s=>{e.history.push({experienceId:t.id,node:s})}),Y=i.attach({source:t.configStore,effect:async({initializeOpenLogic:s})=>re(s)?!!await V(e,s):s??!1});return i.split({source:I,match:s=>s?Fe(s)?"condition":M(s)?"step":_e(s)?"launchExperience":ee(s)?"origin":te(s)?"action":"other":"none",cases:{none:W,origin:G,condition:K,step:z,launchExperience:de,action:J,__:i.createEvent()}}),i.sample({clock:[K.doneData,G.doneData,W.doneData,D.doneData,Q.doneData,J.doneData],filter:Boolean,target:pe}),i.sample({clock:a,target:D}),i.sample({clock:a,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit",step:s,experience:t}))}),i.sample({clock:D.done,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_success",step:s,experience:t}))}),i.sample({clock:D.fail,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_submit_error",step:s,experience:t}))}),i.sample({clock:c,target:fe}),i.sample({clock:o,target:le}),i.sample({source:i.combine([K.pending,G.pending,W.pending,D.pending]),fn:s=>s.some(Boolean)?"transitioning":"ready",target:k}),i.sample({clock:z.doneData,source:f,filter:Boolean,target:e.eventBus.prepend(s=>({type:"step_enter",step:s,experience:t}))}),i.sample({clock:p,target:Y}),i.sample({source:Y.doneData,fn:Boolean,target:v}),i.sample({source:I,clock:n,filter:s=>s?ee(s):!0,target:Q}),i.sample({source:v,filter:Boolean,target:n}),i.sample({source:v,filter:Boolean,target:e.eventBus.prepend(()=>({type:"experience_open",experience:t}))}),i.sample({source:v,filter:s=>!s,target:e.eventBus.prepend(()=>({type:"experience_close",experience:t}))}),i.sample({clock:u,target:[p]}),u(),{id:Math.random().toString(36).substring(7),experienceId:t.id,configStore:t.configStore,target:r,componentStore:y,stateStore:k,isOpenStore:v,open:F.open,close:F.close,toggleOpen:F.toggle,setOpen:F.set,treeStore:t.treeStore,currentNodeStore:I,currentStepStore:f,nextReachableStepNodesStore:h,stepsToOriginStore:A,stepsToLeafStore:_,goToNextStep:a,goToPreviousStep:c,goToStepById:o,stepsHistoryStore:L}});function ue(e){return q.invoke(De,e)}const Re=q.createFactory(({client:e})=>{const t=X.store({}),r=i.createEvent(),n=i.createEvent(),a=i.createEvent(),c=i.createApi(t,{register(f,h){const A=[...f[h.experienceId]??[]];return A.push(h),{...f,[h.experienceId]:A}},unregister(f,h){var v;const A=h.experienceId,_=(v=f[A])==null?void 0:v.filter(F=>F!==h);return{...f,[A]:_??[]}}}),o=i.createEffect(({experience:f,target:h})=>ue({client:e,experience:f,target:h})),u=i.createEffect(f=>{c.register(f)}),p=i.createEffect(f=>{f.target&&Ie(f.target,()=>{a(f)})}),y=i.createEffect(f=>{c.unregister(f)}),k=i.createEffect(f=>{const h=f.componentStore.getState();if(!h){N.logger("warn","No app component registered. Skipping init.");return}const A=h.frameworkStore.getState();if(!A){N.logger("error",`No framework registered for component '${h.name}'. Skipping rendering.`);return}const _=f.target;if(!_){N.logger("error",`No target element registered for experience '${f.experienceId}'. Skipping rendering.`);return}const v=Ee(_);try{A.render(v,h.component,e,f)}catch(F){N.logger("error",F)}});i.sample({clock:r,target:o}),i.sample({clock:a,target:y}),i.sample({clock:o.doneData,target:[u,p,n]}),i.sample({clock:o.doneData,target:e.eventBus.prepend(f=>({type:"experience_initialized",experienceInstance:f}))}),i.sample({clock:n,target:k});function B(f,h){r({experience:f,target:h})}const L=t.map(f=>Object.values(f).flat());function I(f){return t.map(h=>h[f]||[],{skipVoid:!1})}return{spawn:B,getByExperienceId:I,listStore:L}});function Pe(e){return q.invoke(Re,e)}exports.createAppHosts=ve;exports.createExperienceInstance=ue;exports.createExperienceInstanceIndex=Pe;exports.domInteractive=Ne;exports.evaluateRuleLogic=V;exports.getTargetElements=ke;exports.isPickedRoot=oe;exports.isRulesLogic=re;exports.isStepNode=M;exports.tagTargetElement=be;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createDomain as ht, createEvent as
|
|
1
|
+
import { createDomain as ht, createEvent as O, combine as C, createApi as ot, createEffect as M, attach as _, split as yt, sample as m } from "effector";
|
|
2
2
|
import { createFactory as it, invoke as st } from "@withease/factories";
|
|
3
|
-
import {
|
|
3
|
+
import { i as wt, s as at, a as Nt } from "./supports-BjhuLJ8z.js";
|
|
4
4
|
import { l as I } from "./logger-C9a75KZn.js";
|
|
5
5
|
import { i as It } from "./object-JwZ58NOH.js";
|
|
6
6
|
function xt(t) {
|
|
@@ -47,8 +47,8 @@ const Et = {
|
|
|
47
47
|
const a = g(r);
|
|
48
48
|
return n <= s && s <= a;
|
|
49
49
|
},
|
|
50
|
-
"!!": async (t) => await
|
|
51
|
-
"!": async (t) => !await
|
|
50
|
+
"!!": async (t) => await B(t),
|
|
51
|
+
"!": async (t) => !await B(t),
|
|
52
52
|
"%": (t, e) => g(t) % g(e),
|
|
53
53
|
// eslint-disable-next-line sonarjs/function-return-type
|
|
54
54
|
log: (t) => (console.log(t), t),
|
|
@@ -141,20 +141,20 @@ async function p(t, e) {
|
|
|
141
141
|
case "if":
|
|
142
142
|
case "?:":
|
|
143
143
|
for (let o = 0; o < n.length - 1; o += 2)
|
|
144
|
-
if (await
|
|
144
|
+
if (await B(await p(n[o], e)))
|
|
145
145
|
return p(n[o + 1], e);
|
|
146
146
|
return n.length % 2 === 1 ? p(n[n.length - 1], e) : null;
|
|
147
147
|
case "and": {
|
|
148
148
|
let o = null;
|
|
149
149
|
for (const c of n)
|
|
150
|
-
if (o = await p(c, e), !await
|
|
150
|
+
if (o = await p(c, e), !await B(o))
|
|
151
151
|
return o;
|
|
152
152
|
return o;
|
|
153
153
|
}
|
|
154
154
|
case "or": {
|
|
155
155
|
let o = null;
|
|
156
156
|
for (const c of n)
|
|
157
|
-
if (o = await p(c, e), await
|
|
157
|
+
if (o = await p(c, e), await B(o)) return o;
|
|
158
158
|
return o;
|
|
159
159
|
}
|
|
160
160
|
case "map": {
|
|
@@ -165,7 +165,7 @@ async function p(t, e) {
|
|
|
165
165
|
const o = await p(n[0], e);
|
|
166
166
|
return N(o) ? (await Promise.all(
|
|
167
167
|
o.map(async (d) => {
|
|
168
|
-
const y = await
|
|
168
|
+
const y = await B(await p(n[1], d));
|
|
169
169
|
return { item: d, shouldInclude: y };
|
|
170
170
|
})
|
|
171
171
|
)).filter(({ shouldInclude: d }) => d).map(({ item: d }) => d) : [];
|
|
@@ -184,21 +184,21 @@ async function p(t, e) {
|
|
|
184
184
|
const o = await p(n[0], e);
|
|
185
185
|
if (!N(o) || o.length === 0) return !1;
|
|
186
186
|
for (const c of o)
|
|
187
|
-
if (!await
|
|
187
|
+
if (!await B(await p(n[1], c))) return !1;
|
|
188
188
|
return !0;
|
|
189
189
|
}
|
|
190
190
|
case "some": {
|
|
191
191
|
const o = await p(n[0], e);
|
|
192
192
|
if (!N(o)) return !1;
|
|
193
193
|
for (const c of o)
|
|
194
|
-
if (await
|
|
194
|
+
if (await B(await p(n[1], c))) return !0;
|
|
195
195
|
return !1;
|
|
196
196
|
}
|
|
197
197
|
case "none": {
|
|
198
198
|
const o = await p(n[0], e);
|
|
199
199
|
if (!N(o)) return !0;
|
|
200
200
|
for (const c of o)
|
|
201
|
-
if (await
|
|
201
|
+
if (await B(await p(n[1], c))) return !1;
|
|
202
202
|
return !0;
|
|
203
203
|
}
|
|
204
204
|
case "catch":
|
|
@@ -212,8 +212,8 @@ async function p(t, e) {
|
|
|
212
212
|
if (!a) throw new Error(`Unrecognized operation ${r}`);
|
|
213
213
|
return a.apply(e, s);
|
|
214
214
|
}
|
|
215
|
-
async function
|
|
216
|
-
return ct(t) ?
|
|
215
|
+
async function B(t) {
|
|
216
|
+
return ct(t) ? B(await t) : !(Array.isArray(t) && t.length === 0) && !!t;
|
|
217
217
|
}
|
|
218
218
|
function kt(t) {
|
|
219
219
|
return Object.keys(t)[0];
|
|
@@ -255,12 +255,13 @@ function bt(t) {
|
|
|
255
255
|
(e) => e instanceof HTMLElement
|
|
256
256
|
);
|
|
257
257
|
}
|
|
258
|
-
|
|
258
|
+
const vt = "open";
|
|
259
|
+
function Ot(t) {
|
|
259
260
|
if (!wt())
|
|
260
261
|
throw new Error("Shadow DOM is not supported in this environment");
|
|
261
|
-
return t.attachShadow({ mode:
|
|
262
|
+
return t.attachShadow({ mode: vt });
|
|
262
263
|
}
|
|
263
|
-
function
|
|
264
|
+
function zt() {
|
|
264
265
|
return new Promise((t, e) => {
|
|
265
266
|
if (!at()) {
|
|
266
267
|
e();
|
|
@@ -275,18 +276,18 @@ function Bt(t, e) {
|
|
|
275
276
|
});
|
|
276
277
|
r.observe(document.body, { childList: !0, subtree: !0 });
|
|
277
278
|
}
|
|
278
|
-
const
|
|
279
|
-
function
|
|
279
|
+
const G = "picked-root", K = "picked-target", _t = "picked-root";
|
|
280
|
+
function Jt(t, e) {
|
|
280
281
|
return [
|
|
281
282
|
...t,
|
|
282
283
|
// Target and replace picked-root web components
|
|
283
284
|
{
|
|
284
|
-
selector: `${
|
|
285
|
+
selector: `${_t}[experience-id="${e}"]`,
|
|
285
286
|
placement: "replace"
|
|
286
287
|
}
|
|
287
288
|
].flatMap((n) => {
|
|
288
289
|
const s = bt(n.selector).filter(
|
|
289
|
-
(a) =>
|
|
290
|
+
(a) => !$t(a, e) && !Ft(a, e)
|
|
290
291
|
);
|
|
291
292
|
return {
|
|
292
293
|
...n,
|
|
@@ -294,25 +295,25 @@ function zt(t, e) {
|
|
|
294
295
|
};
|
|
295
296
|
});
|
|
296
297
|
}
|
|
297
|
-
function Jt(t, e) {
|
|
298
|
-
return t.flatMap((r) => r.elements.map((n) => Mt(n, r.placement, e)));
|
|
299
|
-
}
|
|
300
298
|
function Qt(t, e) {
|
|
301
|
-
t.
|
|
299
|
+
return t.flatMap((r) => r.elements.map((n) => Tt(n, r.placement, e)));
|
|
302
300
|
}
|
|
303
|
-
function
|
|
304
|
-
|
|
301
|
+
function Yt(t, e) {
|
|
302
|
+
t.classList.add(K), t.classList.add(`${K}-${e}`);
|
|
303
|
+
}
|
|
304
|
+
function $t(t, e) {
|
|
305
|
+
return e ? t.classList.contains(`${K}-${e}`) : t.classList.contains(`${K}`);
|
|
305
306
|
}
|
|
306
|
-
function
|
|
307
|
-
return e ? t.classList.contains(`${
|
|
307
|
+
function Ft(t, e) {
|
|
308
|
+
return e ? t.classList.contains(`${G}-${e}`) : t.classList.contains(G);
|
|
308
309
|
}
|
|
309
|
-
function
|
|
310
|
+
function Mt(t) {
|
|
310
311
|
const e = document.createElement("div");
|
|
311
|
-
return e.style.display = "block", e.classList.add(
|
|
312
|
+
return e.style.display = "block", e.classList.add(G), e.classList.add(`${G}-${t}`), e;
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
+
function Tt(t, e, r) {
|
|
314
315
|
let n;
|
|
315
|
-
const s =
|
|
316
|
+
const s = Mt(r);
|
|
316
317
|
if (t instanceof Document)
|
|
317
318
|
n = t.body.appendChild(s);
|
|
318
319
|
else {
|
|
@@ -337,13 +338,13 @@ function Mt(t, e, r) {
|
|
|
337
338
|
}
|
|
338
339
|
return n;
|
|
339
340
|
}
|
|
340
|
-
function
|
|
341
|
+
function Lt(t) {
|
|
341
342
|
return t.type === "conditional";
|
|
342
343
|
}
|
|
343
344
|
function j(t) {
|
|
344
345
|
return t.type === "step";
|
|
345
346
|
}
|
|
346
|
-
function
|
|
347
|
+
function Dt(t) {
|
|
347
348
|
return t.type === "experience";
|
|
348
349
|
}
|
|
349
350
|
function nt(t) {
|
|
@@ -355,7 +356,7 @@ function rt(t) {
|
|
|
355
356
|
const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.add(r.id), j(r) && !n ? [r] : e.filter((o) => o.sourceNodeId === r.id).flatMap((o) => {
|
|
356
357
|
const c = t.find((d) => d.id === o.destinationNodeId);
|
|
357
358
|
return c ? ut(t, e, c, !1, s) : [];
|
|
358
|
-
})),
|
|
359
|
+
})), Pt = (t, e, r) => ut(t, e, r, !0, /* @__PURE__ */ new Set()), ft = (t, e, r, n, s = /* @__PURE__ */ new Set()) => {
|
|
359
360
|
if (s.has(r.id)) return [-1, -1];
|
|
360
361
|
s.add(r.id);
|
|
361
362
|
const a = e.filter((d) => d.sourceNodeId === r.id);
|
|
@@ -364,24 +365,24 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
364
365
|
for (const d of a) {
|
|
365
366
|
const y = t.find((P) => P.id === d.destinationNodeId);
|
|
366
367
|
if (!y) continue;
|
|
367
|
-
const [k,
|
|
368
|
+
const [k, $] = ft(
|
|
368
369
|
t,
|
|
369
370
|
e,
|
|
370
371
|
y,
|
|
371
372
|
!1,
|
|
372
373
|
new Set(s)
|
|
373
374
|
);
|
|
374
|
-
k !== -1 && (o = Math.min(o, k + 1), c = Math.max(c,
|
|
375
|
+
k !== -1 && (o = Math.min(o, k + 1), c = Math.max(c, $ + 1));
|
|
375
376
|
}
|
|
376
377
|
return o === 1 / 0 ? [-1, -1] : [o, c];
|
|
377
|
-
},
|
|
378
|
+
}, Rt = (t, e, r) => ft(t, e, r, !0, /* @__PURE__ */ new Set()), lt = (t, e, r, n = /* @__PURE__ */ new Set()) => {
|
|
378
379
|
if (n.has(r.id)) return [-1, -1];
|
|
379
380
|
if (n.add(r.id), r.type === "origin") return [0, 0];
|
|
380
381
|
const s = e.filter((c) => c.destinationNodeId === r.id);
|
|
381
382
|
if (s.length === 0) return [-1, -1];
|
|
382
383
|
let a = 1 / 0, o = -1 / 0;
|
|
383
384
|
for (const c of s) {
|
|
384
|
-
const d = t.find((
|
|
385
|
+
const d = t.find(($) => $.id === c.sourceNodeId);
|
|
385
386
|
if (!d) continue;
|
|
386
387
|
const [y, k] = lt(
|
|
387
388
|
t,
|
|
@@ -392,7 +393,7 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
392
393
|
y !== -1 && (a = Math.min(a, y + 1), o = Math.max(o, k + 1));
|
|
393
394
|
}
|
|
394
395
|
return a === 1 / 0 ? [-1, -1] : [a, o];
|
|
395
|
-
},
|
|
396
|
+
}, Ct = (t, e, r) => lt(t, e, r, /* @__PURE__ */ new Set()), dt = (t) => t.find((r) => r.type === "origin") || null, X = (t, e, r) => {
|
|
396
397
|
if (!t)
|
|
397
398
|
return dt(e);
|
|
398
399
|
const n = r.find((a) => a.sourceNodeId === t.id);
|
|
@@ -401,19 +402,19 @@ const ut = (t, e, r, n, s = /* @__PURE__ */ new Set()) => s.has(r.id) ? [] : (s.
|
|
|
401
402
|
const s = e.find((a) => a.id === n.destinationNodeId);
|
|
402
403
|
return s || null;
|
|
403
404
|
};
|
|
404
|
-
async function
|
|
405
|
+
async function Ht(t, e, r, n) {
|
|
405
406
|
const s = t ? "true" : "false", a = n.find(
|
|
406
407
|
(o) => o.sourceNodeHandle === s && o.sourceNodeId === e
|
|
407
408
|
);
|
|
408
409
|
return r.find((o) => o.id === (a == null ? void 0 : a.destinationNodeId));
|
|
409
410
|
}
|
|
410
|
-
const z = ht("experience-instance"),
|
|
411
|
+
const z = ht("experience-instance"), jt = it(
|
|
411
412
|
({
|
|
412
413
|
client: t,
|
|
413
414
|
experience: e,
|
|
414
415
|
target: r
|
|
415
416
|
}) => {
|
|
416
|
-
const n =
|
|
417
|
+
const n = O(), s = O(), a = O(), o = O(), c = O(), d = O(), y = e.componentStore, k = z.store("transitioning"), $ = t.history.entriesStore.map((i) => i.filter((f) => f.experienceId === e.id)), P = $.map((i) => i.filter((f) => j(f.node))), x = $.map((i) => {
|
|
417
418
|
var f;
|
|
418
419
|
return ((f = i[i.length - 1]) == null ? void 0 : f.node) || null;
|
|
419
420
|
}), u = C(
|
|
@@ -423,39 +424,39 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
423
424
|
), S = C(
|
|
424
425
|
e.treeStore,
|
|
425
426
|
x,
|
|
426
|
-
({ nodes: i, edges: f }, l) => l ?
|
|
427
|
+
({ nodes: i, edges: f }, l) => l ? Pt(i, f, l) : []
|
|
427
428
|
), v = C(
|
|
428
429
|
e.treeStore,
|
|
429
430
|
x,
|
|
430
|
-
({ nodes: i, edges: f }, l) => l ?
|
|
431
|
+
({ nodes: i, edges: f }, l) => l ? Ct(i, f, l) : [-1, -1]
|
|
431
432
|
), T = C(
|
|
432
433
|
e.treeStore,
|
|
433
434
|
x,
|
|
434
|
-
({ nodes: i, edges: f }, l) => l ?
|
|
435
|
-
), A = z.store(!1),
|
|
435
|
+
({ nodes: i, edges: f }, l) => l ? Rt(i, f, l) : [-1, -1]
|
|
436
|
+
), A = z.store(!1), F = ot(A, {
|
|
436
437
|
open: () => !0,
|
|
437
438
|
close: () => !1,
|
|
438
439
|
toggle: (i) => !i,
|
|
439
440
|
set: (i, f) => f
|
|
440
441
|
}), pt = M(async () => {
|
|
441
442
|
t.history.back({ experienceId: e.id });
|
|
442
|
-
}), gt =
|
|
443
|
+
}), gt = _({
|
|
443
444
|
source: e.treeStore,
|
|
444
445
|
effect: async (i, f) => {
|
|
445
446
|
const l = i.nodes.find((w) => j(w) && w.stepId === f);
|
|
446
447
|
l && t.history.push({ experienceId: e.id, node: l });
|
|
447
448
|
}
|
|
448
|
-
}), J =
|
|
449
|
+
}), J = _({
|
|
449
450
|
source: x,
|
|
450
451
|
effect: (i) => {
|
|
451
452
|
}
|
|
452
|
-
}),
|
|
453
|
+
}), U = _({
|
|
453
454
|
source: e.treeStore,
|
|
454
455
|
effect: async ({ nodes: i }) => dt(i)
|
|
455
|
-
}),
|
|
456
|
+
}), V = _({
|
|
456
457
|
source: e.treeStore,
|
|
457
458
|
effect: async ({ nodes: i, edges: f }, l) => X(l, i, f)
|
|
458
|
-
}), q =
|
|
459
|
+
}), q = _({
|
|
459
460
|
source: e.treeStore,
|
|
460
461
|
effect: async ({ nodes: i, edges: f, conditionals: l }, w) => {
|
|
461
462
|
if (!w)
|
|
@@ -464,9 +465,9 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
464
465
|
if (!L)
|
|
465
466
|
return;
|
|
466
467
|
const E = w.id, h = await et(t, L.condition);
|
|
467
|
-
return
|
|
468
|
+
return Ht(!!h, E, i, f);
|
|
468
469
|
}
|
|
469
|
-
}), Q =
|
|
470
|
+
}), Q = _({
|
|
470
471
|
source: e.treeStore,
|
|
471
472
|
effect: async ({ nodes: i, edges: f }, l) => {
|
|
472
473
|
if (!l || !rt(l))
|
|
@@ -503,46 +504,46 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
503
504
|
} catch (E) {
|
|
504
505
|
I("warn", `Action '${w}' failed:`, E);
|
|
505
506
|
const h = f.find(
|
|
506
|
-
(
|
|
507
|
+
(W) => W.sourceNodeId === l.id && W.sourceNodeHandle === "false"
|
|
507
508
|
);
|
|
508
509
|
if (!h)
|
|
509
510
|
return I("warn", `No 'false' edge found for action node ${l.id}`), null;
|
|
510
|
-
const b = i.find((
|
|
511
|
+
const b = i.find((W) => W.id === h.destinationNodeId);
|
|
511
512
|
return I("info", `Action '${w}' failed, moving to node ${b == null ? void 0 : b.id}`), b || null;
|
|
512
513
|
}
|
|
513
514
|
}
|
|
514
515
|
}), mt = M((i) => {
|
|
515
516
|
if (i)
|
|
516
517
|
return t.launchExperienceById(i.experienceId);
|
|
517
|
-
}), Y =
|
|
518
|
+
}), Y = _({
|
|
518
519
|
source: [x, e.treeStore],
|
|
519
520
|
effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
|
|
520
|
-
}), R =
|
|
521
|
+
}), R = _({
|
|
521
522
|
source: [x, e.treeStore],
|
|
522
523
|
effect: async ([i, { nodes: f, edges: l }]) => X(i, f, l)
|
|
523
524
|
}), St = M((i) => {
|
|
524
525
|
t.history.push({ experienceId: e.id, node: i });
|
|
525
|
-
}), Z =
|
|
526
|
+
}), Z = _({
|
|
526
527
|
source: e.configStore,
|
|
527
528
|
effect: async ({ initializeOpenLogic: i }) => At(i) ? !!await et(t, i) : i ?? !1
|
|
528
529
|
});
|
|
529
530
|
return yt({
|
|
530
531
|
source: x,
|
|
531
|
-
match: (i) => i ?
|
|
532
|
+
match: (i) => i ? Lt(i) ? "condition" : j(i) ? "step" : Dt(i) ? "launchExperience" : nt(i) ? "origin" : rt(i) ? "action" : "other" : "none",
|
|
532
533
|
cases: {
|
|
533
|
-
none:
|
|
534
|
-
origin:
|
|
534
|
+
none: U,
|
|
535
|
+
origin: V,
|
|
535
536
|
condition: q,
|
|
536
537
|
step: J,
|
|
537
538
|
launchExperience: mt,
|
|
538
539
|
action: Q,
|
|
539
|
-
__:
|
|
540
|
+
__: O()
|
|
540
541
|
}
|
|
541
542
|
}), m({
|
|
542
543
|
clock: [
|
|
543
544
|
q.doneData,
|
|
544
|
-
W.doneData,
|
|
545
545
|
V.doneData,
|
|
546
|
+
U.doneData,
|
|
546
547
|
R.doneData,
|
|
547
548
|
Y.doneData,
|
|
548
549
|
Q.doneData
|
|
@@ -585,8 +586,8 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
585
586
|
}), m({ clock: o, target: gt }), m({
|
|
586
587
|
source: C([
|
|
587
588
|
q.pending,
|
|
588
|
-
W.pending,
|
|
589
589
|
V.pending,
|
|
590
|
+
U.pending,
|
|
590
591
|
R.pending
|
|
591
592
|
]),
|
|
592
593
|
fn: (i) => i.some(Boolean) ? "transitioning" : "ready",
|
|
@@ -644,10 +645,10 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
644
645
|
stateStore: k,
|
|
645
646
|
// open close
|
|
646
647
|
isOpenStore: A,
|
|
647
|
-
open:
|
|
648
|
-
close:
|
|
649
|
-
toggleOpen:
|
|
650
|
-
setOpen:
|
|
648
|
+
open: F.open,
|
|
649
|
+
close: F.close,
|
|
650
|
+
toggleOpen: F.toggle,
|
|
651
|
+
setOpen: F.set,
|
|
651
652
|
// nodes
|
|
652
653
|
treeStore: e.treeStore,
|
|
653
654
|
currentNodeStore: x,
|
|
@@ -663,11 +664,11 @@ const z = ht("experience-instance"), Ht = it(
|
|
|
663
664
|
};
|
|
664
665
|
}
|
|
665
666
|
);
|
|
666
|
-
function
|
|
667
|
-
return st(
|
|
667
|
+
function Wt(t) {
|
|
668
|
+
return st(jt, t);
|
|
668
669
|
}
|
|
669
670
|
const Gt = it(({ client: t }) => {
|
|
670
|
-
const e = z.store({}), r =
|
|
671
|
+
const e = z.store({}), r = O(), n = O(), s = O(), a = ot(e, {
|
|
671
672
|
register(u, S) {
|
|
672
673
|
const v = [
|
|
673
674
|
...u[S.experienceId] ?? []
|
|
@@ -680,7 +681,7 @@ const Gt = it(({ client: t }) => {
|
|
|
680
681
|
unregister(u, S) {
|
|
681
682
|
var A;
|
|
682
683
|
const v = S.experienceId, T = (A = u[v]) == null ? void 0 : A.filter(
|
|
683
|
-
(
|
|
684
|
+
(F) => F !== S
|
|
684
685
|
);
|
|
685
686
|
return {
|
|
686
687
|
...u,
|
|
@@ -688,7 +689,7 @@ const Gt = it(({ client: t }) => {
|
|
|
688
689
|
};
|
|
689
690
|
}
|
|
690
691
|
}), o = M(
|
|
691
|
-
({ experience: u, target: S }) =>
|
|
692
|
+
({ experience: u, target: S }) => Wt({ client: t, experience: u, target: S })
|
|
692
693
|
), c = M((u) => {
|
|
693
694
|
a.register(u);
|
|
694
695
|
}), d = M(
|
|
@@ -721,11 +722,11 @@ const Gt = it(({ client: t }) => {
|
|
|
721
722
|
);
|
|
722
723
|
return;
|
|
723
724
|
}
|
|
724
|
-
const A =
|
|
725
|
+
const A = Ot(T);
|
|
725
726
|
try {
|
|
726
727
|
v.render(A, S.component, t, u);
|
|
727
|
-
} catch (
|
|
728
|
-
I("error",
|
|
728
|
+
} catch (F) {
|
|
729
|
+
I("error", F);
|
|
729
730
|
}
|
|
730
731
|
});
|
|
731
732
|
m({
|
|
@@ -751,7 +752,7 @@ const Gt = it(({ client: t }) => {
|
|
|
751
752
|
clock: n,
|
|
752
753
|
target: k
|
|
753
754
|
});
|
|
754
|
-
function
|
|
755
|
+
function $(u, S) {
|
|
755
756
|
r({ experience: u, target: S });
|
|
756
757
|
}
|
|
757
758
|
const P = e.map((u) => Object.values(u).flat());
|
|
@@ -759,23 +760,23 @@ const Gt = it(({ client: t }) => {
|
|
|
759
760
|
return e.map((S) => S[u] || [], { skipVoid: !1 });
|
|
760
761
|
}
|
|
761
762
|
return {
|
|
762
|
-
spawn:
|
|
763
|
+
spawn: $,
|
|
763
764
|
getByExperienceId: x,
|
|
764
765
|
listStore: P
|
|
765
766
|
};
|
|
766
767
|
});
|
|
767
|
-
function
|
|
768
|
+
function Zt(t) {
|
|
768
769
|
return st(Gt, t);
|
|
769
770
|
}
|
|
770
771
|
export {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
772
|
+
j as a,
|
|
773
|
+
Zt as b,
|
|
774
|
+
Qt as c,
|
|
775
|
+
zt as d,
|
|
775
776
|
et as e,
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
777
|
+
Ft as f,
|
|
778
|
+
Jt as g,
|
|
779
|
+
Wt as h,
|
|
780
|
+
At as i,
|
|
781
|
+
Yt as t
|
|
781
782
|
};
|
|
@@ -81,15 +81,15 @@ function h() {
|
|
|
81
81
|
export {
|
|
82
82
|
t as G,
|
|
83
83
|
l as a,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
a as b,
|
|
85
|
+
h as c,
|
|
86
|
+
r as d,
|
|
87
|
+
e,
|
|
88
|
+
s as f,
|
|
89
|
+
c as g,
|
|
90
|
+
u as h,
|
|
91
|
+
i,
|
|
92
|
+
f as j,
|
|
93
|
+
y as k,
|
|
94
94
|
p as s
|
|
95
95
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ7D;
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/utils/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAA;AAGzE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CAQ7D;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,CAMhE;AAED,wBAAgB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAa9C;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,IAAI,QAS1E;AAED,KAAK,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAOtE,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EAAE,EACrD,YAAY,EAAE,MAAM,GACnB,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,CAqBpD;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,CAAC,gBAAgB,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,CAAC,EAAE,EAC3D,YAAY,EAAE,MAAM,iBAOrB;AAGD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,QAG1E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,WAMzE;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC,EAAE,MAAM,WAMvE;AAED,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,kBAMpD;AAED,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,GAAG,QAAQ,EAC9B,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,MAAM,eA+BrB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picked/client",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.1764090824933",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@withease/factories": "^1.0.5"
|
|
6
6
|
},
|
|
@@ -45,12 +45,6 @@
|
|
|
45
45
|
"require": "./dist/cjs/plugins/create-experience/index.js",
|
|
46
46
|
"default": "./dist/esm/plugins/create-experience/index.js"
|
|
47
47
|
},
|
|
48
|
-
"./plugins/shopify": {
|
|
49
|
-
"types": "./dist/types/plugins/shopify/index.d.ts",
|
|
50
|
-
"import": "./dist/esm/plugins/shopify/index.js",
|
|
51
|
-
"require": "./dist/cjs/plugins/shopify/index.js",
|
|
52
|
-
"default": "./dist/esm/plugins/shopify/index.js"
|
|
53
|
-
},
|
|
54
48
|
"./plugins/window-object": {
|
|
55
49
|
"types": "./dist/types/plugins/window-object/index.d.ts",
|
|
56
50
|
"import": "./dist/esm/plugins/window-object/index.js",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../../../supports-YvpQZxbh.cjs");require("../../../user-session-CuJzmUIs.cjs");require("../../../experience-instance-B2l_MG7I.cjs");require("effector");function c(){if(r.supportsWindow())return window.pickedConfig}function l(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.customer}function s(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.product}function u(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.collection}function d(){var e;if(r.supportsWindow())return(e=c())==null?void 0:e.experiments}function f(){var e,o;if(r.supportsWindow())return(o=(e=c())==null?void 0:e.storefront_api)==null?void 0:o.token}const t={homepage:/^\/$/,page:/(?:^|\/)pages\/[^/]+$/,blog:/(?:^|\/)blogs\/(?<blogHandle>[^/]+)\/?$/,article:/^\/blogs\/[^/]+\/(?<article>[^/]+)\/?$/,cart:/(?:^|\/)cart\/[^/]+$/,checkout:/^\/checkout\/.+/,appProxy:/^\/(?:a|apps|community|tools)\/(?<proxyTarget>[^/]+)/,accountWildcard:/^\/account\/.+/,accountLogin:/^\/account\/login(?:\/|$)/,accountRegister:/^\/account\/register(?:\/|$)/},n=(e,o)=>o?!!e.exec(o.pathname):!1,a=(e,o)=>{if(o){const i=e.exec(o.pathname);if(i)return i[1]}},p=e=>{var o,i;switch(e){case"product":return((o=s())==null?void 0:o.handle)??!1;case"collection":return((i=u())==null?void 0:i.handle)??!1;default:return!1}},h={"is-page":({location:e})=>n(t.page,e),"get-page-handle":({location:e})=>a(t.page,e),"is-product-page":()=>!!p("product"),"get-product-handle":()=>p("product"),"is-collection-page":()=>!!p("collection"),"get-collection-handle":()=>p("collection"),"is-blog-page":({location:e})=>n(t.blog,e),"get-blog-handle":({location:e})=>a(t.blog,e),"is-article-page":({location:e})=>n(t.article,e),"get-article-handle":({location:e})=>a(t.article,e),"is-app-proxy-page":({location:e})=>n(t.appProxy,e),"get-app-proxy-handle":({location:e})=>a(t.appProxy,e),"is-account-page":({location:e})=>n(t.accountWildcard,e),"is-login-page":({location:e})=>n(t.accountLogin,e),"is-register-page":({location:e})=>n(t.accountRegister,e),"is-cart-page":({location:e})=>n(t.cart,e),"is-checkout-page":({location:e})=>n(t.checkout,e),"is-homepage":({location:e})=>n(t.homepage,e)};function g(){if(!r.supportsWindow()||!window.Shopify)throw new Error("Shopify global object not found. This plugin must be used on a Shopify storefront page.");return window.Shopify}function y(e){var o,i;return typeof((i=(o=g())==null?void 0:o.analytics)==null?void 0:i.publish)=="function"}const P=()=>({name:"shopify",setup:e=>{Object.entries(h).forEach(([o,i])=>{e.registerPredicate(`shopify-${o}`,i)}),r.supportsWindow()&&e.eventBus.watch(o=>{y()&&o.type==="session"&&window.Shopify.analytics.publish("picked:session",{id:o.id})})}});exports.getPickedConfig=c;exports.getPickedConfigCollection=u;exports.getPickedConfigCustomer=l;exports.getPickedConfigExperiments=d;exports.getPickedConfigProduct=s;exports.getPickedConfigStorefrontApiToken=f;exports.getShopify=g;exports.shopifyPlugin=P;
|