@uniformdev/uniform-nuxt 17.5.1-alpha.130 → 17.5.1-alpha.131

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/module.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "nuxt-uniform",
3
3
  "configKey": "uniform",
4
- "version": "17.5.1-alpha.130+3fac779b1"
4
+ "version": "17.5.1-alpha.131+1a06e230b"
5
5
  }
@@ -1,4 +1,4 @@
1
- import { type RootComponentInstance, type CompositionGetByNodePathParameters, type CompositionGetBySlugParameters, type CompositionGetByNodeIdParameters, type CompositionGetByIdParameters, type DataResolutionOption } from '@uniformdev/canvas';
1
+ import { type CompositionGetByIdParameters, type CompositionGetByNodeIdParameters, type CompositionGetByNodePathParameters, type CompositionGetBySlugParameters, type DataResolutionOption, type RootComponentInstance } from '@uniformdev/canvas';
2
2
  export declare const useUniformComposition: (options: (CompositionGetBySlugParameters | CompositionGetByIdParameters | CompositionGetByNodePathParameters | CompositionGetByNodeIdParameters) & DataResolutionOption & {
3
3
  enhance?: ((composition: RootComponentInstance) => RootComponentInstance | Promise<RootComponentInstance>) | undefined;
4
4
  }) => Promise<{
@@ -60,6 +60,7 @@ export declare const useUniformComposition: (options: (CompositionGetBySlugParam
60
60
  _id: string;
61
61
  _slug?: string | null | undefined;
62
62
  _name: string;
63
+ _branch: string;
63
64
  _dataResources?: {
64
65
  [key: string]: {
65
66
  type: string;
@@ -1,10 +1,10 @@
1
- import { useAsyncData, useNuxtApp } from "#app";
2
- import { watch, ref, toRaw } from "vue-demi";
3
1
  import {
4
2
  CANVAS_DRAFT_STATE,
5
3
  CANVAS_PUBLISHED_STATE
6
4
  } from "@uniformdev/canvas";
7
5
  import { useContextualEditing } from "@uniformdev/canvas-vue";
6
+ import { ref, toRaw, watch } from "vue-demi";
7
+ import { useAsyncData, useNuxtApp } from "#app";
8
8
  export const useUniformComposition = async (options) => {
9
9
  const { enhance = (c) => c, ...parameters } = options;
10
10
  const { $uniformCanvasClient, $preview: preview } = useNuxtApp();
@@ -28,37 +28,41 @@ export const useUniformComposition = async (options) => {
28
28
  `composition-${JSON.stringify(parameters)}`,
29
29
  async () => {
30
30
  const state = preview ? CANVAS_DRAFT_STATE : CANVAS_PUBLISHED_STATE;
31
+ let response = void 0;
31
32
  if ("slug" in parameters) {
32
- const slug = parameters.slug;
33
- return await canvasClient.getCompositionBySlug({
33
+ response = await canvasClient.getCompositionBySlug({
34
34
  ...parameters,
35
- slug,
36
35
  state
37
36
  });
38
37
  } else if ("compositionId" in parameters) {
39
- const compositionId = parameters.compositionId;
40
- return await canvasClient.getCompositionById({
38
+ response = await canvasClient.getCompositionById({
41
39
  ...parameters,
42
- compositionId,
43
40
  state
44
41
  });
45
42
  } else if ("projectMapNodeId" in parameters) {
46
- return await canvasClient.unstable_getCompositionByNodeId({
43
+ response = await canvasClient.unstable_getCompositionByNodeId({
47
44
  ...parameters,
48
45
  state
49
46
  });
50
47
  } else if ("projectMapNodePath" in parameters) {
51
- return await canvasClient.unstable_getCompositionByNodePath({
48
+ response = await canvasClient.unstable_getCompositionByNodePath({
52
49
  ...parameters,
53
50
  state
54
51
  });
55
52
  }
53
+ if (!response) {
54
+ throw new Error(
55
+ `Failed to fetch the composition with the given parameters: ${JSON.stringify(parameters)}`
56
+ );
57
+ }
58
+ const composition = await enhance(response.composition);
59
+ return { composition, response };
56
60
  }
57
61
  );
58
- activeComposition.value = data.value?.composition ? await enhance(data.value.composition) : void 0;
62
+ activeComposition.value = data.value?.composition;
59
63
  return {
60
64
  composition: activeComposition,
61
- fullResponse: data.value,
65
+ fullResponse: data.value?.response,
62
66
  pending,
63
67
  error
64
68
  };
@@ -19,7 +19,6 @@ import {
19
19
  import { toRaw, watch } from "vue-demi";
20
20
  import {
21
21
  defineNuxtPlugin,
22
- navigateTo,
23
22
  refreshNuxtData,
24
23
  useAsyncData,
25
24
  useCookie,
@@ -38,7 +37,7 @@ export default defineNuxtPlugin((nuxtApp) => {
38
37
  }
39
38
  try {
40
39
  const currentCompositionId = useState("currentCompositionId", () => "");
41
- const preview = setupPreview();
40
+ const preview = setupPreview(nuxtApp);
42
41
  const uniformContextData = setupContext(nuxtApp);
43
42
  const uniformCanvasClient = setupCanvas(nuxtApp);
44
43
  setupLivePreview(currentCompositionId, Boolean(preview));
@@ -114,7 +113,7 @@ function setupCanvas(nuxtApp) {
114
113
  });
115
114
  return uniformCanvasClient;
116
115
  }
117
- function setupPreview() {
116
+ function setupPreview(nuxtApp) {
118
117
  const router = useRouter();
119
118
  const route = useRoute();
120
119
  let preview;
@@ -125,16 +124,18 @@ function setupPreview() {
125
124
  compositionId: route.query.id
126
125
  };
127
126
  }
128
- if (preview && route.query.redirectedForPreview !== "true") {
129
- navigateTo({
130
- path: preview.slug,
131
- query: {
132
- ...route.query,
133
- redirectedForPreview: "true"
134
- },
135
- replace: true
136
- });
137
- }
127
+ nuxtApp.hook("app:beforeMount", () => {
128
+ if (preview && route.query.slug) {
129
+ router.push({
130
+ path: preview?.slug,
131
+ query: {
132
+ ...route.query,
133
+ slug: void 0,
134
+ id: void 0
135
+ }
136
+ });
137
+ }
138
+ });
138
139
  router.beforeEach((to, from, next) => {
139
140
  if (!next) {
140
141
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/uniform-nuxt",
3
- "version": "17.5.1-alpha.130+3fac779b1",
3
+ "version": "17.5.1-alpha.131+1a06e230b",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,10 +35,10 @@
35
35
  "@nuxt/module-builder": "0.2.1",
36
36
  "@nuxt/schema": "3.0.0",
37
37
  "@nuxtjs/eslint-config-typescript": "11.0.0",
38
- "@uniformdev/canvas": "^17.5.1-alpha.130+3fac779b1",
39
- "@uniformdev/canvas-vue": "^17.5.1-alpha.130+3fac779b1",
40
- "@uniformdev/context": "^17.5.1-alpha.130+3fac779b1",
41
- "@uniformdev/context-vue": "^17.5.1-alpha.130+3fac779b1",
38
+ "@uniformdev/canvas": "^17.5.1-alpha.131+1a06e230b",
39
+ "@uniformdev/canvas-vue": "^17.5.1-alpha.131+1a06e230b",
40
+ "@uniformdev/context": "^17.5.1-alpha.131+1a06e230b",
41
+ "@uniformdev/context-vue": "^17.5.1-alpha.131+1a06e230b",
42
42
  "esbuild": "0.15.15",
43
43
  "eslint": "latest",
44
44
  "nuxt": "3.0.0",
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "3fac779b1b42a1afeb05156cb51768a98573438f"
51
+ "gitHead": "1a06e230be7112298a5d5bf6d93bd66c9cbc39f6"
52
52
  }