@uniformdev/next-app-router 20.75.1-alpha.0 → 20.76.1-alpha.3
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/{UniformComposition-BWxMuY7i.d.ts → UniformComposition-Ck7mRTp-.d.ts} +5 -0
- package/dist/{UniformComposition-Bo6UsTDC.d.mts → UniformComposition-CpEVJ-SR.d.mts} +5 -0
- package/dist/cache.js +3 -1
- package/dist/cache.mjs +3 -1
- package/dist/compat.d.mts +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/component.d.mts +2 -2
- package/dist/component.d.ts +2 -2
- package/dist/component.js +31 -15
- package/dist/component.mjs +18 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.esm.js +3241 -485
- package/dist/index.js +3249 -496
- package/dist/index.mjs +3241 -485
- package/dist/middleware.js +172 -213
- package/dist/middleware.mjs +169 -210
- package/package.json +8 -8
package/dist/middleware.js
CHANGED
|
@@ -3012,7 +3012,9 @@ var DefaultDataClient = class {
|
|
|
3012
3012
|
source: "middleware",
|
|
3013
3013
|
route: options.route,
|
|
3014
3014
|
routeClient,
|
|
3015
|
-
|
|
3015
|
+
// The runtime cache is keyed on the route path. Development bypasses it so an author sees
|
|
3016
|
+
// an edit right away, the same way the fetch cache is bypassed for development.
|
|
3017
|
+
enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache() && !isDevelopmentEnvironment(),
|
|
3016
3018
|
disableSwrCache: getDisableSwrMiddlewareCache()
|
|
3017
3019
|
});
|
|
3018
3020
|
if (resolvedRoute.type === "composition") {
|
|
@@ -3069,16 +3071,82 @@ var DefaultDataClient = class {
|
|
|
3069
3071
|
}
|
|
3070
3072
|
};
|
|
3071
3073
|
|
|
3074
|
+
// src/middleware/composition/evaluate/evaluateRunnables.ts
|
|
3075
|
+
var import_next_app_router_shared = require("@uniformdev/next-app-router-shared");
|
|
3076
|
+
var evaluateRunnables = async ({
|
|
3077
|
+
runnables,
|
|
3078
|
+
context,
|
|
3079
|
+
compositionContext,
|
|
3080
|
+
isPrefetch
|
|
3081
|
+
}) => {
|
|
3082
|
+
var _a;
|
|
3083
|
+
const result = {
|
|
3084
|
+
components: {},
|
|
3085
|
+
rules: void 0
|
|
3086
|
+
};
|
|
3087
|
+
const runnablesToProcess = runnables.filter((item2) => item2.variantId === void 0);
|
|
3088
|
+
let item;
|
|
3089
|
+
while (item = runnablesToProcess.shift()) {
|
|
3090
|
+
if (item.type === "test" && isPrefetch) {
|
|
3091
|
+
continue;
|
|
3092
|
+
}
|
|
3093
|
+
if (item.type === "test") {
|
|
3094
|
+
const testResult = (0, import_next_app_router_shared.evaluateTest)({
|
|
3095
|
+
context,
|
|
3096
|
+
test: item.result,
|
|
3097
|
+
compositionContext
|
|
3098
|
+
});
|
|
3099
|
+
if (testResult.index !== null) {
|
|
3100
|
+
result.components[item._id] = {
|
|
3101
|
+
indexes: [testResult.index]
|
|
3102
|
+
};
|
|
3103
|
+
if (testResult.componentId) {
|
|
3104
|
+
const dependentRunnables = runnables.filter((r) => r.variantId === testResult.componentId);
|
|
3105
|
+
runnablesToProcess.push(...dependentRunnables);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
} else if (item.type === "personalization") {
|
|
3109
|
+
const personalizationResult = (0, import_next_app_router_shared.evaluatePersonalization)({
|
|
3110
|
+
context,
|
|
3111
|
+
personalization: item.result,
|
|
3112
|
+
compositionContext
|
|
3113
|
+
});
|
|
3114
|
+
if (personalizationResult.indexes.length) {
|
|
3115
|
+
result.components[item._id] = {
|
|
3116
|
+
indexes: personalizationResult.indexes
|
|
3117
|
+
};
|
|
3118
|
+
}
|
|
3119
|
+
if (personalizationResult.componentIds.length) {
|
|
3120
|
+
const dependentRunnables = runnables.filter(
|
|
3121
|
+
(r) => r.variantId && personalizationResult.componentIds.includes(r.variantId)
|
|
3122
|
+
);
|
|
3123
|
+
runnablesToProcess.push(...dependentRunnables);
|
|
3124
|
+
}
|
|
3125
|
+
} else if (item.type === "visibility") {
|
|
3126
|
+
const rules = createQuirksVisibilityRule(context.quirks);
|
|
3127
|
+
const isVisible = evaluateNodeVisibilityParameter({
|
|
3128
|
+
rules,
|
|
3129
|
+
parameter: item.rules
|
|
3130
|
+
});
|
|
3131
|
+
if (isVisible !== null) {
|
|
3132
|
+
result.rules = (_a = result.rules) != null ? _a : {};
|
|
3133
|
+
result.rules[item._id] = isVisible;
|
|
3134
|
+
}
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
return result;
|
|
3138
|
+
};
|
|
3139
|
+
|
|
3072
3140
|
// src/data/extract/extractRunnables.ts
|
|
3073
|
-
var
|
|
3141
|
+
var import_next_app_router_shared4 = require("@uniformdev/next-app-router-shared");
|
|
3074
3142
|
|
|
3075
3143
|
// src/data/extract/extractPersonalization.ts
|
|
3076
|
-
var
|
|
3144
|
+
var import_next_app_router_shared2 = require("@uniformdev/next-app-router-shared");
|
|
3077
3145
|
var extractPersonalization = ({
|
|
3078
3146
|
component
|
|
3079
3147
|
}) => {
|
|
3080
3148
|
var _a, _b, _c;
|
|
3081
|
-
const trackingEventName = (0,
|
|
3149
|
+
const trackingEventName = (0, import_next_app_router_shared2.extractPersonalizationName)({ component });
|
|
3082
3150
|
const countParameter = (_a = component.parameters) == null ? void 0 : _a.count;
|
|
3083
3151
|
const algorithmParameter = (_b = component.parameters) == null ? void 0 : _b.algorithm;
|
|
3084
3152
|
const count = countParameter == null ? void 0 : countParameter.value;
|
|
@@ -3114,10 +3182,10 @@ var extractPersonalization = ({
|
|
|
3114
3182
|
};
|
|
3115
3183
|
|
|
3116
3184
|
// src/data/extract/extractTest.ts
|
|
3117
|
-
var
|
|
3185
|
+
var import_next_app_router_shared3 = require("@uniformdev/next-app-router-shared");
|
|
3118
3186
|
var extractTest = ({ component }) => {
|
|
3119
3187
|
var _a;
|
|
3120
|
-
const testName = (0,
|
|
3188
|
+
const testName = (0, import_next_app_router_shared3.extractTestName)({ component });
|
|
3121
3189
|
const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_TEST_SLOT]) || [];
|
|
3122
3190
|
const componentVariations = mapSlotToTestVariations(slot).map((variation, index) => {
|
|
3123
3191
|
const slotComponent = slot[index];
|
|
@@ -3173,7 +3241,7 @@ var extractRunnables = (composition) => {
|
|
|
3173
3241
|
if (visibilityRules) {
|
|
3174
3242
|
runnable.push({
|
|
3175
3243
|
type: "visibility",
|
|
3176
|
-
_id: (0,
|
|
3244
|
+
_id: (0, import_next_app_router_shared4.getRuleId)(visibilityRules),
|
|
3177
3245
|
variantId: findAncestorVariant(node.ancestorsAndSelf),
|
|
3178
3246
|
rules: visibilityRules
|
|
3179
3247
|
});
|
|
@@ -3183,6 +3251,41 @@ var extractRunnables = (composition) => {
|
|
|
3183
3251
|
return runnable;
|
|
3184
3252
|
};
|
|
3185
3253
|
|
|
3254
|
+
// src/data/evaluate/evaluatePageState.ts
|
|
3255
|
+
var evaluatePageState = async ({
|
|
3256
|
+
composition,
|
|
3257
|
+
matchedRoute,
|
|
3258
|
+
dynamicInputs,
|
|
3259
|
+
pageState,
|
|
3260
|
+
context
|
|
3261
|
+
}) => {
|
|
3262
|
+
const extracted = extractRunnables(composition);
|
|
3263
|
+
const result = await evaluateRunnables({
|
|
3264
|
+
runnables: extracted,
|
|
3265
|
+
context,
|
|
3266
|
+
isPrefetch: pageState.isPrefetch,
|
|
3267
|
+
compositionContext: {
|
|
3268
|
+
_id: composition._id,
|
|
3269
|
+
type: composition.type,
|
|
3270
|
+
state: pageState.compositionState,
|
|
3271
|
+
isContextualEditing: pageState.compositionState === CANVAS_EDITOR_STATE,
|
|
3272
|
+
matchedRoute,
|
|
3273
|
+
dynamicInputs,
|
|
3274
|
+
pageState: {
|
|
3275
|
+
...pageState,
|
|
3276
|
+
// empty for now, we need to pass composition metadata down to evaluateRunnables for Context events enrichment
|
|
3277
|
+
components: {},
|
|
3278
|
+
rules: void 0
|
|
3279
|
+
}
|
|
3280
|
+
}
|
|
3281
|
+
});
|
|
3282
|
+
const allComponentIds = extracted.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
3283
|
+
return {
|
|
3284
|
+
...result,
|
|
3285
|
+
allComponentIds
|
|
3286
|
+
};
|
|
3287
|
+
};
|
|
3288
|
+
|
|
3186
3289
|
// src/data/routes.ts
|
|
3187
3290
|
var findRouteMatch = (routes, path) => {
|
|
3188
3291
|
const pieces = path.split("/").filter(Boolean);
|
|
@@ -3214,72 +3317,6 @@ var findRouteMatch = (routes, path) => {
|
|
|
3214
3317
|
return void 0;
|
|
3215
3318
|
};
|
|
3216
3319
|
|
|
3217
|
-
// src/middleware/composition/evaluate/evaluateRunnables.ts
|
|
3218
|
-
var import_next_app_router_shared4 = require("@uniformdev/next-app-router-shared");
|
|
3219
|
-
var evaluateRunnables = async ({
|
|
3220
|
-
runnables,
|
|
3221
|
-
context,
|
|
3222
|
-
compositionContext,
|
|
3223
|
-
isPrefetch
|
|
3224
|
-
}) => {
|
|
3225
|
-
var _a;
|
|
3226
|
-
const result = {
|
|
3227
|
-
components: {},
|
|
3228
|
-
rules: void 0
|
|
3229
|
-
};
|
|
3230
|
-
const runnablesToProcess = runnables.filter((item2) => item2.variantId === void 0);
|
|
3231
|
-
let item;
|
|
3232
|
-
while (item = runnablesToProcess.shift()) {
|
|
3233
|
-
if (item.type === "test" && isPrefetch) {
|
|
3234
|
-
continue;
|
|
3235
|
-
}
|
|
3236
|
-
if (item.type === "test") {
|
|
3237
|
-
const testResult = (0, import_next_app_router_shared4.evaluateTest)({
|
|
3238
|
-
context,
|
|
3239
|
-
test: item.result,
|
|
3240
|
-
compositionContext
|
|
3241
|
-
});
|
|
3242
|
-
if (testResult.index !== null) {
|
|
3243
|
-
result.components[item._id] = {
|
|
3244
|
-
indexes: [testResult.index]
|
|
3245
|
-
};
|
|
3246
|
-
if (testResult.componentId) {
|
|
3247
|
-
const dependentRunnables = runnables.filter((r) => r.variantId === testResult.componentId);
|
|
3248
|
-
runnablesToProcess.push(...dependentRunnables);
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
} else if (item.type === "personalization") {
|
|
3252
|
-
const personalizationResult = (0, import_next_app_router_shared4.evaluatePersonalization)({
|
|
3253
|
-
context,
|
|
3254
|
-
personalization: item.result,
|
|
3255
|
-
compositionContext
|
|
3256
|
-
});
|
|
3257
|
-
if (personalizationResult.indexes.length) {
|
|
3258
|
-
result.components[item._id] = {
|
|
3259
|
-
indexes: personalizationResult.indexes
|
|
3260
|
-
};
|
|
3261
|
-
}
|
|
3262
|
-
if (personalizationResult.componentIds.length) {
|
|
3263
|
-
const dependentRunnables = runnables.filter(
|
|
3264
|
-
(r) => r.variantId && personalizationResult.componentIds.includes(r.variantId)
|
|
3265
|
-
);
|
|
3266
|
-
runnablesToProcess.push(...dependentRunnables);
|
|
3267
|
-
}
|
|
3268
|
-
} else if (item.type === "visibility") {
|
|
3269
|
-
const rules = createQuirksVisibilityRule(context.quirks);
|
|
3270
|
-
const isVisible = evaluateNodeVisibilityParameter({
|
|
3271
|
-
rules,
|
|
3272
|
-
parameter: item.rules
|
|
3273
|
-
});
|
|
3274
|
-
if (isVisible !== null) {
|
|
3275
|
-
result.rules = (_a = result.rules) != null ? _a : {};
|
|
3276
|
-
result.rules[item._id] = isVisible;
|
|
3277
|
-
}
|
|
3278
|
-
}
|
|
3279
|
-
}
|
|
3280
|
-
return result;
|
|
3281
|
-
};
|
|
3282
|
-
|
|
3283
3320
|
// ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
3284
3321
|
var has = Object.prototype.hasOwnProperty;
|
|
3285
3322
|
function dequal(foo, bar) {
|
|
@@ -4371,8 +4408,8 @@ var TransitionDataStore = class {
|
|
|
4371
4408
|
}
|
|
4372
4409
|
/**
|
|
4373
4410
|
* Updates data in the transition storage.
|
|
4374
|
-
* @param commands Commands to execute against existing stored value (event based stores)
|
|
4375
|
-
* @param computedValue Pre-computed new value against existing value (object based stores)
|
|
4411
|
+
* @param commands - Commands to execute against existing stored value (event based stores)
|
|
4412
|
+
* @param computedValue - Pre-computed new value against existing value (object based stores)
|
|
4376
4413
|
* @returns Resolved promise when the data has been updated
|
|
4377
4414
|
*/
|
|
4378
4415
|
updateData(commands, computedValue) {
|
|
@@ -4848,7 +4885,7 @@ var VisitorDataStore = class {
|
|
|
4848
4885
|
/**
|
|
4849
4886
|
* Deletes visitor data (forgetting them)
|
|
4850
4887
|
* In most cases you should use forget() on the Context instead of this function, which also clears the Context state.
|
|
4851
|
-
* @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
|
|
4888
|
+
* @param fromAllDevices - for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
|
|
4852
4889
|
*/
|
|
4853
4890
|
async delete(fromAllDevices) {
|
|
4854
4891
|
var _a, _b, _c, _d, _e;
|
|
@@ -5367,7 +5404,7 @@ var Context = class {
|
|
|
5367
5404
|
}
|
|
5368
5405
|
/**
|
|
5369
5406
|
* Forgets the visitor's data and resets the Context to its initial state.
|
|
5370
|
-
* @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
|
|
5407
|
+
* @param fromAllDevices - for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
|
|
5371
5408
|
*/
|
|
5372
5409
|
async forget(fromAllDevices) {
|
|
5373
5410
|
const previousCompositionMetadata = __privateGet4(this, _state).compositionMetadata;
|
|
@@ -5408,14 +5445,14 @@ var Context = class {
|
|
|
5408
5445
|
});
|
|
5409
5446
|
return transitionState;
|
|
5410
5447
|
}
|
|
5411
|
-
/** @deprecated */
|
|
5448
|
+
/** @deprecated Internal API for test event processing; not for public use. */
|
|
5412
5449
|
internal_processTestEvent(event) {
|
|
5413
5450
|
if (event.variantId) {
|
|
5414
5451
|
this.setTestVariantId(event.name, event.variantId);
|
|
5415
5452
|
__privateMethod(this, _Context_instances, emitTest_fn).call(this, event);
|
|
5416
5453
|
}
|
|
5417
5454
|
}
|
|
5418
|
-
/** @deprecated */
|
|
5455
|
+
/** @deprecated Internal API for personalization event processing; not for public use. */
|
|
5419
5456
|
internal_processPersonalizationEvent(event) {
|
|
5420
5457
|
__privateGet4(this, _pzCache)[event.name] = event.variantIds;
|
|
5421
5458
|
__privateGet4(this, _mitt3).emit("personalizationResult", event);
|
|
@@ -5488,7 +5525,8 @@ var dc2 = (0, import_rfdc3.default)();
|
|
|
5488
5525
|
|
|
5489
5526
|
// src/middleware/context/index.ts
|
|
5490
5527
|
var createOnDemandContext = async (options) => {
|
|
5491
|
-
|
|
5528
|
+
var _a;
|
|
5529
|
+
const manifest = await options.dataClient.getManifest({ source: (_a = options.source) != null ? _a : "middleware" });
|
|
5492
5530
|
if (!manifest) {
|
|
5493
5531
|
console.error("Uniform manifest not found, falling back to empty manifest");
|
|
5494
5532
|
}
|
|
@@ -5612,6 +5650,22 @@ var determineState = async ({
|
|
|
5612
5650
|
return isDraftMode ? (isCanvasEditing ? [CANVAS_EDITOR_STATE] : []).concat([CANVAS_DRAFT_STATE]) : [CANVAS_PUBLISHED_STATE];
|
|
5613
5651
|
};
|
|
5614
5652
|
|
|
5653
|
+
// src/utils/quirks.ts
|
|
5654
|
+
var buildQuirksFromHeaders = (headers) => {
|
|
5655
|
+
const headerToQuirkKey = {
|
|
5656
|
+
"x-vercel-ip-country": "vc-country",
|
|
5657
|
+
"x-vercel-ip-country-region": "vc-region",
|
|
5658
|
+
"x-vercel-ip-city": "vc-city"
|
|
5659
|
+
};
|
|
5660
|
+
return Object.entries(headerToQuirkKey).reduce((acc, [headerName, quirkKey]) => {
|
|
5661
|
+
const value = headers.get(headerName);
|
|
5662
|
+
if (value) {
|
|
5663
|
+
acc[quirkKey] = value;
|
|
5664
|
+
}
|
|
5665
|
+
return acc;
|
|
5666
|
+
}, {});
|
|
5667
|
+
};
|
|
5668
|
+
|
|
5615
5669
|
// src/middleware.ts
|
|
5616
5670
|
var uniformMiddleware = (options) => {
|
|
5617
5671
|
return async (request) => {
|
|
@@ -5650,26 +5704,11 @@ var isPlaygroundPath = (path) => {
|
|
|
5650
5704
|
);
|
|
5651
5705
|
return (match == null ? void 0 : match.route.id) === PLAYGROUND_ID ? match : void 0;
|
|
5652
5706
|
};
|
|
5653
|
-
var buildQuirksFromHeaders = (headers) => {
|
|
5654
|
-
const headerToQuirkKey = {
|
|
5655
|
-
"x-vercel-ip-country": "vc-country",
|
|
5656
|
-
"x-vercel-ip-country-region": "vc-region",
|
|
5657
|
-
"x-vercel-ip-city": "vc-city"
|
|
5658
|
-
};
|
|
5659
|
-
return Object.entries(headerToQuirkKey).reduce((acc, [headerName, quirkKey]) => {
|
|
5660
|
-
const value = headers.get(headerName);
|
|
5661
|
-
if (value) {
|
|
5662
|
-
acc[quirkKey] = value;
|
|
5663
|
-
}
|
|
5664
|
-
return acc;
|
|
5665
|
-
}, {});
|
|
5666
|
-
};
|
|
5667
5707
|
var handlePlaygroundRequest = async ({
|
|
5668
5708
|
request,
|
|
5669
|
-
options
|
|
5670
|
-
dataClient
|
|
5709
|
+
options
|
|
5671
5710
|
}) => {
|
|
5672
|
-
var _a
|
|
5711
|
+
var _a;
|
|
5673
5712
|
const id = request.nextUrl.searchParams.get("id");
|
|
5674
5713
|
if (!id) {
|
|
5675
5714
|
return import_server.NextResponse.json(
|
|
@@ -5711,41 +5750,12 @@ var handlePlaygroundRequest = async ({
|
|
|
5711
5750
|
}
|
|
5712
5751
|
const serverConfig = getServerConfig();
|
|
5713
5752
|
const playgroundPath = getPlaygroundPath();
|
|
5714
|
-
const onDemandContext = await createOnDemandContext({
|
|
5715
|
-
cookies: request.cookies,
|
|
5716
|
-
dataClient,
|
|
5717
|
-
defaultConsent: determineDefaultConsent({
|
|
5718
|
-
serverConfig,
|
|
5719
|
-
defaultConsent: options.defaultConsent
|
|
5720
|
-
})
|
|
5721
|
-
});
|
|
5722
|
-
const context = await onDemandContext.getContext();
|
|
5723
|
-
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
5724
|
-
composition: composition.composition,
|
|
5725
|
-
routePath: id,
|
|
5726
|
-
state: composition.state,
|
|
5727
|
-
context,
|
|
5728
|
-
matchedRoute: id,
|
|
5729
|
-
dynamicInputs: {},
|
|
5730
|
-
releaseId: (_a = options.release) == null ? void 0 : _a.id,
|
|
5731
|
-
defaultConsent: determineDefaultConsent({
|
|
5732
|
-
serverConfig,
|
|
5733
|
-
defaultConsent: options.defaultConsent
|
|
5734
|
-
}),
|
|
5735
|
-
keys: void 0,
|
|
5736
|
-
previewMode: determinePreviewMode({
|
|
5737
|
-
searchParams: request.nextUrl.searchParams,
|
|
5738
|
-
isDraftModeEnabled: true
|
|
5739
|
-
// this is checked above
|
|
5740
|
-
}),
|
|
5741
|
-
isPrefetch: false
|
|
5742
|
-
});
|
|
5743
5753
|
const pageState = {
|
|
5744
5754
|
routePath: id,
|
|
5745
5755
|
compositionState: composition.state,
|
|
5746
|
-
components,
|
|
5756
|
+
components: {},
|
|
5747
5757
|
keys: void 0,
|
|
5748
|
-
releaseId: (
|
|
5758
|
+
releaseId: (_a = options.release) == null ? void 0 : _a.id,
|
|
5749
5759
|
defaultConsent: determineDefaultConsent({
|
|
5750
5760
|
serverConfig,
|
|
5751
5761
|
defaultConsent: options.defaultConsent
|
|
@@ -5755,13 +5765,13 @@ var handlePlaygroundRequest = async ({
|
|
|
5755
5765
|
isDraftModeEnabled: true
|
|
5756
5766
|
// this is checked above
|
|
5757
5767
|
}),
|
|
5758
|
-
rules,
|
|
5768
|
+
rules: void 0,
|
|
5759
5769
|
locale: options.locale,
|
|
5760
|
-
isPrefetch: void 0
|
|
5770
|
+
isPrefetch: void 0,
|
|
5771
|
+
requestPath: `${request.nextUrl.pathname}${request.nextUrl.search}`
|
|
5761
5772
|
};
|
|
5762
5773
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5763
|
-
payload: pageState
|
|
5764
|
-
allComponentIds
|
|
5774
|
+
payload: pageState
|
|
5765
5775
|
});
|
|
5766
5776
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "playground" }) : void 0);
|
|
5767
5777
|
if (!pathToRewriteTo) {
|
|
@@ -5844,30 +5854,10 @@ var handleRouteRequest = async ({
|
|
|
5844
5854
|
isDraftModeEnabled: draftModeEnabled
|
|
5845
5855
|
});
|
|
5846
5856
|
const isPrefetch = isPrefetchRequest(request);
|
|
5847
|
-
const
|
|
5848
|
-
composition: route.compositionApiResponse.composition,
|
|
5849
|
-
routePath,
|
|
5850
|
-
state,
|
|
5851
|
-
context,
|
|
5852
|
-
matchedRoute: route.matchedRoute,
|
|
5853
|
-
dynamicInputs: (_g = route.dynamicInputs) != null ? _g : {},
|
|
5854
|
-
releaseId,
|
|
5855
|
-
defaultConsent: determineDefaultConsent({
|
|
5856
|
-
serverConfig,
|
|
5857
|
-
defaultConsent: options.defaultConsent
|
|
5858
|
-
}),
|
|
5859
|
-
keys: requestPath.keys,
|
|
5860
|
-
previewMode: determinePreviewMode({
|
|
5861
|
-
searchParams: request.nextUrl.searchParams,
|
|
5862
|
-
isDraftModeEnabled: true
|
|
5863
|
-
// this is checked above
|
|
5864
|
-
}),
|
|
5865
|
-
isPrefetch
|
|
5866
|
-
});
|
|
5867
|
-
const pageState = {
|
|
5857
|
+
const basePageState = {
|
|
5868
5858
|
routePath,
|
|
5869
5859
|
compositionState: state,
|
|
5870
|
-
components,
|
|
5860
|
+
components: {},
|
|
5871
5861
|
keys: requestPath.keys,
|
|
5872
5862
|
releaseId,
|
|
5873
5863
|
defaultConsent: determineDefaultConsent({
|
|
@@ -5875,10 +5865,32 @@ var handleRouteRequest = async ({
|
|
|
5875
5865
|
defaultConsent: options.defaultConsent
|
|
5876
5866
|
}),
|
|
5877
5867
|
previewMode,
|
|
5878
|
-
rules,
|
|
5868
|
+
rules: void 0,
|
|
5879
5869
|
locale: options.locale,
|
|
5880
|
-
isPrefetch: isPrefetch || void 0
|
|
5870
|
+
isPrefetch: isPrefetch || void 0,
|
|
5871
|
+
// Draft requests evaluate while the page renders, so they carry with them the inputs that
|
|
5872
|
+
// cannot be derived again there: the request path, and any custom quirks the consumer
|
|
5873
|
+
// supplied to the middleware. Quirks from request headers are rebuilt at render time.
|
|
5874
|
+
requestPath: draftModeEnabled ? `${request.nextUrl.pathname}${request.nextUrl.search}` : void 0,
|
|
5875
|
+
quirks: draftModeEnabled ? options.quirks : void 0
|
|
5881
5876
|
};
|
|
5877
|
+
let pageState = basePageState;
|
|
5878
|
+
let allComponentIds = void 0;
|
|
5879
|
+
if (!draftModeEnabled) {
|
|
5880
|
+
const evaluated = await evaluatePageState({
|
|
5881
|
+
composition: route.compositionApiResponse.composition,
|
|
5882
|
+
matchedRoute: route.matchedRoute,
|
|
5883
|
+
dynamicInputs: (_g = route.dynamicInputs) != null ? _g : {},
|
|
5884
|
+
pageState: basePageState,
|
|
5885
|
+
context
|
|
5886
|
+
});
|
|
5887
|
+
pageState = {
|
|
5888
|
+
...basePageState,
|
|
5889
|
+
components: evaluated.components,
|
|
5890
|
+
rules: evaluated.rules
|
|
5891
|
+
};
|
|
5892
|
+
allComponentIds = evaluated.allComponentIds;
|
|
5893
|
+
}
|
|
5882
5894
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5883
5895
|
payload: pageState,
|
|
5884
5896
|
allComponentIds
|
|
@@ -5901,49 +5913,6 @@ var handleRouteRequest = async ({
|
|
|
5901
5913
|
var isPrefetchRequest = (request) => {
|
|
5902
5914
|
return request.headers.has("next-url");
|
|
5903
5915
|
};
|
|
5904
|
-
var extractAndEvaluateRunnables = async ({
|
|
5905
|
-
composition,
|
|
5906
|
-
routePath,
|
|
5907
|
-
context,
|
|
5908
|
-
state,
|
|
5909
|
-
matchedRoute,
|
|
5910
|
-
dynamicInputs,
|
|
5911
|
-
releaseId,
|
|
5912
|
-
defaultConsent,
|
|
5913
|
-
keys,
|
|
5914
|
-
previewMode,
|
|
5915
|
-
isPrefetch
|
|
5916
|
-
}) => {
|
|
5917
|
-
const extracted = extractRunnables(composition);
|
|
5918
|
-
const result = await evaluateRunnables({
|
|
5919
|
-
runnables: extracted,
|
|
5920
|
-
context,
|
|
5921
|
-
isPrefetch,
|
|
5922
|
-
compositionContext: {
|
|
5923
|
-
_id: composition._id,
|
|
5924
|
-
type: composition.type,
|
|
5925
|
-
state,
|
|
5926
|
-
isContextualEditing: state === CANVAS_EDITOR_STATE,
|
|
5927
|
-
matchedRoute,
|
|
5928
|
-
dynamicInputs,
|
|
5929
|
-
pageState: {
|
|
5930
|
-
routePath,
|
|
5931
|
-
compositionState: state,
|
|
5932
|
-
// empty for now, we need to pass composition metadata down to evaluateRunnables for Context events enrichment
|
|
5933
|
-
components: {},
|
|
5934
|
-
keys,
|
|
5935
|
-
releaseId,
|
|
5936
|
-
defaultConsent,
|
|
5937
|
-
previewMode,
|
|
5938
|
-
rules: void 0,
|
|
5939
|
-
locale: void 0,
|
|
5940
|
-
isPrefetch: isPrefetch || void 0
|
|
5941
|
-
}
|
|
5942
|
-
}
|
|
5943
|
-
});
|
|
5944
|
-
const allComponentIds = extracted.filter((r) => r.type === "test" || r.type === "personalization").map((r) => r._id);
|
|
5945
|
-
return { ...result, allComponentIds };
|
|
5946
|
-
};
|
|
5947
5916
|
var handleRedirect = ({ request, route }) => {
|
|
5948
5917
|
const href = resolveRedirectHref({
|
|
5949
5918
|
resolveResult: route,
|
|
@@ -5966,7 +5935,7 @@ var buildRoutePath = ({
|
|
|
5966
5935
|
pathname,
|
|
5967
5936
|
route
|
|
5968
5937
|
}) => {
|
|
5969
|
-
var _a, _b, _c;
|
|
5938
|
+
var _a, _b, _c, _d;
|
|
5970
5939
|
const [routePath, search] = pathname.split("?");
|
|
5971
5940
|
const locale = (_a = route.dynamicInputs) == null ? void 0 : _a.locale;
|
|
5972
5941
|
const projectMapNode = (_b = route.compositionApiResponse.composition.projectMapNodes) == null ? void 0 : _b.find((node) => {
|
|
@@ -5981,22 +5950,12 @@ var buildRoutePath = ({
|
|
|
5981
5950
|
});
|
|
5982
5951
|
const searchParams = new URLSearchParams();
|
|
5983
5952
|
if ((_c = projectMapNode == null ? void 0 : projectMapNode.data) == null ? void 0 : _c.queryStrings) {
|
|
5984
|
-
|
|
5985
|
-
const existingSearchParams = new URLSearchParams(search);
|
|
5986
|
-
for (const [key, value] of existingSearchParams.entries()) {
|
|
5987
|
-
searchParams.set(key, value);
|
|
5988
|
-
}
|
|
5989
|
-
}
|
|
5953
|
+
const existingSearchParams = search ? new URLSearchParams(search) : void 0;
|
|
5990
5954
|
for (const qs of projectMapNode.data.queryStrings) {
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
searchParams.set(qs.name, qsValue != null ? qsValue : "");
|
|
5994
|
-
}
|
|
5955
|
+
const existingValue = existingSearchParams == null ? void 0 : existingSearchParams.get(qs.name);
|
|
5956
|
+
searchParams.set(qs.name, (_d = existingValue != null ? existingValue : qs.value) != null ? _d : "");
|
|
5995
5957
|
}
|
|
5996
5958
|
}
|
|
5997
|
-
if (process.env.NODE_ENV === "development") {
|
|
5998
|
-
searchParams.set("cache", (/* @__PURE__ */ new Date()).valueOf().toString());
|
|
5999
|
-
}
|
|
6000
5959
|
if (searchParams.size) {
|
|
6001
5960
|
return `${routePath}?${searchParams.toString()}`;
|
|
6002
5961
|
}
|