@preprio/toolkit 1.0.0-rc.3 → 1.0.0-rc.4

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.
@@ -34,7 +34,7 @@ __export(astro_exports, {
34
34
  module.exports = __toCommonJS(astro_exports);
35
35
 
36
36
  // src/version.ts
37
- var VERSION = "1.0.0-rc.3";
37
+ var VERSION = "1.0.0-rc.4";
38
38
 
39
39
  // src/core/constants.ts
40
40
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "1.0.0-rc.3";
2
+ var VERSION = "1.0.0-rc.4";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  VERSION,
3
3
  resolveFeatures
4
- } from "./chunk-EJDHVIFU.js";
4
+ } from "./chunk-QWTSVPEQ.js";
5
5
 
6
6
  // src/core/server.ts
7
7
  var PreprError = class extends Error {
@@ -2,7 +2,7 @@ import {
2
2
  ALL_FEATURES_ENABLED,
3
3
  VERSION,
4
4
  resolveFeatures
5
- } from "./chunk-EJDHVIFU.js";
5
+ } from "./chunk-QWTSVPEQ.js";
6
6
  import {
7
7
  createIframeBridge,
8
8
  isLocale,
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "1.0.0-rc.3";
2
+ var VERSION = "1.0.0-rc.4";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
package/dist/index.cjs CHANGED
@@ -51,7 +51,7 @@ __export(src_exports, {
51
51
  module.exports = __toCommonJS(src_exports);
52
52
 
53
53
  // src/version.ts
54
- var VERSION = "1.0.0-rc.3";
54
+ var VERSION = "1.0.0-rc.4";
55
55
 
56
56
  // src/core/features.ts
57
57
  function isEnabled(config) {
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 = "1.0.0-rc.3";
8
+ declare const VERSION = "1.0.0-rc.4";
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 = "1.0.0-rc.3";
8
+ declare const VERSION = "1.0.0-rc.4";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  setTrackingParam,
9
9
  stegaClean,
10
10
  trackEvent
11
- } from "./chunk-PI5HUQ6G.js";
11
+ } from "./chunk-K62RW46G.js";
12
12
  import {
13
13
  PreprError,
14
14
  extractAccessToken,
@@ -19,11 +19,11 @@ import {
19
19
  getPreprUUIDFromHeaders,
20
20
  getToolbarPropsFromHeaders,
21
21
  validatePreprToken
22
- } from "./chunk-N6CXRQQP.js";
22
+ } from "./chunk-6PMBN7OR.js";
23
23
  import {
24
24
  VERSION,
25
25
  resolveFeatures
26
- } from "./chunk-EJDHVIFU.js";
26
+ } from "./chunk-QWTSVPEQ.js";
27
27
  import {
28
28
  createLiveBridge,
29
29
  createLiveStore
@@ -3707,7 +3707,7 @@ function createPreprPreview(opts = {}) {
3707
3707
  var import_react = require("react");
3708
3708
 
3709
3709
  // src/version.ts
3710
- var VERSION = "1.0.0-rc.3";
3710
+ var VERSION = "1.0.0-rc.4";
3711
3711
 
3712
3712
  // src/core/pixel.ts
3713
3713
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  createPreprPreview,
4
4
  loadTrackingPixel
5
- } from "../chunk-PI5HUQ6G.js";
6
- import "../chunk-EJDHVIFU.js";
5
+ } from "../chunk-K62RW46G.js";
6
+ import "../chunk-QWTSVPEQ.js";
7
7
  import "../chunk-Y7JWV7WV.js";
8
8
  import "../chunk-UTKH7DOI.js";
9
9
  import "../chunk-V7MCHPE7.js";
@@ -49,7 +49,7 @@ module.exports = __toCommonJS(nextjs_exports);
49
49
  var import_server = require("next/server");
50
50
 
51
51
  // src/version.ts
52
- var VERSION = "1.0.0-rc.3";
52
+ var VERSION = "1.0.0-rc.4";
53
53
 
54
54
  // src/core/constants.ts
55
55
  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 = "1.0.0-rc.3";
5
+ var VERSION = "1.0.0-rc.4";
6
6
 
7
7
  // src/core/constants.ts
8
8
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -1,8 +1,8 @@
1
1
  "use server";
2
2
  import {
3
3
  isPreviewFromHeaders
4
- } from "../chunk-N6CXRQQP.js";
5
- import "../chunk-EJDHVIFU.js";
4
+ } from "../chunk-6PMBN7OR.js";
5
+ import "../chunk-QWTSVPEQ.js";
6
6
  import {
7
7
  parsePatchLog
8
8
  } from "../chunk-KM2GME62.js";
