@dyrected/nuxt 2.5.59 → 2.5.61

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": "@dyrected/nuxt",
3
3
  "configKey": "dyrected",
4
- "version": "2.5.58"
4
+ "version": "2.5.60"
5
5
  }
package/dist/module.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineNuxtModule, createResolver, addServerHandler, addPlugin, addComponent, addImports, addTemplate, addServerPlugin } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, installModule, addServerHandler, addPlugin, addComponent, addImports, addTemplate, addServerPlugin } from '@nuxt/kit';
2
2
  import { join } from 'path';
3
3
  import { existsSync } from 'fs';
4
4
  import { createRequire } from 'module';
@@ -20,8 +20,9 @@ const module = defineNuxtModule({
20
20
  defaults: {
21
21
  apiBase: "/dyrected"
22
22
  },
23
- setup(options, nuxt) {
23
+ async setup(options, nuxt) {
24
24
  const resolver = createResolver(import.meta.url);
25
+ await installModule("@nuxt/image");
25
26
  const _require = createRequire(import.meta.url);
26
27
  try {
27
28
  const adminCssPath = _require.resolve("@dyrected/admin/styles");
@@ -42,6 +43,10 @@ const module = defineNuxtModule({
42
43
  name: "DyrectedMedia",
43
44
  filePath: resolver.resolve("./runtime/components/DyrectedMedia.vue")
44
45
  });
46
+ addComponent({
47
+ name: "DyrectedImage",
48
+ filePath: resolver.resolve("./runtime/components/DyrectedImage.vue")
49
+ });
45
50
  addComponent({
46
51
  name: "DyrectedAdmin",
47
52
  filePath: resolver.resolve("./runtime/components/DyrectedAdmin.vue")
@@ -56,6 +61,11 @@ const module = defineNuxtModule({
56
61
  filePath: "@dyrected/vue",
57
62
  export: "DyrectedIcon"
58
63
  });
64
+ addComponent({
65
+ name: "DyrectedRichText",
66
+ filePath: "@dyrected/vue",
67
+ export: "DyrectedRichText"
68
+ });
59
69
  addImports([
60
70
  { name: "useDyrected", from: resolver.resolve("./runtime/composables/useDyrected") },
61
71
  { name: "useDyrectedClient", from: resolver.resolve("./runtime/composables/useDyrected") },
@@ -68,7 +78,8 @@ const module = defineNuxtModule({
68
78
  { name: "useDyrectedAuth", from: resolver.resolve("./runtime/composables/useDyrectedAuth") },
69
79
  { name: "useLivePreview", from: "@dyrected/vue" },
70
80
  { name: "useDyPath", from: "@dyrected/vue" },
71
- { name: "provideDyPath", from: "@dyrected/vue" }
81
+ { name: "provideDyPath", from: "@dyrected/vue" },
82
+ { name: "getPreviewToken", from: "@dyrected/vue" }
72
83
  ]);
73
84
  const runtimeConfig = {
74
85
  ...options,
@@ -173,9 +184,10 @@ export default defineNitroPlugin(async (nitroApp) => {
173
184
  const base = listener.url.replace(/\/$/, "");
174
185
  const adminSlug = options.adminPath || "cms";
175
186
  const apiSlug = options.apiBase || "/dyrected";
187
+ const apiUrl = apiSlug.startsWith("http") ? apiSlug : `${base}${apiSlug}`;
176
188
  console.log(`
177
189
  \u279C Dyrected admin: ${base}/${adminSlug}`);
178
- console.log(` \u279C Dyrected API: ${base}${apiSlug}
190
+ console.log(` \u279C Dyrected API: ${apiUrl}
179
191
  `);
180
192
  });
181
193
  if (options.db) {
@@ -1,7 +1,6 @@
1
1
  <template>
2
- <DyrectedAdmin
3
- :config="config"
4
- :basename="basename || '/cms-admin'"
2
+ <DyrectedAdmin
3
+ :config="config"
5
4
  :components="components"
6
5
  />
7
6
  </template>
@@ -12,11 +11,6 @@ import { useRuntimeConfig } from "#imports";
12
11
  import { DyrectedAdmin } from "@dyrected/vue";
13
12
 
14
13
  defineProps<{
15
- /**
16
- * The base path where the admin is mounted.
17
- * @default "/cms-admin"
18
- */
19
- basename?: string;
20
14
  /**
21
15
  * Custom components to inject into the Admin UI.
22
16
  */
@@ -1,15 +1,29 @@
1
1
  <template>
2
- <BaseDyrectedImage v-bind="$props" />
2
+ <NuxtImg
3
+ :src="src"
4
+ :width="width ?? resolvedWidth"
5
+ :height="height ?? resolvedHeight"
6
+ :alt="alt ?? resolvedAlt"
7
+ v-bind="$attrs"
8
+ />
3
9
  </template>
4
10
 
5
11
  <script setup lang="ts">
6
- import { DyrectedImage as BaseDyrectedImage } from "@dyrected/vue";
7
- import type { Media } from '@dyrected/sdk';
12
+ import { computed } from "vue";
13
+ import type { Media } from "@dyrected/sdk";
8
14
 
9
- defineProps<{
15
+ // Nuxt renders images through @nuxt/image's <NuxtImg> for optimization, the way
16
+ // the Next integration uses next/image. @dyrected/nuxt installs @nuxt/image, so
17
+ // <NuxtImg> is always available.
18
+ const props = defineProps<{
10
19
  media: Media | string;
11
20
  width?: number | string;
12
21
  height?: number | string;
13
22
  alt?: string;
14
23
  }>();
24
+
25
+ const src = computed(() => (typeof props.media === "string" ? props.media : props.media.url));
26
+ const resolvedWidth = computed(() => (typeof props.media === "string" ? 500 : props.media.width ?? 500));
27
+ const resolvedHeight = computed(() => (typeof props.media === "string" ? 500 : props.media.height ?? 500));
28
+ const resolvedAlt = computed(() => (typeof props.media === "string" ? "" : props.media.filename));
15
29
  </script>
@@ -1,19 +1,73 @@
1
1
  <template>
2
- <BaseDyrectedMedia v-bind="$props">
3
- <template #fallback>
4
- <slot name="fallback" />
5
- </template>
6
- </BaseDyrectedMedia>
2
+ <div
3
+ v-if="youtubeId"
4
+ class="dyrected-media-video"
5
+ style="position: relative; padding-bottom: 56.25%; height: 0;"
6
+ >
7
+ <iframe
8
+ :src="`https://www.youtube.com/embed/${youtubeId}`"
9
+ frameborder="0"
10
+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
11
+ allowfullscreen
12
+ style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"
13
+ />
14
+ </div>
15
+
16
+ <NuxtImg
17
+ v-else-if="isImage"
18
+ :src="url"
19
+ :width="width ?? 500"
20
+ :height="height ?? 500"
21
+ :alt="alt ?? filename"
22
+ v-bind="$attrs"
23
+ />
24
+
25
+ <video
26
+ v-else-if="isVideo"
27
+ :src="url"
28
+ controls
29
+ :width="width ?? 500"
30
+ :height="height ?? 500"
31
+ class="dyrected-media-video"
32
+ v-bind="$attrs"
33
+ />
34
+
35
+ <div v-else class="dyrected-media-file">
36
+ <slot name="fallback">
37
+ <a :href="url" target="_blank" rel="noopener noreferrer" class="dyrected-file-link">
38
+ Download {{ filename || "File" }}
39
+ </a>
40
+ </slot>
41
+ </div>
7
42
  </template>
8
43
 
9
44
  <script setup lang="ts">
10
- import { DyrectedMedia as BaseDyrectedMedia } from "@dyrected/vue";
11
- import type { Media } from '@dyrected/sdk';
45
+ import { computed } from "vue";
46
+ import type { Media } from "@dyrected/sdk";
12
47
 
13
- defineProps<{
48
+ // Nuxt renders the image case through @nuxt/image's <NuxtImg> for optimization,
49
+ // mirroring how the Next integration's DyrectedMedia uses next/image.
50
+ const props = defineProps<{
14
51
  media: Media | string;
15
52
  width?: number | string;
16
53
  height?: number | string;
17
54
  alt?: string;
18
55
  }>();
56
+
57
+ const url = computed(() => (typeof props.media === "string" ? props.media : props.media.url));
58
+ const filename = computed(() => (typeof props.media === "string" ? "" : props.media.filename));
59
+ const mimeType = computed(() => (typeof props.media === "string" ? null : props.media.mimeType));
60
+
61
+ const youtubeId = computed(() => {
62
+ const regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/;
63
+ const match = url.value.match(regExp);
64
+ return match && match[2].length === 11 ? match[2] : null;
65
+ });
66
+
67
+ const isImage = computed(
68
+ () => mimeType.value?.startsWith("image/") || url.value.match(/\.(jpg|jpeg|png|gif|webp|avif|svg)$/i),
69
+ );
70
+ const isVideo = computed(
71
+ () => mimeType.value?.startsWith("video/") || url.value.match(/\.(mp4|webm|ogg)$/i),
72
+ );
19
73
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyrected/nuxt",
3
- "version": "2.5.59",
3
+ "version": "2.5.61",
4
4
  "type": "module",
5
5
  "main": "./dist/module.mjs",
6
6
  "types": "./dist/module.d.ts",
@@ -15,14 +15,15 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
+ "@nuxt/image": "^1.8.0",
18
19
  "@nuxt/kit": "^3.11.2",
19
20
  "h3": "^1.15.0",
20
21
  "react": "^18.0.0 || ^19.0.0",
21
22
  "react-dom": "^18.0.0 || ^19.0.0",
22
- "@dyrected/core": "2.5.59",
23
- "@dyrected/sdk": "2.5.59",
24
- "@dyrected/admin": "2.5.59",
25
- "@dyrected/vue": "2.5.59"
23
+ "@dyrected/sdk": "2.5.61",
24
+ "@dyrected/core": "2.5.61",
25
+ "@dyrected/vue": "2.5.61",
26
+ "@dyrected/admin": "2.5.61"
26
27
  },
27
28
  "peerDependencies": {
28
29
  "nuxt": "^3.0.0",