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

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { CanvasClient, RouteClient, ResolvedRouteGetResponse, RouteGetParameters } from '@uniformdev/canvas';
1
+ import { CanvasClient, RouteClient, ResolvedRouteGetResponse, CompositionGetBySlugParameters, RouteGetParameters } from '@uniformdev/canvas';
2
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';
@@ -243,7 +243,7 @@ declare const isIncontextEditingEnabled: ({ searchParams, }: {
243
243
  declare const isOnVercelPreviewEnvironment: () => boolean;
244
244
  declare const isDevelopmentEnvironment: () => boolean;
245
245
 
246
- type RetrieveRouteOptions = PageParameters & {
246
+ type RetrieveCommonOptions = {
247
247
  /**
248
248
  * If true, the manifest will not be prefetched.
249
249
  *
@@ -251,7 +251,17 @@ type RetrieveRouteOptions = PageParameters & {
251
251
  */
252
252
  skipPrefetch?: boolean;
253
253
  };
254
+ type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
255
+ type RetrieveSlugOptions = Pick<CompositionGetBySlugParameters, 'slug' | 'locale' | 'releaseId' | 'versionId'> & {
256
+ /**
257
+ * The searchParams object from Next.js router. Used for signal evaluation.
258
+ */
259
+ searchParams?: {
260
+ [key: string]: string | undefined;
261
+ };
262
+ } & RetrieveCommonOptions;
254
263
  type RetrieveRouteFetchOptions = Omit<RouteGetParameters, 'projectId' | 'path' | 'withComponentIDs' | 'withContentSourceMap' | 'state'>;
264
+ declare const retrieveCompositionBySlug: ({ slug, searchParams, skipPrefetch, locale, releaseId, versionId, }: RetrieveSlugOptions) => Promise<ResolvedRouteGetResponse>;
255
265
  declare const retrieveRoute: ({ params, searchParams, skipPrefetch }: RetrieveRouteOptions, fetchOptions?: RetrieveRouteFetchOptions) => Promise<ResolvedRouteGetResponse>;
256
266
 
257
- export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
267
+ export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveCompositionBySlug, retrieveRoute };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CanvasClient, RouteClient, ResolvedRouteGetResponse, RouteGetParameters } from '@uniformdev/canvas';
1
+ import { CanvasClient, RouteClient, ResolvedRouteGetResponse, CompositionGetBySlugParameters, RouteGetParameters } from '@uniformdev/canvas';
2
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';
@@ -243,7 +243,7 @@ declare const isIncontextEditingEnabled: ({ searchParams, }: {
243
243
  declare const isOnVercelPreviewEnvironment: () => boolean;
244
244
  declare const isDevelopmentEnvironment: () => boolean;
245
245
 
246
- type RetrieveRouteOptions = PageParameters & {
246
+ type RetrieveCommonOptions = {
247
247
  /**
248
248
  * If true, the manifest will not be prefetched.
249
249
  *
@@ -251,7 +251,17 @@ type RetrieveRouteOptions = PageParameters & {
251
251
  */
252
252
  skipPrefetch?: boolean;
253
253
  };
254
+ type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
255
+ type RetrieveSlugOptions = Pick<CompositionGetBySlugParameters, 'slug' | 'locale' | 'releaseId' | 'versionId'> & {
256
+ /**
257
+ * The searchParams object from Next.js router. Used for signal evaluation.
258
+ */
259
+ searchParams?: {
260
+ [key: string]: string | undefined;
261
+ };
262
+ } & RetrieveCommonOptions;
254
263
  type RetrieveRouteFetchOptions = Omit<RouteGetParameters, 'projectId' | 'path' | 'withComponentIDs' | 'withContentSourceMap' | 'state'>;
264
+ declare const retrieveCompositionBySlug: ({ slug, searchParams, skipPrefetch, locale, releaseId, versionId, }: RetrieveSlugOptions) => Promise<ResolvedRouteGetResponse>;
255
265
  declare const retrieveRoute: ({ params, searchParams, skipPrefetch }: RetrieveRouteOptions, fetchOptions?: RetrieveRouteFetchOptions) => Promise<ResolvedRouteGetResponse>;
256
266
 
257
- export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveRoute };
267
+ export { ContextUpdateTransfer, type ContextUpdateTransferProps, type CreateServerUniformContextProps, type CreateStaticParamsOptions, type GetCanvasClientOptions, type GetManifestClientOptions, type GetProjectMapClientOptions, type GetRouteClientOptions, UniformCompositionProps, UniformContext, type UniformContextProps, UniformPlayground, type UniformPlaygroundProps, createServerUniformContext, createStaticParams, generateStaticParams, getCanvasClient, getDefaultCanvasClient, getDefaultManifestClient, getDefaultProjectMapClient, getDefaultRouteClient, getManifest, getManifestClient, getProjectMapClient, getRouteClient, isDevelopmentEnvironment, isDraftModeEnabled, isIncontextEditingEnabled, isOnVercelPreviewEnvironment, retrieveCompositionBySlug, retrieveRoute };
package/dist/index.esm.js CHANGED
@@ -460,13 +460,62 @@ import {
460
460
  } from "@uniformdev/canvas";
461
461
  import { getBaseUrl, resolvePath } from "@uniformdev/canvas-next-rsc-shared";
462
462
  import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
463
+ var retrieveCompositionBySlug = async ({
464
+ slug,
465
+ searchParams,
466
+ skipPrefetch,
467
+ locale,
468
+ releaseId,
469
+ versionId
470
+ }) => {
471
+ var _a;
472
+ if (!skipPrefetch) {
473
+ void getManifest({
474
+ searchParams
475
+ });
476
+ }
477
+ let result;
478
+ const states = determineState({
479
+ searchParams
480
+ });
481
+ for (let i = 0; i < states.length; i++) {
482
+ const state = states[i];
483
+ const canvasClient = getDefaultCanvasClient({
484
+ searchParams
485
+ });
486
+ try {
487
+ const composition = await canvasClient.getCompositionBySlug({
488
+ slug,
489
+ state,
490
+ withComponentIDs: true,
491
+ withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
492
+ locale,
493
+ releaseId,
494
+ versionId
495
+ });
496
+ result = {
497
+ type: "composition",
498
+ compositionApiResponse: composition,
499
+ matchedRoute: "slug"
500
+ };
501
+ } catch (e) {
502
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
503
+ }
504
+ if ((result == null ? void 0 : result.type) !== "notFound") {
505
+ break;
506
+ }
507
+ }
508
+ return result || {
509
+ type: "notFound"
510
+ };
511
+ };
463
512
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
464
513
  if (!skipPrefetch) {
465
514
  void getManifest({
466
515
  searchParams
467
516
  });
468
517
  }
469
- const { type, value } = resolvePath({
518
+ const { value } = resolvePath({
470
519
  params
471
520
  });
472
521
  const states = determineState({
@@ -475,34 +524,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
475
524
  let result;
476
525
  for (let i = 0; i < states.length; i++) {
477
526
  const state = states[i];
478
- if (type === "path") {
479
- try {
480
- result = await retrieveRouteByPath({
481
- path: value,
482
- state,
483
- searchParams,
484
- fetchOptions
485
- });
486
- } catch (e) {
487
- console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
488
- }
489
- } else if (type === "slug") {
490
- const canvasClient = getDefaultCanvasClient({
491
- searchParams
527
+ try {
528
+ result = await retrieveRouteByPath({
529
+ path: value,
530
+ state,
531
+ searchParams,
532
+ fetchOptions
492
533
  });
493
- try {
494
- const composition = await canvasClient.getCompositionBySlug({
495
- slug: value,
496
- state
497
- });
498
- result = {
499
- type: "composition",
500
- compositionApiResponse: composition,
501
- matchedRoute: "slug"
502
- };
503
- } catch (e) {
504
- console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
505
- }
534
+ } catch (e) {
535
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
506
536
  }
507
537
  if ((result == null ? void 0 : result.type) !== "notFound") {
508
538
  break;
@@ -1070,5 +1100,6 @@ export {
1070
1100
  isIncontextEditingEnabled,
1071
1101
  isOnVercelPreviewEnvironment,
1072
1102
  resolveComposition,
1103
+ retrieveCompositionBySlug,
1073
1104
  retrieveRoute
1074
1105
  };
package/dist/index.js CHANGED
@@ -51,6 +51,7 @@ __export(src_exports, {
51
51
  isIncontextEditingEnabled: () => isIncontextEditingEnabled,
52
52
  isOnVercelPreviewEnvironment: () => isOnVercelPreviewEnvironment,
53
53
  resolveComposition: () => resolveComposition,
54
+ retrieveCompositionBySlug: () => retrieveCompositionBySlug,
54
55
  retrieveRoute: () => retrieveRoute
55
56
  });
56
57
  module.exports = __toCommonJS(src_exports);
@@ -491,13 +492,62 @@ var createServerUniformContextFromManifest = async (options) => {
491
492
  var import_canvas4 = require("@uniformdev/canvas");
492
493
  var import_canvas_next_rsc_shared2 = require("@uniformdev/canvas-next-rsc-shared");
493
494
  var import_redirect = require("@uniformdev/redirect");
495
+ var retrieveCompositionBySlug = async ({
496
+ slug,
497
+ searchParams,
498
+ skipPrefetch,
499
+ locale,
500
+ releaseId,
501
+ versionId
502
+ }) => {
503
+ var _a;
504
+ if (!skipPrefetch) {
505
+ void getManifest({
506
+ searchParams
507
+ });
508
+ }
509
+ let result;
510
+ const states = determineState({
511
+ searchParams
512
+ });
513
+ for (let i = 0; i < states.length; i++) {
514
+ const state = states[i];
515
+ const canvasClient = getDefaultCanvasClient({
516
+ searchParams
517
+ });
518
+ try {
519
+ const composition = await canvasClient.getCompositionBySlug({
520
+ slug,
521
+ state,
522
+ withComponentIDs: true,
523
+ withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
524
+ locale,
525
+ releaseId,
526
+ versionId
527
+ });
528
+ result = {
529
+ type: "composition",
530
+ compositionApiResponse: composition,
531
+ matchedRoute: "slug"
532
+ };
533
+ } catch (e) {
534
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
535
+ }
536
+ if ((result == null ? void 0 : result.type) !== "notFound") {
537
+ break;
538
+ }
539
+ }
540
+ return result || {
541
+ type: "notFound"
542
+ };
543
+ };
494
544
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
495
545
  if (!skipPrefetch) {
496
546
  void getManifest({
497
547
  searchParams
498
548
  });
499
549
  }
500
- const { type, value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
550
+ const { value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
501
551
  params
502
552
  });
503
553
  const states = determineState({
@@ -506,34 +556,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
506
556
  let result;
507
557
  for (let i = 0; i < states.length; i++) {
508
558
  const state = states[i];
509
- if (type === "path") {
510
- try {
511
- result = await retrieveRouteByPath({
512
- path: value,
513
- state,
514
- searchParams,
515
- fetchOptions
516
- });
517
- } catch (e) {
518
- console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
519
- }
520
- } else if (type === "slug") {
521
- const canvasClient = getDefaultCanvasClient({
522
- searchParams
559
+ try {
560
+ result = await retrieveRouteByPath({
561
+ path: value,
562
+ state,
563
+ searchParams,
564
+ fetchOptions
523
565
  });
524
- try {
525
- const composition = await canvasClient.getCompositionBySlug({
526
- slug: value,
527
- state
528
- });
529
- result = {
530
- type: "composition",
531
- compositionApiResponse: composition,
532
- matchedRoute: "slug"
533
- };
534
- } catch (e) {
535
- console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
536
- }
566
+ } catch (e) {
567
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
537
568
  }
538
569
  if ((result == null ? void 0 : result.type) !== "notFound") {
539
570
  break;
@@ -1097,5 +1128,6 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
1097
1128
  isIncontextEditingEnabled,
1098
1129
  isOnVercelPreviewEnvironment,
1099
1130
  resolveComposition,
1131
+ retrieveCompositionBySlug,
1100
1132
  retrieveRoute
1101
1133
  });
package/dist/index.mjs CHANGED
@@ -460,13 +460,62 @@ import {
460
460
  } from "@uniformdev/canvas";
461
461
  import { getBaseUrl, resolvePath } from "@uniformdev/canvas-next-rsc-shared";
462
462
  import { getTargetVariableExpandedUrl } from "@uniformdev/redirect";
463
+ var retrieveCompositionBySlug = async ({
464
+ slug,
465
+ searchParams,
466
+ skipPrefetch,
467
+ locale,
468
+ releaseId,
469
+ versionId
470
+ }) => {
471
+ var _a;
472
+ if (!skipPrefetch) {
473
+ void getManifest({
474
+ searchParams
475
+ });
476
+ }
477
+ let result;
478
+ const states = determineState({
479
+ searchParams
480
+ });
481
+ for (let i = 0; i < states.length; i++) {
482
+ const state = states[i];
483
+ const canvasClient = getDefaultCanvasClient({
484
+ searchParams
485
+ });
486
+ try {
487
+ const composition = await canvasClient.getCompositionBySlug({
488
+ slug,
489
+ state,
490
+ withComponentIDs: true,
491
+ withContentSourceMap: isOnVercelPreviewEnvironment() && ((_a = getServerConfig().experimental) == null ? void 0 : _a.vercelVisualEditing),
492
+ locale,
493
+ releaseId,
494
+ versionId
495
+ });
496
+ result = {
497
+ type: "composition",
498
+ compositionApiResponse: composition,
499
+ matchedRoute: "slug"
500
+ };
501
+ } catch (e) {
502
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
503
+ }
504
+ if ((result == null ? void 0 : result.type) !== "notFound") {
505
+ break;
506
+ }
507
+ }
508
+ return result || {
509
+ type: "notFound"
510
+ };
511
+ };
463
512
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
464
513
  if (!skipPrefetch) {
465
514
  void getManifest({
466
515
  searchParams
467
516
  });
468
517
  }
469
- const { type, value } = resolvePath({
518
+ const { value } = resolvePath({
470
519
  params
471
520
  });
472
521
  const states = determineState({
@@ -475,34 +524,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
475
524
  let result;
476
525
  for (let i = 0; i < states.length; i++) {
477
526
  const state = states[i];
478
- if (type === "path") {
479
- try {
480
- result = await retrieveRouteByPath({
481
- path: value,
482
- state,
483
- searchParams,
484
- fetchOptions
485
- });
486
- } catch (e) {
487
- console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
488
- }
489
- } else if (type === "slug") {
490
- const canvasClient = getDefaultCanvasClient({
491
- searchParams
527
+ try {
528
+ result = await retrieveRouteByPath({
529
+ path: value,
530
+ state,
531
+ searchParams,
532
+ fetchOptions
492
533
  });
493
- try {
494
- const composition = await canvasClient.getCompositionBySlug({
495
- slug: value,
496
- state
497
- });
498
- result = {
499
- type: "composition",
500
- compositionApiResponse: composition,
501
- matchedRoute: "slug"
502
- };
503
- } catch (e) {
504
- console.warn(`Failed to retrieve composition by slug: ${value} with state ${state}`, e);
505
- }
534
+ } catch (e) {
535
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
506
536
  }
507
537
  if ((result == null ? void 0 : result.type) !== "notFound") {
508
538
  break;
@@ -1070,5 +1100,6 @@ export {
1070
1100
  isIncontextEditingEnabled,
1071
1101
  isOnVercelPreviewEnvironment,
1072
1102
  resolveComposition,
1103
+ retrieveCompositionBySlug,
1073
1104
  retrieveRoute
1074
1105
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas-next-rsc",
3
- "version": "19.147.1-alpha.5+fd42f9399d",
3
+ "version": "19.147.1-alpha.7+28bb27296b",
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.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",
64
+ "@uniformdev/canvas": "19.147.1-alpha.7+28bb27296b",
65
+ "@uniformdev/canvas-next-rsc-client": "^19.147.1-alpha.7+28bb27296b",
66
+ "@uniformdev/canvas-next-rsc-shared": "^19.147.1-alpha.7+28bb27296b",
67
+ "@uniformdev/canvas-react": "19.147.1-alpha.7+28bb27296b",
68
+ "@uniformdev/context": "19.147.1-alpha.7+28bb27296b",
69
+ "@uniformdev/project-map": "19.147.1-alpha.7+28bb27296b",
70
+ "@uniformdev/redirect": "19.147.1-alpha.7+28bb27296b",
71
+ "@uniformdev/richtext": "19.147.1-alpha.7+28bb27296b",
72
+ "@uniformdev/webhooks": "19.147.1-alpha.7+28bb27296b",
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": "fd42f9399d22a39666b01163b53c2eab646081d2"
89
+ "gitHead": "28bb27296bbf7b66680eab516958fef155d59aa4"
90
90
  }