@uniformdev/next-app-router-shared 20.54.1-alpha.1 → 20.55.1
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 +1 -3
- package/dist/index.d.ts +1 -3
- package/dist/index.esm.js +33 -12
- package/dist/index.js +33 -12
- package/dist/index.mjs +33 -12
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -79,10 +79,8 @@ 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 }: {
|
|
83
83
|
payload: PageState;
|
|
84
|
-
/** @deprecated No longer needed — v2 format is URL-safe by default. */
|
|
85
|
-
encode?: boolean;
|
|
86
84
|
}) => string;
|
|
87
85
|
declare const deserializeEvaluationResult: ({ input: providedInput, decode, }: {
|
|
88
86
|
input: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -79,10 +79,8 @@ 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 }: {
|
|
83
83
|
payload: PageState;
|
|
84
|
-
/** @deprecated No longer needed — v2 format is URL-safe by default. */
|
|
85
|
-
encode?: boolean;
|
|
86
84
|
}) => string;
|
|
87
85
|
declare const deserializeEvaluationResult: ({ input: providedInput, decode, }: {
|
|
88
86
|
input: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -253,11 +253,12 @@ var serializeV2 = (payload) => {
|
|
|
253
253
|
...payload.components[key]
|
|
254
254
|
}));
|
|
255
255
|
const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
|
|
256
|
+
const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
|
|
256
257
|
const componentEntries = [];
|
|
257
258
|
Object.keys(compressedComponentIds).forEach((compressedId) => {
|
|
258
259
|
var _a;
|
|
259
260
|
const originalId = compressedComponentIds[compressedId];
|
|
260
|
-
const component =
|
|
261
|
+
const component = componentById.get(originalId);
|
|
261
262
|
if (!component) {
|
|
262
263
|
throw new Error(`Component ${originalId} not found`);
|
|
263
264
|
}
|
|
@@ -286,9 +287,7 @@ var serializeV2 = (payload) => {
|
|
|
286
287
|
parts.push(rulesStr);
|
|
287
288
|
let keysStr = "";
|
|
288
289
|
if (payload.keys) {
|
|
289
|
-
const keyEntries = Object.entries(payload.keys).map(
|
|
290
|
-
([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`
|
|
291
|
-
);
|
|
290
|
+
const keyEntries = Object.entries(payload.keys).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`);
|
|
292
291
|
keysStr = keyEntries.join(V2_ENTRY_SEP);
|
|
293
292
|
}
|
|
294
293
|
parts.push(keysStr);
|
|
@@ -297,20 +296,38 @@ var serializeV2 = (payload) => {
|
|
|
297
296
|
parts.push(payload.locale ? toBase64Url(payload.locale) : "");
|
|
298
297
|
return parts.join(V2_FIELD_SEP);
|
|
299
298
|
};
|
|
299
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
300
|
+
var isUnsafeKey = (key) => UNSAFE_KEYS.has(key);
|
|
300
301
|
var deserializeV2 = (input) => {
|
|
301
302
|
var _a, _b, _c, _d;
|
|
302
303
|
const fields = input.split(V2_FIELD_SEP);
|
|
303
|
-
|
|
304
|
+
if (fields.length < 3) {
|
|
305
|
+
throw new Error(`Invalid serialized PageState: expected at least 3 fields but got ${fields.length}`);
|
|
306
|
+
}
|
|
307
|
+
const compositionStateRaw = fields[1];
|
|
308
|
+
const compositionState = Number.parseInt(compositionStateRaw, 10);
|
|
309
|
+
if (Number.isNaN(compositionState)) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Invalid serialized PageState: compositionState '${compositionStateRaw}' is not a valid number`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
304
314
|
const routePath = fromBase64Url(fields[2]);
|
|
305
|
-
const components =
|
|
315
|
+
const components = /* @__PURE__ */ Object.create(null);
|
|
306
316
|
const componentsStr = (_a = fields[3]) != null ? _a : "";
|
|
307
317
|
if (componentsStr) {
|
|
308
318
|
componentsStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
309
319
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
310
320
|
if (sepIdx === -1) {
|
|
311
|
-
|
|
321
|
+
const id = entry;
|
|
322
|
+
if (isUnsafeKey(id)) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
components[id] = {};
|
|
312
326
|
} else {
|
|
313
327
|
const id = entry.slice(0, sepIdx);
|
|
328
|
+
if (isUnsafeKey(id)) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
314
331
|
const indexes = entry.slice(sepIdx + 1).split(V2_INDEX_SEP).map(Number);
|
|
315
332
|
components[id] = { indexes };
|
|
316
333
|
}
|
|
@@ -319,22 +336,28 @@ var deserializeV2 = (input) => {
|
|
|
319
336
|
const rulesStr = (_b = fields[4]) != null ? _b : "";
|
|
320
337
|
let rules;
|
|
321
338
|
if (rulesStr) {
|
|
322
|
-
rules =
|
|
339
|
+
rules = /* @__PURE__ */ Object.create(null);
|
|
323
340
|
rulesStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
324
341
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
325
342
|
if (sepIdx !== -1) {
|
|
326
343
|
const id = entry.slice(0, sepIdx);
|
|
344
|
+
if (isUnsafeKey(id)) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
327
347
|
rules[id] = entry.slice(sepIdx + 1) === "1";
|
|
328
348
|
}
|
|
329
349
|
});
|
|
330
350
|
}
|
|
331
351
|
const keysStr = (_c = fields[5]) != null ? _c : "";
|
|
332
|
-
const keys =
|
|
352
|
+
const keys = /* @__PURE__ */ Object.create(null);
|
|
333
353
|
if (keysStr) {
|
|
334
354
|
keysStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
335
355
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
336
356
|
if (sepIdx !== -1) {
|
|
337
357
|
const k = fromBase64Url(entry.slice(0, sepIdx));
|
|
358
|
+
if (isUnsafeKey(k)) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
338
361
|
const v = fromBase64Url(entry.slice(sepIdx + 1));
|
|
339
362
|
keys[k] = v;
|
|
340
363
|
}
|
|
@@ -356,9 +379,7 @@ var deserializeV2 = (input) => {
|
|
|
356
379
|
isPrefetch
|
|
357
380
|
};
|
|
358
381
|
};
|
|
359
|
-
var serializeEvaluationResult = ({
|
|
360
|
-
payload
|
|
361
|
-
}) => {
|
|
382
|
+
var serializeEvaluationResult = ({ payload }) => {
|
|
362
383
|
return serializeV2(payload);
|
|
363
384
|
};
|
|
364
385
|
var deserializeEvaluationResult = ({
|
package/dist/index.js
CHANGED
|
@@ -288,11 +288,12 @@ var serializeV2 = (payload) => {
|
|
|
288
288
|
...payload.components[key]
|
|
289
289
|
}));
|
|
290
290
|
const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
|
|
291
|
+
const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
|
|
291
292
|
const componentEntries = [];
|
|
292
293
|
Object.keys(compressedComponentIds).forEach((compressedId) => {
|
|
293
294
|
var _a;
|
|
294
295
|
const originalId = compressedComponentIds[compressedId];
|
|
295
|
-
const component =
|
|
296
|
+
const component = componentById.get(originalId);
|
|
296
297
|
if (!component) {
|
|
297
298
|
throw new Error(`Component ${originalId} not found`);
|
|
298
299
|
}
|
|
@@ -321,9 +322,7 @@ var serializeV2 = (payload) => {
|
|
|
321
322
|
parts.push(rulesStr);
|
|
322
323
|
let keysStr = "";
|
|
323
324
|
if (payload.keys) {
|
|
324
|
-
const keyEntries = Object.entries(payload.keys).map(
|
|
325
|
-
([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`
|
|
326
|
-
);
|
|
325
|
+
const keyEntries = Object.entries(payload.keys).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`);
|
|
327
326
|
keysStr = keyEntries.join(V2_ENTRY_SEP);
|
|
328
327
|
}
|
|
329
328
|
parts.push(keysStr);
|
|
@@ -332,20 +331,38 @@ var serializeV2 = (payload) => {
|
|
|
332
331
|
parts.push(payload.locale ? toBase64Url(payload.locale) : "");
|
|
333
332
|
return parts.join(V2_FIELD_SEP);
|
|
334
333
|
};
|
|
334
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
335
|
+
var isUnsafeKey = (key) => UNSAFE_KEYS.has(key);
|
|
335
336
|
var deserializeV2 = (input) => {
|
|
336
337
|
var _a, _b, _c, _d;
|
|
337
338
|
const fields = input.split(V2_FIELD_SEP);
|
|
338
|
-
|
|
339
|
+
if (fields.length < 3) {
|
|
340
|
+
throw new Error(`Invalid serialized PageState: expected at least 3 fields but got ${fields.length}`);
|
|
341
|
+
}
|
|
342
|
+
const compositionStateRaw = fields[1];
|
|
343
|
+
const compositionState = Number.parseInt(compositionStateRaw, 10);
|
|
344
|
+
if (Number.isNaN(compositionState)) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
`Invalid serialized PageState: compositionState '${compositionStateRaw}' is not a valid number`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
339
349
|
const routePath = fromBase64Url(fields[2]);
|
|
340
|
-
const components =
|
|
350
|
+
const components = /* @__PURE__ */ Object.create(null);
|
|
341
351
|
const componentsStr = (_a = fields[3]) != null ? _a : "";
|
|
342
352
|
if (componentsStr) {
|
|
343
353
|
componentsStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
344
354
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
345
355
|
if (sepIdx === -1) {
|
|
346
|
-
|
|
356
|
+
const id = entry;
|
|
357
|
+
if (isUnsafeKey(id)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
components[id] = {};
|
|
347
361
|
} else {
|
|
348
362
|
const id = entry.slice(0, sepIdx);
|
|
363
|
+
if (isUnsafeKey(id)) {
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
349
366
|
const indexes = entry.slice(sepIdx + 1).split(V2_INDEX_SEP).map(Number);
|
|
350
367
|
components[id] = { indexes };
|
|
351
368
|
}
|
|
@@ -354,22 +371,28 @@ var deserializeV2 = (input) => {
|
|
|
354
371
|
const rulesStr = (_b = fields[4]) != null ? _b : "";
|
|
355
372
|
let rules;
|
|
356
373
|
if (rulesStr) {
|
|
357
|
-
rules =
|
|
374
|
+
rules = /* @__PURE__ */ Object.create(null);
|
|
358
375
|
rulesStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
359
376
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
360
377
|
if (sepIdx !== -1) {
|
|
361
378
|
const id = entry.slice(0, sepIdx);
|
|
379
|
+
if (isUnsafeKey(id)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
362
382
|
rules[id] = entry.slice(sepIdx + 1) === "1";
|
|
363
383
|
}
|
|
364
384
|
});
|
|
365
385
|
}
|
|
366
386
|
const keysStr = (_c = fields[5]) != null ? _c : "";
|
|
367
|
-
const keys =
|
|
387
|
+
const keys = /* @__PURE__ */ Object.create(null);
|
|
368
388
|
if (keysStr) {
|
|
369
389
|
keysStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
370
390
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
371
391
|
if (sepIdx !== -1) {
|
|
372
392
|
const k = fromBase64Url(entry.slice(0, sepIdx));
|
|
393
|
+
if (isUnsafeKey(k)) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
373
396
|
const v = fromBase64Url(entry.slice(sepIdx + 1));
|
|
374
397
|
keys[k] = v;
|
|
375
398
|
}
|
|
@@ -391,9 +414,7 @@ var deserializeV2 = (input) => {
|
|
|
391
414
|
isPrefetch
|
|
392
415
|
};
|
|
393
416
|
};
|
|
394
|
-
var serializeEvaluationResult = ({
|
|
395
|
-
payload
|
|
396
|
-
}) => {
|
|
417
|
+
var serializeEvaluationResult = ({ payload }) => {
|
|
397
418
|
return serializeV2(payload);
|
|
398
419
|
};
|
|
399
420
|
var deserializeEvaluationResult = ({
|
package/dist/index.mjs
CHANGED
|
@@ -253,11 +253,12 @@ var serializeV2 = (payload) => {
|
|
|
253
253
|
...payload.components[key]
|
|
254
254
|
}));
|
|
255
255
|
const compressedComponentIds = compressIds(sortedComponents.map((c) => c._id));
|
|
256
|
+
const componentById = new Map(sortedComponents.map((c) => [c._id, c]));
|
|
256
257
|
const componentEntries = [];
|
|
257
258
|
Object.keys(compressedComponentIds).forEach((compressedId) => {
|
|
258
259
|
var _a;
|
|
259
260
|
const originalId = compressedComponentIds[compressedId];
|
|
260
|
-
const component =
|
|
261
|
+
const component = componentById.get(originalId);
|
|
261
262
|
if (!component) {
|
|
262
263
|
throw new Error(`Component ${originalId} not found`);
|
|
263
264
|
}
|
|
@@ -286,9 +287,7 @@ var serializeV2 = (payload) => {
|
|
|
286
287
|
parts.push(rulesStr);
|
|
287
288
|
let keysStr = "";
|
|
288
289
|
if (payload.keys) {
|
|
289
|
-
const keyEntries = Object.entries(payload.keys).map(
|
|
290
|
-
([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`
|
|
291
|
-
);
|
|
290
|
+
const keyEntries = Object.entries(payload.keys).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => `${toBase64Url(k)}${V2_KV_SEP}${toBase64Url(v)}`);
|
|
292
291
|
keysStr = keyEntries.join(V2_ENTRY_SEP);
|
|
293
292
|
}
|
|
294
293
|
parts.push(keysStr);
|
|
@@ -297,20 +296,38 @@ var serializeV2 = (payload) => {
|
|
|
297
296
|
parts.push(payload.locale ? toBase64Url(payload.locale) : "");
|
|
298
297
|
return parts.join(V2_FIELD_SEP);
|
|
299
298
|
};
|
|
299
|
+
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
300
|
+
var isUnsafeKey = (key) => UNSAFE_KEYS.has(key);
|
|
300
301
|
var deserializeV2 = (input) => {
|
|
301
302
|
var _a, _b, _c, _d;
|
|
302
303
|
const fields = input.split(V2_FIELD_SEP);
|
|
303
|
-
|
|
304
|
+
if (fields.length < 3) {
|
|
305
|
+
throw new Error(`Invalid serialized PageState: expected at least 3 fields but got ${fields.length}`);
|
|
306
|
+
}
|
|
307
|
+
const compositionStateRaw = fields[1];
|
|
308
|
+
const compositionState = Number.parseInt(compositionStateRaw, 10);
|
|
309
|
+
if (Number.isNaN(compositionState)) {
|
|
310
|
+
throw new Error(
|
|
311
|
+
`Invalid serialized PageState: compositionState '${compositionStateRaw}' is not a valid number`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
304
314
|
const routePath = fromBase64Url(fields[2]);
|
|
305
|
-
const components =
|
|
315
|
+
const components = /* @__PURE__ */ Object.create(null);
|
|
306
316
|
const componentsStr = (_a = fields[3]) != null ? _a : "";
|
|
307
317
|
if (componentsStr) {
|
|
308
318
|
componentsStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
309
319
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
310
320
|
if (sepIdx === -1) {
|
|
311
|
-
|
|
321
|
+
const id = entry;
|
|
322
|
+
if (isUnsafeKey(id)) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
components[id] = {};
|
|
312
326
|
} else {
|
|
313
327
|
const id = entry.slice(0, sepIdx);
|
|
328
|
+
if (isUnsafeKey(id)) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
314
331
|
const indexes = entry.slice(sepIdx + 1).split(V2_INDEX_SEP).map(Number);
|
|
315
332
|
components[id] = { indexes };
|
|
316
333
|
}
|
|
@@ -319,22 +336,28 @@ var deserializeV2 = (input) => {
|
|
|
319
336
|
const rulesStr = (_b = fields[4]) != null ? _b : "";
|
|
320
337
|
let rules;
|
|
321
338
|
if (rulesStr) {
|
|
322
|
-
rules =
|
|
339
|
+
rules = /* @__PURE__ */ Object.create(null);
|
|
323
340
|
rulesStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
324
341
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
325
342
|
if (sepIdx !== -1) {
|
|
326
343
|
const id = entry.slice(0, sepIdx);
|
|
344
|
+
if (isUnsafeKey(id)) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
327
347
|
rules[id] = entry.slice(sepIdx + 1) === "1";
|
|
328
348
|
}
|
|
329
349
|
});
|
|
330
350
|
}
|
|
331
351
|
const keysStr = (_c = fields[5]) != null ? _c : "";
|
|
332
|
-
const keys =
|
|
352
|
+
const keys = /* @__PURE__ */ Object.create(null);
|
|
333
353
|
if (keysStr) {
|
|
334
354
|
keysStr.split(V2_ENTRY_SEP).forEach((entry) => {
|
|
335
355
|
const sepIdx = entry.indexOf(V2_KV_SEP);
|
|
336
356
|
if (sepIdx !== -1) {
|
|
337
357
|
const k = fromBase64Url(entry.slice(0, sepIdx));
|
|
358
|
+
if (isUnsafeKey(k)) {
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
338
361
|
const v = fromBase64Url(entry.slice(sepIdx + 1));
|
|
339
362
|
keys[k] = v;
|
|
340
363
|
}
|
|
@@ -356,9 +379,7 @@ var deserializeV2 = (input) => {
|
|
|
356
379
|
isPrefetch
|
|
357
380
|
};
|
|
358
381
|
};
|
|
359
|
-
var serializeEvaluationResult = ({
|
|
360
|
-
payload
|
|
361
|
-
}) => {
|
|
382
|
+
var serializeEvaluationResult = ({ payload }) => {
|
|
362
383
|
return serializeV2(payload);
|
|
363
384
|
};
|
|
364
385
|
var deserializeEvaluationResult = ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/next-app-router-shared",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.55.1",
|
|
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.
|
|
40
|
-
"@uniformdev/context": "20.
|
|
39
|
+
"@uniformdev/canvas": "20.55.1",
|
|
40
|
+
"@uniformdev/context": "20.55.1",
|
|
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": "
|
|
54
|
+
"gitHead": "44d778abd699dafbabda982cb3295be043ba3cb0"
|
|
55
55
|
}
|