@preprio/toolkit 0.6.0-alpha.0 → 0.6.0-alpha.10

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.
Files changed (59) hide show
  1. package/README.md +268 -59
  2. package/dist/astro/{chunk-3UVUDDNY.js → chunk-CG2QBHNU.js} +1 -1
  3. package/dist/astro/graphql.cjs +154 -59
  4. package/dist/astro/graphql.d.cts +75 -6
  5. package/dist/astro/graphql.d.ts +75 -6
  6. package/dist/astro/graphql.js +150 -59
  7. package/dist/astro/index.cjs +1 -1
  8. package/dist/astro/index.js +1 -1
  9. package/dist/chunk-3NCEVJJ3.js +10 -0
  10. package/dist/{chunk-BJ2LBLWO.js → chunk-LIDUJWWJ.js} +6 -4
  11. package/dist/chunk-M3RBYJ5J.js +499 -0
  12. package/dist/{chunk-DGZA7KX7.js → chunk-S5RWVMDJ.js} +0 -24
  13. package/dist/{chunk-YR7P4IWE.js → chunk-SF6TN4JR.js} +1 -9
  14. package/dist/chunk-TN6SNAR2.js +26 -0
  15. package/dist/graphql/codegen.cjs +557 -0
  16. package/dist/graphql/codegen.d.cts +23 -0
  17. package/dist/graphql/codegen.d.ts +23 -0
  18. package/dist/graphql/codegen.js +99 -0
  19. package/dist/graphql.cjs +185 -59
  20. package/dist/graphql.d.cts +110 -6
  21. package/dist/graphql.d.ts +110 -6
  22. package/dist/graphql.js +91 -430
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.js +10 -6
  27. package/dist/nextjs/chunk-B4GVZEOL.js +549 -0
  28. package/dist/nextjs/components.cjs +297 -81
  29. package/dist/nextjs/components.d.cts +26 -11
  30. package/dist/nextjs/components.d.ts +26 -11
  31. package/dist/nextjs/components.js +289 -73
  32. package/dist/nextjs/graphql.cjs +952 -315
  33. package/dist/nextjs/graphql.d.cts +225 -83
  34. package/dist/nextjs/graphql.d.ts +225 -83
  35. package/dist/nextjs/graphql.js +634 -314
  36. package/dist/nextjs/index.cjs +116 -54
  37. package/dist/nextjs/index.d.cts +61 -23
  38. package/dist/nextjs/index.d.ts +61 -23
  39. package/dist/nextjs/index.js +97 -299
  40. package/dist/nextjs/{server-CjpELYvq.d.ts → server-BL-sqZvu.d.cts} +1 -1
  41. package/dist/nextjs/{server-CjpELYvq.d.cts → server-BL-sqZvu.d.ts} +1 -1
  42. package/dist/nuxt/{chunk-P6ENNAEE.js → chunk-FMC3DP7N.js} +1 -1
  43. package/dist/nuxt/graphql.cjs +154 -59
  44. package/dist/nuxt/graphql.d.cts +75 -6
  45. package/dist/nuxt/graphql.d.ts +75 -6
  46. package/dist/nuxt/graphql.js +150 -59
  47. package/dist/nuxt/index.cjs +1 -1
  48. package/dist/nuxt/index.js +1 -1
  49. package/dist/react/components.cjs +1 -1
  50. package/dist/react/components.js +1 -1
  51. package/dist/sveltekit/{chunk-FSARVMG5.js → chunk-AJPKBAHO.js} +1 -1
  52. package/dist/sveltekit/graphql.cjs +154 -59
  53. package/dist/sveltekit/graphql.d.cts +75 -6
  54. package/dist/sveltekit/graphql.d.ts +75 -6
  55. package/dist/sveltekit/graphql.js +150 -59
  56. package/dist/sveltekit/index.cjs +1 -1
  57. package/dist/sveltekit/index.js +1 -1
  58. package/package.json +6 -1
  59. package/dist/nextjs/chunk-U4HXENF7.js +0 -231
