From d4b1abacb8001b6011084a5b01a58e2318deac77 Mon Sep 17 00:00:00 2001 From: Artur Bauer Date: Mon, 13 Nov 2023 19:54:09 +0100 Subject: [PATCH 1/3] update to vanilla cookie consent 3.0.0 --- package.json | 101 ++++++++++++++++++++++++++------------------------- src/main.ts | 25 +++++-------- 2 files changed, 60 insertions(+), 66 deletions(-) diff --git a/package.json b/package.json index 4df010f..37c9631 100644 --- a/package.json +++ b/package.json @@ -1,54 +1,55 @@ { - "name": "@jop-software/astro-cookieconsent", - "version": "2.0.0", - "description": "vanilla-cookieconsent for astro", - "type": "module", - "license": "GPL-3.0-or-later", - "types": "./dist/main.d.ts", - "keywords": [ - "astro-integration", - "astro-component", - "cookieconsent", - "consent", - "tracking", - "gdpr" - ], - "contributors": [ - { - "name": "Johannes Przymusinski", - "email": "johannes.przymusinski@jop-software.de", - "url": "https://jop-software.de" - } - ], - "exports": { - ".": { - "import": "./dist/astro-cookieconsent.es.js", - "require": "./dist/astro-cookieconsent.umd.js" - } + "name": "@jop-software/astro-cookieconsent", + "version": "3.0.0", + "description": "vanilla-cookieconsent for astro", + "type": "module", + "license": "GPL-3.0-or-later", + "types": "./dist/main.d.ts", + "keywords": [ + "astro-integration", + "astro-component", + "cookieconsent", + "consent", + "tracking", + "gdpr" + ], + "contributors": [ + { + "name": "Johannes Przymusinski", + "email": "johannes.przymusinski@jop-software.de", + "url": "https://jop-software.de" }, - "main": "./dist/astro-cookieconsent.umd.js", - "module": "./dist/astro-cookieconsent.es.js", - "files": [ - "dist" - ], - "scripts": { - "build": "vite build && tsc --emitDeclarationOnly", - "build:watch": "vite build --watch", - "dev": "vite", - "prettier:check": "prettier --check src", - "prettier:write": "prettier --write src" - }, - "devDependencies": { - "astro": "^1.8.0", - "prettier": "^2.7.1", - "typescript": "^4.9.4", - "vite": "^4.0.3" - }, - "repository": { - "type": "git", - "url": "https://github.com/jop-software/astro-cookieconsent" - }, - "peerDependencies": { - "vanilla-cookieconsent": "^2.9.1" + { + "name": "Artur Bauer" + } + ], + "exports": { + ".": { + "import": "./dist/astro-cookieconsent.es.js", + "require": "./dist/astro-cookieconsent.umd.js" } + }, + "main": "./dist/astro-cookieconsent.umd.js", + "module": "./dist/astro-cookieconsent.es.js", + "files": ["dist"], + "scripts": { + "build": "vite build && tsc --emitDeclarationOnly", + "build:watch": "vite build --watch", + "dev": "vite", + "prettier:check": "prettier --check src", + "prettier:write": "prettier --write src" + }, + "devDependencies": { + "astro": "^1.8.0", + "prettier": "^2.7.1", + "typescript": "^4.9.4", + "vite": "^4.0.3" + }, + "repository": { + "type": "git", + "url": "https://github.com/jop-software/astro-cookieconsent" + }, + "peerDependencies": { + "vanilla-cookieconsent": "^3.0.0" + } } diff --git a/src/main.ts b/src/main.ts index 892bbe2..51423e8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,27 +1,20 @@ -import * as CookieConsent from "vanilla-cookieconsent"; +import { type AstroIntegration } from 'astro'; +import { type CookieConsentConfig } from 'vanilla-cookieconsent'; -const createPlugin = (config: UserConfig) => { +const createPlugin = (config: CookieConsentConfig): AstroIntegration => { return { - name: "@jop-software/astro-cookieconsent", + name: '@jop-software/astro-cookieconsent', hooks: { - "astro:config:setup": async ({ injectScript }: any) => { + 'astro:config:setup': async ({ injectScript }) => { injectScript( - "page", - "import 'vanilla-cookieconsent';" + 'page', + "import * as CookieConsent 'vanilla-cookieconsent';" ); injectScript( - "page-ssr", + 'page-ssr', "import 'vanilla-cookieconsent/dist/cookieconsent.css';" ); - injectScript( - "page", - `window.cookieConsentConfiguration = ${JSON.stringify(config)}` - ); - injectScript("page", `window.cookieConsent = initCookieConsent();`); - injectScript( - "page", - `window.cookieConsent.run(window.cookieConsentConfiguration);` - ); + injectScript('page', `cookieConsent.run(${JSON.stringify(config)});`); }, }, }; From 2130d11fe3dbd0f10657d4235516894d2e989f83 Mon Sep 17 00:00:00 2001 From: Artur Bauer Date: Mon, 15 Jan 2024 17:49:46 +0100 Subject: [PATCH 2/3] Update src/main.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: MichaƂ Kuczaj <37776903+mikucz@users.noreply.github.com> --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 51423e8..9736a77 100644 --- a/src/main.ts +++ b/src/main.ts @@ -8,7 +8,7 @@ const createPlugin = (config: CookieConsentConfig): AstroIntegration => { 'astro:config:setup': async ({ injectScript }) => { injectScript( 'page', - "import * as CookieConsent 'vanilla-cookieconsent';" + "import * as cookieConsent from 'vanilla-cookieconsent';" ); injectScript( 'page-ssr', From 2692244c3bcffeae149b1253ab2be06f7de0f138 Mon Sep 17 00:00:00 2001 From: Johannes Przymusinski Date: Mon, 5 Feb 2024 20:42:59 +0100 Subject: [PATCH 3/3] chore: code formatting and type export fix --- package.json | 6 ++++-- src/main.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 37c9631..c19dcd8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@jop-software/astro-cookieconsent", - "version": "3.0.0", + "version": "2.0.0", "description": "vanilla-cookieconsent for astro", "type": "module", "license": "GPL-3.0-or-later", @@ -31,7 +31,9 @@ }, "main": "./dist/astro-cookieconsent.umd.js", "module": "./dist/astro-cookieconsent.es.js", - "files": ["dist"], + "files": [ + "dist" + ], "scripts": { "build": "vite build && tsc --emitDeclarationOnly", "build:watch": "vite build --watch", diff --git a/src/main.ts b/src/main.ts index 9736a77..aa18466 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,25 +1,25 @@ -import { type AstroIntegration } from 'astro'; -import { type CookieConsentConfig } from 'vanilla-cookieconsent'; +import { type AstroIntegration } from "astro"; +import { type CookieConsentConfig } from "vanilla-cookieconsent"; const createPlugin = (config: CookieConsentConfig): AstroIntegration => { return { - name: '@jop-software/astro-cookieconsent', + name: "@jop-software/astro-cookieconsent", hooks: { - 'astro:config:setup': async ({ injectScript }) => { + "astro:config:setup": async ({ injectScript }) => { injectScript( - 'page', + "page", "import * as cookieConsent from 'vanilla-cookieconsent';" ); injectScript( - 'page-ssr', + "page-ssr", "import 'vanilla-cookieconsent/dist/cookieconsent.css';" ); - injectScript('page', `cookieConsent.run(${JSON.stringify(config)});`); + injectScript("page", `cookieConsent.run(${JSON.stringify(config)});`); }, }, }; }; -export type { CookieConsent }; +export type { CookieConsentConfig }; export default createPlugin;