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

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
@@ -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,21 @@ type RetrieveRouteOptions = PageParameters & {
251
251
  */
252
252
  skipPrefetch?: boolean;
253
253
  };
254
+ type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
255
+ type RetrieveSlugOptions = {
256
+ /**
257
+ * The slug of the composition to retrieve.
258
+ */
259
+ slug: string;
260
+ /**
261
+ * The searchParams object from Next.js router. Used for signal evaluation.
262
+ */
263
+ searchParams?: {
264
+ [key: string]: string | undefined;
265
+ };
266
+ } & RetrieveCommonOptions;
254
267
  type RetrieveRouteFetchOptions = Omit<RouteGetParameters, 'projectId' | 'path' | 'withComponentIDs' | 'withContentSourceMap' | 'state'>;
268
+ declare const retrieveCompositionBySlug: ({ slug, searchParams, skipPrefetch, }: RetrieveSlugOptions) => Promise<ResolvedRouteGetResponse>;
255
269
  declare const retrieveRoute: ({ params, searchParams, skipPrefetch }: RetrieveRouteOptions, fetchOptions?: RetrieveRouteFetchOptions) => Promise<ResolvedRouteGetResponse>;
256
270
 
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 };
271
+ 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
@@ -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,21 @@ type RetrieveRouteOptions = PageParameters & {
251
251
  */
252
252
  skipPrefetch?: boolean;
253
253
  };
254
+ type RetrieveRouteOptions = PageParameters & RetrieveCommonOptions;
255
+ type RetrieveSlugOptions = {
256
+ /**
257
+ * The slug of the composition to retrieve.
258
+ */
259
+ slug: string;
260
+ /**
261
+ * The searchParams object from Next.js router. Used for signal evaluation.
262
+ */
263
+ searchParams?: {
264
+ [key: string]: string | undefined;
265
+ };
266
+ } & RetrieveCommonOptions;
254
267
  type RetrieveRouteFetchOptions = Omit<RouteGetParameters, 'projectId' | 'path' | 'withComponentIDs' | 'withContentSourceMap' | 'state'>;
268
+ declare const retrieveCompositionBySlug: ({ slug, searchParams, skipPrefetch, }: RetrieveSlugOptions) => Promise<ResolvedRouteGetResponse>;
255
269
  declare const retrieveRoute: ({ params, searchParams, skipPrefetch }: RetrieveRouteOptions, fetchOptions?: RetrieveRouteFetchOptions) => Promise<ResolvedRouteGetResponse>;
256
270
 
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 };
271
+ 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,54 @@ 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
+ }) => {
468
+ if (!skipPrefetch) {
469
+ void getManifest({
470
+ searchParams
471
+ });
472
+ }
473
+ let result;
474
+ const states = determineState({
475
+ searchParams
476
+ });
477
+ for (let i = 0; i < states.length; i++) {
478
+ const state = states[i];
479
+ const canvasClient = getDefaultCanvasClient({
480
+ searchParams
481
+ });
482
+ try {
483
+ const composition = await canvasClient.getCompositionBySlug({
484
+ slug,
485
+ state,
486
+ withComponentIDs: true
487
+ });
488
+ result = {
489
+ type: "composition",
490
+ compositionApiResponse: composition,
491
+ matchedRoute: "slug"
492
+ };
493
+ } catch (e) {
494
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
495
+ }
496
+ if ((result == null ? void 0 : result.type) !== "notFound") {
497
+ break;
498
+ }
499
+ }
500
+ return result || {
501
+ type: "notFound"
502
+ };
503
+ };
463
504
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
464
505
  if (!skipPrefetch) {
465
506
  void getManifest({
466
507
  searchParams
467
508
  });
468
509
  }
