@uniformdev/canvas-next-rsc 19.173.1-alpha.17 → 19.173.2-alpha.258
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 +94 -37
- package/dist/component.mjs +93 -35
- 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/config.js +11 -17
- package/dist/config.mjs +11 -14
- 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 +14 -10
- package/dist/handler.mjs +3 -16
- 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 +57 -37
- package/dist/index.js +85 -62
- package/dist/index.mjs +57 -37
- 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 +21 -21
package/dist/index.js
CHANGED
|
@@ -60,6 +60,9 @@ var import_server_only = require("server-only");
|
|
|
60
60
|
// src/clients/canvasClient.ts
|
|
61
61
|
var import_canvas2 = require("@uniformdev/canvas");
|
|
62
62
|
|
|
63
|
+
// src/config/helpers.ts
|
|
64
|
+
var import_uniform_server = __toESM(require("uniform.server.config"));
|
|
65
|
+
|
|
63
66
|
// src/utils/draft.ts
|
|
64
67
|
var import_canvas = require("@uniformdev/canvas");
|
|
65
68
|
var import_headers = require("next/headers");
|
|
@@ -91,15 +94,7 @@ var isDevelopmentEnvironment = () => {
|
|
|
91
94
|
|
|
92
95
|
// src/config/helpers.ts
|
|
93
96
|
var getServerConfig = () => {
|
|
94
|
-
|
|
95
|
-
try {
|
|
96
|
-
serverConfig = require("uniform.server.config.js");
|
|
97
|
-
} catch (e) {
|
|
98
|
-
serverConfig = {
|
|
99
|
-
defaultConsent: false
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
return serverConfig;
|
|
97
|
+
return import_uniform_server.default;
|
|
103
98
|
};
|
|
104
99
|
var shouldCacheBeDisabled = (options) => {
|
|
105
100
|
if (isDraftModeEnabled(options)) {
|
|
@@ -258,7 +253,8 @@ var getCanvasClient = (options) => {
|
|
|
258
253
|
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
259
254
|
},
|
|
260
255
|
next: {
|
|
261
|
-
revalidate
|
|
256
|
+
revalidate,
|
|
257
|
+
tags: tags.length ? tags : void 0
|
|
262
258
|
}
|
|
263
259
|
});
|
|
264
260
|
}
|
|
@@ -416,7 +412,7 @@ var ContextUpdateTransfer = async ({
|
|
|
416
412
|
return null;
|
|
417
413
|
}
|
|
418
414
|
if (serverContext) {
|
|
419
|
-
await serverContext.
|
|
415
|
+
await serverContext.internal_update(result);
|
|
420
416
|
}
|
|
421
417
|
return /* @__PURE__ */ import_react.default.createElement(import_canvas_next_rsc_client.ContextUpdateTransferClient, { ts: (/* @__PURE__ */ new Date()).valueOf(), update: result });
|
|
422
418
|
};
|
|
@@ -455,13 +451,13 @@ async function generateStaticParams() {
|
|
|
455
451
|
}
|
|
456
452
|
|
|
457
453
|
// src/components/UniformComposition.ts
|
|
458
|
-
var
|
|
459
|
-
var
|
|
454
|
+
var import_canvas8 = require("@uniformdev/canvas");
|
|
455
|
+
var import_canvas_next_rsc_client7 = require("@uniformdev/canvas-next-rsc-client");
|
|
460
456
|
var import_canvas_next_rsc_shared6 = require("@uniformdev/canvas-next-rsc-shared");
|
|
461
457
|
var import_core = require("@uniformdev/canvas-react/core");
|
|
462
458
|
var import_headers3 = require("next/headers");
|
|
463
459
|
var import_navigation = require("next/navigation");
|
|
464
|
-
var
|
|
460
|
+
var import_react9 = require("react");
|
|
465
461
|
|
|
466
462
|
// src/context/createServerUniformContext.ts
|
|
467
463
|
var import_canvas_next_rsc_shared = require("@uniformdev/canvas-next-rsc-shared");
|
|
@@ -481,12 +477,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
481
477
|
...options || {},
|
|
482
478
|
serverCookieValue: (_a = (0, import_headers2.cookies)().get(import_context.UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
483
479
|
});
|
|
484
|
-
return
|
|
485
|
-
...context,
|
|
486
|
-
__INTERNAL__: {
|
|
487
|
-
update: (...props) => context.update(...props)
|
|
488
|
-
}
|
|
489
|
-
};
|
|
480
|
+
return context;
|
|
490
481
|
};
|
|
491
482
|
|
|
492
483
|
// src/utils/route.ts
|
|
@@ -715,6 +706,23 @@ var TestServer = async (props) => {
|
|
|
715
706
|
return (0, import_react7.createElement)(import_react7.Fragment, void 0, [component, eventElement]);
|
|
716
707
|
};
|
|
717
708
|
|
|
709
|
+
// src/components/VisibilityRulesWrapper.tsx
|
|
710
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
711
|
+
var import_canvas_next_rsc_client6 = require("@uniformdev/canvas-next-rsc-client");
|
|
712
|
+
var import_react8 = __toESM(require("react"));
|
|
713
|
+
var VisibilityRulesWrapper = (props) => {
|
|
714
|
+
const { context, ...rest } = props;
|
|
715
|
+
let isVisible = null;
|
|
716
|
+
if (context) {
|
|
717
|
+
const rules = (0, import_canvas7.createQuirksVisibilityRule)(context.quirks);
|
|
718
|
+
isVisible = (0, import_canvas7.evaluateNodeVisibilityParameter)({
|
|
719
|
+
rules,
|
|
720
|
+
parameter: props.parameter
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_canvas_next_rsc_client6.VisibilityRulesWrapperClient, { ...rest, initialIsVisible: isVisible });
|
|
724
|
+
};
|
|
725
|
+
|
|
718
726
|
// src/components/UniformComposition.ts
|
|
719
727
|
var UniformComposition = async ({
|
|
720
728
|
resolveComponent,
|
|
@@ -740,8 +748,8 @@ var UniformComposition = async ({
|
|
|
740
748
|
(0, import_navigation.redirect)(href);
|
|
741
749
|
}
|
|
742
750
|
const state = route.compositionApiResponse.state;
|
|
743
|
-
if (state ===
|
|
744
|
-
(0,
|
|
751
|
+
if (state === import_canvas8.CANVAS_DRAFT_STATE || state === import_canvas8.CANVAS_EDITOR_STATE) {
|
|
752
|
+
(0, import_canvas8.walkNodeTree)(route.compositionApiResponse.composition, (node) => {
|
|
745
753
|
if (node.type === "component" && node.node.parameters) {
|
|
746
754
|
Object.keys(node.node.parameters).forEach((key) => {
|
|
747
755
|
const parameter = node.node.parameters[key];
|
|
@@ -777,15 +785,18 @@ var UniformComposition = async ({
|
|
|
777
785
|
if (props.mode === "server") {
|
|
778
786
|
const headersValue = (0, import_headers3.headers)();
|
|
779
787
|
const missingQuirkValue = "unknown";
|
|
780
|
-
transfer = (0,
|
|
788
|
+
transfer = (0, import_react9.createElement)(ContextUpdateTransfer, {
|
|
781
789
|
serverContext,
|
|
782
790
|
update: {
|
|
783
791
|
params: props.params,
|
|
784
792
|
searchParams,
|
|
785
|
-
cookies: (0, import_headers3.cookies)().getAll().reduce(
|
|
786
|
-
acc
|
|
787
|
-
|
|
788
|
-
|
|
793
|
+
cookies: (0, import_headers3.cookies)().getAll().reduce(
|
|
794
|
+
(acc, cookie) => {
|
|
795
|
+
acc[cookie.name] = cookie.value;
|
|
796
|
+
return acc;
|
|
797
|
+
},
|
|
798
|
+
{}
|
|
799
|
+
),
|
|
789
800
|
quirks: {
|
|
790
801
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
791
802
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
|
@@ -794,21 +805,21 @@ var UniformComposition = async ({
|
|
|
794
805
|
}
|
|
795
806
|
});
|
|
796
807
|
} else if (props.mode === "static") {
|
|
797
|
-
transfer = (0,
|
|
808
|
+
transfer = (0, import_react9.createElement)(ContextUpdateTrigger, {
|
|
798
809
|
path
|
|
799
810
|
});
|
|
800
811
|
}
|
|
801
|
-
return (0,
|
|
812
|
+
return (0, import_react9.createElement)(import_react9.Fragment, void 0, transfer, resolved);
|
|
802
813
|
};
|
|
803
814
|
var isServerComponent = ({
|
|
804
815
|
component,
|
|
805
816
|
serverContext
|
|
806
817
|
}) => {
|
|
807
818
|
var _a, _b;
|
|
808
|
-
if (component.type ===
|
|
819
|
+
if (component.type === import_canvas8.CANVAS_PERSONALIZE_TYPE) {
|
|
809
820
|
return serverContext && ((_a = getServerConfig().evaluation) == null ? void 0 : _a.personalization) !== "client";
|
|
810
821
|
}
|
|
811
|
-
if (component.type ===
|
|
822
|
+
if (component.type === import_canvas8.CANVAS_TEST_TYPE) {
|
|
812
823
|
return serverContext && ((_b = getServerConfig().evaluation) == null ? void 0 : _b.testing) !== "client";
|
|
813
824
|
}
|
|
814
825
|
};
|
|
@@ -820,12 +831,12 @@ var resolveSystemComponent = ({
|
|
|
820
831
|
const config = getServerConfig();
|
|
821
832
|
let resolved = null;
|
|
822
833
|
let suspense = void 0;
|
|
823
|
-
if (component.type ===
|
|
834
|
+
if (component.type === import_canvas8.CANVAS_PERSONALIZE_TYPE) {
|
|
824
835
|
resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
825
836
|
suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
|
|
826
837
|
}
|
|
827
|
-
if (component.type ===
|
|
828
|
-
resolved = server ? TestServer :
|
|
838
|
+
if (component.type === import_canvas8.CANVAS_TEST_TYPE) {
|
|
839
|
+
resolved = server ? TestServer : import_canvas_next_rsc_client7.TestClient;
|
|
829
840
|
suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
|
|
830
841
|
}
|
|
831
842
|
return {
|
|
@@ -903,7 +914,7 @@ var resolveComponents = ({
|
|
|
903
914
|
parent = target.parent;
|
|
904
915
|
}
|
|
905
916
|
const resolved = components.map((component, componentIndex) => {
|
|
906
|
-
var _a, _b;
|
|
917
|
+
var _a, _b, _c;
|
|
907
918
|
const isServer = isServerComponent({
|
|
908
919
|
component,
|
|
909
920
|
serverContext
|
|
@@ -933,7 +944,8 @@ var resolveComponents = ({
|
|
|
933
944
|
const resolvedComponent = systemComponent || regularComponent;
|
|
934
945
|
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
935
946
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
936
|
-
const enrichmentTags = (_b = parameters[
|
|
947
|
+
const enrichmentTags = (_b = parameters[import_canvas8.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
948
|
+
const visibilityRules = (_c = parameters[import_canvas8.CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _c.value;
|
|
937
949
|
const key = `${slotName}-${componentIndex}-component`;
|
|
938
950
|
const componentProps = {
|
|
939
951
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
@@ -949,20 +961,20 @@ var resolveComponents = ({
|
|
|
949
961
|
};
|
|
950
962
|
let element = null;
|
|
951
963
|
if (wrapInSuspense) {
|
|
952
|
-
element = (0,
|
|
953
|
-
|
|
964
|
+
element = (0, import_react9.createElement)(
|
|
965
|
+
import_react9.Suspense,
|
|
954
966
|
{
|
|
955
967
|
key,
|
|
956
|
-
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0,
|
|
968
|
+
fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0, import_react9.createElement)(wrapInSuspense.fallback)
|
|
957
969
|
},
|
|
958
|
-
(0,
|
|
970
|
+
(0, import_react9.createElement)(resolvedComponent, componentProps)
|
|
959
971
|
);
|
|
960
972
|
} else {
|
|
961
|
-
element = (0,
|
|
973
|
+
element = (0, import_react9.createElement)(resolvedComponent, { ...componentProps, key });
|
|
962
974
|
}
|
|
963
975
|
let tagElement = null;
|
|
964
976
|
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
965
|
-
tagElement = (0,
|
|
977
|
+
tagElement = (0, import_react9.createElement)(ContextUpdateTransfer, {
|
|
966
978
|
key: `${slotName}-${componentIndex}-tags`,
|
|
967
979
|
update: {
|
|
968
980
|
enrichments: enrichmentTags
|
|
@@ -976,8 +988,8 @@ var resolveComponents = ({
|
|
|
976
988
|
if (tagElement) {
|
|
977
989
|
elements.push(tagElement);
|
|
978
990
|
}
|
|
979
|
-
const isPlaceholder = (0,
|
|
980
|
-
childNode = (0,
|
|
991
|
+
const isPlaceholder = (0, import_canvas8.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
992
|
+
childNode = (0, import_react9.createElement)(
|
|
981
993
|
import_core.PureContextualEditingComponentWrapper,
|
|
982
994
|
{
|
|
983
995
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
@@ -996,8 +1008,8 @@ var resolveComponents = ({
|
|
|
996
1008
|
if (tagElement) {
|
|
997
1009
|
elements.push(tagElement);
|
|
998
1010
|
}
|
|
999
|
-
childNode = (0,
|
|
1000
|
-
|
|
1011
|
+
childNode = (0, import_react9.createElement)(
|
|
1012
|
+
import_canvas_next_rsc_client7.ClientContextualEditingComponentWrapper,
|
|
1001
1013
|
{
|
|
1002
1014
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
1003
1015
|
isPlaceholder: false,
|
|
@@ -1017,8 +1029,19 @@ var resolveComponents = ({
|
|
|
1017
1029
|
}
|
|
1018
1030
|
childNode = elements;
|
|
1019
1031
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1032
|
+
if (visibilityRules) {
|
|
1033
|
+
childNode = (0, import_react9.createElement)(
|
|
1034
|
+
VisibilityRulesWrapper,
|
|
1035
|
+
{
|
|
1036
|
+
key: `${slotName}-${componentIndex}-visibility`,
|
|
1037
|
+
parameter: visibilityRules,
|
|
1038
|
+
context: serverContext
|
|
1039
|
+
},
|
|
1040
|
+
childNode
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
return (0, import_react9.createElement)(
|
|
1044
|
+
import_react9.Fragment,
|
|
1022
1045
|
{
|
|
1023
1046
|
key: !isRoot ? `${slotName}-${componentIndex}` : void 0
|
|
1024
1047
|
},
|
|
@@ -1029,9 +1052,9 @@ var resolveComponents = ({
|
|
|
1029
1052
|
};
|
|
1030
1053
|
|
|
1031
1054
|
// src/components/UniformContext.tsx
|
|
1032
|
-
var
|
|
1033
|
-
var
|
|
1034
|
-
var
|
|
1055
|
+
var import_canvas_next_rsc_client8 = require("@uniformdev/canvas-next-rsc-client");
|
|
1056
|
+
var import_react10 = require("react");
|
|
1057
|
+
var import_react11 = __toESM(require("react"));
|
|
1035
1058
|
var UniformContext = async ({
|
|
1036
1059
|
clientContextComponent,
|
|
1037
1060
|
children
|
|
@@ -1040,27 +1063,27 @@ var UniformContext = async ({
|
|
|
1040
1063
|
const manifest = await getManifest({
|
|
1041
1064
|
searchParams: {}
|
|
1042
1065
|
});
|
|
1043
|
-
const ContextComponent = clientContextComponent ||
|
|
1044
|
-
const
|
|
1045
|
-
const disableDevTools = ((_a =
|
|
1046
|
-
const defaultConsent =
|
|
1047
|
-
return /* @__PURE__ */
|
|
1066
|
+
const ContextComponent = clientContextComponent || import_canvas_next_rsc_client8.DefaultUniformClientContext;
|
|
1067
|
+
const serverConfig2 = getServerConfig();
|
|
1068
|
+
const disableDevTools = ((_a = serverConfig2.context) == null ? void 0 : _a.disableDevTools) || false;
|
|
1069
|
+
const defaultConsent = serverConfig2.defaultConsent || false;
|
|
1070
|
+
return /* @__PURE__ */ import_react11.default.createElement(import_react11.default.Fragment, null, children, /* @__PURE__ */ import_react11.default.createElement(
|
|
1048
1071
|
ContextComponent,
|
|
1049
1072
|
{
|
|
1050
1073
|
manifest,
|
|
1051
1074
|
disableDevTools,
|
|
1052
1075
|
defaultConsent
|
|
1053
1076
|
}
|
|
1054
|
-
), /* @__PURE__ */
|
|
1077
|
+
), /* @__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
1078
|
};
|
|
1056
1079
|
|
|
1057
1080
|
// src/components/UniformPlayground.tsx
|
|
1058
|
-
var
|
|
1081
|
+
var import_canvas9 = require("@uniformdev/canvas");
|
|
1059
1082
|
var import_navigation2 = require("next/navigation");
|
|
1060
|
-
var
|
|
1083
|
+
var import_react12 = __toESM(require("react"));
|
|
1061
1084
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1062
1085
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
1063
|
-
return /* @__PURE__ */
|
|
1086
|
+
return /* @__PURE__ */ import_react12.default.createElement("div", null, /* @__PURE__ */ import_react12.default.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1064
1087
|
}
|
|
1065
1088
|
const id = searchParams["id"];
|
|
1066
1089
|
if (!id) {
|
|
@@ -1071,7 +1094,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1071
1094
|
type: "no-cache"
|
|
1072
1095
|
}
|
|
1073
1096
|
});
|
|
1074
|
-
const possibleStates = [
|
|
1097
|
+
const possibleStates = [import_canvas9.CANVAS_EDITOR_STATE, import_canvas9.CANVAS_DRAFT_STATE];
|
|
1075
1098
|
let composition = void 0;
|
|
1076
1099
|
for (let i = 0; i < possibleStates.length; i++) {
|
|
1077
1100
|
const state = possibleStates[i];
|
|
@@ -1091,7 +1114,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1091
1114
|
if (!composition) {
|
|
1092
1115
|
(0, import_navigation2.notFound)();
|
|
1093
1116
|
}
|
|
1094
|
-
return /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
1095
1118
|
UniformComposition,
|
|
1096
1119
|
{
|
|
1097
1120
|
mode: "server",
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/index.ts
|
|
9
2
|
import "server-only";
|
|
10
3
|
|
|
11
4
|
// src/clients/canvasClient.ts
|
|
12
5
|
import { CanvasClient } from "@uniformdev/canvas";
|
|
13
6
|
|
|
7
|
+
// src/config/helpers.ts
|
|
8
|
+
import serverConfig from "uniform.server.config";
|
|
9
|
+
|
|
14
10
|
// src/utils/draft.ts
|
|
15
11
|
import { IN_CONTEXT_EDITOR_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
16
12
|
import { draftMode } from "next/headers";
|
|
@@ -42,14 +38,6 @@ var isDevelopmentEnvironment = () => {
|
|
|
42
38
|
|
|
43
39
|
// src/config/helpers.ts
|
|
44
40
|
var getServerConfig = () => {
|
|
45
|
-
let serverConfig;
|
|
46
|
-
try {
|
|
47
|
-
serverConfig = __require("uniform.server.config.js");
|
|
48
|
-
} catch (e) {
|
|
49
|
-
serverConfig = {
|
|
50
|
-
defaultConsent: false
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
41
|
return serverConfig;
|
|
54
42
|
};
|
|
55
43
|
var shouldCacheBeDisabled = (options) => {
|
|
@@ -209,7 +197,8 @@ var getCanvasClient = (options) => {
|
|
|
209
197
|
"x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
|
|
210
198
|
},
|
|
211
199
|
next: {
|
|
212
|
-
revalidate
|
|
200
|
+
revalidate,
|
|
201
|
+
tags: tags.length ? tags : void 0
|
|
213
202
|
}
|
|
214
203
|
});
|
|
215
204
|
}
|
|
@@ -367,7 +356,7 @@ var ContextUpdateTransfer = async ({
|
|
|
367
356
|
return null;
|
|
368
357
|
}
|
|
369
358
|
if (serverContext) {
|
|
370
|
-
await serverContext.
|
|
359
|
+
await serverContext.internal_update(result);
|
|
371
360
|
}
|
|
372
361
|
return /* @__PURE__ */ React.createElement(ContextUpdateTransferClient, { ts: (/* @__PURE__ */ new Date()).valueOf(), update: result });
|
|
373
362
|
};
|
|
@@ -412,6 +401,7 @@ import {
|
|
|
412
401
|
CANVAS_ENRICHMENT_TAG_PARAM,
|
|
413
402
|
CANVAS_PERSONALIZE_TYPE,
|
|
414
403
|
CANVAS_TEST_TYPE,
|
|
404
|
+
CANVAS_VIZ_CONTROL_PARAM,
|
|
415
405
|
isComponentPlaceholderId,
|
|
416
406
|
walkNodeTree
|
|
417
407
|
} from "@uniformdev/canvas";
|
|
@@ -444,12 +434,7 @@ var createServerUniformContextFromManifest = async (options) => {
|
|
|
444
434
|
...options || {},
|
|
445
435
|
serverCookieValue: (_a = cookies().get(UNIFORM_DEFAULT_COOKIE_NAME)) == null ? void 0 : _a.value
|
|
446
436
|
});
|
|
447
|
-
return
|
|
448
|
-
...context,
|
|
449
|
-
__INTERNAL__: {
|
|
450
|
-
update: (...props) => context.update(...props)
|
|
451
|
-
}
|
|
452
|
-
};
|
|
437
|
+
return context;
|
|
453
438
|
};
|
|
454
439
|
|
|
455
440
|
// src/utils/route.ts
|
|
@@ -684,6 +669,26 @@ var TestServer = async (props) => {
|
|
|
684
669
|
return createElement2(Fragment2, void 0, [component, eventElement]);
|
|
685
670
|
};
|
|
686
671
|
|
|
672
|
+
// src/components/VisibilityRulesWrapper.tsx
|
|
673
|
+
import {
|
|
674
|
+
createQuirksVisibilityRule,
|
|
675
|
+
evaluateNodeVisibilityParameter
|
|
676
|
+
} from "@uniformdev/canvas";
|
|
677
|
+
import { VisibilityRulesWrapperClient } from "@uniformdev/canvas-next-rsc-client";
|
|
678
|
+
import React6 from "react";
|
|
679
|
+
var VisibilityRulesWrapper = (props) => {
|
|
680
|
+
const { context, ...rest } = props;
|
|
681
|
+
let isVisible = null;
|
|
682
|
+
if (context) {
|
|
683
|
+
const rules = createQuirksVisibilityRule(context.quirks);
|
|
684
|
+
isVisible = evaluateNodeVisibilityParameter({
|
|
685
|
+
rules,
|
|
686
|
+
parameter: props.parameter
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
return /* @__PURE__ */ React6.createElement(VisibilityRulesWrapperClient, { ...rest, initialIsVisible: isVisible });
|
|
690
|
+
};
|
|
691
|
+
|
|
687
692
|
// src/components/UniformComposition.ts
|
|
688
693
|
var UniformComposition = async ({
|
|
689
694
|
resolveComponent,
|
|
@@ -751,10 +756,13 @@ var UniformComposition = async ({
|
|
|
751
756
|
update: {
|
|
752
757
|
params: props.params,
|
|
753
758
|
searchParams,
|
|
754
|
-
cookies: cookies2().getAll().reduce(
|
|
755
|
-
acc
|
|
756
|
-
|
|
757
|
-
|
|
759
|
+
cookies: cookies2().getAll().reduce(
|
|
760
|
+
(acc, cookie) => {
|
|
761
|
+
acc[cookie.name] = cookie.value;
|
|
762
|
+
return acc;
|
|
763
|
+
},
|
|
764
|
+
{}
|
|
765
|
+
),
|
|
758
766
|
quirks: {
|
|
759
767
|
"vc-country": headersValue.get("x-vercel-ip-country") || missingQuirkValue,
|
|
760
768
|
"vc-region": headersValue.get("x-vercel-ip-country-region") || missingQuirkValue,
|
|
@@ -872,7 +880,7 @@ var resolveComponents = ({
|
|
|
872
880
|
parent = target.parent;
|
|
873
881
|
}
|
|
874
882
|
const resolved = components.map((component, componentIndex) => {
|
|
875
|
-
var _a, _b;
|
|
883
|
+
var _a, _b, _c;
|
|
876
884
|
const isServer = isServerComponent({
|
|
877
885
|
component,
|
|
878
886
|
serverContext
|
|
@@ -903,6 +911,7 @@ var resolveComponents = ({
|
|
|
903
911
|
const wrapInSuspense = systemSuspense || componentSuspense;
|
|
904
912
|
const parameters = (_a = component.parameters) != null ? _a : {};
|
|
905
913
|
const enrichmentTags = (_b = parameters[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
|
|
914
|
+
const visibilityRules = (_c = parameters[CANVAS_VIZ_CONTROL_PARAM]) == null ? void 0 : _c.value;
|
|
906
915
|
const key = `${slotName}-${componentIndex}-component`;
|
|
907
916
|
const componentProps = {
|
|
908
917
|
...Object.keys(parameters).reduce((acc, cur) => {
|
|
@@ -986,6 +995,17 @@ var resolveComponents = ({
|
|
|
986
995
|
}
|
|
987
996
|
childNode = elements;
|
|
988
997
|
}
|
|
998
|
+
if (visibilityRules) {
|
|
999
|
+
childNode = createElement3(
|
|
1000
|
+
VisibilityRulesWrapper,
|
|
1001
|
+
{
|
|
1002
|
+
key: `${slotName}-${componentIndex}-visibility`,
|
|
1003
|
+
parameter: visibilityRules,
|
|
1004
|
+
context: serverContext
|
|
1005
|
+
},
|
|
1006
|
+
childNode
|
|
1007
|
+
);
|
|
1008
|
+
}
|
|
989
1009
|
return createElement3(
|
|
990
1010
|
Fragment3,
|
|
991
1011
|
{
|
|
@@ -1003,7 +1023,7 @@ import {
|
|
|
1003
1023
|
UniformScript
|
|
1004
1024
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
1005
1025
|
import { Suspense as Suspense2 } from "react";
|
|
1006
|
-
import
|
|
1026
|
+
import React7 from "react";
|
|
1007
1027
|
var UniformContext = async ({
|
|
1008
1028
|
clientContextComponent,
|
|
1009
1029
|
children
|
|
@@ -1013,26 +1033,26 @@ var UniformContext = async ({
|
|
|
1013
1033
|
searchParams: {}
|
|
1014
1034
|
});
|
|
1015
1035
|
const ContextComponent = clientContextComponent || DefaultUniformClientContext;
|
|
1016
|
-
const
|
|
1017
|
-
const disableDevTools = ((_a =
|
|
1018
|
-
const defaultConsent =
|
|
1019
|
-
return /* @__PURE__ */
|
|
1036
|
+
const serverConfig2 = getServerConfig();
|
|
1037
|
+
const disableDevTools = ((_a = serverConfig2.context) == null ? void 0 : _a.disableDevTools) || false;
|
|
1038
|
+
const defaultConsent = serverConfig2.defaultConsent || false;
|
|
1039
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, children, /* @__PURE__ */ React7.createElement(
|
|
1020
1040
|
ContextComponent,
|
|
1021
1041
|
{
|
|
1022
1042
|
manifest,
|
|
1023
1043
|
disableDevTools,
|
|
1024
1044
|
defaultConsent
|
|
1025
1045
|
}
|
|
1026
|
-
), /* @__PURE__ */
|
|
1046
|
+
), /* @__PURE__ */ React7.createElement(Suspense2, { fallback: /* @__PURE__ */ React7.createElement(React7.Fragment, null) }, /* @__PURE__ */ React7.createElement(UniformScript, null)));
|
|
1027
1047
|
};
|
|
1028
1048
|
|
|
1029
1049
|
// src/components/UniformPlayground.tsx
|
|
1030
1050
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
1031
1051
|
import { notFound as notFound2 } from "next/navigation";
|
|
1032
|
-
import
|
|
1052
|
+
import React8 from "react";
|
|
1033
1053
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
1034
1054
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
1035
|
-
return /* @__PURE__ */
|
|
1055
|
+
return /* @__PURE__ */ React8.createElement("div", null, /* @__PURE__ */ React8.createElement("h1", null, "Playground is only available in draft mode"));
|
|
1036
1056
|
}
|
|
1037
1057
|
const id = searchParams["id"];
|
|
1038
1058
|
if (!id) {
|
|
@@ -1063,7 +1083,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
1063
1083
|
if (!composition) {
|
|
1064
1084
|
notFound2();
|
|
1065
1085
|
}
|
|
1066
|
-
return /* @__PURE__ */
|
|
1086
|
+
return /* @__PURE__ */ React8.createElement(
|
|
1067
1087
|
UniformComposition,
|
|
1068
1088
|
{
|
|
1069
1089
|
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;
|