@devite/nuxt-sanity 2.15.0 → 2.16.0

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.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { HistoryRefresh, VisualEditingOptions as VisualEditingOptions$1 } from '@sanity/visual-editing';
3
3
  import { ClientConfig } from '@sanity/client';
4
- import { Slug, ImageAsset, PortableTextBlock } from '@sanity/types';
4
+ import { Slug, PortableTextBlock, ImageAsset } from '@sanity/types';
5
5
 
6
6
  type ModuleOptions = ClientConfig & {
7
7
  projectId?: string;
@@ -54,22 +54,6 @@ interface VisualEditingOptions {
54
54
  type SanityVisualEditingMode = 'live-visual-editing' | 'visual-editing' | 'custom';
55
55
  type SanityVisualEditingRefreshHandler = (payload: HistoryRefresh, refreshDefault: () => false | Promise<void>) => false | Promise<void>;
56
56
 
57
- interface Page {
58
- _id: string;
59
- _type: 'page';
60
- title: string;
61
- slug: Slug;
62
- modules: SanityArray<SanityModule>;
63
- seo: SEO;
64
- }
65
-
66
- interface GlobalSEO {
67
- siteName: string;
68
- image: {
69
- asset: ImageAsset;
70
- };
71
- }
72
-
73
57
  interface LinkExternal {
74
58
  _type: 'linkExternal';
75
59
  url: string;
@@ -85,6 +69,17 @@ interface LinkInternal {
85
69
  relationship?: string;
86
70
  }
87
71
 
72
+ interface Page {
73
+ _id: string;
74
+ _type: 'page';
75
+ title: string;
76
+ slug: Slug;
77
+ modules: SanityArray<SanityModule>;
78
+ seo: SEO;
79
+ }
80
+
81
+ type RichText = PortableTextBlock[];
82
+
88
83
  interface SEO {
89
84
  _type: 'seo';
90
85
  indexable: boolean;
@@ -98,8 +93,6 @@ interface SEO {
98
93
  };
99
94
  }
100
95
 
101
- type RichText = PortableTextBlock[];
102
-
103
96
  interface Home {
104
97
  _type: 'home';
105
98
  modules: SanityArray<SanityModule>;
@@ -123,4 +116,4 @@ type SanityArray<T> = Array<T & {
123
116
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
124
117
 
125
118
  export { _default as default };
126
- export type { GlobalSEO, Home, LinkExternal, LinkInternal, ModuleOptions, NotFound, Page, RichText, SEO, SanityArray, SanityModule, SanityVisualEditingMode, SanityVisualEditingRefreshHandler, VisualEditingOptions };
119
+ export type { Home, LinkExternal, LinkInternal, ModuleOptions, NotFound, Page, RichText, SEO, SanityArray, SanityModule, SanityVisualEditingMode, SanityVisualEditingRefreshHandler, VisualEditingOptions };
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "configKey": "sanity",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
package/dist/module.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import crypto from 'node:crypto';
2
- import { defineNuxtModule, createResolver, addPlugin, addServerHandler, addImports, addServerImports, addComponentsDir, installModule } from '@nuxt/kit';
1
+ import { defineNuxtModule, createResolver, addPlugin, addServerHandler, addImports, addServerImports, addComponentsDir } from '@nuxt/kit';
3
2
  import defu from 'defu';
3
+ import { randomBytes } from 'node:crypto';
4
4
 
5
5
  const name = "@devite/nuxt-sanity";
6
- const version = "2.15.0";
6
+ const version = "2.16.0";
7
7
 
8
8
  const CONFIG_KEY = "sanity";
9
9
  const module = defineNuxtModule({
@@ -13,6 +13,9 @@ const module = defineNuxtModule({
13
13
  configKey: CONFIG_KEY
14
14
  },
15
15
  defaults: {},
16
+ moduleDependencies: {
17
+ "@nuxt/image": { version: ">=1.11.0", optional: false }
18
+ },
16
19
  async setup(options, nuxt) {
17
20
  const { resolve } = createResolver(import.meta.url);
18
21
  const $config = nuxt.options.runtimeConfig;
@@ -120,7 +123,7 @@ const module = defineNuxtModule({
120
123
  $config.sanity = defu($config.sanity, {
121
124
  visualEditing: moduleConfig.visualEditing && {
122
125
  ...moduleConfig.visualEditing,
123
- previewModeId: moduleConfig.visualEditing.previewMode ? crypto.randomBytes(16).toString("hex") : "",
126
+ previewModeId: moduleConfig.visualEditing.previewMode ? randomBytes(16).toString("hex") : "",
124
127
  token: moduleConfig.visualEditing.token || ""
125
128
  },
126
129
  webhookSecret: moduleConfig.minimalClient && moduleConfig.minimalClient.webhookSecret || void 0
@@ -172,6 +175,7 @@ const module = defineNuxtModule({
172
175
  { name: "useSanityVisualEditingState", from: resolve("runtime/composables/visual_editing_state") },
173
176
  { name: "useSanitySEO", from: resolve("runtime/composables/sanity_seo") },
174
177
  // helper methods
178
+ { name: "default", as: "useSanityClient", from: resolve("runtime/utils/useSanityClient") },
175
179
  { name: "resolveImageAssetById", from: resolve("runtime/utils/resolveImageAssetById") },
176
180
  { name: "resolveInternalLink", from: resolve("runtime/utils/resolveInternalLink") },
177
181
  // shared
@@ -184,25 +188,19 @@ const module = defineNuxtModule({
184
188
  // shared
185
189
  ...sharedImports
186
190
  ]);
187
- await addComponentsDir({ path: resolve("runtime/components") });
188
- await addComponentsDir({
189
- path: "~/sanity",
190
- global: true,
191
- prefix: "Sanity",
192
- pathPrefix: false
193
- });
194
- await installModule("@nuxt/image", {
195
- providers: {
196
- cachedSanity: {
197
- provider: resolve("runtime/imageProviders/sanity"),
198
- options: {
199
- projectId: moduleConfig.projectId,
200
- dataset: moduleConfig.dataset,
201
- cacheEndpoint: typeof moduleConfig.minimalClient === "object" && moduleConfig.minimalClient.cachingEnabled && moduleConfig.minimalClient.cacheClientBaseUrl + moduleConfig.minimalClient.assetEndpoint || void 0
202
- }
191
+ addComponentsDir({ path: resolve("runtime/components"), pathPrefix: false });
192
+ addComponentsDir({ path: "~/sanity", global: true, prefix: "Sanity", pathPrefix: false });
193
+ if (nuxt.options.image) {
194
+ nuxt.options.image.providers ??= {};
195
+ nuxt.options.image.providers.cachedSanity = {
196
+ provider: resolve("runtime/imageProviders/sanity"),
197
+ options: {
198
+ projectId: moduleConfig.projectId,
199
+ dataset: moduleConfig.dataset,
200
+ cacheEndpoint: typeof moduleConfig.minimalClient === "object" && moduleConfig.minimalClient.cachingEnabled && moduleConfig.minimalClient.cacheClientBaseUrl + moduleConfig.minimalClient.assetEndpoint || void 0
203
201
  }
204
- }
205
- }, nuxt);
202
+ };
203
+ }
206
204
  }
207
205
  });
208
206
 
@@ -1,4 +1,3 @@
1
- import type { Reference } from '@sanity/types';
2
1
  import type { LinkInternal } from '@devite/nuxt-sanity';
3
2
  type __VLS_Props = {
4
3
  data: LinkInternal | {
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <NuxtLink
3
- :to="resolvedLink?.slug"
3
+ :to="resolvedLink?.slug + (data.queryString ? `?${data.queryString}` : '')"
4
4
  :title="resolvedLink?.linkTitle"
5
5
  :rel="resolvedLink?.relationship"
6
6
  >
@@ -1,4 +1,3 @@
1
- import type { Reference } from '@sanity/types';
2
1
  import type { LinkInternal } from '@devite/nuxt-sanity';
3
2
  type __VLS_Props = {
4
3
  data: LinkInternal | {
@@ -1,4 +1,4 @@
1
1
  export declare const useSanityVisualEditingState: () => {
2
- enabled: any;
2
+ enabled: boolean;
3
3
  isInFrame: () => boolean | undefined;
4
4
  };
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
package/dist/types.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { default } from './module.mjs'
2
2
 
3
- export { type GlobalSEO, type Home, type LinkExternal, type LinkInternal, type ModuleOptions, type NotFound, type Page, type RichText, type SEO, type SanityArray, type SanityModule, type SanityVisualEditingMode, type SanityVisualEditingRefreshHandler, type VisualEditingOptions } from './module.mjs'
3
+ export { type Home, type LinkExternal, type LinkInternal, type ModuleOptions, type NotFound, type Page, type RichText, type SEO, type SanityArray, type SanityModule, type SanityVisualEditingMode, type SanityVisualEditingRefreshHandler, type VisualEditingOptions } from './module.mjs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devite/nuxt-sanity",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Advanced Sanity integration for Nuxt.js.",
5
5
  "repository": "devite-io/nuxt-sanity",
6
6
  "license": "MIT",
@@ -30,33 +30,33 @@
30
30
  "@nuxt/image": "^1.11.0",
31
31
  "@portabletext/vue": "^1.0.14",
32
32
  "@sanity/client": "^7.12.0",
33
- "@sanity/core-loader": "^1.8.21",
33
+ "@sanity/core-loader": "^2.0.0",
34
34
  "@sanity/preview-url-secret": "^2.1.15",
35
- "@sanity/types": "^4.11.0",
36
- "@sanity/visual-editing": "^3.2.4",
35
+ "@sanity/types": "^4.12.0",
36
+ "@sanity/visual-editing": "^4.0.0",
37
37
  "defu": "^6.1.4",
38
- "ofetch": "^1.4.1",
38
+ "ofetch": "^1.5.0",
39
39
  "ohash": "^1.1.6",
40
40
  "unstorage": "^1.17.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@nuxt/eslint-config": "^1.9.0",
44
- "@nuxt/kit": "^4.1.3",
44
+ "@nuxt/kit": "^4.2.0",
45
45
  "@nuxt/module-builder": "^1.0.2",
46
- "@nuxt/schema": "^4.1.3",
47
- "@nuxt/test-utils": "^3.19.2",
46
+ "@nuxt/schema": "^4.2.0",
47
+ "@nuxt/test-utils": "^3.20.1",
48
48
  "@types/node": "latest",
49
49
  "changelogen": "^0.6.2",
50
50
  "eslint": "^9.38.0",
51
51
  "h3": "^1.15.4",
52
- "nuxt": "^4.1.3",
53
- "typescript": "5.8.3",
54
- "vite": "7.1.11",
55
- "vitest": "^4.0.0",
52
+ "nuxt": "^4.2.0",
53
+ "typescript": "5.9.3",
54
+ "vite": "7.1.12",
55
+ "vitest": "^3.2.0",
56
56
  "vitest-environment-nuxt": "1.0.1",
57
57
  "vue": "3.5.22",
58
58
  "vue-router": "^4.6.3",
59
- "vue-tsc": "^3.1.1"
59
+ "vue-tsc": "^3.1.2"
60
60
  },
61
61
  "resolutions": {
62
62
  "@devite/nuxt-sanity": "link:."