@tickboxhq/nuxt 0.0.1
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/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +15 -0
- package/dist/module.d.ts +15 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +45 -0
- package/dist/runtime/plugin.d.ts +0 -0
- package/dist/runtime/plugin.js +39 -0
- package/dist/types.d.mts +7 -0
- package/dist/types.d.ts +7 -0
- package/package.json +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tiny Systems Limited
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @tickboxhq/nuxt
|
|
2
|
+
|
|
3
|
+
Nuxt module for Tickbox. Wires up the Vue adapter, auto-imports `useConsent`, auto-registers `<ConsentBanner>`, and reads the consent cookie on the server so SSR'd pages reflect the visitor's choice.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tickboxhq/nuxt
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// nuxt.config.ts
|
|
13
|
+
export default defineNuxtConfig({
|
|
14
|
+
modules: ['@tickboxhq/nuxt'],
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// consent.config.ts (project root)
|
|
20
|
+
import { defineConsent, jurisdictions } from '@tickboxhq/core'
|
|
21
|
+
|
|
22
|
+
export default defineConsent({
|
|
23
|
+
jurisdiction: jurisdictions.UK_DUAA,
|
|
24
|
+
policy: { version: '2026-05-06', url: '/privacy' },
|
|
25
|
+
categories: {
|
|
26
|
+
necessary: { required: true },
|
|
27
|
+
analytics: { vendors: ['plausible', 'fathom'] },
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Use it
|
|
33
|
+
|
|
34
|
+
`useConsent` is auto-imported. `<ConsentBanner>` is auto-registered.
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
const { granted, grant, deny } = useConsent('analytics')
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<div>
|
|
43
|
+
<p v-if="granted">Analytics on</p>
|
|
44
|
+
<button @click="deny">Turn off</button>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Module options
|
|
50
|
+
|
|
51
|
+
| Option | Default | Description |
|
|
52
|
+
| --- | --- | --- |
|
|
53
|
+
| `configPath` | `'~/consent.config'` | Path to the consent config file (relative to project root or using `~` / `@` aliases) |
|
package/dist/module.cjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Path to the user's consent config file.
|
|
6
|
+
* The file must default-export a `ConsentConfig` (typically created via `defineConsent`).
|
|
7
|
+
*
|
|
8
|
+
* @default '~/consent.config'
|
|
9
|
+
*/
|
|
10
|
+
configPath?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const tickboxModule: NuxtModule<ModuleOptions>;
|
|
13
|
+
|
|
14
|
+
export { tickboxModule as default };
|
|
15
|
+
export type { ModuleOptions };
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Path to the user's consent config file.
|
|
6
|
+
* The file must default-export a `ConsentConfig` (typically created via `defineConsent`).
|
|
7
|
+
*
|
|
8
|
+
* @default '~/consent.config'
|
|
9
|
+
*/
|
|
10
|
+
configPath?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const tickboxModule: NuxtModule<ModuleOptions>;
|
|
13
|
+
|
|
14
|
+
export { tickboxModule as default };
|
|
15
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { defineNuxtModule, createResolver, resolveAlias, addTemplate, addPlugin, addImports, addComponent } from '@nuxt/kit';
|
|
2
|
+
|
|
3
|
+
const tickboxModule = defineNuxtModule({
|
|
4
|
+
meta: {
|
|
5
|
+
name: "@tickboxhq/nuxt",
|
|
6
|
+
configKey: "tickbox",
|
|
7
|
+
compatibility: {
|
|
8
|
+
nuxt: ">=3.0.0"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
defaults: {
|
|
12
|
+
configPath: "~/consent.config"
|
|
13
|
+
},
|
|
14
|
+
setup(options, nuxt) {
|
|
15
|
+
const resolver = createResolver(import.meta.url);
|
|
16
|
+
const aliases = {
|
|
17
|
+
"~": nuxt.options.srcDir,
|
|
18
|
+
"@": nuxt.options.srcDir,
|
|
19
|
+
"~~": nuxt.options.rootDir,
|
|
20
|
+
"@@": nuxt.options.rootDir
|
|
21
|
+
};
|
|
22
|
+
const resolvedConfigPath = resolveAlias(options.configPath ?? "~/consent.config", aliases);
|
|
23
|
+
addTemplate({
|
|
24
|
+
filename: "tickbox-config.mjs",
|
|
25
|
+
write: true,
|
|
26
|
+
getContents: () => `export { default } from ${JSON.stringify(resolvedConfigPath)}
|
|
27
|
+
`
|
|
28
|
+
});
|
|
29
|
+
nuxt.options.build.transpile.push("@tickboxhq/vue", "@tickboxhq/core");
|
|
30
|
+
addPlugin(resolver.resolve("./runtime/plugin"));
|
|
31
|
+
addImports([
|
|
32
|
+
{
|
|
33
|
+
name: "useConsent",
|
|
34
|
+
from: "@tickboxhq/vue"
|
|
35
|
+
}
|
|
36
|
+
]);
|
|
37
|
+
addComponent({
|
|
38
|
+
name: "ConsentBanner",
|
|
39
|
+
filePath: "@tickboxhq/vue",
|
|
40
|
+
export: "ConsentBanner"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export { tickboxModule as default };
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ConsentStore, applyConsent } from "@tickboxhq/core";
|
|
2
|
+
import { ConsentStoreKey } from "@tickboxhq/vue";
|
|
3
|
+
import { defineNuxtPlugin, useRequestHeaders } from "nuxt/app";
|
|
4
|
+
import userConfig from "#build/tickbox-config";
|
|
5
|
+
export default defineNuxtPlugin({
|
|
6
|
+
name: "tickbox",
|
|
7
|
+
enforce: "pre",
|
|
8
|
+
setup(nuxtApp) {
|
|
9
|
+
const config = userConfig?.default ?? userConfig;
|
|
10
|
+
if (!config || typeof config !== "object" || !("jurisdiction" in config)) {
|
|
11
|
+
console.error(
|
|
12
|
+
"[@tickboxhq/nuxt] Could not load consent config from `#tickbox-config`. Make sure your `consent.config.ts` default-exports a value created via `defineConsent()`."
|
|
13
|
+
);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (config.jurisdiction === "auto") {
|
|
17
|
+
console.warn(
|
|
18
|
+
'[@tickboxhq/nuxt] `jurisdiction: "auto"` is not yet supported by the Nuxt module. Set an explicit jurisdiction in your consent config for now.'
|
|
19
|
+
);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const store = new ConsentStore(config, {
|
|
23
|
+
jurisdiction: config.jurisdiction,
|
|
24
|
+
storage: config.storage,
|
|
25
|
+
applyEffects: true,
|
|
26
|
+
onApply: import.meta.client ? applyConsent : void 0
|
|
27
|
+
});
|
|
28
|
+
if (import.meta.server) {
|
|
29
|
+
const headers = useRequestHeaders(["cookie"]);
|
|
30
|
+
store.hydrateFromHeader(headers.cookie);
|
|
31
|
+
}
|
|
32
|
+
if (import.meta.client) {
|
|
33
|
+
nuxtApp.hook("app:mounted", () => {
|
|
34
|
+
store.hydrate();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
nuxtApp.vueApp.provide(ConsentStoreKey, store);
|
|
38
|
+
}
|
|
39
|
+
});
|
package/dist/types.d.mts
ADDED
package/dist/types.d.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tickboxhq/nuxt",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Nuxt 3/4 module for Tickbox consent management",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://tickbox.dev",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/tickboxhq/tickbox.git",
|
|
10
|
+
"directory": "packages/nuxt"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/module.cjs",
|
|
14
|
+
"module": "./dist/module.mjs",
|
|
15
|
+
"types": "./dist/types.d.mts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/types.d.mts",
|
|
19
|
+
"import": "./dist/module.mjs",
|
|
20
|
+
"require": "./dist/module.cjs"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@nuxt/kit": "^3.13.0",
|
|
32
|
+
"@tickboxhq/vue": "0.0.1",
|
|
33
|
+
"@tickboxhq/core": "0.0.1"
|
|
34
|
+
},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"nuxt": "^3.0.0 || ^4.0.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@nuxt/module-builder": "^0.8.4",
|
|
40
|
+
"@nuxt/schema": "^3.13.0",
|
|
41
|
+
"typescript": "^5.7.2"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "nuxt-module-build build",
|
|
45
|
+
"typecheck": "tsc --noEmit"
|
|
46
|
+
}
|
|
47
|
+
}
|