@jlnstack/cookies 0.0.1 → 0.0.3
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/README.md +5 -0
- package/dist/browser.cjs +7 -7
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.cts.map +1 -1
- package/dist/browser.d.mts +1 -1
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +7 -7
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/next.cjs +7 -7
- package/dist/next.d.cts +1 -1
- package/dist/next.d.cts.map +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.mts.map +1 -1
- package/dist/next.mjs +7 -7
- package/dist/next.mjs.map +1 -1
- package/dist/types.d.cts +2 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +2 -1
- package/dist/types.d.mts.map +1 -1
- package/package.json +1 -1
package/README.md
ADDED
package/dist/browser.cjs
CHANGED
|
@@ -21,14 +21,14 @@ function setCookie(name, value, options) {
|
|
|
21
21
|
function deleteCookie(name) {
|
|
22
22
|
document.cookie = `${encodeURIComponent(name)}=; max-age=0`;
|
|
23
23
|
}
|
|
24
|
-
function createCookie(
|
|
24
|
+
function createCookie(options) {
|
|
25
25
|
return require_index.createCookie({
|
|
26
|
-
name,
|
|
27
|
-
schema: options
|
|
28
|
-
serializer: options
|
|
29
|
-
get: () => getCookie(name),
|
|
30
|
-
set: (value, opts) => setCookie(name, value, opts),
|
|
31
|
-
delete: () => deleteCookie(name)
|
|
26
|
+
name: options.name,
|
|
27
|
+
schema: options.schema,
|
|
28
|
+
serializer: options.serializer,
|
|
29
|
+
get: () => getCookie(options.name),
|
|
30
|
+
set: (value, opts) => setCookie(options.name, value, opts),
|
|
31
|
+
delete: () => deleteCookie(options.name)
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
package/dist/browser.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Cookie, CookieGroup, CookieOptions, CreateCookieOptions, Serializer } f
|
|
|
2
2
|
import { createCookieGroup } from "./index.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/browser.d.ts
|
|
5
|
-
declare function createCookie<T>(
|
|
5
|
+
declare function createCookie<T = string>(options: CreateCookieOptions<T>): Cookie<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
|
8
8
|
//# sourceMappingURL=browser.d.cts.map
|
package/dist/browser.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.cts","names":[],"sources":["../src/browser.ts"],"sourcesContent":[],"mappings":";;;;iBA8CgB,
|
|
1
|
+
{"version":3,"file":"browser.d.cts","names":[],"sources":["../src/browser.ts"],"sourcesContent":[],"mappings":";;;;iBA8CgB,kCACL,oBAAoB,KAC5B,OAAO"}
|
package/dist/browser.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Cookie, CookieGroup, CookieOptions, CreateCookieOptions, Serializer } f
|
|
|
2
2
|
import { createCookieGroup } from "./index.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/browser.d.ts
|
|
5
|
-
declare function createCookie<T>(
|
|
5
|
+
declare function createCookie<T = string>(options: CreateCookieOptions<T>): Cookie<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
|
8
8
|
//# sourceMappingURL=browser.d.mts.map
|
package/dist/browser.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.mts","names":[],"sources":["../src/browser.ts"],"sourcesContent":[],"mappings":";;;;iBA8CgB,
|
|
1
|
+
{"version":3,"file":"browser.d.mts","names":[],"sources":["../src/browser.ts"],"sourcesContent":[],"mappings":";;;;iBA8CgB,kCACL,oBAAoB,KAC5B,OAAO"}
|
package/dist/browser.mjs
CHANGED
|
@@ -21,14 +21,14 @@ function setCookie(name, value, options) {
|
|
|
21
21
|
function deleteCookie(name) {
|
|
22
22
|
document.cookie = `${encodeURIComponent(name)}=; max-age=0`;
|
|
23
23
|
}
|
|
24
|
-
function createCookie(
|
|
24
|
+
function createCookie(options) {
|
|
25
25
|
return createCookie$1({
|
|
26
|
-
name,
|
|
27
|
-
schema: options
|
|
28
|
-
serializer: options
|
|
29
|
-
get: () => getCookie(name),
|
|
30
|
-
set: (value, opts) => setCookie(name, value, opts),
|
|
31
|
-
delete: () => deleteCookie(name)
|
|
26
|
+
name: options.name,
|
|
27
|
+
schema: options.schema,
|
|
28
|
+
serializer: options.serializer,
|
|
29
|
+
get: () => getCookie(options.name),
|
|
30
|
+
set: (value, opts) => setCookie(options.name, value, opts),
|
|
31
|
+
delete: () => deleteCookie(options.name)
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
|
package/dist/browser.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.mjs","names":["createCookieCore"],"sources":["../src/browser.ts"],"sourcesContent":["import { createCookie as createCookieCore } from \"./index\";\nimport type { Cookie, CookieOptions, CreateCookieOptions } from \"./types\";\n\nexport { createCookieGroup } from \"./index\";\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nfunction getCookie(name: string): string | undefined {\n const cookies = document.cookie.split(\"; \");\n for (const cookie of cookies) {\n const [key, ...valueParts] = cookie.split(\"=\");\n if (key === name) {\n return decodeURIComponent(valueParts.join(\"=\"));\n }\n }\n return undefined;\n}\n\nfunction setCookie(name: string, value: string, options?: CookieOptions): void {\n const parts = [`${encodeURIComponent(name)}=${encodeURIComponent(value)}`];\n\n if (options?.maxAge !== undefined) {\n parts.push(`max-age=${options.maxAge}`);\n }\n if (options?.expires) {\n parts.push(`expires=${options.expires.toUTCString()}`);\n }\n if (options?.path) {\n parts.push(`path=${options.path}`);\n }\n if (options?.domain) {\n parts.push(`domain=${options.domain}`);\n }\n if (options?.secure) {\n parts.push(\"secure\");\n }\n if (options?.sameSite) {\n parts.push(`samesite=${options.sameSite}`);\n }\n\n document.cookie = parts.join(\"; \");\n}\n\nfunction deleteCookie(name: string): void {\n document.cookie = `${encodeURIComponent(name)}=; max-age=0`;\n}\n\nexport function createCookie<T>(\n
|
|
1
|
+
{"version":3,"file":"browser.mjs","names":["createCookieCore"],"sources":["../src/browser.ts"],"sourcesContent":["import { createCookie as createCookieCore } from \"./index\";\nimport type { Cookie, CookieOptions, CreateCookieOptions } from \"./types\";\n\nexport { createCookieGroup } from \"./index\";\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nfunction getCookie(name: string): string | undefined {\n const cookies = document.cookie.split(\"; \");\n for (const cookie of cookies) {\n const [key, ...valueParts] = cookie.split(\"=\");\n if (key === name) {\n return decodeURIComponent(valueParts.join(\"=\"));\n }\n }\n return undefined;\n}\n\nfunction setCookie(name: string, value: string, options?: CookieOptions): void {\n const parts = [`${encodeURIComponent(name)}=${encodeURIComponent(value)}`];\n\n if (options?.maxAge !== undefined) {\n parts.push(`max-age=${options.maxAge}`);\n }\n if (options?.expires) {\n parts.push(`expires=${options.expires.toUTCString()}`);\n }\n if (options?.path) {\n parts.push(`path=${options.path}`);\n }\n if (options?.domain) {\n parts.push(`domain=${options.domain}`);\n }\n if (options?.secure) {\n parts.push(\"secure\");\n }\n if (options?.sameSite) {\n parts.push(`samesite=${options.sameSite}`);\n }\n\n document.cookie = parts.join(\"; \");\n}\n\nfunction deleteCookie(name: string): void {\n document.cookie = `${encodeURIComponent(name)}=; max-age=0`;\n}\n\nexport function createCookie<T = string>(\n options: CreateCookieOptions<T>,\n): Cookie<T> {\n return createCookieCore({\n name: options.name,\n schema: options.schema,\n serializer: options.serializer,\n get: () => getCookie(options.name),\n set: (value, opts) => setCookie(options.name, value, opts),\n delete: () => deleteCookie(options.name),\n });\n}\n"],"mappings":";;;AAMA,SAAS,UAAU,MAAkC;CACnD,MAAM,UAAU,SAAS,OAAO,MAAM,KAAK;AAC3C,MAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,CAAC,KAAK,GAAG,cAAc,OAAO,MAAM,IAAI;AAC9C,MAAI,QAAQ,KACV,QAAO,mBAAmB,WAAW,KAAK,IAAI,CAAC;;;AAMrD,SAAS,UAAU,MAAc,OAAe,SAA+B;CAC7E,MAAM,QAAQ,CAAC,GAAG,mBAAmB,KAAK,CAAC,GAAG,mBAAmB,MAAM,GAAG;AAE1E,wDAAI,QAAS,YAAW,OACtB,OAAM,KAAK,WAAW,QAAQ,SAAS;AAEzC,uDAAI,QAAS,QACX,OAAM,KAAK,WAAW,QAAQ,QAAQ,aAAa,GAAG;AAExD,uDAAI,QAAS,KACX,OAAM,KAAK,QAAQ,QAAQ,OAAO;AAEpC,uDAAI,QAAS,OACX,OAAM,KAAK,UAAU,QAAQ,SAAS;AAExC,uDAAI,QAAS,OACX,OAAM,KAAK,SAAS;AAEtB,uDAAI,QAAS,SACX,OAAM,KAAK,YAAY,QAAQ,WAAW;AAG5C,UAAS,SAAS,MAAM,KAAK,KAAK;;AAGpC,SAAS,aAAa,MAAoB;AACxC,UAAS,SAAS,GAAG,mBAAmB,KAAK,CAAC;;AAGhD,SAAgB,aACd,SACW;AACX,QAAOA,eAAiB;EACtB,MAAM,QAAQ;EACd,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACpB,WAAW,UAAU,QAAQ,KAAK;EAClC,MAAM,OAAO,SAAS,UAAU,QAAQ,MAAM,OAAO,KAAK;EAC1D,cAAc,aAAa,QAAQ,KAAK;EACzC,CAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cookie, CookieConfig, CookieGroup, CookieOptions, Serializer } from "./types.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
-
declare function createCookie<T>(config: CookieConfig<T>): Cookie<T>;
|
|
4
|
+
declare function createCookie<T = string>(config: CookieConfig<T>): Cookie<T>;
|
|
5
5
|
declare function createCookieGroup<T extends Record<string, Cookie<unknown>>>(cookies: T): CookieGroup<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAuCgB,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAuCgB,iCAAiC,aAAa,KAAK,OAAO;AAA1D,iBA0CA,iBA1CY,CAAA,UA0CgB,MA1ChB,CAAA,MAAA,EA0C+B,MA1C/B,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,OAAA,EA2CjB,CA3CiB,CAAA,EA4CzB,WA5CyB,CA4Cb,CA5Ca,CAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cookie, CookieConfig, CookieGroup, CookieOptions, Serializer } from "./types.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
|
-
declare function createCookie<T>(config: CookieConfig<T>): Cookie<T>;
|
|
4
|
+
declare function createCookie<T = string>(config: CookieConfig<T>): Cookie<T>;
|
|
5
5
|
declare function createCookieGroup<T extends Record<string, Cookie<unknown>>>(cookies: T): CookieGroup<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAuCgB,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;iBAuCgB,iCAAiC,aAAa,KAAK,OAAO;AAA1D,iBA0CA,iBA1CY,CAAA,UA0CgB,MA1ChB,CAAA,MAAA,EA0C+B,MA1C/B,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA,OAAA,EA2CjB,CA3CiB,CAAA,EA4CzB,WA5CyB,CA4Cb,CA5Ca,CAAA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n Cookie,\n CookieConfig,\n CookieGroup,\n CookieOptions,\n CookieValues,\n Serializer,\n} from \"./types\";\n\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nconst jsonSerializer: Serializer<unknown> = {\n serialize: (value) => {\n if (typeof value === \"string\") return value;\n return JSON.stringify(value);\n },\n deserialize: (raw) => {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n },\n};\n\nasync function validateSchema<T>(\n schema: StandardSchemaV1<T>,\n value: unknown,\n): Promise<{ success: true; value: T } | { success: false }> {\n const result = await schema[\"~standard\"].validate(value);\n\n if (\"issues\" in result && result.issues) {\n return { success: false };\n }\n\n return { success: true, value: result.value as T };\n}\n\nexport function createCookie<T>(config: CookieConfig<T>): Cookie<T> {\n const {\n name,\n schema,\n serializer = jsonSerializer as Serializer<T>,\n get,\n set,\n delete: deleteFn,\n } = config;\n\n return {\n name,\n async get() {\n const raw = await get();\n if (raw === undefined) return undefined;\n\n const parsed = serializer.deserialize(raw);\n\n if (schema) {\n const result = await validateSchema(schema, parsed);\n if (!result.success) return undefined;\n return result.value;\n }\n\n return parsed;\n },\n async set(value: T, options?: CookieOptions) {\n if (schema) {\n const result = await validateSchema(schema, value);\n if (!result.success) {\n throw new Error(\"Invalid cookie value\");\n }\n }\n\n await set(serializer.serialize(value), options);\n },\n async delete() {\n await deleteFn();\n },\n };\n}\n\nexport function createCookieGroup<T extends Record<string, Cookie<unknown>>>(\n cookies: T,\n): CookieGroup<T> {\n return {\n ...cookies,\n async get() {\n const entries = await Promise.all(\n Object.entries(cookies).map(async ([key, cookie]) => [\n key,\n await cookie.get(),\n ]),\n );\n return Object.fromEntries(entries) as {\n [K in keyof T]: Awaited<ReturnType<T[K][\"get\"]>>;\n };\n },\n async set(values: Partial<CookieValues<T>>, options?: CookieOptions) {\n const promises: Promise<void>[] = [];\n for (const [key, value] of Object.entries(values)) {\n const cookie = cookies[key as keyof T];\n if (cookie && value !== undefined) {\n promises.push(cookie.set(value, options));\n }\n }\n await Promise.all(promises);\n },\n async deleteAll() {\n await Promise.all(Object.values(cookies).map((c) => c.delete()));\n },\n };\n}\n"],"mappings":";;;AAYA,MAAM,iBAAsC;CAC1C,YAAY,UAAU;AACpB,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO,KAAK,UAAU,MAAM;;CAE9B,cAAc,QAAQ;AACpB,MAAI;AACF,UAAO,KAAK,MAAM,IAAI;oBAChB;AACN,UAAO;;;CAGZ;AAED,eAAe,eACb,QACA,OAC2D;CAC3D,MAAM,SAAS,MAAM,OAAO,aAAa,SAAS,MAAM;AAExD,KAAI,YAAY,UAAU,OAAO,OAC/B,QAAO,EAAE,SAAS,OAAO;AAG3B,QAAO;EAAE,SAAS;EAAM,OAAO,OAAO;EAAY;;AAGpD,SAAgB,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type {\n Cookie,\n CookieConfig,\n CookieGroup,\n CookieOptions,\n CookieValues,\n Serializer,\n} from \"./types\";\n\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nconst jsonSerializer: Serializer<unknown> = {\n serialize: (value) => {\n if (typeof value === \"string\") return value;\n return JSON.stringify(value);\n },\n deserialize: (raw) => {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n },\n};\n\nasync function validateSchema<T>(\n schema: StandardSchemaV1<T>,\n value: unknown,\n): Promise<{ success: true; value: T } | { success: false }> {\n const result = await schema[\"~standard\"].validate(value);\n\n if (\"issues\" in result && result.issues) {\n return { success: false };\n }\n\n return { success: true, value: result.value as T };\n}\n\nexport function createCookie<T = string>(config: CookieConfig<T>): Cookie<T> {\n const {\n name,\n schema,\n serializer = jsonSerializer as Serializer<T>,\n get,\n set,\n delete: deleteFn,\n } = config;\n\n return {\n name,\n async get() {\n const raw = await get();\n if (raw === undefined) return undefined;\n\n const parsed = serializer.deserialize(raw);\n\n if (schema) {\n const result = await validateSchema(schema, parsed);\n if (!result.success) return undefined;\n return result.value;\n }\n\n return parsed;\n },\n async set(value: T, options?: CookieOptions) {\n if (schema) {\n const result = await validateSchema(schema, value);\n if (!result.success) {\n throw new Error(\"Invalid cookie value\");\n }\n }\n\n await set(serializer.serialize(value), options);\n },\n async delete() {\n await deleteFn();\n },\n };\n}\n\nexport function createCookieGroup<T extends Record<string, Cookie<unknown>>>(\n cookies: T,\n): CookieGroup<T> {\n return {\n ...cookies,\n async get() {\n const entries = await Promise.all(\n Object.entries(cookies).map(async ([key, cookie]) => [\n key,\n await cookie.get(),\n ]),\n );\n return Object.fromEntries(entries) as {\n [K in keyof T]: Awaited<ReturnType<T[K][\"get\"]>>;\n };\n },\n async set(values: Partial<CookieValues<T>>, options?: CookieOptions) {\n const promises: Promise<void>[] = [];\n for (const [key, value] of Object.entries(values)) {\n const cookie = cookies[key as keyof T];\n if (cookie && value !== undefined) {\n promises.push(cookie.set(value, options));\n }\n }\n await Promise.all(promises);\n },\n async deleteAll() {\n await Promise.all(Object.values(cookies).map((c) => c.delete()));\n },\n };\n}\n"],"mappings":";;;AAYA,MAAM,iBAAsC;CAC1C,YAAY,UAAU;AACpB,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,SAAO,KAAK,UAAU,MA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AACvB,QAAI,UAAU,UAAU,OACtB,UAAS,KAAK,OAAO,IAAI,OAAO,QAAQ,CAAC;;AAG7C,SAAM,QAAQ,IAAI,SAAS;;EAE7B,MAAM,YAAY;AAChB,SAAM,QAAQ,IAAI,OAAO,OAAO,QAAQ,CAAC,KAAK,MAAM,EAAE,QAAQ,CAAC,CAAC"}
|
package/dist/next.cjs
CHANGED
|
@@ -2,20 +2,20 @@ const require_index = require('./index.cjs');
|
|
|
2
2
|
let next_headers = require("next/headers");
|
|
3
3
|
|
|
4
4
|
//#region src/next.ts
|
|
5
|
-
function createCookie(
|
|
5
|
+
function createCookie(options) {
|
|
6
6
|
return require_index.createCookie({
|
|
7
|
-
name,
|
|
8
|
-
schema: options
|
|
9
|
-
serializer: options
|
|
7
|
+
name: options.name,
|
|
8
|
+
schema: options.schema,
|
|
9
|
+
serializer: options.serializer,
|
|
10
10
|
get: async () => {
|
|
11
11
|
var _await$cookies$get;
|
|
12
|
-
return (_await$cookies$get = (await (0, next_headers.cookies)()).get(name)) === null || _await$cookies$get === void 0 ? void 0 : _await$cookies$get.value;
|
|
12
|
+
return (_await$cookies$get = (await (0, next_headers.cookies)()).get(options.name)) === null || _await$cookies$get === void 0 ? void 0 : _await$cookies$get.value;
|
|
13
13
|
},
|
|
14
14
|
set: async (value, opts) => {
|
|
15
|
-
(await (0, next_headers.cookies)()).set(name, value, opts);
|
|
15
|
+
(await (0, next_headers.cookies)()).set(options.name, value, opts);
|
|
16
16
|
},
|
|
17
17
|
delete: async () => {
|
|
18
|
-
(await (0, next_headers.cookies)()).delete(name);
|
|
18
|
+
(await (0, next_headers.cookies)()).delete(options.name);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
}
|
package/dist/next.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Cookie, CookieGroup, CookieOptions, CreateCookieOptions, Serializer } f
|
|
|
2
2
|
import { createCookieGroup } from "./index.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/next.d.ts
|
|
5
|
-
declare function createCookie<T>(
|
|
5
|
+
declare function createCookie<T = string>(options: CreateCookieOptions<T>): Cookie<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
|
8
8
|
//# sourceMappingURL=next.d.cts.map
|
package/dist/next.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.cts","names":[],"sources":["../src/next.ts"],"sourcesContent":[],"mappings":";;;;iBAOgB,
|
|
1
|
+
{"version":3,"file":"next.d.cts","names":[],"sources":["../src/next.ts"],"sourcesContent":[],"mappings":";;;;iBAOgB,kCACL,oBAAoB,KAC5B,OAAO"}
|
package/dist/next.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { Cookie, CookieGroup, CookieOptions, CreateCookieOptions, Serializer } f
|
|
|
2
2
|
import { createCookieGroup } from "./index.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/next.d.ts
|
|
5
|
-
declare function createCookie<T>(
|
|
5
|
+
declare function createCookie<T = string>(options: CreateCookieOptions<T>): Cookie<T>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { type Cookie, type CookieGroup, type CookieOptions, type Serializer, createCookie, createCookieGroup };
|
|
8
8
|
//# sourceMappingURL=next.d.mts.map
|
package/dist/next.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.d.mts","names":[],"sources":["../src/next.ts"],"sourcesContent":[],"mappings":";;;;iBAOgB,
|
|
1
|
+
{"version":3,"file":"next.d.mts","names":[],"sources":["../src/next.ts"],"sourcesContent":[],"mappings":";;;;iBAOgB,kCACL,oBAAoB,KAC5B,OAAO"}
|
package/dist/next.mjs
CHANGED
|
@@ -2,20 +2,20 @@ import { createCookie as createCookie$1, createCookieGroup } from "./index.mjs";
|
|
|
2
2
|
import { cookies } from "next/headers";
|
|
3
3
|
|
|
4
4
|
//#region src/next.ts
|
|
5
|
-
function createCookie(
|
|
5
|
+
function createCookie(options) {
|
|
6
6
|
return createCookie$1({
|
|
7
|
-
name,
|
|
8
|
-
schema: options
|
|
9
|
-
serializer: options
|
|
7
|
+
name: options.name,
|
|
8
|
+
schema: options.schema,
|
|
9
|
+
serializer: options.serializer,
|
|
10
10
|
get: async () => {
|
|
11
11
|
var _await$cookies$get;
|
|
12
|
-
return (_await$cookies$get = (await cookies()).get(name)) === null || _await$cookies$get === void 0 ? void 0 : _await$cookies$get.value;
|
|
12
|
+
return (_await$cookies$get = (await cookies()).get(options.name)) === null || _await$cookies$get === void 0 ? void 0 : _await$cookies$get.value;
|
|
13
13
|
},
|
|
14
14
|
set: async (value, opts) => {
|
|
15
|
-
(await cookies()).set(name, value, opts);
|
|
15
|
+
(await cookies()).set(options.name, value, opts);
|
|
16
16
|
},
|
|
17
17
|
delete: async () => {
|
|
18
|
-
(await cookies()).delete(name);
|
|
18
|
+
(await cookies()).delete(options.name);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
21
|
}
|
package/dist/next.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next.mjs","names":["createCookieCore"],"sources":["../src/next.ts"],"sourcesContent":["import { cookies } from \"next/headers\";\nimport { createCookie as createCookieCore } from \"./index\";\nimport type { Cookie, CreateCookieOptions } from \"./types\";\n\nexport { createCookieGroup } from \"./index\";\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nexport function createCookie<T>(\n
|
|
1
|
+
{"version":3,"file":"next.mjs","names":["createCookieCore"],"sources":["../src/next.ts"],"sourcesContent":["import { cookies } from \"next/headers\";\nimport { createCookie as createCookieCore } from \"./index\";\nimport type { Cookie, CreateCookieOptions } from \"./types\";\n\nexport { createCookieGroup } from \"./index\";\nexport type { Cookie, CookieGroup, CookieOptions, Serializer } from \"./types\";\n\nexport function createCookie<T = string>(\n options: CreateCookieOptions<T>,\n): Cookie<T> {\n return createCookieCore({\n name: options.name,\n schema: options.schema,\n serializer: options.serializer,\n get: async () => (await cookies()).get(options.name)?.value,\n set: async (value, opts) => {\n (await cookies()).set(options.name, value, opts);\n },\n delete: async () => {\n (await cookies()).delete(options.name);\n },\n });\n}\n"],"mappings":";;;;AAOA,SAAgB,aACd,SACW;AACX,QAAOA,eAAiB;EACtB,MAAM,QAAQ;EACd,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACpB,KAAK,YAAY;;iCAAC,MAAM,SAAS,EAAE,IAAI,QAAQ,KAAK,0EAAE;;EACtD,KAAK,OAAO,OAAO,SAAS;AAC1B,IAAC,MAAM,SAAS,EAAE,IAAI,QAAQ,MAAM,OAAO,KAAK;;EAElD,QAAQ,YAAY;AAClB,IAAC,MAAM,SAAS,EAAE,OAAO,QAAQ,KAAK;;EAEzC,CAAC"}
|
package/dist/types.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ interface Serializer<T> {
|
|
|
14
14
|
serialize: (value: T) => string;
|
|
15
15
|
deserialize: (raw: string) => T;
|
|
16
16
|
}
|
|
17
|
-
interface Cookie<T> {
|
|
17
|
+
interface Cookie<T = string> {
|
|
18
18
|
name: string;
|
|
19
19
|
get(): Promise<T | undefined>;
|
|
20
20
|
set(value: T, options?: CookieOptions): Promise<void>;
|
|
@@ -29,6 +29,7 @@ interface CookieConfig<T> {
|
|
|
29
29
|
delete: () => Promise<void> | void;
|
|
30
30
|
}
|
|
31
31
|
interface CreateCookieOptions<T> {
|
|
32
|
+
name: string;
|
|
32
33
|
schema?: StandardSchemaV1<T>;
|
|
33
34
|
serializer?: Serializer<T>;
|
|
34
35
|
}
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,aAAA;;EAAA,OAAA,CAAA,EAEL,IAFK;EAUA,IAAA,CAAA,EAAA,MAAU;EAAA,MAAA,CAAA,EAAA,MAAA;QACN,CAAA,EAAA,OAA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A,EAAA,OAAA,CAAA,EAAA,aAAA,EAAA,GAAkB,OAAlB,CAAA,IAAA,CAAA,GAAA,IAAA;QAAkB,EAAA,GAAA,GACnC,OADmC,CAAA,IAAA,CAAA,GAAA,IAAA;;AAC5B,UAGN,mBAHM,CAAA,CAAA,CAAA,CAAA;EAGN,IAAA,EAAA,MAAA;EAAmB,MAAA,CAAA,EAEzB,gBAFyB,CAER,CAFQ,CAAA;YAER,CAAA,EACb,UADa,CACF,CADE,CAAA;;AACb,KASH,YATG,CAAA,UASoB,MATpB,CAAA,MAAA,EASmC,MATnC,CAAA,OAAA,CAAA,CAAA,CAAA,GAAA,QAAU,MAUX,CAVW,GAUP,UAVO,CAUI,CAVJ,CAUM,CAVN,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EASzB;AAAwB,UAIP,YAJO,CAAA,UAIgB,MAJhB,CAAA,MAAA,EAI+B,MAJ/B,CAAA,OAAA,CAAA,CAAA,CAAA,CAAA;KAA0B,EAAA,EAKzC,OALyC,CAAA,QAAf,MAKJ,CALI,GAKA,OALA,CAKQ,UALR,CAKmB,CALnB,CAKqB,CALrB,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA;KACN,CAAA,MAAA,EAKf,OALe,CAKP,YALO,CAKM,CALN,CAAA,CAAA,EAAA,OAAA,CAAA,EAKqB,aALrB,CAAA,EAKqC,OALrC,CAAA,IAAA,CAAA;WAAE,EAAA,EAMhB,OANgB,CAAA,IAAA,CAAA;;AAAH,KAShB,WATgB,CAAA,UASM,MATN,CAAA,MAAA,EASqB,MATrB,CAAA,OAAA,CAAA,CAAA,CAAA,GAU1B,YAV0B,CAUb,CAVa,CAAA,GAUR,CAVQ"}
|
package/dist/types.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ interface Serializer<T> {
|
|
|
14
14
|
serialize: (value: T) => string;
|
|
15
15
|
deserialize: (raw: string) => T;
|
|
16
16
|
}
|
|
17
|
-
interface Cookie<T> {
|
|
17
|
+
interface Cookie<T = string> {
|
|
18
18
|
name: string;
|
|
19
19
|
get(): Promise<T | undefined>;
|
|
20
20
|
set(value: T, options?: CookieOptions): Promise<void>;
|
|
@@ -29,6 +29,7 @@ interface CookieConfig<T> {
|
|
|
29
29
|
delete: () => Promise<void> | void;
|
|
30
30
|
}
|
|
31
31
|
interface CreateCookieOptions<T> {
|
|
32
|
+
name: string;
|
|
32
33
|
schema?: StandardSchemaV1<T>;
|
|
33
34
|
serializer?: Serializer<T>;
|
|
34
35
|
}
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,aAAA;;EAAA,OAAA,CAAA,EAEL,IAFK;EAUA,IAAA,CAAA,EAAA,MAAU;EAAA,MAAA,CAAA,EAAA,MAAA;QACN,CAAA,EAAA,OAAA;UACW,CAAA,EAAA,OAAA;EAAC,QAAA,CAAA,EAAA,QAAA,GAAA,KAAA,GAAA,MAAA;AAGjC;AAAuB,UALN,UAKM,CAAA,CAAA,CAAA,CAAA;WAEN,EAAA,CAAA,KAAA,EANI,CAMJ,EAAA,GAAA,MAAA;aAAR,EAAA,CAAA,GAAA,EAAA,MAAA,EAAA,GALuB,CAKvB;;AACiB,UAHT,MAGS,CAAA,
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;UAEiB,aAAA;;EAAA,OAAA,CAAA,EAEL,IAFK;EAUA,IAAA,CAAA,EAAA,MAAU;EAAA,MAAA,CAAA,EAAA,MAAA;QACN,CAAA,EAAA,OAAA;UACW,CAAA,EAAA,OAAA;EAAC,QAAA,CAAA,EAAA,QAAA,GAAA,KAAA,GAAA,MAAA;AAGjC;AAAuB,UALN,UAKM,CAAA,CAAA,CAAA,CAAA;WAEN,EAAA,CAAA,KAAA,EANI,CAMJ,EAAA,GAAA,MAAA;aAAR,EAAA,CAAA,GAAA,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