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