@picked/client 0.0.22 → 0.0.23-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { createEffect as r, sample as i } from "effector";
2
- import { c, l as g, s as S } from "../../../storage-Cb_71y48.js";
2
+ import { c, l as g, s as S } from "../../../storage-BLmAhfhl.js";
3
3
  import { l as f } from "../../../logger-C9a75KZn.js";
4
4
  const y = ({
5
5
  storage: a = "local"
@@ -1,5 +1,5 @@
1
1
  import { createEffect as s, sample as r } from "effector";
2
- import { c as l, l as y, s as g } from "../../../storage-Cb_71y48.js";
2
+ import { c as l, l as y, s as g } from "../../../storage-BLmAhfhl.js";
3
3
  const a = l("history", "global"), f = ({
4
4
  storage: i = "local"
5
5
  } = {}) => ({
@@ -1,5 +1,5 @@
1
1
  import { createEffect as d, attach as m, sample as l } from "effector";
2
- import { c as b, l as h, s as E } from "../../../storage-Cb_71y48.js";
2
+ import { c as b, l as h, s as E } from "../../../storage-BLmAhfhl.js";
3
3
  const p = b("responses", "global"), y = ({
4
4
  storage: i = "local"
5
5
  } = {}) => ({
@@ -1,38 +1,38 @@
1
1
  const f = (e) => btoa([...e].map((t) => String.fromCharCode(t.charCodeAt(0) ^ 7)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
2
- function m(e, t = "global", o) {
3
- let r = "pckd";
2
+ function m(e, t = "global", r) {
3
+ let o = "pckd";
4
4
  if (t === "experience") {
5
- if (!o)
5
+ if (!r)
6
6
  throw new Error("Experience instance is required to scope storage to an experience");
7
- r = `${r}:${o.experienceId}`;
7
+ o = `${o}:${r.experienceId}`;
8
8
  }
9
- return `${r}:${f(e)}`;
9
+ return { _: `${o}:${f(e)}`, scope: t };
10
10
  }
11
- function l(e, t, o, r) {
12
- const n = o === "local" ? localStorage : sessionStorage, s = typeof t != "string" ? JSON.stringify(t) : t;
13
- if (n.setItem(e, s), typeof r == "number") {
14
- const a = new Date(Date.now() + r).toISOString();
15
- n.setItem(`${e}:expires-at`, a);
11
+ function l(e, t, r, o) {
12
+ const n = r === "local" ? localStorage : sessionStorage, s = typeof t != "string" ? JSON.stringify(t) : t;
13
+ if (n.setItem(e._, s), typeof o == "number") {
14
+ const a = new Date(Date.now() + o).toISOString();
15
+ n.setItem(`${e._}:expires-at`, a);
16
16
  }
17
17
  }
18
18
  function c(e, t) {
19
- const o = t === "local" ? localStorage : sessionStorage;
20
- o.removeItem(e), o.removeItem(`${e}:expires-at`);
19
+ const r = t === "local" ? localStorage : sessionStorage;
20
+ r.removeItem(e._), r.removeItem(`${e._}:expires-at`);
21
21
  }
22
- function u(e, t, o, r) {
22
+ function u(e, t, r, o) {
23
23
  const n = t === "local" ? localStorage : sessionStorage;
24
24
  function s(i) {
25
- i.storageArea === n && i.key === e && r(o(e));
25
+ i.storageArea === n && i.key === e._ && o(r(e));
26
26
  }
27
27
  return window.addEventListener("storage", s), function() {
28
28
  window.removeEventListener("storage", s);
29
29
  };
30
30
  }
31
31
  function g(e, t) {
32
- const o = t === "local" ? localStorage : sessionStorage, r = o.getItem(e), n = o.getItem(`${e}:expires-at`), s = (a) => l(e, a, t), i = () => c(e, t);
32
+ const r = t === "local" ? localStorage : sessionStorage, o = r.getItem(e._), n = r.getItem(`${e._}:expires-at`), s = (a) => l(e, a, t), i = () => c(e, t);
33
33
  if (n) {
34
- const a = /* @__PURE__ */ new Date(), p = new Date(n);
35
- if (a > p)
34
+ const a = /* @__PURE__ */ new Date(), S = new Date(n);
35
+ if (a > S)
36
36
  return c(e, t), {
37
37
  isSet: () => !1,
38
38
  text: () => null,
@@ -44,27 +44,27 @@ function g(e, t) {
44
44
  }
45
45
  return {
46
46
  isSet() {
47
- return r !== null;
47
+ return o !== null;
48
48
  },
49
49
  text() {
50
- return r;
50
+ return o;
51
51
  },
52
52
  json() {
53
- return r ? JSON.parse(r) : null;
53
+ return o ? JSON.parse(o) : null;
54
54
  },
55
55
  boolean() {
56
- return r ? r === "true" : null;
56
+ return o ? o === "true" : null;
57
57
  },
58
58
  set: s,
59
59
  remove: i
60
60
  };
61
61
  }
62
- const S = {
62
+ const p = {
63
63
  get(e) {
64
64
  return g(e, "session");
65
65
  },
66
- set(e, t, o) {
67
- l(e, t, "session", o);
66
+ set(e, t, r) {
67
+ l(e, t, "session", r);
68
68
  },
69
69
  remove(e) {
70
70
  c(e, "session");
@@ -72,12 +72,12 @@ const S = {
72
72
  subscribe(e, t) {
73
73
  return u(e, "session", this.get, t);
74
74
  }
75
- }, x = {
75
+ }, b = {
76
76
  get(e) {
77
77
  return g(e, "local");
78
78
  },
79
- set(e, t, o) {
80
- l(e, t, "local", o);
79
+ set(e, t, r) {
80
+ l(e, t, "local", r);
81
81
  },
82
82
  remove(e) {
83
83
  c(e, "local");
@@ -89,6 +89,6 @@ const S = {
89
89
  export {
90
90
  u as a,
91
91
  m as c,
92
- x as l,
93
- S as s
92
+ b as l,
93
+ p as s
94
94
  };
@@ -0,0 +1 @@
1
+ "use strict";const f=e=>btoa([...e].map(t=>String.fromCharCode(t.charCodeAt(0)^7)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function m(e,t="global",r){let o="pckd";if(t==="experience"){if(!r)throw new Error("Experience instance is required to scope storage to an experience");o=`${o}:${r.experienceId}`}return{_:`${o}:${f(e)}`,scope:t}}function l(e,t,r,o){const n=r==="local"?localStorage:sessionStorage,s=typeof t!="string"?JSON.stringify(t):t;if(n.setItem(e._,s),typeof o=="number"){const c=new Date(Date.now()+o).toISOString();n.setItem(`${e._}:expires-at`,c)}}function a(e,t){const r=t==="local"?localStorage:sessionStorage;r.removeItem(e._),r.removeItem(`${e._}:expires-at`)}function u(e,t,r,o){const n=t==="local"?localStorage:sessionStorage;function s(i){i.storageArea===n&&i.key===e._&&o(r(e))}return window.addEventListener("storage",s),function(){window.removeEventListener("storage",s)}}function g(e,t){const r=t==="local"?localStorage:sessionStorage,o=r.getItem(e._),n=r.getItem(`${e._}:expires-at`),s=c=>l(e,c,t),i=()=>a(e,t);if(n){const c=new Date,S=new Date(n);if(c>S)return a(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:s,remove:i}}return{isSet(){return o!==null},text(){return o},json(){return o?JSON.parse(o):null},boolean(){return o?o==="true":null},set:s,remove:i}}const b={get(e){return g(e,"session")},set(e,t,r){l(e,t,"session",r)},remove(e){a(e,"session")},subscribe(e,t){return u(e,"session",this.get,t)}},p={get(e){return g(e,"local")},set(e,t,r){l(e,t,"local",r)},remove(e){a(e,"local")},subscribe(e,t){return u(e,"local",this.get,t)}};exports.createStorageKey=m;exports.localStore=p;exports.sessionStore=b;exports.subscribe=u;
@@ -1 +1 @@
1
- {"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAatC;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CA+C1D,CAAA"}
1
+ {"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/ping.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAatC;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAU,QAAQ,MAAM,KAAG,OAAO,CAAC,OAAO,CAmD1D,CAAA"}
@@ -8,18 +8,22 @@ export interface StorageItem<T = unknown> {
8
8
  set: (value: T) => void;
9
9
  remove: () => void;
10
10
  }
11
- export declare function createStorageKey(key: string, scope?: StorageScope, experienceInstance?: ExperienceInstance): string;
12
- export declare function subscribe<T = unknown>(key: string, storage: 'local' | 'session', get: (key: string) => StorageItem<T>, callback: (value: StorageItem<T>) => void): () => void;
11
+ export interface StorageKey {
12
+ _: string;
13
+ scope: StorageScope;
14
+ }
15
+ export declare function createStorageKey(key: string, scope?: StorageScope, experienceInstance?: ExperienceInstance): StorageKey;
16
+ export declare function subscribe<T = unknown>(key: StorageKey, storage: 'local' | 'session', get: (key: StorageKey) => StorageItem<T>, callback: (value: StorageItem<T>) => void): () => void;
13
17
  export declare const sessionStore: {
14
- get<T = unknown>(key: string): StorageItem<T>;
15
- set(key: string, value: unknown, expiresIn?: number): void;
16
- remove(key: string): void;
17
- subscribe<T = unknown>(key: string, callback: (value: StorageItem<T>) => void): () => void;
18
+ get<T = unknown>(key: StorageKey): StorageItem<T>;
19
+ set(key: StorageKey, value: unknown, expiresIn?: number): void;
20
+ remove(key: StorageKey): void;
21
+ subscribe<T = unknown>(key: StorageKey, callback: (value: StorageItem<T>) => void): () => void;
18
22
  };
19
23
  export declare const localStore: {
20
- get<T = unknown>(key: string): StorageItem<T>;
21
- set(key: string, value: unknown, expiresIn?: number): void;
22
- remove(key: string): void;
23
- subscribe<T = unknown>(key: string, callback: (value: StorageItem<T>) => void): () => void;
24
+ get<T = unknown>(key: StorageKey): StorageItem<T>;
25
+ set(key: StorageKey, value: unknown, expiresIn?: number): void;
26
+ remove(key: StorageKey): void;
27
+ subscribe<T = unknown>(key: StorageKey, callback: (value: StorageItem<T>) => void): () => void;
24
28
  };
25
29
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/utils/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qDAAqD,CAAA;AAE7F,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAA;AAElD,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,KAAK,EAAE,MAAM,OAAO,CAAA;IACpB,IAAI,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IACzB,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAAA;IAC7B,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,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M,OAAO,GAAG,IAAI,CAAA;IAC7B,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,IAAI,CAAA;CACnB;AAQD,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,KAAK,EAAE,YAAY,CAAA;CACpB;AAED,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,YAAuB,EAC9B,kBAAkB,CAAC,EAAE,kBAAkB,GACtC,UAAU,CAaZ;AAyBD,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EACnC,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,OAAO,GAAG,SAAS,EAC5B,GAAG,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,EACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,cAc1C;AAmDD,eAAO,MAAM,YAAY;QACnB,CAAC,iBAAiB,UAAU;aAGvB,UAAU,SAAS,OAAO,cAAc,MAAM;gBAG3C,UAAU;cAGZ,CAAC,iBAAiB,UAAU,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI;CAGlF,CAAA;AAED,eAAO,MAAM,UAAU;QACjB,CAAC,iBAAiB,UAAU;aAGvB,UAAU,SAAS,OAAO,cAAc,MAAM;gBAG3C,UAAU;cAGZ,CAAC,iBAAiB,UAAU,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI;CAGlF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/client",
3
- "version": "0.0.22",
3
+ "version": "0.0.23-next.1",
4
4
  "dependencies": {
5
5
  "@withease/factories": "^1.0.5"
6
6
  },
@@ -1 +0,0 @@
1
- "use strict";const f=e=>btoa([...e].map(t=>String.fromCharCode(t.charCodeAt(0)^7)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function m(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}:${f(e)}`}function l(e,t,o,r){const n=o==="local"?localStorage:sessionStorage,s=typeof t!="string"?JSON.stringify(t):t;if(n.setItem(e,s),typeof r=="number"){const c=new Date(Date.now()+r).toISOString();n.setItem(`${e}:expires-at`,c)}}function a(e,t){const o=t==="local"?localStorage:sessionStorage;o.removeItem(e),o.removeItem(`${e}:expires-at`)}function u(e,t,o,r){const n=t==="local"?localStorage:sessionStorage;function s(i){i.storageArea===n&&i.key===e&&r(o(e))}return window.addEventListener("storage",s),function(){window.removeEventListener("storage",s)}}function g(e,t){const o=t==="local"?localStorage:sessionStorage,r=o.getItem(e),n=o.getItem(`${e}:expires-at`),s=c=>l(e,c,t),i=()=>a(e,t);if(n){const c=new Date,S=new Date(n);if(c>S)return a(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:s,remove:i}}return{isSet(){return r!==null},text(){return r},json(){return r?JSON.parse(r):null},boolean(){return r?r==="true":null},set:s,remove:i}}const p={get(e){return g(e,"session")},set(e,t,o){l(e,t,"session",o)},remove(e){a(e,"session")},subscribe(e,t){return u(e,"session",this.get,t)}},b={get(e){return g(e,"local")},set(e,t,o){l(e,t,"local",o)},remove(e){a(e,"local")},subscribe(e,t){return u(e,"local",this.get,t)}};exports.createStorageKey=m;exports.localStore=b;exports.sessionStore=p;exports.subscribe=u;