@veribenim/vue 1.0.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/index.d.mts +33 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +106 -0
- package/dist/index.mjs +80 -0
- package/package.json +46 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { VeribenimConfig, ConsentPreferences } from '@veribenim/core';
|
|
3
|
+
export { ConsentPreferences, VeribenimConfig } from '@veribenim/core';
|
|
4
|
+
|
|
5
|
+
interface VeribenimPluginState {
|
|
6
|
+
preferences: ConsentPreferences | null;
|
|
7
|
+
isConsented: boolean;
|
|
8
|
+
isLoaded: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Veribenim Vue 3 Plugin
|
|
12
|
+
*
|
|
13
|
+
* @example main.ts:
|
|
14
|
+
* import { createApp } from 'vue';
|
|
15
|
+
* import { VeribenimPlugin } from '@veribenim/vue';
|
|
16
|
+
*
|
|
17
|
+
* const app = createApp(App);
|
|
18
|
+
* app.use(VeribenimPlugin, { token: 'ENV_TOKEN' });
|
|
19
|
+
* app.mount('#app');
|
|
20
|
+
*
|
|
21
|
+
* @example Composable:
|
|
22
|
+
* import { useVeribenim } from '@veribenim/vue';
|
|
23
|
+
* const { preferences, accept, decline } = useVeribenim();
|
|
24
|
+
*/
|
|
25
|
+
declare const VeribenimPlugin: {
|
|
26
|
+
install(app: App, config: VeribenimConfig): void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Vue Composable
|
|
30
|
+
*/
|
|
31
|
+
declare function useVeribenim(): {};
|
|
32
|
+
|
|
33
|
+
export { VeribenimPlugin, type VeribenimPluginState, useVeribenim };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { VeribenimConfig, ConsentPreferences } from '@veribenim/core';
|
|
3
|
+
export { ConsentPreferences, VeribenimConfig } from '@veribenim/core';
|
|
4
|
+
|
|
5
|
+
interface VeribenimPluginState {
|
|
6
|
+
preferences: ConsentPreferences | null;
|
|
7
|
+
isConsented: boolean;
|
|
8
|
+
isLoaded: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Veribenim Vue 3 Plugin
|
|
12
|
+
*
|
|
13
|
+
* @example main.ts:
|
|
14
|
+
* import { createApp } from 'vue';
|
|
15
|
+
* import { VeribenimPlugin } from '@veribenim/vue';
|
|
16
|
+
*
|
|
17
|
+
* const app = createApp(App);
|
|
18
|
+
* app.use(VeribenimPlugin, { token: 'ENV_TOKEN' });
|
|
19
|
+
* app.mount('#app');
|
|
20
|
+
*
|
|
21
|
+
* @example Composable:
|
|
22
|
+
* import { useVeribenim } from '@veribenim/vue';
|
|
23
|
+
* const { preferences, accept, decline } = useVeribenim();
|
|
24
|
+
*/
|
|
25
|
+
declare const VeribenimPlugin: {
|
|
26
|
+
install(app: App, config: VeribenimConfig): void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Vue Composable
|
|
30
|
+
*/
|
|
31
|
+
declare function useVeribenim(): {};
|
|
32
|
+
|
|
33
|
+
export { VeribenimPlugin, type VeribenimPluginState, useVeribenim };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
VeribenimPlugin: () => VeribenimPlugin,
|
|
24
|
+
useVeribenim: () => useVeribenim
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
var import_vue = require("vue");
|
|
28
|
+
var import_core = require("@veribenim/core");
|
|
29
|
+
var INJECTION_KEY = /* @__PURE__ */ Symbol("veribenim");
|
|
30
|
+
var VeribenimPlugin = {
|
|
31
|
+
install(app, config) {
|
|
32
|
+
const preferences = (0, import_vue.ref)(null);
|
|
33
|
+
const isLoaded = (0, import_vue.ref)(false);
|
|
34
|
+
const client = new import_core.Veribenim(config, {
|
|
35
|
+
onAccept: (prefs) => {
|
|
36
|
+
preferences.value = prefs;
|
|
37
|
+
},
|
|
38
|
+
onDecline: (prefs) => {
|
|
39
|
+
preferences.value = prefs;
|
|
40
|
+
},
|
|
41
|
+
onChange: (prefs) => {
|
|
42
|
+
preferences.value = prefs;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
client.getPreferences().then((res) => {
|
|
46
|
+
if (res) preferences.value = res.preferences;
|
|
47
|
+
isLoaded.value = true;
|
|
48
|
+
});
|
|
49
|
+
const state = {
|
|
50
|
+
client,
|
|
51
|
+
preferences: (0, import_vue.readonly)(preferences),
|
|
52
|
+
isLoaded: (0, import_vue.readonly)(isLoaded),
|
|
53
|
+
get isConsented() {
|
|
54
|
+
return preferences.value !== null;
|
|
55
|
+
},
|
|
56
|
+
async accept(prefs) {
|
|
57
|
+
const fullPrefs = {
|
|
58
|
+
necessary: true,
|
|
59
|
+
analytics: true,
|
|
60
|
+
marketing: true,
|
|
61
|
+
preferences: true,
|
|
62
|
+
...prefs
|
|
63
|
+
};
|
|
64
|
+
const res = await client.savePreferences(fullPrefs);
|
|
65
|
+
if (res) {
|
|
66
|
+
preferences.value = res.preferences;
|
|
67
|
+
await client.logConsent({ action: "accept_all", preferences: fullPrefs });
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
async decline() {
|
|
71
|
+
const declined = {
|
|
72
|
+
necessary: true,
|
|
73
|
+
analytics: false,
|
|
74
|
+
marketing: false,
|
|
75
|
+
preferences: false
|
|
76
|
+
};
|
|
77
|
+
const res = await client.savePreferences(declined);
|
|
78
|
+
if (res) {
|
|
79
|
+
preferences.value = res.preferences;
|
|
80
|
+
await client.logConsent({ action: "reject_all", preferences: declined });
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
async savePreferences(prefs) {
|
|
84
|
+
const res = await client.savePreferences(prefs);
|
|
85
|
+
if (res) {
|
|
86
|
+
preferences.value = res.preferences;
|
|
87
|
+
await client.logConsent({ action: "save_preferences", preferences: prefs });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
app.provide(INJECTION_KEY, state);
|
|
92
|
+
app.config.globalProperties.$veribenim = state;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function useVeribenim() {
|
|
96
|
+
const state = (0, import_vue.inject)(INJECTION_KEY);
|
|
97
|
+
if (!state) {
|
|
98
|
+
throw new Error("[Veribenim] useVeribenim() \xE7a\u011Fr\u0131s\u0131 VeribenimPlugin kurulmadan yap\u0131ld\u0131");
|
|
99
|
+
}
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
102
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
+
0 && (module.exports = {
|
|
104
|
+
VeribenimPlugin,
|
|
105
|
+
useVeribenim
|
|
106
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { ref, readonly, inject } from "vue";
|
|
3
|
+
import { Veribenim } from "@veribenim/core";
|
|
4
|
+
var INJECTION_KEY = /* @__PURE__ */ Symbol("veribenim");
|
|
5
|
+
var VeribenimPlugin = {
|
|
6
|
+
install(app, config) {
|
|
7
|
+
const preferences = ref(null);
|
|
8
|
+
const isLoaded = ref(false);
|
|
9
|
+
const client = new Veribenim(config, {
|
|
10
|
+
onAccept: (prefs) => {
|
|
11
|
+
preferences.value = prefs;
|
|
12
|
+
},
|
|
13
|
+
onDecline: (prefs) => {
|
|
14
|
+
preferences.value = prefs;
|
|
15
|
+
},
|
|
16
|
+
onChange: (prefs) => {
|
|
17
|
+
preferences.value = prefs;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
client.getPreferences().then((res) => {
|
|
21
|
+
if (res) preferences.value = res.preferences;
|
|
22
|
+
isLoaded.value = true;
|
|
23
|
+
});
|
|
24
|
+
const state = {
|
|
25
|
+
client,
|
|
26
|
+
preferences: readonly(preferences),
|
|
27
|
+
isLoaded: readonly(isLoaded),
|
|
28
|
+
get isConsented() {
|
|
29
|
+
return preferences.value !== null;
|
|
30
|
+
},
|
|
31
|
+
async accept(prefs) {
|
|
32
|
+
const fullPrefs = {
|
|
33
|
+
necessary: true,
|
|
34
|
+
analytics: true,
|
|
35
|
+
marketing: true,
|
|
36
|
+
preferences: true,
|
|
37
|
+
...prefs
|
|
38
|
+
};
|
|
39
|
+
const res = await client.savePreferences(fullPrefs);
|
|
40
|
+
if (res) {
|
|
41
|
+
preferences.value = res.preferences;
|
|
42
|
+
await client.logConsent({ action: "accept_all", preferences: fullPrefs });
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async decline() {
|
|
46
|
+
const declined = {
|
|
47
|
+
necessary: true,
|
|
48
|
+
analytics: false,
|
|
49
|
+
marketing: false,
|
|
50
|
+
preferences: false
|
|
51
|
+
};
|
|
52
|
+
const res = await client.savePreferences(declined);
|
|
53
|
+
if (res) {
|
|
54
|
+
preferences.value = res.preferences;
|
|
55
|
+
await client.logConsent({ action: "reject_all", preferences: declined });
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
async savePreferences(prefs) {
|
|
59
|
+
const res = await client.savePreferences(prefs);
|
|
60
|
+
if (res) {
|
|
61
|
+
preferences.value = res.preferences;
|
|
62
|
+
await client.logConsent({ action: "save_preferences", preferences: prefs });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
app.provide(INJECTION_KEY, state);
|
|
67
|
+
app.config.globalProperties.$veribenim = state;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
function useVeribenim() {
|
|
71
|
+
const state = inject(INJECTION_KEY);
|
|
72
|
+
if (!state) {
|
|
73
|
+
throw new Error("[Veribenim] useVeribenim() \xE7a\u011Fr\u0131s\u0131 VeribenimPlugin kurulmadan yap\u0131ld\u0131");
|
|
74
|
+
}
|
|
75
|
+
return state;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
VeribenimPlugin,
|
|
79
|
+
useVeribenim
|
|
80
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@veribenim/vue",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Veribenim KVKK/GDPR çerez onayı SDK - Vue 3",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kvkk",
|
|
7
|
+
"gdpr",
|
|
8
|
+
"cookie",
|
|
9
|
+
"consent",
|
|
10
|
+
"veribenim",
|
|
11
|
+
"vue",
|
|
12
|
+
"vue3"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.mjs",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.mjs",
|
|
22
|
+
"require": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@veribenim/core": "1.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": ">=3.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@vue/runtime-core": "^3.0.0",
|
|
36
|
+
"tsup": "^8.0.0",
|
|
37
|
+
"typescript": "^5.4.0",
|
|
38
|
+
"vue": "^3.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
42
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
43
|
+
"lint": "tsc --noEmit",
|
|
44
|
+
"clean": "rm -rf dist"
|
|
45
|
+
}
|
|
46
|
+
}
|