@preprio/toolkit 0.4.1 → 0.4.2

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.4.1";
33
+ var VERSION = "0.4.2";
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.4.1";
2
+ var VERSION = "0.4.2";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -1,5 +1,5 @@
1
1
  // src/version.ts
2
- var VERSION = "0.4.1";
2
+ var VERSION = "0.4.2";
3
3
 
4
4
  // src/core/features.ts
5
5
  function isEnabled(config) {
@@ -655,6 +655,7 @@ function createStegaAutoClean(options) {
655
655
  const info = cleaned.get(textNode);
656
656
  const settled = stripText ? info?.cleaned : info?.original;
657
657
  if (info && textContent === settled) {
658
+ if (!info.decoded) return false;
658
659
  const shown = resolveEditTarget(textNode);
659
660
  if (!shown) return false;
660
661
  pendingHidden.delete(textNode);
@@ -666,13 +667,14 @@ function createStegaAutoClean(options) {
666
667
  const { cleaned: stripped, encoded } = vercelStegaSplit(textContent);
667
668
  if (!encoded || stripped === textContent) return false;
668
669
  const decoded = decodeStega(textContent);
669
- if (!decoded?.href) return false;
670
+ if (!decoded?.href && !stripText) return false;
670
671
  cleaned.set(textNode, {
671
672
  original: textContent,
672
673
  cleaned: stripped,
673
- decoded
674
+ decoded: decoded?.href ? decoded : null
674
675
  });
675
676
  if (stripText) textNode.textContent = stripped;
677
+ if (!decoded?.href) return false;
676
678
  const target = resolveEditTarget(textNode);
677
679
  if (target) {
678
680
  pendingHidden.delete(textNode);
@@ -709,7 +711,9 @@ function createStegaAutoClean(options) {
709
711
  if (mutation.type === "characterData" && mutation.target.nodeType === Node.TEXT_NODE) {
710
712
  const textNode = mutation.target;
711
713
  const info = cleaned.get(textNode);
712
- if (info && textNode.textContent === info.original) {
714
+ const text = textNode.textContent ?? "";
715
+ const settled = stripText ? info?.cleaned : info?.original;
716
+ if (text !== settled && vercelStegaSplit(text).encoded) {
713
717
  affected.add(textNode);
714
718
  }
715
719
  }
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.4.1";
47
+ var VERSION = "0.4.2";
48
48
 
49
49
  // src/core/features.ts
50
50
  function isEnabled(config) {
@@ -456,6 +456,7 @@ function createStegaAutoClean(options) {
456
456
  const info = cleaned.get(textNode);
457
457
  const settled = stripText ? info?.cleaned : info?.original;
458
458
  if (info && textContent === settled) {
459
+ if (!info.decoded) return false;
459
460
  const shown = resolveEditTarget(textNode);
460
461
  if (!shown) return false;
461
462
  pendingHidden.delete(textNode);
@@ -467,13 +468,14 @@ function createStegaAutoClean(options) {
467
468
  const { cleaned: stripped, encoded } = (0, import_stega2.vercelStegaSplit)(textContent);
468
469
  if (!encoded || stripped === textContent) return false;
469
470
  const decoded = decodeStega(textContent);
470
- if (!decoded?.href) return false;
471
+ if (!decoded?.href && !stripText) return false;
471
472
  cleaned.set(textNode, {
472
473
  original: textContent,
473
474
  cleaned: stripped,
474
- decoded
475
+ decoded: decoded?.href ? decoded : null
475
476
  });
476
477
  if (stripText) textNode.textContent = stripped;
478
+ if (!decoded?.href) return false;
477
479
  const target = resolveEditTarget(textNode);
478
480
  if (target) {
479
481
  pendingHidden.delete(textNode);
@@ -510,7 +512,9 @@ function createStegaAutoClean(options) {
510
512
  if (mutation.type === "characterData" && mutation.target.nodeType === Node.TEXT_NODE) {
511
513
  const textNode = mutation.target;
512
514
  const info = cleaned.get(textNode);
513
- if (info && textNode.textContent === info.original) {
515
+ const text = textNode.textContent ?? "";
516
+ const settled = stripText ? info?.cleaned : info?.original;
517
+ if (text !== settled && (0, import_stega2.vercelStegaSplit)(text).encoded) {
514
518
  affected.add(textNode);
515
519
  }
516
520
  }
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.4.1";
8
+ declare const VERSION = "0.4.2";
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.4.1";
8
+ declare const VERSION = "0.4.2";
9
9
 
10
10
  /**
11
11
  * Resolve a `PreprFeatures` bag to plain booleans, defaulting every omitted key
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setTrackingParam,
19
19
  stegaClean,
20
20
  trackEvent
21
- } from "./chunk-FP5XYD6J.js";
21
+ } from "./chunk-72BQJDDK.js";
22
22
 
23
23
  // src/core/server.ts
24
24
  var PreprError = class extends Error {
@@ -432,6 +432,7 @@ function createStegaAutoClean(options) {
432
432
  const info = cleaned.get(textNode);
433
433
  const settled = stripText ? info?.cleaned : info?.original;
434
434
  if (info && textContent === settled) {
435
+ if (!info.decoded) return false;
435
436
  const shown = resolveEditTarget(textNode);
436
437
  if (!shown) return false;
437
438
  pendingHidden.delete(textNode);
@@ -443,13 +444,14 @@ function createStegaAutoClean(options) {
443
444
  const { cleaned: stripped, encoded } = (0, import_stega2.vercelStegaSplit)(textContent);
444
445
  if (!encoded || stripped === textContent) return false;
445
446
  const decoded = decodeStega(textContent);
446
- if (!decoded?.href) return false;
447
+ if (!decoded?.href && !stripText) return false;
447
448
  cleaned.set(textNode, {
448
449
  original: textContent,
449
450
  cleaned: stripped,
450
- decoded
451
+ decoded: decoded?.href ? decoded : null
451
452
  });
452
453
  if (stripText) textNode.textContent = stripped;
454
+ if (!decoded?.href) return false;
453
455
  const target = resolveEditTarget(textNode);
454
456
  if (target) {
455
457
  pendingHidden.delete(textNode);
@@ -486,7 +488,9 @@ function createStegaAutoClean(options) {
486
488
  if (mutation.type === "characterData" && mutation.target.nodeType === Node.TEXT_NODE) {
487
489
  const textNode = mutation.target;
488
490
  const info = cleaned.get(textNode);
489
- if (info && textNode.textContent === info.original) {
491
+ const text = textNode.textContent ?? "";
492
+ const settled = stripText ? info?.cleaned : info?.original;
493
+ if (text !== settled && (0, import_stega2.vercelStegaSplit)(text).encoded) {
490
494
  affected.add(textNode);
491
495
  }
492
496
  }
@@ -2266,7 +2270,7 @@ function createPreprPreview(opts = {}) {
2266
2270
  var import_react = require("react");
2267
2271
 
2268
2272
  // src/version.ts
2269
- var VERSION = "0.4.1";
2273
+ var VERSION = "0.4.2";
2270
2274
 
2271
2275
  // src/core/pixel.ts
2272
2276
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  createPreprPreview,
4
4
  loadTrackingPixel
5
- } from "../chunk-FP5XYD6J.js";
5
+ } from "../chunk-72BQJDDK.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.4.1";
41
+ var VERSION = "0.4.2";
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.4.1";
5
+ var VERSION = "0.4.2";
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.4.1";
38
+ var VERSION = "0.4.2";
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.4.1";
2
+ var VERSION = "0.4.2";
3
3
 
4
4
  // src/core/constants.ts
5
5
  var COOKIE_PREVIEW_MODE = "Prepr-Preview-Mode";
@@ -431,6 +431,7 @@ function createStegaAutoClean(options) {
431
431
  const info = cleaned.get(textNode);
432
432
  const settled = stripText ? info?.cleaned : info?.original;
433
433
  if (info && textContent === settled) {
434
+ if (!info.decoded) return false;
434
435
  const shown = resolveEditTarget(textNode);
435
436
  if (!shown) return false;
436
437
  pendingHidden.delete(textNode);
@@ -442,13 +443,14 @@ function createStegaAutoClean(options) {
442
443
  const { cleaned: stripped, encoded } = (0, import_stega2.vercelStegaSplit)(textContent);
443
444
  if (!encoded || stripped === textContent) return false;
444
445
  const decoded = decodeStega(textContent);
445
- if (!decoded?.href) return false;
446
+ if (!decoded?.href && !stripText) return false;
446
447
  cleaned.set(textNode, {
447
448
  original: textContent,
448
449
  cleaned: stripped,
449
- decoded
450
+ decoded: decoded?.href ? decoded : null
450
451
  });
451
452
  if (stripText) textNode.textContent = stripped;
453
+ if (!decoded?.href) return false;
452
454
  const target = resolveEditTarget(textNode);
453
455
  if (target) {
454
456
  pendingHidden.delete(textNode);
@@ -485,7 +487,9 @@ function createStegaAutoClean(options) {
485
487
  if (mutation.type === "characterData" && mutation.target.nodeType === Node.TEXT_NODE) {
486
488
  const textNode = mutation.target;
487
489
  const info = cleaned.get(textNode);
488
- if (info && textNode.textContent === info.original) {
490
+ const text = textNode.textContent ?? "";
491
+ const settled = stripText ? info?.cleaned : info?.original;
492
+ if (text !== settled && (0, import_stega2.vercelStegaSplit)(text).encoded) {
489
493
  affected.add(textNode);
490
494
  }
491
495
  }
@@ -2262,7 +2266,7 @@ function createPreprPreview(opts = {}) {
2262
2266
  }
2263
2267
 
2264
2268
  // src/version.ts
2265
- var VERSION = "0.4.1";
2269
+ var VERSION = "0.4.2";
2266
2270
 
2267
2271
  // src/core/pixel.ts
2268
2272
  var PIXEL_SCRIPT_URL = "https://cdn.tracking.prepr.io/js/prepr.min.js";
@@ -407,6 +407,7 @@ function createStegaAutoClean(options) {
407
407
  const info = cleaned.get(textNode);
408
408
  const settled = stripText ? info?.cleaned : info?.original;
409
409
  if (info && textContent === settled) {
410
+ if (!info.decoded) return false;
410
411
  const shown = resolveEditTarget(textNode);
411
412
  if (!shown) return false;
412
413
  pendingHidden.delete(textNode);
@@ -418,13 +419,14 @@ function createStegaAutoClean(options) {
418
419
  const { cleaned: stripped, encoded } = vercelStegaSplit(textContent);
419
420
  if (!encoded || stripped === textContent) return false;
420
421
  const decoded = decodeStega(textContent);
421
- if (!decoded?.href) return false;
422
+ if (!decoded?.href && !stripText) return false;
422
423
  cleaned.set(textNode, {
423
424
  original: textContent,
424
425
  cleaned: stripped,
425
- decoded
426
+ decoded: decoded?.href ? decoded : null
426
427
  });
427
428
  if (stripText) textNode.textContent = stripped;
429
+ if (!decoded?.href) return false;
428
430
  const target = resolveEditTarget(textNode);
429
431
  if (target) {
430
432
  pendingHidden.delete(textNode);
@@ -461,7 +463,9 @@ function createStegaAutoClean(options) {
461
463
  if (mutation.type === "characterData" && mutation.target.nodeType === Node.TEXT_NODE) {
462
464
  const textNode = mutation.target;
463
465
  const info = cleaned.get(textNode);
464
- if (info && textNode.textContent === info.original) {
466
+ const text = textNode.textContent ?? "";
467
+ const settled = stripText ? info?.cleaned : info?.original;
468
+ if (text !== settled && vercelStegaSplit(text).encoded) {
465
469
  affected.add(textNode);
466
470
  }
467
471
  }
@@ -2238,7 +2242,7 @@ function createPreprPreview(opts = {}) {
2238
2242
  }
2239
2243
 
2240
2244
  // src/version.ts
2241
- var VERSION = "0.4.1";
2245
+ var VERSION = "0.4.2";
2242
2246
 
2243
2247
  // src/core/pixel.ts
2244
2248
  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 = "0.4.1";
38
+ var VERSION = "0.4.2";
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.4.1";
2
+ var VERSION = "0.4.2";
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.4.1",
3
+ "version": "0.4.2",
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)",