@preprio/toolkit 0.1.0-beta.6 → 0.2.0-beta.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.
package/README.md CHANGED
@@ -570,11 +570,11 @@ Forward the headers on your GraphQL fetch with `getPreprHeadersFromHeaders(reque
570
570
  **Client** — mount the toolbar imperatively:
571
571
 
572
572
  ```javascript
573
- import { createPreprToolbar, loadTrackingPixel } from '@preprio/toolkit';
573
+ import { createPreprPreview, loadTrackingPixel } from '@preprio/toolkit';
574
574
 
575
575
  loadTrackingPixel('YOUR_ACCESS_TOKEN');
576
576
 
577
- const controller = createPreprToolbar({ props: toolbarProps });
577
+ const controller = createPreprPreview({ props: toolbarProps });
578
578
  // later: controller.destroy()
579
579
  ```
580
580
 
@@ -707,12 +707,12 @@ const { requestHeaders, responseCookies } = processPreprRequest(request, { previ
707
707
  // responseCookies: CookieSpec[] — { name, value, maxAge, path }
708
708
  ```
709
709
 
710
- #### `createPreprToolbar(options)`
710
+ #### `createPreprPreview(options)`
711
711
 
712
- Mounts the toolbar and returns a controller.
712
+ Starts the preview runtime — optionally mounting the toolbar — and returns a controller.
713
713
 
714
714
  ```typescript
715
- const controller = createPreprToolbar({
715
+ const controller = createPreprPreview({
716
716
  props: toolbarProps,
717
717
  options: { debug: true, locale: 'nl' },
718
718
  navigation: {
@@ -727,13 +727,15 @@ controller.destroy();
727
727
 
728
728
  | Option | Type | Description |
729
729
  | --- | --- | --- |
730
- | `props` | `PreprToolbarProps` | Required. From `getToolbarProps`. |
731
- | `options` | `PreprToolbarOptions` | `{ debug?, locale? }`. |
730
+ | `props` | `PreprToolbarProps` | From `getToolbarProps`. Optional — a headless preview has no segment list to pass. |
731
+ | `options` | `PreprPreviewOptions` | `{ debug?, locale?, features?, ui?, allowedEditorOrigins? }`. |
732
732
  | `navigation` | `PreprNavigationAdapter` | How segment/variant switches navigate. |
733
733
 
734
734
  The navigation adapter is optional. Omit it and the toolbar uses `window.location.assign` — a full page load. Supply one to integrate with a client-side router; its `reload` member is optional too, and runs after a preview-mode toggle (defaulting to `window.location.reload()`). The Next.js and SvelteKit wrappers wire all of this up for you.
735
735
 
736
- `createPreprToolbar` is a no-op outside a browser (no `window`/`document`) and returns a controller whose `destroy()` does nothing, so it is safe to call during SSR. It also skips mounting when `prepr_hide_bar=true` is present, which is how the Prepr live-preview iframe suppresses the bar.
736
+ `createPreprPreview` is a no-op outside a browser (no `window`/`document`) and returns a controller whose `destroy()` does nothing, so it is safe to call during SSR.
737
+
738
+ Chrome is skipped — while every side effect stays wired — when any of these hold: `ui: false`, `?prepr_hide_bar=true` (how the Prepr live-preview iframe suppresses the bar), or running inside the editor's iframe. See [Headless preview](#headless-preview-no-toolbar-ui).
737
739
 
738
740
  #### `loadTrackingPixel(id, config?)`
739
741
 
@@ -810,18 +812,89 @@ createPreprMiddleware(request, response, { preview: true });
810
812
  | Option | Type | Description |
811
813
  | --- | --- | --- |
812
814
  | `preview` | `boolean` | Enables preview mode. The only gate — resolve it from your own environment signal. |
815
+ | `features` | `PreprFeatures` | Disable features app-wide. See [Feature flags](#feature-flags). |
813
816
  | `version` | `string` | Override the version reported in the `Prepr-Package` header. Mainly for tests. |
814
817
 
815
- ### Toolbar Options
818
+ ### Preview Options
816
819
 
817
820
  ```typescript
