@uniformdev/canvas-next-rsc 19.147.1-alpha.1 → 19.147.1-alpha.5

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.
@@ -36,6 +36,9 @@ type ResolveComponentFunction = (options: {
36
36
  type ResolveComponentResult = {
37
37
  component: ComponentType<ComponentProps<any, any>> | null;
38
38
  includeContext?: boolean;
39
+ suspense?: {
40
+ fallback: ComponentType<any> | undefined;
41
+ };
39
42
  };
40
43
  declare const resolveComposition: (props: Omit<ResolveComponentsOptions, 'slotName' | 'slotIndex' | 'target'> & {
41
44
  composition: ComponentInstance;
@@ -36,6 +36,9 @@ type ResolveComponentFunction = (options: {
36
36
  type ResolveComponentResult = {
37
37
  component: ComponentType<ComponentProps<any, any>> | null;
38
38
  includeContext?: boolean;
39
+ suspense?: {
40
+ fallback: ComponentType<any> | undefined;
41
+ };
39
42
  };
40
43
  declare const resolveComposition: (props: Omit<ResolveComponentsOptions, 'slotName' | 'slotIndex' | 'target'> & {
41
44
  composition: ComponentInstance;
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps, CompositionContext, SlotDefinition } from '@uniformdev/canvas-next-rsc-shared';
2
2
  export { ComponentProps, CompositionContext } from '@uniformdev/canvas-next-rsc-shared';
3
3
  import React__default, { PropsWithChildren, ReactNode, Key } from 'react';
4
- export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-D4tBQ2U4.mjs';
4
+ export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-B-Z17dUt.mjs';
5
5
  import { ComponentInstance } from '@uniformdev/canvas';
6
6
  import { RichTextNode } from '@uniformdev/richtext';
7
7
  import { PureUniformTextProps } from '@uniformdev/canvas-react/core';
@@ -1,7 +1,7 @@
1
1
  import { ComponentProps, CompositionContext, SlotDefinition } from '@uniformdev/canvas-next-rsc-shared';
2
2
  export { ComponentProps, CompositionContext } from '@uniformdev/canvas-next-rsc-shared';
3
3
  import React__default, { PropsWithChildren, ReactNode, Key } from 'react';
4
- export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-D4tBQ2U4.js';
4
+ export { R as ResolveComponentFunction, b as ResolveComponentResult } from './UniformComposition-B-Z17dUt.js';
5
5
  import { ComponentInstance } from '@uniformdev/canvas';
6
6
  import { RichTextNode } from '@uniformdev/richtext';
7
7
  import { PureUniformTextProps } from '@uniformdev/canvas-react/core';
package/dist/handler.js CHANGED
@@ -228,6 +228,7 @@ var getCanvasClient = (options) => {
228
228
  apiHost: env.getApiHost(),
229
229
  apiKey: env.getApiKey(),
230
230
  edgeApiHost: env.getEdgeApiHost(),
231
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
231
232
  fetch: (req, init) => {
232
233
  let requestedUrl;
233
234
  if (typeof req === "string") {
@@ -259,7 +260,7 @@ var getCanvasClient = (options) => {
259
260
  cache,
260
261
  headers: {
261
262
  ...init == null ? void 0 : init.headers,
262
- "x-bypass-cache": "true"
263
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
263
264
  },
264
265
  next: {
265
266
  revalidate
@@ -282,7 +283,7 @@ var getProjectMapClient = (options) => {
282
283
  ...init,
283
284
  headers: {
284
285
  ...init == null ? void 0 : init.headers,
285
- "x-bypass-cache": "true"
286
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
286
287
  },
287
288
  cache,
288
289
  next: {
@@ -301,6 +302,7 @@ var getRouteClient = (options) => {
301
302
  projectId: env.getProjectId(),
302
303
  apiKey: env.getApiKey(),
303
304
  edgeApiHost: env.getEdgeApiHost(),
305
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
304
306
  fetch: (req, init) => {
305
307
  let requestedUrl;
306
308
  if (typeof req === "string") {
@@ -328,7 +330,7 @@ var getRouteClient = (options) => {
328
330
  ...init,
329
331
  headers: {
330
332
  ...init == null ? void 0 : init.headers,
331
- "x-bypass-cache": "true"
333
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
332
334
  },
333
335
  cache,
334
336
  next: {
@@ -382,6 +384,7 @@ var processCompositionChange = async (compositionId) => {
382
384
  getComposition({ compositionId })
383
385
  ]);
384
386
  const tags = [];
387
+ const paths = [];
385
388
  if (composition == null ? void 0 : composition.pattern) {
386
389
  tags.push("route");
387
390
  }
@@ -391,12 +394,17 @@ var processCompositionChange = async (compositionId) => {
391
394
  await processEdgeConfigChange({
392
395
  source_url: node.path
393
396
  });
394
- tags.push(...buildProjectMapNodePaths(node.path));
397
+ const result = buildProjectMapNodePaths(node.path);
398
+ tags.push(...result.tags);
399
+ if (result.paths) {
400
+ paths.push(...result.paths);
401
+ }
395
402
  }
396
403
  }
397
404
  tags.push(buildCompositionTag(compositionId));
398
405
  return {
399
- tags
406
+ tags,
407
+ paths
400
408
  };
401
409
  };
402
410
  var getComposition = async ({ compositionId }) => {
@@ -419,9 +427,11 @@ var getComposition = async ({ compositionId }) => {
419
427
  };
420
428
  var buildProjectMapNodePaths = (path) => {
421
429
  const tags = [];
430
+ const paths = [];
422
431
  const isDynamic = path.includes(":");
423
432
  if (!isDynamic) {
424
433
  tags.push(buildPathTag(path));
434
+ paths.push(path);
425
435
  } else {
426
436
  const pieces = path.split("/");
427
437
  const invalidatePieces = [];
@@ -434,8 +444,12 @@ var buildProjectMapNodePaths = (path) => {
434
444
  }
435
445
  const toInvalidate = invalidatePieces.join("/");
436
446
  tags.push(buildPathTag(toInvalidate));
447
+ paths.push(toInvalidate);
437
448
  }
438
- return tags;
449
+ return {
450
+ tags,
451
+ paths
452
+ };
439
453
  };
440
454
  var getPathName = (url) => {
441
455
  try {
@@ -450,7 +464,8 @@ var processRedirectChange = async (sourceUrl) => {
450
464
  const pathName = getPathName(sourceUrl);
451
465
  tags.push(buildPathTag(pathName));
452
466
  return {
453
- tags
467
+ tags,
468
+ paths: [pathName]
454
469
  };
455
470
  };
456
471
  var processEdgeConfigChange = async ({ source_url }) => {
@@ -557,7 +572,12 @@ var handleProjectMapNodeDelete = async (body) => {
557
572
  return void 0;
558
573
  }
559
574
  const tags = [];
560
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
575
+ const paths = [];
576
+ const result = buildProjectMapNodePaths(parsed.data.path);
577
+ tags.push(...result.tags);
578
+ if (result.paths) {
579
+ paths.push(...result.paths);
580
+ }
561
581
  const config = getServerConfig();
562
582
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
563
583
  await processEdgeConfigChange({
@@ -565,7 +585,8 @@ var handleProjectMapNodeDelete = async (body) => {
565
585
  });
566
586
  }
567
587
  return {
568
- tags
588
+ tags,
589
+ paths
569
590
  };
570
591
  };
571
592
 
@@ -578,7 +599,12 @@ var handleProjectMapNodeInsert = async (body) => {
578
599
  return void 0;
579
600
  }
580
601
  const tags = [];
581
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
602
+ const paths = [];
603
+ const result = buildProjectMapNodePaths(parsed.data.path);
604
+ tags.push(...result.tags);
605
+ if (result.paths) {
606
+ paths.push(...result.paths);
607
+ }
582
608
  const config = getServerConfig();
583
609
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
584
610
  await processEdgeConfigChange({
@@ -586,7 +612,8 @@ var handleProjectMapNodeInsert = async (body) => {
586
612
  });
587
613
  }
588
614
  return {
589
- tags
615
+ tags,
616
+ paths
590
617
  };
591
618
  };
592
619
 
@@ -599,8 +626,17 @@ var handleProjectMapNodeUpdate = async (body) => {
599
626
  return void 0;
600
627
  }
601
628
  const tags = [];
602
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
603
- tags.push(...buildProjectMapNodePaths(parsed.data.previous_path));
629
+ const paths = [];
630
+ const currentResult = buildProjectMapNodePaths(parsed.data.path);
631
+ tags.push(...currentResult.tags);
632
+ if (currentResult.paths) {
633
+ paths.push(...currentResult.paths);
634
+ }
635
+ const previousResult = buildProjectMapNodePaths(parsed.data.previous_path);
636
+ tags.push(...previousResult.tags);
637
+ if (previousResult.paths) {
638
+ paths.push(...previousResult.paths);
639
+ }
604
640
  const config = getServerConfig();
605
641
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
606
642
  await processEdgeConfigChange({
@@ -608,7 +644,8 @@ var handleProjectMapNodeUpdate = async (body) => {
608
644
  });
609
645
  }
610
646
  return {
611
- tags
647
+ tags,
648
+ paths
612
649
  };
613
650
  };
614
651
 
@@ -703,6 +740,7 @@ var handleSvixMessage = async (request) => {
703
740
  handleManifestPublished
704
741
  ];
705
742
  let tags = void 0;
743
+ let paths = void 0;
706
744
  let jsonBody;
707
745
  try {
708
746
  jsonBody = await request.json();
@@ -715,6 +753,7 @@ var handleSvixMessage = async (request) => {
715
753
  const result = await handler(jsonBody);
716
754
  if (result) {
717
755
  tags = result.tags;
756
+ paths = result.paths;
718
757
  break;
719
758
  }
720
759
  }
@@ -724,10 +763,17 @@ var handleSvixMessage = async (request) => {
724
763
  (0, import_cache.revalidateTag)(tag);
725
764
  }
726
765
  }
766
+ if (paths == null ? void 0 : paths.length) {
767
+ for (let i = 0; i < paths.length; i++) {
768
+ const path = paths[i];
769
+ (0, import_cache.revalidatePath)(path);
770
+ }
771
+ }
727
772
  return new Response(
728
773
  JSON.stringify({
729
- handled: typeof tags !== "undefined",
730
- tags
774
+ handled: typeof tags !== "undefined" || typeof paths !== "undefined",
775
+ tags,
776
+ paths
731
777
  })
732
778
  );
733
779
  };
package/dist/handler.mjs CHANGED
@@ -142,7 +142,7 @@ var createPreviewOPTIONSRouteHandler = () => {
142
142
 
143
143
  // src/handler/createPreviewPOSTRouteHandler.ts
144
144
  import { SECRET_QUERY_STRING_PARAM as SECRET_QUERY_STRING_PARAM2 } from "@uniformdev/canvas";
145
- import { revalidateTag } from "next/cache";
145
+ import { revalidatePath, revalidateTag } from "next/cache";
146
146
 
147
147
  // src/handler/helpers.ts
148
148
  import { ApiClientError } from "@uniformdev/canvas";
@@ -213,6 +213,7 @@ var getCanvasClient = (options) => {
213
213
  apiHost: env.getApiHost(),
214
214
  apiKey: env.getApiKey(),
215
215
  edgeApiHost: env.getEdgeApiHost(),
216
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
216
217
  fetch: (req, init) => {
217
218
  let requestedUrl;
218
219
  if (typeof req === "string") {
@@ -244,7 +245,7 @@ var getCanvasClient = (options) => {
244
245
  cache,
245
246
  headers: {
246
247
  ...init == null ? void 0 : init.headers,
247
- "x-bypass-cache": "true"
248
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
248
249
  },
249
250
  next: {
250
251
  revalidate
@@ -267,7 +268,7 @@ var getProjectMapClient = (options) => {
267
268
  ...init,
268
269
  headers: {
269
270
  ...init == null ? void 0 : init.headers,
270
- "x-bypass-cache": "true"
271
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
271
272
  },
272
273
  cache,
273
274
  next: {
@@ -286,6 +287,7 @@ var getRouteClient = (options) => {
286
287
  projectId: env.getProjectId(),
287
288
  apiKey: env.getApiKey(),
288
289
  edgeApiHost: env.getEdgeApiHost(),
290
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
289
291
  fetch: (req, init) => {
290
292
  let requestedUrl;
291
293
  if (typeof req === "string") {
@@ -313,7 +315,7 @@ var getRouteClient = (options) => {
313
315
  ...init,
314
316
  headers: {
315
317
  ...init == null ? void 0 : init.headers,
316
- "x-bypass-cache": "true"
318
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
317
319
  },
318
320
  cache,
319
321
  next: {
@@ -367,6 +369,7 @@ var processCompositionChange = async (compositionId) => {
367
369
  getComposition({ compositionId })
368
370
  ]);
369
371
  const tags = [];
372
+ const paths = [];
370
373
  if (composition == null ? void 0 : composition.pattern) {
371
374
  tags.push("route");
372
375
  }
@@ -376,12 +379,17 @@ var processCompositionChange = async (compositionId) => {
376
379
  await processEdgeConfigChange({
377
380
  source_url: node.path
378
381
  });
379
- tags.push(...buildProjectMapNodePaths(node.path));
382
+ const result = buildProjectMapNodePaths(node.path);
383
+ tags.push(...result.tags);
384
+ if (result.paths) {
385
+ paths.push(...result.paths);
386
+ }
380
387
  }
381
388
  }
382
389
  tags.push(buildCompositionTag(compositionId));
383
390
  return {
384
- tags
391
+ tags,
392
+ paths
385
393
  };
386
394
  };
387
395
  var getComposition = async ({ compositionId }) => {
@@ -404,9 +412,11 @@ var getComposition = async ({ compositionId }) => {
404
412
  };
405
413
  var buildProjectMapNodePaths = (path) => {
406
414
  const tags = [];
415
+ const paths = [];
407
416
  const isDynamic = path.includes(":");
408
417
  if (!isDynamic) {
409
418
  tags.push(buildPathTag(path));
419
+ paths.push(path);
410
420
  } else {
411
421
  const pieces = path.split("/");
412
422
  const invalidatePieces = [];
@@ -419,8 +429,12 @@ var buildProjectMapNodePaths = (path) => {
419
429
  }
420
430
  const toInvalidate = invalidatePieces.join("/");
421
431
  tags.push(buildPathTag(toInvalidate));
432
+ paths.push(toInvalidate);
422
433
  }
423
- return tags;
434
+ return {
435
+ tags,
436
+ paths
437
+ };
424
438
  };
425
439
  var getPathName = (url) => {
426
440
  try {
@@ -435,7 +449,8 @@ var processRedirectChange = async (sourceUrl) => {
435
449
  const pathName = getPathName(sourceUrl);
436
450
  tags.push(buildPathTag(pathName));
437
451
  return {
438
- tags
452
+ tags,
453
+ paths: [pathName]
439
454
  };
440
455
  };
441
456
  var processEdgeConfigChange = async ({ source_url }) => {
@@ -542,7 +557,12 @@ var handleProjectMapNodeDelete = async (body) => {
542
557
  return void 0;
543
558
  }
544
559
  const tags = [];
545
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
560
+ const paths = [];
561
+ const result = buildProjectMapNodePaths(parsed.data.path);
562
+ tags.push(...result.tags);
563
+ if (result.paths) {
564
+ paths.push(...result.paths);
565
+ }
546
566
  const config = getServerConfig();
547
567
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
548
568
  await processEdgeConfigChange({
@@ -550,7 +570,8 @@ var handleProjectMapNodeDelete = async (body) => {
550
570
  });
551
571
  }
552
572
  return {
553
- tags
573
+ tags,
574
+ paths
554
575
  };
555
576
  };
556
577
 
@@ -563,7 +584,12 @@ var handleProjectMapNodeInsert = async (body) => {
563
584
  return void 0;
564
585
  }
565
586
  const tags = [];
566
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
587
+ const paths = [];
588
+ const result = buildProjectMapNodePaths(parsed.data.path);
589
+ tags.push(...result.tags);
590
+ if (result.paths) {
591
+ paths.push(...result.paths);
592
+ }
567
593
  const config = getServerConfig();
568
594
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
569
595
  await processEdgeConfigChange({
@@ -571,7 +597,8 @@ var handleProjectMapNodeInsert = async (body) => {
571
597
  });
572
598
  }
573
599
  return {
574
- tags
600
+ tags,
601
+ paths
575
602
  };
576
603
  };
577
604
 
@@ -584,8 +611,17 @@ var handleProjectMapNodeUpdate = async (body) => {
584
611
  return void 0;
585
612
  }
586
613
  const tags = [];
587
- tags.push(...buildProjectMapNodePaths(parsed.data.path));
588
- tags.push(...buildProjectMapNodePaths(parsed.data.previous_path));
614
+ const paths = [];
615
+ const currentResult = buildProjectMapNodePaths(parsed.data.path);
616
+ tags.push(...currentResult.tags);
617
+ if (currentResult.paths) {
618
+ paths.push(...currentResult.paths);
619
+ }
620
+ const previousResult = buildProjectMapNodePaths(parsed.data.previous_path);
621
+ tags.push(...previousResult.tags);
622
+ if (previousResult.paths) {
623
+ paths.push(...previousResult.paths);
624
+ }
589
625
  const config = getServerConfig();
590
626
  if ((_a = config.experimental) == null ? void 0 : _a.edgeCompositions) {
591
627
  await processEdgeConfigChange({
@@ -593,7 +629,8 @@ var handleProjectMapNodeUpdate = async (body) => {
593
629
  });
594
630
  }
595
631
  return {
596
- tags
632
+ tags,
633
+ paths
597
634
  };
598
635
  };
599
636
 
@@ -688,6 +725,7 @@ var handleSvixMessage = async (request) => {
688
725
  handleManifestPublished
689
726
  ];
690
727
  let tags = void 0;
728
+ let paths = void 0;
691
729
  let jsonBody;
692
730
  try {
693
731
  jsonBody = await request.json();
@@ -700,6 +738,7 @@ var handleSvixMessage = async (request) => {
700
738
  const result = await handler(jsonBody);
701
739
  if (result) {
702
740
  tags = result.tags;
741
+ paths = result.paths;
703
742
  break;
704
743
  }
705
744
  }
@@ -709,10 +748,17 @@ var handleSvixMessage = async (request) => {
709
748
  revalidateTag(tag);
710
749
  }
711
750
  }
751
+ if (paths == null ? void 0 : paths.length) {
752
+ for (let i = 0; i < paths.length; i++) {
753
+ const path = paths[i];
754
+ revalidatePath(path);
755
+ }
756
+ }
712
757
  return new Response(
713
758
  JSON.stringify({
714
- handled: typeof tags !== "undefined",
715
- tags
759
+ handled: typeof tags !== "undefined" || typeof paths !== "undefined",
760
+ tags,
761
+ paths
716
762
  })
717
763
  );
718
764
  };
package/dist/index.d.mts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { CanvasClient, RouteClient, ResolvedRouteGetResponse, RouteGetParameters } from '@uniformdev/canvas';
2
- import { CacheMode, PageParameters, AppDirectoryContextState, AppDirectoryServerContext, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
2
+ import { UniformServerConfig, PageParameters, AppDirectoryContextState, AppDirectoryServerContext, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
3
3
  export { PageParameters, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
4
4
  import { ManifestClient } from '@uniformdev/context/api';
5
5
  import { ProjectMapClient, ProjectMapNode } from '@uniformdev/project-map';
6
6
  import { ContextState, ContextOptions } from '@uniformdev/context';
7
7
  import React__default, { PropsWithChildren } from 'react';
8
- import { U as UniformCompositionProps } from './UniformComposition-D4tBQ2U4.mjs';
9
- export { a as UniformComposition, r as resolveComposition } from './UniformComposition-D4tBQ2U4.mjs';
8
+ import { U as UniformCompositionProps } from './UniformComposition-B-Z17dUt.mjs';
9
+ export { a as UniformComposition, r as resolveComposition } from './UniformComposition-B-Z17dUt.mjs';
10
10
  import { ClientContextComponent } from '@uniformdev/canvas-next-rsc-client';
11
11
 
12
12
  type GetCanvasClientOptions = {
13
- cache: CacheMode;
13
+ cache: NonNullable<UniformServerConfig['canvasCache']>;
14
14
  };
15
15
  declare const getCanvasClient: (options: GetCanvasClientOptions) => CanvasClient;
16
16
  declare const getDefaultCanvasClient: ({ searchParams, }: {
@@ -18,7 +18,7 @@ declare const getDefaultCanvasClient: ({ searchParams, }: {
18
18
  }) => CanvasClient;
19
19
 
20
20
  type GetManifestClientOptions = {
21
- cache: CacheMode;
21
+ cache: NonNullable<UniformServerConfig['manifestCache']>;
22
22
  };
23
23
  declare const getManifestClient: (options: GetManifestClientOptions) => ManifestClient;
24
24
  declare const getDefaultManifestClient: ({ searchParams, }: {
@@ -183,7 +183,7 @@ declare const getManifest: ({ searchParams }: {
183
183
  }>;
184
184
 
185
185
  type GetProjectMapClientOptions = {
186
- cache: CacheMode;
186
+ cache: NonNullable<UniformServerConfig['projectMapCache']>;
187
187
  };
188
188
  declare const getProjectMapClient: (options: GetProjectMapClientOptions) => ProjectMapClient;
189
189
  declare const getDefaultProjectMapClient: ({ searchParams, }: {
@@ -191,7 +191,7 @@ declare const getDefaultProjectMapClient: ({ searchParams, }: {
191
191
  }) => ProjectMapClient;
192
192
 
193
193
  type GetRouteClientOptions = {
194
- cache: CacheMode;
194
+ cache: NonNullable<UniformServerConfig['canvasCache']>;
195
195
  };
196
196
  declare const getRouteClient: (options: GetRouteClientOptions) => RouteClient;
197
197
  declare const getDefaultRouteClient: ({ searchParams }: {
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { CanvasClient, RouteClient, ResolvedRouteGetResponse, RouteGetParameters } from '@uniformdev/canvas';
2
- import { CacheMode, PageParameters, AppDirectoryContextState, AppDirectoryServerContext, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
2
+ import { UniformServerConfig, PageParameters, AppDirectoryContextState, AppDirectoryServerContext, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
3
3
  export { PageParameters, PlaygroundParameters } from '@uniformdev/canvas-next-rsc-shared';
4
4
  import { ManifestClient } from '@uniformdev/context/api';
5
5
  import { ProjectMapClient, ProjectMapNode } from '@uniformdev/project-map';
6
6
  import { ContextState, ContextOptions } from '@uniformdev/context';
7
7
  import React__default, { PropsWithChildren } from 'react';
8
- import { U as UniformCompositionProps } from './UniformComposition-D4tBQ2U4.js';
9
- export { a as UniformComposition, r as resolveComposition } from './UniformComposition-D4tBQ2U4.js';
8
+ import { U as UniformCompositionProps } from './UniformComposition-B-Z17dUt.js';
9
+ export { a as UniformComposition, r as resolveComposition } from './UniformComposition-B-Z17dUt.js';
10
10
  import { ClientContextComponent } from '@uniformdev/canvas-next-rsc-client';
11
11
 
12
12
  type GetCanvasClientOptions = {
13
- cache: CacheMode;
13
+ cache: NonNullable<UniformServerConfig['canvasCache']>;
14
14
  };
15
15
  declare const getCanvasClient: (options: GetCanvasClientOptions) => CanvasClient;
16
16
  declare const getDefaultCanvasClient: ({ searchParams, }: {
@@ -18,7 +18,7 @@ declare const getDefaultCanvasClient: ({ searchParams, }: {
18
18
  }) => CanvasClient;
19
19
 
20
20
  type GetManifestClientOptions = {
21
- cache: CacheMode;
21
+ cache: NonNullable<UniformServerConfig['manifestCache']>;
22
22
  };
23
23
  declare const getManifestClient: (options: GetManifestClientOptions) => ManifestClient;
24
24
  declare const getDefaultManifestClient: ({ searchParams, }: {
@@ -183,7 +183,7 @@ declare const getManifest: ({ searchParams }: {
183
183
  }>;
184
184
 
185
185
  type GetProjectMapClientOptions = {
186
- cache: CacheMode;
186
+ cache: NonNullable<UniformServerConfig['projectMapCache']>;
187
187
  };
188
188
  declare const getProjectMapClient: (options: GetProjectMapClientOptions) => ProjectMapClient;
189
189
  declare const getDefaultProjectMapClient: ({ searchParams, }: {
@@ -191,7 +191,7 @@ declare const getDefaultProjectMapClient: ({ searchParams, }: {
191
191
  }) => ProjectMapClient;
192
192
 
193
193
  type GetRouteClientOptions = {
194
- cache: CacheMode;
194
+ cache: NonNullable<UniformServerConfig['canvasCache']>;
195
195
  };
196
196
  declare const getRouteClient: (options: GetRouteClientOptions) => RouteClient;
197
197
  declare const getDefaultRouteClient: ({ searchParams }: {
package/dist/index.esm.js CHANGED
@@ -174,6 +174,7 @@ var getCanvasClient = (options) => {
174
174
  apiHost: env.getApiHost(),
175
175
  apiKey: env.getApiKey(),
176
176
  edgeApiHost: env.getEdgeApiHost(),
177
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
177
178
  fetch: (req, init) => {
178
179
  let requestedUrl;
179
180
  if (typeof req === "string") {
@@ -205,7 +206,7 @@ var getCanvasClient = (options) => {
205
206
  cache,
206
207
  headers: {
207
208
  ...init == null ? void 0 : init.headers,
208
- "x-bypass-cache": "true"
209
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
209
210
  },
210
211
  next: {
211
212
  revalidate
@@ -237,7 +238,7 @@ var getManifestClient = (options) => {
237
238
  ...init,
238
239
  headers: {
239
240
  ...init == null ? void 0 : init.headers,
240
- "x-bypass-cache": "true"
241
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
241
242
  },
242
243
  cache,
243
244
  next: {
@@ -278,7 +279,7 @@ var getProjectMapClient = (options) => {
278
279
  ...init,
279
280
  headers: {
280
281
  ...init == null ? void 0 : init.headers,
281
- "x-bypass-cache": "true"
282
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
282
283
  },
283
284
  cache,
284
285
  next: {
@@ -306,6 +307,7 @@ var getRouteClient = (options) => {
306
307
  projectId: env.getProjectId(),
307
308
  apiKey: env.getApiKey(),
308
309
  edgeApiHost: env.getEdgeApiHost(),
310
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
309
311
  fetch: (req, init) => {
310
312
  let requestedUrl;
311
313
  if (typeof req === "string") {
@@ -333,7 +335,7 @@ var getRouteClient = (options) => {
333
335
  ...init,
334
336
  headers: {
335
337
  ...init == null ? void 0 : init.headers,
336
- "x-bypass-cache": "true"
338
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
337
339
  },
338
340
  cache,
339
341
  next: {
@@ -420,7 +422,7 @@ import {
420
422
  import { PureContextualEditingComponentWrapper } from "@uniformdev/canvas-react/core";
421
423
  import { cookies as cookies2, headers } from "next/headers";
422
424
  import { notFound, redirect } from "next/navigation";
423
- import { createElement as createElement3, Fragment as Fragment3 } from "react";
425
+ import { createElement as createElement3, Fragment as Fragment3, Suspense } from "react";
424
426
 
425
427
  // src/context/createServerUniformContext.ts
426
428
  import {
@@ -585,6 +587,7 @@ var PersonalizeClientWrapper = (props) => {
585
587
  // src/components/PersonalizeServer.ts
586
588
  import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
587
589
  import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
590
+ import { unstable_noStore as noStore } from "next/cache";
588
591
  import { createElement, Fragment } from "react";
589
592
 
590
593
  // src/components/ContextPersonalizationTransfer.tsx
@@ -596,15 +599,19 @@ var ContextPersonalizationTransfer = ({ event }) => {
596
599
 
597
600
  // src/components/PersonalizeServer.ts
598
601
  var PersonalizeServer = (props) => {
599
- var _a;
602
+ var _a, _b;
603
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.personalizationSuspense) {
604
+ noStore();
605
+ }
600
606
  const { indexes, event } = runPersonalization2(props);
601
- const slot = (_a = props.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT];
607
+ const slot = (_b = props.slots) == null ? void 0 : _b[CANVAS_PERSONALIZE_SLOT];
602
608
  const components = indexes.map((index) => {
603
609
  const component = slot.items[index];
604
610
  return component;
605
611
  });
606
612
  const eventElement = createElement(ContextPersonalizationTransfer, {
607
- event
613
+ event,
614
+ key: `${props.slotName}-${props.slotIndex}-personalization-transfer`
608
615
  });
609
616
  return createElement(Fragment, void 0, [...components, eventElement]);
610
617
  };
@@ -614,6 +621,7 @@ import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
614
621
  import {
615
622
  runTest
616
623
  } from "@uniformdev/canvas-next-rsc-shared";
624
+ import { unstable_noStore as noStore2 } from "next/cache";
617
625
  import { createElement as createElement2, Fragment as Fragment2 } from "react";
618
626
 
619
627
  // src/components/ContextTestTransfer.tsx
@@ -624,17 +632,24 @@ var ContextTestTransfer = ({ event }) => {
624
632
  };
625
633
 
626
634
  // src/components/TestServer.ts
627
- var TestServer = (props) => {
628
- var _a, _b, _c, _d;
635
+ var TestServer = async (props) => {
636
+ var _a, _b, _c, _d, _e;
637
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
638
+ noStore2();
639
+ }
629
640
  const { contextInstance, test } = props;
630
- const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
641
+ const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
631
642
  if (!isTestDefined && process.env.NODE_ENV !== "production") {
632
643
  console.warn(`Test "${test}" is not defined in Uniform manifest.`);
633
644
  }
634
645
  const { index, event } = runTest(props);
635
- 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;
646
+ if (index === null || event === null) {
647
+ return null;
648
+ }
649
+ const component = typeof index === "number" ? (_e = (_d = (_c = props.slots) == null ? void 0 : _c[CANVAS_TEST_SLOT]) == null ? void 0 : _d.items[index]) != null ? _e : null : null;
636
650
  const eventElement = createElement2(ContextTestTransfer, {
637
- event
651
+ event,
652
+ key: `${props.slotName}-${props.slotIndex}-server-transfer`
638
653
  });
639
654
  return createElement2(Fragment2, void 0, [component, eventElement]);
640
655
  };
@@ -738,19 +753,24 @@ var isServerComponent = ({
738
753
  };
739
754
  var resolveSystemComponent = ({
740
755
  component,
741
- serverContext
756
+ server
742
757
  }) => {
743
- const server = isServerComponent({
744
- component,
745
- serverContext
746
- });
758
+ var _a, _b;
759
+ const config = getServerConfig();
760
+ let resolved = null;
761
+ let suspense = void 0;
747
762
  if (component.type === CANVAS_PERSONALIZE_TYPE) {
748
- return server ? PersonalizeServer : PersonalizeClientWrapper;
763
+ resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
764
+ suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
749
765
  }
750
766
  if (component.type === CANVAS_TEST_TYPE) {
751
- return server ? TestServer : TestClient;
767
+ resolved = server ? TestServer : TestClient;
768
+ suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
752
769
  }
753
- return null;
770
+ return {
771
+ component: resolved,
772
+ suspense
773
+ };
754
774
  };
755
775
  var resolveSlots = ({
756
776
  component,
@@ -827,11 +847,15 @@ var resolveComponents = ({
827
847
  component,
828
848
  serverContext
829
849
  });
830
- const systemComponent = resolveSystemComponent({
850
+ const { component: systemComponent, suspense: systemSuspense } = resolveSystemComponent({
831
851
  component,
832
- serverContext
852
+ server: isServer
833
853
  });
834
- const { component: regularComponent, includeContext } = resolveComponent({ component }) || {
854
+ const {
855
+ component: regularComponent,
856
+ includeContext,
857
+ suspense: componentSuspense
858
+ } = resolveComponent({ component }) || {
835
859
  component: null
836
860
  };
837
861
  if (!systemComponent && !regularComponent) {
@@ -846,10 +870,11 @@ var resolveComponents = ({
846
870
  mode
847
871
  });
848
872
  const resolvedComponent = systemComponent || regularComponent;
873
+ const wrapInSuspense = systemSuspense || componentSuspense;
849
874
  const parameters = (_a = component.parameters) != null ? _a : {};
850
875
  const enrichmentTags = (_b = parameters[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
876
+ const key = `${slotName}-${componentIndex}-component`;
851
877
  const componentProps = {
852
- key: `${slotName}-${componentIndex}-component`,
853
878
  ...Object.keys(parameters).reduce((acc, cur) => {
854
879
  acc[cur] = parameters[cur].value;
855
880
  return acc;
@@ -861,7 +886,19 @@ var resolveComponents = ({
861
886
  slotName,
862
887
  slotIndex: isRoot ? void 0 : componentIndex
863
888
  };
864
- const element = createElement3(resolvedComponent, componentProps);
889
+ let element = null;
890
+ if (wrapInSuspense) {
891
+ element = createElement3(
892
+ Suspense,
893
+ {
894
+ key,
895
+ fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : createElement3(wrapInSuspense.fallback)
896
+ },
897
+ createElement3(resolvedComponent, componentProps)
898
+ );
899
+ } else {
900
+ element = createElement3(resolvedComponent, { ...componentProps, key });
901
+ }
865
902
  let tagElement = null;
866
903
  if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
867
904
  tagElement = createElement3(ContextUpdateTransfer, {
@@ -935,7 +972,7 @@ import {
935
972
  DefaultUniformClientContext,
936
973
  UniformScript
937
974
  } from "@uniformdev/canvas-next-rsc-client";
938
- import { Suspense } from "react";
975
+ import { Suspense as Suspense2 } from "react";
939
976
  import React6 from "react";
940
977
  var UniformContext = async ({
941
978
  clientContextComponent,
@@ -956,7 +993,7 @@ var UniformContext = async ({
956
993
  disableDevTools,
957
994
  defaultConsent
958
995
  }
959
- ), /* @__PURE__ */ React6.createElement(Suspense, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
996
+ ), /* @__PURE__ */ React6.createElement(Suspense2, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
960
997
  };
961
998
 
962
999
  // src/components/UniformPlayground.tsx
package/dist/index.js CHANGED
@@ -221,6 +221,7 @@ var getCanvasClient = (options) => {
221
221
  apiHost: env.getApiHost(),
222
222
  apiKey: env.getApiKey(),
223
223
  edgeApiHost: env.getEdgeApiHost(),
224
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
224
225
  fetch: (req, init) => {
225
226
  let requestedUrl;
226
227
  if (typeof req === "string") {
@@ -252,7 +253,7 @@ var getCanvasClient = (options) => {
252
253
  cache,
253
254
  headers: {
254
255
  ...init == null ? void 0 : init.headers,
255
- "x-bypass-cache": "true"
256
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
256
257
  },
257
258
  next: {
258
259
  revalidate
@@ -284,7 +285,7 @@ var getManifestClient = (options) => {
284
285
  ...init,
285
286
  headers: {
286
287
  ...init == null ? void 0 : init.headers,
287
- "x-bypass-cache": "true"
288
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
288
289
  },
289
290
  cache,
290
291
  next: {
@@ -325,7 +326,7 @@ var getProjectMapClient = (options) => {
325
326
  ...init,
326
327
  headers: {
327
328
  ...init == null ? void 0 : init.headers,
328
- "x-bypass-cache": "true"
329
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
329
330
  },
330
331
  cache,
331
332
  next: {
@@ -353,6 +354,7 @@ var getRouteClient = (options) => {
353
354
  projectId: env.getProjectId(),
354
355
  apiKey: env.getApiKey(),
355
356
  edgeApiHost: env.getEdgeApiHost(),
357
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
356
358
  fetch: (req, init) => {
357
359
  let requestedUrl;
358
360
  if (typeof req === "string") {
@@ -380,7 +382,7 @@ var getRouteClient = (options) => {
380
382
  ...init,
381
383
  headers: {
382
384
  ...init == null ? void 0 : init.headers,
383
- "x-bypass-cache": "true"
385
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
384
386
  },
385
387
  cache,
386
388
  next: {
@@ -616,6 +618,7 @@ var PersonalizeClientWrapper = (props) => {
616
618
  // src/components/PersonalizeServer.ts
617
619
  var import_canvas5 = require("@uniformdev/canvas");
618
620
  var import_canvas_next_rsc_shared4 = require("@uniformdev/canvas-next-rsc-shared");
621
+ var import_cache = require("next/cache");
619
622
  var import_react5 = require("react");
620
623
 
621
624
  // src/components/ContextPersonalizationTransfer.tsx
@@ -627,15 +630,19 @@ var ContextPersonalizationTransfer = ({ event }) => {
627
630
 
628
631
  // src/components/PersonalizeServer.ts
629
632
  var PersonalizeServer = (props) => {
630
- var _a;
633
+ var _a, _b;
634
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.personalizationSuspense) {
635
+ (0, import_cache.unstable_noStore)();
636
+ }
631
637
  const { indexes, event } = (0, import_canvas_next_rsc_shared4.runPersonalization)(props);
632
- const slot = (_a = props.slots) == null ? void 0 : _a[import_canvas5.CANVAS_PERSONALIZE_SLOT];
638
+ const slot = (_b = props.slots) == null ? void 0 : _b[import_canvas5.CANVAS_PERSONALIZE_SLOT];
633
639
  const components = indexes.map((index) => {
634
640
  const component = slot.items[index];
635
641
  return component;
636
642
  });
637
643
  const eventElement = (0, import_react5.createElement)(ContextPersonalizationTransfer, {
638
- event
644
+ event,
645
+ key: `${props.slotName}-${props.slotIndex}-personalization-transfer`
639
646
  });
640
647
  return (0, import_react5.createElement)(import_react5.Fragment, void 0, [...components, eventElement]);
641
648
  };
@@ -643,6 +650,7 @@ var PersonalizeServer = (props) => {
643
650
  // src/components/TestServer.ts
644
651
  var import_canvas6 = require("@uniformdev/canvas");
645
652
  var import_canvas_next_rsc_shared5 = require("@uniformdev/canvas-next-rsc-shared");
653
+ var import_cache2 = require("next/cache");
646
654
  var import_react7 = require("react");
647
655
 
648
656
  // src/components/ContextTestTransfer.tsx
@@ -653,17 +661,24 @@ var ContextTestTransfer = ({ event }) => {
653
661
  };
654
662
 
655
663
  // src/components/TestServer.ts
656
- var TestServer = (props) => {
657
- var _a, _b, _c, _d;
664
+ var TestServer = async (props) => {
665
+ var _a, _b, _c, _d, _e;
666
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
667
+ (0, import_cache2.unstable_noStore)();
668
+ }
658
669
  const { contextInstance, test } = props;
659
- const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
670
+ const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
660
671
  if (!isTestDefined && process.env.NODE_ENV !== "production") {
661
672
  console.warn(`Test "${test}" is not defined in Uniform manifest.`);
662
673
  }
663
674
  const { index, event } = (0, import_canvas_next_rsc_shared5.runTest)(props);
664
- 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;
675
+ if (index === null || event === null) {
676
+ return null;
677
+ }
678
+ const component = typeof index === "number" ? (_e = (_d = (_c = props.slots) == null ? void 0 : _c[import_canvas6.CANVAS_TEST_SLOT]) == null ? void 0 : _d.items[index]) != null ? _e : null : null;
665
679
  const eventElement = (0, import_react7.createElement)(ContextTestTransfer, {
666
- event
680
+ event,
681
+ key: `${props.slotName}-${props.slotIndex}-server-transfer`
667
682
  });
668
683
  return (0, import_react7.createElement)(import_react7.Fragment, void 0, [component, eventElement]);
669
684
  };
@@ -767,19 +782,24 @@ var isServerComponent = ({
767
782
  };
768
783
  var resolveSystemComponent = ({
769
784
  component,
770
- serverContext
785
+ server
771
786
  }) => {
772
- const server = isServerComponent({
773
- component,
774
- serverContext
775
- });
787
+ var _a, _b;
788
+ const config = getServerConfig();
789
+ let resolved = null;
790
+ let suspense = void 0;
776
791
  if (component.type === import_canvas7.CANVAS_PERSONALIZE_TYPE) {
777
- return server ? PersonalizeServer : PersonalizeClientWrapper;
792
+ resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
793
+ suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
778
794
  }
779
795
  if (component.type === import_canvas7.CANVAS_TEST_TYPE) {
780
- return server ? TestServer : import_canvas_next_rsc_client6.TestClient;
796
+ resolved = server ? TestServer : import_canvas_next_rsc_client6.TestClient;
797
+ suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
781
798
  }
782
- return null;
799
+ return {
800
+ component: resolved,
801
+ suspense
802
+ };
783
803
  };
784
804
  var resolveSlots = ({
785
805
  component,
@@ -856,11 +876,15 @@ var resolveComponents = ({
856
876
  component,
857
877
  serverContext
858
878
  });
859
- const systemComponent = resolveSystemComponent({
879
+ const { component: systemComponent, suspense: systemSuspense } = resolveSystemComponent({
860
880
  component,
861
- serverContext
881
+ server: isServer
862
882
  });
863
- const { component: regularComponent, includeContext } = resolveComponent({ component }) || {
883
+ const {
884
+ component: regularComponent,
885
+ includeContext,
886
+ suspense: componentSuspense
887
+ } = resolveComponent({ component }) || {
864
888
  component: null
865
889
  };
866
890
  if (!systemComponent && !regularComponent) {
@@ -875,10 +899,11 @@ var resolveComponents = ({
875
899
  mode
876
900
  });
877
901
  const resolvedComponent = systemComponent || regularComponent;
902
+ const wrapInSuspense = systemSuspense || componentSuspense;
878
903
  const parameters = (_a = component.parameters) != null ? _a : {};
879
904
  const enrichmentTags = (_b = parameters[import_canvas7.CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
905
+ const key = `${slotName}-${componentIndex}-component`;
880
906
  const componentProps = {
881
- key: `${slotName}-${componentIndex}-component`,
882
907
  ...Object.keys(parameters).reduce((acc, cur) => {
883
908
  acc[cur] = parameters[cur].value;
884
909
  return acc;
@@ -890,7 +915,19 @@ var resolveComponents = ({
890
915
  slotName,
891
916
  slotIndex: isRoot ? void 0 : componentIndex
892
917
  };
893
- const element = (0, import_react8.createElement)(resolvedComponent, componentProps);
918
+ let element = null;
919
+ if (wrapInSuspense) {
920
+ element = (0, import_react8.createElement)(
921
+ import_react8.Suspense,
922
+ {
923
+ key,
924
+ fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : (0, import_react8.createElement)(wrapInSuspense.fallback)
925
+ },
926
+ (0, import_react8.createElement)(resolvedComponent, componentProps)
927
+ );
928
+ } else {
929
+ element = (0, import_react8.createElement)(resolvedComponent, { ...componentProps, key });
930
+ }
894
931
  let tagElement = null;
895
932
  if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
896
933
  tagElement = (0, import_react8.createElement)(ContextUpdateTransfer, {
package/dist/index.mjs CHANGED
@@ -174,6 +174,7 @@ var getCanvasClient = (options) => {
174
174
  apiHost: env.getApiHost(),
175
175
  apiKey: env.getApiKey(),
176
176
  edgeApiHost: env.getEdgeApiHost(),
177
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
177
178
  fetch: (req, init) => {
178
179
  let requestedUrl;
179
180
  if (typeof req === "string") {
@@ -205,7 +206,7 @@ var getCanvasClient = (options) => {
205
206
  cache,
206
207
  headers: {
207
208
  ...init == null ? void 0 : init.headers,
208
- "x-bypass-cache": "true"
209
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
209
210
  },
210
211
  next: {
211
212
  revalidate
@@ -237,7 +238,7 @@ var getManifestClient = (options) => {
237
238
  ...init,
238
239
  headers: {
239
240
  ...init == null ? void 0 : init.headers,
240
- "x-bypass-cache": "true"
241
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
241
242
  },
242
243
  cache,
243
244
  next: {
@@ -278,7 +279,7 @@ var getProjectMapClient = (options) => {
278
279
  ...init,
279
280
  headers: {
280
281
  ...init == null ? void 0 : init.headers,
281
- "x-bypass-cache": "true"
282
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
282
283
  },
283
284
  cache,
284
285
  next: {
@@ -306,6 +307,7 @@ var getRouteClient = (options) => {
306
307
  projectId: env.getProjectId(),
307
308
  apiKey: env.getApiKey(),
308
309
  edgeApiHost: env.getEdgeApiHost(),
310
+ disableSWR: typeof options.cache.disableSWR !== "undefined" ? options.cache.disableSWR : true,
309
311
  fetch: (req, init) => {
310
312
  let requestedUrl;
311
313
  if (typeof req === "string") {
@@ -333,7 +335,7 @@ var getRouteClient = (options) => {
333
335
  ...init,
334
336
  headers: {
335
337
  ...init == null ? void 0 : init.headers,
336
- "x-bypass-cache": "true"
338
+ "x-bypass-cache": typeof options.cache.bypassCache !== "undefined" ? options.cache.bypassCache.toString() : "false"
337
339
  },
338
340
  cache,
339
341
  next: {
@@ -420,7 +422,7 @@ import {
420
422
  import { PureContextualEditingComponentWrapper } from "@uniformdev/canvas-react/core";
421
423
  import { cookies as cookies2, headers } from "next/headers";
422
424
  import { notFound, redirect } from "next/navigation";
423
- import { createElement as createElement3, Fragment as Fragment3 } from "react";
425
+ import { createElement as createElement3, Fragment as Fragment3, Suspense } from "react";
424
426
 
425
427
  // src/context/createServerUniformContext.ts
426
428
  import {
@@ -585,6 +587,7 @@ var PersonalizeClientWrapper = (props) => {
585
587
  // src/components/PersonalizeServer.ts
586
588
  import { CANVAS_PERSONALIZE_SLOT } from "@uniformdev/canvas";
587
589
  import { runPersonalization as runPersonalization2 } from "@uniformdev/canvas-next-rsc-shared";
590
+ import { unstable_noStore as noStore } from "next/cache";
588
591
  import { createElement, Fragment } from "react";
589
592
 
590
593
  // src/components/ContextPersonalizationTransfer.tsx
@@ -596,15 +599,19 @@ var ContextPersonalizationTransfer = ({ event }) => {
596
599
 
597
600
  // src/components/PersonalizeServer.ts
598
601
  var PersonalizeServer = (props) => {
599
- var _a;
602
+ var _a, _b;
603
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.personalizationSuspense) {
604
+ noStore();
605
+ }
600
606
  const { indexes, event } = runPersonalization2(props);
601
- const slot = (_a = props.slots) == null ? void 0 : _a[CANVAS_PERSONALIZE_SLOT];
607
+ const slot = (_b = props.slots) == null ? void 0 : _b[CANVAS_PERSONALIZE_SLOT];
602
608
  const components = indexes.map((index) => {
603
609
  const component = slot.items[index];
604
610
  return component;
605
611
  });
606
612
  const eventElement = createElement(ContextPersonalizationTransfer, {
607
- event
613
+ event,
614
+ key: `${props.slotName}-${props.slotIndex}-personalization-transfer`
608
615
  });
609
616
  return createElement(Fragment, void 0, [...components, eventElement]);
610
617
  };
@@ -614,6 +621,7 @@ import { CANVAS_TEST_SLOT } from "@uniformdev/canvas";
614
621
  import {
615
622
  runTest
616
623
  } from "@uniformdev/canvas-next-rsc-shared";
624
+ import { unstable_noStore as noStore2 } from "next/cache";
617
625
  import { createElement as createElement2, Fragment as Fragment2 } from "react";
618
626
 
619
627
  // src/components/ContextTestTransfer.tsx
@@ -624,17 +632,24 @@ var ContextTestTransfer = ({ event }) => {
624
632
  };
625
633
 
626
634
  // src/components/TestServer.ts
627
- var TestServer = (props) => {
628
- var _a, _b, _c, _d;
635
+ var TestServer = async (props) => {
636
+ var _a, _b, _c, _d, _e;
637
+ if ((_a = getServerConfig().ppr) == null ? void 0 : _a.testSuspense) {
638
+ noStore2();
639
+ }
629
640
  const { contextInstance, test } = props;
630
- const isTestDefined = Boolean((_a = contextInstance.manifest.data.project.test) == null ? void 0 : _a[test]);
641
+ const isTestDefined = Boolean((_b = contextInstance.manifest.data.project.test) == null ? void 0 : _b[test]);
631
642
  if (!isTestDefined && process.env.NODE_ENV !== "production") {
632
643
  console.warn(`Test "${test}" is not defined in Uniform manifest.`);
633
644
  }
634
645
  const { index, event } = runTest(props);
635
- 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;
646
+ if (index === null || event === null) {
647
+ return null;
648
+ }
649
+ const component = typeof index === "number" ? (_e = (_d = (_c = props.slots) == null ? void 0 : _c[CANVAS_TEST_SLOT]) == null ? void 0 : _d.items[index]) != null ? _e : null : null;
636
650
  const eventElement = createElement2(ContextTestTransfer, {
637
- event
651
+ event,
652
+ key: `${props.slotName}-${props.slotIndex}-server-transfer`
638
653
  });
639
654
  return createElement2(Fragment2, void 0, [component, eventElement]);
640
655
  };
@@ -738,19 +753,24 @@ var isServerComponent = ({
738
753
  };
739
754
  var resolveSystemComponent = ({
740
755
  component,
741
- serverContext
756
+ server
742
757
  }) => {
743
- const server = isServerComponent({
744
- component,
745
- serverContext
746
- });
758
+ var _a, _b;
759
+ const config = getServerConfig();
760
+ let resolved = null;
761
+ let suspense = void 0;
747
762
  if (component.type === CANVAS_PERSONALIZE_TYPE) {
748
- return server ? PersonalizeServer : PersonalizeClientWrapper;
763
+ resolved = server ? PersonalizeServer : PersonalizeClientWrapper;
764
+ suspense = server && ((_a = config.ppr) == null ? void 0 : _a.personalizationSuspense);
749
765
  }
750
766
  if (component.type === CANVAS_TEST_TYPE) {
751
- return server ? TestServer : TestClient;
767
+ resolved = server ? TestServer : TestClient;
768
+ suspense = server && ((_b = config.ppr) == null ? void 0 : _b.testSuspense);
752
769
  }
753
- return null;
770
+ return {
771
+ component: resolved,
772
+ suspense
773
+ };
754
774
  };
755
775
  var resolveSlots = ({
756
776
  component,
@@ -827,11 +847,15 @@ var resolveComponents = ({
827
847
  component,
828
848
  serverContext
829
849
  });
830
- const systemComponent = resolveSystemComponent({
850
+ const { component: systemComponent, suspense: systemSuspense } = resolveSystemComponent({
831
851
  component,
832
- serverContext
852
+ server: isServer
833
853
  });
834
- const { component: regularComponent, includeContext } = resolveComponent({ component }) || {
854
+ const {
855
+ component: regularComponent,
856
+ includeContext,
857
+ suspense: componentSuspense
858
+ } = resolveComponent({ component }) || {
835
859
  component: null
836
860
  };
837
861
  if (!systemComponent && !regularComponent) {
@@ -846,10 +870,11 @@ var resolveComponents = ({
846
870
  mode
847
871
  });
848
872
  const resolvedComponent = systemComponent || regularComponent;
873
+ const wrapInSuspense = systemSuspense || componentSuspense;
849
874
  const parameters = (_a = component.parameters) != null ? _a : {};
850
875
  const enrichmentTags = (_b = parameters[CANVAS_ENRICHMENT_TAG_PARAM]) == null ? void 0 : _b.value;
876
+ const key = `${slotName}-${componentIndex}-component`;
851
877
  const componentProps = {
852
- key: `${slotName}-${componentIndex}-component`,
853
878
  ...Object.keys(parameters).reduce((acc, cur) => {
854
879
  acc[cur] = parameters[cur].value;
855
880
  return acc;
@@ -861,7 +886,19 @@ var resolveComponents = ({
861
886
  slotName,
862
887
  slotIndex: isRoot ? void 0 : componentIndex
863
888
  };
864
- const element = createElement3(resolvedComponent, componentProps);
889
+ let element = null;
890
+ if (wrapInSuspense) {
891
+ element = createElement3(
892
+ Suspense,
893
+ {
894
+ key,
895
+ fallback: typeof wrapInSuspense === "boolean" || typeof (wrapInSuspense == null ? void 0 : wrapInSuspense.fallback) === "undefined" ? void 0 : createElement3(wrapInSuspense.fallback)
896
+ },
897
+ createElement3(resolvedComponent, componentProps)
898
+ );
899
+ } else {
900
+ element = createElement3(resolvedComponent, { ...componentProps, key });
901
+ }
865
902
  let tagElement = null;
866
903
  if (enrichmentTags == null ? void 0 : enrichmentTags.length) {
867
904
  tagElement = createElement3(ContextUpdateTransfer, {
@@ -935,7 +972,7 @@ import {
935
972
  DefaultUniformClientContext,
936
973
  UniformScript
937
974
  } from "@uniformdev/canvas-next-rsc-client";
938
- import { Suspense } from "react";
975
+ import { Suspense as Suspense2 } from "react";
939
976
  import React6 from "react";
940
977
  var UniformContext = async ({
941
978
  clientContextComponent,
@@ -956,7 +993,7 @@ var UniformContext = async ({
956
993
  disableDevTools,
957
994
  defaultConsent
958
995
  }
959
- ), /* @__PURE__ */ React6.createElement(Suspense, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
996
+ ), /* @__PURE__ */ React6.createElement(Suspense2, { fallback: /* @__PURE__ */ React6.createElement(React6.Fragment, null) }, /* @__PURE__ */ React6.createElement(UniformScript, null)));
960
997
  };
961
998
 
962
999
  // src/components/UniformPlayground.tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc",
3
- "version": "19.147.1-alpha.1+3b71376893",
3
+ "version": "19.147.1-alpha.5+fd42f9399d",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "scripts": {
6
6
  "build": "tsup",
@@ -56,20 +56,20 @@
56
56
  "@types/node": "^20.0.0",
57
57
  "@types/react": "18.2.40",
58
58
  "eslint": "8.57.0",
59
- "next": "^13.4.12",
59
+ "next": "^14.0.0",
60
60
  "react": "18.2.0",
61
61
  "react-dom": "18.2.0"
62
62
  },
63
63
  "dependencies": {
64
- "@uniformdev/canvas": "19.147.1-alpha.1+3b71376893",
65
- "@uniformdev/canvas-next-rsc-client": "^19.147.1-alpha.1+3b71376893",
66
- "@uniformdev/canvas-next-rsc-shared": "^19.147.1-alpha.1+3b71376893",
67
- "@uniformdev/canvas-react": "19.147.1-alpha.1+3b71376893",
68
- "@uniformdev/context": "19.147.1-alpha.1+3b71376893",
69
- "@uniformdev/project-map": "19.147.1-alpha.1+3b71376893",
70
- "@uniformdev/redirect": "19.147.1-alpha.1+3b71376893",
71
- "@uniformdev/richtext": "19.147.1-alpha.1+3b71376893",
72
- "@uniformdev/webhooks": "19.147.1-alpha.1+3b71376893",
64
+ "@uniformdev/canvas": "19.147.1-alpha.5+fd42f9399d",
65
+ "@uniformdev/canvas-next-rsc-client": "^19.147.1-alpha.5+fd42f9399d",
66
+ "@uniformdev/canvas-next-rsc-shared": "^19.147.1-alpha.5+fd42f9399d",
67
+ "@uniformdev/canvas-react": "19.147.1-alpha.5+fd42f9399d",
68
+ "@uniformdev/context": "19.147.1-alpha.5+fd42f9399d",
69
+ "@uniformdev/project-map": "19.147.1-alpha.5+fd42f9399d",
70
+ "@uniformdev/redirect": "19.147.1-alpha.5+fd42f9399d",
71
+ "@uniformdev/richtext": "19.147.1-alpha.5+fd42f9399d",
72
+ "@uniformdev/webhooks": "19.147.1-alpha.5+fd42f9399d",
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": "3b71376893147a07f47c6118425304f96d099067"
89
+ "gitHead": "fd42f9399d22a39666b01163b53c2eab646081d2"
90
90
  }