@preprio/toolkit 0.2.0-beta.6 → 0.2.0-beta.7

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.
@@ -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.6";
33
+ var VERSION = "0.2.0-beta.7";
34
34
 
35
35
  // src/core/features.ts
36
36
  function isEnabled(config) {
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.2.0-beta.6";
2
+ var VERSION = "0.2.0-beta.7";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -644,6 +644,8 @@ function createStegaAutoClean() {
644
644
  function scanAndClean() {
645
645
  processing = true;
646
646
  walkTextNodes(document.body, cleanTextNode);
647
+ const title = vercelStegaSplit(document.title);
648
+ if (title.encoded) document.title = title.cleaned;
647
649
  processing = false;
648
650
  }
649
651
  function collectAffected(mutations) {
@@ -689,15 +691,8 @@ function createStegaAutoClean() {
689
691
  }
690
692
  function start() {
691
693
  if (observer || typeof window === "undefined") return;
692
- const run = () => {
693
- scanAndClean();
694
- setupObserver();
695
- };
696
- if ("requestIdleCallback" in window) {
697
- window.requestIdleCallback(run);
698
- } else {
699
- setTimeout(run, 0);
700
- }
694
+ scanAndClean();
695
+ setupObserver();
701
696
  debug6.log("stega auto-clean started");
702
697
  }
703
698
  function stop() {
@@ -1934,7 +1929,7 @@ function cookieOpts() {
1934
1929
  };
1935
1930
  }
1936
1931
  function createChangeHandler(deps) {
1937
- const { store, stega, syncAutoClean, features, editingEnabled } = deps;
1932
+ const { store, stega, features, editingEnabled } = deps;
1938
1933
  function updateParams(patch) {
1939
1934
  const [path, existing] = splitPath(deps.currentPath());
1940
1935
  const params = new URLSearchParams(existing);
@@ -1997,16 +1992,17 @@ function createChangeHandler(deps) {
1997
1992
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1998
1993
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1999
1994
  sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
2000
- syncAutoClean(after.previewMode);
2001
- const [path, existing] = splitPath(deps.currentPath());
2002
- const params = new URLSearchParams(existing);
2003
- if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
2004
- params.delete(PARAM_SEGMENT);
2005
- params.delete(PARAM_VARIANT);
2006
- const query = params.toString();
2007
- deps.navigate(query ? `${path}?${query}` : path);
2008
- } else {
2009
- deps.reload();
1995
+ if (!after.isIframe) {
1996
+ const [path, existing] = splitPath(deps.currentPath());
1997
+ const params = new URLSearchParams(existing);
1998
+ if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1999
+ params.delete(PARAM_SEGMENT);
2000
+ params.delete(PARAM_VARIANT);
2001
+ const query = params.toString();
2002
+ deps.navigate(query ? `${path}?${query}` : path);
2003
+ } else {
2004
+ deps.reload();
2005
+ }
2010
2006
  }
2011
2007
  }
2012
2008
  if (before.toolbarOpen !== after.toolbarOpen) {
@@ -2118,16 +2114,7 @@ function createPreprPreview(opts = {}) {
2118
2114
  }
2119
2115
  });
2120
2116
  const autoClean = createStegaAutoClean();
2121
- let autoCleanActive = false;
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
- }
2117
+ autoClean.start();
2131
2118
  const handleChange = createChangeHandler({
2132
2119
  store,
2133
2120
  features,
@@ -2135,8 +2122,7 @@ function createPreprPreview(opts = {}) {
2135
2122
  navigate: (url) => navigation.navigate(url),
2136
2123
  currentPath: () => navigation.currentPath(),
2137
2124
  reload: navigation.reload ?? (() => window.location.reload()),
2138
- stega,
2139
- syncAutoClean
2125
+ stega
2140
2126
  });
2141
2127
  let prev = store.get();
2142
2128
  const unsubscribe = store.subscribe((state) => {
@@ -2144,7 +2130,6 @@ function createPreprPreview(opts = {}) {
2144
2130
  prev = state;
2145
2131
  handleChange(before, state);
2146
2132
  });
2147
- syncAutoClean(store.get().previewMode);
2148
2133
  const bridge = createIframeBridge(store, {
2149
2134
  allowedEditorOrigins: options?.allowedEditorOrigins
2150
2135
  });
@@ -2157,7 +2142,7 @@ function createPreprPreview(opts = {}) {
2157
2142
  function destroy() {
2158
2143
  unsubscribe();
2159
2144
  stega.stop();
2160
- syncAutoClean(false);
2145
+ autoClean.stop();
2161
2146
  if (isIframe) {
2162
2147
  bridge.stop();
2163
2148
  }
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.6";
47
+ var VERSION = "0.2.0-beta.7";
48
48
 
49
49
  // src/core/features.ts
50
50
  function isEnabled(config) {
@@ -464,6 +464,8 @@ function createStegaAutoClean() {
464
464
  function scanAndClean() {
465
465
  processing = true;
466
466
  walkTextNodes(document.body, cleanTextNode);
467
+ const title = (0, import_stega2.vercelStegaSplit)(document.title);
468
+ if (title.encoded) document.title = title.cleaned;
467
469
  processing = false;
468
470
  }
469
471
  function collectAffected(mutations) {
@@ -509,15 +511,8 @@ function createStegaAutoClean() {
509
511
  }
510
512
  function start() {
511
513
  if (observer || typeof window === "undefined") return;
512
- const run = () => {
513
- scanAndClean();
514
- setupObserver();
515
- };
516
- if ("requestIdleCallback" in window) {
517
- window.requestIdleCallback(run);
518
- } else {
519
- setTimeout(run, 0);
520
- }
514
+ scanAndClean();
515
+ setupObserver();
521
516
  debug2.log("stega auto-clean started");
522
517
  }
523
518
  function stop() {
@@ -1010,7 +1005,7 @@ function cookieOpts() {
1010
1005
  };
1011
1006
  }
1012
1007
  function createChangeHandler(deps) {
1013
- const { store, stega, syncAutoClean, features, editingEnabled } = deps;
1008
+ const { store, stega, features, editingEnabled } = deps;
1014
1009
  function updateParams(patch) {
1015
1010
  const [path, existing] = splitPath(deps.currentPath());
1016
1011
  const params = new URLSearchParams(existing);
@@ -1073,16 +1068,17 @@ function createChangeHandler(deps) {
1073
1068
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1074
1069
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1075
1070
  sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1076
- syncAutoClean(after.previewMode);
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();
1071
+ if (!after.isIframe) {
1072
+ const [path, existing] = splitPath(deps.currentPath());
1073
+ const params = new URLSearchParams(existing);
1074
+ if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1075
+ params.delete(PARAM_SEGMENT);
1076
+ params.delete(PARAM_VARIANT);
1077
+ const query = params.toString();
1078
+ deps.navigate(query ? `${path}?${query}` : path);
1079
+ } else {
1080
+ deps.reload();
1081
+ }
1086
1082
  }
1087
1083
  }
1088
1084
  if (before.toolbarOpen !== after.toolbarOpen) {
@@ -2166,16 +2162,7 @@ function createPreprPreview(opts = {}) {
2166
2162
  }
2167
2163
  });
2168
2164
  const autoClean = createStegaAutoClean();
2169
- let autoCleanActive = false;
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
- }
2165
+ autoClean.start();
2179
2166
  const handleChange = createChangeHandler({
2180
2167
  store,
2181
2168
  features,
@@ -2183,8 +2170,7 @@ function createPreprPreview(opts = {}) {
2183
2170
  navigate: (url) => navigation.navigate(url),
2184
2171
  currentPath: () => navigation.currentPath(),
2185
2172
  reload: navigation.reload ?? (() => window.location.reload()),
2186
- stega,
2187
- syncAutoClean
2173
+ stega
2188
2174
  });
2189
2175
  let prev = store.get();
2190
2176
  const unsubscribe = store.subscribe((state) => {
@@ -2192,7 +2178,6 @@ function createPreprPreview(opts = {}) {
2192
2178
  prev = state;
2193
2179
  handleChange(before, state);
2194
2180
  });
2195
- syncAutoClean(store.get().previewMode);
2196
2181
  const bridge = createIframeBridge(store, {
2197
2182
  allowedEditorOrigins: options?.allowedEditorOrigins
2198
2183
  });
@@ -2205,7 +2190,7 @@ function createPreprPreview(opts = {}) {
2205
2190
  function destroy() {
2206
2191
  unsubscribe();
2207
2192
  stega.stop();
2208
- syncAutoClean(false);
2193
+ autoClean.stop();
2209
2194
  if (isIframe) {
2210
2195
  bridge.stop();
2211
2196
  }
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.6";
8
+ declare const VERSION = "0.2.0-beta.7";
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.6";
8
+ declare const VERSION = "0.2.0-beta.7";
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-C6YEXA5G.js";
20
+ } from "./chunk-P6VTLWM4.js";
21
21
 
22
22
  // src/version.ts
23
- var VERSION = "0.2.0-beta.6";
23
+ var VERSION = "0.2.0-beta.7";
24
24
 
25
25
  // src/core/server.ts
26
26
  var PreprError = class extends Error {
@@ -440,6 +440,8 @@ function createStegaAutoClean() {
440
440
  function scanAndClean() {
441
441
  processing = true;
442
442
  walkTextNodes(document.body, cleanTextNode);
443
+ const title = (0, import_stega2.vercelStegaSplit)(document.title);
444
+ if (title.encoded) document.title = title.cleaned;
443
445
  processing = false;
444
446
  }
445
447
  function collectAffected(mutations) {
@@ -485,15 +487,8 @@ function createStegaAutoClean() {
485
487
  }
486
488
  function start() {
487
489
  if (observer || typeof window === "undefined") return;
488
- const run = () => {
489
- scanAndClean();
490
- setupObserver();
491
- };
492
- if ("requestIdleCallback" in window) {
493
- window.requestIdleCallback(run);
494
- } else {
495
- setTimeout(run, 0);
496
- }
490
+ scanAndClean();
491
+ setupObserver();
497
492
  debug2.log("stega auto-clean started");
498
493
  }
499
494
  function stop() {
@@ -986,7 +981,7 @@ function cookieOpts() {
986
981
  };
987
982
  }
988
983
  function createChangeHandler(deps) {
989
- const { store, stega, syncAutoClean, features, editingEnabled } = deps;
984
+ const { store, stega, features, editingEnabled } = deps;
990
985
  function updateParams(patch) {
991
986
  const [path, existing] = splitPath(deps.currentPath());
992
987
  const params = new URLSearchParams(existing);
@@ -1049,16 +1044,17 @@ function createChangeHandler(deps) {
1049
1044
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1050
1045
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1051
1046
  sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1052
- syncAutoClean(after.previewMode);
1053
- const [path, existing] = splitPath(deps.currentPath());
1054
- const params = new URLSearchParams(existing);
1055
- if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1056
- params.delete(PARAM_SEGMENT);
1057
- params.delete(PARAM_VARIANT);
1058
- const query = params.toString();
1059
- deps.navigate(query ? `${path}?${query}` : path);
1060
- } else {
1061
- deps.reload();
1047
+ if (!after.isIframe) {
1048
+ const [path, existing] = splitPath(deps.currentPath());
1049
+ const params = new URLSearchParams(existing);
1050
+ if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1051
+ params.delete(PARAM_SEGMENT);
1052
+ params.delete(PARAM_VARIANT);
1053
+ const query = params.toString();
1054
+ deps.navigate(query ? `${path}?${query}` : path);
1055
+ } else {
1056
+ deps.reload();
1057
+ }
1062
1058
  }
1063
1059
  }
1064
1060
  if (before.toolbarOpen !== after.toolbarOpen) {
@@ -2142,16 +2138,7 @@ function createPreprPreview(opts = {}) {
2142
2138
  }
2143
2139
  });
2144
2140
  const autoClean = createStegaAutoClean();
2145
- let autoCleanActive = false;
2146
- function syncAutoClean(active) {
2147
- if (active && !autoCleanActive) {
2148
- autoClean.start();
2149
- autoCleanActive = true;
2150
- } else if (!active && autoCleanActive) {
2151
- autoClean.stop();
2152
- autoCleanActive = false;
2153
- }
2154
- }
2141
+ autoClean.start();
2155
2142
  const handleChange = createChangeHandler({
2156
2143
  store,
2157
2144
  features,
@@ -2159,8 +2146,7 @@ function createPreprPreview(opts = {}) {
2159
2146
  navigate: (url) => navigation.navigate(url),
2160
2147
  currentPath: () => navigation.currentPath(),
2161
2148
  reload: navigation.reload ?? (() => window.location.reload()),
2162
- stega,
2163
- syncAutoClean
2149
+ stega
2164
2150
  });
2165
2151
  let prev = store.get();
2166
2152
  const unsubscribe = store.subscribe((state) => {
@@ -2168,7 +2154,6 @@ function createPreprPreview(opts = {}) {
2168
2154
  prev = state;
2169
2155
  handleChange(before, state);
2170
2156
  });
2171
- syncAutoClean(store.get().previewMode);
2172
2157
  const bridge = createIframeBridge(store, {
2173
2158
  allowedEditorOrigins: options?.allowedEditorOrigins
2174
2159
  });
@@ -2181,7 +2166,7 @@ function createPreprPreview(opts = {}) {
2181
2166
  function destroy() {
2182
2167
  unsubscribe();
2183
2168
  stega.stop();
2184
- syncAutoClean(false);
2169
+ autoClean.stop();
2185
2170
  if (isIframe) {
2186
2171
  bridge.stop();
2187
2172
  }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createPreprPreview,
4
4
  loadTrackingPixel
5
- } from "../chunk-C6YEXA5G.js";
5
+ } from "../chunk-P6VTLWM4.js";
6
6
 
7
7
  // src/nextjs/components.ts
8
8
  import { usePathname, useRouter } from "next/navigation";
@@ -38,7 +38,7 @@ module.exports = __toCommonJS(nextjs_exports);
38
38
  var import_server = require("next/server");
39
39
 
40
40
  // src/version.ts
41
- var VERSION = "0.2.0-beta.6";
41
+ var VERSION = "0.2.0-beta.7";
42
42
 
43
43
  // src/core/constants.ts
44
44
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -2,7 +2,7 @@
2
2
  import { NextResponse } from "next/server";
3
3
 
4
4
  // src/version.ts
5
- var VERSION = "0.2.0-beta.6";
5
+ var VERSION = "0.2.0-beta.7";
6
6
 
7
7
  // src/core/constants.ts
8
8
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -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-beta.6";
38
+ var VERSION = "0.2.0-beta.7";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.2.0-beta.6";
2
+ var VERSION = "0.2.0-beta.7";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -439,6 +439,8 @@ function createStegaAutoClean() {
439
439
  function scanAndClean() {
440
440
  processing = true;
441
441
  walkTextNodes(document.body, cleanTextNode);
442
+ const title = (0, import_stega2.vercelStegaSplit)(document.title);
443
+ if (title.encoded) document.title = title.cleaned;
442
444
  processing = false;
443
445
  }
444
446
  function collectAffected(mutations) {
@@ -484,15 +486,8 @@ function createStegaAutoClean() {
484
486
  }
485
487
  function start() {
486
488
  if (observer || typeof window === "undefined") return;
487
- const run = () => {
488
- scanAndClean();
489
- setupObserver();
490
- };
491
- if ("requestIdleCallback" in window) {
492
- window.requestIdleCallback(run);
493
- } else {
494
- setTimeout(run, 0);
495
- }
489
+ scanAndClean();
490
+ setupObserver();
496
491
  debug2.log("stega auto-clean started");
497
492
  }
498
493
  function stop() {
@@ -985,7 +980,7 @@ function cookieOpts() {
985
980
  };
986
981
  }
987
982
  function createChangeHandler(deps) {
988
- const { store, stega, syncAutoClean, features, editingEnabled } = deps;
983
+ const { store, stega, features, editingEnabled } = deps;
989
984
  function updateParams(patch) {
990
985
  const [path, existing] = splitPath(deps.currentPath());
991
986
  const params = new URLSearchParams(existing);
@@ -1048,16 +1043,17 @@ function createChangeHandler(deps) {
1048
1043
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1049
1044
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1050
1045
  sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1051
- syncAutoClean(after.previewMode);
1052
- const [path, existing] = splitPath(deps.currentPath());
1053
- const params = new URLSearchParams(existing);
1054
- if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1055
- params.delete(PARAM_SEGMENT);
1056
- params.delete(PARAM_VARIANT);
1057
- const query = params.toString();
1058
- deps.navigate(query ? `${path}?${query}` : path);
1059
- } else {
1060
- deps.reload();
1046
+ if (!after.isIframe) {
1047
+ const [path, existing] = splitPath(deps.currentPath());
1048
+ const params = new URLSearchParams(existing);
1049
+ if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1050
+ params.delete(PARAM_SEGMENT);
1051
+ params.delete(PARAM_VARIANT);
1052
+ const query = params.toString();
1053
+ deps.navigate(query ? `${path}?${query}` : path);
1054
+ } else {
1055
+ deps.reload();
1056
+ }
1061
1057
  }
1062
1058
  }
1063
1059
  if (before.toolbarOpen !== after.toolbarOpen) {
@@ -2141,16 +2137,7 @@ function createPreprPreview(opts = {}) {
2141
2137
  }
2142
2138
  });
2143
2139
  const autoClean = createStegaAutoClean();
2144
- let autoCleanActive = false;
2145
- function syncAutoClean(active) {
2146
- if (active && !autoCleanActive) {
2147
- autoClean.start();
2148
- autoCleanActive = true;
2149
- } else if (!active && autoCleanActive) {
2150
- autoClean.stop();
2151
- autoCleanActive = false;
2152
- }
2153
- }
2140
+ autoClean.start();
2154
2141
  const handleChange = createChangeHandler({
2155
2142
  store,
2156
2143
  features,
@@ -2158,8 +2145,7 @@ function createPreprPreview(opts = {}) {
2158
2145
  navigate: (url) => navigation.navigate(url),
2159
2146
  currentPath: () => navigation.currentPath(),
2160
2147
  reload: navigation.reload ?? (() => window.location.reload()),
2161
- stega,
2162
- syncAutoClean
2148
+ stega
2163
2149
  });
2164
2150
  let prev = store.get();
2165
2151
  const unsubscribe = store.subscribe((state) => {
@@ -2167,7 +2153,6 @@ function createPreprPreview(opts = {}) {
2167
2153
  prev = state;
2168
2154
  handleChange(before, state);
2169
2155
  });
2170
- syncAutoClean(store.get().previewMode);
2171
2156
  const bridge = createIframeBridge(store, {
2172
2157
  allowedEditorOrigins: options?.allowedEditorOrigins
2173
2158
  });
@@ -2180,7 +2165,7 @@ function createPreprPreview(opts = {}) {
2180
2165
  function destroy() {
2181
2166
  unsubscribe();
2182
2167
  stega.stop();
2183
- syncAutoClean(false);
2168
+ autoClean.stop();
2184
2169
  if (isIframe) {
2185
2170
  bridge.stop();
2186
2171
  }
@@ -415,6 +415,8 @@ function createStegaAutoClean() {
415
415
  function scanAndClean() {
416
416
  processing = true;
417
417
  walkTextNodes(document.body, cleanTextNode);
418
+ const title = vercelStegaSplit(document.title);
419
+ if (title.encoded) document.title = title.cleaned;
418
420
  processing = false;
419
421
  }
420
422
  function collectAffected(mutations) {
@@ -460,15 +462,8 @@ function createStegaAutoClean() {
460
462
  }
461
463
  function start() {
462
464
  if (observer || typeof window === "undefined") return;
463
- const run = () => {
464
- scanAndClean();
465
- setupObserver();
466
- };
467
- if ("requestIdleCallback" in window) {
468
- window.requestIdleCallback(run);
469
- } else {
470
- setTimeout(run, 0);
471
- }
465
+ scanAndClean();
466
+ setupObserver();
472
467
  debug2.log("stega auto-clean started");
473
468
  }
474
469
  function stop() {
@@ -961,7 +956,7 @@ function cookieOpts() {
961
956
  };
962
957
  }
963
958
  function createChangeHandler(deps) {
964
- const { store, stega, syncAutoClean, features, editingEnabled } = deps;
959
+ const { store, stega, features, editingEnabled } = deps;
965
960
  function updateParams(patch) {
966
961
  const [path, existing] = splitPath(deps.currentPath());
967
962
  const params = new URLSearchParams(existing);
@@ -1024,16 +1019,17 @@ function createChangeHandler(deps) {
1024
1019
  setCookie(COOKIE_PREVIEW_MODE, String(after.previewMode), cookieOpts());
1025
1020
  setCookie(COOKIE_TOOLBAR_OPEN, "false", cookieOpts());
1026
1021
  sendPreprEvent("preview_mode_toggled", { previewMode: after.previewMode });
1027
- syncAutoClean(after.previewMode);
1028
- const [path, existing] = splitPath(deps.currentPath());
1029
- const params = new URLSearchParams(existing);
1030
- if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1031
- params.delete(PARAM_SEGMENT);
1032
- params.delete(PARAM_VARIANT);
1033
- const query = params.toString();
1034
- deps.navigate(query ? `${path}?${query}` : path);
1035
- } else {
1036
- deps.reload();
1022
+ if (!after.isIframe) {
1023
+ const [path, existing] = splitPath(deps.currentPath());
1024
+ const params = new URLSearchParams(existing);
1025
+ if (params.has(PARAM_SEGMENT) || params.has(PARAM_VARIANT)) {
1026
+ params.delete(PARAM_SEGMENT);
1027
+ params.delete(PARAM_VARIANT);
1028
+ const query = params.toString();
1029
+ deps.navigate(query ? `${path}?${query}` : path);
1030
+ } else {
1031
+ deps.reload();
1032
+ }
1037
1033
  }
1038
1034
  }
1039
1035
  if (before.toolbarOpen !== after.toolbarOpen) {
@@ -2117,16 +2113,7 @@ function createPreprPreview(opts = {}) {
2117
2113
  }
2118
2114
  });
2119
2115
  const autoClean = createStegaAutoClean();
2120
- let autoCleanActive = false;
2121
- function syncAutoClean(active) {
2122
- if (active && !autoCleanActive) {
2123
- autoClean.start();
2124
- autoCleanActive = true;
2125
- } else if (!active && autoCleanActive) {
2126
- autoClean.stop();
2127
- autoCleanActive = false;
2128
- }
2129
- }
2116
+ autoClean.start();
2130
2117
  const handleChange = createChangeHandler({
2131
2118
  store,
2132
2119
  features,
@@ -2134,8 +2121,7 @@ function createPreprPreview(opts = {}) {
2134
2121
  navigate: (url) => navigation.navigate(url),
2135
2122
  currentPath: () => navigation.currentPath(),
2136
2123
  reload: navigation.reload ?? (() => window.location.reload()),
2137
- stega,
2138
- syncAutoClean
2124
+ stega
2139
2125
  });
2140
2126
  let prev = store.get();
2141
2127
  const unsubscribe = store.subscribe((state) => {
@@ -2143,7 +2129,6 @@ function createPreprPreview(opts = {}) {
2143
2129
  prev = state;
2144
2130
  handleChange(before, state);
2145
2131
  });
2146
- syncAutoClean(store.get().previewMode);
2147
2132
  const bridge = createIframeBridge(store, {
2148
2133
  allowedEditorOrigins: options?.allowedEditorOrigins
2149
2134
  });
@@ -2156,7 +2141,7 @@ function createPreprPreview(opts = {}) {
2156
2141
  function destroy() {
2157
2142
  unsubscribe();
2158
2143
  stega.stop();
2159
- syncAutoClean(false);
2144
+ autoClean.stop();
2160
2145
  if (isIframe) {
2161
2146
  bridge.stop();
2162
2147
  }
@@ -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.6";
38
+ var VERSION = "0.2.0-beta.7";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.2.0-beta.6";
2
+ var VERSION = "0.2.0-beta.7";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preprio/toolkit",
3
- "version": "0.2.0-beta.6",
3
+ "version": "0.2.0-beta.7",
4
4
  "description": "Prepr personalization, A/B testing and preview toolkit for React, Next.js, Nuxt, Astro, SvelteKit and Express",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Prepr B.V. (https://prepr.io)",
@@ -94,6 +94,16 @@
94
94
  "src/sveltekit/*.svelte",
95
95
  "src/nuxt/*.vue"
96
96
  ],
97
+ "scripts": {
98
+ "gen:css": "node scripts/compile-css.mjs",
99
+ "prebuild": "rm -rf dist && pnpm gen:css && node scripts/check-version.mjs",
100
+ "pretest": "pnpm gen:css",
101
+ "pretypecheck": "pnpm gen:css",
102
+ "build": "tsup",
103
+ "postbuild": "node scripts/check-exports.mjs",
104
+ "test": "vitest run",
105
+ "typecheck": "tsc --noEmit"
106
+ },
97
107
  "dependencies": {
98
108
  "@vercel/stega": "^1.1.0",
99
109
  "preact": "^10.29.7"
@@ -135,15 +145,5 @@
135
145
  "tsup": "^8.5.1",
136
146
  "typescript": "^5.9.3",
137
147
  "vitest": "^4.1.10"
138
- },
139
- "scripts": {
140
- "gen:css": "node scripts/compile-css.mjs",
141
- "prebuild": "rm -rf dist && pnpm gen:css && node scripts/check-version.mjs",
142
- "pretest": "pnpm gen:css",
143
- "pretypecheck": "pnpm gen:css",
144
- "build": "tsup",
145
- "postbuild": "node scripts/check-exports.mjs",
146
- "test": "vitest run",
147
- "typecheck": "tsc --noEmit"
148
148
  }
149
- }
149
+ }