@preprio/toolkit 0.2.0-beta.7 → 0.2.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/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-P6VTLWM4.js → chunk-4PJK6IQ4.js} +25 -15
- package/dist/index.cjs +41 -20
- 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 +28 -16
- 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 +25 -15
- package/dist/react/components.js +25 -15
- 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 +3 -3
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.2.0
|
|
5
|
+
var VERSION = "0.2.0";
|
|
6
6
|
|
|
7
7
|
// src/core/constants.ts
|
|
8
8
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -56,7 +56,11 @@ function parseCookies(request) {
|
|
|
56
56
|
const name = part.slice(0, eq).trim();
|
|
57
57
|
const value = part.slice(eq + 1).trim();
|
|
58
58
|
if (!name) continue;
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
cookies.set(name, decodeURIComponent(value));
|
|
61
|
+
} catch {
|
|
62
|
+
cookies.set(name, value);
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
65
|
return cookies;
|
|
62
66
|
}
|
|
@@ -95,7 +99,10 @@ function processPreprRequest(request, opts) {
|
|
|
95
99
|
if (userAgent) {
|
|
96
100
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
97
101
|
}
|
|
98
|
-
requestHeaders.set(
|
|
102
|
+
requestHeaders.set(
|
|
103
|
+
"Prepr-Package",
|
|
104
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
105
|
+
);
|
|
99
106
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
100
107
|
if (ip) {
|
|
101
108
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -104,7 +111,7 @@ function processPreprRequest(request, opts) {
|
|
|
104
111
|
if (hutkCookie) {
|
|
105
112
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
106
113
|
}
|
|
107
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
114
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
108
115
|
if (!uid) {
|
|
109
116
|
uid = crypto.randomUUID();
|
|
110
117
|
responseCookies.push({
|
|
@@ -188,19 +195,30 @@ function createPreprMiddleware(request, responseOrOptions, maybeOptions) {
|
|
|
188
195
|
} else {
|
|
189
196
|
options = responseOrOptions;
|
|
190
197
|
}
|
|
191
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
198
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
199
|
+
request,
|
|
200
|
+
options
|
|
201
|
+
);
|
|
192
202
|
const response = chainedResponse ?? NextResponse.next({ request: { headers: requestHeaders } });
|
|
193
203
|
if (chainedResponse) {
|
|
204
|
+
const existing = response.headers.get("x-middleware-override-headers");
|
|
205
|
+
const names = new Set(
|
|
206
|
+
existing ? existing.split(",").map((name) => name.trim()).filter(Boolean) : []
|
|
207
|
+
);
|
|
194
208
|
requestHeaders.forEach((value, key) => {
|
|
195
|
-
|
|
209
|
+
names.add(key);
|
|
210
|
+
response.headers.set(`x-middleware-request-${key}`, value);
|
|
196
211
|
});
|
|
212
|
+
response.headers.set("x-middleware-override-headers", [...names].join(","));
|
|
197
213
|
}
|
|
198
214
|
for (const cookie of responseCookies) {
|
|
199
215
|
response.cookies.set(cookie.name, cookie.value, {
|
|
200
216
|
maxAge: cookie.maxAge,
|
|
201
217
|
path: cookie.path,
|
|
202
218
|
// Lower-cased: Next's cookie API expects 'none' | 'lax' | 'strict'.
|
|
203
|
-
...cookie.sameSite ? {
|
|
219
|
+
...cookie.sameSite ? {
|
|
220
|
+
sameSite: cookie.sameSite.toLowerCase()
|
|
221
|
+
} : {},
|
|
204
222
|
...cookie.secure ? { secure: true } : {}
|
|
205
223
|
});
|
|
206
224
|
}
|
|
@@ -260,7 +278,11 @@ function getPreprHeadersFromHeaders(headers2) {
|
|
|
260
278
|
}
|
|
261
279
|
function validatePreprToken(token) {
|
|
262
280
|
if (!token) {
|
|
263
|
-
throw new PreprError(
|
|
281
|
+
throw new PreprError(
|
|
282
|
+
"Token is required",
|
|
283
|
+
"MISSING_TOKEN",
|
|
284
|
+
"validatePreprToken"
|
|
285
|
+
);
|
|
264
286
|
}
|
|
265
287
|
if (!token.startsWith("https://")) {
|
|
266
288
|
throw new PreprError(
|
|
@@ -393,7 +415,7 @@ async function getToolbarProps(token, features) {
|
|
|
393
415
|
import {
|
|
394
416
|
PreprToolbar,
|
|
395
417
|
PreprTrackingPixel
|
|
396
|
-
} from "./components";
|
|
418
|
+
} from "./components.js";
|
|
397
419
|
export {
|
|
398
420
|
PreprError,
|
|
399
421
|
PreprToolbar,
|
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.2.0
|
|
38
|
+
var VERSION = "0.2.0";
|
|
39
39
|
|
|
40
40
|
// src/core/constants.ts
|
|
41
41
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -103,7 +103,11 @@ function parseCookies(request) {
|
|
|
103
103
|
const name = part.slice(0, eq).trim();
|
|
104
104
|
const value = part.slice(eq + 1).trim();
|
|
105
105
|
if (!name) continue;
|
|
106
|
-
|
|
106
|
+
try {
|
|
107
|
+
cookies.set(name, decodeURIComponent(value));
|
|
108
|
+
} catch {
|
|
109
|
+
cookies.set(name, value);
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
return cookies;
|
|
109
113
|
}
|
|
@@ -142,7 +146,10 @@ function processPreprRequest(request, opts) {
|
|
|
142
146
|
if (userAgent) {
|
|
143
147
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
144
148
|
}
|
|
145
|
-
requestHeaders.set(
|
|
149
|
+
requestHeaders.set(
|
|
150
|
+
"Prepr-Package",
|
|
151
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
152
|
+
);
|
|
146
153
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
147
154
|
if (ip) {
|
|
148
155
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -151,7 +158,7 @@ function processPreprRequest(request, opts) {
|
|
|
151
158
|
if (hutkCookie) {
|
|
152
159
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
153
160
|
}
|
|
154
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
161
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
155
162
|
if (!uid) {
|
|
156
163
|
uid = crypto.randomUUID();
|
|
157
164
|
responseCookies.push({
|
|
@@ -238,7 +245,10 @@ function handlePreprRequest(event, options) {
|
|
|
238
245
|
request.headers.set(key, value.join(", "));
|
|
239
246
|
}
|
|
240
247
|
}
|
|
241
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
248
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
249
|
+
request,
|
|
250
|
+
options
|
|
251
|
+
);
|
|
242
252
|
requestHeaders.forEach((value, key) => {
|
|
243
253
|
req.headers[key.toLowerCase()] = value;
|
|
244
254
|
});
|
|
@@ -302,7 +312,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
302
312
|
}
|
|
303
313
|
function validatePreprToken(token) {
|
|
304
314
|
if (!token) {
|
|
305
|
-
throw new PreprError(
|
|
315
|
+
throw new PreprError(
|
|
316
|
+
"Token is required",
|
|
317
|
+
"MISSING_TOKEN",
|
|
318
|
+
"validatePreprToken"
|
|
319
|
+
);
|
|
306
320
|
}
|
|
307
321
|
if (!token.startsWith("https://")) {
|
|
308
322
|
throw new PreprError(
|
package/dist/nuxt/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.2.0
|
|
2
|
+
var VERSION = "0.2.0";
|
|
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({
|
|
@@ -202,7 +209,10 @@ function handlePreprRequest(event, options) {
|
|
|
202
209
|
request.headers.set(key, value.join(", "));
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
212
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
213
|
+
request,
|
|
214
|
+
options
|
|
215
|
+
);
|
|
206
216
|
requestHeaders.forEach((value, key) => {
|
|
207
217
|
req.headers[key.toLowerCase()] = value;
|
|
208
218
|
});
|
|
@@ -266,7 +276,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
266
276
|
}
|
|
267
277
|
function validatePreprToken(token) {
|
|
268
278
|
if (!token) {
|
|
269
|
-
throw new PreprError(
|
|
279
|
+
throw new PreprError(
|
|
280
|
+
"Token is required",
|
|
281
|
+
"MISSING_TOKEN",
|
|
282
|
+
"validatePreprToken"
|
|
283
|
+
);
|
|
270
284
|
}
|
|
271
285
|
if (!token.startsWith("https://")) {
|
|
272
286
|
throw new PreprError(
|
|
@@ -368,9 +368,7 @@ function decodeStega(str) {
|
|
|
368
368
|
const match = str.match(/{"origin.*?}/);
|
|
369
369
|
if (match) {
|
|
370
370
|
try {
|
|
371
|
-
const decodedMatch = (0, import_stega.vercelStegaDecode)(
|
|
372
|
-
match[0]
|
|
373
|
-
);
|
|
371
|
+
const decodedMatch = (0, import_stega.vercelStegaDecode)(match[0]);
|
|
374
372
|
if (decodedMatch?.href) {
|
|
375
373
|
return decodedMatch;
|
|
376
374
|
}
|
|
@@ -898,8 +896,13 @@ function createStegaController(opts) {
|
|
|
898
896
|
overlay.hide();
|
|
899
897
|
}
|
|
900
898
|
}, 16);
|
|
901
|
-
document.addEventListener("mousemove", throttledMouseMove
|
|
902
|
-
|
|
899
|
+
document.addEventListener("mousemove", throttledMouseMove, {
|
|
900
|
+
passive: true
|
|
901
|
+
});
|
|
902
|
+
window.addEventListener("scroll", handleScroll, {
|
|
903
|
+
capture: true,
|
|
904
|
+
passive: true
|
|
905
|
+
});
|
|
903
906
|
initialized = true;
|
|
904
907
|
debug6.log("stega controller started");
|
|
905
908
|
};
|
|
@@ -1042,7 +1045,9 @@ function createChangeHandler(deps) {
|
|
|
1042
1045
|
}
|
|
1043
1046
|
setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
|
|
1044
1047
|
setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
|
|
1045
|
-
sendPreprEvent("preview_mode_toggled", {
|
|
1048
|
+
sendPreprEvent("preview_mode_toggled", {
|
|
1049
|
+
previewMode: after.previewMode
|
|
1050
|
+
});
|
|
1046
1051
|
if (!after.isIframe) {
|
|
1047
1052
|
const [path, existing] = splitPath(deps.currentPath());
|
|
1048
1053
|
const params = new URLSearchParams(existing);
|
|
@@ -1349,7 +1354,7 @@ var CLOSE_ICON_SVG = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none
|
|
|
1349
1354
|
</svg>`;
|
|
1350
1355
|
|
|
1351
1356
|
// src/core/ui/toolbar.generated.ts
|
|
1352
|
-
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
1357
|
+
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
1353
1358
|
|
|
1354
1359
|
// ../../node_modules/.pnpm/preact@10.29.7/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
1355
1360
|
var f2 = 0;
|
|
@@ -1363,7 +1368,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
|
|
|
1363
1368
|
}
|
|
1364
1369
|
|
|
1365
1370
|
// src/core/ui/panel.tsx
|
|
1366
|
-
function RawSvg({
|
|
1371
|
+
function RawSvg({
|
|
1372
|
+
svg,
|
|
1373
|
+
className
|
|
1374
|
+
}) {
|
|
1367
1375
|
return /* @__PURE__ */ u2(
|
|
1368
1376
|
"span",
|
|
1369
1377
|
{
|
|
@@ -1630,7 +1638,7 @@ function StatusPill({
|
|
|
1630
1638
|
{
|
|
1631
1639
|
class: "prepr-status-x",
|
|
1632
1640
|
"data-prepr": "status-x",
|
|
1633
|
-
hidden: !features.segments
|
|
1641
|
+
hidden: !state.previewMode || !(features.segments && state.selectedSegment !== null || features.abTesting && state.selectedVariant === "B"),
|
|
1634
1642
|
children: /* @__PURE__ */ u2(RawSvg, { svg: XMARK_ICON_SVG })
|
|
1635
1643
|
}
|
|
1636
1644
|
)
|
|
@@ -1934,9 +1942,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
|
|
|
1934
1942
|
) ?? null;
|
|
1935
1943
|
}
|
|
1936
1944
|
optionsList() {
|
|
1937
|
-
return this.shadowRoot?.querySelector(
|
|
1938
|
-
'[data-prepr="options"]'
|
|
1939
|
-
) ?? null;
|
|
1945
|
+
return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
|
|
1940
1946
|
}
|
|
1941
1947
|
onListboxKeydown(event) {
|
|
1942
1948
|
const e2 = event;
|
|
@@ -2156,9 +2162,13 @@ function createPreprPreview(opts = {}) {
|
|
|
2156
2162
|
const bridge = createIframeBridge(store, {
|
|
2157
2163
|
allowedEditorOrigins: options?.allowedEditorOrigins
|
|
2158
2164
|
});
|
|
2159
|
-
sendPreprEvent(
|
|
2160
|
-
|
|
2161
|
-
|
|
2165
|
+
sendPreprEvent(
|
|
2166
|
+
"getScrollPosition",
|
|
2167
|
+
{ value: 0 },
|
|
2168
|
+
{
|
|
2169
|
+
allowUntrustedTarget: true
|
|
2170
|
+
}
|
|
2171
|
+
);
|
|
2162
2172
|
if (isIframe) {
|
|
2163
2173
|
bridge.start();
|
|
2164
2174
|
}
|
package/dist/react/components.js
CHANGED
|
@@ -344,9 +344,7 @@ function decodeStega(str) {
|
|
|
344
344
|
const match = str.match(/{"origin.*?}/);
|
|
345
345
|
if (match) {
|
|
346
346
|
try {
|
|
347
|
-
const decodedMatch = vercelStegaDecode(
|
|
348
|
-
match[0]
|
|
349
|
-
);
|
|
347
|
+
const decodedMatch = vercelStegaDecode(match[0]);
|
|
350
348
|
if (decodedMatch?.href) {
|
|
351
349
|
return decodedMatch;
|
|
352
350
|
}
|
|
@@ -874,8 +872,13 @@ function createStegaController(opts) {
|
|
|
874
872
|
overlay.hide();
|
|
875
873
|
}
|
|
876
874
|
}, 16);
|
|
877
|
-
document.addEventListener("mousemove", throttledMouseMove
|
|
878
|
-
|
|
875
|
+
document.addEventListener("mousemove", throttledMouseMove, {
|
|
876
|
+
passive: true
|
|
877
|
+
});
|
|
878
|
+
window.addEventListener("scroll", handleScroll, {
|
|
879
|
+
capture: true,
|
|
880
|
+
passive: true
|
|
881
|
+
});
|
|
879
882
|
initialized = true;
|
|
880
883
|
debug6.log("stega controller started");
|
|
881
884
|
};
|
|
@@ -1018,7 +1021,9 @@ function createChangeHandler(deps) {
|
|
|
1018
1021
|
}
|
|
1019
1022
|
setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
|
|
1020
1023
|
setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
|
|
1021
|
-
sendPreprEvent("preview_mode_toggled", {
|
|
1024
|
+
sendPreprEvent("preview_mode_toggled", {
|
|
1025
|
+
previewMode: after.previewMode
|
|
1026
|
+
});
|
|
1022
1027
|
if (!after.isIframe) {
|
|
1023
1028
|
const [path, existing] = splitPath(deps.currentPath());
|
|
1024
1029
|
const params = new URLSearchParams(existing);
|
|
@@ -1325,7 +1330,7 @@ var CLOSE_ICON_SVG = `<svg width="10" height="10" viewBox="0 0 10 10" fill="none
|
|
|
1325
1330
|
</svg>`;
|
|
1326
1331
|
|
|
1327
1332
|
// src/core/ui/toolbar.generated.ts
|
|
1328
|
-
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
1333
|
+
var TOOLBAR_CSS = ":host{--prepr-primary:#4338ca;--prepr-bg:#eef2ff;--prepr-text:#1f2937;--prepr-radius:8px;--prepr-shadow:0px 0px 40px 0px #1f29373d;--prepr-z-index:10000;--prepr-primary-50:#eef2ff;--prepr-primary-100:#e0e7ff;--prepr-primary-800:#3730a3;--prepr-indigo-600:#4f46e5;--prepr-indigo-50:#eef2ff;--prepr-indigo-700:#4338ca;--prepr-secondary-400:#fb923c;--prepr-secondary-500:#f97316;--prepr-gray-100:#f3f4f6;--prepr-gray-200:#e5e7eb;--prepr-gray-300:#d1d5db;--prepr-gray-400:#9ca3af;--prepr-gray-500:#6b7280;--prepr-gray-700:#374151;--prepr-gray-800:#1f2937;--prepr-gray-900:#111827;--prepr-shadow-sm:0px 0px 12px 0px #c3c3c3cc;color:var(--prepr-text);box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.5}:host *,:host :before,:host :after,*,:before,:after{box-sizing:border-box}button{font-family:inherit;font-size:inherit;margin:0}.prepr-regular-text{font-size:.875rem;font-weight:500;line-height:1.5}.prepr-backdrop{z-index:calc(var(--prepr-z-index) - 1);opacity:0;pointer-events:none;background:#0000001a;transition:opacity .2s ease-in-out;position:fixed;top:0;bottom:0;left:0;right:0}.prepr-backdrop[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-container{z-index:var(--prepr-z-index);justify-content:flex-end;align-items:center;display:flex;position:fixed;top:calc(50% - 64px);right:0}.prepr-toggle-holder{padding:.5rem}.prepr-toggle{cursor:pointer;background:var(--prepr-primary);color:#fff;border:none;border-radius:9999px;justify-content:center;align-items:center;width:2.25rem;height:2.25rem;display:flex}.prepr-toggle>span{display:flex}.prepr-toggle svg{color:#fff}.prepr-panel{z-index:var(--prepr-z-index);opacity:0;pointer-events:none;justify-content:flex-end;padding:.75rem;transition:opacity .2s ease-in-out;display:flex;position:fixed;top:50%;right:0;transform:translateY(-50%)}.prepr-panel[data-open=true]{opacity:1;pointer-events:auto;animation:.2s ease-in-out prepr-fade-in}.prepr-content{box-shadow:var(--prepr-shadow);border-radius:var(--prepr-radius);background:var(--prepr-bg);flex-direction:column;gap:2.5rem;width:100%;padding:1.5rem;display:flex}@media (min-width:640px){.prepr-panel{margin-right:4rem;padding:0}.prepr-content{width:502px;padding:2.5rem}}.prepr-header{justify-content:space-between;align-items:center;gap:.5rem;display:flex}.prepr-header-left{align-items:flex-start;gap:.75rem;display:flex}.prepr-badge{background:var(--prepr-primary-100);height:1.5rem;color:var(--prepr-primary);border-radius:4px;align-items:center;padding:.25rem .75rem;font-size:.875rem;display:flex}.prepr-header-close{cursor:pointer;background:var(--prepr-primary-100);width:2rem;height:2rem;color:var(--prepr-gray-700);border:none;border-radius:6px;justify-content:center;align-items:center;display:flex}.prepr-section{flex-direction:column;gap:.5rem;display:flex}.prepr-section-label{color:var(--prepr-gray-400);font-size:.875rem}.prepr-row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.5rem 1.5rem;display:flex}.prepr-row-title{color:var(--prepr-gray-800);margin:0;font-size:1rem;font-weight:600}.prepr-radiogroup{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);background:#fff;align-items:center;gap:.25rem;height:2.5rem;padding:.25rem;display:flex}.prepr-radiogroup[data-disabled=true]{cursor:not-allowed;opacity:.5}.prepr-radiogroup[data-disabled=true] .prepr-radio{pointer-events:none}.prepr-radio{cursor:pointer;white-space:nowrap;text-align:center;height:2rem;color:var(--prepr-gray-900);background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;padding:.5rem 1.125rem;font-size:.875rem;font-weight:500;transition:all .2s ease-in-out;display:flex}.prepr-radio[data-checked=true]{background:var(--prepr-indigo-600);color:#fff;box-shadow:var(--prepr-shadow-sm)}.prepr-radio[data-checked=true][data-off=true]{background:var(--prepr-gray-800);color:#fff}.prepr-radio-variant{width:82px}.prepr-listbox{position:relative}.prepr-segment-button{border-radius:var(--prepr-radius);border:1px solid var(--prepr-gray-300);width:240px;height:2.5rem;color:var(--prepr-gray-500);cursor:pointer;background:#fff;flex-shrink:0;align-items:center;gap:.5rem;padding:0 .5rem;font-size:.875rem;font-weight:500;display:flex;overflow:hidden}@media (min-width:768px){.prepr-segment-button{padding:0 1rem}}.prepr-segment-button:disabled{cursor:not-allowed;background:var(--prepr-gray-200);color:var(--prepr-gray-400)}.prepr-segment-button[aria-expanded=true]{border-bottom-color:#fff;border-bottom-right-radius:0;border-bottom-left-radius:0}.prepr-segment-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-segment-caret{color:var(--prepr-gray-800);display:flex}.prepr-options{z-index:calc(var(--prepr-z-index) + 1);border-left:1px solid var(--prepr-gray-300);border-right:1px solid var(--prepr-gray-300);border-bottom:1px solid var(--prepr-gray-300);-ms-overflow-style:none;scrollbar-width:none;background:#fff;border-radius:0 0 6px 6px;width:240px;max-height:300px;margin:0;padding:0;list-style:none;position:absolute;top:100%;left:0;overflow-y:auto;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-options::-webkit-scrollbar{display:none}.prepr-options[hidden]{display:none}.prepr-option-search{background:#fff;padding:.5rem;position:-webkit-sticky;position:sticky;top:0}.prepr-segment-search{border:1px solid var(--prepr-gray-300);border-radius:var(--prepr-radius);width:100%;height:2rem;font:inherit;color:var(--prepr-gray-900);box-sizing:border-box;background:#fff;padding:0 .5rem;font-size:.875rem}.prepr-segment-search::placeholder{color:var(--prepr-gray-400)}.prepr-segment-search:focus{border-color:var(--prepr-gray-400);outline:none}.prepr-option{cursor:pointer;width:100%;color:var(--prepr-gray-900);background:#fff;align-items:center;padding:.5rem 1rem;font-size:.875rem;font-weight:500;display:flex}.prepr-option:hover{background:var(--prepr-gray-100)}.prepr-option[aria-selected=true]{background:var(--prepr-indigo-50);color:var(--prepr-indigo-700)}.prepr-option-label{white-space:nowrap;text-overflow:ellipsis;text-align:left;width:100%;margin-right:auto;overflow:hidden}.prepr-reset{background:var(--prepr-secondary-400);color:#fff;cursor:pointer;border:none;border-radius:6px;justify-content:center;align-items:center;gap:.5rem;width:100%;height:2.5rem;padding:.5rem .75rem;font-size:.875rem;font-weight:500;display:flex}.prepr-reset:hover:not(:disabled){background:var(--prepr-secondary-500)}.prepr-reset:disabled{background:var(--prepr-gray-400);color:var(--prepr-gray-500);cursor:not-allowed}@media (min-width:768px){.prepr-reset{width:108px}}.prepr-indicators{z-index:var(--prepr-z-index);gap:.75rem;display:flex;position:fixed;bottom:1.5rem;right:1.5rem}.prepr-status-pill{background:var(--prepr-primary);color:#fff;cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-status-pill:hover{background:var(--prepr-primary-800)}.prepr-status-pill[hidden]{display:none}.prepr-status-viewing{color:#fff9;font-size:10px}.prepr-status-segment{text-overflow:ellipsis;white-space:nowrap;max-width:120px;display:inline-block;overflow:hidden}.prepr-status-variant{text-overflow:ellipsis;white-space:nowrap;background:#fff3;border-radius:4px;max-width:80px;padding:0 .5rem;display:inline-block;overflow:hidden}.prepr-status-x{color:#fff;width:.75rem;height:.75rem}.prepr-close-edit-pill{background:var(--prepr-primary-50);color:var(--prepr-gray-800);cursor:pointer;border:none;border-radius:9999px;align-items:center;gap:.5rem;padding:.5rem 1rem;font-size:.75rem;font-weight:500;transition:background-color .15s;display:flex;box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a}.prepr-close-edit-pill:hover{background:var(--prepr-primary-100)}.prepr-close-edit-pill[hidden]{display:none}.prepr-close-edit-x{width:1rem;height:1rem;color:var(--prepr-gray-500);transition:color .15s}.prepr-close-edit-pill:hover .prepr-close-edit-x{color:var(--prepr-gray-700)}.prepr-tip{z-index:calc(var(--prepr-z-index) + 2);overflow-wrap:break-word;background:var(--prepr-gray-900);color:#fff;pointer-events:none;border-radius:6px;width:auto;max-width:min(420px,100vw - 16px);padding:.5rem .75rem;font-size:.75rem;font-weight:500;position:fixed;box-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a}.prepr-tip-arrow{border-left:6px solid #0000;border-right:6px solid #0000;border-top:6px solid var(--prepr-gray-900);width:0;height:0;position:absolute;top:100%;transform:translate(-50%)}[hidden]{display:none!important}@keyframes prepr-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
1329
1334
|
|
|
1330
1335
|
// ../../node_modules/.pnpm/preact@10.29.7/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
1331
1336
|
var f2 = 0;
|
|
@@ -1339,7 +1344,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
|
|
|
1339
1344
|
}
|
|
1340
1345
|
|
|
1341
1346
|
// src/core/ui/panel.tsx
|
|
1342
|
-
function RawSvg({
|
|
1347
|
+
function RawSvg({
|
|
1348
|
+
svg,
|
|
1349
|
+
className
|
|
1350
|
+
}) {
|
|
1343
1351
|
return /* @__PURE__ */ u2(
|
|
1344
1352
|
"span",
|
|
1345
1353
|
{
|
|
@@ -1606,7 +1614,7 @@ function StatusPill({
|
|
|
1606
1614
|
{
|
|
1607
1615
|
class: "prepr-status-x",
|
|
1608
1616
|
"data-prepr": "status-x",
|
|
1609
|
-
hidden: !features.segments
|
|
1617
|
+
hidden: !state.previewMode || !(features.segments && state.selectedSegment !== null || features.abTesting && state.selectedVariant === "B"),
|
|
1610
1618
|
children: /* @__PURE__ */ u2(RawSvg, { svg: XMARK_ICON_SVG })
|
|
1611
1619
|
}
|
|
1612
1620
|
)
|
|
@@ -1910,9 +1918,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
|
|
|
1910
1918
|
) ?? null;
|
|
1911
1919
|
}
|
|
1912
1920
|
optionsList() {
|
|
1913
|
-
return this.shadowRoot?.querySelector(
|
|
1914
|
-
'[data-prepr="options"]'
|
|
1915
|
-
) ?? null;
|
|
1921
|
+
return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
|
|
1916
1922
|
}
|
|
1917
1923
|
onListboxKeydown(event) {
|
|
1918
1924
|
const e2 = event;
|
|
@@ -2132,9 +2138,13 @@ function createPreprPreview(opts = {}) {
|
|
|
2132
2138
|
const bridge = createIframeBridge(store, {
|
|
2133
2139
|
allowedEditorOrigins: options?.allowedEditorOrigins
|
|
2134
2140
|
});
|
|
2135
|
-
sendPreprEvent(
|
|
2136
|
-
|
|
2137
|
-
|
|
2141
|
+
sendPreprEvent(
|
|
2142
|
+
"getScrollPosition",
|
|
2143
|
+
{ value: 0 },
|
|
2144
|
+
{
|
|
2145
|
+
allowUntrustedTarget: true
|
|
2146
|
+
}
|
|
2147
|
+
);
|
|
2138
2148
|
if (isIframe) {
|
|
2139
2149
|
bridge.start();
|
|
2140
2150
|
}
|
package/dist/react/index.cjs
CHANGED
|
@@ -24,7 +24,7 @@ __export(react_exports, {
|
|
|
24
24
|
PreprTrackingPixel: () => import_components.PreprTrackingPixel
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(react_exports);
|
|
27
|
-
var import_components = require("./components.
|
|
27
|
+
var import_components = require("./components.cjs");
|
|
28
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
29
|
0 && (module.exports = {
|
|
30
30
|
PreprPreview,
|
package/dist/react/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { PreprPreview, PreprPreviewProps, PreprTrackingPixel, PreprTrackingPixelProps } from './components.
|
|
1
|
+
export { PreprPreview, PreprPreviewProps, PreprTrackingPixel, PreprTrackingPixelProps } from './components.cjs';
|
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.2.0
|
|
38
|
+
var VERSION = "0.2.0";
|
|
39
39
|
|
|
40
40
|
// src/core/constants.ts
|
|
41
41
|
var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
|
|
@@ -103,7 +103,11 @@ function parseCookies(request) {
|
|
|
103
103
|
const name = part.slice(0, eq).trim();
|
|
104
104
|
const value = part.slice(eq + 1).trim();
|
|
105
105
|
if (!name) continue;
|
|
106
|
-
|
|
106
|
+
try {
|
|
107
|
+
cookies.set(name, decodeURIComponent(value));
|
|
108
|
+
} catch {
|
|
109
|
+
cookies.set(name, value);
|
|
110
|
+
}
|
|
107
111
|
}
|
|
108
112
|
return cookies;
|
|
109
113
|
}
|
|
@@ -142,7 +146,10 @@ function processPreprRequest(request, opts) {
|
|
|
142
146
|
if (userAgent) {
|
|
143
147
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
144
148
|
}
|
|
145
|
-
requestHeaders.set(
|
|
149
|
+
requestHeaders.set(
|
|
150
|
+
"Prepr-Package",
|
|
151
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
152
|
+
);
|
|
146
153
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
147
154
|
if (ip) {
|
|
148
155
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -151,7 +158,7 @@ function processPreprRequest(request, opts) {
|
|
|
151
158
|
if (hutkCookie) {
|
|
152
159
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
153
160
|
}
|
|
154
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
161
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
155
162
|
if (!uid) {
|
|
156
163
|
uid = crypto.randomUUID();
|
|
157
164
|
responseCookies.push({
|
|
@@ -229,7 +236,10 @@ function processPreprRequest(request, opts) {
|
|
|
229
236
|
var PREPR_LOCALS_KEY = "prepr";
|
|
230
237
|
function preprHandle(options) {
|
|
231
238
|
return async ({ event, resolve }) => {
|
|
232
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
239
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
240
|
+
event.request,
|
|
241
|
+
options
|
|
242
|
+
);
|
|
233
243
|
requestHeaders.forEach((value, key) => {
|
|
234
244
|
event.request.headers.set(key, value);
|
|
235
245
|
});
|
|
@@ -298,7 +308,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
298
308
|
}
|
|
299
309
|
function validatePreprToken(token) {
|
|
300
310
|
if (!token) {
|
|
301
|
-
throw new PreprError(
|
|
311
|
+
throw new PreprError(
|
|
312
|
+
"Token is required",
|
|
313
|
+
"MISSING_TOKEN",
|
|
314
|
+
"validatePreprToken"
|
|
315
|
+
);
|
|
302
316
|
}
|
|
303
317
|
if (!token.startsWith("https://")) {
|
|
304
318
|
throw new PreprError(
|
package/dist/sveltekit/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/version.ts
|
|
2
|
-
var VERSION = "0.2.0
|
|
2
|
+
var VERSION = "0.2.0";
|
|
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
|
|
3
|
+
"version": "0.2.0",
|
|
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)",
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"next": ">=13",
|
|
113
113
|
"react": ">=17",
|
|
114
114
|
"react-dom": ">=17",
|
|
115
|
-
"svelte": ">=
|
|
116
|
-
"vue": ">=3"
|
|
115
|
+
"svelte": ">=5",
|
|
116
|
+
"vue": ">=3.3"
|
|
117
117
|
},
|
|
118
118
|
"peerDependenciesMeta": {
|
|
119
119
|
"next": {
|