@uniformdev/canvas-next-rsc 19.173.0 → 19.173.2-alpha.210
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-0pvEHduc.d.mts +64 -0
- package/dist/UniformComposition-0pvEHduc.d.ts +77 -0
- package/dist/UniformComposition-38e22896.d.ts +74 -0
- package/dist/UniformComposition-B-Z17dUt.d.ts +56 -43
- package/dist/UniformComposition-D4tBQ2U4.d.mts +64 -0
- package/dist/UniformComposition-D4tBQ2U4.d.ts +77 -0
- package/dist/UniformComposition-Dw55RFP6.d.mts +67 -0
- package/dist/UniformComposition-Dw55RFP6.d.ts +67 -0
- package/dist/UniformComposition-d178d865.d.ts +77 -0
- package/dist/actions/updateContext.d.ts +2 -0
- package/dist/actions/updateContext.js +17 -0
- package/dist/client/canvasClient.d.ts +5 -0
- package/dist/client/canvasClient.js +53 -0
- package/dist/client/manifestClient.d.ts +209 -0
- package/dist/client/manifestClient.js +33 -0
- package/dist/client/projectMapClient.d.ts +5 -0
- package/dist/client/projectMapClient.js +17 -0
- package/dist/client/routeClient.d.ts +5 -0
- package/dist/client/routeClient.js +68 -0
- package/dist/component.d.mts +23 -5
- package/dist/component.d.ts +23 -5
- package/dist/component.js +67 -25
- package/dist/component.mjs +66 -23
- package/dist/components/DefaultNotImplementedComponent.d.ts +4 -0
- package/dist/components/DefaultNotImplementedComponent.js +45 -0
- package/dist/components/GoogleTagManagerAnalytics.d.ts +3 -0
- package/dist/components/GoogleTagManagerAnalytics.js +44 -0
- package/dist/components/UniformComponent.d.ts +35 -0
- package/dist/components/UniformComponent.js +14 -0
- package/dist/components/UniformComposition.d.ts +47 -0
- package/dist/components/UniformComposition.js +35 -0
- package/dist/components/UniformContext.d.ts +13 -0
- package/dist/components/UniformContext.js +19 -0
- package/dist/components/UniformRichText.d.ts +42 -0
- package/dist/components/UniformRichText.js +15 -0
- package/dist/components/UniformRichTextNode.d.ts +14 -0
- package/dist/components/UniformRichTextNode.js +49 -0
- package/dist/components/UniformScript.d.ts +5 -0
- package/dist/components/UniformScript.js +49 -0
- package/dist/components/UniformSlot.d.ts +48 -0
- package/dist/components/UniformSlot.js +38 -0
- package/dist/components/UniformText.d.ts +10 -0
- package/dist/components/UniformText.js +5 -0
- package/dist/components/__tests__/evaluateComposition.spec.d.ts +1 -0
- package/dist/components/__tests__/evaluateComposition.spec.js +80 -0
- package/dist/components/convertComponentToProps.d.ts +18 -0
- package/dist/components/convertComponentToProps.js +22 -0
- package/dist/components/evaluateComposition.d.ts +32 -0
- package/dist/components/evaluateComposition.js +183 -0
- package/dist/components/getEnrichmentTags.d.ts +5 -0
- package/dist/components/getEnrichmentTags.js +13 -0
- package/dist/components/getUniformContext.d.ts +10 -0
- package/dist/components/getUniformContext.js +17 -0
- package/dist/components/nodes/HeadingRichTextNode.d.ts +2 -0
- package/dist/components/nodes/HeadingRichTextNode.js +6 -0
- package/dist/components/nodes/LinebreakRichTextNode.d.ts +2 -0
- package/dist/components/nodes/LinebreakRichTextNode.js +4 -0
- package/dist/components/nodes/LinkRichTextNode.d.ts +2 -0
- package/dist/components/nodes/LinkRichTextNode.js +6 -0
- package/dist/components/nodes/ListItemRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ListItemRichTextNode.js +5 -0
- package/dist/components/nodes/ListRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ListRichTextNode.js +6 -0
- package/dist/components/nodes/ParagraphRichTextNode.d.ts +2 -0
- package/dist/components/nodes/ParagraphRichTextNode.js +6 -0
- package/dist/components/nodes/TabRichTextNode.d.ts +2 -0
- package/dist/components/nodes/TabRichTextNode.js +4 -0
- package/dist/components/nodes/TextRichTextNode.d.ts +2 -0
- package/dist/components/nodes/TextRichTextNode.js +9 -0
- package/dist/components/renderComponent.d.ts +26 -0
- package/dist/components/renderComponent.js +52 -0
- package/dist/components/resolvePath.d.ts +5 -0
- package/dist/components/resolvePath.js +34 -0
- package/dist/components/retrieveRoute.d.ts +198 -0
- package/dist/components/retrieveRoute.js +146 -0
- package/dist/components/types.d.ts +15 -0
- package/dist/components/types.js +1 -0
- package/dist/config/helpers.d.ts +23 -0
- package/dist/config/helpers.js +34 -0
- package/dist/config/models.d.ts +51 -0
- package/dist/config/models.js +1 -0
- package/dist/config/uniform.server.config.d.ts +3 -0
- package/dist/config/uniform.server.config.js +4 -0
- package/dist/cookie/index.d.ts +12 -0
- package/dist/cookie/index.js +21 -0
- package/dist/handler/createPreviewGETRouteHandler.d.ts +1 -0
- package/dist/handler/createPreviewGETRouteHandler.js +43 -0
- package/dist/handler/createPreviewPOSTRouteHandler.d.ts +1 -0
- package/dist/handler/createPreviewPOSTRouteHandler.js +88 -0
- package/dist/handler/createUniformRouteHandler.d.ts +4 -0
- package/dist/handler/createUniformRouteHandler.js +10 -0
- package/dist/handler/helpers.d.ts +17 -0
- package/dist/handler/helpers.js +148 -0
- package/dist/handler/messages/handleCompositionChanged.d.ts +2 -0
- package/dist/handler/messages/handleCompositionChanged.js +9 -0
- package/dist/handler/messages/handleCompositionDeleted.d.ts +2 -0
- package/dist/handler/messages/handleCompositionDeleted.js +9 -0
- package/dist/handler/messages/handleCompositionPublished.d.ts +2 -0
- package/dist/handler/messages/handleCompositionPublished.js +9 -0
- package/dist/handler/messages/handleManifestPublished.d.ts +2 -0
- package/dist/handler/messages/handleManifestPublished.js +10 -0
- package/dist/handler/messages/handleProjectMapNodeDelete.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeDelete.js +21 -0
- package/dist/handler/messages/handleProjectMapNodeInsert.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeInsert.js +21 -0
- package/dist/handler/messages/handleProjectMapNodeUpdate.d.ts +2 -0
- package/dist/handler/messages/handleProjectMapNodeUpdate.js +22 -0
- package/dist/handler/messages/handleRedirectDelete.d.ts +2 -0
- package/dist/handler/messages/handleRedirectDelete.js +15 -0
- package/dist/handler/messages/handleRedirectInsert.d.ts +2 -0
- package/dist/handler/messages/handleRedirectInsert.js +15 -0
- package/dist/handler/messages/handleRedirectUpdate.d.ts +2 -0
- package/dist/handler/messages/handleRedirectUpdate.js +15 -0
- package/dist/handler.js +2 -1
- package/dist/handler.mjs +2 -1
- package/dist/hooks/useForgetMe.d.ts +4 -0
- package/dist/hooks/useForgetMe.js +10 -0
- package/dist/hooks/useToggleConsent.d.ts +7 -0
- package/dist/hooks/useToggleConsent.js +22 -0
- package/dist/hooks/useUniformContext.d.ts +1 -0
- package/dist/hooks/useUniformContext.js +3 -0
- package/dist/index.d.mts +38 -38
- package/dist/index.d.ts +38 -38
- package/dist/index.esm.js +51 -19
- package/dist/index.js +78 -50
- package/dist/index.mjs +51 -19
- package/dist/models/index.d.ts +30 -0
- package/dist/models/index.js +1 -0
- package/dist/register/componentStore.d.ts +1 -0
- package/dist/register/componentStore.js +2 -0
- package/dist/register/componentStoreResolver.d.ts +4 -0
- package/dist/register/componentStoreResolver.js +5 -0
- package/dist/register/createComponentStore.d.ts +12 -0
- package/dist/register/createComponentStore.js +13 -0
- package/dist/register/createComponentStoreResolver.d.ts +12 -0
- package/dist/register/createComponentStoreResolver.js +9 -0
- package/dist/register/getTypeWithVariant.d.ts +1 -0
- package/dist/register/getTypeWithVariant.js +1 -0
- package/dist/register/registerUniformComponent.d.ts +10 -0
- package/dist/register/registerUniformComponent.js +8 -0
- package/dist/resolve/resolveChildren.d.ts +17 -0
- package/dist/resolve/resolveChildren.js +20 -0
- package/dist/score/index.d.ts +3 -0
- package/dist/score/index.js +114 -0
- package/dist/utils/__tests__/apply.spec.d.ts +1 -0
- package/dist/utils/__tests__/apply.spec.js +358 -0
- package/dist/utils/__tests__/diff.spec.d.ts +1 -0
- package/dist/utils/__tests__/diff.spec.js +394 -0
- package/dist/utils/apply.d.ts +10 -0
- package/dist/utils/apply.js +124 -0
- package/dist/utils/comp.d.ts +25 -0
- package/dist/utils/comp.js +65 -0
- package/dist/utils/diff.d.ts +58 -0
- package/dist/utils/diff.js +144 -0
- package/dist/utils/draft.d.ts +20 -0
- package/dist/utils/draft.js +22 -0
- package/dist/utils/tag.d.ts +2 -0
- package/dist/utils/tag.js +7 -0
- package/dist/utils/url.d.ts +1 -0
- package/dist/utils/url.js +10 -0
- package/package.json +20 -20
package/dist/index.js
CHANGED
|
@@ -258,7 +258,8 @@ var getCanvasClient = (options) => {
|
|
|
258
258
|
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
259
259
|
},
|
|
260
260
|
next: {
|
|
261
|
-
revalidate
|
|
261
|
+
revalidate,
|
|
262
|
+
tags: tags.length ? tags : void 0
|
|
262
263
|
}
|
|
263
264
|
});
|
|
264
265
|
}
|
|
@@ -416,7 +417,7 @@ var ContextUpdateTransfer = async ({
|
|
|
416
417
|
return null;
|
|
417
418
|
}
|
|
418
419
|
if (serverContext) {
|
|
419
|
-
await serverContext.
|
|
420
|
+
await serverContext.internal_update(result);
|
|
420
421
|
}
|
|
421
422
|
return /* @__PURE__ */ import_react.default.createElement(import_canvas_next_rsc_client.ContextUpdateTransferClient, { ts: (/* @__PURE__ */ new Date()).valueOf(), update: result });
|
|
422
423
|
};
|
|
@@ -455,13 +456,13 @@ async function generateStaticParams() {
|
|
|
455
456
|
}
|
|
456
457
|
|
|
457
458
|
// src/components/UniformComposition.ts
|
|
458
|
-
var
|
|
459
|
-
var
|
|
459
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
460
|
+
var import_canvas_next_rsc_client7 = require("@uniformdev/canvas-next-rsc-client");
|
|
460
461
|
var import_canvas_next_rsc_shared6 = require("@uniformdev/canvas-next-rsc-shared");
|
|
461
462
|
var import_core = require("@uniformdev/canvas-react/core");
|
|
462
463
|
var import_headers3 = require("next/headers");
|
|
463
464
|
var import_navigation = require("next/navigation");
|
|
464
|
-
var
|
|
465
|
+
var import_react9 = require("react");
|
|
465
466
|
|
|
466
467
|
// src/context/createServerUniformContext.ts
|
|
467
468
|
var import_canvas_next_rsc_shared = require("@uniformdev/canvas-next-rsc-shared");
|
|
@@ -481,12 +482,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
481
482
|
...options || {},
|
|
482
483
|
serverCookieValue: (_a = (0, import_headers2.cookies)().get(import_context.UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
483
484
|
});
|
|
484
|
-
return
|
|
485
|
-
...context,
|
|
486
|
-
__INTERNAL__: {
|
|
487
|
-
update: (...props) => context.update(...props)
|
|
488
|
-
}
|
|
489
|
-
};
|
|
485
|
+
return context;
|
|
490
486
|
};
|
|
491
487
|
|
|
492
488
|
// src/utils/route.ts
|
|
@@ -715,6 +711,23 @@ var TestServer = async (props) => {
|
|
|
715
711
|
return (0, import_react7.createElement)(import_react7.Fragment, void 0, [component, eventElement]);
|
|
716
712
|
};
|
|
717
713
|
|
|
714
|
+
// src/components/VisibilityRulesWrapper.tsx
|
|
715
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
716
|
+
var import_canvas_next_rsc_client6 = require("@uniformdev/canvas-next-rsc-client");
|
|
717
|
+
var import_react8 = __toESM(require("react"));
|
|
718
|
+
var VisibilityRulesWrapper = (props) => {
|
|
719
|
+
const { context, ...rest } = props;
|
|
720
|
+
let isVisible = null;
|
|
721
|
+
if (context) {
|
|
722
|
+
const rules = (0, import_canvas7.createQuirksVisibilityRule)(context.quirks);
|
|
723
|
+
isVisible = (0, import_canvas7.evaluateNodeVisibilityParameter)({
|
|
724
|
+
rules,
|
|
725
|
+
parameter: props.parameter
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_canvas_next_rsc_client6.VisibilityRulesWrapperClient, { ...rest, initialIsVisible: isVisible });
|
|
729
|
+
};
|
|
730
|
+
|
|
718
731
|
// src/components/UniformComposition.ts
|
|
719
732
|
var UniformComposition = async ({
|
|
720
733
|
resolveComponent,
|
|
@@ -740,8 +753,8 @@ var UniformComposition = async ({
|
|
|
740
753
|
(0, import_navigation.redirect)(href);
|
|
741
754
|
}
|
|
742
755
|
const state = route.compositionApiResponse.state;
|
|
743
|
-
if (state ===
|
|
744
|
-
(0,
|
|
756
|
+
if (state === import_canvas8.CANVAS_DRAFT_STATE || state === import_canvas8.CANVAS_EDITOR_STATE) {
|
|
757
|
+
(0, import_canvas8.walkNodeTree)(route.compositionApiResponse.composition, (node) => {
|
|
745
758
|
if (node.type === "component" && node.node.parameters) {
|
|
746
759
|
Object.keys(node.node.parameters).forEach((key) => {
|
|
747
760
|
const parameter = node.node.parameters[key];
|
|
@@ -777,15 +790,18 @@ var UniformComposition = async ({
|
|
|
777
790
|
if (props.mode === "server") {
|
|
778
791
|
const headersValue = (0, import_headers3.headers)();
|
|
779
792
|
const missingQuirkValue = "unknown";
|
|
780
|
-
transfer = (0,
|
|
793
|
+
transfer = (0, import_react9.createElement)(ContextUpdateTransfer, {
|
|
781
794
|
serverContext,
|
|
782
795
|
update: {
|
|
783
796
|
params: props.params,
|
|
784
797
|
searchParams,
|
|
785
|
-
cookies: (0, import_headers3.cookies)().getAll().reduce(
|
|
786
|
-
acc
|
|
787
|
-
|
|
788
|
-
|
|
798
|
+
cookies: (0, import_headers3.cookies)().getAll().reduce(
|
|
799
|
+
(acc, cookie) => {
|
|
800
|
+
acc[cookie.name] = cookie.value;
|
|
801
|
+
return acc;
|
|
802
|
+
},
|
|
803
|
+
{}
|
|
804
|
+
),
|
|
789
805
|
quirks: {
|
|
790
806
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
791
807
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
|
@@ -794,21 +810,21 @@ var UniformComposition = async ({
|
|
|
794
810
|
}
|
|
795
811
|
});
|
|
796
812
|
} else if (props.mode === "static") {
|
|
797
|
-
transfer = (0,
|
|
813
|
+
transfer = (0, import_react9.createElement)(ContextUpdateTrigger, {
|
|
798
814
|
path
|
|
799
815
|
});
|
|
800
816
|
}
|
|
801
|
-
return (0,
|
|
817
|
+
return (0, import_react9.createElement)(import_react9.Fragment, void 0, transfer, resolved);
|
|
802
818
|
};
|
|
803
819
|
var isServerComponent = ({
|
|
804
820
|
component,
|
|
805
821
|
serverContext
|
|
806
822
|
}) => {
|
|
807
823
|
var _a, _b;
|
|
808
|
-
if (component.type ===
|
|
824
|
+
if (component.type === import_canvas8.CANVAS_PERSONALIZE_TYPE) {
|
|
809
825
|
return serverContext && ((_a = getServerConfig().evaluation) == null ? void 0 : _a.personalization) !== "client";
|
|
810
826
|
}
|
|
811
|
-
if (component.type ===
|
|
827
|
+
if (component.type === import_canvas8.CANVAS_TEST_TYPE) {
|
|
812
828
|
return serverContext && ((_b = getServerConfig().evaluation) == null ? void 0 : _b.testing) !== "client";
|
|
813
829
|
}
|
|
814
830
|
};
|
|
@@ -820,12 +836,12 @@ var resolveSystemComponent = ({
|
|
|
820
836
|
const config = getServerConfig();
|
|
821
837
|
let resolved = null;
|
|
822
838
|
let suspense = void 0;
|
|
823
|
-
if (component.type ===
|
|
839
|
+
if (component.type === import_canvas8.CANVAS_PERSONALIZE_TYPE) {
|
|
824
840
|
resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
825
841
|
suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
|
|
826
842
|
}
|
|
827
|
-
if (component.type ===
|
|
828
|
-
resolved = server ? TestServer :
|
|
843
|
+
if (component.type === import_canvas8.CANVAS_TEST_TYPE) {
|
|
844
|
+
resolved = server ? TestServer : import_canvas_next_rsc_client7.TestClient;
|
|
829
845
|
suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
|
|
830
846
|
}
|
|
831
847
|
return {
|
|
@@ -903,7 +919,7 @@ var resolveComponents = ({
|
|
|
903
919
|
parent = target.parent;
|
|
904
920
|
}
|
|
905
921
|
const resolved = components.map((component, componentIndex) => {
|
|
906
|
-
var _a, _b;
|
|
922
|
+
var _a, _b, _c;
|
|
907
923
|
const isServer = isServerComponent({
|
|
908
924
|
component,
|
|
909
925
|
serverContext
|
|
@@ -933,7 +949,8 @@ var resolveComponents = ({
|
|
|
933
949
|
const resolvedComponent = systemComponent || regularComponent;
|
|
934
950
|
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
935
951
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
936
|
-
const enrichmentTags = (_b = parameters[
|
|
952
|
+
const enrichmentTags = (_b = parameters[import_canvas8.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
953
|
+
const visibilityRules = (_c = parameters[import_canvas8.CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _c.value;
|
|
937
954
|
const key = `${slotName}-${componentIndex}-component`;
|
|
938
955
|
const componentProps = {
|
|
939
956
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
@@ -949,20 +966,20 @@ var resolveComponents = ({
|
|
|
949
966
|
};
|
|
950
967
|
let element = null;
|
|
951
968
|
if (wrapInSuspense) {
|
|
952
|
-
element = (0,
|
|
953
|
-
|
|
969
|
+
element = (0, import_react9.createElement)(
|
|
970
|
+
import_react9.Suspense,
|
|
954
971
|
{
|
|
955
972
|
key,
|
|
956
|
-
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0,
|
|
973
|
+
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0, import_react9.createElement)(wrapInSuspense.fallback)
|
|
957
974
|
},
|
|
958
|
-
(0,
|
|
975
|
+
(0, import_react9.createElement)(resolvedComponent, componentProps)
|
|
959
976
|
);
|
|
960
977
|
} else {
|
|
961
|
-
element = (0,
|
|
978
|
+
element = (0, import_react9.createElement)(resolvedComponent, { ...componentProps, key });
|
|
962
979
|
}
|
|
963
980
|
let tagElement = null;
|
|
964
981
|
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
965
|
-
tagElement = (0,
|
|
982
|
+
tagElement = (0, import_react9.createElement)(ContextUpdateTransfer, {
|
|
966
983
|
key: `${slotName}-${componentIndex}-tags`,
|
|
967
984
|
update: {
|
|
968
985
|
enrichments: enrichmentTags
|
|
@@ -976,8 +993,8 @@ var resolveComponents = ({
|
|
|
976
993
|
if (tagElement) {
|
|
977
994
|
elements.push(tagElement);
|
|
978
995
|
}
|
|
979
|
-
const isPlaceholder = (0,
|
|
980
|
-
childNode = (0,
|
|
996
|
+
const isPlaceholder = (0, import_canvas8.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
997
|
+
childNode = (0, import_react9.createElement)(
|
|
981
998
|
import_core.PureContextualEditingComponentWrapper,
|
|
982
999
|
{
|
|
983
1000
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
@@ -996,8 +1013,8 @@ var resolveComponents = ({
|
|
|
996
1013
|
if (tagElement) {
|
|
997
1014
|
elements.push(tagElement);
|
|
998
1015
|
}
|
|
999
|
-
childNode = (0,
|
|
1000
|
-
|
|
1016
|
+
childNode = (0, import_react9.createElement)(
|
|
1017
|
+
import_canvas_next_rsc_client7.ClientContextualEditingComponentWrapper,
|
|
1001
1018
|
{
|
|
1002
1019
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
1003
1020
|
isPlaceholder: false,
|
|
@@ -1017,8 +1034,19 @@ var resolveComponents = ({
|
|
|
1017
1034
|
}
|
|
1018
1035
|
childNode = elements;
|
|
1019
1036
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1037
|
+
if (visibilityRules) {
|
|
1038
|
+
childNode = (0, import_react9.createElement)(
|
|
1039
|
+
VisibilityRulesWrapper,
|
|
1040
|
+
{
|
|
1041
|
+
key: `${slotName}-${componentIndex}-visibility`,
|
|
1042
|
+
parameter: visibilityRules,
|
|
1043
|
+
context: serverContext
|
|
1044
|
+
},
|
|
1045
|
+
childNode
|
|
1046
|
+
);
|
|
1047
|
+
}
|
|
1048
|
+
return (0, import_react9.createElement)(
|
|
1049
|
+
import_react9.Fragment,
|
|
1022
1050
|
{
|
|
1023
1051
|
key: !isRoot ? `${slotName}-${componentIndex}` : void 0
|
|
1024
1052
|
},
|
|
@@ -1029,9 +1057,9 @@ var resolveComponents = ({
|
|
|
1029
1057
|
};
|
|
1030
1058
|
|
|
1031
1059
|
// src/components/UniformContext.tsx
|
|
1032
|
-
var
|
|
1033
|
-
var
|
|
1034
|
-
var
|
|
1060
|
+
var import_canvas_next_rsc_client8 = require("@uniformdev/canvas-next-rsc-client");
|
|
1061
|
+
var import_react10 = require("react");
|
|
1062
|
+
var import_react11 = __toESM(require("react"));
|
|
1035
1063
|
var UniformContext = async ({
|
|
1036
1064
|
clientContextComponent,
|
|
1037
1065
|
children
|
|
@@ -1040,27 +1068,27 @@ var UniformContext = async ({
|
|
|
1040
1068
|
const manifest = await getManifest({
|
|
1041
1069
|
searchParams: {}
|
|
1042
1070
|
});
|
|
1043
|
-
const ContextComponent = clientContextComponent ||
|
|
1071
|
+
const ContextComponent = clientContextComponent || import_canvas_next_rsc_client8.DefaultUniformClientContext;
|
|
1044
1072
|
const serverConfig = getServerConfig();
|
|
1045
1073
|
const disableDevTools = ((_a = serverConfig.context) == null ? void 0 : _a.disableDevTools) || false;
|
|
1046
1074
|
const defaultConsent = serverConfig.defaultConsent || false;
|
|
1047
|
-
return /* @__PURE__ */
|
|
1075
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, children, /* @__PURE__ */ import_react11.default.createElement(
|
|
1048
1076
|
ContextComponent,
|
|
1049
1077
|
{
|
|
1050
1078
|
manifest,
|
|
1051
1079
|
disableDevTools,
|
|
1052
1080
|
defaultConsent
|
|
1053
1081
|
}
|
|
1054
|
-
), /* @__PURE__ */
|
|
1082
|
+
), /* @__PURE__ */ import_react11.default.createElement(import_react10.Suspense, { fallback: /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null) }, /* @__PURE__ */ import_react11.default.createElement(import_canvas_next_rsc_client8.UniformScript, null)));
|
|
1055
1083
|
};
|
|
1056
1084
|
|
|
1057
1085
|
// src/components/UniformPlayground.tsx
|
|
1058
|
-
var
|
|
1086
|
+
var import_canvas9 = require("@uniformdev/canvas");
|
|
1059
1087
|
var import_navigation2 = require("next/navigation");
|
|
1060
|
-
var
|
|
1088
|
+
var import_react12 = __toESM(require("react"));
|
|
1061
1089
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1062
1090
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
1063
|
-
return /* @__PURE__ */
|
|
1091
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1064
1092
|
}
|
|
1065
1093
|
const id = searchParams["id"];
|
|
1066
1094
|
if (!id) {
|
|
@@ -1071,7 +1099,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1071
1099
|
type: "no-cache"
|
|
1072
1100
|
}
|
|
1073
1101
|
});
|
|
1074
|
-
const possibleStates = [
|
|
1102
|
+
const possibleStates = [import_canvas9.CANVAS_EDITOR_STATE, import_canvas9.CANVAS_DRAFT_STATE];
|
|
1075
1103
|
let composition = void 0;
|
|
1076
1104
|
for (let i = 0; i < possibleStates.length; i++) {
|
|
1077
1105
|
const state = possibleStates[i];
|
|
@@ -1091,7 +1119,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1091
1119
|
if (!composition) {
|
|
1092
1120
|
(0, import_navigation2.notFound)();
|
|
1093
1121
|
}
|
|
1094
|
-
return /* @__PURE__ */
|
|
1122
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1095
1123
|
UniformComposition,
|
|
1096
1124
|
{
|
|
1097
1125
|
mode: "server",
|
package/dist/index.mjs
CHANGED
|
@@ -209,7 +209,8 @@ var getCanvasClient = (options) => {
|
|
|
209
209
|
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
210
210
|
},
|
|
211
211
|
next: {
|
|
212
|
-
revalidate
|
|
212
|
+
revalidate,
|
|
213
|
+
tags: tags.length ? tags : void 0
|
|
213
214
|
}
|
|
214
215
|
});
|
|
215
216
|
}
|
|
@@ -367,7 +368,7 @@ var ContextUpdateTransfer = async ({
|
|
|
367
368
|
return null;
|
|
368
369
|
}
|
|
369
370
|
if (serverContext) {
|
|
370
|
-
await serverContext.
|
|
371
|
+
await serverContext.internal_update(result);
|
|
371
372
|
}
|
|
372
373
|
return /* @__PURE__ */ React.createElement(ContextUpdateTransferClient, { ts: (/* @__PURE__ */ new Date()).valueOf(), update: result });
|
|
373
374
|
};
|
|
@@ -412,6 +413,7 @@ import {
|
|
|
412
413
|
CANVAS_ENRICHMENT_TAG_PARAM,
|
|
413
414
|
CANVAS_PERSONALIZE_TYPE,
|
|
414
415
|
CANVAS_TEST_TYPE,
|
|
416
|
+
CANVAS_VIZ_CONTROL_PARAM,
|
|
415
417
|
isComponentPlaceholderId,
|
|
416
418
|
walkNodeTree
|
|
417
419
|
} from "@uniformdev/canvas";
|
|
@@ -444,12 +446,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
444
446
|
...options || {},
|
|
445
447
|
serverCookieValue: (_a = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
446
448
|
});
|
|
447
|
-
return
|
|
448
|
-
...context,
|
|
449
|
-
__INTERNAL__: {
|
|
450
|
-
update: (...props) => context.update(...props)
|
|
451
|
-
}
|
|
452
|
-
};
|
|
449
|
+
return context;
|
|
453
450
|
};
|
|
454
451
|
|
|
455
452
|
// src/utils/route.ts
|
|
@@ -684,6 +681,26 @@ var TestServer = async (props) => {
|
|
|
684
681
|
return createElement2(Fragment2, void 0, [component, eventElement]);
|
|
685
682
|
};
|
|
686
683
|
|
|
684
|
+
// src/components/VisibilityRulesWrapper.tsx
|
|
685
|
+
import {
|
|
686
|
+
createQuirksVisibilityRule,
|
|
687
|
+
evaluateNodeVisibilityParameter
|
|
688
|
+
} from "@uniformdev/canvas";
|
|
689
|
+
import { VisibilityRulesWrapperClient } from "@uniformdev/canvas-next-rsc-client";
|
|
690
|
+
import React6 from "react";
|
|
691
|
+
var VisibilityRulesWrapper = (props) => {
|
|
692
|
+
const { context, ...rest } = props;
|
|
693
|
+
let isVisible = null;
|
|
694
|
+
if (context) {
|
|
695
|
+
const rules = createQuirksVisibilityRule(context.quirks);
|
|
696
|
+
isVisible = evaluateNodeVisibilityParameter({
|
|
697
|
+
rules,
|
|
698
|
+
parameter: props.parameter
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
return /* @__PURE__ */ React6.createElement(VisibilityRulesWrapperClient, { ...rest, initialIsVisible: isVisible });
|
|
702
|
+
};
|
|
703
|
+
|
|
687
704
|
// src/components/UniformComposition.ts
|
|
688
705
|
var UniformComposition = async ({
|
|
689
706
|
resolveComponent,
|
|
@@ -751,10 +768,13 @@ var UniformComposition = async ({
|
|
|
751
768
|
update: {
|
|
752
769
|
params: props.params,
|
|
753
770
|
searchParams,
|
|
754
|
-
cookies: cookies2().getAll().reduce(
|
|
755
|
-
acc
|
|
756
|
-
|
|
757
|
-
|
|
771
|
+
cookies: cookies2().getAll().reduce(
|
|
772
|
+
(acc, cookie) => {
|
|
773
|
+
acc[cookie.name] = cookie.value;
|
|
774
|
+
return acc;
|
|
775
|
+
},
|
|
776
|
+
{}
|
|
777
|
+
),
|
|
758
778
|
quirks: {
|
|
759
779
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
760
780
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
|
@@ -872,7 +892,7 @@ var resolveComponents = ({
|
|
|
872
892
|
parent = target.parent;
|
|
873
893
|
}
|
|
874
894
|
const resolved = components.map((component, componentIndex) => {
|
|
875
|
-
var _a, _b;
|
|
895
|
+
var _a, _b, _c;
|
|
876
896
|
const isServer = isServerComponent({
|
|
877
897
|
component,
|
|
878
898
|
serverContext
|
|
@@ -903,6 +923,7 @@ var resolveComponents = ({
|
|
|
903
923
|
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
904
924
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
905
925
|
const enrichmentTags = (_b = parameters[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
926
|
+
const visibilityRules = (_c = parameters[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _c.value;
|
|
906
927
|
const key = `${slotName}-${componentIndex}-component`;
|
|
907
928
|
const componentProps = {
|
|
908
929
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
@@ -986,6 +1007,17 @@ var resolveComponents = ({
|
|
|
986
1007
|
}
|
|
987
1008
|
childNode = elements;
|
|
988
1009
|
}
|
|
1010
|
+
if (visibilityRules) {
|
|
1011
|
+
childNode = createElement3(
|
|
1012
|
+
VisibilityRulesWrapper,
|
|
1013
|
+
{
|
|
1014
|
+
key: `${slotName}-${componentIndex}-visibility`,
|
|
1015
|
+
parameter: visibilityRules,
|
|
1016
|
+
context: serverContext
|
|
1017
|
+
},
|
|
1018
|
+
childNode
|
|
1019
|
+
);
|
|
1020
|
+
}
|
|
989
1021
|
return createElement3(
|
|
990
1022
|
Fragment3,
|
|
991
1023
|
{
|
|
@@ -1003,7 +1035,7 @@ import {
|
|
|
1003
1035
|
UniformScript
|
|
1004
1036
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
1005
1037
|
import { Suspense as Suspense2 } from "react";
|
|
1006
|
-
import
|
|
1038
|
+
import React7 from "react";
|
|
1007
1039
|
var UniformContext = async ({
|
|
1008
1040
|
clientContextComponent,
|
|
1009
1041
|
children
|
|
@@ -1016,23 +1048,23 @@ var UniformContext = async ({
|
|
|
1016
1048
|
const serverConfig = getServerConfig();
|
|
1017
1049
|
const disableDevTools = ((_a = serverConfig.context) == null ? void 0 : _a.disableDevTools) || false;
|
|
1018
1050
|
const defaultConsent = serverConfig.defaultConsent || false;
|
|
1019
|
-
return /* @__PURE__ */
|
|
1051
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children, /* @__PURE__ */ React7.createElement(
|
|
1020
1052
|
ContextComponent,
|
|
1021
1053
|
{
|
|
1022
1054
|
manifest,
|
|
1023
1055
|
disableDevTools,
|
|
1024
1056
|
defaultConsent
|
|
1025
1057
|
}
|
|
1026
|
-
), /* @__PURE__ */
|
|
1058
|
+
), /* @__PURE__ */ React7.createElement(Suspense2, { fallback: /* @__PURE__ */ React7.createElement(React7.Fragment, null) }, /* @__PURE__ */ React7.createElement(UniformScript, null)));
|
|
1027
1059
|
};
|
|
1028
1060
|
|
|
1029
1061
|
// src/components/UniformPlayground.tsx
|
|
1030
1062
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
1031
1063
|
import { notFound as notFound2 } from "next/navigation";
|
|
1032
|
-
import
|
|
1064
|
+
import React8 from "react";
|
|
1033
1065
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1034
1066
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
1035
|
-
return /* @__PURE__ */
|
|
1067
|
+
return /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1036
1068
|
}
|
|
1037
1069
|
const id = searchParams["id"];
|
|
1038
1070
|
if (!id) {
|
|
@@ -1063,7 +1095,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1063
1095
|
if (!composition) {
|
|
1064
1096
|
notFound2();
|
|
1065
1097
|
}
|
|
1066
|
-
return /* @__PURE__ */
|
|
1098
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1067
1099
|
UniformComposition,
|
|
1068
1100
|
{
|
|
1069
1101
|
mode: "server",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentInstance, ComponentParameter } from '@uniformdev/canvas';
|
|
2
|
+
export interface TestComponent {
|
|
3
|
+
slots?: {
|
|
4
|
+
test?: ComponentInstance[];
|
|
5
|
+
};
|
|
6
|
+
parameters: {
|
|
7
|
+
test?: ComponentParameter<string | undefined>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PersonalizeComponent {
|
|
11
|
+
slots?: {
|
|
12
|
+
pz?: ComponentInstance[];
|
|
13
|
+
};
|
|
14
|
+
parameters: {
|
|
15
|
+
trackingEventName?: ComponentParameter<string>;
|
|
16
|
+
count?: ComponentParameter<string | number>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export type SeenUniformComponent = SeenPersonalizationComponent | SeenTestComponent;
|
|
20
|
+
export interface SeenPersonalizationComponent {
|
|
21
|
+
id: string;
|
|
22
|
+
type: 'personalization';
|
|
23
|
+
variants: string[];
|
|
24
|
+
control: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface SeenTestComponent {
|
|
27
|
+
id: string;
|
|
28
|
+
type: 'test';
|
|
29
|
+
variant: string | undefined;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const componentStore: import('./createComponentStore').ComponentStore;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentProps } from '../components/UniformComponent';
|
|
3
|
+
export declare const NOT_IMPLEMENTED_COMPONENT = '__not_implemented__';
|
|
4
|
+
export declare const createComponentStore: () => ComponentStore;
|
|
5
|
+
export type ComponentStore = {
|
|
6
|
+
register: (options: {
|
|
7
|
+
type: string;
|
|
8
|
+
variantId?: string;
|
|
9
|
+
component: React.ComponentType<ComponentProps<any>>;
|
|
10
|
+
}) => void;
|
|
11
|
+
get: (type: string, variantId?: string) => React.ComponentType<ComponentProps<any>> | undefined;
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getTypeWithVariant } from './getTypeWithVariant';
|
|
2
|
+
export const NOT_IMPLEMENTED_COMPONENT = '__not_implemented__';
|
|
3
|
+
export const createComponentStore = () => {
|
|
4
|
+
const components = new Map();
|
|
5
|
+
return {
|
|
6
|
+
register: ({ type, component, variantId }) => {
|
|
7
|
+
components.set(getTypeWithVariant(type, variantId), component);
|
|
8
|
+
},
|
|
9
|
+
get: (type, variantId) => {
|
|
10
|
+
return components.get(getTypeWithVariant(type, variantId));
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type ComponentInstance } from '@uniformdev/canvas';
|
|
3
|
+
|
|
4
|
+
import { ComponentProps } from '../components/UniformComponent';
|
|
5
|
+
import { ComponentStore } from './createComponentStore';
|
|
6
|
+
type RenderComponentResolver = (
|
|
7
|
+
component: ComponentInstance
|
|
8
|
+
) => React.ComponentType<ComponentProps<any>> | null;
|
|
9
|
+
export declare const createComponentStoreResolver: (options: {
|
|
10
|
+
store: ComponentStore;
|
|
11
|
+
}) => RenderComponentResolver;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DefaultNotImplementedComponent } from '../components/DefaultNotImplementedComponent';
|
|
2
|
+
import { getTypeWithVariant } from './getTypeWithVariant';
|
|
3
|
+
export const createComponentStoreResolver = ({ store }) => {
|
|
4
|
+
return (component) => {
|
|
5
|
+
var _a;
|
|
6
|
+
const resolved = (_a = store.get(getTypeWithVariant(component.type, component.variant))) !== null && _a !== void 0 ? _a : store.get(getTypeWithVariant(component.type));
|
|
7
|
+
return resolved || DefaultNotImplementedComponent;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTypeWithVariant: (type: string, variantId?: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const getTypeWithVariant = (type, variantId) => `${type}${variantId ? `__${variantId}` : ''}`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ComponentProps } from '../components/UniformComponent';
|
|
2
|
+
export declare const registerUniformComponent: ({
|
|
3
|
+
type,
|
|
4
|
+
variantId,
|
|
5
|
+
component,
|
|
6
|
+
}: {
|
|
7
|
+
type: string;
|
|
8
|
+
variantId?: string | undefined;
|
|
9
|
+
component: React.ComponentType<ComponentProps<any>>;
|
|
10
|
+
}) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { RenderComponentResolver } from '@uniformdev/canvas-react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { CompositionContext, UniformComponentProps } from '../components/UniformComponent';
|
|
5
|
+
export declare function resolveChildren<TRenderProps = unknown>({
|
|
6
|
+
children,
|
|
7
|
+
data,
|
|
8
|
+
context,
|
|
9
|
+
hasParentLayout,
|
|
10
|
+
resolveRenderer,
|
|
11
|
+
}: {
|
|
12
|
+
children: UniformComponentProps<TRenderProps>['children'];
|
|
13
|
+
data: Required<UniformComponentProps<TRenderProps>>['data'];
|
|
14
|
+
context: CompositionContext;
|
|
15
|
+
hasParentLayout: boolean;
|
|
16
|
+
resolveRenderer: RenderComponentResolver;
|
|
17
|
+
}): ReactNode;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createElement } from 'react';
|
|
3
|
+
import { convertComponentToProps } from '../components/convertComponentToProps';
|
|
4
|
+
import { UniformSlot } from '../components/UniformSlot';
|
|
5
|
+
export function resolveChildren({ children, data, context, hasParentLayout, resolveRenderer, }) {
|
|
6
|
+
// attempt to resolve the top level component if we're at the root and children were not provided
|
|
7
|
+
if (!children && !hasParentLayout) {
|
|
8
|
+
const topLevelComponent = resolveRenderer({ type: data.type });
|
|
9
|
+
if (topLevelComponent) {
|
|
10
|
+
children = createElement(topLevelComponent, convertComponentToProps({ component: data, context }));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
children = Object.keys(data.slots || {}).map((slotName) => (_jsx(UniformSlot, { name: slotName, data: data, context: context }, slotName)));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const renderChildren = typeof children === 'function'
|
|
17
|
+
? children(convertComponentToProps({ component: data, context }))
|
|
18
|
+
: children;
|
|
19
|
+
return renderChildren;
|
|
20
|
+
}
|