next-sanity 9.4.0 → 9.4.2

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.cjs CHANGED
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  mod
20
20
  ));
21
21
  Object.defineProperty(exports, "__esModule", { value: !0 });
22
- var client = require("@sanity/client"), jsxRuntime = require("react/jsx-runtime"), dynamic = require("next/dynamic"), react = require("@portabletext/react"), groq = require("groq"), createDataAttribute = require("@sanity/visual-editing/create-data-attribute");
22
+ var client = require("@sanity/client"), jsxRuntime = require("react/jsx-runtime"), dynamic = require("next/dynamic.js"), react = require("@portabletext/react"), groq = require("groq"), createDataAttribute = require("@sanity/visual-editing/create-data-attribute");
23
23
  function _interopDefaultCompat(e) {
24
24
  return e && typeof e == "object" && "default" in e ? e : { default: e };
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/visual-editing/index.tsx"],"sourcesContent":["/* eslint-disable dot-notation */\nimport dynamic from 'next/dynamic'\nimport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n\nconst VisualEditingComponent = dynamic(\n () => import('next-sanity/visual-editing/client-component'),\n {ssr: false},\n)\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport {\n type CreateDataAttribute,\n createDataAttribute,\n type CreateDataAttributeProps,\n} from '@sanity/visual-editing/create-data-attribute'\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"names":["dynamic","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,yBAAyBA,iBAAA;AAAA,EAC7B,MAAM,OAAO,6CAA6C;AAAA,EAC1D,EAAC,KAAK,GAAK;AACb;AAKO,SAAS,cAAc,OAA+C;AAZ7E,MAAA,IAAA;AAaM,MAAA;AACA,MAAA,OAAO,MAAM,YAAa;AACxB,QAAA;AACF,qBAAe,QAAQ,IAAI,wBACvB,gBAEF,QAAQ;AAAA,QACN,6BAA6B,KAAK,UAAU,YAAY,CAAC;AAAA,MAAA;AAAA,aAGtD,KAAK;AACJ,cAAA,MAAM,6BAA6B,GAAG;AAAA,IAChD;AAEE,MAAA;AACA,MAAA,OAAO,MAAM,iBAAkB;AAC7B,QAAA;AACF,0BAAoB,CAAQ,CAAA,QAAQ,IAAI,uBACpC,qBAEF,QAAQ;AAAA,QACN,kCAAkC,KAAK,UAAU,iBAAiB,CAAC;AAAA,MAAA;AAAA,aAGhE,KAAK;AACJ,cAAA,MAAM,kCAAkC,GAAG;AAAA,IACrD;AAGA,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAU,KAAM,MAAA,aAAN,OAAkB,KAAA;AAAA,MAC5B,gBAAe,KAAM,MAAA,kBAAN,OAAuB,KAAA;AAAA,IAAA;AAAA,EAAA;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/visual-editing/index.tsx"],"sourcesContent":["/* eslint-disable dot-notation */\nimport dynamic from 'next/dynamic.js'\nimport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n\nconst VisualEditingComponent = dynamic(\n () => import('next-sanity/visual-editing/client-component'),\n {ssr: false},\n)\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport {\n type CreateDataAttribute,\n createDataAttribute,\n type CreateDataAttributeProps,\n} from '@sanity/visual-editing/create-data-attribute'\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"names":["dynamic","jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM,yBAAyBA,iBAAA;AAAA,EAC7B,MAAM,OAAO,6CAA6C;AAAA,EAC1D,EAAC,KAAK,GAAK;AACb;AAKO,SAAS,cAAc,OAA+C;AAZ7E,MAAA,IAAA;AAaM,MAAA;AACA,MAAA,OAAO,MAAM,YAAa;AACxB,QAAA;AACF,qBAAe,QAAQ,IAAI,wBACvB,gBAEF,QAAQ;AAAA,QACN,6BAA6B,KAAK,UAAU,YAAY,CAAC;AAAA,MAAA;AAAA,aAGtD,KAAK;AACJ,cAAA,MAAM,6BAA6B,GAAG;AAAA,IAChD;AAEE,MAAA;AACA,MAAA,OAAO,MAAM,iBAAkB;AAC7B,QAAA;AACF,0BAAoB,CAAQ,CAAA,QAAQ,IAAI,uBACpC,qBAEF,QAAQ;AAAA,QACN,kCAAkC,KAAK,UAAU,iBAAiB,CAAC;AAAA,MAAA;AAAA,aAGhE,KAAK;AACJ,cAAA,MAAM,kCAAkC,GAAG;AAAA,IACrD;AAGA,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAU,KAAM,MAAA,aAAN,OAAkB,KAAA;AAAA,MAC5B,gBAAe,KAAM,MAAA,kBAAN,OAAuB,KAAA;AAAA,IAAA;AAAA,EAAA;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createClient, unstable__adapter, unstable__environment } from "@sanity/client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import dynamic from "next/dynamic";
3
+ import dynamic from "next/dynamic.js";
4
4
  export * from "@portabletext/react";
5
5
  import { default as default2 } from "groq";
6
6
  import { createDataAttribute } from "@sanity/visual-editing/create-data-attribute";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/visual-editing/index.tsx"],"sourcesContent":["/* eslint-disable dot-notation */\nimport dynamic from 'next/dynamic'\nimport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n\nconst VisualEditingComponent = dynamic(\n () => import('next-sanity/visual-editing/client-component'),\n {ssr: false},\n)\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport {\n type CreateDataAttribute,\n createDataAttribute,\n type CreateDataAttributeProps,\n} from '@sanity/visual-editing/create-data-attribute'\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"names":[],"mappings":";;;;;;AAIA,MAAM,yBAAyB;AAAA,EAC7B,MAAM,OAAO,6CAA6C;AAAA,EAC1D,EAAC,KAAK,GAAK;AACb;AAKO,SAAS,cAAc,OAA+C;AAZ7E,MAAA,IAAA;AAaM,MAAA;AACA,MAAA,OAAO,MAAM,YAAa;AACxB,QAAA;AACF,qBAAe,QAAQ,IAAI,wBACvB,gBAEF,QAAQ;AAAA,QACN,6BAA6B,KAAK,UAAU,YAAY,CAAC;AAAA,MAAA;AAAA,aAGtD,KAAK;AACJ,cAAA,MAAM,6BAA6B,GAAG;AAAA,IAChD;AAEE,MAAA;AACA,MAAA,OAAO,MAAM,iBAAkB;AAC7B,QAAA;AACF,0BAAoB,CAAQ,CAAA,QAAQ,IAAI,uBACpC,qBAEF,QAAQ;AAAA,QACN,kCAAkC,KAAK,UAAU,iBAAiB,CAAC;AAAA,MAAA;AAAA,aAGhE,KAAK;AACJ,cAAA,MAAM,kCAAkC,GAAG;AAAA,IACrD;AAGA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAU,KAAM,MAAA,aAAN,OAAkB,KAAA;AAAA,MAC5B,gBAAe,KAAM,MAAA,kBAAN,OAAuB,KAAA;AAAA,IAAA;AAAA,EAAA;AAG5C;"}
