@picked/client 0.0.50-next.3 → 0.0.50-next.4

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.
Files changed (51) hide show
  1. package/dist/api-C2lg7yBn.cjs +1 -0
  2. package/dist/api-CHaIe0uL.js +37 -0
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/plugins/create-experience/index.js +1 -1
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
  7. package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
  8. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  9. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  10. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  11. package/dist/cjs/plugins/web-components/index.js +1 -1
  12. package/dist/cjs/plugins/window-object/index.js +1 -1
  13. package/dist/cjs/server/index.js +1 -1
  14. package/dist/esm/index.js +1126 -1220
  15. package/dist/esm/plugins/create-experience/index.js +461 -468
  16. package/dist/esm/plugins/dynamic-experiences/index.js +106 -123
  17. package/dist/esm/plugins/experience-browser-storage/index.js +32 -37
  18. package/dist/esm/plugins/history-browser-storage/index.js +23 -25
  19. package/dist/esm/plugins/responses-browser-storage/index.js +36 -39
  20. package/dist/esm/plugins/responses-indexeddb/index.js +81 -80
  21. package/dist/esm/plugins/single-page-app/index.js +31 -35
  22. package/dist/esm/plugins/web-components/index.js +18 -20
  23. package/dist/esm/plugins/window-object/index.js +9 -9
  24. package/dist/esm/server/index.js +95 -89
  25. package/dist/experience-instance-BRpI9I4s.js +710 -0
  26. package/dist/experience-instance-BUTnwbSJ.cjs +1 -0
  27. package/dist/id-BniPxOdF.js +4 -0
  28. package/dist/id-CIbS4P60.cjs +1 -0
  29. package/dist/logger-6z_gb4rA.js +4 -0
  30. package/dist/logger-fbvQC40v.cjs +1 -0
  31. package/dist/object-BReQiaSS.cjs +1 -0
  32. package/dist/object-Clj5zVr1.js +24 -0
  33. package/dist/storage-BFjb8azI.cjs +1 -0
  34. package/dist/storage-DyxpJ0pg.js +101 -0
  35. package/dist/supports-0XIfd4-R.js +85 -0
  36. package/dist/supports-Dsjg-82e.cjs +1 -0
  37. package/package.json +5 -5
  38. package/dist/api-4mY9vhi4.cjs +0 -1
  39. package/dist/api-D1FqIUly.js +0 -32
  40. package/dist/experience-instance-BsXG5XJ4.cjs +0 -1
  41. package/dist/experience-instance-fvSEb72i.js +0 -819
  42. package/dist/id-BKIWbSTy.cjs +0 -1
  43. package/dist/id-BW-g3y32.js +0 -6
  44. package/dist/logger-BsmHUUw1.cjs +0 -1
  45. package/dist/logger-C9a75KZn.js +0 -5
  46. package/dist/object-BbFTsGh3.cjs +0 -1
  47. package/dist/object-JwZ58NOH.js +0 -28
  48. package/dist/storage-Be5xWNPC.cjs +0 -1
  49. package/dist/storage-Co_LbKr_.js +0 -239
  50. package/dist/supports-8YT4QKI7.js +0 -95
  51. package/dist/supports-YvpQZxbh.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";const e={};let n=0;const r=t=>(e[t]||(e[t]=`${(n++).toString(36)}`),`${e[t]}:${(n++).toString(36)}`);exports.generateId=r;