@@ -1953,12 +1953,15 @@ function createLogSync() {
1953
1953
  let pending = null;
1954
1954
  let cancelled = false;
1955
1955
  let lastGood = [];
1956
+ let stopSettling = null;
1956
1957
  const send = async (incoming) => {
1957
1958
  const skipped = new Set(quarantined());
1958
1959
  const log = skipped.size ? incoming.filter((patch) => !skipped.has(patchKey(patch))) : incoming;
1959
1960
  if (!log.length) return;
1960
1961
  inFlight = true;
1961
- const stopWatching = showsPreprContent() ? watchUntilSettled(() => recoverFrom(log, lastGood)) : () => {
1962
+ const watch = stopSettling !== null || showsPreprContent();
1963
+ stopSettling?.();
1964
+ const stopWatching = watch ? watchUntilSettled(() => recoverFrom(log, lastGood)) : () => {
1962
1965
  };
1963
1966
  let failed = false;
1964
1967
  try {
@@ -1967,11 +1970,21 @@ function createLogSync() {
1967
1970
  failed = true;
1968
1971
  debug6.log("sending unsaved changes failed", error);
1969
1972
  }
1970
- await new Promise((resolve) => setTimeout(resolve, RENDER_SETTLE_MS));
1971
- stopWatching();
1972
1973
  inFlight = false;
1973
- if (recovering) return;
1974
- if (!failed) lastGood = log;
1974
+ if (recovering) {
1975
+ stopWatching();
1976
+ return;
1977
+ }
1978
+ const settle = setTimeout(() => {
1979
+ stopSettling = null;
1980
+ stopWatching();
1981
+ if (!failed && !recovering) lastGood = log;
1982
+ }, RENDER_SETTLE_MS);
1983
+ stopSettling = watch ? () => {
1984
+ clearTimeout(settle);
1985
+ stopWatching();
1986
+ stopSettling = null;
1987
+ } : null;
1975
1988
  if (pending && !cancelled) {
1976
1989
  const next = pending;
1977
1990
  pending = null;
@@ -231,12 +231,15 @@ function createLogSync() {
231
231
  let pending = null;
232
232
  let cancelled = false;
233
233
  let lastGood = [];
234
+ let stopSettling = null;
234
235
  const send = async (incoming) => {
235
236
  const skipped = new Set(quarantined());
236
237
  const log = skipped.size ? incoming.filter((patch) => !skipped.has(patchKey(patch))) : incoming;
237
238
  if (!log.length) return;
238
239
  inFlight = true;
239
- const stopWatching = showsPreprContent() ? watchUntilSettled(() => recoverFrom(log, lastGood)) : () => {
240
+ const watch = stopSettling !== null || showsPreprContent();
241
+ stopSettling?.();
242
+ const stopWatching = watch ? watchUntilSettled(() => recoverFrom(log, lastGood)) : () => {
240
243
  };
241
244
  let failed = false;
242
245
  try {
@@ -245,11 +248,21 @@ function createLogSync() {
245
248
  failed = true;
246
249
  debug.log("sending unsaved changes failed", error);
247
250
  }
248
- await new Promise((resolve) => setTimeout(resolve, RENDER_SETTLE_MS));
249
- stopWatching();
250
251
  inFlight = false;
251
- if (recovering) return;
252
- if (!failed) lastGood = log;
252
+ if (recovering) {
253
+ stopWatching();
254
+ return;
255
+ }
256
+ const settle = setTimeout(() => {
257
+ stopSettling = null;
258
+ stopWatching();
259
+ if (!failed && !recovering) lastGood = log;
260
+ }, RENDER_SETTLE_MS);
261
+ stopSettling = watch ? () => {
262
+ clearTimeout(settle);
263
+ stopWatching();
264
+ stopSettling = null;
265
+ } : null;
253
266
  if (pending && !cancelled) {
254
267
  const next = pending;
255
268
  pending = null;
@@ -35,7 +35,7 @@ __export(nuxt_exports, {
35
35
  module.exports = __toCommonJS(nuxt_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "1.0.0-rc.3";
38
+ var VERSION = "1.0.0-rc.4";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-LUKVPOJ2.js";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = "1.0.0-rc.3";
14
+ var VERSION = "1.0.0-rc.4";
15
15
 
16
16
  // src/core/features.ts
17
17
  function isEnabled(config) {
@@ -3703,7 +3703,7 @@ function createPreprPreview(opts = {}) {
3703
3703
  }
3704
3704
 
3705
3705
  // src/version.ts
3706
- var VERSION = "1.0.0-rc.3";
3706
+ var VERSION = "1.0.0-rc.4";
3707
3707
 
3708
3708
  // src/core/pixel.ts
3709
3709
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -3679,7 +3679,7 @@ function createPreprPreview(opts = {}) {
3679
3679
  }
3680
3680
 
3681
3681
  // src/version.ts
3682
- var VERSION = "1.0.0-rc.3";
3682
+ var VERSION = "1.0.0-rc.4";
3683
3683
 
3684
3684
  // src/core/pixel.ts
3685
3685
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -35,7 +35,7 @@ __export(sveltekit_exports, {
35
35
  module.exports = __toCommonJS(sveltekit_exports);
36
36
 
37
37
  // src/version.ts
38
- var VERSION = "1.0.0-rc.3";
38
+ var VERSION = "1.0.0-rc.4";
39
39
 
40
40
  // src/core/constants.ts
41
41
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-LUKVPOJ2.js";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = "1.0.0-rc.3";
14
+ var VERSION = "1.0.0-rc.4";
15
15
 
16
16
  // src/core/features.ts
17
17
  function isEnabled(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preprio/toolkit",
3
- "version": "1.0.0-rc.3",
3
+ "version": "1.0.0-rc.4",
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)",