1
+ {"version":3,"file":"index.js","sources":["../src/visual-editing/index.tsx"],"sourcesContent":["/* eslint-disable dot-notation */\nimport dynamic from 'next/dynamic.js'\nimport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n\nconst VisualEditingComponent = dynamic(\n () => import('next-sanity/visual-editing/client-component'),\n {ssr: false},\n)\n\n/**\n * @public\n */\nexport function VisualEditing(props: VisualEditingProps): React.ReactElement {\n let autoBasePath: string | undefined\n if (typeof props.basePath !== 'string') {\n try {\n autoBasePath = process.env['__NEXT_ROUTER_BASEPATH']\n if (autoBasePath) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next basePath as ${JSON.stringify(autoBasePath)} by reading \"process.env.__NEXT_ROUTER_BASEPATH\". If this is incorrect then you can set it manually with the basePath prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting basePath', err)\n }\n }\n let autoTrailingSlash: boolean | undefined\n if (typeof props.trailingSlash !== 'boolean') {\n try {\n autoTrailingSlash = Boolean(process.env['__NEXT_TRAILING_SLASH'])\n if (autoTrailingSlash) {\n // eslint-disable-next-line no-console\n console.log(\n `Detected next trailingSlash as ${JSON.stringify(autoTrailingSlash)} by reading \"process.env.__NEXT_TRAILING_SLASH\". If this is incorrect then you can set it manually with the trailingSlash prop on the <VisualEditing /> component.`,\n )\n }\n } catch (err) {\n console.error('Failed detecting trailingSlash', err)\n }\n }\n return (\n <VisualEditingComponent\n {...props}\n basePath={props.basePath ?? autoBasePath}\n trailingSlash={props.trailingSlash ?? autoTrailingSlash}\n />\n )\n}\n\nexport {\n type CreateDataAttribute,\n createDataAttribute,\n type CreateDataAttributeProps,\n} from '@sanity/visual-editing/create-data-attribute'\nexport type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'\n"],"names":[],"mappings":";;;;;;AAIA,MAAM,yBAAyB;AAAA,EAC7B,MAAM,OAAO,6CAA6C;AAAA,EAC1D,EAAC,KAAK,GAAK;AACb;AAKO,SAAS,cAAc,OAA+C;AAZ7E,MAAA,IAAA;AAaM,MAAA;AACA,MAAA,OAAO,MAAM,YAAa;AACxB,QAAA;AACF,qBAAe,QAAQ,IAAI,wBACvB,gBAEF,QAAQ;AAAA,QACN,6BAA6B,KAAK,UAAU,YAAY,CAAC;AAAA,MAAA;AAAA,aAGtD,KAAK;AACJ,cAAA,MAAM,6BAA6B,GAAG;AAAA,IAChD;AAEE,MAAA;AACA,MAAA,OAAO,MAAM,iBAAkB;AAC7B,QAAA;AACF,0BAAoB,CAAQ,CAAA,QAAQ,IAAI,uBACpC,qBAEF,QAAQ;AAAA,QACN,kCAAkC,KAAK,UAAU,iBAAiB,CAAC;AAAA,MAAA;AAAA,aAGhE,KAAK;AACJ,cAAA,MAAM,kCAAkC,GAAG;AAAA,IACrD;AAGA,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAU,KAAM,MAAA,aAAN,OAAkB,KAAA;AAAA,MAC5B,gBAAe,KAAM,MAAA,kBAAN,OAAuB,KAAA;AAAA,IAAA;AAAA,EAAA;AAG5C;"}
package/dist/studio.cjs CHANGED
@@ -19,7 +19,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
19
19
  mod
20
20
  ));
21
21
  Object.defineProperty(exports, "__esModule", { value: !0 });