@@ -1,6 +0,0 @@
1
- const n = {};
2
- let r = 0;
3
- const e = (t) => (n[t] || (n[t] = `${(r++).toString(36)}`), `${n[t]}:${(r++).toString(36)}`);
4
- export {
5
- e as g
6
- };
@@ -1 +0,0 @@
1
- "use strict";const e=(r,...g)=>{};exports.logger=e;
@@ -1,5 +0,0 @@
1
- const l = (e, ...r) => {
2
- };
3
- export {
4
- l
5
- };
@@ -1 +0,0 @@
1
- "use strict";function c(t,e,n){if(!(e in t))return;const o=t[e];if(typeof o!="function")throw new Error(`Expected '${String(e)}' to be a function`);const r=n(o);p(r,o),t[e]=r}function i(t,e,n){Object.defineProperty(t,e,{enumerable:!1,value:n,writable:!0,configurable:!0})}function p(t,e){const n=e.prototype||{};t.prototype=e.prototype=n,i(t,"__picked_original",e)}function u(t){return t===void 0||typeof t=="object"&&t!==null&&t.constructor===Object&&Object.keys(t).length===0}exports.isEmpty=u;exports.patchMethod=c;
@@ -1,28 +0,0 @@
1
- function p(t, e, n) {
2
- if (!(e in t))
3
- return;
4
- const o = t[e];
5
- if (typeof o != "function")
6
- throw new Error(`Expected '${String(e)}' to be a function`);
7
- const r = n(o);
8
- i(r, o), t[e] = r;
9
- }
10
- function c(t, e, n) {
11
- Object.defineProperty(t, e, {
12
- enumerable: !1,
13
- value: n,
14
- writable: !0,
15
- configurable: !0
16
- });
17
- }
18
- function i(t, e) {
19
- const n = e.prototype || {};
20
- t.prototype = e.prototype = n, c(t, "__picked_original", e);
21
- }
22
- function u(t) {
23
- return t === void 0 || typeof t == "object" && t !== null && t.constructor === Object && Object.keys(t).length === 0;
24
- }
25
- export {
26
- u as i,
27
- p
28
- };
@@ -1 +0,0 @@
1
- "use strict";const p=e=>btoa([...e].map(t=>String.fromCharCode(t.charCodeAt(0)^7)).join("")).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");function w(e,t="global",o){let r="pckd";if(t==="experience"){if(!o)throw new Error("Experience instance is required to scope storage to an experience");r=`${r}:${o.experienceId}`}return{_:`${r}:${p(e)}`,scope:t}}const a=new Map;function m(e,t){const o=a.get(e._);o&&o.forEach(r=>r(e,t))}function S(e,t,o,r){const i=o==="local"?localStorage:sessionStorage,c=typeof t!="string"?JSON.stringify(t):t;if(i.setItem(e._,c),typeof r=="number"){const s=new Date(Date.now()+r).toISOString();i.setItem(`${e._}:expires-at`,s)}m(e,o)}function b(e,t){const o=t==="local"?localStorage:sessionStorage;o.removeItem(e._),o.removeItem(`${e._}:expires-at`),m(e,t)}function f(e,t,o,r){const i=t==="local"?localStorage:sessionStorage;function c(s){s.storageArea===i&&s.key===e._&&r(o(e))}function l(s,n){n===t&&r(o(s))}return window.addEventListener("storage",c),a.has(e._)||a.set(e._,new Set),a.get(e._).add(l),function(){window.removeEventListener("storage",c);const n=a.get(e._);n&&(n.delete(l),n.size===0&&a.delete(e._))}}function g(e,t){const o=t==="local"?localStorage:sessionStorage,r=o.getItem(e._),i=o.getItem(`${e._}:expires-at`),c=(n,u)=>S(e,n,t,u),l=()=>b(e,t),s=n=>f(e,t,u=>g(u,t),n);if(i){const n=new Date,u=new Date(i);if(n>u)return b(e,t),{isSet:()=>!1,text:()=>null,json:()=>null,boolean:()=>null,set:c,remove:l,subscribe:s}}return{isSet(){return r!==null},text(){return r},json(){return r?JSON.parse(r):null},boolean(){return r?r==="true":null},set:c,remove:l,subscribe:s}}const d={get(e){return g(e,"session")},set(e,t,o){S(e,t,"session",o)},remove(e){b(e,"session")},subscribe(e,t){return f(e,"session",this.get,t)}},_={get(e){return g(e,"local")},set(e,t,o){S(e,t,"local",o)},remove(e){b(e,"local")},subscribe(e,t){return f(e,"local",this.get,t)}};exports.createStorageKey=w;exports.localStore=_;exports.sessionStore=d;exports.subscribe=f;
@@ -1,239 +0,0 @@
1
- const m = (e) => btoa([...e].map((t) => String.fromCharCode(t.charCodeAt(0) ^ 7)).join("")).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
2
- function w(e, t = "global", o) {
3
- let r = "pckd";
4
- if (t === "experience") {
5
- if (!o)
6
- throw new Error("Experience instance is required to scope storage to an experience");
7
- r = `${r}:${o.experienceId}`;
8
- }
9
- return { _: `${r}:${m(e)}`, scope: t };
10
- }
11
- const l = /* @__PURE__ */ new Map();
12
- function p(e, t) {
13
- const o = l.get(e._);
14
- o && o.forEach((r) => r(e, t));
15
- }
16
- function b(e, t, o, r) {
17
- const i = o === "local" ? localStorage : sessionStorage, c = typeof t != "string" ? JSON.stringify(t) : t;
18
- if (i.setItem(e._, c), typeof r == "number") {
19
- const s = new Date(Date.now() + r).toISOString();
20
- i.setItem(`${e._}:expires-at`, s);
21
- }
22
- p(e, o);
23
- }
24
- function f(e, t) {
25
- const o = t === "local" ? localStorage : sessionStorage;
26
- o.removeItem(e._), o.removeItem(`${e._}:expires-at`), p(e, t);
27
- }
28
- function S(e, t, o, r) {
29
- const i = t === "local" ? localStorage : sessionStorage;
30
- function c(s) {
31
- s.storageArea === i && s.key === e._ && r(o(e));
32
- }
33
- function a(s, n) {
34
- n === t && r(o(s));
35
- }
36
- return window.addEventListener("storage", c), l.has(e._) || l.set(e._, /* @__PURE__ */ new Set()), l.get(e._).add(a), function() {
37
- window.removeEventListener("storage", c);
38
- const n = l.get(e._);
39
- n && (n.delete(a), n.size === 0 && l.delete(e._));
40
- };
41
- }
42
- function g(e, t) {
43
- const o = t === "local" ? localStorage : sessionStorage, r = o.getItem(e._), i = o.getItem(`${e._}:expires-at`), c = (n, u) => b(e, n, t, u), a = () => f(e, t), s = (n) => S(e, t, (u) => g(u, t), n);
44
- if (i) {
45
- const n = /* @__PURE__ */ new Date(), u = new Date(i);
46
- if (n > u)
47
- return f(e, t), {
48
- isSet: () => !1,
49
- text: () => null,
50
- json: () => null,
51
- boolean: () => null,
52
- set: c,
53
- remove: a,
54
- subscribe: s
55
- };
56
- }
57
- return {
58
- isSet() {
59
- return r !== null;
60
- },
61
- text() {
62
- return r;
63
- },
64
- json() {
65
- return r ? JSON.parse(r) : null;
66
- },
67
- boolean() {
68
- return r ? r === "true" : null;
69
- },
70
- set: c,
71
- remove: a,
72
- subscribe: s
73
- };
74
- }
75
- const d = {
76
- /**
77
- * Retrieves a storage item from sessionStorage.
78
- *
79
- * @template T - The type of the stored value
80
- * @param key - The storage key
81
- * @returns A StorageItem with methods to interact with the value
82
- *
83
- * @example
84
- * ```typescript
85
- * const key = createStorageKey('user')
86
- * const item = sessionStore.get<User>(key)
87
- * const user = item.json() // User | null
88
- * ```
89
- */
90
- get(e) {
91
- return g(e, "session");
92
- },
93
- /**
94
- * Sets a value in sessionStorage with optional expiry.
95
- *
96
- * @param key - The storage key
97
- * @param value - The value to store
98
- * @param expiresIn - Optional expiry time in milliseconds from now
99
- *
100
- * @example
101
- * ```typescript
102
- * const key = createStorageKey('theme')
103
- * // Set without expiry
104
- * sessionStore.set(key, 'dark')
105
- * // Set with 1 hour expiry
106
- * sessionStore.set(key, 'dark', 60 * 60 * 1000)
107
- * ```
108
- */
109
- set(e, t, o) {
110
- b(e, t, "session", o);
111
- },
112
- /**
113
- * Removes a value from sessionStorage, including expiry metadata.
114
- *
115
- * @param key - The storage key
116
- *
117
- * @example
118
- * ```typescript
119
- * const key = createStorageKey('temp-data')
120
- * sessionStore.remove(key)
121
- * ```
122
- */
123
- remove(e) {
124
- f(e, "session");
125
- },
126
- /**
127
- * Subscribes to storage changes for a key, both in the same tab and across browser tabs/windows.
128
- * Callbacks are invoked when changes occur via sessionStore.set() or sessionStore.remove() in the same tab,
129
- * and also when changes are made in other tabs/windows.
130
- *
131
- * @template T - The type of the stored value
132
- * @param key - The storage key to watch
133
- * @param callback - Function called when storage changes
134
- * @returns Unsubscribe function to stop listening
135
- *
136
- * @example
137
- * ```typescript
138
- * const key = createStorageKey('notifications')
139
- * const unsubscribe = sessionStore.subscribe<Notification[]>(key, (item) => {
140
- * const notifications = item.json()
141
- * console.log('Notifications updated:', notifications)
142
- * })
143
- *
144
- * // Changes in same tab trigger callback
145
- * sessionStore.set(key, [{ id: 1, message: 'New notification' }])
146
- *
147
- * // Later, stop listening
148
- * unsubscribe()
149
- * ```
150
- */
151
- subscribe(e, t) {
152
- return S(e, "session", this.get, t);
153
- }
154
- }, _ = {
155
- /**
156
- * Retrieves a storage item from localStorage.
157
- *
158
- * @template T - The type of the stored value
159
- * @param key - The storage key
160
- * @returns A StorageItem with methods to interact with the value
161
- *
162
- * @example
163
- * ```typescript
164
- * const key = createStorageKey('settings')
165
- * const item = localStore.get<Settings>(key)
166
- * const settings = item.json() // Settings | null
167
- * ```
168
- */
169
- get(e) {
170
- return g(e, "local");
171
- },
172
- /**
173
- * Sets a value in localStorage with optional expiry.
174
- *
175
- * @param key - The storage key
176
- * @param value - The value to store
177
- * @param expiresIn - Optional expiry time in milliseconds from now
178
- *
179
- * @example
180
- * ```typescript
181
- * const key = createStorageKey('auth-token')
182
- * // Set without expiry
183
- * localStore.set(key, 'token123')
184
- * // Set with 24 hour expiry
185
- * localStore.set(key, 'token123', 24 * 60 * 60 * 1000)
186
- * ```
187
- */
188
- set(e, t, o) {
189
- b(e, t, "local", o);
190
- },
191
- /**
192
- * Removes a value from localStorage, including expiry metadata.
193
- *
194
- * @param key - The storage key
195
- *
196
- * @example
197
- * ```typescript
198
- * const key = createStorageKey('cached-data')
199
- * localStore.remove(key)
200
- * ```
201
- */
202
- remove(e) {
203
- f(e, "local");
204
- },
205
- /**
206
- * Subscribes to storage changes for a key, both in the same tab and across browser tabs/windows.
207
- * Callbacks are invoked when changes occur via localStore.set() or localStore.remove() in the same tab,
208
- * and also when changes are made in other tabs/windows.
209
- *
210
- * @template T - The type of the stored value
211
- * @param key - The storage key to watch
212
- * @param callback - Function called when storage changes
213
- * @returns Unsubscribe function to stop listening
214
- *
215
- * @example
216
- * ```typescript
217
- * const key = createStorageKey('user-status')
218
- * const unsubscribe = localStore.subscribe<UserStatus>(key, (item) => {
219
- * const status = item.json()
220
- * console.log('User status changed:', status)
221
- * })
222
- *
223
- * // Changes in same tab trigger callback
224
- * localStore.set(key, { online: true })
225
- *
226
- * // Later, stop listening
227
- * unsubscribe()
228
- * ```
229
- */
230
- subscribe(e, t) {
231
- return S(e, "local", this.get, t);
232
- }
233
- };
234
- export {
235
- S as a,
236
- w as c,
237
- _ as l,
238
- d as s
239
- };
@@ -1,95 +0,0 @@
1
- const o = /* @__PURE__ */ Symbol("Picked"), t = globalThis, r = (n) => {
2
- t[o] = n;
3
- };
4
- function e() {
5
- try {
6
- return "location" in t && !!t.location;
7
- } catch {
8
- return !1;
9
- }
10
- }
11
- function s() {
12
- try {
13
- return "history" in t && !!t.history;
14
- } catch {
15
- return !1;
16
- }
17
- }
18
- function a() {
19
- try {
20
- return "localStorage" in t && !!t.localStorage;
21
- } catch {
22
- return !1;
23
- }
24
- }
25
- function c() {
26
- try {
27
- return "sessionStorage" in t && !!t.sessionStorage;
28
- } catch {
29
- return !1;
30
- }
31
- }
32
- function u() {
33
- try {
34
- return "document" in t && "cookie" in t.document;
35
- } catch {
36
- return !1;
37
- }
38
- }
39
- function i() {
40
- try {
41
- return "document" in t && "createElement" in t.document && "attachShadow" in t.document.createElement("div");
42
- } catch {
43
- return !1;
44
- }
45
- }
46
- function l() {
47
- try {
48
- return "window" in t;
49
- } catch {
50
- return !1;
51
- }
52
- }
53
- function p() {
54
- try {
55
- return "document" in t;
56
- } catch {
57
- return !1;
58
- }
59
- }
60
- function f() {
61
- try {
62
- return "IntersectionObserver" in t;
63
- } catch {
64
- return !1;
65
- }
66
- }
67
- function y() {
68
- try {
69
- return "customElements" in t && !!t.customElements;
70
- } catch {
71
- return !1;
72
- }
73
- }
74
- function h() {
75
- try {
76
- return "crypto" in t && "randomUUID" in t.crypto;
77
- } catch {
78
- return !1;
79
- }
80
- }
81
- export {
82
- t as G,
83
- l as a,
84
- a as b,
85
- h as c,
86
- r as d,
87
- u as e,
88
- s as f,
89
- f as g,
90
- e as h,
91
- c as i,
92
- i as j,
93
- y as k,
94
- p as s
95
- };
@@ -1 +0,0 @@
1
- "use strict";const n=Symbol("Picked"),t=globalThis,r=o=>{t[n]=o};function e(){try{return"location"in t&&!!t.location}catch{return!1}}function s(){try{return"history"in t&&!!t.history}catch{return!1}}function u(){try{return"localStorage"in t&&!!t.localStorage}catch{return!1}}function c(){try{return"sessionStorage"in t&&!!t.sessionStorage}catch{return!1}}function a(){try{return"document"in t&&"cookie"in t.document}catch{return!1}}function i(){try{return"document"in t&&"createElement"in t.document&&"attachShadow"in t.document.createElement("div")}catch{return!1}}function p(){try{return"window"in t}catch{return!1}}function l(){try{return"document"in t}catch{return!1}}function f(){try{return"IntersectionObserver"in t}catch{return!1}}function y(){try{return"customElements"in t&&!!t.customElements}catch{return!1}}function m(){try{return"crypto"in t&&"randomUUID"in t.crypto}catch{return!1}}exports.GLOBAL_OBJ=t;exports.bindClient=r;exports.supportsCookies=a;exports.supportsCryptoRandomUUID=m;exports.supportsDocument=l;exports.supportsHistory=s;exports.supportsIntersectionObserver=f;exports.supportsLocalStorage=u;exports.supportsLocation=e;exports.supportsSessionStorage=c;exports.supportsShadowRoot=i;exports.supportsWebComponents=y;exports.supportsWindow=p;