@preprio/toolkit 0.2.0-beta.6 → 0.2.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +237 -471
- package/dist/astro/index.cjs +20 -6
- package/dist/astro/index.d.cts +1 -1
- package/dist/astro/index.d.ts +1 -1
- package/dist/astro/index.js +20 -6
- package/dist/{chunk-C6YEXA5G.js → chunk-JVUG6S4O.js} +42 -47
- package/dist/index.cjs +58 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -6
- package/dist/nextjs/components.cjs +45 -48
- package/dist/nextjs/components.js +5 -3
- package/dist/nextjs/image-loader.cjs +7 -2
- package/dist/nextjs/image-loader.d.cts +1 -1
- package/dist/nextjs/image-loader.d.ts +1 -1
- package/dist/nextjs/image-loader.js +7 -2
- package/dist/nextjs/index.cjs +31 -9
- package/dist/nextjs/index.d.cts +99 -2
- package/dist/nextjs/index.d.ts +99 -2
- package/dist/nextjs/index.js +31 -9
- package/dist/nuxt/index.cjs +20 -6
- package/dist/nuxt/index.js +20 -6
- package/dist/react/components.cjs +42 -47
- package/dist/react/components.js +42 -47
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/sveltekit/index.cjs +20 -6
- package/dist/sveltekit/index.js +20 -6
- package/package.json +14 -14
package/dist/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.2.0-beta.
|
|
33
|
+
var VERSION = "0.2.0-beta.9";
|
|
34
34
|
|
|
35
35
|
// src/core/features.ts
|
|
36
36
|
function isEnabled(config) {
|
|
@@ -100,7 +100,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
100
100
|
}
|
|
101
101
|
function validatePreprToken(token) {
|
|
102
102
|
if (!token) {
|
|
103
|
-
throw new PreprError(
|
|
103
|
+
throw new PreprError(
|
|
104
|
+
"Token is required",
|
|
105
|
+
"MISSING_TOKEN",
|
|
106
|
+
"validatePreprToken"
|
|
107
|
+
);
|
|
104
108
|
}
|
|
105
109
|
if (!token.startsWith("https://")) {
|
|
106
110
|
throw new PreprError(
|
|
@@ -222,7 +226,11 @@ function parseCookies(request) {
|
|
|
222
226
|
const name = part.slice(0, eq).trim();
|
|
223
227
|
const value = part.slice(eq + 1).trim();
|
|
224
228
|
if (!name) continue;
|
|
225
|
-
|
|
229
|
+
try {
|
|
230
|
+
cookies.set(name, decodeURIComponent(value));
|
|
231
|
+
} catch {
|
|
232
|
+
cookies.set(name, value);
|
|
233
|
+
}
|
|
226
234
|
}
|
|
227
235
|
return cookies;
|
|
228
236
|
}
|
|
@@ -261,7 +269,10 @@ function processPreprRequest(request, opts) {
|
|
|
261
269
|
if (userAgent) {
|
|
262
270
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
263
271
|
}
|
|
264
|
-
requestHeaders.set(
|
|
272
|
+
requestHeaders.set(
|
|
273
|
+
"Prepr-Package",
|
|
274
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
275
|
+
);
|
|
265
276
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
266
277
|
if (ip) {
|
|
267
278
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -270,7 +281,7 @@ function processPreprRequest(request, opts) {
|
|
|
270
281
|
if (hutkCookie) {
|
|
271
282
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
272
283
|
}
|
|
273
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
284
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
274
285
|
if (!uid) {
|
|
275
286
|
uid = crypto.randomUUID();
|
|
276
287
|
responseCookies.push({
|
|
@@ -346,7 +357,10 @@ function processPreprRequest(request, opts) {
|
|
|
346
357
|
|
|
347
358
|
// src/astro/index.ts
|
|
348
359
|
async function onPreprRequest(context, next, options) {
|
|
349
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
360
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
361
|
+
context.request,
|
|
362
|
+
options
|
|
363
|
+
);
|
|
350
364
|
requestHeaders.forEach((value, key) => {
|
|
351
365
|
context.request.headers.set(key, value);
|
|
352
366
|
});
|
package/dist/astro/index.d.cts
CHANGED
|
@@ -90,7 +90,7 @@ type AstroNext = () => Promise<Response>;
|
|
|
90
90
|
* Astro middleware entry point: computes the Prepr headers/cookies for this
|
|
91
91
|
* request, forwards the headers downstream and sets the cookies on the response.
|
|
92
92
|
*
|
|
93
|
-
* Astro hands downstream code the same `Request` instance
|
|
93
|
+
* Astro hands downstream code the same `Request` instance this middleware receives, so the
|
|
94
94
|
* headers are mutated in place — building a new `Request` would go nowhere,
|
|
95
95
|
* there's no way to hand a replacement back out of middleware.
|
|
96
96
|
*/
|
package/dist/astro/index.d.ts
CHANGED
|
@@ -90,7 +90,7 @@ type AstroNext = () => Promise<Response>;
|
|
|
90
90
|
* Astro middleware entry point: computes the Prepr headers/cookies for this
|
|
91
91
|
* request, forwards the headers downstream and sets the cookies on the response.
|
|
92
92
|
*
|
|
93
|
-
* Astro hands downstream code the same `Request` instance
|
|
93
|
+
* Astro hands downstream code the same `Request` instance this middleware receives, so the
|
|
94
94
|
* headers are mutated in place — building a new `Request` would go nowhere,
|
|
95
95
|
* there's no way to hand a replacement back out of middleware.
|
|
96
96
|
*/
|
package/dist/astro/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/features.ts
|
|
5
5
|
function isEnabled(config) {
|
|
@@ -69,7 +69,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
69
69
|
}
|
|
70
70
|
function validatePreprToken(token) {
|
|
71
71
|
if (!token) {
|
|
72
|
-
throw new PreprError(
|
|
72
|
+
throw new PreprError(
|
|
73
|
+
"Token is required",
|
|
74
|
+
"MISSING_TOKEN",
|
|
75
|
+
"validatePreprToken"
|
|
76
|
+
);
|
|
73
77
|
}
|
|
74
78
|
if (!token.startsWith("https://")) {
|
|
75
79
|
throw new PreprError(
|
|
@@ -191,7 +195,11 @@ function parseCookies(request) {
|
|
|
191
195
|
const name = part.slice(0, eq).trim();
|
|
192
196
|
const value = part.slice(eq + 1).trim();
|
|
193
197
|
if (!name) continue;
|
|
194
|
-
|
|
198
|
+
try {
|
|
199
|
+
cookies.set(name, decodeURIComponent(value));
|
|
200
|
+
} catch {
|
|
201
|
+
cookies.set(name, value);
|
|
202
|
+
}
|
|
195
203
|
}
|
|
196
204
|
return cookies;
|
|
197
205
|
}
|
|
@@ -230,7 +238,10 @@ function processPreprRequest(request, opts) {
|
|
|
230
238
|
if (userAgent) {
|
|
231
239
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
232
240
|
}
|
|
233
|
-
requestHeaders.set(
|
|
241
|
+
requestHeaders.set(
|
|
242
|
+
"Prepr-Package",
|
|
243
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
244
|
+
);
|
|
234
245
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
235
246
|
if (ip) {
|
|
236
247
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -239,7 +250,7 @@ function processPreprRequest(request, opts) {
|
|
|
239
250
|
if (hutkCookie) {
|
|
240
251
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
241
252
|
}
|
|
242
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
253
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
243
254
|
if (!uid) {
|
|
244
255
|
uid = crypto.randomUUID();
|
|
245
256
|
responseCookies.push({
|
|
@@ -315,7 +326,10 @@ function processPreprRequest(request, opts) {
|
|
|
315
326
|
|
|
316
327
|
// src/astro/index.ts
|
|
317
328
|
async function onPreprRequest(context, next, options) {
|
|
318
|
-
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
329
|
+
const { requestHeaders, responseCookies } = processPreprRequest(
|
|
330
|
+
context.request,
|
|
331
|
+
options
|
|
332
|
+
);
|
|
319
333
|
requestHeaders.forEach((value, key) => {
|
|
320
334
|
context.request.headers.set(key, value);
|
|
321
335
|
});
|
|
@@ -142,9 +142,7 @@ function decodeStega(str) {
|
|
|
142
142
|
const match = str.match(/{"origin.*?}/);
|
|
143
143
|
if (match) {
|
|
144
144
|
try {
|
|
145
|
-
const decodedMatch = vercelStegaDecode(
|
|
146
|
-
match[0]
|
|
147
|
-
);
|
|
145
|
+
const decodedMatch = vercelStegaDecode(match[0]);
|
|
148
146
|
if (decodedMatch?.href) {
|
|
149
147
|
return decodedMatch;
|
|
150
148
|
}
|
|
@@ -570,8 +568,13 @@ function createStegaController(opts) {
|
|
|
570
568
|
overlay.hide();
|
|
571
569
|
}
|
|
572
570
|
}, 16);
|
|
573
|
-
document.addEventListener("mousemove", throttledMouseMove
|
|
574
|
-
|
|
571
|
+
document.addEventListener("mousemove", throttledMouseMove, {
|
|
572
|
+
passive: true
|
|
573
|
+
});
|
|
574
|
+
window.addEventListener("scroll", handleScroll, {
|
|
575
|
+
capture: true,
|
|
576
|
+
passive: true
|
|
577
|
+
});
|
|
575
578
|
initialized = true;
|
|
576
579
|
debug5.log("stega controller started");
|
|
577
580
|
};
|
|
@@ -644,6 +647,8 @@ function createStegaAutoClean() {
|
|
|
644
647
|
function scanAndClean() {
|
|
645
648
|
processing = true;
|
|
646
649
|
walkTextNodes(document.body, cleanTextNode);
|
|
650
|
+
const title = vercelStegaSplit(document.title);
|
|
651
|
+
if (title.encoded) document.title = title.cleaned;
|
|
647
652
|
processing = false;
|
|
648
653
|
}
|
|
649
654
|
function collectAffected(mutations) {
|
|
@@ -689,15 +694,8 @@ function createStegaAutoClean() {
|
|
|
689
694
|
}
|
|
690
695
|
function start() {
|
|
691
696
|
if (observer || typeof window === "undefined") return;
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
setupObserver();
|
|
695
|
-
};
|
|
696
|
-
if ("requestIdleCallback" in window) {
|
|
697
|
-
window.requestIdleCallback(run);
|
|
698
|
-
} else {
|
|
699
|
-
setTimeout(run, 0);
|
|
700
|
-
}
|
|
697
|
+
scanAndClean();
|
|
698
|
+
setupObserver();
|
|
701
699
|
debug6.log("stega auto-clean started");
|
|
702
700
|
}
|
|
703
701
|
function stop() {
|
|
@@ -1047,7 +1045,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
|
|
|
1047
1045
|
}
|
|
1048
1046
|
|
|
1049
1047
|
// src/core/ui/panel.tsx
|
|
1050
|
-
function RawSvg({
|
|
1048
|
+
function RawSvg({
|
|
1049
|
+
svg,
|
|
1050
|
+
className
|
|
1051
|
+
}) {
|
|
1051
1052
|
return /* @__PURE__ */ u2(
|
|
1052
1053
|
"span",
|
|
1053
1054
|
{
|
|
@@ -1618,9 +1619,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
|
|
|
1618
1619
|
) ?? null;
|
|
1619
1620
|
}
|
|
1620
1621
|
optionsList() {
|
|
1621
|
-
return this.shadowRoot?.querySelector(
|
|
1622
|
-
'[data-prepr="options"]'
|
|
1623
|
-
) ?? null;
|
|
1622
|
+
return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
|
|
1624
1623
|
}
|
|
1625
1624
|
onListboxKeydown(event) {
|
|
1626
1625
|
const e2 = event;
|
|
@@ -1934,7 +1933,7 @@ function cookieOpts() {
|
|
|
1934
1933
|
};
|
|
1935
1934
|
}
|
|
1936
1935
|
function createChangeHandler(deps) {
|
|
1937
|
-
const { store, stega,
|
|
1936
|
+
const { store, stega, features, editingEnabled } = deps;
|
|
1938
1937
|
function updateParams(patch) {
|
|
1939
1938
|
const [path, existing] = splitPath(deps.currentPath());
|
|
1940
1939
|
const params = new URLSearchParams(existing);
|
|
@@ -1996,17 +1995,20 @@ function createChangeHandler(deps) {
|
|
|
1996
1995
|
}
|
|
1997
1996
|
setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
|
|
1998
1997
|
setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
|
|
1999
|
-
sendPreprEvent("preview_mode_toggled", {
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
params
|
|
2005
|
-
params.
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
1998
|
+
sendPreprEvent("preview_mode_toggled", {
|
|
1999
|
+
previewMode: after.previewMode
|
|
2000
|
+
});
|
|
2001
|
+
if (!after.isIframe) {
|
|
2002
|
+
const [path, existing] = splitPath(deps.currentPath());
|
|
2003
|
+
const params = new URLSearchParams(existing);
|
|
2004
|
+
if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
|
|
2005
|
+
params.delete(PARAM_SEGMENT);
|
|
2006
|
+
params.delete(PARAM_VARIANT);
|
|
2007
|
+
const query = params.toString();
|
|
2008
|
+
deps.navigate(query ? `${path}?${query}` : path);
|
|
2009
|
+
} else {
|
|
2010
|
+
deps.reload();
|
|
2011
|
+
}
|
|
2010
2012
|
}
|
|
2011
2013
|
}
|
|
2012
2014
|
if (before.toolbarOpen !== after.toolbarOpen) {
|
|
@@ -2118,16 +2120,7 @@ function createPreprPreview(opts = {}) {
|
|
|
2118
2120
|
}
|
|
2119
2121
|
});
|
|
2120
2122
|
const autoClean = createStegaAutoClean();
|
|
2121
|
-
|
|
2122
|
-
function syncAutoClean(active) {
|
|
2123
|
-
if (active && !autoCleanActive) {
|
|
2124
|
-
autoClean.start();
|
|
2125
|
-
autoCleanActive = true;
|
|
2126
|
-
} else if (!active && autoCleanActive) {
|
|
2127
|
-
autoClean.stop();
|
|
2128
|
-
autoCleanActive = false;
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2123
|
+
autoClean.start();
|
|
2131
2124
|
const handleChange = createChangeHandler({
|
|
2132
2125
|
store,
|
|
2133
2126
|
features,
|
|
@@ -2135,8 +2128,7 @@ function createPreprPreview(opts = {}) {
|
|
|
2135
2128
|
navigate: (url) => navigation.navigate(url),
|
|
2136
2129
|
currentPath: () => navigation.currentPath(),
|
|
2137
2130
|
reload: navigation.reload ?? (() => window.location.reload()),
|
|
2138
|
-
stega
|
|
2139
|
-
syncAutoClean
|
|
2131
|
+
stega
|
|
2140
2132
|
});
|
|
2141
2133
|
let prev = store.get();
|
|
2142
2134
|
const unsubscribe = store.subscribe((state) => {
|
|
@@ -2144,20 +2136,23 @@ function createPreprPreview(opts = {}) {
|
|
|
2144
2136
|
prev = state;
|
|
2145
2137
|
handleChange(before, state);
|
|
2146
2138
|
});
|
|
2147
|
-
syncAutoClean(store.get().previewMode);
|
|
2148
2139
|
const bridge = createIframeBridge(store, {
|
|
2149
2140
|
allowedEditorOrigins: options?.allowedEditorOrigins
|
|
2150
2141
|
});
|
|
2151
|
-
sendPreprEvent(
|
|
2152
|
-
|
|
2153
|
-
|
|
2142
|
+
sendPreprEvent(
|
|
2143
|
+
"getScrollPosition",
|
|
2144
|
+
{ value: 0 },
|
|
2145
|
+
{
|
|
2146
|
+
allowUntrustedTarget: true
|
|
2147
|
+
}
|
|
2148
|
+
);
|
|
2154
2149
|
if (isIframe) {
|
|
2155
2150
|
bridge.start();
|
|
2156
2151
|
}
|
|
2157
2152
|
function destroy() {
|
|
2158
2153
|
unsubscribe();
|
|
2159
2154
|
stega.stop();
|
|
2160
|
-
|
|
2155
|
+
autoClean.stop();
|
|
2161
2156
|
if (isIframe) {
|
|
2162
2157
|
bridge.stop();
|
|
2163
2158
|
}
|
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.2.0-beta.
|
|
47
|
+
var VERSION = "0.2.0-beta.9";
|
|
48
48
|
|
|
49
49
|
// src/core/features.ts
|
|
50
50
|
function isEnabled(config) {
|
|
@@ -393,9 +393,7 @@ function decodeStega(str) {
|
|
|
393
393
|
const match = str.match(/{"origin.*?}/);
|
|
394
394
|
if (match) {
|
|
395
395
|
try {
|
|
396
|
-
const decodedMatch = (0, import_stega.vercelStegaDecode)(
|
|
397
|
-
match[0]
|
|
398
|
-
);
|
|
396
|
+
const decodedMatch = (0, import_stega.vercelStegaDecode)(match[0]);
|
|
399
397
|
if (decodedMatch?.href) {
|
|
400
398
|
return decodedMatch;
|
|
401
399
|
}
|
|
@@ -464,6 +462,8 @@ function createStegaAutoClean() {
|
|
|
464
462
|
function scanAndClean() {
|
|
465
463
|
processing = true;
|
|
466
464
|
walkTextNodes(document.body, cleanTextNode);
|
|
465
|
+
const title = (0, import_stega2.vercelStegaSplit)(document.title);
|
|
466
|
+
if (title.encoded) document.title = title.cleaned;
|
|
467
467
|
processing = false;
|
|
468
468
|
}
|
|
469
469
|
function collectAffected(mutations) {
|
|
@@ -509,15 +509,8 @@ function createStegaAutoClean() {
|
|
|
509
509
|
}
|
|
510
510
|
function start() {
|
|
511
511
|
if (observer || typeof window === "undefined") return;
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
setupObserver();
|
|
515
|
-
};
|
|
516
|
-
if ("requestIdleCallback" in window) {
|
|
517
|
-
window.requestIdleCallback(run);
|
|
518
|
-
} else {
|
|
519
|
-
setTimeout(run, 0);
|
|
520
|
-
}
|
|
512
|
+
scanAndClean();
|
|
513
|
+
setupObserver();
|
|
521
514
|
debug2.log("stega auto-clean started");
|
|
522
515
|
}
|
|
523
516
|
function stop() {
|
|
@@ -928,8 +921,13 @@ function createStegaController(opts) {
|
|
|
928
921
|
overlay.hide();
|
|
929
922
|
}
|
|
930
923
|
}, 16);
|
|
931
|
-
document.addEventListener("mousemove", throttledMouseMove
|
|
932
|
-
|
|
924
|
+
document.addEventListener("mousemove", throttledMouseMove, {
|
|
925
|
+
passive: true
|
|
926
|
+
});
|
|
927
|
+
window.addEventListener("scroll", handleScroll, {
|
|
928
|
+
capture: true,
|
|
929
|
+
passive: true
|
|
930
|
+
});
|
|
933
931
|
initialized = true;
|
|
934
932
|
debug6.log("stega controller started");
|
|
935
933
|
};
|
|
@@ -1010,7 +1008,7 @@ function cookieOpts() {
|
|
|
1010
1008
|
};
|
|
1011
1009
|
}
|
|
1012
1010
|
function createChangeHandler(deps) {
|
|
1013
|
-
const { store, stega,
|
|
1011
|
+
const { store, stega, features, editingEnabled } = deps;
|
|
1014
1012
|
function updateParams(patch) {
|
|
1015
1013
|
const [path, existing] = splitPath(deps.currentPath());
|
|
1016
1014
|
const params = new URLSearchParams(existing);
|
|
@@ -1072,17 +1070,20 @@ function createChangeHandler(deps) {
|
|
|
1072
1070
|
}
|
|
1073
1071
|
setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
|
|
1074
1072
|
setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
|
|
1075
|
-
sendPreprEvent("preview_mode_toggled", {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
params
|
|
1081
|
-
params.
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1073
|
+
sendPreprEvent("preview_mode_toggled", {
|
|
1074
|
+
previewMode: after.previewMode
|
|
1075
|
+
});
|
|
1076
|
+
if (!after.isIframe) {
|
|
1077
|
+
const [path, existing] = splitPath(deps.currentPath());
|
|
1078
|
+
const params = new URLSearchParams(existing);
|
|
1079
|
+
if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
|
|
1080
|
+
params.delete(PARAM_SEGMENT);
|
|
1081
|
+
params.delete(PARAM_VARIANT);
|
|
1082
|
+
const query = params.toString();
|
|
1083
|
+
deps.navigate(query ? `${path}?${query}` : path);
|
|
1084
|
+
} else {
|
|
1085
|
+
deps.reload();
|
|
1086
|
+
}
|
|
1086
1087
|
}
|
|
1087
1088
|
}
|
|
1088
1089
|
if (before.toolbarOpen !== after.toolbarOpen) {
|
|
@@ -1392,7 +1393,10 @@ function u2(e2, t3, n2, o2, i2, u3) {
|
|
|
1392
1393
|
}
|
|
1393
1394
|
|
|
1394
1395
|
// src/core/ui/panel.tsx
|
|
1395
|
-
function RawSvg({
|
|
1396
|
+
function RawSvg({
|
|
1397
|
+
svg,
|
|
1398
|
+
className
|
|
1399
|
+
}) {
|
|
1396
1400
|
return /* @__PURE__ */ u2(
|
|
1397
1401
|
"span",
|
|
1398
1402
|
{
|
|
@@ -1963,9 +1967,7 @@ var PreprToolbarElement = class extends HTMLElementBase {
|
|
|
1963
1967
|
) ?? null;
|
|
1964
1968
|
}
|
|
1965
1969
|
optionsList() {
|
|
1966
|
-
return this.shadowRoot?.querySelector(
|
|
1967
|
-
'[data-prepr="options"]'
|
|
1968
|
-
) ?? null;
|
|
1970
|
+
return this.shadowRoot?.querySelector('[data-prepr="options"]') ?? null;
|
|
1969
1971
|
}
|
|
1970
1972
|
onListboxKeydown(event) {
|
|
1971
1973
|
const e2 = event;
|
|
@@ -2166,16 +2168,7 @@ function createPreprPreview(opts = {}) {
|
|
|
2166
2168
|
}
|
|
2167
2169
|
});
|
|
2168
2170
|
const autoClean = createStegaAutoClean();
|
|
2169
|
-
|
|
2170
|
-
function syncAutoClean(active) {
|
|
2171
|
-
if (active && !autoCleanActive) {
|
|
2172
|
-
autoClean.start();
|
|
2173
|
-
autoCleanActive = true;
|
|
2174
|
-
} else if (!active && autoCleanActive) {
|
|
2175
|
-
autoClean.stop();
|
|
2176
|
-
autoCleanActive = false;
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2171
|
+
autoClean.start();
|
|
2179
2172
|
const handleChange = createChangeHandler({
|
|
2180
2173
|
store,
|
|
2181
2174
|
features,
|
|
@@ -2183,8 +2176,7 @@ function createPreprPreview(opts = {}) {
|
|
|
2183
2176
|
navigate: (url) => navigation.navigate(url),
|
|
2184
2177
|
currentPath: () => navigation.currentPath(),
|
|
2185
2178
|
reload: navigation.reload ?? (() => window.location.reload()),
|
|
2186
|
-
stega
|
|
2187
|
-
syncAutoClean
|
|
2179
|
+
stega
|
|
2188
2180
|
});
|
|
2189
2181
|
let prev = store.get();
|
|
2190
2182
|
const unsubscribe = store.subscribe((state) => {
|
|
@@ -2192,20 +2184,23 @@ function createPreprPreview(opts = {}) {
|
|
|
2192
2184
|
prev = state;
|
|
2193
2185
|
handleChange(before, state);
|
|
2194
2186
|
});
|
|
2195
|
-
syncAutoClean(store.get().previewMode);
|
|
2196
2187
|
const bridge = createIframeBridge(store, {
|
|
2197
2188
|
allowedEditorOrigins: options?.allowedEditorOrigins
|
|
2198
2189
|
});
|
|
2199
|
-
sendPreprEvent(
|
|
2200
|
-
|
|
2201
|
-
|
|
2190
|
+
sendPreprEvent(
|
|
2191
|
+
"getScrollPosition",
|
|
2192
|
+
{ value: 0 },
|
|
2193
|
+
{
|
|
2194
|
+
allowUntrustedTarget: true
|
|
2195
|
+
}
|
|
2196
|
+
);
|
|
2202
2197
|
if (isIframe) {
|
|
2203
2198
|
bridge.start();
|
|
2204
2199
|
}
|
|
2205
2200
|
function destroy() {
|
|
2206
2201
|
unsubscribe();
|
|
2207
2202
|
stega.stop();
|
|
2208
|
-
|
|
2203
|
+
autoClean.stop();
|
|
2209
2204
|
if (isIframe) {
|
|
2210
2205
|
bridge.stop();
|
|
2211
2206
|
}
|
|
@@ -2267,7 +2262,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
2267
2262
|
}
|
|
2268
2263
|
function validatePreprToken(token) {
|
|
2269
2264
|
if (!token) {
|
|
2270
|
-
throw new PreprError(
|
|
2265
|
+
throw new PreprError(
|
|
2266
|
+
"Token is required",
|
|
2267
|
+
"MISSING_TOKEN",
|
|
2268
|
+
"validatePreprToken"
|
|
2269
|
+
);
|
|
2271
2270
|
}
|
|
2272
2271
|
if (!token.startsWith("https://")) {
|
|
2273
2272
|
throw new PreprError(
|
|
@@ -2394,7 +2393,11 @@ function parseCookies(request) {
|
|
|
2394
2393
|
const name = part.slice(0, eq).trim();
|
|
2395
2394
|
const value = part.slice(eq + 1).trim();
|
|
2396
2395
|
if (!name) continue;
|
|
2397
|
-
|
|
2396
|
+
try {
|
|
2397
|
+
cookies.set(name, decodeURIComponent(value));
|
|
2398
|
+
} catch {
|
|
2399
|
+
cookies.set(name, value);
|
|
2400
|
+
}
|
|
2398
2401
|
}
|
|
2399
2402
|
return cookies;
|
|
2400
2403
|
}
|
|
@@ -2433,7 +2436,10 @@ function processPreprRequest(request, opts) {
|
|
|
2433
2436
|
if (userAgent) {
|
|
2434
2437
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
2435
2438
|
}
|
|
2436
|
-
requestHeaders.set(
|
|
2439
|
+
requestHeaders.set(
|
|
2440
|
+
"Prepr-Package",
|
|
2441
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
2442
|
+
);
|
|
2437
2443
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
2438
2444
|
if (ip) {
|
|
2439
2445
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -2442,7 +2448,7 @@ function processPreprRequest(request, opts) {
|
|
|
2442
2448
|
if (hutkCookie) {
|
|
2443
2449
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
2444
2450
|
}
|
|
2445
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
2451
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
2446
2452
|
if (!uid) {
|
|
2447
2453
|
uid = crypto.randomUUID();
|
|
2448
2454
|
responseCookies.push({
|
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.2.0-beta.
|
|
8
|
+
declare const VERSION = "0.2.0-beta.9";
|
|
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.2.0-beta.
|
|
8
|
+
declare const VERSION = "0.2.0-beta.9";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
|
package/dist/index.js
CHANGED
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
setTrackingParam,
|
|
18
18
|
stegaClean,
|
|
19
19
|
trackEvent
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JVUG6S4O.js";
|
|
21
21
|
|
|
22
22
|
// src/version.ts
|
|
23
|
-
var VERSION = "0.2.0-beta.
|
|
23
|
+
var VERSION = "0.2.0-beta.9";
|
|
24
24
|
|
|
25
25
|
// src/core/server.ts
|
|
26
26
|
var PreprError = class extends Error {
|
|
@@ -72,7 +72,11 @@ function getPreprHeadersFromHeaders(headers) {
|
|
|
72
72
|
}
|
|
73
73
|
function validatePreprToken(token) {
|
|
74
74
|
if (!token) {
|
|
75
|
-
throw new PreprError(
|
|
75
|
+
throw new PreprError(
|
|
76
|
+
"Token is required",
|
|
77
|
+
"MISSING_TOKEN",
|
|
78
|
+
"validatePreprToken"
|
|
79
|
+
);
|
|
76
80
|
}
|
|
77
81
|
if (!token.startsWith("https://")) {
|
|
78
82
|
throw new PreprError(
|
|
@@ -199,7 +203,11 @@ function parseCookies(request) {
|
|
|
199
203
|
const name = part.slice(0, eq).trim();
|
|
200
204
|
const value = part.slice(eq + 1).trim();
|
|
201
205
|
if (!name) continue;
|
|
202
|
-
|
|
206
|
+
try {
|
|
207
|
+
cookies.set(name, decodeURIComponent(value));
|
|
208
|
+
} catch {
|
|
209
|
+
cookies.set(name, value);
|
|
210
|
+
}
|
|
203
211
|
}
|
|
204
212
|
return cookies;
|
|
205
213
|
}
|
|
@@ -238,7 +246,10 @@ function processPreprRequest(request, opts) {
|
|
|
238
246
|
if (userAgent) {
|
|
239
247
|
requestHeaders.set("Prepr-User-Agent", sanitizeHeaderValue(userAgent));
|
|
240
248
|
}
|
|
241
|
-
requestHeaders.set(
|
|
249
|
+
requestHeaders.set(
|
|
250
|
+
"Prepr-Package",
|
|
251
|
+
`@preprio/toolkit@${opts?.version ?? VERSION}`
|
|
252
|
+
);
|
|
242
253
|
const ip = request.headers.get("Cf-Connecting-Ip") ?? request.headers.get("x-real-ip");
|
|
243
254
|
if (ip) {
|
|
244
255
|
requestHeaders.set("Prepr-Visitor-IP", sanitizeHeaderValue(ip));
|
|
@@ -247,7 +258,7 @@ function processPreprRequest(request, opts) {
|
|
|
247
258
|
if (hutkCookie) {
|
|
248
259
|
requestHeaders.set("Prepr-Hubspot-Id", sanitizeHeaderValue(hutkCookie));
|
|
249
260
|
}
|
|
250
|
-
let uid = requestCookies.get(COOKIE_UID);
|
|
261
|
+
let uid = sanitizeHeaderValue(requestCookies.get(COOKIE_UID) ?? "");
|
|
251
262
|
if (!uid) {
|
|
252
263
|
uid = crypto.randomUUID();
|
|
253
264
|
responseCookies.push({
|