@@ -0,0 +1,499 @@
1
+ import {
2
+ PreprError
3
+ } from "./chunk-SF6TN4JR.js";
4
+
5
+ // src/core/variants/constants.ts
6
+ var PREPR_CONTEXT_ALIAS = "_preprContext";
7
+ var PREPR_TYPE_ALIAS = "_preprType";
8
+ var PREPR_DEFAULT_VARIANT = "ALL_OTHER_USERS";
9
+
10
+ // src/core/variants/resolve.ts
11
+ function personalizationPaths(data) {
12
+ const paths = /* @__PURE__ */ new Map();
13
+ const walk = (value, path) => {
14
+ if (Array.isArray(value)) {
15
+ for (const item of value) {
16
+ if (contextOf(item)?.kind === "PERSONALIZATION") {
17
+ const record = item;
18
+ const type = record[PREPR_TYPE_ALIAS] ?? record.__typename;
19
+ const types = paths.get(path) ?? /* @__PURE__ */ new Set();
20
+ types.add(typeof type === "string" ? type : "*");
21
+ paths.set(path, types);
22
+ }
23
+ walk(item, path);
24
+ }
25
+ return;
26
+ }
27
+ if (!value || typeof value !== "object") return;
28
+ for (const [key, child] of Object.entries(value)) {
29
+ if (key !== PREPR_CONTEXT_ALIAS && key !== PREPR_TYPE_ALIAS)
30
+ walk(child, path ? `${path}.${key}` : key);
31
+ }
32
+ };
33
+ walk(data, "");
34
+ return paths;
35
+ }
36
+ function contextOf(item) {
37
+ if (!item || typeof item !== "object") return null;
38
+ const context = item[PREPR_CONTEXT_ALIAS];
39
+ const ctx = context;
40
+ return ctx?.kind && ctx.group_id ? ctx : null;
41
+ }
42
+ function decisionsFrom(data) {
43
+ const decisions = /* @__PURE__ */ new Map();
44
+ const walk = (value) => {
45
+ if (Array.isArray(value)) return value.forEach(walk);
46
+ if (!value || typeof value !== "object") return;
47
+ const ctx = contextOf(value);
48
+ if (ctx?.group_id && ctx.variant_id) {
49
+ const ids = decisions.get(ctx.group_id) ?? [];
50
+ if (!ids.includes(ctx.variant_id)) ids.push(ctx.variant_id);
51
+ decisions.set(ctx.group_id, ids);
52
+ }
53
+ Object.values(value).forEach(walk);
54
+ };
55
+ walk(data);
56
+ return decisions;
57
+ }
58
+ function chosenVariants(ctx, options) {
59
+ const decided = options.decisions?.get(ctx.group_id);
60
+ if (ctx.kind === "AB_TEST") {
61
+ return options.bucket ? [options.bucket] : decided ?? ["A"];
62
+ }
63
+ return decided ?? [PREPR_DEFAULT_VARIANT];
64
+ }
65
+ function resolveVariants(data, options = {}) {
66
+ const resolve = (value) => {
67
+ if (Array.isArray(value)) {
68
+ return value.filter((item) => {
69
+ const ctx = contextOf(item);
70
+ return !ctx || chosenVariants(ctx, options).includes(ctx.variant_id ?? "");
71
+ }).map(resolve);
72
+ }
73
+ if (!value || typeof value !== "object") return value;
74
+ const out = {};
75
+ for (const [key, child] of Object.entries(value)) out[key] = resolve(child);
76
+ return out;
77
+ };
78
+ return resolve(data);
79
+ }
80
+
81
+ // src/core/variants/schema.ts
82
+ var PREPR_SCHEMA_QUERY = `query PreprPersonalizationSchema {
83
+ __schema {
84
+ queryType { name }
85
+ types {
86
+ name
87
+ possibleTypes { name }
88
+ fields {
89
+ name
90
+ args { name }
91
+ type { name ofType { name ofType { name ofType { name ofType { name } } } } }
92
+ }
93
+ }
94
+ }
95
+ }`;
96
+ function namedType(ref) {
97
+ let current = ref;
98
+ while (current && !current.name) current = current.ofType;
99
+ return current?.name ?? "";
100
+ }
101
+ function toSchemaInfo(introspection) {
102
+ const types = {};
103
+ for (const type of introspection.__schema.types) {
104
+ if (type.name.startsWith("__")) continue;
105
+ const fields = {};
106
+ for (const field of type.fields ?? []) {
107
+ fields[field.name] = {
108
+ type: namedType(field.type),
109
+ personalizable: field.args.some((arg) => arg.name === "personalize")
110
+ };
111
+ }
112
+ types[type.name] = {
113
+ fields,
114
+ possibleTypes: (type.possibleTypes ?? []).map((t) => t.name),
115
+ hasContext: "_context" in fields
116
+ };
117
+ }
118
+ return { queryType: introspection.__schema.queryType.name, types };
119
+ }
120
+
121
+ // src/core/graphql/document.ts
122
+ import { print } from "graphql/language/printer.js";
123
+ import { stripIgnoredCharacters } from "graphql/utilities/stripIgnoredCharacters.js";
124
+ var printed = /* @__PURE__ */ new WeakMap();
125
+ function isDocumentNode(value) {
126
+ return typeof value === "object" && value !== null && value.kind === "Document" && Array.isArray(value.definitions);
127
+ }
128
+ function invalidDocument(originalError) {
129
+ return new PreprError(
130
+ "Expected a GraphQL query string, TypedDocumentString or DocumentNode",
131
+ "INVALID_DOCUMENT",
132
+ "createPreprClient",
133
+ originalError
134
+ );
135
+ }
136
+ var minified = /* @__PURE__ */ new Map();
137
+ var MINIFIED_CACHE_LIMIT = 500;
138
+ function minify(query) {
139
+ const cached = minified.get(query);
140
+ if (cached !== void 0) return cached;
141
+ let result = query;
142
+ try {
143
+ result = stripIgnoredCharacters(query);
144
+ } catch {
145
+ }
146
+ if (minified.size < MINIFIED_CACHE_LIMIT) minified.set(query, result);
147
+ return result;
148
+ }
149
+ function resolveQuery(document) {
150
+ if (typeof document === "string") return minify(document);
151
+ if (document instanceof String) return minify(document.toString());
152
+ if (!isDocumentNode(document)) throw invalidDocument();
153
+ let query = printed.get(document);
154
+ if (query === void 0) {
155
+ try {
156
+ query = minify(print(document));
157
+ } catch (error) {
158
+ throw invalidDocument(error instanceof Error ? error : void 0);
159
+ }
160
+ printed.set(document, query);
161
+ }
162
+ return query;
163
+ }
164
+
165
+ // src/core/variants/ast.ts
166
+ import { parse } from "graphql/language/parser.js";
167
+ var name = (value) => ({ kind: "Name", value });
168
+ function selectionSet(selections) {
169
+ return { kind: "SelectionSet", selections };
170
+ }
171
+ function contextField(withKey) {
172
+ const fields = ["kind", "group_id", "variant_id"];
173
+ if (withKey) fields.push("variant_key");
174
+ return {
175
+ kind: "Field",
176
+ alias: name(PREPR_CONTEXT_ALIAS),
177
+ name: name("_context"),
178
+ selectionSet: selectionSet(
179
+ fields.map(
180
+ (field) => ({ kind: "Field", name: name(field) })
181
+ )
182
+ )
183
+ };
184
+ }
185
+ function typenameField() {
186
+ return {
187
+ kind: "Field",
188
+ alias: name(PREPR_TYPE_ALIAS),
189
+ name: name("__typename")
190
+ };
191
+ }
192
+ function inlineFragment(typeName, selections) {
193
+ return {
194
+ kind: "InlineFragment",
195
+ typeCondition: { kind: "NamedType", name: name(typeName) },
196
+ selectionSet: selectionSet(selections)
197
+ };
198
+ }
199
+ function contextSelections(typeName, schema, onlyTypes, withType = true) {
200
+ const fields = () => withType ? [contextField(true), typenameField()] : [contextField(false)];
201
+ const type = schema.types[typeName];
202
+ if (!type) return [];
203
+ if (type.possibleTypes.length > 0) {
204
+ return type.possibleTypes.filter(
205
+ (member) => schema.types[member]?.hasContext && (!onlyTypes || onlyTypes.has(member))
206
+ ).map((member) => inlineFragment(member, fields()));
207
+ }
208
+ return type.hasContext ? fields() : [];
209
+ }
210
+ function withoutPersonalizeArg(args = []) {
211
+ return args.filter((arg) => arg.name.value !== "personalize");
212
+ }
213
+ function documentOf(document) {
214
+ if (typeof document === "string") return parse(document);
215
+ if (document instanceof String) return parse(document.toString());
216
+ return document;
217
+ }
218
+ function collectVariables(node, used) {
219
+ if (!node || typeof node !== "object") return;
220
+ if (Array.isArray(node)) {
221
+ for (const item of node) collectVariables(item, used);
222
+ return;
223
+ }
224
+ const value = node;
225
+ if (value.kind === "Variable") {
226
+ used.add(value.name.value);
227
+ return;
228
+ }
229
+ for (const key of Object.keys(value)) {
230
+ if (key !== "loc") collectVariables(value[key], used);
231
+ }
232
+ }
233
+
234
+ // src/core/variants/decision-document.ts
235
+ function decisionSelectionSet(set, typeName, path, ctx) {
236
+ const selections = [];
237
+ for (const selection of set.selections) {
238
+ if (selection.kind === "FragmentSpread") {
239
+ const fragment = ctx.fragments[selection.name.value];
240
+ if (!fragment) continue;
241
+ const pruned = decisionSelectionSet(
242
+ fragment.selectionSet,
243
+ fragment.typeCondition.name.value,
244
+ path,
245
+ ctx
246
+ );
247
+ if (!pruned) continue;
248
+ if (fragment.typeCondition.name.value === typeName) {
249
+ selections.push(...pruned.selections);
250
+ } else {
251
+ selections.push(
252
+ inlineFragment(fragment.typeCondition.name.value, [
253
+ ...pruned.selections
254
+ ])
255
+ );
256
+ }
257
+ continue;
258
+ }
259
+ if (selection.kind === "InlineFragment") {
260
+ const condition = selection.typeCondition?.name.value ?? typeName;
261
+ const pruned = decisionSelectionSet(
262
+ selection.selectionSet,
263
+ condition,
264
+ path,
265
+ ctx
266
+ );
267
+ if (!pruned) continue;
268
+ if (condition === typeName && !selection.directives?.length) {
269
+ selections.push(...pruned.selections);
270
+ } else {
271
+ selections.push({ ...selection, selectionSet: pruned });
272
+ }
273
+ continue;
274
+ }
275
+ if (!selection.selectionSet) continue;
276
+ const field = ctx.schema.types[typeName]?.fields[selection.name.value];
277
+ if (!field) continue;
278
+ const key = selection.alias?.value ?? selection.name.value;
279
+ const fieldPath = path ? `${path}.${key}` : key;
280
+ if (ctx.paths && !ctx.paths.prefixes.has(fieldPath)) continue;
281
+ const child = decisionSelectionSet(
282
+ selection.selectionSet,
283
+ field.type,
284
+ fieldPath,
285
+ ctx
286
+ );
287
+ const groupTypes = ctx.paths?.groups.get(fieldPath);
288
+ const holdsGroups = field.personalizable && (!ctx.paths || groupTypes !== void 0);
289
+ if (holdsGroups) {
290
+ selections.push({
291
+ ...selection,
292
+ arguments: withoutPersonalizeArg(selection.arguments),
293
+ selectionSet: selectionSet([
294
+ ...ctx.topLevelOnly ? [] : child?.selections ?? [],
295
+ ...contextSelections(
296
+ field.type,
297
+ ctx.schema,
298
+ groupTypes && !groupTypes.has("*") ? groupTypes : void 0,
299
+ false
300
+ )
301
+ ])
302
+ });
303
+ } else if (child) {
304
+ selections.push({
305
+ ...selection,
306
+ arguments: field.personalizable ? withoutPersonalizeArg(selection.arguments) : selection.arguments,
307
+ selectionSet: child
308
+ });
309
+ }
310
+ }
311
+ return selections.length > 0 ? selectionSet(selections) : null;
312
+ }
313
+ function toDecisionDocument(document, schema, groupPaths, options) {
314
+ const doc = documentOf(document);
315
+ const fragments = {};
316
+ for (const definition of doc.definitions) {
317
+ if (definition.kind === "FragmentDefinition") {
318
+ fragments[definition.name.value] = definition;
319
+ }
320
+ }
321
+ const operation = doc.definitions.find(
322
+ (definition) => definition.kind === "OperationDefinition"
323
+ );
324
+ if (!operation) return null;
325
+ let paths;
326
+ if (groupPaths) {
327
+ const prefixes = /* @__PURE__ */ new Set();
328
+ for (const groupPath of groupPaths.keys()) {
329
+ const parts = groupPath.split(".");
330
+ for (let i = 1; i <= parts.length; i++) {
331
+ prefixes.add(parts.slice(0, i).join("."));
332
+ }
333
+ }
334
+ paths = { groups: groupPaths, prefixes };
335
+ }
336
+ const pruned = decisionSelectionSet(
337
+ operation.selectionSet,
338
+ schema.queryType,
339
+ "",
340
+ { schema, fragments, paths, topLevelOnly: options?.topLevelOnly }
341
+ );
342
+ if (!pruned) return null;
343
+ const used = /* @__PURE__ */ new Set();
344
+ collectVariables(pruned, used);
345
+ collectVariables(operation.directives, used);
346
+ const shared = sharedContextFragment(schema);
347
+ return {
348
+ kind: "Document",
349
+ definitions: [
350
+ ...shared ? [shared.definition] : [],
351
+ {
352
+ ...operation,
353
+ name: operation.name && name(`${operation.name.value}Decision`),
354
+ variableDefinitions: (operation.variableDefinitions ?? []).filter(
355
+ (definition) => used.has(definition.variable.name.value)
356
+ ),
357
+ selectionSet: shared ? shared.apply(pruned) : pruned
358
+ }
359
+ ]
360
+ };
361
+ }
362
+ function sharedContextFragment(schema) {
363
+ const contextTypes = new Set(
364
+ Object.values(schema.types).flatMap(
365
+ (type) => type.hasContext ? [type.fields._context.type] : []
366
+ )
367
+ );
368
+ if (contextTypes.size !== 1) return null;
369
+ const [contextType] = contextTypes;
370
+ const fragmentName = "c";
371
+ const definition = {
372
+ kind: "FragmentDefinition",
373
+ name: name(fragmentName),
374
+ typeCondition: { kind: "NamedType", name: name(contextType) },
375
+ selectionSet: selectionSet(
376
+ ["kind", "group_id", "variant_id"].map(
377
+ (field) => ({ kind: "Field", name: name(field) })
378
+ )
379
+ )
380
+ };
381
+ const spread = {
382
+ kind: "FragmentSpread",
383
+ name: name(fragmentName)
384
+ };
385
+ const apply = (set) => selectionSet(
386
+ set.selections.map((selection) => {
387
+ if (selection.kind === "Field" && selection.alias?.value === PREPR_CONTEXT_ALIAS) {
388
+ return { ...selection, selectionSet: selectionSet([spread]) };
389
+ }
390
+ return "selectionSet" in selection && selection.selectionSet ? {
391
+ ...selection,
392
+ selectionSet: apply(selection.selectionSet)
393
+ } : selection;
394
+ })
395
+ );
396
+ return { definition, apply };
397
+ }
398
+
399
+ // src/core/variants/variants-document.ts
400
+ function variantsSelectionSet(set, typeName, schema) {
401
+ const selections = set.selections.map((selection) => {
402
+ if (selection.kind === "InlineFragment") {
403
+ return {
404
+ ...selection,
405
+ selectionSet: variantsSelectionSet(
406
+ selection.selectionSet,
407
+ selection.typeCondition?.name.value ?? typeName,
408
+ schema
409
+ )
410
+ };
411
+ }
412
+ if (selection.kind !== "Field" || !selection.selectionSet) return selection;
413
+ const field = schema.types[typeName]?.fields[selection.name.value];
414
+ if (!field) return selection;
415
+ const child = variantsSelectionSet(
416
+ selection.selectionSet,
417
+ field.type,
418
+ schema
419
+ );
420
+ if (!field.personalizable) return { ...selection, selectionSet: child };
421
+ return {
422
+ ...selection,
423
+ arguments: [
424
+ ...withoutPersonalizeArg(selection.arguments),
425
+ {
426
+ kind: "Argument",
427
+ name: name("personalize"),
428
+ value: { kind: "BooleanValue", value: false }
429
+ }
430
+ ],
431
+ selectionSet: selectionSet([
432
+ ...child.selections,
433
+ ...contextSelections(field.type, schema)
434
+ ])
435
+ };
436
+ });
437
+ return { ...set, selections };
438
+ }
439
+ function toVariantsDocument(document, schema) {
440
+ const doc = documentOf(document);
441
+ return {
442
+ ...doc,
443
+ definitions: doc.definitions.map((definition) => {
444
+ if (definition.kind === "OperationDefinition") {
445
+ return {
446
+ ...definition,
447
+ selectionSet: variantsSelectionSet(
448
+ definition.selectionSet,
449
+ schema.queryType,
450
+ schema
451
+ )
452
+ };
453
+ }
454
+ if (definition.kind === "FragmentDefinition") {
455
+ return {
456
+ ...definition,
457
+ selectionSet: variantsSelectionSet(
458
+ definition.selectionSet,
459
+ definition.typeCondition.name.value,
460
+ schema
461
+ )
462
+ };
463
+ }
464
+ return definition;
465
+ })
466
+ };
467
+ }
468
+
469
+ // src/core/variants/queries.ts
470
+ function toVariantsQuery(document, schema) {
471
+ return resolveQuery(toVariantsDocument(document, schema));
472
+ }
473
+ function toDecisionQuery(document, schema, options = {}) {
474
+ const paths = options.from === void 0 ? void 0 : personalizationPaths(options.from);
475
+ if (paths && paths.size === 0) return null;
476
+ const decision = toDecisionDocument(document, schema, paths, {
477
+ topLevelOnly: !paths && options.topLevelOnly
478
+ });
479
+ return decision ? resolveQuery(decision) : null;
480
+ }
481
+
482
+ export {
483
+ PREPR_DEFAULT_VARIANT,
484
+ name,
485
+ selectionSet,
486
+ documentOf,
487
+ collectVariables,
488
+ toDecisionDocument,
489
+ personalizationPaths,
490
+ contextOf,
491
+ decisionsFrom,
492
+ resolveVariants,
493
+ PREPR_SCHEMA_QUERY,
494
+ toSchemaInfo,
495
+ toVariantsDocument,
496
+ resolveQuery,
497
+ toVariantsQuery,
498
+ toDecisionQuery
499
+ };
@@ -1,24 +1,3 @@
1
- // src/version.ts
2
- var VERSION = "0.6.0-alpha.0";
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
- });
21
-
22
1
  // src/core/stega/clean.ts
