@preprio/toolkit 0.4.0 → 0.4.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/dist/astro/index.cjs +13 -8
- package/dist/astro/index.js +13 -8
- package/dist/{chunk-XFRVWN3C.js → chunk-FP5XYD6J.js} +1 -1
- package/dist/index.cjs +12 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +12 -5
- package/dist/nextjs/components.cjs +1 -1
- package/dist/nextjs/components.js +1 -1
- package/dist/nextjs/index.cjs +13 -8
- package/dist/nextjs/index.js +13 -8
- package/dist/nuxt/index.cjs +13 -8
- package/dist/nuxt/index.js +13 -8
- package/dist/react/components.cjs +1 -1
- package/dist/react/components.js +1 -1
- package/dist/sveltekit/index.cjs +13 -8
- package/dist/sveltekit/index.js +13 -8
- package/package.json +1 -1
package/dist/astro/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(astro_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(astro_exports);
|
|
31
31
|
|
|
32
32
|
// src/version.ts
|
|
33
|
-
var VERSION = "0.4.
|
|
33
|
+
var VERSION = "0.4.1";
|
|
34
34
|
|
|
35
35
|
// src/core/features.ts
|
|
36
36
|
function isEnabled(config) {
|
|
@@ -120,6 +120,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
120
120
|
try {
|
|
121
121
|
const response = await fetch(token, {
|
|
122
122
|
headers: {
|
|
123
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
124
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
125
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
126
|
+
// still identify the toolbar by that string.
|
|
123
127
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
124
128
|
"Content-Type": "application/json"
|
|
125
129
|
},
|
|
@@ -235,7 +239,7 @@ function parseCookies(request) {
|
|
|
235
239
|
}
|
|
236
240
|
return cookies;
|
|
237
241
|
}
|
|
238
|
-
function
|
|
242
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
239
243
|
const requestHeaders = new Headers(request.headers);
|
|
240
244
|
const responseCookies = [];
|
|
241
245
|
const inboundPreprHeaders = [];
|
|
@@ -270,10 +274,10 @@ function processPreprRequest(request, opts) {
|
|
|
270
274
|
if (userAgent) {
|
|
271
275
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
272
276
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
);
|
|
277
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
278
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
279
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
280
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
277
281
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
278
282
|
if (ip) {
|
|
279
283
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -358,9 +362,10 @@ function processPreprRequest(request, opts) {
|
|
|
358
362
|
|
|
359
363
|
// src/astro/index.ts
|
|
360
364
|
async function onPreprRequest(context, next, options) {
|
|
361
|
-
const { requestHeaders, responseCookies } =
|
|
365
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
362
366
|
context.request,
|
|
363
|
-
options
|
|
367
|
+
options,
|
|
368
|
+
"astro"
|
|
364
369
|
);
|
|
365
370
|
requestHeaders.forEach((value, key) => {
|
|
366
371
|
context.request.headers.set(key, value);
|
package/dist/astro/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.4.
|
|
2
|
+
var VERSION = "0.4.1";
|
|
3
3
|
|
|
4
4
|
// src/core/features.ts
|
|
5
5
|
function isEnabled(config) {
|
|
@@ -89,6 +89,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
89
89
|
try {
|
|
90
90
|
const response = await fetch(token, {
|
|
91
91
|
headers: {
|
|
92
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
93
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
94
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
95
|
+
// still identify the toolbar by that string.
|
|
92
96
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
93
97
|
"Content-Type": "application/json"
|
|
94
98
|
},
|
|
@@ -204,7 +208,7 @@ function parseCookies(request) {
|
|
|
204
208
|
}
|
|
205
209
|
return cookies;
|
|
206
210
|
}
|
|
207
|
-
function
|
|
211
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
208
212
|
const requestHeaders = new Headers(request.headers);
|
|
209
213
|
const responseCookies = [];
|
|
210
214
|
const inboundPreprHeaders = [];
|
|
@@ -239,10 +243,10 @@ function processPreprRequest(request, opts) {
|
|
|
239
243
|
if (userAgent) {
|
|
240
244
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
241
245
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
);
|
|
246
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
247
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
248
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
249
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
246
250
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
247
251
|
if (ip) {
|
|
248
252
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -327,9 +331,10 @@ function processPreprRequest(request, opts) {
|
|
|
327
331
|
|
|
328
332
|
// src/astro/index.ts
|
|
329
333
|
async function onPreprRequest(context, next, options) {
|
|
330
|
-
const { requestHeaders, responseCookies } =
|
|
334
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
331
335
|
context.request,
|
|
332
|
-
options
|
|
336
|
+
options,
|
|
337
|
+
"astro"
|
|
333
338
|
);
|
|
334
339
|
requestHeaders.forEach((value, key) => {
|
|
335
340
|
context.request.headers.set(key, value);
|
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ __export(src_exports, {
|
|
|
44
44
|
module.exports = __toCommonJS(src_exports);
|
|
45
45
|
|
|
46
46
|
// src/version.ts
|
|
47
|
-
var VERSION = "0.4.
|
|
47
|
+
var VERSION = "0.4.1";
|
|
48
48
|
|
|
49
49
|
// src/core/features.ts
|
|
50
50
|
function isEnabled(config) {
|
|
@@ -2386,6 +2386,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
2386
2386
|
try {
|
|
2387
2387
|
const response = await fetch(token, {
|
|
2388
2388
|
headers: {
|
|
2389
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
2390
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
2391
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
2392
|
+
// still identify the toolbar by that string.
|
|
2389
2393
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
2390
2394
|
"Content-Type": "application/json"
|
|
2391
2395
|
},
|
|
@@ -2477,6 +2481,9 @@ function parseCookies(request) {
|
|
|
2477
2481
|
return cookies;
|
|
2478
2482
|
}
|
|
2479
2483
|
function processPreprRequest(request, opts) {
|
|
2484
|
+
return processFrameworkRequest(request, opts);
|
|
2485
|
+
}
|
|
2486
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
2480
2487
|
const requestHeaders = new Headers(request.headers);
|
|
2481
2488
|
const responseCookies = [];
|
|
2482
2489
|
const inboundPreprHeaders = [];
|
|
@@ -2511,10 +2518,10 @@ function processPreprRequest(request, opts) {
|
|
|
2511
2518
|
if (userAgent) {
|
|
2512
2519
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
2513
2520
|
}
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
);
|
|
2521
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
2522
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
2523
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
2524
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
2518
2525
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
2519
2526
|
if (ip) {
|
|
2520
2527
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
package/dist/index.d.cts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "0.4.
|
|
8
|
+
declare const VERSION = "0.4.1";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { g as PreprEnvironment, h as PreprEventType, i as PreprFeatureConfig, j
|
|
|
5
5
|
* Package version; must match package.json. Lives in its own leaf module so
|
|
6
6
|
* core can import it without cycling through the barrel.
|
|
7
7
|
*/
|
|
8
|
-
declare const VERSION = "0.4.
|
|
8
|
+
declare const VERSION = "0.4.1";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
setTrackingParam,
|
|
19
19
|
stegaClean,
|
|
20
20
|
trackEvent
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-FP5XYD6J.js";
|
|
22
22
|
|
|
23
23
|
// src/core/server.ts
|
|
24
24
|
var PreprError = class extends Error {
|
|
@@ -120,6 +120,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
120
120
|
try {
|
|
121
121
|
const response = await fetch(token, {
|
|
122
122
|
headers: {
|
|
123
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
124
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
125
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
126
|
+
// still identify the toolbar by that string.
|
|
123
127
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
124
128
|
"Content-Type": "application/json"
|
|
125
129
|
},
|
|
@@ -211,6 +215,9 @@ function parseCookies(request) {
|
|
|
211
215
|
return cookies;
|
|
212
216
|
}
|
|
213
217
|
function processPreprRequest(request, opts) {
|
|
218
|
+
return processFrameworkRequest(request, opts);
|
|
219
|
+
}
|
|
220
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
214
221
|
const requestHeaders = new Headers(request.headers);
|
|
215
222
|
const responseCookies = [];
|
|
216
223
|
const inboundPreprHeaders = [];
|
|
@@ -245,10 +252,10 @@ function processPreprRequest(request, opts) {
|
|
|
245
252
|
if (userAgent) {
|
|
246
253
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
247
254
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
);
|
|
255
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
256
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
257
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
258
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
252
259
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
253
260
|
if (ip) {
|
|
254
261
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -2266,7 +2266,7 @@ function createPreprPreview(opts = {}) {
|
|
|
2266
2266
|
var import_react = require("react");
|
|
2267
2267
|
|
|
2268
2268
|
// src/version.ts
|
|
2269
|
-
var VERSION = "0.4.
|
|
2269
|
+
var VERSION = "0.4.1";
|
|
2270
2270
|
|
|
2271
2271
|
// src/core/pixel.ts
|
|
2272
2272
|
var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
|
package/dist/nextjs/index.cjs
CHANGED
|
@@ -38,7 +38,7 @@ module.exports = __toCommonJS(nextjs_exports);
|
|
|
38
38
|
var import_server = require("next/server");
|
|
39
39
|
|
|
40
40
|
// src/version.ts
|
|
41
|
-
var VERSION = "0.4.
|
|
41
|
+
var VERSION = "0.4.1";
|
|
42
42
|
|
|
43
43
|
// src/core/constants.ts
|
|
44
44
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -100,7 +100,7 @@ function parseCookies(request) {
|
|
|
100
100
|
}
|
|
101
101
|
return cookies;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
104
104
|
const requestHeaders = new Headers(request.headers);
|
|
105
105
|
const responseCookies = [];
|
|
106
106
|
const inboundPreprHeaders = [];
|
|
@@ -135,10 +135,10 @@ function processPreprRequest(request, opts) {
|
|
|
135
135
|
if (userAgent) {
|
|
136
136
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
);
|
|
138
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
139
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
140
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
141
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
142
142
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
143
143
|
if (ip) {
|
|
144
144
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -231,9 +231,10 @@ function createPreprMiddleware(request, responseOrOptions, maybeOptions) {
|
|
|
231
231
|
} else {
|
|
232
232
|
options = responseOrOptions;
|
|
233
233
|
}
|
|
234
|
-
const { requestHeaders, responseCookies } =
|
|
234
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
235
235
|
request,
|
|
236
|
-
options
|
|
236
|
+
options,
|
|
237
|
+
"nextjs"
|
|
237
238
|
);
|
|
238
239
|
const response = chainedResponse ?? import_server.NextResponse.next({ request: { headers: requestHeaders } });
|
|
239
240
|
if (chainedResponse) {
|
|
@@ -364,6 +365,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
364
365
|
try {
|
|
365
366
|
const response = await fetch(token, {
|
|
366
367
|
headers: {
|
|
368
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
369
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
370
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
371
|
+
// still identify the toolbar by that string.
|
|
367
372
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
368
373
|
"Content-Type": "application/json"
|
|
369
374
|
},
|
package/dist/nextjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { NextResponse } from "next/server";
|
|
3
3
|
|
|
4
4
|
// src/version.ts
|
|
5
|
-
var VERSION = "0.4.
|
|
5
|
+
var VERSION = "0.4.1";
|
|
6
6
|
|
|
7
7
|
// src/core/constants.ts
|
|
8
8
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -64,7 +64,7 @@ function parseCookies(request) {
|
|
|
64
64
|
}
|
|
65
65
|
return cookies;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
68
68
|
const requestHeaders = new Headers(request.headers);
|
|
69
69
|
const responseCookies = [];
|
|
70
70
|
const inboundPreprHeaders = [];
|
|
@@ -99,10 +99,10 @@ function processPreprRequest(request, opts) {
|
|
|
99
99
|
if (userAgent) {
|
|
100
100
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
101
101
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
);
|
|
102
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
103
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
104
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
105
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
106
106
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
107
107
|
if (ip) {
|
|
108
108
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -195,9 +195,10 @@ function createPreprMiddleware(request, responseOrOptions, maybeOptions) {
|
|
|
195
195
|
} else {
|
|
196
196
|
options = responseOrOptions;
|
|
197
197
|
}
|
|
198
|
-
const { requestHeaders, responseCookies } =
|
|
198
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
199
199
|
request,
|
|
200
|
-
options
|
|
200
|
+
options,
|
|
201
|
+
"nextjs"
|
|
201
202
|
);
|
|
202
203
|
const response = chainedResponse ?? NextResponse.next({ request: { headers: requestHeaders } });
|
|
203
204
|
if (chainedResponse) {
|
|
@@ -328,6 +329,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
328
329
|
try {
|
|
329
330
|
const response = await fetch(token, {
|
|
330
331
|
headers: {
|
|
332
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
333
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
334
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
335
|
+
// still identify the toolbar by that string.
|
|
331
336
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
332
337
|
"Content-Type": "application/json"
|
|
333
338
|
},
|
package/dist/nuxt/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(nuxt_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(nuxt_exports);
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = "0.4.
|
|
38
|
+
var VERSION = "0.4.1";
|
|
39
39
|
|
|
40
40
|
// src/core/constants.ts
|
|
41
41
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -111,7 +111,7 @@ function parseCookies(request) {
|
|
|
111
111
|
}
|
|
112
112
|
return cookies;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
115
115
|
const requestHeaders = new Headers(request.headers);
|
|
116
116
|
const responseCookies = [];
|
|
117
117
|
const inboundPreprHeaders = [];
|
|
@@ -146,10 +146,10 @@ function processPreprRequest(request, opts) {
|
|
|
146
146
|
if (userAgent) {
|
|
147
147
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
149
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
150
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
151
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
152
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
153
153
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
154
154
|
if (ip) {
|
|
155
155
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -245,9 +245,10 @@ function handlePreprRequest(event, options) {
|
|
|
245
245
|
request.headers.set(key, value.join(", "));
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
const { requestHeaders, responseCookies } =
|
|
248
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
249
249
|
request,
|
|
250
|
-
options
|
|
250
|
+
options,
|
|
251
|
+
"nuxt"
|
|
251
252
|
);
|
|
252
253
|
requestHeaders.forEach((value, key) => {
|
|
253
254
|
req.headers[key.toLowerCase()] = value;
|
|
@@ -362,6 +363,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
362
363
|
try {
|
|
363
364
|
const response = await fetch(token, {
|
|
364
365
|
headers: {
|
|
366
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
367
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
368
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
369
|
+
// still identify the toolbar by that string.
|
|
365
370
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
366
371
|
"Content-Type": "application/json"
|
|
367
372
|
},
|
package/dist/nuxt/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.4.
|
|
2
|
+
var VERSION = "0.4.1";
|
|
3
3
|
|
|
4
4
|
// src/core/constants.ts
|
|
5
5
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -75,7 +75,7 @@ function parseCookies(request) {
|
|
|
75
75
|
}
|
|
76
76
|
return cookies;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
79
79
|
const requestHeaders = new Headers(request.headers);
|
|
80
80
|
const responseCookies = [];
|
|
81
81
|
const inboundPreprHeaders = [];
|
|
@@ -110,10 +110,10 @@ function processPreprRequest(request, opts) {
|
|
|
110
110
|
if (userAgent) {
|
|
111
111
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
113
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
114
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
115
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
116
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
117
117
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
118
118
|
if (ip) {
|
|
119
119
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -209,9 +209,10 @@ function handlePreprRequest(event, options) {
|
|
|
209
209
|
request.headers.set(key, value.join(", "));
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
const { requestHeaders, responseCookies } =
|
|
212
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
213
213
|
request,
|
|
214
|
-
options
|
|
214
|
+
options,
|
|
215
|
+
"nuxt"
|
|
215
216
|
);
|
|
216
217
|
requestHeaders.forEach((value, key) => {
|
|
217
218
|
req.headers[key.toLowerCase()] = value;
|
|
@@ -326,6 +327,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
326
327
|
try {
|
|
327
328
|
const response = await fetch(token, {
|
|
328
329
|
headers: {
|
|
330
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
331
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
332
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
333
|
+
// still identify the toolbar by that string.
|
|
329
334
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
330
335
|
"Content-Type": "application/json"
|
|
331
336
|
},
|
package/dist/react/components.js
CHANGED
package/dist/sveltekit/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ __export(sveltekit_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(sveltekit_exports);
|
|
36
36
|
|
|
37
37
|
// src/version.ts
|
|
38
|
-
var VERSION = "0.4.
|
|
38
|
+
var VERSION = "0.4.1";
|
|
39
39
|
|
|
40
40
|
// src/core/constants.ts
|
|
41
41
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -111,7 +111,7 @@ function parseCookies(request) {
|
|
|
111
111
|
}
|
|
112
112
|
return cookies;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
115
115
|
const requestHeaders = new Headers(request.headers);
|
|
116
116
|
const responseCookies = [];
|
|
117
117
|
const inboundPreprHeaders = [];
|
|
@@ -146,10 +146,10 @@ function processPreprRequest(request, opts) {
|
|
|
146
146
|
if (userAgent) {
|
|
147
147
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
);
|
|
149
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
150
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
151
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
152
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
153
153
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
154
154
|
if (ip) {
|
|
155
155
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -236,9 +236,10 @@ function processPreprRequest(request, opts) {
|
|
|
236
236
|
var PREPR_LOCALS_KEY = "prepr";
|
|
237
237
|
function preprHandle(options) {
|
|
238
238
|
return async ({ event, resolve }) => {
|
|
239
|
-
const { requestHeaders, responseCookies } =
|
|
239
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
240
240
|
event.request,
|
|
241
|
-
options
|
|
241
|
+
options,
|
|
242
|
+
"sveltekit"
|
|
242
243
|
);
|
|
243
244
|
requestHeaders.forEach((value, key) => {
|
|
244
245
|
event.request.headers.set(key, value);
|
|
@@ -358,6 +359,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
358
359
|
try {
|
|
359
360
|
const response = await fetch(token, {
|
|
360
361
|
headers: {
|
|
362
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
363
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
364
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
365
|
+
// still identify the toolbar by that string.
|
|
361
366
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
362
367
|
"Content-Type": "application/json"
|
|
363
368
|
},
|
package/dist/sveltekit/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.4.
|
|
2
|
+
var VERSION = "0.4.1";
|
|
3
3
|
|
|
4
4
|
// src/core/constants.ts
|
|
5
5
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -75,7 +75,7 @@ function parseCookies(request) {
|
|
|
75
75
|
}
|
|
76
76
|
return cookies;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function processFrameworkRequest(request, opts, framework) {
|
|
79
79
|
const requestHeaders = new Headers(request.headers);
|
|
80
80
|
const responseCookies = [];
|
|
81
81
|
const inboundPreprHeaders = [];
|
|
@@ -110,10 +110,10 @@ function processPreprRequest(request, opts) {
|
|
|
110
110
|
if (userAgent) {
|
|
111
111
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
113
|
+
const packageParts = [`@preprio/toolkit@${opts?.version ?? VERSION}`];
|
|
114
|
+
if (framework) packageParts.push(`framework=${framework}`);
|
|
115
|
+
packageParts.push(`preview=${opts?.preview ? "true" : "false"}`);
|
|
116
|
+
requestHeaders.set("Prepr-Package", packageParts.join("; "));
|
|
117
117
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
118
118
|
if (ip) {
|
|
119
119
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -200,9 +200,10 @@ function processPreprRequest(request, opts) {
|
|
|
200
200
|
var PREPR_LOCALS_KEY = "prepr";
|
|
201
201
|
function preprHandle(options) {
|
|
202
202
|
return async ({ event, resolve }) => {
|
|
203
|
-
const { requestHeaders, responseCookies } =
|
|
203
|
+
const { requestHeaders, responseCookies } = processFrameworkRequest(
|
|
204
204
|
event.request,
|
|
205
|
-
options
|
|
205
|
+
options,
|
|
206
|
+
"sveltekit"
|
|
206
207
|
);
|
|
207
208
|
requestHeaders.forEach((value, key) => {
|
|
208
209
|
event.request.headers.set(key, value);
|
|
@@ -322,6 +323,10 @@ async function getPreprEnvironmentSegments(token) {
|
|
|
322
323
|
try {
|
|
323
324
|
const response = await fetch(token, {
|
|
324
325
|
headers: {
|
|
326
|
+
"Prepr-Package": `@preprio/toolkit@${VERSION}`,
|
|
327
|
+
// Duplicates the version in Prepr-Package. It keeps the User-Agent
|
|
328
|
+
// format used by `@preprio/prepr-nextjs`, for Prepr API consumers that
|
|
329
|
+
// still identify the toolbar by that string.
|
|
325
330
|
"User-Agent": `Prepr-Preview-Bar/${VERSION}`,
|
|
326
331
|
"Content-Type": "application/json"
|
|
327
332
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@preprio/toolkit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
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)",
|