@uniformdev/next-app-router-shared 20.56.1-alpha.21 → 20.56.2-alpha.5

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/dist/index.d.mts CHANGED
@@ -79,8 +79,18 @@ declare const resolveRuleFromPageState: ({ pageState, rule, }: {
79
79
  pageState: PageState;
80
80
  rule: VisibilityParameterValue;
81
81
  }) => boolean | undefined;
82
- declare const serializeEvaluationResult: ({ payload }: {
82
+ declare const serializeEvaluationResult: ({ payload, allComponentIds, }: {
83
83
  payload: PageState;
84
+ /**
85
+ * All test and personalization component IDs on the page, including ones inside
86
+ * unselected personalization variants that were not evaluated by the middleware.
87
+ *
88
+ * Not serialized into the output. Only used to widen the prefix compression
89
+ * namespace so that compressed keys are long enough to be unique across every
90
+ * component on the page, preventing false-positive prefix matches during
91
+ * {@link resolveComponentFromPageState} lookups.
92
+ */
93
+ allComponentIds?: string[];
84
94
  }) => string;
85
95
  declare const deserializeEvaluationResult: ({ input: providedInput, decode, }: {
86
96
  input: string;
package/dist/index.d.ts CHANGED
@@ -79,8 +79,18 @@ declare const resolveRuleFromPageState: ({ pageState, rule, }: {
79
79
  pageState: PageState;
80
80
  rule: VisibilityParameterValue;
81
81
  }) => boolean | undefined;
82
- declare const serializeEvaluationResult: ({ payload }: {
82
+ declare const serializeEvaluationResult: ({ payload, allComponentIds, }: {
83
83
  payload: PageState;
84
+ /**
85
+ * All test and personalization component IDs on the page, including ones inside
86
+ * unselected personalization variants that were not evaluated by the middleware.
87
+ *
88
+ * Not serialized into the output. Only used to widen the prefix compression
89
+ * namespace so that compressed keys are long enough to be unique across every
90
+ * component on the page, preventing false-positive prefix matches during
91
+ * {@link resolveComponentFromPageState} lookups.
92
+ */
93
+ allComponentIds?: string[];
84
94
  }) => string;
85
95
  declare const deserializeEvaluationResult: ({ input: providedInput, decode, }: {
86
96
  input: string;
package/dist/index.esm.js CHANGED
@@ -242,7 +242,7 @@ var decodeFlags = (hex) => {
242
242
  isPrefetch: flags & 16 ? true : void 0
243
243
  };
244
244
  };
245
- var serializeV2 = (payload) => {
245
+ var serializeV2 = (payload, allComponentIds) => {
246
246
  const parts = ["2"];
247
247
  parts.push(String(payload.compositionState));
248
248
  parts.push(toBase64Url(payload.routePath));
@@ -252,7 +252,12 @@ var serializeV2 = (payload) => {
252
252
  _id: isNotARegularUuid(key) ? v5(key, NAMESPACE_UUID) : key,
253
253
  ...payload.components[key]
254
254
  }));
255
- const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
255
+ const evaluatedIds = sortedComponents.map((c) => c._id);
256
+ const normalizedAllIds = allComponentIds == null ? void 0 : allComponentIds.map(
257
+ (id) => isNotARegularUuid(id) ? v5(id, NAMESPACE_UUID) : id
258
+ );
259
+ const compressionNamespace = normalizedAllIds ? [.../* @__PURE__ */ new Set([...evaluatedIds, ...normalizedAllIds])].sort() : evaluatedIds;
260
+ const compressedComponentIds = compressIds(compressionNamespace);
256
261
  const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
257
262
  const componentEntries = [];
258
263
  Object.keys(compressedComponentIds).forEach((compressedId) => {
@@ -260,7 +265,7 @@ var serializeV2 = (payload) => {
260
265
  const originalId = compressedComponentIds[compressedId];
261
266
  const component = componentById.get(originalId);
262
267
  if (!component) {
263
- throw new Error(`Component ${originalId} not found`);
268
+ return;
264
269
  }
265
270
  const indexes = ((_a = component.indexes) == null ? void 0 : _a.length) ? component.indexes : void 0;
266
271
  if (indexes) {
@@ -379,8 +384,11 @@ var deserializeV2 = (input) => {
379
384
  isPrefetch
380
385
  };
381
386
  };
382
- var serializeEvaluationResult = ({ payload }) => {
383
- return serializeV2(payload);
387
+ var serializeEvaluationResult = ({
388
+ payload,
389
+ allComponentIds
390
+ }) => {
391
+ return serializeV2(payload, allComponentIds);
384
392
  };
385
393
  var deserializeEvaluationResult = ({
386
394
  input: providedInput,
package/dist/index.js CHANGED
@@ -277,7 +277,7 @@ var decodeFlags = (hex) => {
277
277
  isPrefetch: flags & 16 ? true : void 0
278
278
  };
279
279
  };
280
- var serializeV2 = (payload) => {
280
+ var serializeV2 = (payload, allComponentIds) => {
281
281
  const parts = ["2"];
282
282
  parts.push(String(payload.compositionState));
283
283
  parts.push(toBase64Url(payload.routePath));
@@ -287,7 +287,12 @@ var serializeV2 = (payload) => {
287
287
  _id: isNotARegularUuid(key) ? (0, import_uuid.v5)(key, NAMESPACE_UUID) : key,
288
288
  ...payload.components[key]
289
289
  }));
290
- const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
290
+ const evaluatedIds = sortedComponents.map((c) => c._id);
291
+ const normalizedAllIds = allComponentIds == null ? void 0 : allComponentIds.map(
292
+ (id) => isNotARegularUuid(id) ? (0, import_uuid.v5)(id, NAMESPACE_UUID) : id
293
+ );
294
+ const compressionNamespace = normalizedAllIds ? [.../* @__PURE__ */ new Set([...evaluatedIds, ...normalizedAllIds])].sort() : evaluatedIds;
295
+ const compressedComponentIds = compressIds(compressionNamespace);
291
296
  const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
292
297
  const componentEntries = [];
293
298
  Object.keys(compressedComponentIds).forEach((compressedId) => {
@@ -295,7 +300,7 @@ var serializeV2 = (payload) => {
295
300
  const originalId = compressedComponentIds[compressedId];
296
301
  const component = componentById.get(originalId);
297
302
  if (!component) {
298
- throw new Error(`Component ${originalId} not found`);
303
+ return;
299
304
  }
300
305
  const indexes = ((_a = component.indexes) == null ? void 0 : _a.length) ? component.indexes : void 0;
301
306
  if (indexes) {
@@ -414,8 +419,11 @@ var deserializeV2 = (input) => {
414
419
  isPrefetch
415
420
  };
416
421
  };
417
- var serializeEvaluationResult = ({ payload }) => {
418
- return serializeV2(payload);
422
+ var serializeEvaluationResult = ({
423
+ payload,
424
+ allComponentIds
425
+ }) => {
426
+ return serializeV2(payload, allComponentIds);
419
427
  };
420
428
  var deserializeEvaluationResult = ({
421
429
  input: providedInput,
package/dist/index.mjs CHANGED
@@ -242,7 +242,7 @@ var decodeFlags = (hex) => {
242
242
  isPrefetch: flags & 16 ? true : void 0
243
243
  };
244
244
  };
245
- var serializeV2 = (payload) => {
245
+ var serializeV2 = (payload, allComponentIds) => {
246
246
  const parts = ["2"];
247
247
  parts.push(String(payload.compositionState));
248
248
  parts.push(toBase64Url(payload.routePath));
@@ -252,7 +252,12 @@ var serializeV2 = (payload) => {
252
252
  _id: isNotARegularUuid(key) ? v5(key, NAMESPACE_UUID) : key,
253
253
  ...payload.components[key]
254
254
  }));
255
- const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
255
+ const evaluatedIds = sortedComponents.map((c) => c._id);
256
+ const normalizedAllIds = allComponentIds == null ? void 0 : allComponentIds.map(
257
+ (id) => isNotARegularUuid(id) ? v5(id, NAMESPACE_UUID) : id
258
+ );
259
+ const compressionNamespace = normalizedAllIds ? [.../* @__PURE__ */ new Set([...evaluatedIds, ...normalizedAllIds])].sort() : evaluatedIds;
260
+ const compressedComponentIds = compressIds(compressionNamespace);
256
261
  const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
257
262
  const componentEntries = [];
258
263
  Object.keys(compressedComponentIds).forEach((compressedId) => {
@@ -260,7 +265,7 @@ var serializeV2 = (payload) => {
260
265
  const originalId = compressedComponentIds[compressedId];
261
266
  const component = componentById.get(originalId);
262
267
  if (!component) {
263
- throw new Error(`Component ${originalId} not found`);
268
+ return;
264
269
  }
265
270
  const indexes = ((_a = component.indexes) == null ? void 0 : _a.length) ? component.indexes : void 0;
266
271
  if (indexes) {
@@ -379,8 +384,11 @@ var deserializeV2 = (input) => {
379
384
  isPrefetch
380
385
  };
381
386
  };
382
- var serializeEvaluationResult = ({ payload }) => {
383
- return serializeV2(payload);
387
+ var serializeEvaluationResult = ({
388
+ payload,
389
+ allComponentIds
390
+ }) => {
391
+ return serializeV2(payload, allComponentIds);
384
392
  };
385
393
  var deserializeEvaluationResult = ({
386
394
  input: providedInput,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/next-app-router-shared",
3
- "version": "20.56.1-alpha.21+28f83064e9",
3
+ "version": "20.56.2-alpha.5+ae5a0d2550",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -36,8 +36,8 @@
36
36
  "vitest": "3.2.4"
37
37
  },
38
38
  "dependencies": {
39
- "@uniformdev/canvas": "20.56.1-alpha.21+28f83064e9",
40
- "@uniformdev/context": "20.56.1-alpha.21+28f83064e9",
39
+ "@uniformdev/canvas": "20.56.2-alpha.5+ae5a0d2550",
40
+ "@uniformdev/context": "20.56.2-alpha.5+ae5a0d2550",
41
41
  "uuid": "9.0.1"
42
42
  },
43
43
  "engines": {
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "28f83064e9573adbe807d4ec989ee57a2b311fa8"
54
+ "gitHead": "ae5a0d255085f10d36ad4f557d393536033eac7f"
55
55
  }