@picked/client 0.0.1-dev.1763438100668 → 0.0.1-dev.1763519870626
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/esm/index.js +7 -7
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var m=Object.defineProperty;var y=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../user-session-X9sLAm_B.cjs"),d=require("../logger-BsmHUUw1.cjs"),l=require("../experience-instance-B2l_MG7I.cjs"),S=require("effector"),c=require("../supports-YvpQZxbh.cjs"),u=require("../storage-DuRlyFaY.cjs"),w=(i,e,t)=>{const s=e.name,n=e.setup(i);if(n){const a=t[s]??{};t[s]=Object.freeze({...a,...n})}};function v(i){const e=typeof window<"u",t={client:i,responses:i.responses.listStore.getState(),fields:i.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(t)}const I=()=>S.createEvent(),P=()=>"0.0.1-dev.
|
|
1
|
+
"use strict";var m=Object.defineProperty;var y=(i,e,t)=>e in i?m(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e,t)=>y(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../user-session-X9sLAm_B.cjs"),d=require("../logger-BsmHUUw1.cjs"),l=require("../experience-instance-B2l_MG7I.cjs"),S=require("effector"),c=require("../supports-YvpQZxbh.cjs"),u=require("../storage-DuRlyFaY.cjs"),w=(i,e,t)=>{const s=e.name,n=e.setup(i);if(n){const a=t[s]??{};t[s]=Object.freeze({...a,...n})}};function v(i){const e=typeof window<"u",t={client:i,responses:i.responses.listStore.getState(),fields:i.fields.listStore.getState(),location:e?window.location:void 0,document:e?window.document:void 0,sessionStorage:e?window.sessionStorage:void 0,localStorage:e?window.localStorage:void 0};return Object.freeze(t)}const I=()=>S.createEvent(),P=()=>"0.0.1-dev.1763519870626";function k(){if(c.supportsDocument()){const i=[document.currentScript,document.getElementById("picked_script"),document.getElementById("picked"),document.getElementById("cvly"),document.getElementById("cvly-x")];for(const e of i)if(e!=null&&e.dataset.api)return e.dataset.api}return"https://api.picked.app"}function x(){if(!c.supportsWindow())return{};const i=new URLSearchParams(window.location.search),e={},t=new Set;for(const[n]of i.entries())n.startsWith("picked-")&&t.add(n);for(const n of t){const a=n.replace("picked-","");e[a]=i.getAll(n)}const s=u.createStorageKey("s");if(t.size>0)u.sessionStore.set(s,e);else{const n=u.sessionStore.get(s);if(n)return n.json()||{}}return e}class h{constructor(e){o(this,"options");o(this,"isReady",!1);o(this,"project");o(this,"plugins",{});o(this,"eventBus",I());o(this,"organizationId");o(this,"projectId");o(this,"apiUrl");o(this,"session");o(this,"searchParams",x());o(this,"history",r.createHistory());o(this,"components",r.createComponentIndex({client:this}));o(this,"experienceInstances",l.createExperienceInstanceIndex({client:this}));o(this,"experiences",r.createExperienceIndex({client:this}));o(this,"frameworks",r.createFrameworkIndex({client:this}));o(this,"predicates",r.createPredicateIndex({client:this}));o(this,"features",r.createFeatureIndex({client:this}));o(this,"responses",r.createResponseIndex({client:this}));o(this,"fields",r.createFieldIndex());o(this,"actions",r.createActionIndex());d.logger("info","Picked client initializing."),this.organizationId=e.organizationId,this.projectId=e.projectId,this.options=Object.freeze(e),this.apiUrl=e.apiUrl||k(),this.session=r.initialiseSession(),this.setupPlugins(),this.setupFeatures(),this.setupPredicates(),this.setupActions(),this.eventBus({type:"initialized",version:P()}),d.logger("info","Picked client initialized.")}start(){r.ping(this),(async()=>{c.supportsDocument()&&(document.body&&r.initialiseExperiences(this),await l.domInteractive(),r.initialiseExperiences(this),this.eventBus({type:"ready"}),this.isReady=!0,this.session&&this.eventBus({type:"session",...this.session}))})()}registerFramework(e){r.setupFramework(e,this.frameworks)}registerComponent(e,t){r.setupComponent(e,t,this.components)}registerPlugin(e){w(this,e,this.plugins)}registerFeature(e,t){r.setupFeature(e,t,this.features)}registerPredicate(e,t){r.setupPredicate(e,t,this.predicates)}registerField(e){r.setupField(e,this.fields)}registerAction(e,t){r.setupAction(e,t,this.actions)}registerExperience(e){e.component&&r.setupComponent(`experience:${e.id}`,e.component,this.components),r.setupExperience(e,this.experiences)}getStateSnapshot(){return v(this)}async launchExperienceById(e){const t=this.experiences.getById(e).getState();if(!t){d.logger("warn",`Experience with id '${e}' not found.`);return}r.initialiseExperience(this,t)}setupPlugins(){var e;(e=this.options.plugins)==null||e.forEach(t=>{if(Array.isArray(t)){t.forEach(n=>{this.registerPlugin(n)});return}const s=typeof t=="function"?t():t;if(Array.isArray(s)){s.forEach(n=>this.registerPlugin(n));return}this.registerPlugin(s)})}setupFeatures(){const e=this.options.features;e&&(Object.entries(e).forEach(([t,s])=>{const n=typeof s=="function"?s():s;this.registerFeature(t,n)}),this.searchParams.feature&&this.searchParams.feature.forEach(t=>{try{const[s,n]=t.split(":");if(!s||!n)return;let a=n;a==="true"&&(a=!0),a==="false"&&(a=!1),this.registerFeature(s,{key:`${a}`,name:s,decide:()=>a,storage:"session"})}catch{}}))}setupPredicates(){const e=this.options.predicates;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Predicate "${t}" is not a function.`);return}this.registerPredicate(t,s)})}setupActions(){const e=this.options.actions;e&&Object.entries(e).forEach(([t,s])=>{if(typeof s!="function"){d.logger("warn",`Action "${t}" is not a function.`);return}this.registerAction(t,s)})}getPluginConfig(e){return this.plugins[e]??{}}}o(h,"logger",d.logger);function f(i){var e;return((e=i.options)==null?void 0:e.some(t=>"condition"in t))??!1}function E(i){return i.some(e=>e.condition||f(e))}async function C(i,e){return e.length===0||!E(e)?e:(await Promise.all(e.map(async s=>{if(!(s.condition?await l.evaluateRuleLogic(i,s.condition):!0))return null;if(!s.options||!f(s))return s;const g=(await Promise.all(s.options.map(async p=>p.condition?await l.evaluateRuleLogic(i,p.condition)?p:null:p))).filter(p=>p!==null);return g.length===s.options.length?s:g.length===0?null:{...s,options:g}}))).filter(s=>s!==null)}const R=i=>{const e=new h(i);return c.bindClient(e),e};exports.evaluateRuleLogic=l.evaluateRuleLogic;exports.isPickedRoot=l.isPickedRoot;exports.supportsCookies=c.supportsCookies;exports.supportsCryptoRandomUUID=c.supportsCryptoRandomUUID;exports.supportsDocument=c.supportsDocument;exports.supportsHistory=c.supportsHistory;exports.supportsIntersectionObserver=c.supportsIntersectionObserver;exports.supportsLocalStorage=c.supportsLocalStorage;exports.supportsLocation=c.supportsLocation;exports.supportsSessionStorage=c.supportsSessionStorage;exports.supportsShadowRoot=c.supportsShadowRoot;exports.supportsWebComponents=c.supportsWebComponents;exports.supportsWindow=c.supportsWindow;exports.createStorageKey=u.createStorageKey;exports.localStore=u.localStore;exports.sessionStore=u.sessionStore;exports.subscribe=u.subscribe;exports.Picked=h;exports.createClient=R;exports.getStepFields=C;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var y = Object.defineProperty;
|
|
2
2
|
var w = (i, e, t) => e in i ? y(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var n = (i, e, t) => w(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { c as S, a as x, b as I, d as
|
|
4
|
+
import { c as S, a as x, b as I, d as v, e as P, f as k, g as E, h as F, i as b, j as C, p as A, s as R, k as u, l as j, m as B, n as z, o as U, q as O, r as $, t as d } from "../user-session-CxJHSMaR.js";
|
|
5
5
|
import { l as c } from "../logger-C9a75KZn.js";
|
|
6
6
|
import { c as K, d as L, e as l } from "../experience-instance-CeuHLrdL.js";
|
|
7
7
|
import { i as pe } from "../experience-instance-CeuHLrdL.js";
|
|
@@ -9,7 +9,7 @@ import { createEvent as W } from "effector";
|
|
|
9
9
|
import { s as h, a as _, b as D } from "../supports-DBMT17KZ.js";
|
|
10
10
|
import { g as de, k as le, d as fe, i as he, e as ge, c as me, f as ye, h as we, j as Se } from "../supports-DBMT17KZ.js";
|
|
11
11
|
import { c as H, s as f } from "../storage-Cb_71y48.js";
|
|
12
|
-
import { l as Ie, a as
|
|
12
|
+
import { l as Ie, a as ve } from "../storage-Cb_71y48.js";
|
|
13
13
|
const q = (i, e, t) => {
|
|
14
14
|
const s = e.name, r = e.setup(i);
|
|
15
15
|
if (r) {
|
|
@@ -29,7 +29,7 @@ function N(i) {
|
|
|
29
29
|
};
|
|
30
30
|
return Object.freeze(t);
|
|
31
31
|
}
|
|
32
|
-
const T = () => W(), V = () => "0.0.1-dev.
|
|
32
|
+
const T = () => W(), V = () => "0.0.1-dev.1763519870626";
|
|
33
33
|
function G() {
|
|
34
34
|
if (h()) {
|
|
35
35
|
const i = [
|
|
@@ -81,8 +81,8 @@ class g {
|
|
|
81
81
|
n(this, "components", x({ client: this }));
|
|
82
82
|
n(this, "experienceInstances", K({ client: this }));
|
|
83
83
|
n(this, "experiences", I({ client: this }));
|
|
84
|
-
n(this, "frameworks",
|
|
85
|
-
n(this, "predicates",
|
|
84
|
+
n(this, "frameworks", v({ client: this }));
|
|
85
|
+
n(this, "predicates", P({ client: this }));
|
|
86
86
|
n(this, "features", k({ client: this }));
|
|
87
87
|
n(this, "responses", E({ client: this }));
|
|
88
88
|
n(this, "fields", F());
|
|
@@ -91,7 +91,7 @@ class g {
|
|
|
91
91
|
}
|
|
92
92
|
start() {
|
|
93
93
|
A(this), (async () => {
|
|
94
|
-
h() && (document.body && d(this), await L(),
|
|
94
|
+
h() && (document.body && d(this), await L(), d(this), this.eventBus({ type: "ready" }), this.isReady = !0, this.session && this.eventBus({ type: "session", ...this.session }));
|
|
95
95
|
})();
|
|
96
96
|
}
|
|
97
97
|
registerFramework(e) {
|
|
@@ -237,7 +237,7 @@ export {
|
|
|
237
237
|
pe as isPickedRoot,
|
|
238
238
|
Ie as localStore,
|
|
239
239
|
f as sessionStore,
|
|
240
|
-
|
|
240
|
+
ve as subscribe,
|
|
241
241
|
de as supportsCookies,
|
|
242
242
|
le as supportsCryptoRandomUUID,
|
|
243
243
|
h as supportsDocument,
|