818
- createPreprToolbar({ props, options: { debug: true, locale: 'nl' } });
821
+ createPreprPreview({ props, options: { debug: true, locale: 'nl' } });
819
822
  ```
820
823
 
821
824
  | Option | Type | Default | Description |
822
825
  | --- | --- | --- | --- |
823
826
  | `debug` | `boolean` | `false` | Enable debug logging. |
824
827
  | `locale` | `'en' \| 'nl'` | auto-detected | UI language. Falls back to the first supported browser language, then `en`. |
828
+ | `features` | `PreprFeatures` | all enabled | Which features run. See [Feature flags](#feature-flags). |
829
+ | `ui` | `boolean` | `true` | Mount the visible toolbar. See [Headless preview](#headless-preview-no-toolbar-ui). |
830
+ | `allowedEditorOrigins` | `string[]` | `*.prepr.io` | Exact editor origins allowed to drive this preview, for self-hosted editors. Replaces the wildcard. |
831
+
832
+ `features` and `ui` are independent: `features` decides *what runs*, `ui` decides *whether the toolbar is visible*.
833
+
834
+ ### Headless preview (no toolbar UI)
835
+
836
+ `ui: false` keeps every non-visual side effect wired — click-to-edit, the editor bridge, scroll restore, cookies and headers — while rendering no chrome of its own. That is how a site gets live editing, or editor scroll restore, alongside its own UI instead of the Prepr bar.
837
+
838
+ ```typescript
839
+ // Live editing, no bar:
840
+ const preview = createPreprPreview({
841
+ options: { ui: false, features: { editMode: true } },
842
+ });
843
+
844
+ preview.destroy();
845
+ ```
846
+
847
+ `props` is optional here — a headless preview that only wants click-to-edit or scroll restore has no segment list to pass. For scroll restore and nothing else:
848
+
849
+ ```typescript
850
+ createPreprPreview({
851
+ options: {
852
+ ui: false,
853
+ features: { segments: false, abTesting: false, editMode: false },
854
+ },
855
+ });
856
+ ```
857
+
858
+ `?prepr_hide_bar=true` and the editor's own iframe both imply `ui: false`. Outside an iframe the bridge is a no-op, so mounting unconditionally is safe. Call `createPreprPreview` **once per page** — two calls start two bridges and announce the preview twice.
859
+
860
+ ### Feature flags
861
+
862
+ Preview mode is the master switch. Within it, each feature can be turned off with a `features` object. Everything is **on by default** — omit it and nothing changes.
863
+
864
+ ```typescript
865
+ import type { PreprFeatures } from '@preprio/toolkit';
866
+
867
+ export const preprFeatures: PreprFeatures = {
868
+ segments: false, // or { enabled: false }
869
+ abTesting: true,
870
+ editMode: { enabled: false },
871
+ };
872
+ ```
873
+
874
+ | Feature | Off means |
875
+ | --- | --- |
876
+ | `segments` | No segment picker. No `Prepr-Segments` header, from cookie **or** `?prepr_preview_segment`. No segment cookie written. The `_Segments` API call is skipped, saving a round-trip per page. |
877
+ | `abTesting` | No A/B control or variant badge. No `Prepr-ABtesting` header, from cookie **or** `?prepr_preview_ab`. No variant cookie written. |
878
+ | `editMode` | No Edit mode control, no click-to-edit overlay, no close-edit pill. |
879
+
880
+ Pass the **same object to both sides**. Each enforces its own half, so a feature disabled in only one place is still half-on — the UI would hide a control the middleware still honours:
881
+
882
+ ```typescript
883
+ // server
884
+ createPreprMiddleware(request, { preview: true, features: preprFeatures });
885
+ const props = await getToolbarProps(graphqlUrl, preprFeatures);
886
+
887
+ // client
888
+ <PreprToolbar {...props} options={{ features: preprFeatures }} />
889
+ ```
890
+
891
+ Every framework's `getToolbarProps` takes `features` as its last argument, and every `<PreprToolbar>` accepts an `options` prop. Keeping the object in one module both sides import is the simplest way to stay in sync.
892
+
893
+ Disabling a feature also stops its `segment_changed` / `variant_changed` events, and the Reset button ignores it — state the user cannot see is never rewritten.
894
+
895
+ **`editMode` does not disable the Prepr visual editor.** It governs your site's own click-to-edit affordance. When the Prepr editor frames your site it drives edit mode over its own `postMessage` handshake, which keeps working regardless — that is the CMS operating inside its own iframe, not an affordance offered to your visitors. Treat `editMode: false` as a UI choice, never as a security control.
896
+
897
+ Feature flags govern the toolbar and the middleware. The toolbar-free scroll-sync entry point carries no personalization state, so there is nothing there to disable.
825
898
 
826
899
  ### Pixel Options
827
900
 
@@ -864,7 +937,7 @@ Because the toolbar renders inside a shadow root, none of your own page CSS —
864
937
  The toolbar UI ships with English and Dutch. Pass `locale` explicitly, or omit it to auto-detect from the browser and fall back to `en`:
865
938
 
866
939
  ```typescript
