@frigear-nu/cookie-consent 0.1.3 → 0.2.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 +1 -1
- package/dist/module.mjs +8 -1
- package/dist/runtime/app/components/CookieConsentBanner.vue +2 -0
- package/dist/runtime/app/components/CookieConsentBannerActions.vue +1 -0
- package/dist/runtime/app/components/CookieConsentManage.vue +1 -0
- package/dist/runtime/app/components/CookieConsentPreferences.vue +1 -0
- package/dist/runtime/app/composables/useConsentT.d.ts +2 -2
- package/dist/runtime/app/composables/useConsentT.js +1 -0
- package/dist/runtime/app/composables/useCookieConsent.d.ts +6 -6
- package/dist/runtime/app/composables/useCookieConsent.js +7 -1
- package/package.json +5 -5
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, hasNuxtModule, addImports, addServerImports, addComponentsDir } from '@nuxt/kit';
|
|
2
|
-
import { registerModule, registerTailwindSource, registerLocales, addModuleRoutes, extendDatabaseTable } from '@frigear-nu/module-kit/utils';
|
|
2
|
+
import { registerModule, registerTailwindSource, registerLocales, addOptionalImports, inlineModuleRuntime, addModuleRoutes, extendDatabaseTable } from '@frigear-nu/module-kit/utils';
|
|
3
3
|
import { mergeCategories, DEFAULT_CATEGORIES, computeVersion } from '../dist/runtime/utils/consent.js';
|
|
4
4
|
|
|
5
5
|
const DEFAULT_MAX_AGE = 60 * 60 * 24 * 180;
|
|
@@ -26,6 +26,12 @@ const module$1 = defineNuxtModule({
|
|
|
26
26
|
registerTailwindSource(nuxt, resolver.resolve("./runtime/app"));
|
|
27
27
|
registerLocales(nuxt, resolver.resolve("./runtime/i18n/lang"));
|
|
28
28
|
const persistToUser = (options.persistToUser ?? true) && hasNuxtModule("@frigear-nu/users");
|
|
29
|
+
addOptionalImports(nuxt, "#cookie-consent/optional", [{
|
|
30
|
+
name: "useUserSession",
|
|
31
|
+
available: () => hasNuxtModule("@frigear-nu/auth", nuxt),
|
|
32
|
+
fallback: `() => { throw new Error('[@frigear-nu/cookie-consent] \`persistToUser\` needs \`@frigear-nu/users\`') }`,
|
|
33
|
+
fallbackType: "() => { loggedIn: import('vue').Ref<boolean> }"
|
|
34
|
+
}]);
|
|
29
35
|
addImports([
|
|
30
36
|
{ name: "useCookieConsent", from: resolver.resolve("./runtime/app/composables/useCookieConsent") },
|
|
31
37
|
{ name: "onCookieConsent", from: resolver.resolve("./runtime/app/composables/useCookieConsent") },
|
|
@@ -35,6 +41,7 @@ const module$1 = defineNuxtModule({
|
|
|
35
41
|
{ name: "getCookieConsent", from: resolver.resolve("./runtime/server/utils/consent") },
|
|
36
42
|
{ name: "hasCookieConsent", from: resolver.resolve("./runtime/server/utils/consent") }
|
|
37
43
|
]);
|
|
44
|
+
inlineModuleRuntime(nuxt, resolver);
|
|
38
45
|
addComponentsDir({ path: resolver.resolve("./runtime/app/components"), priority: -1 });
|
|
39
46
|
if (persistToUser) {
|
|
40
47
|
addModuleRoutes(resolver, [
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useWindowScroll } from "@vueuse/core";
|
|
3
|
+
import { computed, onMounted, ref, useConsentT, useCookieConsent, useNuxtApp, useRoute, watch } from "#imports";
|
|
4
|
+
import { useUserSession } from "#cookie-consent/optional";
|
|
3
5
|
const { config, hasResponded, hydrateFromUser } = useCookieConsent();
|
|
4
6
|
const { t, policyUrl } = useConsentT();
|
|
5
7
|
const route = useRoute();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { ref, useConsentT, useCookieConsent, watch } from "#imports";
|
|
2
3
|
const { categories, consent, isPreferencesOpen, save, acceptAll, rejectAll } = useCookieConsent();
|
|
3
4
|
const { t, label, description, localize } = useConsentT();
|
|
4
5
|
const choices = ref({});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ConsentCategory, ConsentMessages, Translated } from '../../../types.js';
|
|
2
2
|
export declare function useConsentT(): {
|
|
3
|
-
locale:
|
|
3
|
+
locale: import("vue").ComputedRef<string>;
|
|
4
4
|
/** The policy link target for the current locale, if `policyUrl` is set. */
|
|
5
|
-
policyUrl:
|
|
5
|
+
policyUrl: import("vue").ComputedRef<string | undefined>;
|
|
6
6
|
/** The `policyLabel` option wins over the translated `policy` text. */
|
|
7
7
|
t: (key: keyof ConsentMessages) => any;
|
|
8
8
|
label: (category: ConsentCategory) => string;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { ConsentState } from '../../../types.js';
|
|
2
2
|
export declare function useCookieConsent(): {
|
|
3
|
-
config:
|
|
3
|
+
config: {};
|
|
4
4
|
categories: any;
|
|
5
|
-
consent:
|
|
6
|
-
hasResponded:
|
|
5
|
+
consent: import("vue").ComputedRef<ConsentState | null>;
|
|
6
|
+
hasResponded: import("vue").ComputedRef<boolean>;
|
|
7
7
|
isAllowed: (key: string) => boolean;
|
|
8
8
|
acceptAll: () => Promise<ConsentState>;
|
|
9
9
|
rejectAll: () => Promise<ConsentState>;
|
|
10
10
|
save: (choices: Record<string, boolean>) => Promise<ConsentState>;
|
|
11
11
|
reset: () => Promise<void>;
|
|
12
12
|
hydrateFromUser: () => Promise<void>;
|
|
13
|
-
isPreferencesOpen:
|
|
13
|
+
isPreferencesOpen: import("vue").Ref<boolean, boolean>;
|
|
14
14
|
openPreferences: () => void;
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
16
|
/**
|
|
17
17
|
* Runs `callback` once the visitor has granted `category` - immediately if they already did, or as
|
|
18
18
|
* soon as they do. The optional return value is called when consent is withdrawn.
|
|
19
19
|
*
|
|
20
20
|
* onCookieConsent("analytics", () => { startTracking(); return () => stopTracking() })
|
|
21
21
|
*/
|
|
22
|
-
export declare function onCookieConsent(category: string, callback: () => (() => void) | undefined):
|
|
22
|
+
export declare function onCookieConsent(category: string, callback: () => (() => void) | undefined): import("vue").WatchHandle;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { cookieConsentApi } from "../../utils/api.js";
|
|
2
2
|
import { acceptAllChoices, buildConsent, normalizeConsent, rejectAllChoices } from "../../utils/consent.js";
|
|
3
|
+
import { $fetch, computed, effectScope, getCurrentScope, onScopeDispose, useCookie, useNuxtApp, useRuntimeConfig, useState, watch } from "#imports";
|
|
4
|
+
import { useUserSession } from "#cookie-consent/optional";
|
|
3
5
|
const createCookieConsent = (nuxtApp) => {
|
|
4
6
|
const config = useRuntimeConfig().public.cookieConsent;
|
|
5
7
|
const cookie = useCookie(config.cookieName, {
|
|
@@ -66,7 +68,11 @@ export function useCookieConsent() {
|
|
|
66
68
|
const nuxtApp = useNuxtApp();
|
|
67
69
|
let instance = instances.get(nuxtApp);
|
|
68
70
|
if (!instance) {
|
|
69
|
-
|
|
71
|
+
let created;
|
|
72
|
+
nuxtApp.runWithContext(() => {
|
|
73
|
+
created = effectScope(true).run(() => createCookieConsent(nuxtApp));
|
|
74
|
+
});
|
|
75
|
+
instance = created;
|
|
70
76
|
instances.set(nuxtApp, instance);
|
|
71
77
|
}
|
|
72
78
|
return instance;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frigear-nu/cookie-consent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "GDPR cookie consent banner with categories - modules contribute categories (extendCookieConsent), apps gate scripts on consent, and the choice is stored as proof on the user.",
|
|
5
5
|
"homepage": "https://docs.frigear.dev/modules/cookie-consent",
|
|
6
6
|
"repository": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"playground"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@frigear-nu/module-kit": "1.
|
|
39
|
-
"@frigear-nu/ui": "0.
|
|
38
|
+
"@frigear-nu/module-kit": "1.2.0",
|
|
39
|
+
"@frigear-nu/ui": "0.2.0",
|
|
40
40
|
"@libsql/client": "^0.18.0",
|
|
41
41
|
"@nuxt/kit": "^4.6.1",
|
|
42
42
|
"@vueuse/core": "^15.0.0",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@frigear-nu/auth": "0.
|
|
69
|
-
"@frigear-nu/users": "1.
|
|
68
|
+
"@frigear-nu/auth": "0.2.0",
|
|
69
|
+
"@frigear-nu/users": "1.2.0",
|
|
70
70
|
"@nuxt/devtools": "^3.4.2",
|
|
71
71
|
"@nuxt/eslint-config": "^1.17.0",
|
|
72
72
|
"@nuxt/module-builder": "^1.0.3",
|