@uniformdev/next-app-router 20.76.1-alpha.3 → 20.76.3-alpha.7.sha-dd3877d123
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-Ck7mRTp-.d.ts → UniformComposition-BWxMuY7i.d.ts} +0 -5
- package/dist/{UniformComposition-CpEVJ-SR.d.mts → UniformComposition-Bo6UsTDC.d.mts} +0 -5
- package/dist/cache.js +1 -3
- package/dist/cache.mjs +1 -3
- package/dist/compat.d.mts +1 -1
- package/dist/compat.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +458 -3214
- package/dist/index.js +467 -3220
- package/dist/index.mjs +458 -3214
- package/dist/middleware.js +207 -166
- package/dist/middleware.mjs +204 -163
- package/package.json +10 -10
package/dist/middleware.js
CHANGED
|
@@ -3012,9 +3012,7 @@ var DefaultDataClient = class {
|
|
|
3012
3012
|
source: "middleware",
|
|
3013
3013
|
route: options.route,
|
|
3014
3014
|
routeClient,
|
|
3015
|
-
|
|
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(),
|
|
3015
|
+
enableRuntimeCache: options.route.state === CANVAS_PUBLISHED_STATE && getMiddlewareRuntimeCache(),
|
|
3018
3016
|
disableSwrCache: getDisableSwrMiddlewareCache()
|
|
3019
3017
|
});
|
|
3020
3018
|
if (resolvedRoute.type === "composition") {
|
|
@@ -3071,82 +3069,16 @@ var DefaultDataClient = class {
|
|
|
3071
3069
|
}
|
|
3072
3070
|
};
|
|
3073
3071
|
|
|
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
|
-
|
|
3140
3072
|
// src/data/extract/extractRunnables.ts
|
|
3141
|
-
var
|
|
3073
|
+
var import_next_app_router_shared3 = require("@uniformdev/next-app-router-shared");
|
|
3142
3074
|
|
|
3143
3075
|
// src/data/extract/extractPersonalization.ts
|
|
3144
|
-
var
|
|
3076
|
+
var import_next_app_router_shared = require("@uniformdev/next-app-router-shared");
|
|
3145
3077
|
var extractPersonalization = ({
|
|
3146
3078
|
component
|
|
3147
3079
|
}) => {
|
|
3148
3080
|
var _a, _b, _c;
|
|
3149
|
-
const trackingEventName = (0,
|
|
3081
|
+
const trackingEventName = (0, import_next_app_router_shared.extractPersonalizationName)({ component });
|
|
3150
3082
|
const countParameter = (_a = component.parameters) == null ? void 0 : _a.count;
|
|
3151
3083
|
const algorithmParameter = (_b = component.parameters) == null ? void 0 : _b.algorithm;
|
|
3152
3084
|
const count = countParameter == null ? void 0 : countParameter.value;
|
|
@@ -3182,10 +3114,10 @@ var extractPersonalization = ({
|
|
|
3182
3114
|
};
|
|
3183
3115
|
|
|
3184
3116
|
// src/data/extract/extractTest.ts
|
|
3185
|
-
var
|
|
3117
|
+
var import_next_app_router_shared2 = require("@uniformdev/next-app-router-shared");
|
|
3186
3118
|
var extractTest = ({ component }) => {
|
|
3187
3119
|
var _a;
|
|
3188
|
-
const testName = (0,
|
|
3120
|
+
const testName = (0, import_next_app_router_shared2.extractTestName)({ component });
|
|
3189
3121
|
const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_TEST_SLOT]) || [];
|
|
3190
3122
|
const componentVariations = mapSlotToTestVariations(slot).map((variation, index) => {
|
|
3191
3123
|
const slotComponent = slot[index];
|
|
@@ -3241,7 +3173,7 @@ var extractRunnables = (composition) => {
|
|
|
3241
3173
|
if (visibilityRules) {
|
|
3242
3174
|
runnable.push({
|
|
3243
3175
|
type: "visibility",
|
|
3244
|
-
_id: (0,
|
|
3176
|
+
_id: (0, import_next_app_router_shared3.getRuleId)(visibilityRules),
|
|
3245
3177
|
variantId: findAncestorVariant(node.ancestorsAndSelf),
|
|
3246
3178
|
rules: visibilityRules
|
|
3247
3179
|
});
|
|
@@ -3251,41 +3183,6 @@ var extractRunnables = (composition) => {
|
|
|
3251
3183
|
return runnable;
|
|
3252
3184
|
};
|
|
3253
3185
|
|
|
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
|
-
|
|
3289
3186
|
// src/data/routes.ts
|
|
3290
3187
|
var findRouteMatch = (routes, path) => {
|
|
3291
3188
|
const pieces = path.split("/").filter(Boolean);
|
|
@@ -3317,6 +3214,72 @@ var findRouteMatch = (routes, path) => {
|
|
|
3317
3214
|
return void 0;
|
|
3318
3215
|
};
|
|
3319
3216
|
|
|
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
|
+
|
|
3320
3283
|
// ../../node_modules/.pnpm/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
3321
3284
|
var has = Object.prototype.hasOwnProperty;
|
|
3322
3285
|
function dequal(foo, bar) {
|
|
@@ -5525,8 +5488,7 @@ var dc2 = (0, import_rfdc3.default)();
|
|
|
5525
5488
|
|
|
5526
5489
|
// src/middleware/context/index.ts
|
|
5527
5490
|
var createOnDemandContext = async (options) => {
|
|
5528
|
-
|
|
5529
|
-
const manifest = await options.dataClient.getManifest({ source: (_a = options.source) != null ? _a : "middleware" });
|
|
5491
|
+
const manifest = await options.dataClient.getManifest({ source: "middleware" });
|
|
5530
5492
|
if (!manifest) {
|
|
5531
5493
|
console.error("Uniform manifest not found, falling back to empty manifest");
|
|
5532
5494
|
}
|
|
@@ -5650,22 +5612,6 @@ var determineState = async ({
|
|
|
5650
5612
|
return isDraftMode ? (isCanvasEditing ? [CANVAS_EDITOR_STATE] : []).concat([CANVAS_DRAFT_STATE]) : [CANVAS_PUBLISHED_STATE];
|
|
5651
5613
|
};
|
|
5652
5614
|
|
|
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
|
-
|
|
5669
5615
|
// src/middleware.ts
|
|
5670
5616
|
var uniformMiddleware = (options) => {
|
|
5671
5617
|
return async (request) => {
|
|
@@ -5704,11 +5650,26 @@ var isPlaygroundPath = (path) => {
|
|
|
5704
5650
|
);
|
|
5705
5651
|
return (match == null ? void 0 : match.route.id) === PLAYGROUND_ID ? match : void 0;
|
|
5706
5652
|
};
|
|
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
|
+
};
|
|
5707
5667
|
var handlePlaygroundRequest = async ({
|
|
5708
5668
|
request,
|
|
5709
|
-
options
|
|
5669
|
+
options,
|
|
5670
|
+
dataClient
|
|
5710
5671
|
}) => {
|
|
5711
|
-
var _a;
|
|
5672
|
+
var _a, _b;
|
|
5712
5673
|
const id = request.nextUrl.searchParams.get("id");
|
|
5713
5674
|
if (!id) {
|
|
5714
5675
|
return import_server.NextResponse.json(
|
|
@@ -5750,12 +5711,41 @@ var handlePlaygroundRequest = async ({
|
|
|
5750
5711
|
}
|
|
5751
5712
|
const serverConfig = getServerConfig();
|
|
5752
5713
|
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
|
+
});
|
|
5753
5743
|
const pageState = {
|
|
5754
5744
|
routePath: id,
|
|
5755
5745
|
compositionState: composition.state,
|
|
5756
|
-
components
|
|
5746
|
+
components,
|
|
5757
5747
|
keys: void 0,
|
|
5758
|
-
releaseId: (
|
|
5748
|
+
releaseId: (_b = options.release) == null ? void 0 : _b.id,
|
|
5759
5749
|
defaultConsent: determineDefaultConsent({
|
|
5760
5750
|
serverConfig,
|
|
5761
5751
|
defaultConsent: options.defaultConsent
|
|
@@ -5765,13 +5755,13 @@ var handlePlaygroundRequest = async ({
|
|
|
5765
5755
|
isDraftModeEnabled: true
|
|
5766
5756
|
// this is checked above
|
|
5767
5757
|
}),
|
|
5768
|
-
rules
|
|
5758
|
+
rules,
|
|
5769
5759
|
locale: options.locale,
|
|
5770
|
-
isPrefetch: void 0
|
|
5771
|
-
requestPath: `${request.nextUrl.pathname}${request.nextUrl.search}`
|
|
5760
|
+
isPrefetch: void 0
|
|
5772
5761
|
};
|
|
5773
5762
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5774
|
-
payload: pageState
|
|
5763
|
+
payload: pageState,
|
|
5764
|
+
allComponentIds
|
|
5775
5765
|
});
|
|
5776
5766
|
let pathToRewriteTo = await (options.rewriteDestinationPath ? options.rewriteDestinationPath({ code, pageState, source: "playground" }) : void 0);
|
|
5777
5767
|
if (!pathToRewriteTo) {
|
|
@@ -5854,10 +5844,30 @@ var handleRouteRequest = async ({
|
|
|
5854
5844
|
isDraftModeEnabled: draftModeEnabled
|
|
5855
5845
|
});
|
|
5856
5846
|
const isPrefetch = isPrefetchRequest(request);
|
|
5857
|
-
const
|
|
5847
|
+
const { components, rules, allComponentIds } = await extractAndEvaluateRunnables({
|
|
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 = {
|
|
5858
5868
|
routePath,
|
|
5859
5869
|
compositionState: state,
|
|
5860
|
-
components
|
|
5870
|
+
components,
|
|
5861
5871
|
keys: requestPath.keys,
|
|
5862
5872
|
releaseId,
|
|
5863
5873
|
defaultConsent: determineDefaultConsent({
|
|
@@ -5865,32 +5875,10 @@ var handleRouteRequest = async ({
|
|
|
5865
5875
|
defaultConsent: options.defaultConsent
|
|
5866
5876
|
}),
|
|
5867
5877
|
previewMode,
|
|
5868
|
-
rules
|
|
5878
|
+
rules,
|
|
5869
5879
|
locale: options.locale,
|
|
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
|
|
5880
|
+
isPrefetch: isPrefetch || void 0
|
|
5876
5881
|
};
|
|
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
|
-
}
|
|
5894
5882
|
const code = (0, import_next_app_router_shared5.serializeEvaluationResult)({
|
|
5895
5883
|
payload: pageState,
|
|
5896
5884
|
allComponentIds
|
|
@@ -5913,6 +5901,49 @@ var handleRouteRequest = async ({
|
|
|
5913
5901
|
var isPrefetchRequest = (request) => {
|
|
5914
5902
|
return request.headers.has("next-url");
|
|
5915
5903
|
};
|
|
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
|
+
};
|
|
5916
5947
|
var handleRedirect = ({ request, route }) => {
|
|
5917
5948
|
const href = resolveRedirectHref({
|
|
5918
5949
|
resolveResult: route,
|
|
@@ -5935,7 +5966,7 @@ var buildRoutePath = ({
|
|
|
5935
5966
|
pathname,
|
|
5936
5967
|
route
|
|
5937
5968
|
}) => {
|
|
5938
|
-
var _a, _b, _c
|
|
5969
|
+
var _a, _b, _c;
|
|
5939
5970
|
const [routePath, search] = pathname.split("?");
|
|
5940
5971
|
const locale = (_a = route.dynamicInputs) == null ? void 0 : _a.locale;
|
|
5941
5972
|
const projectMapNode = (_b = route.compositionApiResponse.composition.projectMapNodes) == null ? void 0 : _b.find((node) => {
|
|
@@ -5950,12 +5981,22 @@ var buildRoutePath = ({
|
|
|
5950
5981
|
});
|
|
5951
5982
|
const searchParams = new URLSearchParams();
|
|
5952
5983
|
if ((_c = projectMapNode == null ? void 0 : projectMapNode.data) == null ? void 0 : _c.queryStrings) {
|
|
5953
|
-
|
|
5984
|
+
if (search) {
|
|
5985
|
+
const existingSearchParams = new URLSearchParams(search);
|
|
5986
|
+
for (const [key, value] of existingSearchParams.entries()) {
|
|
5987
|
+
searchParams.set(key, value);
|
|
5988
|
+
}
|
|
5989
|
+
}
|
|
5954
5990
|
for (const qs of projectMapNode.data.queryStrings) {
|
|
5955
|
-
|
|
5956
|
-
|
|
5991
|
+
if (!searchParams.has(qs.name)) {
|
|
5992
|
+
const qsValue = qs.value;
|
|
5993
|
+
searchParams.set(qs.name, qsValue != null ? qsValue : "");
|
|
5994
|
+
}
|
|
5957
5995
|
}
|
|
5958
5996
|
}
|
|
5997
|
+
if (process.env.NODE_ENV === "development") {
|
|
5998
|
+
searchParams.set("cache", (/* @__PURE__ */ new Date()).valueOf().toString());
|
|
5999
|
+
}
|
|
5959
6000
|
if (searchParams.size) {
|
|
5960
6001
|
return `${routePath}?${searchParams.toString()}`;
|
|
5961
6002
|
}
|