@uniformdev/canvas-next-rsc 19.147.1-alpha.1 → 19.147.1-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.
- package/dist/{UniformComposition-D4tBQ2U4.d.mts → UniformComposition-B-Z17dUt.d.mts} +3 -0
- package/dist/{UniformComposition-D4tBQ2U4.d.ts → UniformComposition-B-Z17dUt.d.ts} +3 -0
- package/dist/component.d.mts +11 -2
- package/dist/component.d.ts +11 -2
- package/dist/component.js +2 -0
- package/dist/component.mjs +1 -0
- package/dist/handler.js +62 -16
- package/dist/handler.mjs +63 -17
- package/dist/index.d.mts +20 -10
- package/dist/index.d.ts +20 -10
- package/dist/index.esm.js +124 -56
- package/dist/index.js +122 -53
- package/dist/index.mjs +124 -56
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ __export(src_exports, {
|
|
|
51
51
|
isIncontextEditingEnabled: () => isIncontextEditingEnabled,
|
|
52
52
|
isOnVercelPreviewEnvironment: () => isOnVercelPreviewEnvironment,
|
|
53
53
|
resolveComposition: () => resolveComposition,
|
|
54
|
+
retrieveCompositionBySlug: () => retrieveCompositionBySlug,
|
|
54
55
|
retrieveRoute: () => retrieveRoute
|
|
55
56
|
});
|
|
56
57
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -221,6 +222,7 @@ var getCanvasClient = (options) => {
|
|
|
221
222
|
apiHost: env.getApiHost(),
|
|
222
223
|
apiKey: env.getApiKey(),
|
|
223
224
|
edgeApiHost: env.getEdgeApiHost(),
|
|
225
|
+
disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
|
|
224
226
|
fetch: (req, init) => {
|
|
225
227
|
let requestedUrl;
|
|
226
228
|
if (typeof req === "string") {
|
|
@@ -252,7 +254,7 @@ var getCanvasClient = (options) => {
|
|
|
252
254
|
cache,
|
|
253
255
|
headers: {
|
|
254
256
|
...init == null ? void 0 : init.headers,
|
|
255
|
-
"x-bypass-cache": "
|
|
257
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
256
258
|
},
|
|
257
259
|
next: {
|
|
258
260
|
revalidate
|
|
@@ -284,7 +286,7 @@ var getManifestClient = (options) => {
|
|
|
284
286
|
...init,
|
|
285
287
|
headers: {
|
|
286
288
|
...init == null ? void 0 : init.headers,
|
|
287
|
-
"x-bypass-cache": "
|
|
289
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
288
290
|
},
|
|
289
291
|
cache,
|
|
290
292
|
next: {
|
|
@@ -325,7 +327,7 @@ var getProjectMapClient = (options) => {
|
|
|
325
327
|
...init,
|
|
326
328
|
headers: {
|
|
327
329
|
...init == null ? void 0 : init.headers,
|
|
328
|
-
"x-bypass-cache": "
|
|
330
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
329
331
|
},
|
|
330
332
|
cache,
|
|
331
333
|
next: {
|
|
@@ -353,6 +355,7 @@ var getRouteClient = (options) => {
|
|
|
353
355
|
projectId: env.getProjectId(),
|
|
354
356
|
apiKey: env.getApiKey(),
|
|
355
357
|
edgeApiHost: env.getEdgeApiHost(),
|
|
358
|
+
disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
|
|
356
359
|
fetch: (req, init) => {
|
|
357
360
|
let requestedUrl;
|
|
358
361
|
if (typeof req === "string") {
|
|
@@ -380,7 +383,7 @@ var getRouteClient = (options) => {
|
|
|
380
383
|
...init,
|
|
381
384
|
headers: {
|
|
382
385
|
...init == null ? void 0 : init.headers,
|
|
383
|
-
"x-bypass-cache": "
|
|
386
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
384
387
|
},
|
|
385
388
|
cache,
|
|
386
389
|
next: {
|
|
@@ -489,13 +492,62 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
489
492
|
var import_canvas4 = require("@uniformdev/canvas");
|
|
490
493
|
var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
|
|
491
494
|
var import_redirect = require("@uniformdev/redirect");
|
|
495
|
+
var retrieveCompositionBySlug = async ({
|
|
496
|
+
slug,
|
|
497
|
+
searchParams,
|
|
498
|
+
skipPrefetch,
|
|
499
|
+
locale,
|
|
500
|
+
releaseId,
|
|
501
|
+
versionId
|
|
502
|
+
}) => {
|
|
503
|
+
var _a;
|
|
504
|
+
if (!skipPrefetch) {
|
|
505
|
+
void getManifest({
|
|
506
|
+
searchParams
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
let result;
|
|
510
|
+
const states = determineState({
|
|
511
|
+
searchParams
|
|
512
|
+
});
|
|
513
|
+
for (let i = 0; i < states.length; i++) {
|
|
514
|
+
const state = states[i];
|
|
515
|
+
const canvasClient = getDefaultCanvasClient({
|
|
516
|
+
searchParams
|
|
517
|
+
});
|
|
518
|
+
try {
|
|
519
|
+
const composition = await canvasClient.getCompositionBySlug({
|
|
520
|
+
slug,
|
|
521
|
+
state,
|
|
522
|
+
withComponentIDs: true,
|
|
523
|
+
withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
|
|
524
|
+
locale,
|
|
525
|
+
releaseId,
|
|
526
|
+
versionId
|
|
527
|
+
});
|
|
528
|
+
result = {
|
|
529
|
+
type: "composition",
|
|
530
|
+
compositionApiResponse: composition,
|
|
531
|
+
matchedRoute: "slug"
|
|
532
|
+
};
|
|
533
|
+
} catch (e) {
|
|
534
|
+
console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
|
|
535
|
+
}
|
|
536
|
+
if ((result == null ? void 0 : result.type) !== "notFound") {
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return result || {
|
|
541
|
+
type: "notFound"
|
|
542
|
+
};
|
|
543
|
+
};
|
|
492
544
|
var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
|
|
493
545
|
if (!skipPrefetch) {
|
|
494
546
|
void getManifest({
|
|
495
547
|
searchParams
|
|
496
548
|
});
|
|
497
549
|
}
|
|
498
|
-
const {
|
|
550
|
+
const { value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
|
|
499
551
|
params
|
|
500
552
|
});
|
|
501
553
|
const states = determineState({
|
|
@@ -504,34 +556,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
504
556
|
let result;
|
|
505
557
|
for (let i = 0; i < states.length; i++) {
|
|
506
558
|
const state = states[i];
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
fetchOptions
|
|
514
|
-
});
|
|
515
|
-
} catch (e) {
|
|
516
|
-
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
517
|
-
}
|
|
518
|
-
} else if (type === "slug") {
|
|
519
|
-
const canvasClient = getDefaultCanvasClient({
|
|
520
|
-
searchParams
|
|
559
|
+
try {
|
|
560
|
+
result = await retrieveRouteByPath({
|
|
561
|
+
path: value,
|
|
562
|
+
state,
|
|
563
|
+
searchParams,
|
|
564
|
+
fetchOptions
|
|
521
565
|
});
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
slug: value,
|
|
525
|
-
state
|
|
526
|
-
});
|
|
527
|
-
result = {
|
|
528
|
-
type: "composition",
|
|
529
|
-
compositionApiResponse: composition,
|
|
530
|
-
matchedRoute: "slug"
|
|
531
|
-
};
|
|
532
|
-
} catch (e) {
|
|
533
|
-
console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
|
|
534
|
-
}
|
|
566
|
+
} catch (e) {
|
|
567
|
+
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
535
568
|
}
|
|
536
569
|
if ((result == null ? void 0 : result.type) !== "notFound") {
|
|
537
570
|
break;
|
|
@@ -616,6 +649,7 @@ var PersonalizeClientWrapper = (props) => {
|
|
|
616
649
|
// src/components/PersonalizeServer.ts
|
|
617
650
|
var import_canvas5 = require("@uniformdev/canvas");
|
|
618
651
|
var import_canvas_next_rsc_shared4 = require("@uniformdev/canvas-next-rsc-shared");
|
|
652
|
+
var import_cache = require("next/cache");
|
|
619
653
|
var import_react5 = require("react");
|
|
620
654
|
|
|
621
655
|
// src/components/ContextPersonalizationTransfer.tsx
|
|
@@ -627,15 +661,19 @@ var ContextPersonalizationTransfer = ({ event }) => {
|
|
|
627
661
|
|
|
628
662
|
// src/components/PersonalizeServer.ts
|
|
629
663
|
var PersonalizeServer = (props) => {
|
|
630
|
-
var _a;
|
|
664
|
+
var _a, _b;
|
|
665
|
+
if ((_a = getServerConfig().ppr) == null ? void 0 : _a.personalizationSuspense) {
|
|
666
|
+
(0, import_cache.unstable_noStore)();
|
|
667
|
+
}
|
|
631
668
|
const { indexes, event } = (0, import_canvas_next_rsc_shared4.runPersonalization)(props);
|
|
632
|
-
const slot = (
|
|
669
|
+
const slot = (_b = props.slots) == null ? void 0 : _b[import_canvas5.CANVAS_PERSONALIZE_SLOT];
|
|
633
670
|
const components = indexes.map((index) => {
|
|
634
671
|
const component = slot.items[index];
|
|
635
672
|
return component;
|
|
636
673
|
});
|
|
637
674
|
const eventElement = (0, import_react5.createElement)(ContextPersonalizationTransfer, {
|
|
638
|
-
event
|
|
675
|
+
event,
|
|
676
|
+
key: `${props.slotName}-${props.slotIndex}-personalization-transfer`
|
|
639
677
|
});
|
|
640
678
|
return (0, import_react5.createElement)(import_react5.Fragment, void 0, [...components, eventElement]);
|
|
641
679
|
};
|
|
@@ -643,6 +681,7 @@ var PersonalizeServer = (props) => {
|
|
|
643
681
|
// src/components/TestServer.ts
|
|
644
682
|
var import_canvas6 = require("@uniformdev/canvas");
|
|
645
683
|
var import_canvas_next_rsc_shared5 = require("@uniformdev/canvas-next-rsc-shared");
|
|
684
|
+
var import_cache2 = require("next/cache");
|
|
646
685
|
var import_react7 = require("react");
|
|
647
686
|
|
|
648
687
|
// src/components/ContextTestTransfer.tsx
|
|
@@ -653,17 +692,24 @@ var ContextTestTransfer = ({ event }) => {
|
|
|
653
692
|
};
|
|
654
693
|
|
|
655
694
|
// src/components/TestServer.ts
|
|
656
|
-
var TestServer = (props) => {
|
|
657
|
-
var _a, _b, _c, _d;
|
|
695
|
+
var TestServer = async (props) => {
|
|
696
|
+
var _a, _b, _c, _d, _e;
|
|
697
|
+
if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
|
|
698
|
+
(0, import_cache2.unstable_noStore)();
|
|
699
|
+
}
|
|
658
700
|
const { contextInstance, test } = props;
|
|
659
|
-
const isTestDefined = Boolean((
|
|
701
|
+
const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
|
|
660
702
|
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
661
703
|
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
662
704
|
}
|
|
663
705
|
const { index, event } = (0, import_canvas_next_rsc_shared5.runTest)(props);
|
|
664
|
-
|
|
706
|
+
if (index === null || event === null) {
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
const component = typeof index === "number" ? (_e = (_d = (_c = props.slots) == null ? void 0 : _c[import_canvas6.CANVAS_TEST_SLOT]) == null ? void 0 : _d.items[index]) != null ? _e : null : null;
|
|
665
710
|
const eventElement = (0, import_react7.createElement)(ContextTestTransfer, {
|
|
666
|
-
event
|
|
711
|
+
event,
|
|
712
|
+
key: `${props.slotName}-${props.slotIndex}-server-transfer`
|
|
667
713
|
});
|
|
668
714
|
return (0, import_react7.createElement)(import_react7.Fragment, void 0, [component, eventElement]);
|
|
669
715
|
};
|
|
@@ -767,19 +813,24 @@ var isServerComponent = ({
|
|
|
767
813
|
};
|
|
768
814
|
var resolveSystemComponent = ({
|
|
769
815
|
component,
|
|
770
|
-
|
|
816
|
+
server
|
|
771
817
|
}) => {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
818
|
+
var _a, _b;
|
|
819
|
+
const config = getServerConfig();
|
|
820
|
+
let resolved = null;
|
|
821
|
+
let suspense = void 0;
|
|
776
822
|
if (component.type === import_canvas7.CANVAS_PERSONALIZE_TYPE) {
|
|
777
|
-
|
|
823
|
+
resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
824
|
+
suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
|
|
778
825
|
}
|
|
779
826
|
if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
|
|
780
|
-
|
|
827
|
+
resolved = server ? TestServer : import_canvas_next_rsc_client6.TestClient;
|
|
828
|
+
suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
|
|
781
829
|
}
|
|
782
|
-
return
|
|
830
|
+
return {
|
|
831
|
+
component: resolved,
|
|
832
|
+
suspense
|
|
833
|
+
};
|
|
783
834
|
};
|
|
784
835
|
var resolveSlots = ({
|
|
785
836
|
component,
|
|
@@ -856,11 +907,15 @@ var resolveComponents = ({
|
|
|
856
907
|
component,
|
|
857
908
|
serverContext
|
|
858
909
|
});
|
|
859
|
-
const systemComponent = resolveSystemComponent({
|
|
910
|
+
const { component: systemComponent, suspense: systemSuspense } = resolveSystemComponent({
|
|
860
911
|
component,
|
|
861
|
-
|
|
912
|
+
server: isServer
|
|
862
913
|
});
|
|
863
|
-
const {
|
|
914
|
+
const {
|
|
915
|
+
component: regularComponent,
|
|
916
|
+
includeContext,
|
|
917
|
+
suspense: componentSuspense
|
|
918
|
+
} = resolveComponent({ component }) || {
|
|
864
919
|
component: null
|
|
865
920
|
};
|
|
866
921
|
if (!systemComponent && !regularComponent) {
|
|
@@ -875,10 +930,11 @@ var resolveComponents = ({
|
|
|
875
930
|
mode
|
|
876
931
|
});
|
|
877
932
|
const resolvedComponent = systemComponent || regularComponent;
|
|
933
|
+
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
878
934
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
879
935
|
const enrichmentTags = (_b = parameters[import_canvas7.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
936
|
+
const key = `${slotName}-${componentIndex}-component`;
|
|
880
937
|
const componentProps = {
|
|
881
|
-
key: `${slotName}-${componentIndex}-component`,
|
|
882
938
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
883
939
|
acc[cur] = parameters[cur].value;
|
|
884
940
|
return acc;
|
|
@@ -890,7 +946,19 @@ var resolveComponents = ({
|
|
|
890
946
|
slotName,
|
|
891
947
|
slotIndex: isRoot ? void 0 : componentIndex
|
|
892
948
|
};
|
|
893
|
-
|
|
949
|
+
let element = null;
|
|
950
|
+
if (wrapInSuspense) {
|
|
951
|
+
element = (0, import_react8.createElement)(
|
|
952
|
+
import_react8.Suspense,
|
|
953
|
+
{
|
|
954
|
+
key,
|
|
955
|
+
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0, import_react8.createElement)(wrapInSuspense.fallback)
|
|
956
|
+
},
|
|
957
|
+
(0, import_react8.createElement)(resolvedComponent, componentProps)
|
|
958
|
+
);
|
|
959
|
+
} else {
|
|
960
|
+
element = (0, import_react8.createElement)(resolvedComponent, { ...componentProps, key });
|
|
961
|
+
}
|
|
894
962
|
let tagElement = null;
|
|
895
963
|
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
896
964
|
tagElement = (0, import_react8.createElement)(ContextUpdateTransfer, {
|
|
@@ -1060,5 +1128,6 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1060
1128
|
isIncontextEditingEnabled,
|
|
1061
1129
|
isOnVercelPreviewEnvironment,
|
|
1062
1130
|
resolveComposition,
|
|
1131
|
+
retrieveCompositionBySlug,
|
|
1063
1132
|
retrieveRoute
|
|
1064
1133
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -174,6 +174,7 @@ var getCanvasClient = (options) => {
|
|
|
174
174
|
apiHost: env.getApiHost(),
|
|
175
175
|
apiKey: env.getApiKey(),
|
|
176
176
|
edgeApiHost: env.getEdgeApiHost(),
|
|
177
|
+
disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
|
|
177
178
|
fetch: (req, init) => {
|
|
178
179
|
let requestedUrl;
|
|
179
180
|
if (typeof req === "string") {
|
|
@@ -205,7 +206,7 @@ var getCanvasClient = (options) => {
|
|
|
205
206
|
cache,
|
|
206
207
|
headers: {
|
|
207
208
|
...init == null ? void 0 : init.headers,
|
|
208
|
-
"x-bypass-cache": "
|
|
209
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
209
210
|
},
|
|
210
211
|
next: {
|
|
211
212
|
revalidate
|
|
@@ -237,7 +238,7 @@ var getManifestClient = (options) => {
|
|
|
237
238
|
...init,
|
|
238
239
|
headers: {
|
|
239
240
|
...init == null ? void 0 : init.headers,
|
|
240
|
-
"x-bypass-cache": "
|
|
241
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
241
242
|
},
|
|
242
243
|
cache,
|
|
243
244
|
next: {
|
|
@@ -278,7 +279,7 @@ var getProjectMapClient = (options) => {
|
|
|
278
279
|
...init,
|
|
279
280
|
headers: {
|
|
280
281
|
...init == null ? void 0 : init.headers,
|
|
281
|
-
"x-bypass-cache": "
|
|
282
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
282
283
|
},
|
|
283
284
|
cache,
|
|
284
285
|
next: {
|
|
@@ -306,6 +307,7 @@ var getRouteClient = (options) => {
|
|
|
306
307
|
projectId: env.getProjectId(),
|
|
307
308
|
apiKey: env.getApiKey(),
|
|
308
309
|
edgeApiHost: env.getEdgeApiHost(),
|
|
310
|
+
disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
|
|
309
311
|
fetch: (req, init) => {
|
|
310
312
|
let requestedUrl;
|
|
311
313
|
if (typeof req === "string") {
|
|
@@ -333,7 +335,7 @@ var getRouteClient = (options) => {
|
|
|
333
335
|
...init,
|
|
334
336
|
headers: {
|
|
335
337
|
...init == null ? void 0 : init.headers,
|
|
336
|
-
"x-bypass-cache": "
|
|
338
|
+
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
337
339
|
},
|
|
338
340
|
cache,
|
|
339
341
|
next: {
|
|
@@ -420,7 +422,7 @@ import {
|
|
|
420
422
|
import { PureContextualEditingComponentWrapper } from "@uniformdev/canvas-react/core";
|
|
421
423
|
import { cookies as cookies2, headers } from "next/headers";
|
|
422
424
|
import { notFound, redirect } from "next/navigation";
|
|
423
|
-
import { createElement as createElement3, Fragment as Fragment3 } from "react";
|
|
425
|
+
import { createElement as createElement3, Fragment as Fragment3, Suspense } from "react";
|
|
424
426
|
|
|
425
427
|
// src/context/createServerUniformContext.ts
|
|
426
428
|
import {
|
|
@@ -458,13 +460,62 @@ import {
|
|
|
458
460
|
} from "@uniformdev/canvas";
|
|
459
461
|
import { getBaseUrl, resolvePath } from "@uniformdev/canvas-next-rsc-shared";
|
|
460
462
|
import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
|
|
463
|
+
var retrieveCompositionBySlug = async ({
|
|
464
|
+
slug,
|
|
465
|
+
searchParams,
|
|
466
|
+
skipPrefetch,
|
|
467
|
+
locale,
|
|
468
|
+
releaseId,
|
|
469
|
+
versionId
|
|
470
|
+
}) => {
|
|
471
|
+
var _a;
|
|
472
|
+
if (!skipPrefetch) {
|
|
473
|
+
void getManifest({
|
|
474
|
+
searchParams
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
let result;
|
|
478
|
+
const states = determineState({
|
|
479
|
+
searchParams
|
|
480
|
+
});
|
|
481
|
+
for (let i = 0; i < states.length; i++) {
|
|
482
|
+
const state = states[i];
|
|
483
|
+
const canvasClient = getDefaultCanvasClient({
|
|
484
|
+
searchParams
|
|
485
|
+
});
|
|
486
|
+
try {
|
|
487
|
+
const composition = await canvasClient.getCompositionBySlug({
|
|
488
|
+
slug,
|
|
489
|
+
state,
|
|
490
|
+
withComponentIDs: true,
|
|
491
|
+
withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
|
|
492
|
+
locale,
|
|
493
|
+
releaseId,
|
|
494
|
+
versionId
|
|
495
|
+
});
|
|
496
|
+
result = {
|
|
497
|
+
type: "composition",
|
|
498
|
+
compositionApiResponse: composition,
|
|
499
|
+
matchedRoute: "slug"
|
|
500
|
+
};
|
|
501
|
+
} catch (e) {
|
|
502
|
+
console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
|
|
503
|
+
}
|
|
504
|
+
if ((result == null ? void 0 : result.type) !== "notFound") {
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return result || {
|
|
509
|
+
type: "notFound"
|
|
510
|
+
};
|
|
511
|
+
};
|
|
461
512
|
var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
|
|
462
513
|
if (!skipPrefetch) {
|
|
463
514
|
void getManifest({
|
|
464
515
|
searchParams
|
|
465
516
|
});
|
|
466
517
|
}
|
|
467
|
-
const {
|
|
518
|
+
const { value } = resolvePath({
|
|
468
519
|
params
|
|
469
520
|
});
|
|
470
521
|
const states = determineState({
|
|
@@ -473,34 +524,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
473
524
|
let result;
|
|
474
525
|
for (let i = 0; i < states.length; i++) {
|
|
475
526
|
const state = states[i];
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
fetchOptions
|
|
483
|
-
});
|
|
484
|
-
} catch (e) {
|
|
485
|
-
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
486
|
-
}
|
|
487
|
-
} else if (type === "slug") {
|
|
488
|
-
const canvasClient = getDefaultCanvasClient({
|
|
489
|
-
searchParams
|
|
527
|
+
try {
|
|
528
|
+
result = await retrieveRouteByPath({
|
|
529
|
+
path: value,
|
|
530
|
+
state,
|
|
531
|
+
searchParams,
|
|
532
|
+
fetchOptions
|
|
490
533
|
});
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
slug: value,
|
|
494
|
-
state
|
|
495
|
-
});
|
|
496
|
-
result = {
|
|
497
|
-
type: "composition",
|
|
498
|
-
compositionApiResponse: composition,
|
|
499
|
-
matchedRoute: "slug"
|
|
500
|
-
};
|
|
501
|
-
} catch (e) {
|
|
502
|
-
console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
|
|
503
|
-
}
|
|
534
|
+
} catch (e) {
|
|
535
|
+
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
504
536
|
}
|
|
505
537
|
if ((result == null ? void 0 : result.type) !== "notFound") {
|
|
506
538
|
break;
|
|
@@ -585,6 +617,7 @@ var PersonalizeClientWrapper = (props) => {
|
|
|
585
617
|
// src/components/PersonalizeServer.ts
|
|
586
618
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
587
619
|
import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
|
|
620
|
+
import { unstable_noStore as noStore } from "next/cache";
|
|
588
621
|
import { createElement, Fragment } from "react";
|
|
589
622
|
|
|
590
623
|
// src/components/ContextPersonalizationTransfer.tsx
|
|
@@ -596,15 +629,19 @@ var ContextPersonalizationTransfer = ({ event }) => {
|
|
|
596
629
|
|
|
597
630
|
// src/components/PersonalizeServer.ts
|
|
598
631
|
var PersonalizeServer = (props) => {
|
|
599
|
-
var _a;
|
|
632
|
+
var _a, _b;
|
|
633
|
+
if ((_a = getServerConfig().ppr) == null ? void 0 : _a.personalizationSuspense) {
|
|
634
|
+
noStore();
|
|
635
|
+
}
|
|
600
636
|
const { indexes, event } = runPersonalization2(props);
|
|
601
|
-
const slot = (
|
|
637
|
+
const slot = (_b = props.slots) == null ? void 0 : _b[CANVAS_PERSONALIZE_SLOT];
|
|
602
638
|
const components = indexes.map((index) => {
|
|
603
639
|
const component = slot.items[index];
|
|
604
640
|
return component;
|
|
605
641
|
});
|
|
606
642
|
const eventElement = createElement(ContextPersonalizationTransfer, {
|
|
607
|
-
event
|
|
643
|
+
event,
|
|
644
|
+
key: `${props.slotName}-${props.slotIndex}-personalization-transfer`
|
|
608
645
|
});
|
|
609
646
|
return createElement(Fragment, void 0, [...components, eventElement]);
|
|
610
647
|
};
|
|
@@ -614,6 +651,7 @@ import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
|
614
651
|
import {
|
|
615
652
|
runTest
|
|
616
653
|
} from "@uniformdev/canvas-next-rsc-shared";
|
|
654
|
+
import { unstable_noStore as noStore2 } from "next/cache";
|
|
617
655
|
import { createElement as createElement2, Fragment as Fragment2 } from "react";
|
|
618
656
|
|
|
619
657
|
// src/components/ContextTestTransfer.tsx
|
|
@@ -624,17 +662,24 @@ var ContextTestTransfer = ({ event }) => {
|
|
|
624
662
|
};
|
|
625
663
|
|
|
626
664
|
// src/components/TestServer.ts
|
|
627
|
-
var TestServer = (props) => {
|
|
628
|
-
var _a, _b, _c, _d;
|
|
665
|
+
var TestServer = async (props) => {
|
|
666
|
+
var _a, _b, _c, _d, _e;
|
|
667
|
+
if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
|
|
668
|
+
noStore2();
|
|
669
|
+
}
|
|
629
670
|
const { contextInstance, test } = props;
|
|
630
|
-
const isTestDefined = Boolean((
|
|
671
|
+
const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
|
|
631
672
|
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
632
673
|
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
633
674
|
}
|
|
634
675
|
const { index, event } = runTest(props);
|
|
635
|
-
|
|
676
|
+
if (index === null || event === null) {
|
|
677
|
+
return null;
|
|
678
|
+
}
|
|
679
|
+
const component = typeof index === "number" ? (_e = (_d = (_c = props.slots) == null ? void 0 : _c[CANVAS_TEST_SLOT]) == null ? void 0 : _d.items[index]) != null ? _e : null : null;
|
|
636
680
|
const eventElement = createElement2(ContextTestTransfer, {
|
|
637
|
-
event
|
|
681
|
+
event,
|
|
682
|
+
key: `${props.slotName}-${props.slotIndex}-server-transfer`
|
|
638
683
|
});
|
|
639
684
|
return createElement2(Fragment2, void 0, [component, eventElement]);
|
|
640
685
|
};
|
|
@@ -738,19 +783,24 @@ var isServerComponent = ({
|
|
|
738
783
|
};
|
|
739
784
|
var resolveSystemComponent = ({
|
|
740
785
|
component,
|
|
741
|
-
|
|
786
|
+
server
|
|
742
787
|
}) => {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
788
|
+
var _a, _b;
|
|
789
|
+
const config = getServerConfig();
|
|
790
|
+
let resolved = null;
|
|
791
|
+
let suspense = void 0;
|
|
747
792
|
if (component.type === CANVAS_PERSONALIZE_TYPE) {
|
|
748
|
-
|
|
793
|
+
resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
794
|
+
suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
|
|
749
795
|
}
|
|
750
796
|
if (component.type === CANVAS_TEST_TYPE) {
|
|
751
|
-
|
|
797
|
+
resolved = server ? TestServer : TestClient;
|
|
798
|
+
suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
|
|
752
799
|
}
|
|
753
|
-
return
|
|
800
|
+
return {
|
|
801
|
+
component: resolved,
|
|
802
|
+
suspense
|
|
803
|
+
};
|
|
754
804
|
};
|
|
755
805
|
var resolveSlots = ({
|
|
756
806
|
component,
|
|
@@ -827,11 +877,15 @@ var resolveComponents = ({
|
|
|
827
877
|
component,
|
|
828
878
|
serverContext
|
|
829
879
|
});
|
|
830
|
-
const systemComponent = resolveSystemComponent({
|
|
880
|
+
const { component: systemComponent, suspense: systemSuspense } = resolveSystemComponent({
|
|
831
881
|
component,
|
|
832
|
-
|
|
882
|
+
server: isServer
|
|
833
883
|
});
|
|
834
|
-
const {
|
|
884
|
+
const {
|
|
885
|
+
component: regularComponent,
|
|
886
|
+
includeContext,
|
|
887
|
+
suspense: componentSuspense
|
|
888
|
+
} = resolveComponent({ component }) || {
|
|
835
889
|
component: null
|
|
836
890
|
};
|
|
837
891
|
if (!systemComponent && !regularComponent) {
|
|
@@ -846,10 +900,11 @@ var resolveComponents = ({
|
|
|
846
900
|
mode
|
|
847
901
|
});
|
|
848
902
|
const resolvedComponent = systemComponent || regularComponent;
|
|
903
|
+
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
849
904
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
850
905
|
const enrichmentTags = (_b = parameters[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
906
|
+
const key = `${slotName}-${componentIndex}-component`;
|
|
851
907
|
const componentProps = {
|
|
852
|
-
key: `${slotName}-${componentIndex}-component`,
|
|
853
908
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
854
909
|
acc[cur] = parameters[cur].value;
|
|
855
910
|
return acc;
|
|
@@ -861,7 +916,19 @@ var resolveComponents = ({
|
|
|
861
916
|
slotName,
|
|
862
917
|
slotIndex: isRoot ? void 0 : componentIndex
|
|
863
918
|
};
|
|
864
|
-
|
|
919
|
+
let element = null;
|
|
920
|
+
if (wrapInSuspense) {
|
|
921
|
+
element = createElement3(
|
|
922
|
+
Suspense,
|
|
923
|
+
{
|
|
924
|
+
key,
|
|
925
|
+
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : createElement3(wrapInSuspense.fallback)
|
|
926
|
+
},
|
|
927
|
+
createElement3(resolvedComponent, componentProps)
|
|
928
|
+
);
|
|
929
|
+
} else {
|
|
930
|
+
element = createElement3(resolvedComponent, { ...componentProps, key });
|
|
931
|
+
}
|
|
865
932
|
let tagElement = null;
|
|
866
933
|
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
867
934
|
tagElement = createElement3(ContextUpdateTransfer, {
|
|
@@ -935,7 +1002,7 @@ import {
|
|
|
935
1002
|
DefaultUniformClientContext,
|
|
936
1003
|
UniformScript
|
|
937
1004
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
938
|
-
import { Suspense } from "react";
|
|
1005
|
+
import { Suspense as Suspense2 } from "react";
|
|
939
1006
|
import React6 from "react";
|
|
940
1007
|
var UniformContext = async ({
|
|
941
1008
|
clientContextComponent,
|
|
@@ -956,7 +1023,7 @@ var UniformContext = async ({
|
|
|
956
1023
|
disableDevTools,
|
|
957
1024
|
defaultConsent
|
|
958
1025
|
}
|
|
959
|
-
), /* @__PURE__ */ React6.createElement(
|
|
1026
|
+
), /* @__PURE__ */ React6.createElement(Suspense2, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
|
|
960
1027
|
};
|
|
961
1028
|
|
|
962
1029
|
// src/components/UniformPlayground.tsx
|
|
@@ -1033,5 +1100,6 @@ export {
|
|
|
1033
1100
|
isIncontextEditingEnabled,
|
|
1034
1101
|
isOnVercelPreviewEnvironment,
|
|
1035
1102
|
resolveComposition,
|
|
1103
|
+
retrieveCompositionBySlug,
|
|
1036
1104
|
retrieveRoute
|
|
1037
1105
|
};
|