@uniformdev/canvas-next-rsc 19.92.3 → 19.95.0
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/handler.d.mts +1 -1
- package/dist/handler.d.ts +1 -1
- package/dist/handler.js +27 -1
- package/dist/handler.mjs +27 -1
- package/dist/index.esm.js +44 -25
- package/dist/index.js +65 -48
- package/dist/index.mjs +44 -25
- package/package.json +11 -11
package/dist/handler.d.mts
CHANGED
|
@@ -7,6 +7,6 @@ declare const createPreviewGETRouteHandler: (options?: CreatePreviewGETRouteHand
|
|
|
7
7
|
|
|
8
8
|
declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
9
9
|
|
|
10
|
-
declare const createPreviewPOSTRouteHandler: () => (request:
|
|
10
|
+
declare const createPreviewPOSTRouteHandler: () => (request: NextRequest) => Promise<Response>;
|
|
11
11
|
|
|
12
12
|
export { type CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
package/dist/handler.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ declare const createPreviewGETRouteHandler: (options?: CreatePreviewGETRouteHand
|
|
|
7
7
|
|
|
8
8
|
declare const createPreviewOPTIONSRouteHandler: () => () => Promise<Response>;
|
|
9
9
|
|
|
10
|
-
declare const createPreviewPOSTRouteHandler: () => (request:
|
|
10
|
+
declare const createPreviewPOSTRouteHandler: () => (request: NextRequest) => Promise<Response>;
|
|
11
11
|
|
|
12
12
|
export { type CreatePreviewGETRouteHandlerOptions, createPreviewGETRouteHandler, createPreviewOPTIONSRouteHandler, createPreviewPOSTRouteHandler };
|
package/dist/handler.js
CHANGED
|
@@ -376,6 +376,7 @@ var createPreviewOPTIONSRouteHandler = () => {
|
|
|
376
376
|
};
|
|
377
377
|
|
|
378
378
|
// src/handler/createPreviewPOSTRouteHandler.ts
|
|
379
|
+
var import_canvas7 = require("@uniformdev/canvas");
|
|
379
380
|
var import_cache = require("next/cache");
|
|
380
381
|
|
|
381
382
|
// src/handler/helpers.ts
|
|
@@ -734,6 +735,25 @@ var handleRedirectUpdate = async (body) => {
|
|
|
734
735
|
// src/handler/createPreviewPOSTRouteHandler.ts
|
|
735
736
|
var createPreviewPOSTRouteHandler = () => {
|
|
736
737
|
return async (request) => {
|
|
738
|
+
let previewSecretPassed = false;
|
|
739
|
+
if (process.env.UNIFORM_PREVIEW_SECRET) {
|
|
740
|
+
const secretValue = request.nextUrl.searchParams.get(import_canvas7.SECRET_QUERY_STRING_PARAM);
|
|
741
|
+
if (secretValue !== process.env.UNIFORM_PREVIEW_SECRET) {
|
|
742
|
+
console.warn(
|
|
743
|
+
"The preview secret passed in the query string does not match the UNIFORM_PREVIEW_SECRET env var."
|
|
744
|
+
);
|
|
745
|
+
} else {
|
|
746
|
+
previewSecretPassed = true;
|
|
747
|
+
}
|
|
748
|
+
} else {
|
|
749
|
+
if (!process.env.UNIFORM_WEBHOOK_SECRET) {
|
|
750
|
+
console.warn("Both UNIFORM_PREVIEW_SECRET and UNIFORM_WEBHOOK_SECRET are not set.");
|
|
751
|
+
}
|
|
752
|
+
previewSecretPassed = true;
|
|
753
|
+
}
|
|
754
|
+
if (!previewSecretPassed) {
|
|
755
|
+
return new Response("The request could not be validated.", { status: 401 });
|
|
756
|
+
}
|
|
737
757
|
const { looksLikeMessage, validation } = await isSvixMessage(request);
|
|
738
758
|
if (looksLikeMessage) {
|
|
739
759
|
if (!validation) {
|
|
@@ -758,7 +778,13 @@ var handleSvixMessage = async (request) => {
|
|
|
758
778
|
handleManifestPublished
|
|
759
779
|
];
|
|
760
780
|
let tags = void 0;
|
|
761
|
-
|
|
781
|
+
let jsonBody;
|
|
782
|
+
try {
|
|
783
|
+
jsonBody = await request.json();
|
|
784
|
+
} catch (err) {
|
|
785
|
+
console.error("Error parsing the request body as JSON.", err);
|
|
786
|
+
return new Response("Error parsing the request body as JSON.", { status: 400 });
|
|
787
|
+
}
|
|
762
788
|
for (let i = 0; i < handlers.length; i++) {
|
|
763
789
|
const handler = handlers[i];
|
|
764
790
|
const result = await handler(jsonBody);
|
package/dist/handler.mjs
CHANGED
|
@@ -356,6 +356,7 @@ var createPreviewOPTIONSRouteHandler = () => {
|
|
|
356
356
|
};
|
|
357
357
|
|
|
358
358
|
// src/handler/createPreviewPOSTRouteHandler.ts
|
|
359
|
+
import { SECRET_QUERY_STRING_PARAM } from "@uniformdev/canvas";
|
|
359
360
|
import { revalidateTag } from "next/cache";
|
|
360
361
|
|
|
361
362
|
// src/handler/helpers.ts
|
|
@@ -714,6 +715,25 @@ var handleRedirectUpdate = async (body) => {
|
|
|
714
715
|
// src/handler/createPreviewPOSTRouteHandler.ts
|
|
715
716
|
var createPreviewPOSTRouteHandler = () => {
|
|
716
717
|
return async (request) => {
|
|
718
|
+
let previewSecretPassed = false;
|
|
719
|
+
if (process.env.UNIFORM_PREVIEW_SECRET) {
|
|
720
|
+
const secretValue = request.nextUrl.searchParams.get(SECRET_QUERY_STRING_PARAM);
|
|
721
|
+
if (secretValue !== process.env.UNIFORM_PREVIEW_SECRET) {
|
|
722
|
+
console.warn(
|
|
723
|
+
"The preview secret passed in the query string does not match the UNIFORM_PREVIEW_SECRET env var."
|
|
724
|
+
);
|
|
725
|
+
} else {
|
|
726
|
+
previewSecretPassed = true;
|
|
727
|
+
}
|
|
728
|
+
} else {
|
|
729
|
+
if (!process.env.UNIFORM_WEBHOOK_SECRET) {
|
|
730
|
+
console.warn("Both UNIFORM_PREVIEW_SECRET and UNIFORM_WEBHOOK_SECRET are not set.");
|
|
731
|
+
}
|
|
732
|
+
previewSecretPassed = true;
|
|
733
|
+
}
|
|
734
|
+
if (!previewSecretPassed) {
|
|
735
|
+
return new Response("The request could not be validated.", { status: 401 });
|
|
736
|
+
}
|
|
717
737
|
const { looksLikeMessage, validation } = await isSvixMessage(request);
|
|
718
738
|
if (looksLikeMessage) {
|
|
719
739
|
if (!validation) {
|
|
@@ -738,7 +758,13 @@ var handleSvixMessage = async (request) => {
|
|
|
738
758
|
handleManifestPublished
|
|
739
759
|
];
|
|
740
760
|
let tags = void 0;
|
|
741
|
-
|
|
761
|
+
let jsonBody;
|
|
762
|
+
try {
|
|
763
|
+
jsonBody = await request.json();
|
|
764
|
+
} catch (err) {
|
|
765
|
+
console.error("Error parsing the request body as JSON.", err);
|
|
766
|
+
return new Response("Error parsing the request body as JSON.", { status: 400 });
|
|
767
|
+
}
|
|
742
768
|
for (let i = 0; i < handlers.length; i++) {
|
|
743
769
|
const handler = handlers[i];
|
|
744
770
|
const result = await handler(jsonBody);
|
package/dist/index.esm.js
CHANGED
|
@@ -571,38 +571,57 @@ var PersonalizeClientWrapper = (props) => {
|
|
|
571
571
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
572
572
|
import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
|
|
573
573
|
import { createElement, Fragment } from "react";
|
|
574
|
+
|
|
575
|
+
// src/components/ContextPersonalizationTransfer.tsx
|
|
576
|
+
import { ClientContextPersonalizationTransfer } from "@uniformdev/canvas-next-rsc-client";
|
|
577
|
+
import React4 from "react";
|
|
578
|
+
var ContextPersonalizationTransfer = ({ event }) => {
|
|
579
|
+
return /* @__PURE__ */ React4.createElement(ClientContextPersonalizationTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/components/PersonalizeServer.ts
|
|
574
583
|
var PersonalizeServer = (props) => {
|
|
575
584
|
var _a;
|
|
576
|
-
const { indexes } = runPersonalization2(props);
|
|
585
|
+
const { indexes, event } = runPersonalization2(props);
|
|
577
586
|
const slot = (_a = props.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT];
|
|
578
587
|
const components = indexes.map((index) => {
|
|
579
588
|
const component = slot.items[index];
|
|
580
589
|
return component;
|
|
581
590
|
});
|
|
582
|
-
|
|
591
|
+
const eventElement = createElement(ContextPersonalizationTransfer, {
|
|
592
|
+
event
|
|
593
|
+
});
|
|
594
|
+
return createElement(Fragment, void 0, [...components, eventElement]);
|
|
583
595
|
};
|
|
584
596
|
|
|
585
597
|
// src/components/TestServer.ts
|
|
586
|
-
import { CANVAS_TEST_SLOT
|
|
598
|
+
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
599
|
+
import {
|
|
600
|
+
runTest
|
|
601
|
+
} from "@uniformdev/canvas-next-rsc-shared";
|
|
587
602
|
import { createElement as createElement2, Fragment as Fragment2 } from "react";
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
})
|
|
603
|
+
|
|
604
|
+
// src/components/ContextTestTransfer.tsx
|
|
605
|
+
import { ClientContextTestTransfer } from "@uniformdev/canvas-next-rsc-client";
|
|
606
|
+
import React5 from "react";
|
|
607
|
+
var ContextTestTransfer = ({ event }) => {
|
|
608
|
+
return /* @__PURE__ */ React5.createElement(ClientContextTestTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// src/components/TestServer.ts
|
|
612
|
+
var TestServer = (props) => {
|
|
613
|
+
var _a, _b, _c, _d;
|
|
614
|
+
const { contextInstance, test } = props;
|
|
615
|
+
const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
616
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
617
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
618
|
+
}
|
|
619
|
+
const { index, event } = runTest(props);
|
|
620
|
+
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;
|
|
621
|
+
const eventElement = createElement2(ContextTestTransfer, {
|
|
622
|
+
event
|
|
603
623
|
});
|
|
604
|
-
|
|
605
|
-
return createElement2(Fragment2, void 0, components);
|
|
624
|
+
return createElement2(Fragment2, void 0, [component, eventElement]);
|
|
606
625
|
};
|
|
607
626
|
|
|
608
627
|
// src/components/UniformComposition.ts
|
|
@@ -901,7 +920,7 @@ import {
|
|
|
901
920
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
902
921
|
import { getServerConfig as getServerConfig4 } from "@uniformdev/canvas-next-rsc-shared";
|
|
903
922
|
import { Suspense } from "react";
|
|
904
|
-
import
|
|
923
|
+
import React6 from "react";
|
|
905
924
|
var UniformContext = async ({
|
|
906
925
|
clientContextComponent,
|
|
907
926
|
children
|
|
@@ -912,16 +931,16 @@ var UniformContext = async ({
|
|
|
912
931
|
});
|
|
913
932
|
const ContextComponent = clientContextComponent || DefaultUniformClientContext;
|
|
914
933
|
const disableDevTools = ((_a = getServerConfig4().context) == null ? void 0 : _a.disableDevTools) || false;
|
|
915
|
-
return /* @__PURE__ */
|
|
934
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, children, /* @__PURE__ */ React6.createElement(ContextComponent, { manifest, disableDevTools }), /* @__PURE__ */ React6.createElement(Suspense, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
|
|
916
935
|
};
|
|
917
936
|
|
|
918
937
|
// src/components/UniformPlayground.tsx
|
|
919
938
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
920
939
|
import { notFound as notFound2 } from "next/navigation";
|
|
921
|
-
import
|
|
940
|
+
import React7 from "react";
|
|
922
941
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
923
942
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
924
|
-
return /* @__PURE__ */
|
|
943
|
+
return /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h1", null, "Playground is only available in draft mode"));
|
|
925
944
|
}
|
|
926
945
|
const id = searchParams["id"];
|
|
927
946
|
if (!id) {
|
|
@@ -952,7 +971,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
952
971
|
if (!composition) {
|
|
953
972
|
notFound2();
|
|
954
973
|
}
|
|
955
|
-
return /* @__PURE__ */
|
|
974
|
+
return /* @__PURE__ */ React7.createElement(
|
|
956
975
|
UniformComposition,
|
|
957
976
|
{
|
|
958
977
|
mode: "server",
|
package/dist/index.js
CHANGED
|
@@ -444,12 +444,12 @@ async function generateStaticParams() {
|
|
|
444
444
|
|
|
445
445
|
// src/components/UniformComposition.ts
|
|
446
446
|
var import_canvas7 = require("@uniformdev/canvas");
|
|
447
|
-
var
|
|
448
|
-
var
|
|
447
|
+
var import_canvas_next_rsc_client6 = require("@uniformdev/canvas-next-rsc-client");
|
|
448
|
+
var import_canvas_next_rsc_shared7 = require("@uniformdev/canvas-next-rsc-shared");
|
|
449
449
|
var import_core = require("@uniformdev/canvas-react/core");
|
|
450
450
|
var import_headers3 = require("next/headers");
|
|
451
451
|
var import_navigation = require("next/navigation");
|
|
452
|
-
var
|
|
452
|
+
var import_react8 = require("react");
|
|
453
453
|
|
|
454
454
|
// src/context/createServerUniformContext.ts
|
|
455
455
|
var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
|
|
@@ -608,39 +608,56 @@ var PersonalizeClientWrapper = (props) => {
|
|
|
608
608
|
// src/components/PersonalizeServer.ts
|
|
609
609
|
var import_canvas5 = require("@uniformdev/canvas");
|
|
610
610
|
var import_canvas_next_rsc_shared5 = require("@uniformdev/canvas-next-rsc-shared");
|
|
611
|
-
var
|
|
611
|
+
var import_react5 = require("react");
|
|
612
|
+
|
|
613
|
+
// src/components/ContextPersonalizationTransfer.tsx
|
|
614
|
+
var import_canvas_next_rsc_client4 = require("@uniformdev/canvas-next-rsc-client");
|
|
615
|
+
var import_react4 = __toESM(require("react"));
|
|
616
|
+
var ContextPersonalizationTransfer = ({ event }) => {
|
|
617
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_canvas_next_rsc_client4.ClientContextPersonalizationTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
// src/components/PersonalizeServer.ts
|
|
612
621
|
var PersonalizeServer = (props) => {
|
|
613
622
|
var _a;
|
|
614
|
-
const { indexes } = (0, import_canvas_next_rsc_shared5.runPersonalization)(props);
|
|
623
|
+
const { indexes, event } = (0, import_canvas_next_rsc_shared5.runPersonalization)(props);
|
|
615
624
|
const slot = (_a = props.slots) == null ? void 0 : _a[import_canvas5.CANVAS_PERSONALIZE_SLOT];
|
|
616
625
|
const components = indexes.map((index) => {
|
|
617
626
|
const component = slot.items[index];
|
|
618
627
|
return component;
|
|
619
628
|
});
|
|
620
|
-
|
|
629
|
+
const eventElement = (0, import_react5.createElement)(ContextPersonalizationTransfer, {
|
|
630
|
+
event
|
|
631
|
+
});
|
|
632
|
+
return (0, import_react5.createElement)(import_react5.Fragment, void 0, [...components, eventElement]);
|
|
621
633
|
};
|
|
622
634
|
|
|
623
635
|
// src/components/TestServer.ts
|
|
624
636
|
var import_canvas6 = require("@uniformdev/canvas");
|
|
625
|
-
var
|
|
626
|
-
var
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
637
|
+
var import_canvas_next_rsc_shared6 = require("@uniformdev/canvas-next-rsc-shared");
|
|
638
|
+
var import_react7 = require("react");
|
|
639
|
+
|
|
640
|
+
// src/components/ContextTestTransfer.tsx
|
|
641
|
+
var import_canvas_next_rsc_client5 = require("@uniformdev/canvas-next-rsc-client");
|
|
642
|
+
var import_react6 = __toESM(require("react"));
|
|
643
|
+
var ContextTestTransfer = ({ event }) => {
|
|
644
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_canvas_next_rsc_client5.ClientContextTestTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// src/components/TestServer.ts
|
|
648
|
+
var TestServer = (props) => {
|
|
649
|
+
var _a, _b, _c, _d;
|
|
650
|
+
const { contextInstance, test } = props;
|
|
651
|
+
const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
652
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
653
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
654
|
+
}
|
|
655
|
+
const { index, event } = (0, import_canvas_next_rsc_shared6.runTest)(props);
|
|
656
|
+
const component = typeof index === "number" ? (_d = (_c = (_b = props.slots) == null ? void 0 : _b[import_canvas6.CANVAS_TEST_SLOT]) == null ? void 0 : _c.items[index]) != null ? _d : null : null;
|
|
657
|
+
const eventElement = (0, import_react7.createElement)(ContextTestTransfer, {
|
|
658
|
+
event
|
|
641
659
|
});
|
|
642
|
-
|
|
643
|
-
return (0, import_react5.createElement)(import_react5.Fragment, void 0, components);
|
|
660
|
+
return (0, import_react7.createElement)(import_react7.Fragment, void 0, [component, eventElement]);
|
|
644
661
|
};
|
|
645
662
|
|
|
646
663
|
// src/components/UniformComposition.ts
|
|
@@ -659,7 +676,7 @@ var UniformComposition = async ({
|
|
|
659
676
|
});
|
|
660
677
|
searchParams = props.searchParams;
|
|
661
678
|
}
|
|
662
|
-
const { value: path } = (0,
|
|
679
|
+
const { value: path } = (0, import_canvas_next_rsc_shared7.resolvePath)(props);
|
|
663
680
|
if (!route || route.type === "notFound") {
|
|
664
681
|
(0, import_navigation.notFound)();
|
|
665
682
|
}
|
|
@@ -705,7 +722,7 @@ var UniformComposition = async ({
|
|
|
705
722
|
if (props.mode === "server") {
|
|
706
723
|
const headersValue = (0, import_headers3.headers)();
|
|
707
724
|
const missingQuirkValue = "unknown";
|
|
708
|
-
transfer = (0,
|
|
725
|
+
transfer = (0, import_react8.createElement)(ContextUpdateTransfer, {
|
|
709
726
|
serverContext,
|
|
710
727
|
update: {
|
|
711
728
|
params: props.params,
|
|
@@ -722,9 +739,9 @@ var UniformComposition = async ({
|
|
|
722
739
|
}
|
|
723
740
|
});
|
|
724
741
|
} else if (props.mode === "static") {
|
|
725
|
-
transfer = (0,
|
|
742
|
+
transfer = (0, import_react8.createElement)(ContextUpdateTrigger);
|
|
726
743
|
}
|
|
727
|
-
return (0,
|
|
744
|
+
return (0, import_react8.createElement)(import_react8.Fragment, void 0, transfer, resolved);
|
|
728
745
|
};
|
|
729
746
|
var isServerComponent = ({
|
|
730
747
|
component,
|
|
@@ -732,10 +749,10 @@ var isServerComponent = ({
|
|
|
732
749
|
}) => {
|
|
733
750
|
var _a, _b;
|
|
734
751
|
if (component.type === import_canvas7.CANVAS_PERSONALIZE_TYPE) {
|
|
735
|
-
return serverContext && ((_a = (0,
|
|
752
|
+
return serverContext && ((_a = (0, import_canvas_next_rsc_shared7.getServerConfig)().evaluation) == null ? void 0 : _a.personalization) !== "client";
|
|
736
753
|
}
|
|
737
754
|
if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
|
|
738
|
-
return serverContext && ((_b = (0,
|
|
755
|
+
return serverContext && ((_b = (0, import_canvas_next_rsc_shared7.getServerConfig)().evaluation) == null ? void 0 : _b.testing) !== "client";
|
|
739
756
|
}
|
|
740
757
|
};
|
|
741
758
|
var resolveSystemComponent = ({
|
|
@@ -750,7 +767,7 @@ var resolveSystemComponent = ({
|
|
|
750
767
|
return server ? PersonalizeServer : PersonalizeClientWrapper;
|
|
751
768
|
}
|
|
752
769
|
if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
|
|
753
|
-
return server ? TestServer :
|
|
770
|
+
return server ? TestServer : import_canvas_next_rsc_client6.TestClient;
|
|
754
771
|
}
|
|
755
772
|
return null;
|
|
756
773
|
};
|
|
@@ -863,10 +880,10 @@ var resolveComponents = ({
|
|
|
863
880
|
slotName,
|
|
864
881
|
slotIndex: isRoot ? void 0 : componentIndex
|
|
865
882
|
};
|
|
866
|
-
const element = (0,
|
|
883
|
+
const element = (0, import_react8.createElement)(resolvedComponent, componentProps);
|
|
867
884
|
let tagElement = null;
|
|
868
885
|
if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
|
|
869
|
-
tagElement = (0,
|
|
886
|
+
tagElement = (0, import_react8.createElement)(ContextUpdateTransfer, {
|
|
870
887
|
key: `${slotName}-${componentIndex}-tags`,
|
|
871
888
|
update: {
|
|
872
889
|
enrichments: enrichmentTags
|
|
@@ -881,7 +898,7 @@ var resolveComponents = ({
|
|
|
881
898
|
elements.push(tagElement);
|
|
882
899
|
}
|
|
883
900
|
const isPlaceholder = (0, import_canvas7.isComponentPlaceholderId)(component == null ? void 0 : component._id);
|
|
884
|
-
childNode = (0,
|
|
901
|
+
childNode = (0, import_react8.createElement)(
|
|
885
902
|
import_core.PureContextualEditingComponentWrapper,
|
|
886
903
|
{
|
|
887
904
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
@@ -900,8 +917,8 @@ var resolveComponents = ({
|
|
|
900
917
|
if (tagElement) {
|
|
901
918
|
elements.push(tagElement);
|
|
902
919
|
}
|
|
903
|
-
childNode = (0,
|
|
904
|
-
|
|
920
|
+
childNode = (0, import_react8.createElement)(
|
|
921
|
+
import_canvas_next_rsc_client6.ClientContextualEditingComponentWrapper,
|
|
905
922
|
{
|
|
906
923
|
key: `${slotName}-${componentIndex}-wrapper`,
|
|
907
924
|
isPlaceholder: false,
|
|
@@ -921,8 +938,8 @@ var resolveComponents = ({
|
|
|
921
938
|
}
|
|
922
939
|
childNode = elements;
|
|
923
940
|
}
|
|
924
|
-
return (0,
|
|
925
|
-
|
|
941
|
+
return (0, import_react8.createElement)(
|
|
942
|
+
import_react8.Fragment,
|
|
926
943
|
{
|
|
927
944
|
key: !isRoot ? `${slotName}-${componentIndex}` : void 0
|
|
928
945
|
},
|
|
@@ -933,10 +950,10 @@ var resolveComponents = ({
|
|
|
933
950
|
};
|
|
934
951
|
|
|
935
952
|
// src/components/UniformContext.tsx
|
|
936
|
-
var
|
|
937
|
-
var
|
|
938
|
-
var
|
|
939
|
-
var
|
|
953
|
+
var import_canvas_next_rsc_client7 = require("@uniformdev/canvas-next-rsc-client");
|
|
954
|
+
var import_canvas_next_rsc_shared8 = require("@uniformdev/canvas-next-rsc-shared");
|
|
955
|
+
var import_react9 = require("react");
|
|
956
|
+
var import_react10 = __toESM(require("react"));
|
|
940
957
|
var UniformContext = async ({
|
|
941
958
|
clientContextComponent,
|
|
942
959
|
children
|
|
@@ -945,18 +962,18 @@ var UniformContext = async ({
|
|
|
945
962
|
const manifest = await getManifest({
|
|
946
963
|
searchParams: {}
|
|
947
964
|
});
|
|
948
|
-
const ContextComponent = clientContextComponent ||
|
|
949
|
-
const disableDevTools = ((_a = (0,
|
|
950
|
-
return /* @__PURE__ */
|
|
965
|
+
const ContextComponent = clientContextComponent || import_canvas_next_rsc_client7.DefaultUniformClientContext;
|
|
966
|
+
const disableDevTools = ((_a = (0, import_canvas_next_rsc_shared8.getServerConfig)().context) == null ? void 0 : _a.disableDevTools) || false;
|
|
967
|
+
return /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null, children, /* @__PURE__ */ import_react10.default.createElement(ContextComponent, { manifest, disableDevTools }), /* @__PURE__ */ import_react10.default.createElement(import_react9.Suspense, { fallback: /* @__PURE__ */ import_react10.default.createElement(import_react10.default.Fragment, null) }, /* @__PURE__ */ import_react10.default.createElement(import_canvas_next_rsc_client7.UniformScript, null)));
|
|
951
968
|
};
|
|
952
969
|
|
|
953
970
|
// src/components/UniformPlayground.tsx
|
|
954
971
|
var import_canvas8 = require("@uniformdev/canvas");
|
|
955
972
|
var import_navigation2 = require("next/navigation");
|
|
956
|
-
var
|
|
973
|
+
var import_react11 = __toESM(require("react"));
|
|
957
974
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
958
975
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
959
|
-
return /* @__PURE__ */
|
|
976
|
+
return /* @__PURE__ */ import_react11.default.createElement("div", null, /* @__PURE__ */ import_react11.default.createElement("h1", null, "Playground is only available in draft mode"));
|
|
960
977
|
}
|
|
961
978
|
const id = searchParams["id"];
|
|
962
979
|
if (!id) {
|
|
@@ -987,7 +1004,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
987
1004
|
if (!composition) {
|
|
988
1005
|
(0, import_navigation2.notFound)();
|
|
989
1006
|
}
|
|
990
|
-
return /* @__PURE__ */
|
|
1007
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
991
1008
|
UniformComposition,
|
|
992
1009
|
{
|
|
993
1010
|
mode: "server",
|
package/dist/index.mjs
CHANGED
|
@@ -571,38 +571,57 @@ var PersonalizeClientWrapper = (props) => {
|
|
|
571
571
|
import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
|
|
572
572
|
import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
|
|
573
573
|
import { createElement, Fragment } from "react";
|
|
574
|
+
|
|
575
|
+
// src/components/ContextPersonalizationTransfer.tsx
|
|
576
|
+
import { ClientContextPersonalizationTransfer } from "@uniformdev/canvas-next-rsc-client";
|
|
577
|
+
import React4 from "react";
|
|
578
|
+
var ContextPersonalizationTransfer = ({ event }) => {
|
|
579
|
+
return /* @__PURE__ */ React4.createElement(ClientContextPersonalizationTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/components/PersonalizeServer.ts
|
|
574
583
|
var PersonalizeServer = (props) => {
|
|
575
584
|
var _a;
|
|
576
|
-
const { indexes } = runPersonalization2(props);
|
|
585
|
+
const { indexes, event } = runPersonalization2(props);
|
|
577
586
|
const slot = (_a = props.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT];
|
|
578
587
|
const components = indexes.map((index) => {
|
|
579
588
|
const component = slot.items[index];
|
|
580
589
|
return component;
|
|
581
590
|
});
|
|
582
|
-
|
|
591
|
+
const eventElement = createElement(ContextPersonalizationTransfer, {
|
|
592
|
+
event
|
|
593
|
+
});
|
|
594
|
+
return createElement(Fragment, void 0, [...components, eventElement]);
|
|
583
595
|
};
|
|
584
596
|
|
|
585
597
|
// src/components/TestServer.ts
|
|
586
|
-
import { CANVAS_TEST_SLOT
|
|
598
|
+
import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
|
|
599
|
+
import {
|
|
600
|
+
runTest
|
|
601
|
+
} from "@uniformdev/canvas-next-rsc-shared";
|
|
587
602
|
import { createElement as createElement2, Fragment as Fragment2 } from "react";
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
})
|
|
603
|
+
|
|
604
|
+
// src/components/ContextTestTransfer.tsx
|
|
605
|
+
import { ClientContextTestTransfer } from "@uniformdev/canvas-next-rsc-client";
|
|
606
|
+
import React5 from "react";
|
|
607
|
+
var ContextTestTransfer = ({ event }) => {
|
|
608
|
+
return /* @__PURE__ */ React5.createElement(ClientContextTestTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
|
|
609
|
+
};
|
|
610
|
+
|
|
611
|
+
// src/components/TestServer.ts
|
|
612
|
+
var TestServer = (props) => {
|
|
613
|
+
var _a, _b, _c, _d;
|
|
614
|
+
const { contextInstance, test } = props;
|
|
615
|
+
const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
|
|
616
|
+
if (!isTestDefined && process.env.NODE_ENV !== "production") {
|
|
617
|
+
console.warn(`Test "${test}" is not defined in Uniform manifest.`);
|
|
618
|
+
}
|
|
619
|
+
const { index, event } = runTest(props);
|
|
620
|
+
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;
|
|
621
|
+
const eventElement = createElement2(ContextTestTransfer, {
|
|
622
|
+
event
|
|
603
623
|
});
|
|
604
|
-
|
|
605
|
-
return createElement2(Fragment2, void 0, components);
|
|
624
|
+
return createElement2(Fragment2, void 0, [component, eventElement]);
|
|
606
625
|
};
|
|
607
626
|
|
|
608
627
|
// src/components/UniformComposition.ts
|
|
@@ -901,7 +920,7 @@ import {
|
|
|
901
920
|
} from "@uniformdev/canvas-next-rsc-client";
|
|
902
921
|
import { getServerConfig as getServerConfig4 } from "@uniformdev/canvas-next-rsc-shared";
|
|
903
922
|
import { Suspense } from "react";
|
|
904
|
-
import
|
|
923
|
+
import React6 from "react";
|
|
905
924
|
var UniformContext = async ({
|
|
906
925
|
clientContextComponent,
|
|
907
926
|
children
|
|
@@ -912,16 +931,16 @@ var UniformContext = async ({
|
|
|
912
931
|
});
|
|
913
932
|
const ContextComponent = clientContextComponent || DefaultUniformClientContext;
|
|
914
933
|
const disableDevTools = ((_a = getServerConfig4().context) == null ? void 0 : _a.disableDevTools) || false;
|
|
915
|
-
return /* @__PURE__ */
|
|
934
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, children, /* @__PURE__ */ React6.createElement(ContextComponent, { manifest, disableDevTools }), /* @__PURE__ */ React6.createElement(Suspense, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
|
|
916
935
|
};
|
|
917
936
|
|
|
918
937
|
// src/components/UniformPlayground.tsx
|
|
919
938
|
import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
|
|
920
939
|
import { notFound as notFound2 } from "next/navigation";
|
|
921
|
-
import
|
|
940
|
+
import React7 from "react";
|
|
922
941
|
var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
923
942
|
if (!isDraftModeEnabled({ searchParams })) {
|
|
924
|
-
return /* @__PURE__ */
|
|
943
|
+
return /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h1", null, "Playground is only available in draft mode"));
|
|
925
944
|
}
|
|
926
945
|
const id = searchParams["id"];
|
|
927
946
|
if (!id) {
|
|
@@ -952,7 +971,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
|
|
|
952
971
|
if (!composition) {
|
|
953
972
|
notFound2();
|
|
954
973
|
}
|
|
955
|
-
return /* @__PURE__ */
|
|
974
|
+
return /* @__PURE__ */ React7.createElement(
|
|
956
975
|
UniformComposition,
|
|
957
976
|
{
|
|
958
977
|
mode: "server",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next-rsc",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.95.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsup",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"react-dom": "18.2.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@uniformdev/canvas": "19.
|
|
65
|
-
"@uniformdev/canvas-next-rsc-client": "^19.
|
|
66
|
-
"@uniformdev/canvas-next-rsc-shared": "^19.
|
|
67
|
-
"@uniformdev/canvas-react": "19.
|
|
68
|
-
"@uniformdev/context": "19.
|
|
69
|
-
"@uniformdev/project-map": "19.
|
|
70
|
-
"@uniformdev/redirect": "19.
|
|
71
|
-
"@uniformdev/richtext": "19.
|
|
72
|
-
"@uniformdev/webhooks": "19.
|
|
64
|
+
"@uniformdev/canvas": "19.95.0",
|
|
65
|
+
"@uniformdev/canvas-next-rsc-client": "^19.95.0",
|
|
66
|
+
"@uniformdev/canvas-next-rsc-shared": "^19.95.0",
|
|
67
|
+
"@uniformdev/canvas-react": "19.95.0",
|
|
68
|
+
"@uniformdev/context": "19.95.0",
|
|
69
|
+
"@uniformdev/project-map": "19.95.0",
|
|
70
|
+
"@uniformdev/redirect": "19.95.0",
|
|
71
|
+
"@uniformdev/richtext": "19.95.0",
|
|
72
|
+
"@uniformdev/webhooks": "19.95.0",
|
|
73
73
|
"@vercel/edge-config": "^0.4.0",
|
|
74
74
|
"encoding": "^0.1.13",
|
|
75
75
|
"server-only": "^0.0.1",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "3e3fb19655bb28c5452cb98418d8c87bef0f853a"
|
|
90
90
|
}
|