@uniformdev/canvas-next-rsc 19.199.0 → 19.199.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-Dw55RFP6.d.mts → UniformComposition-IWWzoI_H.d.mts} +16 -1
- package/dist/{UniformComposition-Dw55RFP6.d.ts → UniformComposition-IWWzoI_H.d.ts} +16 -1
- package/dist/component.d.mts +3 -3
- package/dist/component.d.ts +3 -3
- package/dist/component.js +80 -4
- package/dist/component.mjs +80 -4
- package/dist/handler.js +7 -3
- package/dist/handler.mjs +7 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +103 -33
- package/dist/index.js +128 -62
- package/dist/index.mjs +103 -33
- package/package.json +19 -19
package/dist/index.esm.js
CHANGED
|
@@ -419,6 +419,7 @@ async function generateStaticParams() {
|
|
|
419
419
|
|
|
420
420
|
// src/components/UniformComposition.ts
|
|
421
421
|
import {
|
|
422
|
+
CANVAS_CONTEXTUAL_EDITING_PARAM,
|
|
422
423
|
CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE2,
|
|
423
424
|
CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE2,
|
|
424
425
|
CANVAS_ENRICHMENT_TAG_PARAM,
|
|
@@ -441,7 +442,10 @@ import { createElement as createElement3, Fragment as Fragment3, Suspense } from
|
|
|
441
442
|
import {
|
|
442
443
|
createUniformContext
|
|
443
444
|
} from "@uniformdev/canvas-next-rsc-shared";
|
|
444
|
-
import {
|
|
445
|
+
import {
|
|
446
|
+
UNIFORM_DEFAULT_COOKIE_NAME,
|
|
447
|
+
UNIFORM_DEFAULT_QUIRK_COOKIE_NAME
|
|
448
|
+
} from "@uniformdev/context";
|
|
445
449
|
import { cookies } from "next/headers";
|
|
446
450
|
var createServerUniformContext = async (options) => {
|
|
447
451
|
const manifest = await getManifest(options);
|
|
@@ -452,10 +456,13 @@ var createServerUniformContext = async (options) => {
|
|
|
452
456
|
return context;
|
|
453
457
|
};
|
|
454
458
|
var createServerUniformContextFromManifest = async (options) => {
|
|
455
|
-
var _a;
|
|
459
|
+
var _a, _b, _c;
|
|
460
|
+
const quirksEnabled = (_a = getServerConfig().experimental) == null ? void 0 : _a.quirkSerialization;
|
|
456
461
|
const context = createUniformContext({
|
|
457
462
|
...options || {},
|
|
458
|
-
serverCookieValue: (
|
|
463
|
+
serverCookieValue: (_b = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _b.value,
|
|
464
|
+
experimental_quirksEnabled: quirksEnabled,
|
|
465
|
+
quirkCookieValue: quirksEnabled ? (_c = cookies().get(UNIFORM_DEFAULT_QUIRK_COOKIE_NAME)) == null ? void 0 : _c.value : void 0
|
|
459
466
|
});
|
|
460
467
|
return context;
|
|
461
468
|
};
|
|
@@ -533,12 +540,17 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
|
|
|
533
540
|
let result;
|
|
534
541
|
for (let i = 0; i < states.length; i++) {
|
|
535
542
|
const state = states[i];
|
|
543
|
+
const releaseId = determineReleaseId({
|
|
544
|
+
searchParams,
|
|
545
|
+
state
|
|
546
|
+
});
|
|
536
547
|
try {
|
|
537
548
|
result = await retrieveRouteByPath({
|
|
538
549
|
path: value,
|
|
539
550
|
state,
|
|
540
551
|
searchParams,
|
|
541
|
-
fetchOptions
|
|
552
|
+
fetchOptions,
|
|
553
|
+
releaseId
|
|
542
554
|
});
|
|
543
555
|
} catch (e) {
|
|
544
556
|
console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
|
|
@@ -555,7 +567,8 @@ var retrieveRouteByPath = async ({
|
|
|
555
567
|
path,
|
|
556
568
|
state,
|
|
557
569
|
searchParams,
|
|
558
|
-
fetchOptions
|
|
570
|
+
fetchOptions,
|
|
571
|
+
releaseId
|
|
559
572
|
}) => {
|
|
560
573
|
var _a;
|
|
561
574
|
const client = getDefaultRouteClient({
|
|
@@ -580,7 +593,8 @@ var retrieveRouteByPath = async ({
|
|
|
580
593
|
state,
|
|
581
594
|
dataSourceVariant: getDataSourceVariantFromRouteGetParams(fetchOptions != null ? fetchOptions : {}, state),
|
|
582
595
|
withComponentIDs: true,
|
|
583
|
-
withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing)
|
|
596
|
+
withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
|
|
597
|
+
releaseId
|
|
584
598
|
});
|
|
585
599
|
};
|
|
586
600
|
var resolveRedirectHref = (resolveResult, path) => {
|
|
@@ -604,6 +618,16 @@ var determineState = ({ searchParams }) => {
|
|
|
604
618
|
}
|
|
605
619
|
return states;
|
|
606
620
|
};
|
|
621
|
+
var determineReleaseId = ({
|
|
622
|
+
searchParams,
|
|
623
|
+
state
|
|
624
|
+
}) => {
|
|
625
|
+
const draftMode2 = isDraftModeEnabled({ searchParams });
|
|
626
|
+
if (!draftMode2 || state === CANVAS_PUBLISHED_STATE) {
|
|
627
|
+
return void 0;
|
|
628
|
+
}
|
|
629
|
+
return searchParams == null ? void 0 : searchParams.releaseId;
|
|
630
|
+
};
|
|
607
631
|
|
|
608
632
|
// src/components/ContextUpdateTrigger.tsx
|
|
609
633
|
import { ClientContextUpdate } from "@uniformdev/canvas-next-rsc-client";
|
|
@@ -656,6 +680,24 @@ var PersonalizeServer = (props) => {
|
|
|
656
680
|
return createElement(Fragment, void 0, [...components, eventElement]);
|
|
657
681
|
};
|
|
658
682
|
|
|
683
|
+
// src/components/PersonalizeServerHybrid.tsx
|
|
684
|
+
import { PersonalizeClient as PersonalizeClient2 } from "@uniformdev/canvas-next-rsc-client";
|
|
685
|
+
import { runPersonalization as runPersonalization3 } from "@uniformdev/canvas-next-rsc-shared";
|
|
686
|
+
import React5 from "react";
|
|
687
|
+
var PersonalizeServerHybrid = (props) => {
|
|
688
|
+
const { indexes } = runPersonalization3(props);
|
|
689
|
+
return /* @__PURE__ */ React5.createElement(
|
|
690
|
+
PersonalizeClient2,
|
|
691
|
+
{
|
|
692
|
+
component: props.component,
|
|
693
|
+
count: props.count,
|
|
694
|
+
slots: props.slots,
|
|
695
|
+
trackingEventName: props.trackingEventName,
|
|
696
|
+
indexes
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
};
|
|
700
|
+
|
|
659
701
|
// src/components/TestServer.ts
|
|
660
702
|
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
661
703
|
import {
|
|
@@ -666,27 +708,22 @@ import { createElement as createElement2, Fragment as Fragment2 } from "react";
|
|
|
666
708
|
|
|
667
709
|
// src/components/ContextTestTransfer.tsx
|
|
668
710
|
import { ClientContextTestTransfer } from "@uniformdev/canvas-next-rsc-client";
|
|
669
|
-
import
|
|
711
|
+
import React6 from "react";
|
|
670
712
|
var ContextTestTransfer = ({ event }) => {
|
|
671
|
-
return /* @__PURE__ */
|
|
713
|
+
return /* @__PURE__ */ React6.createElement(ClientContextTestTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
672
714
|
};
|
|
673
715
|
|
|
674
716
|
// src/components/TestServer.ts
|
|
675
717
|
var TestServer = async (props) => {
|
|
676
|
-
var _a, _b, _c, _d
|
|
718
|
+
var _a, _b, _c, _d;
|
|
677
719
|
if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
|
|
678
720
|
noStore2();
|
|
679
721
|
}
|
|
680
|
-
const { contextInstance, test } = props;
|
|
681
|
-
const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
|
|
682
|
-
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
683
|
-
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
684
|
-
}
|
|
685
722
|
const { index, event } = runTest(props);
|
|
686
723
|
if (index === null || event === null) {
|
|
687
724
|
return null;
|
|
688
725
|
}
|
|
689
|
-
const component = typeof index === "number" ? (
|
|
726
|
+
const component = typeof index === "number" ? (_d = (_c = (_b = props.slots) == null ? void 0 : _b[CANVAS_TEST_SLOT]) == null ? void 0 : _c.items[index]) != null ? _d : null : null;
|
|
690
727
|
const eventElement = createElement2(ContextTestTransfer, {
|
|
691
728
|
event,
|
|
692
729
|
key: `${props.slotName}-${props.slotIndex}-server-transfer`
|
|
@@ -700,7 +737,7 @@ import {
|
|
|
700
737
|
evaluateNodeVisibilityParameter
|
|
701
738
|
} from "@uniformdev/canvas";
|
|
702
739
|
import { VisibilityRulesWrapperClient } from "@uniformdev/canvas-next-rsc-client";
|
|
703
|
-
import
|
|
740
|
+
import React7 from "react";
|
|
704
741
|
var VisibilityRulesWrapper = (props) => {
|
|
705
742
|
const { context, ...rest } = props;
|
|
706
743
|
let isVisible = null;
|
|
@@ -711,12 +748,13 @@ var VisibilityRulesWrapper = (props) => {
|
|
|
711
748
|
parameter: props.parameter
|
|
712
749
|
});
|
|
713
750
|
}
|
|
714
|
-
return /* @__PURE__ */
|
|
751
|
+
return /* @__PURE__ */ React7.createElement(VisibilityRulesWrapperClient, { ...rest, initialIsVisible: isVisible });
|
|
715
752
|
};
|
|
716
753
|
|
|
717
754
|
// src/components/UniformComposition.ts
|
|
718
755
|
var UniformComposition = async ({
|
|
719
756
|
resolveComponent,
|
|
757
|
+
resolveEmptyPlaceholder,
|
|
720
758
|
route,
|
|
721
759
|
...props
|
|
722
760
|
}) => {
|
|
@@ -741,13 +779,16 @@ var UniformComposition = async ({
|
|
|
741
779
|
const state = route.compositionApiResponse.state;
|
|
742
780
|
if (state === CANVAS_DRAFT_STATE2 || state === CANVAS_EDITOR_STATE2) {
|
|
743
781
|
walkNodeTree(route.compositionApiResponse.composition, (node) => {
|
|
782
|
+
var _a, _b;
|
|
744
783
|
if (node.type === "component" && node.node.parameters) {
|
|
784
|
+
const contextualEditing = node.node.parameters[CANVAS_CONTEXTUAL_EDITING_PARAM];
|
|
785
|
+
const editableFields = (_b = (_a = contextualEditing == null ? void 0 : contextualEditing.value) == null ? void 0 : _a.editableParameters) != null ? _b : [];
|
|
745
786
|
Object.keys(node.node.parameters).forEach((key) => {
|
|
746
787
|
const parameter = node.node.parameters[key];
|
|
747
788
|
if (parameter.type === "text") {
|
|
748
789
|
const contextualParameter = parameter;
|
|
749
790
|
contextualParameter._contextualEditing = {
|
|
750
|
-
isEditable:
|
|
791
|
+
isEditable: editableFields.includes(key)
|
|
751
792
|
};
|
|
752
793
|
}
|
|
753
794
|
});
|
|
@@ -771,7 +812,8 @@ var UniformComposition = async ({
|
|
|
771
812
|
resolveComponent,
|
|
772
813
|
serverContext,
|
|
773
814
|
compositionContext,
|
|
774
|
-
mode: props.mode
|
|
815
|
+
mode: props.mode,
|
|
816
|
+
resolveEmptyPlaceholder
|
|
775
817
|
});
|
|
776
818
|
let transfer = null;
|
|
777
819
|
if (props.mode === "server") {
|
|
@@ -824,7 +866,7 @@ var resolveSystemComponent = ({
|
|
|
824
866
|
let resolved = null;
|
|
825
867
|
let suspense = void 0;
|
|
826
868
|
if (component.type === CANVAS_PERSONALIZE_TYPE) {
|
|
827
|
-
resolved = server ?
|
|
869
|
+
resolved = server ? resolveServerPersonalizeComponent({ config }) : PersonalizeClientWrapper;
|
|
828
870
|
suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
|
|
829
871
|
}
|
|
830
872
|
if (component.type === CANVAS_TEST_TYPE) {
|
|
@@ -836,10 +878,15 @@ var resolveSystemComponent = ({
|
|
|
836
878
|
suspense
|
|
837
879
|
};
|
|
838
880
|
};
|
|
881
|
+
var resolveServerPersonalizeComponent = ({ config }) => {
|
|
882
|
+
var _a;
|
|
883
|
+
return ((_a = config.evaluation) == null ? void 0 : _a.personalization) === "hybrid" ? PersonalizeServerHybrid : PersonalizeServer;
|
|
884
|
+
};
|
|
839
885
|
var resolveSlots = ({
|
|
840
886
|
component,
|
|
841
887
|
root,
|
|
842
888
|
resolveComponent,
|
|
889
|
+
resolveEmptyPlaceholder,
|
|
843
890
|
serverContext,
|
|
844
891
|
compositionContext,
|
|
845
892
|
mode
|
|
@@ -859,7 +906,8 @@ var resolveSlots = ({
|
|
|
859
906
|
resolveComponent,
|
|
860
907
|
serverContext,
|
|
861
908
|
compositionContext,
|
|
862
|
-
mode
|
|
909
|
+
mode,
|
|
910
|
+
resolveEmptyPlaceholder
|
|
863
911
|
});
|
|
864
912
|
if (resolved) {
|
|
865
913
|
slots[slotName] = {
|
|
@@ -890,6 +938,7 @@ var resolveComponents = ({
|
|
|
890
938
|
slotName,
|
|
891
939
|
slotIndex,
|
|
892
940
|
resolveComponent,
|
|
941
|
+
resolveEmptyPlaceholder,
|
|
893
942
|
compositionContext,
|
|
894
943
|
mode
|
|
895
944
|
}) => {
|
|
@@ -915,11 +964,29 @@ var resolveComponents = ({
|
|
|
915
964
|
component,
|
|
916
965
|
server: isServer
|
|
917
966
|
});
|
|
967
|
+
const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
|
|
968
|
+
let resolveResult = null;
|
|
969
|
+
if (isPlaceholder && resolveEmptyPlaceholder) {
|
|
970
|
+
const resolvedPlaceholder = resolveEmptyPlaceholder({
|
|
971
|
+
parentComponent: parent,
|
|
972
|
+
component,
|
|
973
|
+
slotName,
|
|
974
|
+
slotIndex: componentIndex
|
|
975
|
+
});
|
|
976
|
+
if (resolvedPlaceholder) {
|
|
977
|
+
resolveResult = {
|
|
978
|
+
component: resolvedPlaceholder.component
|
|
979
|
+
};
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
if (!resolveResult) {
|
|
983
|
+
resolveResult = resolveComponent({ component });
|
|
984
|
+
}
|
|
918
985
|
const {
|
|
919
986
|
component: regularComponent,
|
|
920
987
|
includeContext,
|
|
921
988
|
suspense: componentSuspense
|
|
922
|
-
} =
|
|
989
|
+
} = resolveResult || {
|
|
923
990
|
component: null
|
|
924
991
|
};
|
|
925
992
|
if (!systemComponent && !regularComponent) {
|
|
@@ -931,6 +998,7 @@ var resolveComponents = ({
|
|
|
931
998
|
resolveComponent,
|
|
932
999
|
serverContext,
|
|
933
1000
|
compositionContext,
|
|
1001
|
+
resolveEmptyPlaceholder,
|
|
934
1002
|
mode
|
|
935
1003
|
});
|
|
936
1004
|
const resolvedComponent = systemComponent || regularComponent;
|
|
@@ -980,13 +1048,13 @@ var resolveComponents = ({
|
|
|
980
1048
|
if (tagElement) {
|
|
981
1049
|
elements.push(tagElement);
|
|
982
1050
|
}
|
|
983
|
-
const
|
|
984
|
-
if (!
|
|
1051
|
+
const isPlaceholder2 = isComponentPlaceholderId(component == null ? void 0 : component._id);
|
|
1052
|
+
if (!isPlaceholder2 || compositionContext.previewMode === "editor") {
|
|
985
1053
|
childNode = createElement3(
|
|
986
1054
|
PureContextualEditingComponentWrapper,
|
|
987
1055
|
{
|
|
988
1056
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
989
|
-
isPlaceholder,
|
|
1057
|
+
isPlaceholder: isPlaceholder2,
|
|
990
1058
|
parentComponent: parent,
|
|
991
1059
|
component,
|
|
992
1060
|
slotName,
|
|
@@ -1051,12 +1119,12 @@ import {
|
|
|
1051
1119
|
UniformScript
|
|
1052
1120
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
1053
1121
|
import { Suspense as Suspense2 } from "react";
|
|
1054
|
-
import
|
|
1122
|
+
import React8 from "react";
|
|
1055
1123
|
var UniformContext = async ({
|
|
1056
1124
|
clientContextComponent,
|
|
1057
1125
|
children
|
|
1058
1126
|
}) => {
|
|
1059
|
-
var _a;
|
|
1127
|
+
var _a, _b;
|
|
1060
1128
|
const manifest = await getManifest({
|
|
1061
1129
|
searchParams: {}
|
|
1062
1130
|
});
|
|
@@ -1064,23 +1132,25 @@ var UniformContext = async ({
|
|
|
1064
1132
|
const serverConfig2 = getServerConfig();
|
|
1065
1133
|
const disableDevTools = ((_a = serverConfig2.context) == null ? void 0 : _a.disableDevTools) || false;
|
|
1066
1134
|
const defaultConsent = serverConfig2.defaultConsent || false;
|
|
1067
|
-
|
|
1135
|
+
const experimentalQuirkSerialization = ((_b = serverConfig2.experimental) == null ? void 0 : _b.quirkSerialization) || false;
|
|
1136
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, children, /* @__PURE__ */ React8.createElement(
|
|
1068
1137
|
ContextComponent,
|
|
1069
1138
|
{
|
|
1070
1139
|
manifest,
|
|
1071
1140
|
disableDevTools,
|
|
1072
|
-
defaultConsent
|
|
1141
|
+
defaultConsent,
|
|
1142
|
+
experimentalQuirkSerialization
|
|
1073
1143
|
}
|
|
1074
|
-
), /* @__PURE__ */
|
|
1144
|
+
), /* @__PURE__ */ React8.createElement(Suspense2, { fallback: /* @__PURE__ */ React8.createElement(React8.Fragment, null) }, /* @__PURE__ */ React8.createElement(UniformScript, null)));
|
|
1075
1145
|
};
|
|
1076
1146
|
|
|
1077
1147
|
// src/components/UniformPlayground.tsx
|
|
1078
1148
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
1079
1149
|
import { notFound as notFound2 } from "next/navigation";
|
|
1080
|
-
import
|
|
1150
|
+
import React9 from "react";
|
|
1081
1151
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1082
1152
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
1083
|
-
return /* @__PURE__ */
|
|
1153
|
+
return /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1084
1154
|
}
|
|
1085
1155
|
const id = searchParams["id"];
|
|
1086
1156
|
if (!id) {
|
|
@@ -1111,7 +1181,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1111
1181
|
if (!composition) {
|
|
1112
1182
|
notFound2();
|
|
1113
1183
|
}
|
|
1114
|
-
return /* @__PURE__ */
|
|
1184
|
+
return /* @__PURE__ */ React9.createElement(
|
|
1115
1185
|
UniformComposition,
|
|
1116
1186
|
{
|
|
1117
1187
|
mode: "server",
|