saloe 0.0.27 → 0.0.28

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,16 +1,284 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const setCookie = ({ key, value }) => {
4
- return cookieStore == null ? void 0 : cookieStore.set(key, value);
3
+ /*!
4
+ * Cookie-store v4.0.0-next.4
5
+ * https://github.com/markcellus/cookie-store
6
+ *
7
+ * Copyright (c) 2023 Mark
8
+ * Licensed under the MIT license
9
+ */
10
+ const decode = decodeURIComponent;
11
+ const pairSplitRegExp = /; */;
12
+ function tryDecode(str, decode2) {
13
+ try {
14
+ return typeof decode2 === "boolean" ? decodeURIComponent(str) : decode2(str);
15
+ } catch (e) {
16
+ return str;
17
+ }
18
+ }
19
+ var CookieSameSite;
20
+ (function(CookieSameSite2) {
21
+ CookieSameSite2["strict"] = "strict";
22
+ CookieSameSite2["lax"] = "lax";
23
+ CookieSameSite2["none"] = "none";
24
+ })(CookieSameSite || (CookieSameSite = {}));
25
+ function parse(str, options = {}) {
26
+ if (typeof str !== "string") {
27
+ throw new TypeError("argument str must be a string");
28
+ }
29
+ const obj = [];
30
+ const opt = options || {};
31
+ const pairs = str.split(pairSplitRegExp);
32
+ const dec = opt.decode || decode;
33
+ for (let i = 0; i < pairs.length; i++) {
34
+ const pair = pairs[i];
35
+ let eqIdx = pair.indexOf("=");
36
+ if (eqIdx < 0) {
37
+ continue;
38
+ }
39
+ const key = pair.substr(0, eqIdx).trim();
40
+ let val = pair.substr(++eqIdx, pair.length).trim();
41
+ if ('"' == val[0]) {
42
+ val = val.slice(1, -1);
43
+ }
44
+ if (void 0 == obj[key]) {
45
+ obj.push({
46
+ name: key,
47
+ value: tryDecode(val, dec)
48
+ });
49
+ }
50
+ }
51
+ return obj;
52
+ }
53
+ class CookieChangeEvent extends Event {
54
+ constructor(type, eventInitDict = { changed: [], deleted: [] }) {
55
+ super(type, eventInitDict);
56
+ this.changed = eventInitDict.changed || [];
57
+ this.deleted = eventInitDict.deleted || [];
58
+ }
59
+ }
60
+ class CookieStore extends EventTarget {
61
+ constructor() {
62
+ super();
63
+ throw new TypeError("Illegal Constructor");
64
+ }
65
+ get [Symbol.toStringTag]() {
66
+ return "CookieStore";
67
+ }
68
+ async get(init) {
69
+ if (init == null) {
70
+ throw new TypeError("CookieStoreGetOptions must not be empty");
71
+ } else if (init instanceof Object && !Object.keys(init).length) {
72
+ throw new TypeError("CookieStoreGetOptions must not be empty");
73
+ }
74
+ return (await this.getAll(init))[0];
75
+ }
76
+ async set(init, possibleValue) {
77
+ var _a, _b, _c;
78
+ const item = {
79
+ name: "",
80
+ value: "",
81
+ path: "/",
82
+ secure: false,
83
+ sameSite: CookieSameSite.strict,
84
+ expires: null,
85
+ domain: null
86
+ };
87
+ if (typeof init === "string") {
88
+ item.name = init;
89
+ item.value = possibleValue;
90
+ } else {
91
+ Object.assign(item, init);
92
+ if (item.path && !item.path.startsWith("/")) {
93
+ throw new TypeError('Cookie path must start with "/"');
94
+ }
95
+ if ((_a = item.domain) === null || _a === void 0 ? void 0 : _a.startsWith(".")) {
96
+ throw new TypeError('Cookie domain cannot start with "."');
97
+ }
98
+ if (item.domain && item.domain !== window.location.hostname) {
99
+ throw new TypeError("Cookie domain must domain-match current host");
100
+ }
101
+ if (((_b = item.name) === null || _b === void 0 ? void 0 : _b.startsWith("__Host")) && item.domain) {
102
+ throw new TypeError("Cookie domain must not be specified for host cookies");
103
+ }
104
+ if (((_c = item.name) === null || _c === void 0 ? void 0 : _c.startsWith("__Host")) && item.path != "/") {
105
+ throw new TypeError("Cookie path must not be specified for host cookies");
106
+ }
107
+ if (item.path && item.path.endsWith("/")) {
108
+ item.path = item.path.slice(0, -1);
109
+ }
110
+ if (item.path === "") {
111
+ item.path = "/";
112
+ }
113
+ }
114
+ if (item.name === "" && item.value && item.value.includes("=")) {
115
+ throw new TypeError("Cookie value cannot contain '=' if the name is empty");
116
+ }
117
+ if (item.name && item.name.startsWith("__Host")) {
118
+ item.secure = true;
119
+ }
120
+ let cookieString = `${item.name}=${encodeURIComponent(item.value)}`;
121
+ if (item.domain) {
122
+ cookieString += "; Domain=" + item.domain;
123
+ }
124
+ if (item.path) {
125
+ cookieString += "; Path=" + item.path;
126
+ }
127
+ if (typeof item.expires === "number") {
128
+ cookieString += "; Expires=" + new Date(item.expires).toUTCString();
129
+ } else if (item.expires instanceof Date) {
130
+ cookieString += "; Expires=" + item.expires.toUTCString();
131
+ }
132
+ if (item.name && item.name.startsWith("__Secure") || item.secure) {
133
+ item.sameSite = CookieSameSite.lax;
134
+ cookieString += "; Secure";
135
+ }
136
+ switch (item.sameSite) {
137
+ case CookieSameSite.lax:
138
+ cookieString += "; SameSite=Lax";
139
+ break;
140
+ case CookieSameSite.strict:
141
+ cookieString += "; SameSite=Strict";
142
+ break;
143
+ case CookieSameSite.none:
144
+ cookieString += "; SameSite=None";
145
+ break;
146
+ }
147
+ const previousCookie = this.get(item);
148
+ document.cookie = cookieString;
149
+ if (this.onchange) {
150
+ const changed = [];
151
+ const deleted = [];
152
+ if (previousCookie && !await this.get(item)) {
153
+ deleted.push({ ...item, value: void 0 });
154
+ } else {
155
+ changed.push(item);
156
+ }
157
+ const event = new CookieChangeEvent("change", { changed, deleted });
158
+ this.onchange(event);
159
+ }
160
+ }
161
+ async getAll(init) {
162
+ const cookies = parse(document.cookie);
163
+ if (init == null || Object.keys(init).length === 0) {
164
+ return cookies;
165
+ }
166
+ let name;
167
+ let url;
168
+ if (typeof init === "string") {
169
+ name = init;
170
+ } else {
171
+ name = init.name;
172
+ url = init.url;
173
+ }
174
+ if (url) {
175
+ const parsedURL = new URL(url, window.location.origin);
176
+ if (window.location.href !== parsedURL.href || window.location.origin !== parsedURL.origin) {
177
+ throw new TypeError("URL must match the document URL");
178
+ }
179
+ return cookies.slice(0, 1);
180
+ }
181
+ return cookies.filter((cookie) => cookie.name === name);
182
+ }
183
+ async delete(init) {
184
+ const item = {
185
+ name: "",
186
+ value: "",
187
+ path: "/",
188
+ secure: false,
189
+ sameSite: CookieSameSite.strict,
190
+ expires: null,
191
+ domain: null
192
+ };
193
+ if (typeof init === "string") {
194
+ item.name = init;
195
+ } else {
196
+ Object.assign(item, init);
197
+ }
198
+ item.expires = 0;
199
+ await this.set(item);
200
+ }
201
+ }
202
+ const workerSubscriptions = /* @__PURE__ */ new WeakMap();
203
+ const registrations = /* @__PURE__ */ new WeakMap();
204
+ class CookieStoreManager {
205
+ get [Symbol.toStringTag]() {
206
+ return "CookieStoreManager";
207
+ }
208
+ constructor() {
209
+ throw new TypeError("Illegal Constructor");
210
+ }
211
+ async subscribe(subscriptions) {
212
+ const currentSubcriptions = workerSubscriptions.get(this) || [];
213
+ const worker = registrations.get(this);
214
+ if (!worker)
215
+ throw new TypeError("Illegal invocation");
216
+ for (const subscription of subscriptions) {
217
+ const name = subscription.name;
218
+ const url = new URL(subscription.url || "", worker.scope).toString();
219
+ if (currentSubcriptions.some((x) => x.name === name && x.url === url))
220
+ continue;
221
+ currentSubcriptions.push({
222
+ name: subscription.name,
223
+ url
224
+ });
225
+ }
226
+ workerSubscriptions.set(this, currentSubcriptions);
227
+ }
228
+ async getSubscriptions() {
229
+ return (workerSubscriptions.get(this) || []).map(({ name, url }) => ({
230
+ name,
231
+ url
232
+ }));
233
+ }
234
+ async unsubscribe(subscriptions) {
235
+ let currentSubcriptions = workerSubscriptions.get(this) || [];
236
+ const worker = registrations.get(this);
237
+ if (!worker)
238
+ throw new TypeError("Illegal invocation");
239
+ for (const subscription of subscriptions) {
240
+ const name = subscription.name;
241
+ const url = new URL(subscription.url || "", worker.scope).toString();
242
+ currentSubcriptions = currentSubcriptions.filter((x) => {
243
+ if (x.name !== name)
244
+ return true;
245
+ if (x.url !== url)
246
+ return true;
247
+ return false;
248
+ });
249
+ }
250
+ workerSubscriptions.set(this, currentSubcriptions);
251
+ }
252
+ }
253
+ if (!("cookies" in ServiceWorkerRegistration.prototype)) {
254
+ Object.defineProperty(ServiceWorkerRegistration.prototype, "cookies", {
255
+ configurable: true,
256
+ enumerable: true,
257
+ get() {
258
+ const manager = Object.create(CookieStoreManager.prototype);
259
+ registrations.set(manager, this);
260
+ Object.defineProperty(this, "cookies", { value: manager });
261
+ return manager;
262
+ }
263
+ });
264
+ }
265
+ const cookieStore = Object.create(CookieStore.prototype);
266
+ self.cookieStore = (self == null ? void 0 : self.cookieStore) ?? cookieStore;
267
+ const setCookie = ({ key, value, config }) => {
268
+ var _a;
269
+ return (_a = self.cookieStore) == null ? void 0 : _a.set(key, value, config);
5
270
  };
6
271
  const getCookie = ({ key }) => {
7
- return cookieStore == null ? void 0 : cookieStore.get(key);
272
+ var _a;
273
+ return (_a = self.cookieStore) == null ? void 0 : _a.get(key);
8
274
  };
9
275
  const getAllCookies = () => {
10
- return cookieStore == null ? void 0 : cookieStore.getAll();
276
+ var _a;
277
+ return (_a = self.cookieStore) == null ? void 0 : _a.getAll();
11
278
  };
12
279
  const removeCookie = ({ key }) => {
13
- return cookieStore == null ? void 0 : cookieStore.delete(key);
280
+ var _a;
281
+ return (_a = self.cookieStore) == null ? void 0 : _a.delete(key);
14
282
  };
15
283
  exports.getAllCookies = getAllCookies;
16
284
  exports.getCookie = getCookie;
package/dist/cookie.es.js CHANGED
@@ -1,14 +1,282 @@
1
- const setCookie = ({ key, value }) => {
2
- return cookieStore == null ? void 0 : cookieStore.set(key, value);
1
+ /*!
2
+ * Cookie-store v4.0.0-next.4
3
+ * https://github.com/markcellus/cookie-store
4
+ *
5
+ * Copyright (c) 2023 Mark
6
+ * Licensed under the MIT license
7
+ */
8
+ const decode = decodeURIComponent;
9
+ const pairSplitRegExp = /; */;
10
+ function tryDecode(str, decode2) {
11
+ try {
12
+ return typeof decode2 === "boolean" ? decodeURIComponent(str) : decode2(str);
13
+ } catch (e) {
14
+ return str;
15
+ }
16
+ }
17
+ var CookieSameSite;
18
+ (function(CookieSameSite2) {
19
+ CookieSameSite2["strict"] = "strict";
20
+ CookieSameSite2["lax"] = "lax";
21
+ CookieSameSite2["none"] = "none";
22
+ })(CookieSameSite || (CookieSameSite = {}));
23
+ function parse(str, options = {}) {
24
+ if (typeof str !== "string") {
25
+ throw new TypeError("argument str must be a string");
26
+ }
27
+ const obj = [];
28
+ const opt = options || {};
29
+ const pairs = str.split(pairSplitRegExp);
30
+ const dec = opt.decode || decode;
31
+ for (let i = 0; i < pairs.length; i++) {
32
+ const pair = pairs[i];
33
+ let eqIdx = pair.indexOf("=");
34
+ if (eqIdx < 0) {
35
+ continue;
36
+ }
37
+ const key = pair.substr(0, eqIdx).trim();
38
+ let val = pair.substr(++eqIdx, pair.length).trim();
39
+ if ('"' == val[0]) {
40
+ val = val.slice(1, -1);
41
+ }
42
+ if (void 0 == obj[key]) {
43
+ obj.push({
44
+ name: key,
45
+ value: tryDecode(val, dec)
46
+ });
47
+ }
48
+ }
49
+ return obj;
50
+ }
51
+ class CookieChangeEvent extends Event {
52
+ constructor(type, eventInitDict = { changed: [], deleted: [] }) {
53
+ super(type, eventInitDict);
54
+ this.changed = eventInitDict.changed || [];
55
+ this.deleted = eventInitDict.deleted || [];
56
+ }
57
+ }
58
+ class CookieStore extends EventTarget {
59
+ constructor() {
60
+ super();
61
+ throw new TypeError("Illegal Constructor");
62
+ }
63
+ get [Symbol.toStringTag]() {
64
+ return "CookieStore";
65
+ }
66
+ async get(init) {
67
+ if (init == null) {
68
+ throw new TypeError("CookieStoreGetOptions must not be empty");
69
+ } else if (init instanceof Object && !Object.keys(init).length) {
70
+ throw new TypeError("CookieStoreGetOptions must not be empty");
71
+ }
72
+ return (await this.getAll(init))[0];
73
+ }
74
+ async set(init, possibleValue) {
75
+ var _a, _b, _c;
76
+ const item = {
77
+ name: "",
78
+ value: "",
79
+ path: "/",
80
+ secure: false,
81
+ sameSite: CookieSameSite.strict,
82
+ expires: null,
83
+ domain: null
84
+ };
85
+ if (typeof init === "string") {
86
+ item.name = init;
87
+ item.value = possibleValue;
88
+ } else {
89
+ Object.assign(item, init);
90
+ if (item.path && !item.path.startsWith("/")) {
91
+ throw new TypeError('Cookie path must start with "/"');
92
+ }
93
+ if ((_a = item.domain) === null || _a === void 0 ? void 0 : _a.startsWith(".")) {
94
+ throw new TypeError('Cookie domain cannot start with "."');
95
+ }
96
+ if (item.domain && item.domain !== window.location.hostname) {
97
+ throw new TypeError("Cookie domain must domain-match current host");
98
+ }
99
+ if (((_b = item.name) === null || _b === void 0 ? void 0 : _b.startsWith("__Host")) && item.domain) {
100
+ throw new TypeError("Cookie domain must not be specified for host cookies");
101
+ }
102
+ if (((_c = item.name) === null || _c === void 0 ? void 0 : _c.startsWith("__Host")) && item.path != "/") {
103
+ throw new TypeError("Cookie path must not be specified for host cookies");
104
+ }
105
+ if (item.path && item.path.endsWith("/")) {
106
+ item.path = item.path.slice(0, -1);
107
+ }
108
+ if (item.path === "") {
109
+ item.path = "/";
110
+ }
111
+ }
112
+ if (item.name === "" && item.value && item.value.includes("=")) {
113
+ throw new TypeError("Cookie value cannot contain '=' if the name is empty");
114
+ }
115
+ if (item.name && item.name.startsWith("__Host")) {
116
+ item.secure = true;
117
+ }
118
+ let cookieString = `${item.name}=${encodeURIComponent(item.value)}`;
119
+ if (item.domain) {
120
+ cookieString += "; Domain=" + item.domain;
121
+ }
122
+ if (item.path) {
123
+ cookieString += "; Path=" + item.path;
124
+ }
125
+ if (typeof item.expires === "number") {
126
+ cookieString += "; Expires=" + new Date(item.expires).toUTCString();
127
+ } else if (item.expires instanceof Date) {
128
+ cookieString += "; Expires=" + item.expires.toUTCString();
129
+ }
130
+ if (item.name && item.name.startsWith("__Secure") || item.secure) {
131
+ item.sameSite = CookieSameSite.lax;
132
+ cookieString += "; Secure";
133
+ }
134
+ switch (item.sameSite) {
135
+ case CookieSameSite.lax:
136
+ cookieString += "; SameSite=Lax";
137
+ break;
138
+ case CookieSameSite.strict:
139
+ cookieString += "; SameSite=Strict";
140
+ break;
141
+ case CookieSameSite.none:
142
+ cookieString += "; SameSite=None";
143
+ break;
144
+ }
145
+ const previousCookie = this.get(item);
146
+ document.cookie = cookieString;
147
+ if (this.onchange) {
148
+ const changed = [];
149
+ const deleted = [];
150
+ if (previousCookie && !await this.get(item)) {
151
+ deleted.push({ ...item, value: void 0 });
152
+ } else {
153
+ changed.push(item);
154
+ }
155
+ const event = new CookieChangeEvent("change", { changed, deleted });
156
+ this.onchange(event);
157
+ }
158
+ }
159
+ async getAll(init) {
160
+ const cookies = parse(document.cookie);
161
+ if (init == null || Object.keys(init).length === 0) {
162
+ return cookies;
163
+ }
164
+ let name;
165
+ let url;
166
+ if (typeof init === "string") {
167
+ name = init;
168
+ } else {
169
+ name = init.name;
170
+ url = init.url;
171
+ }
172
+ if (url) {
173
+ const parsedURL = new URL(url, window.location.origin);
174
+ if (window.location.href !== parsedURL.href || window.location.origin !== parsedURL.origin) {
175
+ throw new TypeError("URL must match the document URL");
176
+ }
177
+ return cookies.slice(0, 1);
178
+ }
179
+ return cookies.filter((cookie) => cookie.name === name);
180
+ }
181
+ async delete(init) {
182
+ const item = {
183
+ name: "",
184
+ value: "",
185
+ path: "/",
186
+ secure: false,
187
+ sameSite: CookieSameSite.strict,
188
+ expires: null,
189
+ domain: null
190
+ };
191
+ if (typeof init === "string") {
192
+ item.name = init;
193
+ } else {
194
+ Object.assign(item, init);
195
+ }
196
+ item.expires = 0;
197
+ await this.set(item);
198
+ }
199
+ }
200
+ const workerSubscriptions = /* @__PURE__ */ new WeakMap();
201
+ const registrations = /* @__PURE__ */ new WeakMap();
202
+ class CookieStoreManager {
203
+ get [Symbol.toStringTag]() {
204
+ return "CookieStoreManager";
205
+ }
206
+ constructor() {
207
+ throw new TypeError("Illegal Constructor");
208
+ }
209
+ async subscribe(subscriptions) {
210
+ const currentSubcriptions = workerSubscriptions.get(this) || [];
211
+ const worker = registrations.get(this);
212
+ if (!worker)
213
+ throw new TypeError("Illegal invocation");
214
+ for (const subscription of subscriptions) {
215
+ const name = subscription.name;
216
+ const url = new URL(subscription.url || "", worker.scope).toString();
217
+ if (currentSubcriptions.some((x) => x.name === name && x.url === url))
218
+ continue;
219
+ currentSubcriptions.push({
220
+ name: subscription.name,
221
+ url
222
+ });
223
+ }
224
+ workerSubscriptions.set(this, currentSubcriptions);
225
+ }
226
+ async getSubscriptions() {
227
+ return (workerSubscriptions.get(this) || []).map(({ name, url }) => ({
228
+ name,
229
+ url
230
+ }));
231
+ }
232
+ async unsubscribe(subscriptions) {
233
+ let currentSubcriptions = workerSubscriptions.get(this) || [];
234
+ const worker = registrations.get(this);
235
+ if (!worker)
236
+ throw new TypeError("Illegal invocation");
237
+ for (const subscription of subscriptions) {
238
+ const name = subscription.name;
239
+ const url = new URL(subscription.url || "", worker.scope).toString();
240
+ currentSubcriptions = currentSubcriptions.filter((x) => {
241
+ if (x.name !== name)
242
+ return true;
243
+ if (x.url !== url)
244
+ return true;
245
+ return false;
246
+ });
247
+ }
248
+ workerSubscriptions.set(this, currentSubcriptions);
249
+ }
250
+ }
251
+ if (!("cookies" in ServiceWorkerRegistration.prototype)) {
252
+ Object.defineProperty(ServiceWorkerRegistration.prototype, "cookies", {
253
+ configurable: true,
254
+ enumerable: true,
255
+ get() {
256
+ const manager = Object.create(CookieStoreManager.prototype);
257
+ registrations.set(manager, this);
258
+ Object.defineProperty(this, "cookies", { value: manager });
259
+ return manager;
260
+ }
261
+ });
262
+ }
263
+ const cookieStore = Object.create(CookieStore.prototype);
264
+ self.cookieStore = (self == null ? void 0 : self.cookieStore) ?? cookieStore;
265
+ const setCookie = ({ key, value, config }) => {
266
+ var _a;
267
+ return (_a = self.cookieStore) == null ? void 0 : _a.set(key, value, config);
3
268
  };
4
269
  const getCookie = ({ key }) => {
5
- return cookieStore == null ? void 0 : cookieStore.get(key);
270
+ var _a;
271
+ return (_a = self.cookieStore) == null ? void 0 : _a.get(key);
6
272
  };
7
273
  const getAllCookies = () => {
8
- return cookieStore == null ? void 0 : cookieStore.getAll();
274
+ var _a;
275
+ return (_a = self.cookieStore) == null ? void 0 : _a.getAll();
9
276
  };
10
277
  const removeCookie = ({ key }) => {
11
- return cookieStore == null ? void 0 : cookieStore.delete(key);
278
+ var _a;
279
+ return (_a = self.cookieStore) == null ? void 0 : _a.delete(key);
12
280
  };
13
281
  export {
14
282
  getAllCookies,
@@ -18,6 +18,6 @@ function _interopNamespaceDefault(e) {
18
18
  return Object.freeze(n);
19
19
  }
20
20
  const URLPatternPolyfill__namespace = /* @__PURE__ */ _interopNamespaceDefault(URLPatternPolyfill);
21
- if (self == null ? void 0 : self.URLPattern) self.URLPattern = URLPatternPolyfill__namespace.URLPattern;
21
+ self.URLPattern = (self == null ? void 0 : self.URLPattern) ?? URLPatternPolyfill__namespace.URLPattern;
22
22
  const getURLPatern = ({ pathname }) => new self.URLPattern({ pathname });
23
23
  exports.getURLPatern = getURLPatern;
@@ -1,5 +1,5 @@
1
1
  import * as URLPatternPolyfill from "urlpattern-polyfill";
2
- if (self == null ? void 0 : self.URLPattern) self.URLPattern = URLPatternPolyfill.URLPattern;
2
+ self.URLPattern = (self == null ? void 0 : self.URLPattern) ?? URLPatternPolyfill.URLPattern;
3
3
  const getURLPatern = ({ pathname }) => new self.URLPattern({ pathname });
4
4
  export {
5
5
  getURLPatern
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saloe",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "Tools for making web development easy and efficient",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -60,12 +60,12 @@
60
60
  }
61
61
  },
62
62
  "dependencies": {
63
+ "cookie-store": "^4.0.0-next.4",
63
64
  "fs": "^0.0.1-security",
64
65
  "urlpattern-polyfill": "^10.0.0"
65
66
  },
66
67
  "devDependencies": {
67
68
  "@cloudflare/kv-asset-handler": "^0.3.4",
68
- "saloe": "^0.0.3",
69
69
  "vite": "^5.4.3"
70
70
  }
71
71
  }
package/src/cookie.js CHANGED
@@ -1,17 +1,22 @@
1
- const setCookie = ({ key, value }) => {
2
- return cookieStore?.set(key, value)
1
+ import { cookieStore } from 'cookie-store'
2
+
3
+
4
+ self.cookieStore = self?.cookieStore ?? cookieStore
5
+
6
+ const setCookie = ({ key, value, config }) => {
7
+ return self.cookieStore?.set(key, value, config)
3
8
  }
4
9
 
5
10
  const getCookie = ({ key }) => {
6
- return cookieStore?.get(key)
11
+ return self.cookieStore?.get(key)
7
12
  }
8
13
 
9
14
  const getAllCookies = () => {
10
- return cookieStore?.getAll()
15
+ return self.cookieStore?.getAll()
11
16
  }
12
17
 
13
18
  const removeCookie = ({ key }) => {
14
- return cookieStore?.delete(key)
19
+ return self.cookieStore?.delete(key)
15
20
  }
16
21
 
17
22
  export {
package/src/urlpattern.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as URLPatternPolyfill from 'urlpattern-polyfill'
2
2
 
3
3
 
4
- if (self?.URLPattern) self.URLPattern = URLPatternPolyfill.URLPattern
4
+ self.URLPattern = self?.URLPattern ?? URLPatternPolyfill.URLPattern
5
5
 
6
6
  const getURLPatern = ({ pathname }) => new self.URLPattern({ pathname })
7
7