23
2
  import { vercelStegaClean, vercelStegaDecode } from "@vercel/stega";
24
3
 
@@ -158,9 +137,6 @@ function decodeStega(str) {
158
137
  }
159
138
 
160
139
  export {
161
- VERSION,
162
- resolveFeatures,
163
- ALL_FEATURES_ENABLED,
164
140
  setTrustedParentOrigin,
165
141
  sendPreprEvent,
166
142
  initDebugLogger,
@@ -1,14 +1,7 @@
1
1
  import {
2
2
  VERSION,
3
3
  resolveFeatures
4
- } from "./chunk-DGZA7KX7.js";
5
-
6
- // src/core/personalization.ts
7
- var PERSONALIZED_VARY = /\bPrepr-(Segments|ABTesting)/i;
8
- function isPersonalizedResponse(source) {
9
- const headers = "headers" in source ? source.headers : source;
10
- return PERSONALIZED_VARY.test(headers.get("vary") ?? "");
11
- }
4
+ } from "./chunk-TN6SNAR2.js";
12
5
 
13
6
  // src/core/server.ts
14
7
  var PreprError = class extends Error {
@@ -174,7 +167,6 @@ async function getToolbarPropsFromHeaders(headers, token, features) {
174
167
  }
175
168
 
176
169
  export {
177
- isPersonalizedResponse,
178
170
  PreprError,
179
171
  getPreprUUIDFromHeaders,
180
172
  getActiveSegmentFromHeaders,
@@ -0,0 +1,26 @@
1
+ // src/version.ts
2
+ var VERSION = "0.6.0-alpha.10";
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
+ });
21
+
22
+ export {
23
+ VERSION,
24
+ resolveFeatures,
25
+ ALL_FEATURES_ENABLED
26
+ };