@uniformdev/canvas-next-rsc 19.79.1-alpha.11 → 19.79.1-alpha.8

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/index.mjs CHANGED
@@ -299,7 +299,7 @@ var getRouteClient = (options) => {
299
299
  } else {
300
300
  requestedUrl = new URL(req.url);
301
301
  }
302
- const tags = [];
302
+ const tags = ["route"];
303
303
  if (requestedUrl) {
304
304
  const pathKey = "path";
305
305
  const path = requestedUrl.searchParams.get(pathKey);
@@ -394,6 +394,7 @@ import {
394
394
  CANVAS_ENRICHMENT_TAG_PARAM,
395
395
  CANVAS_PERSONALIZE_TYPE,
396
396
  CANVAS_TEST_TYPE,
397
+ isComponentPlaceholderId,
397
398
  walkNodeTree
398
399
  } from "@uniformdev/canvas";
399
400
  import { ClientContextualEditingComponentWrapper, TestClient } from "@uniformdev/canvas-next-rsc-client";
@@ -442,11 +443,7 @@ import {
442
443
  } from "@uniformdev/canvas";
443
444
  import { getBaseUrl, getServerConfig as getServerConfig2, resolvePath } from "@uniformdev/canvas-next-rsc-shared";
444
445
  import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
445
- var retrieveRoute = async ({
446
- params,
447
- searchParams,
448
- skipPrefetch
449
- }) => {
446
+ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
450
447
  if (!skipPrefetch) {
451
448
  void getManifest({
452
449
  searchParams
@@ -466,7 +463,8 @@ var retrieveRoute = async ({
466
463
  result = await retrieveRouteByPath({
467
464
  path: value,
468
465
  state,
469
- searchParams
466
+ searchParams,
467
+ fetchOptions
470
468
  });
471
469
  } catch (e) {
472
470
  console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
@@ -500,30 +498,39 @@ var retrieveRoute = async ({
500
498
  var retrieveRouteByPath = async ({
501
499
  path,
502
500
  state,
503
- searchParams
501
+ searchParams,
502
+ fetchOptions
504
503
  }) => {
505
504
  var _a;
506
505
  const client = getDefaultRouteClient({
507
506
  searchParams
508
507
  });
508
+ let queryPath = path;
509
+ if (searchParams && Object.keys(searchParams).length > 0) {
510
+ const helper = new URL(getBaseUrl());
511
+ helper.pathname = path;
512
+ Object.entries(searchParams).forEach(([key, value]) => {
513
+ if (typeof value === "string") {
514
+ helper.searchParams.set(key, value);
515
+ }
516
+ });
517
+ if (helper.searchParams.size > 0) {
518
+ queryPath = `${helper.pathname}${helper.search}`;
519
+ }
520
+ }
509
521
  return await client.getRoute({
510
- path,
522
+ ...fetchOptions,
523
+ path: queryPath,
511
524
  state,
512
525
  withComponentIDs: true,
513
526
  withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig2().experimental) == null ? void 0 : _a.vercelVisualEditing)
514
527
  });
515
528
  };
516
529
  var resolveRedirectHref = (resolveResult, path) => {
517
- let href;
518
- if (resolveResult.redirect.targetProjectMapNodeId) {
519
- const requestUrl = `${getBaseUrl()}${path}`;
520
- const expandedUrl = getTargetVariableExpandedUrl(requestUrl, resolveResult.redirect);
521
- const url = new URL(expandedUrl);
522
- href = url.pathname;
523
- } else {
524
- href = resolveResult.redirect.targetUrl;
525
- }
526
- return href;
530
+ const requestUrl = `${getBaseUrl()}${path}`;
531
+ const expandedUrl = getTargetVariableExpandedUrl(requestUrl, resolveResult.redirect);
532
+ const url = new URL(expandedUrl);
533
+ return url.pathname;
527
534
  };
528
535
  var determineState = ({ searchParams }) => {
529
536
  const draftMode2 = isDraftModeEnabled({ searchParams });
@@ -564,38 +571,50 @@ var PersonalizeClientWrapper = (props) => {
564
571
  import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
565
572
  import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
566
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
567
583
  var PersonalizeServer = (props) => {
568
584
  var _a;
569
- const { indexes } = runPersonalization2(props);
585
+ const { indexes, event } = runPersonalization2(props);
570
586
  const slot = (_a = props.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT];
571
587
  const components = indexes.map((index) => {
572
588
  const component = slot.items[index];
573
589
  return component;
574
590
  });
575
- return createElement(Fragment, void 0, components);
591
+ const eventElement = createElement(ContextPersonalizationTransfer, {
592
+ event
593
+ });
594
+ return createElement(Fragment, void 0, [...components, eventElement]);
576
595
  };
577
596
 
578
597
  // src/components/TestServer.ts
579
- import { CANVAS_TEST_SLOT, CANVAS_TEST_VARIANT_PARAM } from "@uniformdev/canvas";
598
+ import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
599
+ import { runTest } from "@uniformdev/canvas-next-rsc-shared";
580
600
  import { createElement as createElement2, Fragment as Fragment2 } from "react";
581
- var TestServer = ({ test, component, contextInstance, slots }) => {
601
+
602
+ // src/components/ContextTestTransfer.tsx
603
+ import { ClientContextTestTransfer } from "@uniformdev/canvas-next-rsc-client";
604
+ import React5 from "react";
605
+ var ContextTestTransfer = ({ event }) => {
606
+ return /* @__PURE__ */ React5.createElement(ClientContextTestTransfer, { ts: (/* @__PURE__ */ new Date()).valueOf(), event });
607
+ };
608
+
609
+ // src/components/TestServer.ts
610
+ var TestServer = (props) => {
582
611
  var _a, _b, _c;
583
- const slot = ((_a = component.slots) == null ? void 0 : _a[CANVAS_TEST_SLOT]) || [];
584
- const { result } = contextInstance.test({
585
- name: test,
586
- variations: slot.map((v, i) => {
587
- var _a2, _b2, _c2;
588
- const contextTag = (_b2 = (_a2 = v.parameters) == null ? void 0 : _a2[CANVAS_TEST_VARIANT_PARAM]) == null ? void 0 : _b2.value;
589
- const id = (_c2 = contextTag == null ? void 0 : contextTag.id) != null ? _c2 : "testId" in v ? v.testId : `ab-${i}-${v.type}`;
590
- return {
591
- id,
592
- testDistribution: contextTag == null ? void 0 : contextTag.testDistribution,
593
- index: i
594
- };
595
- })
612
+ const { index, event } = runTest(props);
613
+ const component = typeof index === "number" ? (_c = (_b = (_a = props.slots) == null ? void 0 : _a[CANVAS_TEST_SLOT]) == null ? void 0 : _b.items[index]) != null ? _c : null : null;
614
+ const eventElement = createElement2(ContextTestTransfer, {
615
+ event
596
616
  });
597
- const components = result ? (_c = (_b = slots == null ? void 0 : slots[CANVAS_TEST_SLOT]) == null ? void 0 : _b.items[result.index]) != null ? _c : null : null;
598
- return createElement2(Fragment2, void 0, components);
617
+ return createElement2(Fragment2, void 0, [component, eventElement]);
599
618
  };
600
619
 
601
620
  // src/components/UniformComposition.ts
@@ -814,7 +833,9 @@ var resolveComponents = ({
814
833
  component,
815
834
  slots,
816
835
  contextInstance: isServer || includeContext ? serverContext : void 0,
817
- context: compositionContext
836
+ context: compositionContext,
837
+ slotName,
838
+ slotIndex: isRoot ? void 0 : componentIndex
818
839
  };
819
840
  const element = createElement3(resolvedComponent, componentProps);
820
841
  let tagElement = null;
@@ -833,11 +854,12 @@ var resolveComponents = ({
833
854
  if (tagElement) {
834
855
  elements.push(tagElement);
835
856
  }
857
+ const isPlaceholder = isComponentPlaceholderId(component == null ? void 0 : component._id);
836
858
  childNode = createElement3(
837
859
  PureContextualEditingComponentWrapper,
838
860
  {
839
861
  key: `${slotName}-${componentIndex}-wrapper`,
840
- isPlaceholder: false,
862
+ isPlaceholder,
841
863
  parentComponent: parent,
842
864
  component,
843
865
  slotName,
@@ -891,7 +913,7 @@ import {
891
913
  } from "@uniformdev/canvas-next-rsc-client";
892
914
  import { getServerConfig as getServerConfig4 } from "@uniformdev/canvas-next-rsc-shared";
893
915
  import { Suspense } from "react";
894
- import React4 from "react";
916
+ import React6 from "react";
895
917
  var UniformContext = async ({
896
918
  clientContextComponent,
897
919
  children
@@ -902,16 +924,16 @@ var UniformContext = async ({
902
924
  });
903
925
  const ContextComponent = clientContextComponent || DefaultUniformClientContext;
904
926
  const disableDevTools = ((_a = getServerConfig4().context) == null ? void 0 : _a.disableDevTools) || false;
905
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, children, /* @__PURE__ */ React4.createElement(ContextComponent, { manifest, disableDevTools }), /* @__PURE__ */ React4.createElement(Suspense, { fallback: /* @__PURE__ */ React4.createElement(React4.Fragment, null) }, /* @__PURE__ */ React4.createElement(UniformScript, null)));
927
+ 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)));
906
928
  };
907
929
 
908
930
  // src/components/UniformPlayground.tsx
909
931
  import { CANVAS_DRAFT_STATE as CANVAS_DRAFT_STATE3, CANVAS_EDITOR_STATE as CANVAS_EDITOR_STATE3 } from "@uniformdev/canvas";
910
932
  import { notFound as notFound2 } from "next/navigation";
911
- import React5 from "react";
933
+ import React7 from "react";
912
934
  var UniformPlayground = async ({ searchParams, ...rest }) => {
913
935
  if (!isDraftModeEnabled({ searchParams })) {
914
- return /* @__PURE__ */ React5.createElement("div", null, /* @__PURE__ */ React5.createElement("h1", null, "Playground is only available in draft mode"));
936
+ return /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement("h1", null, "Playground is only available in draft mode"));
915
937
  }
916
938
  const id = searchParams["id"];
917
939
  if (!id) {
@@ -942,7 +964,7 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
942
964
  if (!composition) {
943
965
  notFound2();
944
966
  }
945
- return /* @__PURE__ */ React5.createElement(
967
+ return /* @__PURE__ */ React7.createElement(
946
968
  UniformComposition,
947
969
  {
948
970
  mode: "server",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc",
3
- "version": "19.79.1-alpha.11+4547ef846",
3
+ "version": "19.79.1-alpha.8+5ba1ad1ca",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -54,22 +54,22 @@
54
54
  ],
55
55
  "devDependencies": {
56
56
  "@types/node": "^18.0.0",
57
- "@types/react": "^18.2.20",
58
- "eslint": "^8.11.0",
57
+ "@types/react": "18.2.40",
58
+ "eslint": "8.54.0",
59
59
  "next": "^13.4.12",
60
60
  "react": "18.2.0",
61
61
  "react-dom": "18.2.0"
62
62
  },
63
63
  "dependencies": {
64
- "@uniformdev/canvas": "19.79.1-alpha.11+4547ef846",
65
- "@uniformdev/canvas-next-rsc-client": "^19.79.1-alpha.11+4547ef846",
66
- "@uniformdev/canvas-next-rsc-shared": "^19.79.1-alpha.11+4547ef846",
67
- "@uniformdev/canvas-react": "19.79.1-alpha.11+4547ef846",
68
- "@uniformdev/context": "19.79.1-alpha.11+4547ef846",
69
- "@uniformdev/project-map": "19.79.1-alpha.11+4547ef846",
70
- "@uniformdev/redirect": "19.79.1-alpha.11+4547ef846",
71
- "@uniformdev/richtext": "19.79.1-alpha.11+4547ef846",
72
- "@uniformdev/webhooks": "19.79.1-alpha.11+4547ef846",
64
+ "@uniformdev/canvas": "19.79.1-alpha.8+5ba1ad1ca",
65
+ "@uniformdev/canvas-next-rsc-client": "^19.79.1-alpha.8+5ba1ad1ca",
66
+ "@uniformdev/canvas-next-rsc-shared": "^19.79.1-alpha.8+5ba1ad1ca",
67
+ "@uniformdev/canvas-react": "19.79.1-alpha.8+5ba1ad1ca",
68
+ "@uniformdev/context": "19.79.1-alpha.8+5ba1ad1ca",
69
+ "@uniformdev/project-map": "19.79.1-alpha.8+5ba1ad1ca",
70
+ "@uniformdev/redirect": "19.79.1-alpha.8+5ba1ad1ca",
71
+ "@uniformdev/richtext": "19.79.1-alpha.8+5ba1ad1ca",
72
+ "@uniformdev/webhooks": "19.79.1-alpha.8+5ba1ad1ca",
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": "4547ef8469f21f7f2341bcd87203372c4646bc08"
89
+ "gitHead": "5ba1ad1ca42f7a035f32e8bb6f51bd1e955f0792"
90
90
  }