867
- createPreprToolbar({ props, options: { locale: 'nl' } });
940
+ createPreprPreview({ props, options: { locale: 'nl' } });
868
941
  ```
869
942
 
870
943
  ## Troubleshooting
@@ -916,7 +989,7 @@ Codes: `INVALID_TOKEN`, `MISSING_TOKEN`, `HTTP_ERROR`, `FETCH_ERROR`, `INVALID_R
916
989
  ### Debug Mode
917
990
 
918
991
  ```typescript
919
- createPreprToolbar({ props, options: { debug: true } });
992
+ createPreprPreview({ props, options: { debug: true } });
920
993
  ```
921
994
 
922
995
  ## How It Works
@@ -30,7 +30,25 @@ __export(astro_exports, {
30
30
  module.exports = __toCommonJS(astro_exports);
31
31
 
32
32
  // src/version.ts
33
- var VERSION = "0.1.0-beta.6";
33
+ var VERSION = "0.2.0-beta.2";
34
+
35
+ // src/core/features.ts
36
+ function isEnabled(config) {
37
+ if (typeof config === "boolean") return config;
38
+ return config?.enabled ?? true;
39
+ }
40
+ function resolveFeatures(features) {
41
+ return {
42
+ segments: isEnabled(features?.segments),
43
+ abTesting: isEnabled(features?.abTesting),
44
+ editMode: isEnabled(features?.editMode)
45
+ };
46
+ }
47
+ var ALL_FEATURES_ENABLED = Object.freeze({
48
+ segments: true,
49
+ abTesting: true,
50
+ editMode: true
51
+ });
34
52
 
35
53
  // src/core/server.ts
36
54
  var PreprError = class extends Error {
@@ -138,16 +156,19 @@ async function getPreprEnvironmentSegments(token) {
138
156
  );
139
157
  }
140
158
  }
141
- async function getToolbarPropsFromHeaders(headers, token) {
159
+ async function getToolbarPropsFromHeaders(headers, token, features) {
160
+ const resolved = resolveFeatures(features);
142
161
  let segments = [];
143
- try {
144
- segments = await getPreprEnvironmentSegments(token);
145
- } catch {
146
- segments = [];
162
+ if (resolved.segments) {
163
+ try {
164
+ segments = await getPreprEnvironmentSegments(token);
165
+ } catch {
166
+ segments = [];
167
+ }
147
168
  }
148
169
  return {
149
- activeSegment: getActiveSegmentFromHeaders(headers),
150
- activeVariant: getActiveVariantFromHeaders(headers),
170
+ activeSegment: resolved.segments ? getActiveSegmentFromHeaders(headers) : null,
171
+ activeVariant: resolved.abTesting ? getActiveVariantFromHeaders(headers) : null,
151
172
  segments,
152
173
  data: segments
153
174
  };
@@ -247,7 +268,8 @@ function processPreprRequest(request, opts) {
247
268
  if (!opts?.preview) {
248
269
  return { requestHeaders, responseCookies };
249
270
  }
250
- const hasPreviewParams = searchParams.has(PARAM_SEGMENT) || searchParams.has(PARAM_VARIANT);
271
+ const features = resolveFeatures(opts?.features);
272
+ const hasPreviewParams = features.segments && searchParams.has(PARAM_SEGMENT) || features.abTesting && searchParams.has(PARAM_VARIANT);
251
273
  if (!hasPreviewParams) {
252
274
  const previewModeCookie = requestCookies.get(COOKIE_PREVIEW_MODE);
253
275
  const previewModeEnabled = previewModeCookie !== "false";
@@ -267,16 +289,16 @@ function processPreprRequest(request, opts) {
267
289
  });
268
290
  }
269
291
  if (!isLivePreview) {
270
- const segmentCookie = requestCookies.get(COOKIE_SEGMENT);
292
+ const segmentCookie = features.segments ? requestCookies.get(COOKIE_SEGMENT) : void 0;
271
293
  if (segmentCookie) {
272
294
  requestHeaders.set("Prepr-Segments", segmentCookie);
273
295
  }
274
- const abCookie = requestCookies.get(COOKIE_VARIANT);
296
+ const abCookie = features.abTesting ? requestCookies.get(COOKIE_VARIANT) : void 0;
275
297
  if (abCookie) {
276
298
  requestHeaders.set("Prepr-ABtesting", abCookie);
277
299
  }
278
300
  }
279
- const previewAb = searchParams.get(PARAM_VARIANT);
301
+ const previewAb = features.abTesting ? searchParams.get(PARAM_VARIANT) : null;
280
302
  if (previewAb !== null) {
281
303
  requestHeaders.set("Prepr-ABtesting", previewAb);
282
304
  if (!isLivePreview) {
@@ -289,7 +311,7 @@ function processPreprRequest(request, opts) {
289
311
  });
290
312
  }
291
313
  }
292
- const previewSegment = searchParams.get(PARAM_SEGMENT);
314
+ const previewSegment = features.segments ? searchParams.get(PARAM_SEGMENT) : null;
293
315
  if (previewSegment !== null) {
294
316
  requestHeaders.set("Prepr-Segments", previewSegment);
295
317
  if (!isLivePreview) {
@@ -329,8 +351,8 @@ function getActiveVariant(headers) {
329
351
  function getPreprHeaders(headers) {
330
352
  return getPreprHeadersFromHeaders(headers);
331
353
  }
332
- async function getToolbarProps(headers, token) {
333
- return getToolbarPropsFromHeaders(headers, token);
354
+ async function getToolbarProps(headers, token, features) {
355
+ return getToolbarPropsFromHeaders(headers, token, features);
334
356
  }
335
357
  // Annotate the CommonJS export names for ESM import in node:
336
358
  0 && (module.exports = {
@@ -1,14 +1,31 @@
1
- interface PreprMiddlewareOptions {
2
- /** Enable preview-mode headers (segment/AB overrides, preview bar). */
3
- preview?: boolean;
4
- /** Override the version reported in Prepr-Package (mainly for tests). */
5
- version?: string;
6
- }
7
-
8
1
  interface PreprSegment {
9
2
  readonly _id: string;
10
3
  readonly name: string;
11
4
  }
5
+ /**
6
+ * Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
7
+ * form leaves room for per-feature options later without a breaking change.
8
+ */
9
+ type PreprFeatureConfig = boolean | {
10
+ enabled?: boolean;
11
+ };
12
+ /** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
13
+ interface PreprFeatures {
14
+ /** Segment picker, `Prepr-Segments` header and its cookie/query param. */
15
+ segments?: PreprFeatureConfig;
16
+ /** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
17
+ abTesting?: PreprFeatureConfig;
18
+ /**
19
+ * The site's own click-to-edit: the toolbar's Edit mode control, the stega
20
+ * tooltip/overlay and the close-edit pill.
21
+ *
22
+ * NOT a security control, and NOT the Prepr editor's live preview. When the
23
+ * site is framed by the editor, `prepr:initVE` still activates edit mode —
24
+ * that is the CMS operating inside its own iframe, not an affordance offered
25
+ * to visitors. See iframe-bridge.ts.
26
+ */
27
+ editMode?: PreprFeatureConfig;
28
+ }
12
29
  interface PreprToolbarProps {
13
30
  readonly activeSegment: string | null;
14
31
  readonly activeVariant: string | null;
@@ -35,6 +52,19 @@ interface PreprHeaders {
35
52
  readonly 'Prepr-User-Agent'?: string;
36
53
  }
37
54
 
55
+ interface PreprMiddlewareOptions {
56
+ /** Enable preview-mode headers (segment/AB overrides, preview bar). */
57
+ preview?: boolean;
58
+ /**
59
+ * Disable features app-wide. Pass the same object you give the toolbar: a
60
+ * disabled feature injects no header and persists no cookie, whatever the
61
+ * request carries.
62
+ */
63
+ features?: PreprFeatures;
64
+ /** Override the version reported in Prepr-Package (mainly for tests). */
65
+ version?: string;
66
+ }
67
+
38
68
  /**
39
69
  * Structural stand-in for Astro's `APIContext`, so this package needs no
40
70
  * build-time dependency on `astro`. Only the fields `onPreprRequest` uses.
@@ -71,6 +101,6 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
71
101
  * your deployment already does — the toolkit reads no environment variables of
72
102
  * its own.
73
103
  */
74
- declare function getToolbarProps(headers: Headers, token: string): Promise<PreprToolbarProps>;
104
+ declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
75
105
 
76
106
  export { type AstroLikeContext, type AstroNext, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, onPreprRequest };
@@ -1,14 +1,31 @@
1
- interface PreprMiddlewareOptions {
2
- /** Enable preview-mode headers (segment/AB overrides, preview bar). */
3
- preview?: boolean;
4
- /** Override the version reported in Prepr-Package (mainly for tests). */
5
- version?: string;
6
- }
7
-
8
1
  interface PreprSegment {
9
2
  readonly _id: string;
10
3
  readonly name: string;
11
4
  }
5
+ /**
6
+ * Per-feature config. `false` is shorthand for `{ enabled: false }`; the object
7
+ * form leaves room for per-feature options later without a breaking change.
8
+ */
9
+ type PreprFeatureConfig = boolean | {
10
+ enabled?: boolean;
11
+ };
12
+ /** Toolkit features a consumer can turn off. Omitted keys stay enabled. */
13
+ interface PreprFeatures {
14
+ /** Segment picker, `Prepr-Segments` header and its cookie/query param. */
15
+ segments?: PreprFeatureConfig;
16
+ /** A/B variant switch, `Prepr-ABtesting` header and its cookie/query param. */
17
+ abTesting?: PreprFeatureConfig;
18
+ /**
19
+ * The site's own click-to-edit: the toolbar's Edit mode control, the stega
20
+ * tooltip/overlay and the close-edit pill.
21
+ *
22
+ * NOT a security control, and NOT the Prepr editor's live preview. When the
23
+ * site is framed by the editor, `prepr:initVE` still activates edit mode —
24
+ * that is the CMS operating inside its own iframe, not an affordance offered
25
+ * to visitors. See iframe-bridge.ts.
26
+ */
27
+ editMode?: PreprFeatureConfig;
28
+ }
12
29
  interface PreprToolbarProps {
13
30
  readonly activeSegment: string | null;
14
31
  readonly activeVariant: string | null;
@@ -35,6 +52,19 @@ interface PreprHeaders {
35
52
  readonly 'Prepr-User-Agent'?: string;
36
53
  }
37
54
 
55
+ interface PreprMiddlewareOptions {
56
+ /** Enable preview-mode headers (segment/AB overrides, preview bar). */
57
+ preview?: boolean;
58
+ /**
59
+ * Disable features app-wide. Pass the same object you give the toolbar: a
60
+ * disabled feature injects no header and persists no cookie, whatever the
61
+ * request carries.
62
+ */
63
+ features?: PreprFeatures;
64
+ /** Override the version reported in Prepr-Package (mainly for tests). */
65
+ version?: string;
66
+ }
67
+
38
68
  /**
39
69
  * Structural stand-in for Astro's `APIContext`, so this package needs no
40
70
  * build-time dependency on `astro`. Only the fields `onPreprRequest` uses.
@@ -71,6 +101,6 @@ declare function getPreprHeaders(headers: Headers): PreprHeaders;
71
101
  * your deployment already does — the toolkit reads no environment variables of
72
102
  * its own.
73
103
  */
74
- declare function getToolbarProps(headers: Headers, token: string): Promise<PreprToolbarProps>;
104
+ declare function getToolbarProps(headers: Headers, token: string, features?: PreprFeatures): Promise<PreprToolbarProps>;
75
105
 
76
106
  export { type AstroLikeContext, type AstroNext, type PreprMiddlewareOptions, getActiveSegment, getActiveVariant, getPreprHeaders, getPreprUUID, getToolbarProps, onPreprRequest };
@@ -1,5 +1,23 @@
1
1
  // src/version.ts
2
- var VERSION = "0.1.0-beta.6";
2
+ var VERSION = "0.2.0-beta.2";
3
+
4
+ // src/core/features.ts
5
+ function isEnabled(config) {
6
+ if (typeof config === "boolean") return config;
7
+ return config?.enabled ?? true;
8
+ }
9
+ function resolveFeatures(features) {
10
+ return {
11
+ segments: isEnabled(features?.segments),
12
+ abTesting: isEnabled(features?.abTesting),
13
+ editMode: isEnabled(features?.editMode)
14
+ };
15
+ }
16
+ var ALL_FEATURES_ENABLED = Object.freeze({
17
+ segments: true,
18
+ abTesting: true,
19
+ editMode: true
20
+ });
3
21
 
4
22
  // src/core/server.ts
5
23
  var PreprError = class extends Error {
@@ -107,16 +125,19 @@ async function getPreprEnvironmentSegments(token) {
107
125
  );
108
126
  }
109
127
  }
110
- async function getToolbarPropsFromHeaders(headers, token) {
128
+ async function getToolbarPropsFromHeaders(headers, token, features) {
129
+ const resolved = resolveFeatures(features);
111
130
  let segments = [];
112
- try {
113
- segments = await getPreprEnvironmentSegments(token);
114
- } catch {
115
- segments = [];
131
+ if (resolved.segments) {
132
+ try {
133
+ segments = await getPreprEnvironmentSegments(token);
134
+ } catch {
135
+ segments = [];
136
+ }
116
137
  }
117
138
  return {
118
- activeSegment: getActiveSegmentFromHeaders(headers),
119
- activeVariant: getActiveVariantFromHeaders(headers),
139
+ activeSegment: resolved.segments ? getActiveSegmentFromHeaders(headers) : null,
140
+ activeVariant: resolved.abTesting ? getActiveVariantFromHeaders(headers) : null,
120
141
  segments,
121
142
  data: segments
122
143
  };
@@ -216,7 +237,8 @@ function processPreprRequest(request, opts) {
216
237
  if (!opts?.preview) {
217
238
  return { requestHeaders, responseCookies };
218
239
  }
219
- const hasPreviewParams = searchParams.has(PARAM_SEGMENT) || searchParams.has(PARAM_VARIANT);
240
+ const features = resolveFeatures(opts?.features);
241
+ const hasPreviewParams = features.segments && searchParams.has(PARAM_SEGMENT) || features.abTesting && searchParams.has(PARAM_VARIANT);
220
242
  if (!hasPreviewParams) {
221
243
  const previewModeCookie = requestCookies.get(COOKIE_PREVIEW_MODE);
222
244
  const previewModeEnabled = previewModeCookie !== "false";
@@ -236,16 +258,16 @@ function processPreprRequest(request, opts) {
236
258
  });
237
259
  }
238
260
  if (!isLivePreview) {
239
- const segmentCookie = requestCookies.get(COOKIE_SEGMENT);
261
+ const segmentCookie = features.segments ? requestCookies.get(COOKIE_SEGMENT) : void 0;
240
262
  if (segmentCookie) {
241
263
  requestHeaders.set("Prepr-Segments", segmentCookie);
242
264
  }
243
- const abCookie = requestCookies.get(COOKIE_VARIANT);
265
+ const abCookie = features.abTesting ? requestCookies.get(COOKIE_VARIANT) : void 0;
244
266
  if (abCookie) {
245
267
  requestHeaders.set("Prepr-ABtesting", abCookie);
246
268
  }
247
269
  }
248
- const previewAb = searchParams.get(PARAM_VARIANT);
270
+ const previewAb = features.abTesting ? searchParams.get(PARAM_VARIANT) : null;
249
271
  if (previewAb !== null) {
250
272
  requestHeaders.set("Prepr-ABtesting", previewAb);
251
273
  if (!isLivePreview) {
@@ -258,7 +280,7 @@ function processPreprRequest(request, opts) {
258
280
  });
259
281
  }
260
282
  }
261
- const previewSegment = searchParams.get(PARAM_SEGMENT);
283
+ const previewSegment = features.segments ? searchParams.get(PARAM_SEGMENT) : null;
262
284
  if (previewSegment !== null) {
263
285
  requestHeaders.set("Prepr-Segments", previewSegment);
264
286
  if (!isLivePreview) {
@@ -298,8 +320,8 @@ function getActiveVariant(headers) {
298
320
  function getPreprHeaders(headers) {
299
321
  return getPreprHeadersFromHeaders(headers);
300
322
  }
301
- async function getToolbarProps(headers, token) {
302
- return getToolbarPropsFromHeaders(headers, token);
323
+ async function getToolbarProps(headers, token, features) {
324
+ return getToolbarPropsFromHeaders(headers, token, features);
303
325
  }
304
326
  export {
305
327
  getActiveSegment,