@dargmuesli/nuxt-cookie-control 5.9.2 → 5.10.0
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
3
3
|
import { createResolver, defineNuxtModule, addPlugin, addImports, addTemplate, extendWebpackConfig, resolvePath } from '@nuxt/kit';
|
|
4
4
|
|
|
5
5
|
const name = "@dargmuesli/nuxt-cookie-control";
|
|
6
|
-
const version = "5.
|
|
6
|
+
const version = "5.10.0";
|
|
7
7
|
|
|
8
8
|
const en = {
|
|
9
9
|
accept: "Accept",
|
|
@@ -96,9 +96,7 @@
|
|
|
96
96
|
getCookieIds(localCookiesEnabled).includes(
|
|
97
97
|
getCookieId(cookie)
|
|
98
98
|
) ||
|
|
99
|
-
(
|
|
100
|
-
moduleOptions.cookieNameIsConsentGiven
|
|
101
|
-
) !== allCookieIdsString &&
|
|
99
|
+
(cookieIsConsentGiven !== allCookieIdsString &&
|
|
102
100
|
typeof moduleOptions.isIframeBlocked ===
|
|
103
101
|
'object' &&
|
|
104
102
|
moduleOptions.isIframeBlocked.initialState)
|
|
@@ -195,7 +193,6 @@ import { ref, computed, onBeforeMount, watch } from 'vue'
|
|
|
195
193
|
import { Cookie, CookieType, Locale, Translatable } from '../types'
|
|
196
194
|
import {
|
|
197
195
|
getAllCookieIdsString,
|
|
198
|
-
getCookie,
|
|
199
196
|
getCookieId,
|
|
200
197
|
getCookieIds,
|
|
201
198
|
removeCookie,
|
|
@@ -225,6 +222,10 @@ const {
|
|
|
225
222
|
const expires = new Date()
|
|
226
223
|
const localCookiesEnabled = ref([...(cookiesEnabled.value || [])])
|
|
227
224
|
const allCookieIdsString = getAllCookieIdsString(moduleOptions)
|
|
225
|
+
const cookieIsConsentGiven = useCookie(moduleOptions.cookieNameIsConsentGiven)
|
|
226
|
+
const cookieCookiesEnabledIds = useCookie(
|
|
227
|
+
moduleOptions.cookieNameCookiesEnabledIds
|
|
228
|
+
)
|
|
228
229
|
|
|
229
230
|
// computations
|
|
230
231
|
const isSaved = computed(
|
|
@@ -335,9 +336,7 @@ onBeforeMount(() => {
|
|
|
335
336
|
setCssVariables(variables)
|
|
336
337
|
}
|
|
337
338
|
|
|
338
|
-
if (
|
|
339
|
-
getCookie(moduleOptions.cookieNameIsConsentGiven) === allCookieIdsString
|
|
340
|
-
) {
|
|
339
|
+
if (cookieIsConsentGiven.value === allCookieIdsString) {
|
|
341
340
|
for (const cookieOptional of moduleOptions.cookies.optional) {
|
|
342
341
|
if (
|
|
343
342
|
typeof moduleOptions.isIframeBlocked === 'boolean'
|
|
@@ -375,7 +374,7 @@ watch(
|
|
|
375
374
|
document.getElementsByTagName('head')[0].appendChild(script)
|
|
376
375
|
}
|
|
377
376
|
} else {
|
|
378
|
-
|
|
377
|
+
cookieCookiesEnabledIds.value = undefined
|
|
379
378
|
}
|
|
380
379
|
|
|
381
380
|
// delete formerly enabled cookies that are now disabled
|
|
@@ -405,7 +404,7 @@ watch(
|
|
|
405
404
|
)
|
|
406
405
|
watch(isConsentGiven, (current, _previous) => {
|
|
407
406
|
if (current === undefined) {
|
|
408
|
-
|
|
407
|
+
cookieIsConsentGiven.value = undefined
|
|
409
408
|
} else {
|
|
410
409
|
setCookie(
|
|
411
410
|
moduleOptions.cookieNameIsConsentGiven,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { type CookieSerializeOptions } from 'cookie-es';
|
|
1
2
|
import { Cookie, ModuleOptions, Translatable } from './types';
|
|
2
3
|
export declare const getAllCookieIdsString: (moduleOptions: ModuleOptions) => string;
|
|
3
|
-
export declare const getCookie: (name: string) => any;
|
|
4
4
|
export declare const getCookieId: (cookie: Cookie) => string;
|
|
5
5
|
export declare const getCookieIds: (cookies: Cookie[]) => string[];
|
|
6
|
-
export declare const removeCookie: (name: string) =>
|
|
6
|
+
export declare const removeCookie: (name: string) => string;
|
|
7
7
|
export declare const resolveTranslatable: (translatable: Translatable, locale?: import("./types").Locale) => string;
|
|
8
|
-
export declare const setCookie: (name: string, value: string, options:
|
|
8
|
+
export declare const setCookie: (name: string, value: string, options: CookieSerializeOptions) => string;
|
|
9
9
|
export declare const useResolveTranslatable: (locale?: import("./types").Locale) => (translatable: Translatable) => string;
|
package/dist/runtime/methods.mjs
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import Cookies from "js-cookie";
|
|
2
1
|
import slugify from "@sindresorhus/slugify";
|
|
2
|
+
import { serialize } from "cookie-es";
|
|
3
3
|
import { LOCALE_DEFAULT } from "./constants.mjs";
|
|
4
4
|
export const getAllCookieIdsString = (moduleOptions) => getCookieIds([
|
|
5
5
|
...moduleOptions.cookies.necessary,
|
|
6
6
|
...moduleOptions.cookies.optional
|
|
7
7
|
]).join("");
|
|
8
|
-
export const getCookie = (name) => Cookies.get(name);
|
|
9
8
|
export const getCookieId = (cookie) => cookie.id || slugify(resolveTranslatable(cookie.name));
|
|
10
9
|
export const getCookieIds = (cookies) => cookies.map((cookie) => getCookieId(cookie));
|
|
11
|
-
export const removeCookie = (name) =>
|
|
10
|
+
export const removeCookie = (name) => document.cookie = serialize(name, "", { expires: /* @__PURE__ */ new Date(0) });
|
|
12
11
|
export const resolveTranslatable = (translatable, locale = LOCALE_DEFAULT) => {
|
|
13
12
|
if (typeof translatable === "string")
|
|
14
13
|
return translatable;
|
|
@@ -19,7 +18,10 @@ export const resolveTranslatable = (translatable, locale = LOCALE_DEFAULT) => {
|
|
|
19
18
|
throw new Error(`Could not get translation for locale ${locale}.`);
|
|
20
19
|
return result;
|
|
21
20
|
};
|
|
22
|
-
export const setCookie = (name, value, options) =>
|
|
21
|
+
export const setCookie = (name, value, options) => document.cookie = serialize(name, value, {
|
|
22
|
+
sameSite: "strict",
|
|
23
|
+
...options
|
|
24
|
+
});
|
|
23
25
|
export const useResolveTranslatable = (locale = LOCALE_DEFAULT) => {
|
|
24
26
|
return (translatable) => resolveTranslatable(translatable, locale);
|
|
25
27
|
};
|
package/dist/runtime/plugin.mjs
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import Cookies from "js-cookie";
|
|
2
1
|
import { ref } from "vue";
|
|
3
2
|
import { getAllCookieIdsString, getCookieId } from "./methods.mjs";
|
|
4
3
|
import { defineNuxtPlugin } from "#imports";
|
|
5
4
|
import moduleOptions from "#build/cookie-control-options";
|
|
6
5
|
export default defineNuxtPlugin((_nuxtApp) => {
|
|
7
|
-
const cookieIsConsentGiven =
|
|
8
|
-
|
|
9
|
-
);
|
|
10
|
-
const cookieCookiesEnabledIds = Cookies.get(
|
|
6
|
+
const cookieIsConsentGiven = useCookie(moduleOptions.cookieNameIsConsentGiven);
|
|
7
|
+
const cookieCookiesEnabledIds = useCookie(
|
|
11
8
|
moduleOptions.cookieNameCookiesEnabledIds
|
|
12
|
-
)?.split("|");
|
|
9
|
+
).value?.split("|");
|
|
13
10
|
const isConsentGiven = ref(
|
|
14
|
-
cookieIsConsentGiven === void 0 ? void 0 : cookieIsConsentGiven === getAllCookieIdsString(moduleOptions)
|
|
11
|
+
cookieIsConsentGiven === void 0 ? void 0 : cookieIsConsentGiven.value === getAllCookieIdsString(moduleOptions)
|
|
15
12
|
);
|
|
16
13
|
const cookiesEnabled = ref(
|
|
17
14
|
cookieCookiesEnabledIds === void 0 ? void 0 : [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dargmuesli/nuxt-cookie-control",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0",
|
|
4
4
|
"description": "Nuxt Cookies Control Module",
|
|
5
5
|
"author": "Dario Ferderber <dario.ferderber@broj42.com>",
|
|
6
6
|
"maintainers": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=16"
|
|
20
20
|
},
|
|
21
|
-
"packageManager": "pnpm@8.
|
|
21
|
+
"packageManager": "pnpm@8.6.1",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"import": "./dist/module.mjs",
|
|
@@ -39,30 +39,28 @@
|
|
|
39
39
|
"prepare": "husky install"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@nuxt/kit": "3.5.
|
|
42
|
+
"@nuxt/kit": "3.5.3",
|
|
43
43
|
"@sindresorhus/slugify": "2.2.1",
|
|
44
44
|
"css-vars-ponyfill": "2.4.8",
|
|
45
|
-
"js-cookie": "3.0.5",
|
|
46
45
|
"string-replace-loader": "3.1.0"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
|
-
"@commitlint/cli": "17.6.
|
|
50
|
-
"@commitlint/config-conventional": "17.6.
|
|
48
|
+
"@commitlint/cli": "17.6.5",
|
|
49
|
+
"@commitlint/config-conventional": "17.6.5",
|
|
51
50
|
"@dargmuesli/nuxt-cookie-control": "link:.",
|
|
52
|
-
"@nuxt/module-builder": "0.
|
|
51
|
+
"@nuxt/module-builder": "0.4.0",
|
|
53
52
|
"@nuxtjs/eslint-config-typescript": "12.0.0",
|
|
54
|
-
"
|
|
55
|
-
"eslint": "8.41.0",
|
|
53
|
+
"eslint": "8.42.0",
|
|
56
54
|
"eslint-config-prettier": "8.8.0",
|
|
57
55
|
"eslint-plugin-prettier": "4.2.1",
|
|
58
56
|
"husky": "8.0.3",
|
|
59
57
|
"lint-staged": "13.2.2",
|
|
60
|
-
"nuxt": "3.5.
|
|
58
|
+
"nuxt": "3.5.3",
|
|
61
59
|
"prettier": "2.8.8",
|
|
62
|
-
"typescript": "5.
|
|
60
|
+
"typescript": "5.1.3",
|
|
63
61
|
"vue": "3.3.4",
|
|
64
62
|
"vue-tsc": "1.6.5",
|
|
65
|
-
"webpack": "5.
|
|
63
|
+
"webpack": "5.86.0"
|
|
66
64
|
},
|
|
67
65
|
"publishConfig": {
|
|
68
66
|
"access": "public"
|