469
- const { type, value } = resolvePath({
510
+ const { value } = resolvePath({
470
511
  params
471
512
  });
472
513
  const states = determineState({
@@ -475,34 +516,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
475
516
  let result;
476
517
  for (let i = 0; i < states.length; i++) {
477
518
  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
519
+ try {
520
+ result = await retrieveRouteByPath({
521
+ path: value,
522
+ state,
523
+ searchParams,
524
+ fetchOptions
492
525
  });
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
- }
526
+ } catch (e) {
527
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
506
528
  }
507
529
  if ((result == null ? void 0 : result.type) !== "notFound") {
508
530
  break;
@@ -1070,5 +1092,6 @@ export {
1070
1092
  isIncontextEditingEnabled,
1071
1093
  isOnVercelPreviewEnvironment,
1072
1094
  resolveComposition,
1095
+ retrieveCompositionBySlug,
1073
1096
  retrieveRoute
1074
1097
  };
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,54 @@ 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
+ }) => {
500
+ if (!skipPrefetch) {
501
+ void getManifest({
502
+ searchParams
503
+ });
504
+ }
505
+ let result;
506
+ const states = determineState({
507
+ searchParams
508
+ });
509
+ for (let i = 0; i < states.length; i++) {
510
+ const state = states[i];
511
+ const canvasClient = getDefaultCanvasClient({
512
+ searchParams
513
+ });
514
+ try {
515
+ const composition = await canvasClient.getCompositionBySlug({
516
+ slug,
517
+ state,
518
+ withComponentIDs: true
519
+ });
520
+ result = {
521
+ type: "composition",
522
+ compositionApiResponse: composition,
523
+ matchedRoute: "slug"
524
+ };
525
+ } catch (e) {
526
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
527
+ }
528
+ if ((result == null ? void 0 : result.type) !== "notFound") {
529
+ break;
530
+ }
531
+ }
532
+ return result || {
533
+ type: "notFound"
534
+ };
535
+ };
494
536
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
495
537
  if (!skipPrefetch) {
496
538
  void getManifest({
497
539
  searchParams
498
540
  });
499
541
  }
500
- const { type, value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
542
+ const { value } = (0, import_canvas_next_rsc_shared2.resolvePath)({
501
543
  params
502
544
  });
503
545
  const states = determineState({
@@ -506,34 +548,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
506
548
  let result;
507
549
  for (let i = 0; i < states.length; i++) {
508
550
  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
551
+ try {
552
+ result = await retrieveRouteByPath({
553
+ path: value,
554
+ state,
555
+ searchParams,
556
+ fetchOptions
523
557
  });
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
- }
558
+ } catch (e) {
559
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
537
560
  }
538
561
  if ((result == null ? void 0 : result.type) !== "notFound") {
539
562
  break;
@@ -1097,5 +1120,6 @@ var UniformPlayground = async ({ searchParams, ...rest }) => {
1097
1120
  isIncontextEditingEnabled,
1098
1121
  isOnVercelPreviewEnvironment,
1099
1122
  resolveComposition,
1123
+ retrieveCompositionBySlug,
1100
1124
  retrieveRoute
1101
1125
  });
package/dist/index.mjs CHANGED
@@ -460,13 +460,54 @@ 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
+ }) => {
468
+ if (!skipPrefetch) {
469
+ void getManifest({
470
+ searchParams
471
+ });
472
+ }
473
+ let result;
474
+ const states = determineState({
475
+ searchParams
476
+ });
477
+ for (let i = 0; i < states.length; i++) {
478
+ const state = states[i];
479
+ const canvasClient = getDefaultCanvasClient({
480
+ searchParams
481
+ });
482
+ try {
483
+ const composition = await canvasClient.getCompositionBySlug({
484
+ slug,
485
+ state,
486
+ withComponentIDs: true
487
+ });
488
+ result = {
489
+ type: "composition",
490
+ compositionApiResponse: composition,
491
+ matchedRoute: "slug"
492
+ };
493
+ } catch (e) {
494
+ console.warn(`Failed to retrieve composition by slug: ${slug} with state ${state}`, e);
495
+ }
496
+ if ((result == null ? void 0 : result.type) !== "notFound") {
497
+ break;
498
+ }
499
+ }
500
+ return result || {
501
+ type: "notFound"
502
+ };
503
+ };
463
504
  var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions) => {
464
505
  if (!skipPrefetch) {
465
506
  void getManifest({
466
507
  searchParams
467
508
  });
468
509
  }
469
- const { type, value } = resolvePath({
510
+ const { value } = resolvePath({
470
511
  params
471
512
  });
472
513
  const states = determineState({
@@ -475,34 +516,15 @@ var retrieveRoute = async ({ params, searchParams, skipPrefetch }, fetchOptions)
475
516
  let result;
476
517
  for (let i = 0; i < states.length; i++) {
477
518
  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
519
+ try {
520
+ result = await retrieveRouteByPath({
521
+ path: value,
522
+ state,
523
+ searchParams,
524
+ fetchOptions
492
525
  });
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
- }
526
+ } catch (e) {
527
+ console.warn(`Failed to retrieve route by path: ${value} with state ${state}`, e);
506
528
  }
507
529
  if ((result == null ? void 0 : result.type) !== "notFound") {
508
530
  break;
@@ -1070,5 +1092,6 @@ export {
1070
1092
  isIncontextEditingEnabled,
1071
1093
  isOnVercelPreviewEnvironment,
1072
1094
  resolveComposition,
1095
+ retrieveCompositionBySlug,
1073
1096
  retrieveRoute
1074
1097
  };
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.6+b883293105",
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.6+b883293105",
65
+ "@uniformdev/canvas-next-rsc-client": "^19.147.1-alpha.6+b883293105",
66
+ "@uniformdev/canvas-next-rsc-shared": "^19.147.1-alpha.6+b883293105",
67
+ "@uniformdev/canvas-react": "19.147.1-alpha.6+b883293105",
68
+ "@uniformdev/context": "19.147.1-alpha.6+b883293105",
69
+ "@uniformdev/project-map": "19.147.1-alpha.6+b883293105",
70
+ "@uniformdev/redirect": "19.147.1-alpha.6+b883293105",
71
+ "@uniformdev/richtext": "19.147.1-alpha.6+b883293105",
72
+ "@uniformdev/webhooks": "19.147.1-alpha.6+b883293105",
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": "b883293105d84f5b52f2d947957dac638c12c6f6"
90
90
  }