@coframe/sdk 1.1.54 → 1.1.56

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 CHANGED
@@ -86,10 +86,11 @@ installations:
86
86
  production visitor would get.
87
87
  - `coframe_should_send_events=true` allows events during preview for testing.
88
88
 
89
- Debug tools are allowed by default. Open the Launcher with `cf_preview=true` and
90
- use **Keep across navigation** in the Preview Session tool to keep the selected
91
- variants active for the current tab. Set `enableDebug: false` to prevent URL or
92
- saved session state from loading the Launcher.
89
+ Debug tools are allowed by default. A preview link (`coframe_variant_id` with
90
+ `cf_preview=true`) keeps the selected variants active for the current tab as you
91
+ navigate; turn off **Keep across navigation** in the Preview Session tool to
92
+ stop. Set `enableDebug: false` to prevent URL or saved session state from
93
+ loading the Launcher (a preview link then applies to its own page only).
93
94
 
94
95
  For SSR, pass the complete request URL, including its query string, as
95
96
  `currentUrl`. This is required for query-sensitive targeting and allows
@@ -2479,6 +2479,16 @@ function readStoredPreviewVariantId() {
2479
2479
  return null;
2480
2480
  }
2481
2481
  }
2482
+ function persistPreviewVariantId(variantId) {
2483
+ const normalized = normalizePreviewVariantId(variantId);
2484
+ if (!normalized)
2485
+ return;
2486
+ try {
2487
+ window.sessionStorage.setItem(COFRAME_PREVIEW_SESSION_STORAGE_KEY, normalized);
2488
+ }
2489
+ catch (_a) {
2490
+ }
2491
+ }
2482
2492
  function resolvePreviewSource(url = window.location.href) {
2483
2493
  const urlVariantId = readPreviewVariantIdFromUrl(url);
2484
2494
  const storedVariantId = readStoredPreviewVariantId();
@@ -5338,6 +5348,10 @@ async function resolveConfig(Coframe, revealActions) {
5338
5348
  if (previewSource.urlVariantId) {
5339
5349
  previewVariantId = previewSource.urlVariantId;
5340
5350
  isSessionVariant = previewSource.isKeptForSession;
5351
+ if (urlParams.get(COFRAME_PREVIEW_QUERY_PARAM) === 'true' &&
5352
+ config.enableDebug !== false) {
5353
+ persistPreviewVariantId(previewSource.urlVariantId);
5354
+ }
5341
5355
  }
5342
5356
  else if (previewSource.storedVariantId) {
5343
5357
  previewVariantId = previewSource.storedVariantId;
@@ -2477,6 +2477,16 @@ function readStoredPreviewVariantId() {
2477
2477
  return null;
2478
2478
  }
2479
2479
  }
2480
+ function persistPreviewVariantId(variantId) {
2481
+ const normalized = normalizePreviewVariantId(variantId);
2482
+ if (!normalized)
2483
+ return;
2484
+ try {
2485
+ window.sessionStorage.setItem(COFRAME_PREVIEW_SESSION_STORAGE_KEY, normalized);
2486
+ }
2487
+ catch (_a) {
2488
+ }
2489
+ }
2480
2490
  function resolvePreviewSource(url = window.location.href) {
2481
2491
  const urlVariantId = readPreviewVariantIdFromUrl(url);
2482
2492
  const storedVariantId = readStoredPreviewVariantId();
@@ -5336,6 +5346,10 @@ async function resolveConfig(Coframe, revealActions) {
5336
5346
  if (previewSource.urlVariantId) {
5337
5347
  previewVariantId = previewSource.urlVariantId;
5338
5348
  isSessionVariant = previewSource.isKeptForSession;
5349
+ if (urlParams.get(COFRAME_PREVIEW_QUERY_PARAM) === 'true' &&
5350
+ config.enableDebug !== false) {
5351
+ persistPreviewVariantId(previewSource.urlVariantId);
5352
+ }
5339
5353
  }
5340
5354
  else if (previewSource.storedVariantId) {
5341
5355
  previewVariantId = previewSource.storedVariantId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coframe/sdk",
3
- "version": "1.1.54",
3
+ "version": "1.1.56",
4
4
  "description": "Coframe optimizes your website using generative AI to deliver maximum impact to your audience and allow your site to improve itself as you sleep. Learn more at coframe.com.",
5
5
  "main": "dist/pkg/cf.cjs.js",
6
6
  "module": "dist/pkg/cf.esm.mjs",