22
- var dynamic = require("next/dynamic"), NextStudioNoScript = require("./_chunks-cjs/NextStudioNoScript.cjs");
22
+ var dynamic = require("next/dynamic.js"), NextStudioNoScript = require("./_chunks-cjs/NextStudioNoScript.cjs");
23
23
  function _interopDefaultCompat(e) {
24
24
  return e && typeof e == "object" && "default" in e ? e : { default: e };
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"studio.cjs","sources":["../src/studio/head.tsx","../src/studio/index.ts"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import dynamic from 'next/dynamic'\n\nexport {metadata, viewport} from './head'\nexport * from './NextStudioLayout'\nexport * from './NextStudioNoScript'\nexport type {NextStudioProps} from 'next-sanity/studio/client-component'\nexport const NextStudio = dynamic(() => import('next-sanity/studio/client-component'), {ssr: false})\n"],"names":["dynamic"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,cAAc;AAAA;AAAA,EAEd,aAAa;AACf,GAoBa,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,QAAQ;AACV,GC1Ca,aAAaA,yBAAQ,MAAM,OAAO,qCAAqC,GAAG,EAAC,KAAK,GAAM,CAAA;;;;;;"}
1
+ {"version":3,"file":"studio.cjs","sources":["../src/studio/head.tsx","../src/studio/index.ts"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import dynamic from 'next/dynamic.js'\n\nexport {metadata, viewport} from './head'\nexport * from './NextStudioLayout'\nexport * from './NextStudioNoScript'\nexport type {NextStudioProps} from 'next-sanity/studio/client-component'\nexport const NextStudio = dynamic(() => import('next-sanity/studio/client-component'), {ssr: false})\n"],"names":["dynamic"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAoBO,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,cAAc;AAAA;AAAA,EAEd,aAAa;AACf,GAoBa,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,QAAQ;AACV,GC1Ca,aAAaA,yBAAQ,MAAM,OAAO,qCAAqC,GAAG,EAAC,KAAK,GAAM,CAAA;;;;;;"}
package/dist/studio.js CHANGED
@@ -1,4 +1,4 @@
1
- import dynamic from "next/dynamic";
1
+ import dynamic from "next/dynamic.js";
2
2
  import { NextStudioLayout, NextStudioNoScript } from "./_chunks-es/NextStudioNoScript.js";
3
3
  const viewport = {
4
4
  width: "device-width",
@@ -1 +1 @@
1
- {"version":3,"file":"studio.js","sources":["../src/studio/head.tsx","../src/studio/index.ts"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import dynamic from 'next/dynamic'\n\nexport {metadata, viewport} from './head'\nexport * from './NextStudioLayout'\nexport * from './NextStudioNoScript'\nexport type {NextStudioProps} from 'next-sanity/studio/client-component'\nexport const NextStudio = dynamic(() => import('next-sanity/studio/client-component'), {ssr: false})\n"],"names":[],"mappings":";;AAoBO,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,cAAc;AAAA;AAAA,EAEd,aAAa;AACf,GAoBa,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,QAAQ;AACV,GC1Ca,aAAa,QAAQ,MAAM,OAAO,qCAAqC,GAAG,EAAC,KAAK,GAAM,CAAA;"}
1
+ {"version":3,"file":"studio.js","sources":["../src/studio/head.tsx","../src/studio/index.ts"],"sourcesContent":["import type {Metadata, Viewport} from 'next'\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the viewport config directly:\n * export {viewport} from 'next-sanity/studio'\n *\n * // To customize the viewport config, spread it on the export:\n * import {viewport as studioViewport} from 'next-sanity/studio'\n * import type { Viewport } from 'next'\n *\n * export const viewport: Viewport = {\n * ...studioViewport,\n * // Overrides the viewport to resize behavior\n * interactiveWidget: 'resizes-content'\n * })\n * ```\n * @public\n */\nexport const viewport = {\n width: 'device-width' as const,\n initialScale: 1 as const,\n // Studio implements display cutouts CSS (The iPhone Notch ™ ) and needs `viewport-fit=covered` for it to work correctly\n viewportFit: 'cover',\n} satisfies Viewport\n\n/**\n * In router segments (`/app/studio/[[...index]]/page.tsx`):\n * ```tsx\n * // If you don't want to change any defaults you can just re-export the metadata directly:\n * export {metadata} from 'next-sanity/studio'\n *\n * // To customize the metadata, spread it on the export:\n * import {metadata as studioMetadata} from 'next-sanity/studio'\n * import type { Metadata } from 'next'\n *\n * export const metadata: Metadata = {\n * ...studioMetadata,\n * // Set another title\n * title: 'My Studio',\n * })\n * ```\n * @public\n */\nexport const metadata = {\n referrer: 'same-origin' as const,\n robots: 'noindex' as const,\n} satisfies Metadata\n","import dynamic from 'next/dynamic.js'\n\nexport {metadata, viewport} from './head'\nexport * from './NextStudioLayout'\nexport * from './NextStudioNoScript'\nexport type {NextStudioProps} from 'next-sanity/studio/client-component'\nexport const NextStudio = dynamic(() => import('next-sanity/studio/client-component'), {ssr: false})\n"],"names":[],"mappings":";;AAoBO,MAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,cAAc;AAAA;AAAA,EAEd,aAAa;AACf,GAoBa,WAAW;AAAA,EACtB,UAAU;AAAA,EACV,QAAQ;AACV,GC1Ca,aAAa,QAAQ,MAAM,OAAO,qCAAqC,GAAG,EAAC,KAAK,GAAM,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-sanity",
3
- "version": "9.4.0",
3
+ "version": "9.4.2",
4
4
  "description": "Sanity.io toolkit for Next.js",
5
5
  "keywords": [
6
6
  "sanity",
@@ -33,10 +33,6 @@
33
33
  },
34
34
  "./image": {
35
35
  "source": "./src/image/index.ts",
36
- "react-compiler": {
37
- "source": "./src/image/index.ts",
38
- "default": "./dist/image.compiled.js"
39
- },
40
36
  "import": "./dist/image.js",
41
37
  "require": "./dist/image.cjs",
42
38
  "default": "./dist/image.js"
@@ -61,20 +57,12 @@
61
57
  },
62
58
  "./studio/client-component": {
63
59
  "source": "./src/studio/client-component/index.ts",
64
- "react-compiler": {
65
- "source": "./src/studio/client-component/index.ts",
66
- "default": "./dist/studio/client-component.compiled.js"
67
- },
68
60
  "import": "./dist/studio/client-component.js",
69
61
  "require": "./dist/studio/client-component.cjs",
70
62
  "default": "./dist/studio/client-component.js"
71
63
  },
72
64
  "./visual-editing/client-component": {
73
65
  "source": "./src/visual-editing/client-component/index.ts",
74
- "react-compiler": {
75
- "source": "./src/visual-editing/client-component/index.ts",
76
- "default": "./dist/visual-editing/client-component.compiled.js"
77
- },
78
66
  "import": "./dist/visual-editing/client-component.js",
79
67
  "require": "./dist/visual-editing/client-component.cjs",
80
68
  "default": "./dist/visual-editing/client-component.js"
@@ -1,4 +1,4 @@
1
- import dynamic from 'next/dynamic'
1
+ import dynamic from 'next/dynamic.js'
2
2
 
3
3
  export {metadata, viewport} from './head'
4
4
  export * from './NextStudioLayout'
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable dot-notation */
2
- import dynamic from 'next/dynamic'
2
+ import dynamic from 'next/dynamic.js'
3
3
  import type {VisualEditingProps} from 'next-sanity/visual-editing/client-component'
4
4
 
5
5
  const VisualEditingComponent = dynamic(
@@ -1,47 +0,0 @@
1
- "use client";
2
- import { jsx } from "react/jsx-runtime";
3
- import { c } from "react/compiler-runtime";
4
- import NextImage from "next/image";
5
- const imageLoader = ({
6
- src,
7
- width,
8
- quality
9
- }) => {
10
- const url = new URL(src);
11
- if (url.searchParams.set("auto", "format"), url.searchParams.set("fit", url.searchParams.get("fit") || url.searchParams.has("h") ? "min" : "max"), url.searchParams.has("h") && url.searchParams.has("w")) {
12
- const originalHeight = parseInt(url.searchParams.get("h"), 10), originalWidth = parseInt(url.searchParams.get("w"), 10);
13
- url.searchParams.set("h", Math.round(originalHeight / originalWidth * width).toString());
14
- }
15
- return url.searchParams.set("w", width.toString()), quality && url.searchParams.set("q", quality.toString()), url.href;
16
- };
17
- function Image(props) {
18
- const $ = c(8);
19
- let T0, t0, t1;
20
- if ($[0] !== props) {
21
- const {
22
- loader,
23
- src,
24
- ...rest
25
- } = props;
26
- if (loader)
27
- throw new TypeError("The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.");
28
- let srcUrl;
29
- try {
30
- srcUrl = new URL(src), props.height && srcUrl.searchParams.set("h", `${props.height}`), props.width && srcUrl.searchParams.set("w", `${props.width}`);
31
- } catch (t22) {
32
- const err = t22;
33
- throw new TypeError("The `src` prop must be a valid URL to an image on the Sanity Image CDN.", {
34
- cause: err
35
- });
36
- }
37
- T0 = NextImage, t0 = rest, t1 = srcUrl.toString(), $[0] = props, $[1] = T0, $[2] = t0, $[3] = t1;
38
- } else
39
- T0 = $[1], t0 = $[2], t1 = $[3];
40
- let t2;
41
- return $[4] !== T0 || $[5] !== t0 || $[6] !== t1 ? (t2 = /* @__PURE__ */ jsx(T0, { ...t0, src: t1, loader: imageLoader }), $[4] = T0, $[5] = t0, $[6] = t1, $[7] = t2) : t2 = $[7], t2;
42
- }
43
- export {
44
- Image,
45
- imageLoader
46
- };
47
- //# sourceMappingURL=image.compiled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image.compiled.js","sources":["../src/image/imageLoader.ts","../src/image/Image.tsx"],"sourcesContent":["import type {ImageLoader} from 'next/image'\n\n/**\n * @alpha\n */\nexport const imageLoader = (({src, width, quality}) => {\n const url = new URL(src)\n url.searchParams.set('auto', 'format')\n url.searchParams.set(\n 'fit',\n url.searchParams.get('fit') || url.searchParams.has('h') ? 'min' : 'max',\n )\n if (url.searchParams.has('h') && url.searchParams.has('w')) {\n const originalHeight = parseInt(url.searchParams.get('h')!, 10)\n const originalWidth = parseInt(url.searchParams.get('w')!, 10)\n url.searchParams.set('h', Math.round((originalHeight / originalWidth) * width).toString())\n }\n url.searchParams.set('w', width.toString())\n if (quality) {\n url.searchParams.set('q', quality.toString())\n }\n return url.href\n}) satisfies ImageLoader\n","import NextImage, {type ImageProps as NextImageProps} from 'next/image'\n\nimport {imageLoader} from './imageLoader'\n\n/**\n * @alpha\n */\nexport interface ImageProps extends Omit<NextImageProps, 'loader' | 'src'> {\n /**\n * The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.\n */\n loader?: never\n /**\n * Must be a string that is a valid URL to an image on the Sanity Image CDN.\n */\n src: string\n}\n\n/**\n * @alpha\n */\nexport function Image(props: ImageProps): JSX.Element {\n const {loader, src, ...rest} = props\n if (loader) {\n throw new TypeError(\n 'The `loader` prop is not supported on `Image` components. Use `next/image` directly to use a custom loader.',\n )\n }\n let srcUrl: URL\n try {\n srcUrl = new URL(src)\n if (props.height) {\n srcUrl.searchParams.set('h', `${props.height}`)\n }\n if (props.width) {\n srcUrl.searchParams.set('w', `${props.width}`)\n }\n } catch (err) {\n throw new TypeError('The `src` prop must be a valid URL to an image on the Sanity Image CDN.', {\n cause: err,\n })\n }\n return <NextImage {...rest} src={srcUrl.toString()} loader={imageLoader} />\n}\n"],"names":["imageLoader","src","width","quality","url","URL","searchParams","set","get","has","originalHeight","parseInt","originalWidth","Math","round","toString","href","Image","props","$","_c","T0","t0","t1","loader","rest","TypeError","srcUrl","height","t2","err","cause","NextImage"],"mappings":";;;;AAKO,MAAMA,cAAeA,CAAC;AAAA,EAACC;AAAAA,EAAKC;AAAAA,EAAOC;AAAO,MAAM;AAC/CC,QAAAA,MAAM,IAAIC,IAAIJ,GAAG;AAMvB,MALAG,IAAIE,aAAaC,IAAI,QAAQ,QAAQ,GACrCH,IAAIE,aAAaC,IACf,OACAH,IAAIE,aAAaE,IAAI,KAAK,KAAKJ,IAAIE,aAAaG,IAAI,GAAG,IAAI,QAAQ,KACrE,GACIL,IAAIE,aAAaG,IAAI,GAAG,KAAKL,IAAIE,aAAaG,IAAI,GAAG,GAAG;AAC1D,UAAMC,iBAAiBC,SAASP,IAAIE,aAAaE,IAAI,GAAG,GAAI,EAAE,GACxDI,gBAAgBD,SAASP,IAAIE,aAAaE,IAAI,GAAG,GAAI,EAAE;AACzDF,QAAAA,aAAaC,IAAI,KAAKM,KAAKC,MAAOJ,iBAAiBE,gBAAiBV,KAAK,EAAEa,SAAU,CAAA;AAAA,EAC3F;AACAX,SAAAA,I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use client";
2
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
- import { c } from "react/compiler-runtime";
4
- import { memo, useState, useSyncExternalStore } from "react";
5
- import { Studio } from "sanity";
6
- import { createHashHistory } from "history";
7
- import { useServerInsertedHTML } from "next/navigation.js";
8
- import { ServerStyleSheet, StyleSheetManager } from "styled-components";
9
- const NextStudioLayoutComponent = (t0) => {
10
- const $ = c(3), {
11
- children
12
- } = t0;
13
- let t1;
14
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = {
15
- height: "100vh",
16
- maxHeight: "100dvh",
17
- overscrollBehavior: "none",
18
- WebkitFontSmoothing: "antialiased",
19
- overflow: "auto"
20
- }, $[0] = t1) : t1 = $[0];
21
- let t2;
22
- return $[1] !== children ? (t2 = /* @__PURE__ */ jsx("div", { id: "sanity", "data-ui": "NextStudioLayout", style: t1, children }), $[1] = children, $[2] = t2) : t2 = $[2], t2;
23
- }, NextStudioLayout = memo(NextStudioLayoutComponent), NextStudioNoScript = () => {
24
- const $ = c(4);
25
- let t0, t1, t2;
26
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
27
- position: "absolute",
28
- top: 0,
29
- right: 0,
30
- left: 0,
31
- bottom: 0,
32
- background: "#fff",
33
- zIndex: 1
34
- }, t1 = {
35
- position: "absolute",
36
- top: "50%",
37
- left: "50%",
38
- transform: "translate(-50%, -50%)",
39
- textAlign: "center",
40
- fontFamily: "helvetica, arial, sans-serif"
41
- }, t2 = /* @__PURE__ */ jsx("h1", { children: "JavaScript disabled" }), $[0] = t0, $[1] = t1, $[2] = t2) : (t0 = $[0], t1 = $[1], t2 = $[2]);
42
- let t3;
43
- return $[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = /* @__PURE__ */ jsx("noscript", { children: /* @__PURE__ */ jsx("div", { style: t0, children: /* @__PURE__ */ jsxs("div", { style: t1, children: [
44
- t2,
45
- /* @__PURE__ */ jsxs("p", { children: [
46
- "Please ",
47
- /* @__PURE__ */ jsx("a", { href: "https://www.enable-javascript.com/", children: "enable JavaScript" }),
48
- " in your browser and reload the page to proceed."
49
- ] })
50
- ] }) }) }), $[3] = t3) : t3 = $[3], t3;
51
- };
52
- function createHashHistoryForStudio() {
53
- const history = createHashHistory();
54
- return {
55
- get action() {
56
- return history.action;
57
- },
58
- get location() {
59
- return history.location;
60
- },
61
- get createHref() {
62
- return history.createHref;
63
- },
64
- get push() {
65
- return history.push;
66
- },
67
- get replace() {
68
- return history.replace;
69
- },
70
- get go() {
71
- return history.go;
72
- },
73
- get back() {
74
- return history.back;
75
- },
76
- get forward() {
77
- return history.forward;
78
- },
79
- get block() {
80
- return history.block;
81
- },
82
- // Overriding listen to workaround a problem where native history provides history.listen(location => void), but the npm package is history.listen(({action, location}) => void)
83
- listen(listener) {
84
- return history.listen(({
85
- location
86
- }) => {
87
- listener(location);
88
- });
89
- }
90
- };
91
- }
92
- function StyledComponentsRegistry(t0) {
93
- const $ = c(8), {
94
- children,
95
- isMounted
96
- } = t0;
97
- let t1;
98
- $[0] === Symbol.for("react.memo_cache_sentinel") ? (t1 = () => new ServerStyleSheet(), $[0] = t1) : t1 = $[0];
99
- const [styledComponentsStyleSheet] = useState(t1);
100
- let t2;
101
- if ($[1] !== styledComponentsStyleSheet ? (t2 = () => {
102
- const styles = styledComponentsStyleSheet.getStyleElement();
103
- return styledComponentsStyleSheet.instance.clearTag(), /* @__PURE__ */ jsx(Fragment, { children: styles });
104
- }, $[1] = styledComponentsStyleSheet, $[2] = t2) : t2 = $[2], useServerInsertedHTML(t2), isMounted) {
105
- let t32;
106
- return $[3] !== children ? (t32 = /* @__PURE__ */ jsx(Fragment, { children }), $[3] = children, $[4] = t32) : t32 = $[4], t32;
107
- }
108
- let t3;
109
- return $[5] !== styledComponentsStyleSheet.instance || $[6] !== children ? (t3 = /* @__PURE__ */ jsx(StyleSheetManager, { sheet: styledComponentsStyleSheet.instance, children }), $[5] = styledComponentsStyleSheet.instance, $[6] = children, $[7] = t3) : t3 = $[7], t3;
110
- }
111
- function useIsMounted() {
112
- const $ = c(2);
113
- let t0, t1;
114
- return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => !0, t1 = () => !1, $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), useSyncExternalStore(emptySubscribe, t0, t1);
115
- }
116
- const emptySubscribe = () => () => {
117
- }, NextStudioComponent = (t0) => {
118
- const $ = c(26);
119
- let t1, history, props, children, config, scheme;
120
- $[0] !== t0 ? ({
121
- children,
122
- config,
123
- unstable__noScript: t1,
124
- scheme,
125
- history,
126
- ...props
127
- } = t0, $[0] = t0, $[1] = t1, $[2] = history, $[3] = props, $[4] = children, $[5] = config, $[6] = scheme) : (t1 = $[1], history = $[2], props = $[3], children = $[4], config = $[5], scheme = $[6]);
128
- const unstable__noScript = t1 === void 0 ? !0 : t1, isMounted = useIsMounted();
129
- let t2;
130
- bb0: {
131
- if (props.unstable_history && history)
132
- throw new Error("Cannot use both `unstable_history` and `history` props at the same time");
133
- if (isMounted && history === "hash") {
134
- let t32;
135
- $[7] === Symbol.for("react.memo_cache_sentinel") ? (t32 = createHashHistoryForStudio(), $[7] = t32) : t32 = $[7], t2 = t32;
136
- break bb0;
137
- }
138
- t2 = props.unstable_history;
139
- }
140
- const unstableHistory = t2;
141
- let t3;
142
- $[8] !== unstable__noScript ? (t3 = unstable__noScript && /* @__PURE__ */ jsx(NextStudioNoScript, {}), $[8] = unstable__noScript, $[9] = t3) : t3 = $[9];
143
- let t4;
144
- $[10] !== history || $[11] !== isMounted || $[12] !== children || $[13] !== config || $[14] !== scheme || $[15] !== props || $[16] !== unstableHistory ? (t4 = history === "hash" && !isMounted ? null : children || /* @__PURE__ */ jsx(Studio, { config, scheme, unstable_globalStyles: !0, ...props, unstable_history: unstableHistory }), $[10] = history, $[11] = isMounted, $[12] = children, $[13] = config, $[14] = scheme, $[15] = props, $[16] = unstableHistory, $[17] = t4) : t4 = $[17];
145
- let t5;
146
- $[18] !== t4 ? (t5 = /* @__PURE__ */ jsx(NextStudioLayout, { children: t4 }), $[18] = t4, $[19] = t5) : t5 = $[19];
147
- let t6;
148
- $[20] !== isMounted || $[21] !== t5 ? (t6 = /* @__PURE__ */ jsx(StyledComponentsRegistry, { isMounted, children: t5 }), $[20] = isMounted, $[21] = t5, $[22] = t6) : t6 = $[22];
149
- let t7;
150
- return $[23] !== t3 || $[24] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Fragment, { children: [
151
- t3,
152
- t6
153
- ] }), $[23] = t3, $[24] = t6, $[25] = t7) : t7 = $[25], t7;
154
- }, NextStudio = memo(NextStudioComponent);
155
- export {
156
- NextStudio as default
157
- };
158
- //# sourceMappingURL=client-component.compiled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-component.compiled.js","sources":["../../src/studio/NextStudioLayout.tsx","../../src/studio/NextStudioNoScript.tsx","../../src/studio/client-component/createHashHistoryForStudio.ts","../../src/studio/client-component/registry.tsx","../../src/studio/client-component/useIsMounted.ts","../../src/studio/client-component/NextStudio.tsx"],"sourcesContent":["import {memo} from 'react'\n\n/** @public */\nexport interface NextStudioLayoutProps {\n children: React.ReactNode\n}\n\nconst NextStudioLayoutComponent = ({children}: NextStudioLayoutProps) => {\n return (\n <div\n id=\"sanity\"\n data-ui=\"NextStudioLayout\"\n style={{\n height: '100vh',\n maxHeight: '100dvh',\n overscrollBehavior: 'none',\n WebkitFontSmoothing: 'antialiased',\n overflow: 'auto',\n }}\n >\n {children}\n </div>\n )\n}\n\n/** @public */\nexport const NextStudioLayout = memo(NextStudioLayoutComponent)\n","/** @internal */\nexport const NextStudioNoScript = (): JSX.Element => (\n <noscript>\n <div\n style={{\n position: 'absolute',\n top: 0,\n right: 0,\n left: 0,\n bottom: 0,\n background: '#fff',\n zIndex: 1,\n }}\n >\n <div\n style={{\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n textAlign: 'center',\n fontFamily: 'helvetica, arial, sans-serif',\n }}\n >\n <h1>JavaScript disabled</h1>\n <p>\n Please <a href=\"https://www.enable-javascript.com/\">enable JavaScript</a> in your browser\n and reload the page to proceed.\n </p>\n </div>\n </div>\n </noscript>\n)\n","import {createHashHistory, type History, type Listener} from 'history'\n\n/** @internal */\nexport function createHashHistoryForStudio(): History {\n const history = createHashHistory()\n return {\n get action() {\n return history.action\n },\n get location() {\n return history.location\n },\n get createHref() {\n return history.createHref\n },\n get push() {\n return history.push\n },\n get replace() {\n return history.replace\n },\n get go() {\n return history.go\n },\n get back() {\n return history.back\n },\n get forward() {\n return history.forward\n },\n get block() {\n return history.block\n },\n // Overriding listen to workaround a problem where native history provides history.listen(location => void), but the npm package is history.listen(({action, location}) => void)\n listen(listener: Listener) {\n // return history.listen(({ action, location }) => {\n return history.listen(({location}) => {\n // console.debug('history.listen', action, location)\n // @ts-expect-error -- working around a bug? in studio\n listener(location)\n })\n },\n }\n}\n","// https://nextjs.org/docs/app/building-your-application/styling/css-in-js#styled-components\nimport {useServerInsertedHTML} from 'next/navigation.js'\nimport {useState} from 'react'\nimport {ServerStyleSheet, StyleSheetManager} from 'styled-components'\n\nexport function StyledComponentsRegistry({\n children,\n isMounted,\n}: {\n children: React.ReactNode\n isMounted: boolean\n}): JSX.Element {\n // Only create stylesheet once with lazy initial state\n // x-ref: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state\n const [styledComponentsStyleSheet] = useState(() => new ServerStyleSheet())\n\n useServerInsertedHTML(() => {\n const styles = styledComponentsStyleSheet.getStyleElement()\n styledComponentsStyleSheet.instance.clearTag()\n return <>{styles}</>\n })\n\n if (isMounted) return <>{children}</>\n\n return (\n <StyleSheetManager sheet={styledComponentsStyleSheet.instance}>{children}</StyleSheetManager>\n )\n}\n","import {useSyncExternalStore} from 'react'\n\n/** @internal */\nexport function useIsMounted(): boolean {\n return useSyncExternalStore(\n emptySubscribe,\n () => true,\n () => false,\n )\n}\n// eslint-disable-next-line no-empty-function\nconst emptySubscribe = () => () => {}\n","import {memo, useMemo} from 'react'\nimport {Studio, type StudioProps} from 'sanity'\n\nimport {NextStudioLayout} from '../NextStudioLayout'\nimport {NextStudioNoScript} from '../NextStudioNoScript'\nimport {createHashHistoryForStudio} from './createHashHistoryForStudio'\nimport {StyledComponentsRegistry} from './registry'\nimport {useIsMounted} from './useIsMounted'\n\n/** @public */\nexport interface NextStudioProps extends StudioProps {\n children?: React.ReactNode\n /**\n * Render the <noscript> tag\n * @defaultValue true\n * @alpha\n */\n unstable__noScript?: boolean\n /**\n * The 'hash' option is new feature that is not yet stable for production, but is available for testing and its API won't change in a breaking way.\n * If 'hash' doesn't work for you, or if you want to use a memory based history, you can use the `unstable_history` prop instead.\n * @alpha\n * @defaultValue 'browser'\n */\n history?: 'browser' | 'hash'\n}\n/**\n * Intended to render at the root of a page, letting the Studio own that page and render much like it would if you used `npx sanity start` to render\n * It's a drop-in replacement for `import {Studio} from 'sanity'`\n */\nconst NextStudioComponent = ({\n children,\n config,\n unstable__noScript = true,\n scheme,\n history,\n ...props\n}: NextStudioProps) => {\n const isMounted = useIsMounted()\n const unstableHistory = useMemo<typeof props.unstable_history>(() => {\n if (props.unstable_history && history) {\n throw new Error('Cannot use both `unstable_history` and `history` props at the same time')\n }\n\n if (isMounted && history === 'hash') {\n return createHashHistoryForStudio()\n }\n return props.unstable_history\n }, [history, isMounted, props.unstable_history])\n\n return (\n <>\n {unstable__noScript && <NextStudioNoScript />}\n <StyledComponentsRegistry isMounted={isMounted}>\n <NextStudioLayout>\n {history === 'hash' && !isMounted\n ? null\n : children || (\n <Studio\n config={config}\n scheme={scheme}\n unstable_globalStyles\n {...props}\n unstable_history={unstableHistory}\n />\n )}\n </NextStudioLayout>\n </StyledComponentsRegistry>\n </>\n )\n}\n\n/**\n * Override how the Studio renders by passing children.\n * This is useful for advanced use cases where you're using StudioProvider and StudioLayout instead of Studio:\n * ```\n * import {StudioProvider, StudioLayout} from 'sanity'\n * import {NextStudio} from 'next-sanity/studio'\n * <NextStudio config={config}>\n * <StudioProvider config={config}>\n * <CustomComponentThatUsesContextFromStudioProvider />\n * <StudioLayout />\n * </StudioProvider>\n * </NextStudio>\n * ```\n * @public\n */\nexport const NextStudio = memo(NextStudioComponent)\n"],"names":["NextStudioLayoutComponent","t0","$","_c","children","t1","Symbol","for","height","maxHeight","overscrollBehavior","WebkitFontSmoothing","overflow","t2","NextStudioLayout","memo","NextStudioNoScript","position","top","right","left","bottom","background","zIndex","transform","textAlign","fontFamily","t3","createHashHistoryForStudio","history","createHashHistory","action","location","createHref","push","replace","go","back","forward","block","listen","listener","StyledComponentsRegistry","isMounted","ServerStyleSheet","styledComponentsStyleSheet","useState","styles","getStyleElement","instance","clearTag","useServerInsertedHTML","useIsMounted","useSyncExternalStore","emptySubscribe","NextStudioComponent","props","config","scheme","unstable__noScript","undefined","unstable_history","Error","bb0","unstableHistory","t4","t5","t6","t7","NextStudio"],"mappings":";;;;;;;;AAOA,MAAMA,4BAA4BC,CAAA,OAAA;AAAAC,QAAAA,IAAAC,EAAA,CAAA,GAAC;AAAA,IAAAC;AAAAA,EAAAH,IAAAA;AAAiCI,MAAAA;AAAAH,IAAA,CAAA,MAAAI,OAAAC,IAAA,2BAAA,KAKvDF,KAAA;AAAA,IAAAG,QACG;AAAA,IAAOC,WACJ;AAAA,IAAQC,oBACC;AAAA,IAAMC,qBACL;AAAA,IAAaC,UACxB;AAAA,EAAA,GACXV,OAAAG,MAAAA,KAAAH,EAAA,CAAA;AAAAW,MAAAA;AAAAX,SAAAA,SAAAE,YATHS,kCACK,IAAA,UACK,WAAA,oBACD,OAAAR,IAQE,UACX,GAAMH,OAAAE,UAAAF,OAAAW,MAAAA,KAAAX,EAAA,CAAA,GAZNW;AAYM,GAKGC,mBAAmBC,KAAKf,yBAAyB,GCzBjDgB,qBAAqBA,MAAA;AAAAd,QAAAA,IAAAC,EAAA,CAAA;AAAA,MAAAF,IAAAI,IAAAQ;AAAAX,IAAA,CAAA,MAAAI,OAAAC,IAAA,2BAAA,KAGrBN,KAAA;AAAA,IAAAgB,U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AAA,MAAAzB,UAAAiE,MAhB7BC,KACGzC,qBAAAA,UAAAA,EAAAA,UAAAA;AAAAA,IAAAA;AAAAA,IACDwC;AAAAA,EAAAA,EAc2B,CAAA,GAC1BjE,QAAAyB,IAAAzB,QAAAiE,IAAAjE,QAAAkE,MAAAA,KAAAlE,EAAA,EAAA,GAjBHkE;AAiBG,GAmBMC,aAAatD,KAAKwC,mBAAmB;"}
@@ -1,113 +0,0 @@
1
- "use client";
2
- import { c } from "react/compiler-runtime";
3
- import { enableVisualEditing } from "@sanity/visual-editing";
4
- import { useRouter, usePathname, useSearchParams } from "next/navigation.js";
5
- import { revalidateRootLayout } from "next-sanity/visual-editing/server-actions";
6
- import { useRef, useState, useEffect } from "react";
7
- function pathHasPrefix(path, prefix) {
8
- if (typeof path != "string")
9
- return !1;
10
- const {
11
- pathname
12
- } = parsePath(path);
13
- return pathname === prefix || pathname.startsWith(`${prefix}/`);
14
- }
15
- function parsePath(path) {
16
- const hashIndex = path.indexOf("#"), queryIndex = path.indexOf("?"), hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex);
17
- return hasQuery || hashIndex > -1 ? {
18
- pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),
19
- query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : void 0) : "",
20
- hash: hashIndex > -1 ? path.slice(hashIndex) : ""
21
- } : {
22
- pathname: path,
23
- query: "",
24
- hash: ""
25
- };
26
- }
27
- function addPathPrefix(path, prefix) {
28
- if (!path.startsWith("/") || !prefix)
29
- return path;
30
- if (path === "/" && prefix)
31
- return prefix;
32
- const {
33
- pathname,
34
- query,
35
- hash
36
- } = parsePath(path);
37
- return `${prefix}${pathname}${query}${hash}`;
38
- }
39
- function removePathPrefix(path, prefix) {
40
- if (!pathHasPrefix(path, prefix))
41
- return path;
42
- const withoutPrefix = path.slice(prefix.length);
43
- return withoutPrefix.startsWith("/") ? withoutPrefix : `/${withoutPrefix}`;
44
- }
45
- const normalizePathTrailingSlash = (path, trailingSlash) => {
46
- const {
47
- pathname,
48
- query,
49
- hash
50
- } = parsePath(path);
51
- return trailingSlash ? pathname.endsWith("/") ? `${pathname}${query}${hash}` : `${pathname}/${query}${hash}` : `${removeTrailingSlash(pathname)}${query}${hash}`;
52
- };
53
- function removeTrailingSlash(route) {
54
- return route.replace(/\/$/, "") || "/";
55
- }
56
- function VisualEditing(props) {
57
- const $ = c(15), {
58
- refresh,
59
- zIndex,
60
- basePath: t0,
61
- trailingSlash: t1
62
- } = props, basePath = t0 === void 0 ? "" : t0, trailingSlash = t1 === void 0 ? !1 : t1, router = useRouter(), routerRef = useRef(router), [navigate, setNavigate] = useState();
63
- let t2, t3;
64
- $[0] !== router ? (t2 = () => {
65
- routerRef.current = router;
66
- }, t3 = [router], $[0] = router, $[1] = t2, $[2] = t3) : (t2 = $[1], t3 = $[2]), useEffect(t2, t3);
67
- let t4, t5;
68
- $[3] !== zIndex || $[4] !== refresh || $[5] !== basePath ? (t4 = () => {
69
- const disable = enableVisualEditing({
70
- zIndex,
71
- refresh: refresh || ((payload) => {
72
- switch (payload.source) {
73
- case "manual":
74
- return payload.livePreviewEnabled ? manualFastRefresh() : manualFallbackRefresh();
75
- case "mutation":
76
- return payload.livePreviewEnabled ? mutationFastRefresh() : mutationFallbackRefresh();
77
- default:
78
- throw new Error("Unknown refresh source", {
79
- cause: payload
80
- });
81
- }
82
- }),
83
- history: {
84
- subscribe: (_navigate) => (setNavigate(() => _navigate), () => setNavigate(void 0)),
85
- update: (update) => {
86
- switch (update.type) {
87
- case "push":
88
- return routerRef.current.push(removePathPrefix(update.url, basePath));
89
- case "pop":
90
- return routerRef.current.back();
91
- case "replace":
92
- return routerRef.current.replace(removePathPrefix(update.url, basePath));
93
- default:
94
- throw new Error(`Unknown update type: ${update.type}`);
95
- }
96
- }
97
- }
98
- }), manualFastRefresh = () => (console.debug("Live preview is setup, calling router.refresh() to refresh the server components without refetching cached data"), routerRef.current.refresh(), Promise.resolve()), manualFallbackRefresh = () => (console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"), revalidateRootLayout()), mutationFastRefresh = () => (console.debug("Live preview is setup, mutation is skipped assuming its handled by the live preview"), !1), mutationFallbackRefresh = () => (console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"), revalidateRootLayout());
99
- return () => disable();
100
- }, t5 = [basePath, refresh, zIndex], $[3] = zIndex, $[4] = refresh, $[5] = basePath, $[6] = t4, $[7] = t5) : (t4 = $[6], t5 = $[7]), useEffect(t4, t5);
101
- const pathname = usePathname(), searchParams = useSearchParams();
102
- let t6, t7;
103
- return $[8] !== navigate || $[9] !== pathname || $[10] !== searchParams || $[11] !== basePath || $[12] !== trailingSlash ? (t6 = () => {
104
- navigate && navigate({
105
- type: "push",
106
- url: normalizePathTrailingSlash(addPathPrefix(`${pathname}${searchParams != null && searchParams.size ? `?${searchParams}` : ""}`, basePath), trailingSlash)
107
- });
108
- }, t7 = [basePath, navigate, pathname, searchParams, trailingSlash], $[8] = navigate, $[9] = pathname, $[10] = searchParams, $[11] = basePath, $[12] = trailingSlash, $[13] = t6, $[14] = t7) : (t6 = $[13], t7 = $[14]), useEffect(t6, t7), null;
109
- }
110
- export {
111
- VisualEditing as default
112
- };
113
- //# sourceMappingURL=client-component.compiled.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-component.compiled.js","sources":["../../src/visual-editing/client-component/utils.ts","../../src/visual-editing/client-component/index.ts"],"sourcesContent":["/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/path-has-prefix.ts#L10-L17\n * Checks if a given path starts with a given prefix. It ensures it matches\n * exactly without containing extra chars. e.g. prefix /docs should replace\n * for /docs, /docs/, /docs/a but not /docsss\n * @param path The path to check.\n * @param prefix The prefix to check against.\n */\nfunction pathHasPrefix(path: string, prefix: string): boolean {\n if (typeof path !== 'string') {\n return false\n }\n\n const {pathname} = parsePath(path)\n return pathname === prefix || pathname.startsWith(`${prefix}/`)\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/parse-path.ts#L6-L22\n * Given a path this function will find the pathname, query and hash and return\n * them. This is useful to parse full paths on the client side.\n * @param path A path to parse e.g. /foo/bar?id=1#hash\n */\nfunction parsePath(path: string): {\n pathname: string\n query: string\n hash: string\n} {\n const hashIndex = path.indexOf('#')\n const queryIndex = path.indexOf('?')\n const hasQuery = queryIndex > -1 && (hashIndex < 0 || queryIndex < hashIndex)\n\n if (hasQuery || hashIndex > -1) {\n return {\n pathname: path.substring(0, hasQuery ? queryIndex : hashIndex),\n query: hasQuery ? path.substring(queryIndex, hashIndex > -1 ? hashIndex : undefined) : '',\n hash: hashIndex > -1 ? path.slice(hashIndex) : '',\n }\n }\n\n return {pathname: path, query: '', hash: ''}\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/add-path-prefix.ts#L3C1-L14C2\n * Adds the provided prefix to the given path. It first ensures that the path\n * is indeed starting with a slash.\n */\nexport function addPathPrefix(path: string, prefix?: string): string {\n if (!path.startsWith('/') || !prefix) {\n return path\n }\n // If the path is exactly '/' then return just the prefix\n if (path === '/' && prefix) {\n return prefix\n }\n\n const {pathname, query, hash} = parsePath(path)\n return `${prefix}${pathname}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/5469e6427b54ab7e9876d4c85b47f9c3afdc5c1f/packages/next/src/shared/lib/router/utils/remove-path-prefix.ts#L3-L39\n * Given a path and a prefix it will remove the prefix when it exists in the\n * given path. It ensures it matches exactly without containing extra chars\n * and if the prefix is not there it will be noop.\n *\n * @param path The path to remove the prefix from.\n * @param prefix The prefix to be removed.\n */\nexport function removePathPrefix(path: string, prefix: string): string {\n // If the path doesn't start with the prefix we can return it as is. This\n // protects us from situations where the prefix is a substring of the path\n // prefix such as:\n //\n // For prefix: /blog\n //\n // /blog -> true\n // /blog/ -> true\n // /blog/1 -> true\n // /blogging -> false\n // /blogging/ -> false\n // /blogging/1 -> false\n if (!pathHasPrefix(path, prefix)) {\n return path\n }\n\n // Remove the prefix from the path via slicing.\n const withoutPrefix = path.slice(prefix.length)\n\n // If the path without the prefix starts with a `/` we can return it as is.\n if (withoutPrefix.startsWith('/')) {\n return withoutPrefix\n }\n\n // If the path without the prefix doesn't start with a `/` we need to add it\n // back to the path to make sure it's a valid path.\n return `/${withoutPrefix}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/client/normalize-trailing-slash.ts#L16\n * Normalizes the trailing slash of a path according to the `trailingSlash` option\n * in `next.config.js`.\n */\nexport const normalizePathTrailingSlash = (path: string, trailingSlash: boolean): string => {\n const {pathname, query, hash} = parsePath(path)\n if (trailingSlash) {\n if (pathname.endsWith('/')) {\n return `${pathname}${query}${hash}`\n }\n return `${pathname}/${query}${hash}`\n }\n\n return `${removeTrailingSlash(pathname)}${query}${hash}`\n}\n\n/**\n * From: https://github.com/vercel/next.js/blob/dfe7fc03e2268e7cb765dce6a89e02c831c922d5/packages/next/src/shared/lib/router/utils/remove-trailing-slash.ts#L8\n * Removes the trailing slash for a given route or page path. Preserves the\n * root page. Examples:\n * - `/foo/bar/` -> `/foo/bar`\n * - `/foo/bar` -> `/foo/bar`\n * - `/` -> `/`\n */\nfunction removeTrailingSlash(route: string) {\n return route.replace(/\\/$/, '') || '/'\n}\n","'use client'\nimport {\n enableVisualEditing,\n type HistoryAdapterNavigate,\n type VisualEditingOptions,\n} from '@sanity/visual-editing'\nimport {usePathname, useRouter, useSearchParams} from 'next/navigation.js'\nimport {revalidateRootLayout} from 'next-sanity/visual-editing/server-actions'\nimport {useEffect, useRef, useState} from 'react'\n\nimport {addPathPrefix, normalizePathTrailingSlash, removePathPrefix} from './utils'\n\n/**\n * @public\n */\nexport interface VisualEditingProps extends Omit<VisualEditingOptions, 'history'> {\n /**\n * @deprecated The histoy adapter is already implemented\n */\n history?: never\n /**\n * If next.config.ts is configured with a basePath we try to configure it automatically,\n * you can disable this by setting basePath to ''.\n * @example basePath=\"/my-custom-base-path\"\n * @alpha experimental and may change without notice\n * @defaultValue process.env.__NEXT_ROUTER_BASEPATH || ''\n */\n basePath?: string\n /**\n * If next.config.ts is configured with a `trailingSlash` we try to detect it automatically,\n * it can be controlled manually by passing a boolean.\n * @example trailingSlash={true}\n * @alpha experimental and may change without notice\n * @defaultValue Boolean(process.env.__NEXT_TRAILING_SLASH)\n */\n trailingSlash?: boolean\n}\n\nexport default function VisualEditing(props: VisualEditingProps): null {\n const {refresh, zIndex, basePath = '', trailingSlash = false} = props\n\n const router = useRouter()\n const routerRef = useRef(router)\n const [navigate, setNavigate] = useState<HistoryAdapterNavigate | undefined>()\n\n useEffect(() => {\n routerRef.current = router\n }, [router])\n useEffect(() => {\n const disable = enableVisualEditing({\n zIndex,\n refresh: refresh\n ? refresh\n : (payload) => {\n switch (payload.source) {\n case 'manual':\n return payload.livePreviewEnabled ? manualFastRefresh() : manualFallbackRefresh()\n case 'mutation':\n return payload.livePreviewEnabled\n ? mutationFastRefresh()\n : mutationFallbackRefresh()\n default:\n throw new Error('Unknown refresh source', {cause: payload})\n }\n },\n history: {\n subscribe: (_navigate) => {\n setNavigate(() => _navigate)\n return () => setNavigate(undefined)\n },\n update: (update) => {\n switch (update.type) {\n case 'push':\n return routerRef.current.push(removePathPrefix(update.url, basePath))\n case 'pop':\n return routerRef.current.back()\n case 'replace':\n return routerRef.current.replace(removePathPrefix(update.url, basePath))\n default:\n throw new Error(`Unknown update type: ${update.type}`)\n }\n },\n },\n })\n\n const manualFastRefresh = () => {\n // eslint-disable-next-line no-console\n console.debug(\n 'Live preview is setup, calling router.refresh() to refresh the server components without refetching cached data',\n )\n routerRef.current.refresh()\n return Promise.resolve()\n }\n const manualFallbackRefresh = () => {\n // eslint-disable-next-line no-console\n console.debug(\n 'No loaders in live mode detected, or preview kit setup, revalidating root layout',\n )\n return revalidateRootLayout()\n }\n const mutationFastRefresh = (): false => {\n // eslint-disable-next-line no-console\n console.debug(\n 'Live preview is setup, mutation is skipped assuming its handled by the live preview',\n )\n return false\n }\n const mutationFallbackRefresh = () => {\n // eslint-disable-next-line no-console\n console.debug(\n 'No loaders in live mode detected, or preview kit setup, revalidating root layout',\n )\n return revalidateRootLayout()\n }\n\n return () => disable()\n }, [basePath, refresh, zIndex])\n\n const pathname = usePathname()\n const searchParams = useSearchParams()\n useEffect(() => {\n if (navigate) {\n navigate({\n type: 'push',\n url: normalizePathTrailingSlash(\n addPathPrefix(`${pathname}${searchParams?.size ? `?${searchParams}` : ''}`, basePath),\n trailingSlash,\n ),\n })\n }\n }, [basePath, navigate, pathname, searchParams, trailingSlash])\n\n return null\n}\n"],"names":["pathHasPrefix","path","prefix","pathname","parsePath","startsWith","hashIndex","indexOf","queryIndex","hasQuery","substring","query","undefined","hash","slice","addPathPrefix","removePathPrefix","withoutPrefix","length","normalizePathTrailingSlash","trailingSlash","endsWith","removeTrailingSlash","route","replace","VisualEditing","props","$","_c","refresh","zIndex","basePath","t0","t1","router","useRouter","routerRef","useRef","navigate","setNavigate","useState","t2","t3","current","useEffect","t4","t5","disable","enableVisualEditing","payload","source","livePreviewEnabled","manualFastRefresh","manualFallbackRefresh","mutationFastRefresh","mutationFallbackRefresh","Error","cause","history","subscribe","_navigate","update","type","push","url","back","console","debug","Promise","resolve","revalidateRootLayout","usePathname","searchParams","useSearchParams","t6","t7","size"],"mappings":";;;;;;AAQA,SAASA,cAAcC,MAAcC,QAAyB;AAC5D,MAAI,OAAOD,QAAS;AACX,WAAA;AAGH,QAAA;AAAA,IAACE;AAAAA,EAAAA,IAAYC,UAAUH,IAAI;AACjC,SAAOE,aAAaD,UAAUC,SAASE,WAAW,GAAGH,MAAM,GAAG;AAChE;AAQA,SAASE,UAAUH,MAIjB;AACA,QAAMK,YAAYL,KA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