@preprio/toolkit 0.2.0-beta.7 → 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-P6VTLWM4.js → chunk-JVUG6S4O.js} +23 -13
- package/dist/index.cjs +39 -18
- 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 +26 -14
- 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 +23 -13
- package/dist/react/components.js +23 -13
- 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/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);
|
|
@@ -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
|
{
|
|
@@ -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-beta.
|
|
38
|
+
var VERSION = "0.2.0-beta.9";
|
|
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-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)",
|
|
@@ -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": {
|