@preprio/toolkit 0.2.0-beta.6 → 0.2.0-beta.9
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/README.md +237 -471
- package/dist/astro/index.cjs +20 -6
- package/dist/astro/index.d.cts +1 -1
- package/dist/astro/index.d.ts +1 -1
- package/dist/astro/index.js +20 -6
- package/dist/{chunk-C6YEXA5G.js → chunk-JVUG6S4O.js} +42 -47
- package/dist/index.cjs +58 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -6
- package/dist/nextjs/components.cjs +45 -48
- package/dist/nextjs/components.js +5 -3
- package/dist/nextjs/image-loader.cjs +7 -2
- package/dist/nextjs/image-loader.d.cts +1 -1
- package/dist/nextjs/image-loader.d.ts +1 -1
- package/dist/nextjs/image-loader.js +7 -2
- package/dist/nextjs/index.cjs +31 -9
- package/dist/nextjs/index.d.cts +99 -2
- package/dist/nextjs/index.d.ts +99 -2
- package/dist/nextjs/index.js +31 -9
- package/dist/nuxt/index.cjs +20 -6
- package/dist/nuxt/index.js +20 -6
- package/dist/react/components.cjs +42 -47
- package/dist/react/components.js +42 -47
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/sveltekit/index.cjs +20 -6
- package/dist/sveltekit/index.js +20 -6
- package/package.json +14 -14
package/dist/sveltekit/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.2.0-beta.
|
|
2
|
+
var VERSION = "0.2.0-beta.9";
|
|
3
3
|
|
|
4
4
|
// src/core/constants.ts
|
|
5
5
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -67,7 +67,11 @@ function parseCookies(request) {
|
|
|
67
67
|
const name = part.slice(0, eq).trim();
|
|
68
68
|
const value = part.slice(eq + 1).trim();
|
|
69
69
|
if (!name) continue;
|
|
70
|
-
|
|
70
|
+
try {
|
|
71
|
+
cookies.set(name, decodeURIComponent(value));
|
|
72
|
+
} catch {
|
|
73
|
+
cookies.set(name, value);
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
return cookies;
|
|
73
77
|
}
|
|
@@ -106,7 +110,10 @@ function processPreprRequest(request, opts) {
|
|
|
106
110
|
if (userAgent) {
|
|
107
111
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
108
112
|
}
|
|
109
|
-
requestHeaders.set(
|
|
113
|
+
requestHeaders.set(
|
|
114
|
+
"Prepr-Package",
|
|
115
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
116
|
+
);
|
|
110
117
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
111
118
|
if (ip) {
|
|
112
119
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -115,7 +122,7 @@ function processPreprRequest(request, opts) {
|
|
|
115
122
|
if (hutkCookie) {
|
|
116
123
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
117
124
|
}
|
|
118
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
125
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
119
126
|
if (!uid) {
|
|
120
127
|
uid = crypto.randomUUID();
|
|
121
128
|
responseCookies.push({
|
|
@@ -193,7 +200,10 @@ function processPreprRequest(request, opts) {
|
|
|
193
200
|
var PREPR_LOCALS_KEY = "prepr";
|
|
194
201
|
function preprHandle(options) {
|
|
195
202
|
return async ({ event, resolve }) => {
|
|
196
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
203
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
204
|
+
event.request,
|
|
205
|
+
options
|
|
206
|
+
);
|
|
197
207
|
requestHeaders.forEach((value, key) => {
|
|
198
208
|
event.request.headers.set(key, value);
|
|
199
209
|
});
|
|
@@ -262,7 +272,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
262
272
|
}
|
|
263
273
|
function validatePreprToken(token) {
|
|
264
274
|
if (!token) {
|
|
265
|
-
throw new PreprError(
|
|
275
|
+
throw new PreprError(
|
|
276
|
+
"Token is required",
|
|
277
|
+
"MISSING_TOKEN",
|
|
278
|
+
"validatePreprToken"
|
|
279
|
+
);
|
|
266
280
|
}
|
|
267
281
|
if (!token.startsWith("https://")) {
|
|
268
282
|
throw new PreprError(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preprio/toolkit",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.9",
|
|
4
4
|
"description": "Prepr personalization, A/B testing and preview toolkit for React, Next.js, Nuxt, Astro, SvelteKit and Express",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Prepr B.V. (https://prepr.io)",
|
|
@@ -94,6 +94,16 @@
|
|
|
94
94
|
"src/sveltekit/*.svelte",
|
|
95
95
|
"src/nuxt/*.vue"
|
|
96
96
|
],
|
|
97
|
+
"scripts": {
|
|
98
|
+
"gen:css": "node scripts/compile-css.mjs",
|
|
99
|
+
"prebuild": "rm -rf dist && pnpm gen:css && node scripts/check-version.mjs",
|
|
100
|
+
"pretest": "pnpm gen:css",
|
|
101
|
+
"pretypecheck": "pnpm gen:css",
|
|
102
|
+
"build": "tsup",
|
|
103
|
+
"postbuild": "node scripts/check-exports.mjs",
|
|
104
|
+
"test": "vitest run",
|
|
105
|
+
"typecheck": "tsc --noEmit"
|
|
106
|
+
},
|
|
97
107
|
"dependencies": {
|
|
98
108
|
"@vercel/stega": "^1.1.0",
|
|
99
109
|
"preact": "^10.29.7"
|
|
@@ -102,8 +112,8 @@
|
|
|
102
112
|
"next": ">=13",
|
|
103
113
|
"react": ">=17",
|
|
104
114
|
"react-dom": ">=17",
|
|
105
|
-
"svelte": ">=
|
|
106
|
-
"vue": ">=3"
|
|
115
|
+
"svelte": ">=5",
|
|
116
|
+
"vue": ">=3.3"
|
|
107
117
|
},
|
|
108
118
|
"peerDependenciesMeta": {
|
|
109
119
|
"next": {
|
|
@@ -135,15 +145,5 @@
|
|
|
135
145
|
"tsup": "^8.5.1",
|
|
136
146
|
"typescript": "^5.9.3",
|
|
137
147
|
"vitest": "^4.1.10"
|
|
138
|
-
},
|
|
139
|
-
"scripts": {
|
|
140
|
-
"gen:css": "node scripts/compile-css.mjs",
|
|
141
|
-
"prebuild": "rm -rf dist && pnpm gen:css && node scripts/check-version.mjs",
|
|
142
|
-
"pretest": "pnpm gen:css",
|
|
143
|
-
"pretypecheck": "pnpm gen:css",
|
|
144
|
-
"build": "tsup",
|
|
145
|
-
"postbuild": "node scripts/check-exports.mjs",
|
|
146
|
-
"test": "vitest run",
|
|
147
|
-
"typecheck": "tsc --noEmit"
|
|
148
148
|
}
|
|
149
|
-
}
|
|
149
|
+
}
|