@picked/client 0.0.77 → 0.0.78-next.2
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/.tsbuildinfo +1 -1
- package/dist/{api-DbeSZFlM.cjs → api-R3q_6NiX.cjs} +1 -1
- package/dist/{api-BLnGMB-Q.js → api-gGqMLTec.js} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/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/server/index.js +1 -1
- package/dist/docs/reference/dashboard/fields.mdx +17 -11
- package/dist/docs/reference/sdk/fields.md +38 -6
- package/dist/esm/index.js +140 -113
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{plugin-BpYxGWE7.js → plugin-CaJyXwSN.js} +2 -2
- package/dist/{plugin-CY9-Cnyw.cjs → plugin-D4WVP2aO.cjs} +1 -1
- package/dist/{provider-C_YC-x5G.cjs → provider-C12099cw.cjs} +1 -1
- package/dist/{provider-c22OqrZH.js → provider-D5CCq15k.js} +1 -1
- package/dist/types/client.d.ts +21 -0
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +26 -7
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/field/policies.d.ts +35 -0
- package/dist/types/entities/field/policies.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/picked.d.ts +1 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +3 -8
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/{version-BEoE_p3Q.js → version-CaCM83j4.js} +1 -1
- package/dist/{version-B921c7hc.cjs → version-ZVJWOz2D.cjs} +1 -1
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { a as i, c as a, d as o, f as s, i as c, l, m as u, n as d, o as f, r as
|
|
|
5
5
|
import { a as _, i as v, r as ee, s as y, t as b } from "../dom-BqcToNL0.js";
|
|
6
6
|
import { l as x, n as S, r as C, u as w } from "../experience-instance-DGk11d8a.js";
|
|
7
7
|
import { i as T, n as E, r as D, t as O } from "../storage-1MW3-_As.js";
|
|
8
|
-
import { i as te, n as ne, r as re, t as ie } from "../version-
|
|
8
|
+
import { i as te, n as ne, r as re, t as ie } from "../version-CaCM83j4.js";
|
|
9
9
|
import { t as ae } from "../id-Bo4RBeOs.js";
|
|
10
10
|
import { n as oe, r as se, t as ce } from "../inert-script-report-B_bMPRzp.js";
|
|
11
11
|
import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as le, sample as I } from "effector";
|
|
@@ -857,20 +857,37 @@ var Xe = 0, Ze = (e) => {
|
|
|
857
857
|
at: /* @__PURE__ */ new Date(),
|
|
858
858
|
payload: t
|
|
859
859
|
}]), t;
|
|
860
|
-
}
|
|
861
|
-
|
|
860
|
+
};
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/entities/field/policies.ts
|
|
863
|
+
function Qe(e) {
|
|
864
|
+
let { doNotTrackValue: t, doNotStoreValue: n } = e ?? {}, r = e?.trackValue ?? t === !1, i = e?.storeValue ?? n === !1;
|
|
865
|
+
return {
|
|
866
|
+
trackValue: r,
|
|
867
|
+
storeValue: i,
|
|
868
|
+
doNotTrackValue: !r,
|
|
869
|
+
doNotStoreValue: !i
|
|
870
|
+
};
|
|
871
|
+
}
|
|
872
|
+
//#endregion
|
|
873
|
+
//#region src/entities/field/field.ts
|
|
874
|
+
var $e = M("field"), et = L(() => {
|
|
875
|
+
let e = $e.store({}), t = j(e, {
|
|
862
876
|
register(e, t) {
|
|
877
|
+
let n = Object.assign({}, t.field, { policies: Qe(t.field.policies) });
|
|
863
878
|
return {
|
|
864
879
|
...e,
|
|
865
|
-
[
|
|
880
|
+
[n.id]: n
|
|
866
881
|
};
|
|
867
882
|
},
|
|
868
883
|
updateByKey(e, t) {
|
|
869
884
|
let n = Object.values(e).find((e) => e.key === t.fieldKey);
|
|
870
|
-
|
|
885
|
+
if (!n) return e;
|
|
886
|
+
let r = Object.assign({}, n, t.updates);
|
|
887
|
+
return {
|
|
871
888
|
...e,
|
|
872
|
-
[n.id]: Object.assign({},
|
|
873
|
-
}
|
|
889
|
+
[n.id]: Object.assign({}, r, { policies: Qe(r.policies) })
|
|
890
|
+
};
|
|
874
891
|
}
|
|
875
892
|
});
|
|
876
893
|
function n(e) {
|
|
@@ -906,13 +923,13 @@ var Xe = 0, Ze = (e) => {
|
|
|
906
923
|
getByName: c
|
|
907
924
|
};
|
|
908
925
|
});
|
|
909
|
-
function
|
|
910
|
-
return R(
|
|
926
|
+
function tt() {
|
|
927
|
+
return R(et);
|
|
911
928
|
}
|
|
912
929
|
//#endregion
|
|
913
930
|
//#region src/entities/step/step.ts
|
|
914
|
-
var
|
|
915
|
-
let e =
|
|
931
|
+
var nt = M("step"), rt = L(() => {
|
|
932
|
+
let e = nt.store({}), t = j(e, { register(e, t) {
|
|
916
933
|
return {
|
|
917
934
|
...e,
|
|
918
935
|
[t.step.id]: t.step
|
|
@@ -936,16 +953,16 @@ var tt = M("step"), nt = L(() => {
|
|
|
936
953
|
indexStore: e
|
|
937
954
|
};
|
|
938
955
|
});
|
|
939
|
-
function
|
|
940
|
-
return R(
|
|
956
|
+
function it() {
|
|
957
|
+
return R(rt);
|
|
941
958
|
}
|
|
942
|
-
function
|
|
959
|
+
function at(e, t) {
|
|
943
960
|
t.register(e);
|
|
944
961
|
}
|
|
945
962
|
//#endregion
|
|
946
963
|
//#region src/entities/content/content.ts
|
|
947
|
-
var
|
|
948
|
-
let e =
|
|
964
|
+
var ot = M("content"), st = L(() => {
|
|
965
|
+
let e = ot.store({}), t = j(e, {
|
|
949
966
|
register(e, t) {
|
|
950
967
|
return {
|
|
951
968
|
...e,
|
|
@@ -986,16 +1003,16 @@ var at = M("content"), ot = L(() => {
|
|
|
986
1003
|
indexStore: e
|
|
987
1004
|
};
|
|
988
1005
|
});
|
|
989
|
-
function
|
|
990
|
-
return R(
|
|
1006
|
+
function ct() {
|
|
1007
|
+
return R(st);
|
|
991
1008
|
}
|
|
992
|
-
function
|
|
1009
|
+
function lt(e, t) {
|
|
993
1010
|
t.register(e);
|
|
994
1011
|
}
|
|
995
1012
|
//#endregion
|
|
996
1013
|
//#region src/entities/action/action.ts
|
|
997
|
-
var
|
|
998
|
-
let t =
|
|
1014
|
+
var ut = M("action"), dt = L(({ client: e }) => {
|
|
1015
|
+
let t = ut.store({}), n = j(t, { register(e, t) {
|
|
999
1016
|
return {
|
|
1000
1017
|
...e,
|
|
1001
1018
|
[t.key]: {
|
|
@@ -1053,10 +1070,10 @@ var lt = M("action"), ut = L(({ client: e }) => {
|
|
|
1053
1070
|
getEvokableAction: s
|
|
1054
1071
|
};
|
|
1055
1072
|
});
|
|
1056
|
-
function
|
|
1057
|
-
return R(
|
|
1073
|
+
function ft(e) {
|
|
1074
|
+
return R(dt, e);
|
|
1058
1075
|
}
|
|
1059
|
-
var
|
|
1076
|
+
var pt = (e, t, n) => {
|
|
1060
1077
|
n.register({
|
|
1061
1078
|
key: e,
|
|
1062
1079
|
action: t
|
|
@@ -1075,35 +1092,35 @@ function J(e, t, n, r) {
|
|
|
1075
1092
|
function Y(e) {
|
|
1076
1093
|
return e === null || e === "" || Array.isArray(e) && !e.length;
|
|
1077
1094
|
}
|
|
1078
|
-
function
|
|
1095
|
+
function mt(e) {
|
|
1079
1096
|
return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
|
|
1080
1097
|
}
|
|
1081
|
-
function
|
|
1098
|
+
function ht(e) {
|
|
1082
1099
|
try {
|
|
1083
1100
|
return JSON.stringify(e), !0;
|
|
1084
1101
|
} catch {
|
|
1085
1102
|
return !1;
|
|
1086
1103
|
}
|
|
1087
1104
|
}
|
|
1088
|
-
function
|
|
1105
|
+
function gt(e, t) {
|
|
1089
1106
|
return t.find((t) => t.key === e) ?? null;
|
|
1090
1107
|
}
|
|
1091
|
-
function
|
|
1108
|
+
function _t(e, t) {
|
|
1092
1109
|
return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
|
|
1093
1110
|
}
|
|
1094
|
-
function
|
|
1111
|
+
function vt(e, t) {
|
|
1095
1112
|
if (e.type !== "object" || Y(t)) return null;
|
|
1096
1113
|
if (e.multiple) {
|
|
1097
1114
|
if (!Array.isArray(t)) return J(e, t, "This field expects multiple values", "Field expects an array of objects.");
|
|
1098
1115
|
for (let n of t) {
|
|
1099
1116
|
if (typeof n != "object" || !n) return J(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
|
|
1100
|
-
if (!
|
|
1117
|
+
if (!ht(n)) return J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1101
1118
|
}
|
|
1102
1119
|
return null;
|
|
1103
1120
|
}
|
|
1104
|
-
return Array.isArray(t) ? J(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? J(e, t, "This field expects an object value", "Field expects an object value.") :
|
|
1121
|
+
return Array.isArray(t) ? J(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? J(e, t, "This field expects an object value", "Field expects an object value.") : ht(t) ? null : J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
|
|
1105
1122
|
}
|
|
1106
|
-
function
|
|
1123
|
+
function yt(e, t) {
|
|
1107
1124
|
if (Y(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
|
|
1108
1125
|
let n = Array.isArray(t) ? t : [t];
|
|
1109
1126
|
if (e.type === "object") {
|
|
@@ -1111,9 +1128,9 @@ function vt(e, t) {
|
|
|
1111
1128
|
return n.every((e) => r.has(JSON.stringify(e))) ? null : J(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
|
|
1112
1129
|
}
|
|
1113
1130
|
let r = e.options.map((e) => e.value);
|
|
1114
|
-
return n.every((e) => !
|
|
1131
|
+
return n.every((e) => !mt(e) || e === null ? !1 : r.includes(e)) ? null : J(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
|
|
1115
1132
|
}
|
|
1116
|
-
async function
|
|
1133
|
+
async function bt(t, n, r, i) {
|
|
1117
1134
|
if (n.validation && !e(n.validation) && !Y(r)) {
|
|
1118
1135
|
let e = i ? {
|
|
1119
1136
|
$input: r,
|
|
@@ -1126,8 +1143,8 @@ async function yt(t, n, r, i) {
|
|
|
1126
1143
|
}
|
|
1127
1144
|
//#endregion
|
|
1128
1145
|
//#region src/entities/response/response.ts
|
|
1129
|
-
var
|
|
1130
|
-
let t =
|
|
1146
|
+
var xt = M("response"), St = L(({ client: e }) => {
|
|
1147
|
+
let t = xt.store({}), r = P(), i = P(), a = j(t, {
|
|
1131
1148
|
register(e, t) {
|
|
1132
1149
|
return {
|
|
1133
1150
|
...e,
|
|
@@ -1166,7 +1183,7 @@ var bt = M("response"), xt = L(({ client: e }) => {
|
|
|
1166
1183
|
...t,
|
|
1167
1184
|
...n
|
|
1168
1185
|
}, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
|
|
1169
|
-
let o =
|
|
1186
|
+
let o = gt(t, e);
|
|
1170
1187
|
if (!o) {
|
|
1171
1188
|
r.push({
|
|
1172
1189
|
fieldKey: t,
|
|
@@ -1176,17 +1193,17 @@ var bt = M("response"), xt = L(({ client: e }) => {
|
|
|
1176
1193
|
});
|
|
1177
1194
|
return;
|
|
1178
1195
|
}
|
|
1179
|
-
let c =
|
|
1196
|
+
let c = _t(o, n), l = await bt(s, o, c, a);
|
|
1180
1197
|
if (l) {
|
|
1181
1198
|
r.push(l);
|
|
1182
1199
|
return;
|
|
1183
1200
|
}
|
|
1184
|
-
let u =
|
|
1201
|
+
let u = vt(o, c);
|
|
1185
1202
|
if (u) {
|
|
1186
1203
|
r.push(u);
|
|
1187
1204
|
return;
|
|
1188
1205
|
}
|
|
1189
|
-
let d =
|
|
1206
|
+
let d = yt(o, c);
|
|
1190
1207
|
if (d) {
|
|
1191
1208
|
r.push(d);
|
|
1192
1209
|
return;
|
|
@@ -1265,13 +1282,13 @@ var bt = M("response"), xt = L(({ client: e }) => {
|
|
|
1265
1282
|
getByFieldName: _
|
|
1266
1283
|
};
|
|
1267
1284
|
});
|
|
1268
|
-
function
|
|
1269
|
-
return R(
|
|
1285
|
+
function Ct(e) {
|
|
1286
|
+
return R(St, e);
|
|
1270
1287
|
}
|
|
1271
1288
|
//#endregion
|
|
1272
1289
|
//#region src/entities/condition/condition.ts
|
|
1273
|
-
var
|
|
1274
|
-
let e =
|
|
1290
|
+
var wt = M("condition"), Tt = L(() => {
|
|
1291
|
+
let e = wt.store({}), t = j(e, { register(e, t) {
|
|
1275
1292
|
return {
|
|
1276
1293
|
...e,
|
|
1277
1294
|
[t.condition.id]: t.condition
|
|
@@ -1295,12 +1312,12 @@ var Ct = M("condition"), wt = L(() => {
|
|
|
1295
1312
|
indexStore: e
|
|
1296
1313
|
};
|
|
1297
1314
|
});
|
|
1298
|
-
function
|
|
1299
|
-
return R(
|
|
1315
|
+
function Et() {
|
|
1316
|
+
return R(Tt);
|
|
1300
1317
|
}
|
|
1301
1318
|
//#endregion
|
|
1302
1319
|
//#region src/utils/api-url.ts
|
|
1303
|
-
function
|
|
1320
|
+
function Dt() {
|
|
1304
1321
|
if (c()) {
|
|
1305
1322
|
let e = [
|
|
1306
1323
|
document.currentScript,
|
|
@@ -1315,7 +1332,7 @@ function Et() {
|
|
|
1315
1332
|
}
|
|
1316
1333
|
//#endregion
|
|
1317
1334
|
//#region src/utils/search-params.ts
|
|
1318
|
-
function
|
|
1335
|
+
function Ot() {
|
|
1319
1336
|
if (!s()) return {};
|
|
1320
1337
|
let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
|
|
1321
1338
|
for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
|
|
@@ -1333,13 +1350,13 @@ function Dt() {
|
|
|
1333
1350
|
}
|
|
1334
1351
|
//#endregion
|
|
1335
1352
|
//#region src/entities/session/session.ts
|
|
1336
|
-
var
|
|
1337
|
-
function
|
|
1353
|
+
var kt = O("session", "global");
|
|
1354
|
+
function At() {
|
|
1338
1355
|
return p() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
|
|
1339
1356
|
}
|
|
1340
|
-
function
|
|
1357
|
+
function jt() {
|
|
1341
1358
|
if (!m()) return null;
|
|
1342
|
-
let e = E.get(
|
|
1359
|
+
let e = E.get(kt);
|
|
1343
1360
|
if (!e.isSet()) return null;
|
|
1344
1361
|
try {
|
|
1345
1362
|
return e.json();
|
|
@@ -1347,8 +1364,8 @@ function At() {
|
|
|
1347
1364
|
return null;
|
|
1348
1365
|
}
|
|
1349
1366
|
}
|
|
1350
|
-
var
|
|
1351
|
-
let e =
|
|
1367
|
+
var Mt = L(() => {
|
|
1368
|
+
let e = jt(), t = { id: e?.id ?? At() };
|
|
1352
1369
|
e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
|
|
1353
1370
|
let n = F(t), r = j(n, {
|
|
1354
1371
|
setIsUser: (e, t) => ({
|
|
@@ -1374,7 +1391,7 @@ var jt = L(() => {
|
|
|
1374
1391
|
source: n,
|
|
1375
1392
|
effect: (e) => {
|
|
1376
1393
|
if (m()) try {
|
|
1377
|
-
E.get(
|
|
1394
|
+
E.get(kt).set(e);
|
|
1378
1395
|
} catch {}
|
|
1379
1396
|
}
|
|
1380
1397
|
});
|
|
@@ -1388,27 +1405,27 @@ var jt = L(() => {
|
|
|
1388
1405
|
removeIdentifier: r.removeIdentifier
|
|
1389
1406
|
};
|
|
1390
1407
|
});
|
|
1391
|
-
function
|
|
1392
|
-
return R(
|
|
1408
|
+
function Nt() {
|
|
1409
|
+
return R(Mt, void 0);
|
|
1393
1410
|
}
|
|
1394
1411
|
//#endregion
|
|
1395
1412
|
//#region src/utils/picked-config.ts
|
|
1396
|
-
function Nt() {
|
|
1397
|
-
if (s()) return globalThis.window.pickedConfig;
|
|
1398
|
-
}
|
|
1399
1413
|
function Pt() {
|
|
1400
|
-
if (s()) return
|
|
1414
|
+
if (s()) return globalThis.window.pickedConfig;
|
|
1401
1415
|
}
|
|
1402
1416
|
function Ft() {
|
|
1417
|
+
if (s()) return Pt()?.projectId;
|
|
1418
|
+
}
|
|
1419
|
+
function It() {
|
|
1403
1420
|
if (!c()) return;
|
|
1404
1421
|
let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
|
|
1405
1422
|
if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
|
|
1406
1423
|
}
|
|
1407
|
-
function
|
|
1424
|
+
function Lt(e) {
|
|
1408
1425
|
if (e.projectId) return e.projectId;
|
|
1409
|
-
let t =
|
|
1426
|
+
let t = Ft();
|
|
1410
1427
|
if (t) return t;
|
|
1411
|
-
let n =
|
|
1428
|
+
let n = It();
|
|
1412
1429
|
if (n) return n;
|
|
1413
1430
|
throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
|
|
1414
1431
|
}
|
|
@@ -1417,7 +1434,7 @@ function It(e) {
|
|
|
1417
1434
|
function X(e) {
|
|
1418
1435
|
return e == null || e === "" || Number.isNaN(e);
|
|
1419
1436
|
}
|
|
1420
|
-
var
|
|
1437
|
+
var Rt = {
|
|
1421
1438
|
default: (e, t) => X(e) ? String(t ?? "") : String(e),
|
|
1422
1439
|
append: (e, t) => t && !X(e) ? `${e} ${t}` : e,
|
|
1423
1440
|
prepend: (e, t) => t && !X(e) ? `${t} ${e}` : e,
|
|
@@ -1438,24 +1455,24 @@ var Lt = {
|
|
|
1438
1455
|
return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
|
|
1439
1456
|
}
|
|
1440
1457
|
};
|
|
1441
|
-
function
|
|
1458
|
+
function zt(e) {
|
|
1442
1459
|
return typeof e == "object" && !!e;
|
|
1443
1460
|
}
|
|
1444
|
-
function
|
|
1461
|
+
function Bt(e, t) {
|
|
1445
1462
|
let n = t;
|
|
1446
|
-
for (let t of e.split(".")) if (
|
|
1463
|
+
for (let t of e.split(".")) if (zt(n) && t in n) n = n[t];
|
|
1447
1464
|
else return;
|
|
1448
1465
|
return typeof n == "function" ? n() : n;
|
|
1449
1466
|
}
|
|
1450
|
-
function
|
|
1451
|
-
let n = e.split("|").map((e) => e.trim()), r =
|
|
1467
|
+
function Vt(e, t) {
|
|
1468
|
+
let n = e.split("|").map((e) => e.trim()), r = Bt(n.shift() ?? "", t);
|
|
1452
1469
|
for (let e of n) {
|
|
1453
|
-
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o =
|
|
1470
|
+
let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Rt[i];
|
|
1454
1471
|
o && (r = o(r, a));
|
|
1455
1472
|
}
|
|
1456
1473
|
return X(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
|
|
1457
1474
|
}
|
|
1458
|
-
function
|
|
1475
|
+
function Ht(e, t) {
|
|
1459
1476
|
let n = "", r = 0;
|
|
1460
1477
|
for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
|
|
1461
1478
|
r += 2;
|
|
@@ -1467,19 +1484,19 @@ function Vt(e, t) {
|
|
|
1467
1484
|
}
|
|
1468
1485
|
i += e[r++];
|
|
1469
1486
|
}
|
|
1470
|
-
n +=
|
|
1487
|
+
n += Vt(i.trim(), t);
|
|
1471
1488
|
} else n += e[r++];
|
|
1472
1489
|
return n;
|
|
1473
1490
|
}
|
|
1474
1491
|
//#endregion
|
|
1475
1492
|
//#region src/utils/preview-session.ts
|
|
1476
|
-
var
|
|
1477
|
-
function
|
|
1478
|
-
return !s() || !h() ? !1 : !!
|
|
1493
|
+
var Ut = "preview-token";
|
|
1494
|
+
function Wt() {
|
|
1495
|
+
return !s() || !h() ? !1 : !!Ot()[Ut]?.[0];
|
|
1479
1496
|
}
|
|
1480
1497
|
//#endregion
|
|
1481
1498
|
//#region src/picked.ts
|
|
1482
|
-
var
|
|
1499
|
+
var Gt = class {
|
|
1483
1500
|
static logger = r;
|
|
1484
1501
|
options;
|
|
1485
1502
|
dataSource = null;
|
|
@@ -1495,8 +1512,8 @@ var Wt = class {
|
|
|
1495
1512
|
apiUrl;
|
|
1496
1513
|
dashboardUrl;
|
|
1497
1514
|
documentationSiteUrl;
|
|
1498
|
-
session =
|
|
1499
|
-
searchParams =
|
|
1515
|
+
session = Nt();
|
|
1516
|
+
searchParams = Ot();
|
|
1500
1517
|
history = Ye();
|
|
1501
1518
|
components = Se({ client: this });
|
|
1502
1519
|
experienceInstances = S({ client: this });
|
|
@@ -1504,12 +1521,12 @@ var Wt = class {
|
|
|
1504
1521
|
frameworks = Ee({ client: this });
|
|
1505
1522
|
predicates = Ge({ client: this });
|
|
1506
1523
|
features = ne({ client: this });
|
|
1507
|
-
conditions =
|
|
1508
|
-
fields =
|
|
1509
|
-
responses =
|
|
1510
|
-
steps =
|
|
1511
|
-
contents =
|
|
1512
|
-
actions =
|
|
1524
|
+
conditions = Et();
|
|
1525
|
+
fields = tt();
|
|
1526
|
+
responses = Ct({ client: this });
|
|
1527
|
+
steps = it();
|
|
1528
|
+
contents = ct();
|
|
1529
|
+
actions = ft({ client: this });
|
|
1513
1530
|
conditionResults = C();
|
|
1514
1531
|
stateSnapshotStore = ke({ client: this });
|
|
1515
1532
|
evaluateRuleLogicFx = Le({ client: this });
|
|
@@ -1524,14 +1541,14 @@ var Wt = class {
|
|
|
1524
1541
|
effect: (e, { template: t, context: n }) => {
|
|
1525
1542
|
let r = {};
|
|
1526
1543
|
for (let t of e) r[t.fieldKey] = t.value;
|
|
1527
|
-
return
|
|
1544
|
+
return Ht(t, {
|
|
1528
1545
|
...n,
|
|
1529
1546
|
responses: r
|
|
1530
1547
|
});
|
|
1531
1548
|
}
|
|
1532
1549
|
});
|
|
1533
1550
|
constructor(e) {
|
|
1534
|
-
this.events = Ze(this.eventBus), this.projectId =
|
|
1551
|
+
this.events = Ze(this.eventBus), this.projectId = Lt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Dt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupFields(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
|
|
1535
1552
|
type: "load",
|
|
1536
1553
|
version: ie()
|
|
1537
1554
|
}), this.maybeStartPreviewChannel();
|
|
@@ -1539,7 +1556,7 @@ var Wt = class {
|
|
|
1539
1556
|
dataProviderFor(e) {
|
|
1540
1557
|
let t = e ?? "", n = this.dataProviders.get(t);
|
|
1541
1558
|
if (n) return n;
|
|
1542
|
-
let r = import("../provider-
|
|
1559
|
+
let r = import("../provider-D5CCq15k.js").then((t) => t.createPickedDataProvider({
|
|
1543
1560
|
apiUrl: this.apiUrl,
|
|
1544
1561
|
projectId: this.projectId,
|
|
1545
1562
|
...e !== void 0 && { previewToken: e }
|
|
@@ -1555,7 +1572,7 @@ var Wt = class {
|
|
|
1555
1572
|
return (await this.dataProviderFor(t?.previewToken)).getContent(e, t?.signal === void 0 ? void 0 : { signal: t.signal });
|
|
1556
1573
|
}
|
|
1557
1574
|
maybeStartPreviewChannel() {
|
|
1558
|
-
|
|
1575
|
+
Wt() && import("../preview-channel-CSr96XAo.js").then((e) => e.initPreviewChannel(this)).catch(() => void 0);
|
|
1559
1576
|
}
|
|
1560
1577
|
registerFramework = (e) => {
|
|
1561
1578
|
De(e, this.frameworks);
|
|
@@ -1581,16 +1598,16 @@ var Wt = class {
|
|
|
1581
1598
|
this.fields.register(e);
|
|
1582
1599
|
};
|
|
1583
1600
|
registerStep = (e) => {
|
|
1584
|
-
|
|
1601
|
+
at(e, this.steps);
|
|
1585
1602
|
};
|
|
1586
1603
|
registerContent = (e) => {
|
|
1587
|
-
|
|
1604
|
+
lt(e, this.contents);
|
|
1588
1605
|
};
|
|
1589
1606
|
patchContent = (e, t) => {
|
|
1590
1607
|
this.contents.patch(e, t);
|
|
1591
1608
|
};
|
|
1592
1609
|
registerAction = (e, t) => {
|
|
1593
|
-
|
|
1610
|
+
pt(e, t, this.actions);
|
|
1594
1611
|
};
|
|
1595
1612
|
registerExperience = (e) => {
|
|
1596
1613
|
e.component && Ce(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
|
|
@@ -1669,6 +1686,16 @@ var Wt = class {
|
|
|
1669
1686
|
this.registerAction(e, t);
|
|
1670
1687
|
});
|
|
1671
1688
|
}
|
|
1689
|
+
setupFields() {
|
|
1690
|
+
let e = this.options.fields;
|
|
1691
|
+
e && Object.entries(e).forEach(([e, t]) => {
|
|
1692
|
+
let n = typeof t == "function" ? t() : t;
|
|
1693
|
+
this.registerField({
|
|
1694
|
+
...n,
|
|
1695
|
+
key: n.key ?? e
|
|
1696
|
+
});
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1672
1699
|
setupComponents() {
|
|
1673
1700
|
let e = this.options.components;
|
|
1674
1701
|
e && Object.entries(e).forEach(([e, t]) => {
|
|
@@ -1676,8 +1703,8 @@ var Wt = class {
|
|
|
1676
1703
|
});
|
|
1677
1704
|
}
|
|
1678
1705
|
getPluginConfig = (e) => this.plugins[e] ?? {};
|
|
1679
|
-
},
|
|
1680
|
-
async function
|
|
1706
|
+
}, Kt = "application/picked-javascript", qt = "application/picked-module", Jt = "data-picked-hydrated";
|
|
1707
|
+
async function Yt(e) {
|
|
1681
1708
|
if (!("document" in globalThis)) return;
|
|
1682
1709
|
let t = "application/picked-module", n = "data-picked-hydrated";
|
|
1683
1710
|
function r(e) {
|
|
@@ -1706,23 +1733,23 @@ async function Jt(e) {
|
|
|
1706
1733
|
a && await a;
|
|
1707
1734
|
}
|
|
1708
1735
|
}
|
|
1709
|
-
function
|
|
1710
|
-
return `<script>(${
|
|
1736
|
+
function Xt() {
|
|
1737
|
+
return `<script>(${Yt.toString()})(document)<\/script>`;
|
|
1711
1738
|
}
|
|
1712
1739
|
//#endregion
|
|
1713
1740
|
//#region src/utils/html-asset-value.ts
|
|
1714
|
-
function
|
|
1741
|
+
function Zt(e) {
|
|
1715
1742
|
return typeof e == "object" && !!e && "id" in e && typeof e.id == "string" && "content" in e && (typeof e.content == "string" || e.content === null);
|
|
1716
1743
|
}
|
|
1717
1744
|
//#endregion
|
|
1718
1745
|
//#region src/entities/component/lazyComponent.ts
|
|
1719
|
-
function
|
|
1746
|
+
function Qt(e) {
|
|
1720
1747
|
return {
|
|
1721
1748
|
$$type: "lazy-component",
|
|
1722
1749
|
load: e
|
|
1723
1750
|
};
|
|
1724
1751
|
}
|
|
1725
|
-
function
|
|
1752
|
+
function $t(e) {
|
|
1726
1753
|
return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
|
|
1727
1754
|
}
|
|
1728
1755
|
//#endregion
|
|
@@ -1738,10 +1765,10 @@ function $(e) {
|
|
|
1738
1765
|
for (let e of t) Z(e) && n.push(e.contentEntryId);
|
|
1739
1766
|
return n;
|
|
1740
1767
|
}
|
|
1741
|
-
function
|
|
1768
|
+
function en(e, t) {
|
|
1742
1769
|
return t === null ? null : e[t] ?? null;
|
|
1743
1770
|
}
|
|
1744
|
-
function
|
|
1771
|
+
function tn(e, t) {
|
|
1745
1772
|
let n = [];
|
|
1746
1773
|
for (let r of t) {
|
|
1747
1774
|
let t = e[r];
|
|
@@ -1749,29 +1776,29 @@ function en(e, t) {
|
|
|
1749
1776
|
}
|
|
1750
1777
|
return n;
|
|
1751
1778
|
}
|
|
1752
|
-
function
|
|
1753
|
-
if (le.store(t)) return A(t, e.indexStore, (e, t) =>
|
|
1779
|
+
function nn(e, t) {
|
|
1780
|
+
if (le.store(t)) return A(t, e.indexStore, (e, t) => en(t, Q(e)));
|
|
1754
1781
|
let n = Q(t);
|
|
1755
|
-
return e.indexStore.map((e) =>
|
|
1782
|
+
return e.indexStore.map((e) => en(e, n), { skipVoid: !1 });
|
|
1756
1783
|
}
|
|
1757
|
-
function
|
|
1758
|
-
if (le.store(t)) return A(t, e.indexStore, (e, t) =>
|
|
1784
|
+
function rn(e, t) {
|
|
1785
|
+
if (le.store(t)) return A(t, e.indexStore, (e, t) => tn(t, $(e)));
|
|
1759
1786
|
let n = $(t);
|
|
1760
|
-
return e.indexStore.map((e) =>
|
|
1787
|
+
return e.indexStore.map((e) => tn(e, n), { skipVoid: !1 });
|
|
1761
1788
|
}
|
|
1762
1789
|
//#endregion
|
|
1763
1790
|
//#region src/exports.ts
|
|
1764
|
-
var
|
|
1765
|
-
let t = new
|
|
1791
|
+
var an = (e) => {
|
|
1792
|
+
let t = new Gt(e);
|
|
1766
1793
|
return u(t), t;
|
|
1767
1794
|
};
|
|
1768
1795
|
//#endregion
|
|
1769
1796
|
//#region src/typed-content.ts
|
|
1770
|
-
function
|
|
1797
|
+
function on(e) {
|
|
1771
1798
|
return typeof e.data == "object";
|
|
1772
1799
|
}
|
|
1773
|
-
function
|
|
1774
|
-
return e.map((e) => !e || !
|
|
1800
|
+
function sn(e) {
|
|
1801
|
+
return e.map((e) => !e || !on(e) ? null : e, { skipVoid: !1 });
|
|
1775
1802
|
}
|
|
1776
1803
|
//#endregion
|
|
1777
|
-
export {
|
|
1804
|
+
export { Jt as PICKED_HYDRATED_ATTR, qt as PICKED_MODULE_SCRIPT_TYPE, Kt as PICKED_SCRIPT_TYPE, Ut as PREVIEW_TOKEN_PARAM, Gt as Picked, Xt as buildRehydrateBootstrap, an as createClient, ge as createPluginEffect, O as createStorageKey, nn as deriveReference, rn as deriveReferences, n as evaluateRuleLogic, Pt as getPickedConfig, Z as isContentReference, Zt as isHtmlAssetValue, h as isInsideIframe, $t as isLazyLoader, _ as isPickedRoot, Wt as isPreviewSession, Qt as lazyComponent, E as localStore, ce as onInertScriptSubtrees, Q as readReferenceId, $ as readReferenceIds, Yt as rehydrateScripts, oe as reportInertScriptSubtrees, se as resetInertScriptReport, D as sessionStore, T as subscribe, d as supportsCookies, p as supportsCryptoRandomUUID, c as supportsDocument, i as supportsHistory, f as supportsIntersectionObserver, m as supportsLocalStorage, a as supportsLocation, l as supportsSessionStorage, g as supportsShadowRoot, o as supportsWebComponents, s as supportsWindow, sn as toTypedContentStore };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "../../../plugin-
|
|
2
|
-
import { n as t, t as n } from "../../../api-
|
|
1
|
+
import { t as e } from "../../../plugin-CaJyXwSN.js";
|
|
2
|
+
import { n as t, t as n } from "../../../api-gGqMLTec.js";
|
|
3
3
|
import { n as r } from "../../../registry-CXZv0uLg.js";
|
|
4
4
|
import { createClientHeaders as i, fetchSchema as a } from "@picked/delivery-api-client";
|
|
5
5
|
export { i as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject, a as fetchSchema, r as registerPickedBundle };
|
|
@@ -4,7 +4,7 @@ import { attach as i, createEffect as a, sample as o } from "effector";
|
|
|
4
4
|
//#region src/plugins/responses-browser-storage/plugin.ts
|
|
5
5
|
var s = r("responses", "global");
|
|
6
6
|
function c(e, t) {
|
|
7
|
-
return Object.fromEntries(Object.entries(e).flatMap(([e, n]) => t.find((t) => t.key === e)?.policies?.
|
|
7
|
+
return Object.fromEntries(Object.entries(e).flatMap(([e, n]) => t.find((t) => t.key === e)?.policies?.storeValue === !0 ? [[e, n]] : []));
|
|
8
8
|
}
|
|
9
9
|
var l = ({ storage: r = "local" } = {}) => ({
|
|
10
10
|
name: "responses-browser-storage-plugin",
|
|
@@ -69,7 +69,7 @@ var l = "responses", u = {
|
|
|
69
69
|
fields: r.fields.listStore
|
|
70
70
|
},
|
|
71
71
|
fn: ({ responses: e, fields: t }) => {
|
|
72
|
-
let n = new Set(t.filter((e) => e.policies?.
|
|
72
|
+
let n = new Set(t.filter((e) => e.policies?.storeValue === !0).map((e) => e.key));
|
|
73
73
|
return e.filter((e) => n.has(e.fieldKey)).map((e) => ({
|
|
74
74
|
fieldKey: e.fieldKey,
|
|
75
75
|
value: e.value
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e, c as t, i as n, o as r, s as i, t as a, u as o } from "../../experience-instance-DGk11d8a.js";
|
|
2
|
-
import { n as s } from "../../plugin-
|
|
2
|
+
import { n as s } from "../../plugin-CaJyXwSN.js";
|
|
3
3
|
import { attach as c, createEffect as l, createEvent as u, createStore as d, sample as f } from "effector";
|
|
4
4
|
//#region src/server/serialize.ts
|
|
5
5
|
var p = 1e4;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { r as e } from "./version-
|
|
3
|
-
import "./api-
|
|
2
|
+
import { r as e } from "./version-CaCM83j4.js";
|
|
3
|
+
import "./api-gGqMLTec.js";
|
|
4
4
|
import { attach as t } from "effector";
|
|
5
5
|
//#region src/plugins/dynamic-experiences/hash.ts
|
|
6
6
|
function n(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./version-
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");const e=require("./version-ZVJWOz2D.cjs");require("./api-R3q_6NiX.cjs");let t=require("effector");function n(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function r(e){let t=e;return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function i(e,t){return r(n(`${e}:${t}`))%100}function a(e,t){return t<=0?!1:t>=100||e<t}var o=4294967296;function s(e,t,i){return(r(n(`${e}:${t}:${i}`))+.5)/o}function c(e,t,n){return n.weight<=0?0:n.weight/-Math.log(s(e,t,n.key))}function l(e,t,n){let r=null,i=0;for(let a of n){let n=c(e,t,a);n<=0||(n>i||n===i&&r!==null&&a.key<r.key)&&(i=n,r=a)}return r}function u(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function d(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function f(e){return typeof e!=`object`||!e?!1:`id`in e&&`key`in e&&`type`in e&&`name`in e}function p(e,t){if(Array.isArray(t.fields))for(let n of t.fields)f(n)&&e.registerField(n)}function m(e,t){if(!Array.isArray(t.steps))return;let n=new Map(t.fields.map(e=>[e.id,e.key]));for(let r of t.steps){let t=[];for(let e of r.fieldIds??[]){let i=n.get(e);if(i===void 0){`${r.key}${e}`;continue}t.push(i)}let i=r.layoutContentId?e.contents.getById(r.layoutContentId):null;e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:t,layoutName:r.layoutName,...r.layoutContentId!==void 0&&{layoutContentId:r.layoutContentId,layoutContentStore:i}})}}function h(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)d(e,n)}function g(e,t,n){y(e,t,n.isPreview,n.sessionId),u(e,t),p(e,t),m(e,t),h(e,t)}function _(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function v(t){let n=new Map,r=t.searchParams.feature;if(!r)return n;for(let t of r){let r=e.r(t);r&&n.set(r.id,r.bucket)}return n}function y(e,t,n,r){let i=v(e);for(let a of t.features){let t=i.get(a.id);if(t!==void 0){b(e,a,t);continue}x(e,a,n,r)}}function b(e,t,n){e.registerFeature(t.id,{key:`${n}`,name:t.name,enabled:!0,weight:t.weight,...t.valueType!==void 0&&{valueType:t.valueType},...t.variants!==void 0&&{variants:t.variants},storage:`session`,decide:()=>n})}function x(e,t,n,r){let o=t.id,s=t.variants;e.registerFeature(o,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,valueType:t.valueType,variants:s,decide:()=>t.valueType===`text`?!s||s.length===0?(`${o}`,!1):l(r,o,s)?.value??!1:a(i(r,o),t.weight)})}function S(e,t){for(let n of[...t.references??[],...t.content])e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function C(e,t){let n=new Map;return(r,i)=>{let a=n.get(r.id);if(a)return a;let o=(async()=>{try{let n=await t(r,i);return n&&S(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function w(e,t){let n=new Set(t&&Array.isArray(t.experiences)?t.experiences.map(e=>e.id):[]);return(t,r)=>n.has(t.id)?e(t,r):Promise.resolve(null)}function T(){return{name:`dynamic-experiences`,setup:e=>({onStart:(0,t.attach)({source:e.session.store.map(e=>e.id),effect:async t=>{let n=_(e),r=n!==void 0,i=n===void 0?void 0:{previewToken:n},a=await e.getProjectConfig(n===void 0?void 0:{previewToken:n}).catch(e=>null);if(e.contentLoader=C(e,w(t=>e.getExperienceContent(t,i),a)),!a)return;let o=e.seededVersionId;if(o!==null&&o!==a.versionId){e.versionSkew={seeded:o,resolved:a.versionId},`${a.versionId}${o}`;return}e.previewEmbedderOrigins=a.previewEmbedderOrigins??null,g(e,a,{isPreview:r,sessionId:t})}})})}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return T}});
|