@preprio/prepr-nextjs 2.0.0-alpha.8 → 2.0.0-alpha.9

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/README.md CHANGED
@@ -168,3 +168,10 @@ Helper function that will either return the customer id header or the preview he
168
168
 
169
169
  #### getPreviewBarProps()
170
170
  Helper function to get the props for the PreviewBar component. Will return the segments and A/B testing variants aswell as an aray of all the segments.
171
+
172
+ ## 📌 Upgrade from v1 to v2
173
+
174
+ If you’re upgrading from **Prepr Next.js v1** to **v2**,
175
+ please follow the [Upgrade Guide](./UPGRADE_GUIDE.mdx) for step-by-step instructions.
176
+
177
+ This guide will help you update your middleware, helper imports, and preview toolbar usage.
@@ -1,4 +1,4 @@
1
- 'use strict';var headers=require('next/headers');var n=(e,r,t)=>new Promise((s,d)=>{var u=i=>{try{a(t.next(i));}catch(p){d(p);}},l=i=>{try{a(t.throw(i));}catch(p){d(p);}},a=i=>i.done?s(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(e,r)).next());});var o={version:"2.0.0-alpha.8"};function w(){return n(this,null,function*(){return (yield headers.headers()).get("prepr-customer-id")})}function g(){return n(this,null,function*(){return (yield headers.headers()).get("Prepr-Segments")})}function x(){return n(this,null,function*(){return (yield headers.headers()).get("Prepr-ABtesting")})}function k(){return n(this,null,function*(){let e={};return (yield headers.headers()).forEach((t,s)=>{s.startsWith("prepr")&&(e[s]=t);}),e})}function h(e){return n(this,null,function*(){var r;if(!e)return console.error("No token provided, make sure you are using your Prepr GraphQL URL"),[];if(!e.startsWith("https://"))return console.error("Invalid token provided, make sure you are using your Prepr GraphQL URL"),[];try{let t=yield fetch(e,{headers:{"User-Agent":`Prepr-Preview-Bar/${y()}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({query:`{
1
+ 'use strict';var headers=require('next/headers');var n=(e,r,t)=>new Promise((s,d)=>{var u=i=>{try{a(t.next(i));}catch(p){d(p);}},l=i=>{try{a(t.throw(i));}catch(p){d(p);}},a=i=>i.done?s(i.value):Promise.resolve(i.value).then(u,l);a((t=t.apply(e,r)).next());});var o={version:"2.0.0-alpha.9"};function w(){return n(this,null,function*(){return (yield headers.headers()).get("prepr-customer-id")})}function g(){return n(this,null,function*(){return (yield headers.headers()).get("Prepr-Segments")})}function x(){return n(this,null,function*(){return (yield headers.headers()).get("Prepr-ABtesting")})}function k(){return n(this,null,function*(){let e={};return (yield headers.headers()).forEach((t,s)=>{s.startsWith("prepr")&&(e[s]=t);}),e})}function h(e){return n(this,null,function*(){var r;if(!e)return console.error("No token provided, make sure you are using your Prepr GraphQL URL"),[];if(!e.startsWith("https://"))return console.error("Invalid token provided, make sure you are using your Prepr GraphQL URL"),[];try{let t=yield fetch(e,{headers:{"User-Agent":`Prepr-Preview-Bar/${y()}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({query:`{
2
2
  _Segments {
3
3
  _id
4
4
  name
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/server/index.ts","../../package.json"],"names":["package_default","getPreprUUID","__async","headers","getActiveSegment","getActiveVariant","getPreprHeaders","newHeaders","value","key","getPreprEnvironmentSegments","token","_a","response","getPackageVersion","json","e","error","getPreviewBarProps","data","activeSegment","activeVariant"],"mappings":"iDAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA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AAA,EAAiB,CACvCiB,EAAgB,MAAMhB,CAAAA,EAAiB,CAAA,CAGlC,CACL,aAAA,CAAAe,CAAAA,CACA,cAAAC,CAAAA,CACA,IAAA,CAAAF,CACF,CACF,CAAA,CAAA,CAEA,SAASL,CAAAA,EAAoB,CAC3B,OAAOd,CAAAA,CAAM,OACf","file":"index.cjs","sourcesContent":["import { headers } from 'next/headers';\nimport { PreprPreviewBarProps, PreprSegment } from '../types';\nimport pjson from '../../package.json';\n\n/**\n * Returns the Prepr Customer ID from the headers\n */\nexport async function getPreprUUID() {\n const headersList = await headers();\n return headersList.get('prepr-customer-id');\n}\n\n/**\n * Retuns the active segment from the headers\n */\nexport async function getActiveSegment() {\n const headersList = await headers();\n return headersList.get('Prepr-Segments');\n}\n\n/**\n * Returns the active variant from the headers\n */\nexport async function getActiveVariant() {\n const headersList = await headers();\n return headersList.get('Prepr-ABtesting');\n}\n\n/**\n * Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)\n */\nexport async function getPreprHeaders() {\n const newHeaders: {\n [key: string]: string;\n } = {};\n\n const headersList = await headers();\n\n headersList.forEach((value, key) => {\n if (key.startsWith('prepr')) {\n newHeaders[key] = value;\n }\n });\n\n return newHeaders;\n}\n\n/**\n * Fetches the segments from the Prepr API\n * @param token Prepr access token with scope 'segments'\n * @returns Array of PreprSegmentResponse\n */\nexport async function getPreprEnvironmentSegments(\n token: string\n): Promise<PreprSegment[]> {\n if (!token) {\n console.error(\n 'No token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n if (!token.startsWith('https://')) {\n console.error(\n 'Invalid token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n try {\n const response = await fetch(token, {\n headers: {\n 'User-Agent': `Prepr-Preview-Bar/${getPackageVersion()}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n query: `{\n _Segments {\n _id\n name\n }\n }`,\n }),\n });\n try {\n const json = await response.json();\n\n if (!json || !json.data || !json.data._Segments) {\n return [];\n }\n\n return json.data?._Segments as PreprSegment[];\n } catch {\n console.error('Error parsing JSON, please contact Prepr support');\n return [];\n }\n } catch (error) {\n console.error('Error fetching segments:', error);\n return [];\n }\n}\n\n/**\n * Fetches all the necessary previewbar props\n * @param token Prepr access token with scope 'segments'\n * @returns Object with activeSegment, activeVariant and data\n */\nexport async function getPreviewBarProps(\n token: string\n): Promise<PreprPreviewBarProps> {\n let data: PreprSegment[] = [];\n let activeSegment: string | null = null;\n let activeVariant: string | null = null;\n\n // Prevent unnecessary function calling in production\n if (process.env.PREPR_ENV === 'preview') {\n data = await getPreprEnvironmentSegments(token);\n activeSegment = await getActiveSegment();\n activeVariant = await getActiveVariant();\n }\n\n return {\n activeSegment,\n activeVariant,\n data,\n };\n}\n\nfunction getPackageVersion() {\n return pjson.version;\n}\n","{\n \"name\": \"@preprio/prepr-nextjs\",\n \"version\": \"2.0.0-alpha.8\",\n \"description\": \"Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities\",\n \"main\": \"dist/react/index.cjs\",\n \"types\": \"./dist/react/index.d.ts\",\n \"module\": \"./dist/react/index.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"dev:css\": \"postcss ./src/globals.css -o ./src/output.css --watch\",\n \"build:css\": \"NODE_ENV=production postcss ./src/globals.css -o ./dist/index.css\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"clean\": \"rm -rf dist\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"release\": \"node scripts/release.js\",\n \"check\": \"npm run type-check && npm run lint:check && npm run format:check\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint src --ext .ts,.tsx --fix\",\n \"lint:check\": \"eslint src --ext .ts,.tsx\",\n \"prepublishOnly\": \"npm run check && npm run build\"\n },\n \"exports\": {\n \"./middleware\": {\n \"import\": \"./dist/middleware/index.js\",\n \"types\": \"./dist/middleware/index.d.ts\",\n \"require\": \"./dist/middleware/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server/index.js\",\n \"types\": \"./dist/server/index.d.ts\",\n \"require\": \"./dist/server/index.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react/index.js\",\n \"types\": \"./dist/react/index.d.ts\",\n \"require\": \"./dist/react/index.cjs\"\n },\n \"./contexts\": {\n \"import\": \"./dist/contexts/index.js\",\n \"types\": \"./dist/contexts/index.d.ts\",\n \"require\": \"./dist/contexts/index.cjs\"\n },\n \"./utils\": {\n \"import\": \"./dist/utils/index.js\",\n \"types\": \"./dist/utils/index.d.ts\",\n \"require\": \"./dist/utils/index.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/types/index.js\",\n \"types\": \"./dist/types/index.d.ts\",\n \"require\": \"./dist/types/index.cjs\"\n },\n \"./index.css\": {\n \"import\": \"./dist/index.css\",\n \"require\": \"./dist/index.css\"\n }\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"keywords\": [\n \"prepr\",\n \"cms\",\n \"nextjs\",\n \"preview\",\n \"visual-editing\",\n \"headless-cms\",\n \"react\",\n \"typescript\",\n \"debug\",\n \"stega\"\n ],\n \"author\": \"Preprio\",\n \"license\": \"MIT\",\n \"packageManager\": \"pnpm@10.5.2\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.25.1\",\n \"@types/node\": \"^20.11.5\",\n \"@types/react\": \"19.1.0\",\n \"@types/react-dom\": \"19.1.2\",\n \"@typescript-eslint/eslint-plugin\": \"^8.31.1\",\n \"@typescript-eslint/parser\": \"^8.31.1\",\n \"autoprefixer\": \"^10.4.21\",\n \"cssnano\": \"^7.0.7\",\n \"eslint\": \"^9.25.1\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"eslint-plugin-react\": \"^7.37.2\",\n \"eslint-plugin-react-hooks\": \"^5.0.0\",\n \"next\": \"15.3.1\",\n \"postcss\": \"^8\",\n \"prettier\": \"^3.5.3\",\n \"prettier-plugin-tailwindcss\": \"^0.5.12\",\n \"react\": \"^19.1.0\",\n \"react-dom\": \"^19.1.0\",\n \"tailwindcss\": \"^3.4.17\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"peerDependencies\": {\n \"next\": \"^15.0.0 || ^14.0.0 || ^13.0.0\",\n \"react\": \"^19.0.0 || ^18.0.0 || ^17.0.0 \",\n \"react-dom\": \"^19.0.0 || ^18.0.0 || ^17.0.0\"\n },\n \"dependencies\": {\n \"@headlessui/react\": \"^2.2.0\",\n \"@vercel/functions\": \"^2.0.0\",\n \"@vercel/stega\": \"^0.1.2\",\n \"clsx\": \"^2.1.1\",\n \"postcss-cli\": \"^11.0.1\",\n \"tailwind-merge\": \"^3.0.1\"\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/server/index.ts","../../package.json"],"names":["package_default","getPreprUUID","__async","headers","getActiveSegment","getActiveVariant","getPreprHeaders","newHeaders","value","key","getPreprEnvironmentSegments","token","_a","response","getPackageVersion","json","e","error","getPreviewBarProps","data","activeSegment","activeVariant"],"mappings":"iDAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,IAAA,OAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,IAAA,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,EAAA,CAAA,MAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAA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MhB,CAAAA,EAAiB,CACvCiB,EAAgB,MAAMhB,CAAAA,EAAiB,CAAA,CAGlC,CACL,aAAA,CAAAe,CAAAA,CACA,cAAAC,CAAAA,CACA,IAAA,CAAAF,CACF,CACF,CAAA,CAAA,CAEA,SAASL,CAAAA,EAAoB,CAC3B,OAAOd,CAAAA,CAAM,OACf","file":"index.cjs","sourcesContent":["import { headers } from 'next/headers';\nimport { PreprPreviewBarProps, PreprSegment } from '../types';\nimport pjson from '../../package.json';\n\n/**\n * Returns the Prepr Customer ID from the headers\n */\nexport async function getPreprUUID() {\n const headersList = await headers();\n return headersList.get('prepr-customer-id');\n}\n\n/**\n * Retuns the active segment from the headers\n */\nexport async function getActiveSegment() {\n const headersList = await headers();\n return headersList.get('Prepr-Segments');\n}\n\n/**\n * Returns the active variant from the headers\n */\nexport async function getActiveVariant() {\n const headersList = await headers();\n return headersList.get('Prepr-ABtesting');\n}\n\n/**\n * Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)\n */\nexport async function getPreprHeaders() {\n const newHeaders: {\n [key: string]: string;\n } = {};\n\n const headersList = await headers();\n\n headersList.forEach((value, key) => {\n if (key.startsWith('prepr')) {\n newHeaders[key] = value;\n }\n });\n\n return newHeaders;\n}\n\n/**\n * Fetches the segments from the Prepr API\n * @param token Prepr access token with scope 'segments'\n * @returns Array of PreprSegmentResponse\n */\nexport async function getPreprEnvironmentSegments(\n token: string\n): Promise<PreprSegment[]> {\n if (!token) {\n console.error(\n 'No token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n if (!token.startsWith('https://')) {\n console.error(\n 'Invalid token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n try {\n const response = await fetch(token, {\n headers: {\n 'User-Agent': `Prepr-Preview-Bar/${getPackageVersion()}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n query: `{\n _Segments {\n _id\n name\n }\n }`,\n }),\n });\n try {\n const json = await response.json();\n\n if (!json || !json.data || !json.data._Segments) {\n return [];\n }\n\n return json.data?._Segments as PreprSegment[];\n } catch {\n console.error('Error parsing JSON, please contact Prepr support');\n return [];\n }\n } catch (error) {\n console.error('Error fetching segments:', error);\n return [];\n }\n}\n\n/**\n * Fetches all the necessary previewbar props\n * @param token Prepr access token with scope 'segments'\n * @returns Object with activeSegment, activeVariant and data\n */\nexport async function getPreviewBarProps(\n token: string\n): Promise<PreprPreviewBarProps> {\n let data: PreprSegment[] = [];\n let activeSegment: string | null = null;\n let activeVariant: string | null = null;\n\n // Prevent unnecessary function calling in production\n if (process.env.PREPR_ENV === 'preview') {\n data = await getPreprEnvironmentSegments(token);\n activeSegment = await getActiveSegment();\n activeVariant = await getActiveVariant();\n }\n\n return {\n activeSegment,\n activeVariant,\n data,\n };\n}\n\nfunction getPackageVersion() {\n return pjson.version;\n}\n","{\n \"name\": \"@preprio/prepr-nextjs\",\n \"version\": \"2.0.0-alpha.9\",\n \"description\": \"Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities\",\n \"main\": \"dist/react/index.cjs\",\n \"types\": \"./dist/react/index.d.ts\",\n \"module\": \"./dist/react/index.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"dev:css\": \"postcss ./src/globals.css -o ./src/output.css --watch\",\n \"build:css\": \"NODE_ENV=production postcss ./src/globals.css -o ./dist/index.css\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"clean\": \"rm -rf dist\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"release\": \"node scripts/release.js\",\n \"check\": \"npm run type-check && npm run lint:check && npm run format:check\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint src --ext .ts,.tsx --fix\",\n \"lint:check\": \"eslint src --ext .ts,.tsx\",\n \"prepublishOnly\": \"npm run check && npm run build\"\n },\n \"exports\": {\n \"./middleware\": {\n \"import\": \"./dist/middleware/index.js\",\n \"types\": \"./dist/middleware/index.d.ts\",\n \"require\": \"./dist/middleware/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server/index.js\",\n \"types\": \"./dist/server/index.d.ts\",\n \"require\": \"./dist/server/index.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react/index.js\",\n \"types\": \"./dist/react/index.d.ts\",\n \"require\": \"./dist/react/index.cjs\"\n },\n \"./contexts\": {\n \"import\": \"./dist/contexts/index.js\",\n \"types\": \"./dist/contexts/index.d.ts\",\n \"require\": \"./dist/contexts/index.cjs\"\n },\n \"./utils\": {\n \"import\": \"./dist/utils/index.js\",\n \"types\": \"./dist/utils/index.d.ts\",\n \"require\": \"./dist/utils/index.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/types/index.js\",\n \"types\": \"./dist/types/index.d.ts\",\n \"require\": \"./dist/types/index.cjs\"\n },\n \"./index.css\": {\n \"import\": \"./dist/index.css\",\n \"require\": \"./dist/index.css\"\n }\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"keywords\": [\n \"prepr\",\n \"cms\",\n \"nextjs\",\n \"preview\",\n \"visual-editing\",\n \"headless-cms\",\n \"react\",\n \"typescript\",\n \"debug\",\n \"stega\"\n ],\n \"author\": \"Preprio\",\n \"license\": \"MIT\",\n \"packageManager\": \"pnpm@10.5.2\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.25.1\",\n \"@types/node\": \"^20.11.5\",\n \"@types/react\": \"19.1.0\",\n \"@types/react-dom\": \"19.1.2\",\n \"@typescript-eslint/eslint-plugin\": \"^8.31.1\",\n \"@typescript-eslint/parser\": \"^8.31.1\",\n \"autoprefixer\": \"^10.4.21\",\n \"cssnano\": \"^7.0.7\",\n \"eslint\": \"^9.25.1\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"eslint-plugin-react\": \"^7.37.2\",\n \"eslint-plugin-react-hooks\": \"^5.0.0\",\n \"next\": \"15.3.1\",\n \"postcss\": \"^8\",\n \"prettier\": \"^3.5.3\",\n \"prettier-plugin-tailwindcss\": \"^0.5.12\",\n \"react\": \"^19.1.0\",\n \"react-dom\": \"^19.1.0\",\n \"tailwindcss\": \"^3.4.17\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"peerDependencies\": {\n \"next\": \"^15.0.0 || ^14.0.0 || ^13.0.0\",\n \"react\": \"^19.0.0 || ^18.0.0 || ^17.0.0 \",\n \"react-dom\": \"^19.0.0 || ^18.0.0 || ^17.0.0\"\n },\n \"dependencies\": {\n \"@headlessui/react\": \"^2.2.0\",\n \"@vercel/functions\": \"^2.0.0\",\n \"@vercel/stega\": \"^0.1.2\",\n \"clsx\": \"^2.1.1\",\n \"postcss-cli\": \"^11.0.1\",\n \"tailwind-merge\": \"^3.0.1\"\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import {c as c$1}from'../chunk-E7ATRJ2F.js';import {headers}from'next/headers';var c={version:"2.0.0-alpha.8"};function x(){return c$1(this,null,function*(){return (yield headers()).get("prepr-customer-id")})}function p(){return c$1(this,null,function*(){return (yield headers()).get("Prepr-Segments")})}function d(){return c$1(this,null,function*(){return (yield headers()).get("Prepr-ABtesting")})}function h(){return c$1(this,null,function*(){let e={};return (yield headers()).forEach((s,t)=>{t.startsWith("prepr")&&(e[t]=s);}),e})}function o(e){return c$1(this,null,function*(){var i;if(!e)return console.error("No token provided, make sure you are using your Prepr GraphQL URL"),[];if(!e.startsWith("https://"))return console.error("Invalid token provided, make sure you are using your Prepr GraphQL URL"),[];try{let s=yield fetch(e,{headers:{"User-Agent":`Prepr-Preview-Bar/${u()}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({query:`{
1
+ import {c as c$1}from'../chunk-E7ATRJ2F.js';import {headers}from'next/headers';var c={version:"2.0.0-alpha.9"};function x(){return c$1(this,null,function*(){return (yield headers()).get("prepr-customer-id")})}function p(){return c$1(this,null,function*(){return (yield headers()).get("Prepr-Segments")})}function d(){return c$1(this,null,function*(){return (yield headers()).get("Prepr-ABtesting")})}function h(){return c$1(this,null,function*(){let e={};return (yield headers()).forEach((s,t)=>{t.startsWith("prepr")&&(e[t]=s);}),e})}function o(e){return c$1(this,null,function*(){var i;if(!e)return console.error("No token provided, make sure you are using your Prepr GraphQL URL"),[];if(!e.startsWith("https://"))return console.error("Invalid token provided, make sure you are using your Prepr GraphQL URL"),[];try{let s=yield fetch(e,{headers:{"User-Agent":`Prepr-Preview-Bar/${u()}`,"Content-Type":"application/json"},method:"POST",body:JSON.stringify({query:`{
2
2
  _Segments {
3
3
  _id
4
4
  name
@@ -1 +1 @@
1
- {"version":3,"sources":["../../package.json","../../src/server/index.ts"],"names":["package_default","getPreprUUID","__async","headers","getActiveSegment","getActiveVariant","getPreprHeaders","newHeaders","value","key","getPreprEnvironmentSegments","token","_a","response","getPackageVersion","json","e","error","getPreviewBarProps","data","activeSegment","activeVariant"],"mappings":"+EAAA,IAAAA,CAAAA,CAAA,CAEE,OAAA,CAAW,eAkHb,EC7GA,SAAsBC,CAAAA,EAAe,CAAA,OAAAC,GAAAA,CAAA,sBAEnC,OAAA,CADoB,MAAMC,OAAAA,EAAQ,EACf,IAAI,mBAAmB,CAC5C,GAKA,SAAsBC,CAAAA,EAAmB,QAAAF,GAAAA,CAAA,IAAA,CAAA,IAAA,CAAA,WAAA,CAEvC,OAAA,CADoB,MAAMC,SAAQ,EACf,GAAA,CAAI,gBAAgB,CACzC,GAKA,SAAsBE,CAAAA,EAAmB,CAAA,OAAAH,GAAAA,CAAA,sBAEvC,OAAA,CADoB,MAAMC,SAAQ,EACf,GAAA,CAAI,iBAAiB,CAC1C,CAAA,CAAA,CAKA,SAAsBG,CAAAA,EAAkB,QAAAJ,GAAAA,CAAA,IAAA,CAAA,IAAA,CAAA,WAAA,CACtC,IAAMK,CAAAA,CAEF,EAAC,CAIL,OA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AA,CACxC,EACT,CACF,CAAA,CAAA,CAOA,SAAsBC,CAAAA,CACpBP,CAAAA,CAC+B,QAAAT,GAAAA,CAAA,IAAA,CAAA,IAAA,CAAA,WAAA,CAC/B,IAAIiB,CAAAA,CAAuB,GACvBC,CAAAA,CAA+B,IAAA,CAC/BC,EAA+B,IAAA,CAGnC,OAAI,QAAQ,GAAA,CAAI,SAAA,GAAc,SAAA,GAC5BF,CAAAA,CAAO,MAAMT,CAAAA,CAA4BC,CAAK,CAAA,CAC9CS,CAAAA,CAAgB,MAAMhB,CAAAA,EAAiB,CACvCiB,EAAgB,MAAMhB,CAAAA,EAAiB,CAAA,CAGlC,CACL,aAAA,CAAAe,CAAAA,CACA,cAAAC,CAAAA,CACA,IAAA,CAAAF,CACF,CACF,CAAA,CAAA,CAEA,SAASL,CAAAA,EAAoB,CAC3B,OAAOd,CAAAA,CAAM,OACf","file":"index.js","sourcesContent":["{\n \"name\": \"@preprio/prepr-nextjs\",\n \"version\": \"2.0.0-alpha.8\",\n \"description\": \"Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities\",\n \"main\": \"dist/react/index.cjs\",\n \"types\": \"./dist/react/index.d.ts\",\n \"module\": \"./dist/react/index.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"dev:css\": \"postcss ./src/globals.css -o ./src/output.css --watch\",\n \"build:css\": \"NODE_ENV=production postcss ./src/globals.css -o ./dist/index.css\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"clean\": \"rm -rf dist\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"release\": \"node scripts/release.js\",\n \"check\": \"npm run type-check && npm run lint:check && npm run format:check\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint src --ext .ts,.tsx --fix\",\n \"lint:check\": \"eslint src --ext .ts,.tsx\",\n \"prepublishOnly\": \"npm run check && npm run build\"\n },\n \"exports\": {\n \"./middleware\": {\n \"import\": \"./dist/middleware/index.js\",\n \"types\": \"./dist/middleware/index.d.ts\",\n \"require\": \"./dist/middleware/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server/index.js\",\n \"types\": \"./dist/server/index.d.ts\",\n \"require\": \"./dist/server/index.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react/index.js\",\n \"types\": \"./dist/react/index.d.ts\",\n \"require\": \"./dist/react/index.cjs\"\n },\n \"./contexts\": {\n \"import\": \"./dist/contexts/index.js\",\n \"types\": \"./dist/contexts/index.d.ts\",\n \"require\": \"./dist/contexts/index.cjs\"\n },\n \"./utils\": {\n \"import\": \"./dist/utils/index.js\",\n \"types\": \"./dist/utils/index.d.ts\",\n \"require\": \"./dist/utils/index.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/types/index.js\",\n \"types\": \"./dist/types/index.d.ts\",\n \"require\": \"./dist/types/index.cjs\"\n },\n \"./index.css\": {\n \"import\": \"./dist/index.css\",\n \"require\": \"./dist/index.css\"\n }\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"keywords\": [\n \"prepr\",\n \"cms\",\n \"nextjs\",\n \"preview\",\n \"visual-editing\",\n \"headless-cms\",\n \"react\",\n \"typescript\",\n \"debug\",\n \"stega\"\n ],\n \"author\": \"Preprio\",\n \"license\": \"MIT\",\n \"packageManager\": \"pnpm@10.5.2\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.25.1\",\n \"@types/node\": \"^20.11.5\",\n \"@types/react\": \"19.1.0\",\n \"@types/react-dom\": \"19.1.2\",\n \"@typescript-eslint/eslint-plugin\": \"^8.31.1\",\n \"@typescript-eslint/parser\": \"^8.31.1\",\n \"autoprefixer\": \"^10.4.21\",\n \"cssnano\": \"^7.0.7\",\n \"eslint\": \"^9.25.1\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"eslint-plugin-react\": \"^7.37.2\",\n \"eslint-plugin-react-hooks\": \"^5.0.0\",\n \"next\": \"15.3.1\",\n \"postcss\": \"^8\",\n \"prettier\": \"^3.5.3\",\n \"prettier-plugin-tailwindcss\": \"^0.5.12\",\n \"react\": \"^19.1.0\",\n \"react-dom\": \"^19.1.0\",\n \"tailwindcss\": \"^3.4.17\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"peerDependencies\": {\n \"next\": \"^15.0.0 || ^14.0.0 || ^13.0.0\",\n \"react\": \"^19.0.0 || ^18.0.0 || ^17.0.0 \",\n \"react-dom\": \"^19.0.0 || ^18.0.0 || ^17.0.0\"\n },\n \"dependencies\": {\n \"@headlessui/react\": \"^2.2.0\",\n \"@vercel/functions\": \"^2.0.0\",\n \"@vercel/stega\": \"^0.1.2\",\n \"clsx\": \"^2.1.1\",\n \"postcss-cli\": \"^11.0.1\",\n \"tailwind-merge\": \"^3.0.1\"\n }\n}\n","import { headers } from 'next/headers';\nimport { PreprPreviewBarProps, PreprSegment } from '../types';\nimport pjson from '../../package.json';\n\n/**\n * Returns the Prepr Customer ID from the headers\n */\nexport async function getPreprUUID() {\n const headersList = await headers();\n return headersList.get('prepr-customer-id');\n}\n\n/**\n * Retuns the active segment from the headers\n */\nexport async function getActiveSegment() {\n const headersList = await headers();\n return headersList.get('Prepr-Segments');\n}\n\n/**\n * Returns the active variant from the headers\n */\nexport async function getActiveVariant() {\n const headersList = await headers();\n return headersList.get('Prepr-ABtesting');\n}\n\n/**\n * Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)\n */\nexport async function getPreprHeaders() {\n const newHeaders: {\n [key: string]: string;\n } = {};\n\n const headersList = await headers();\n\n headersList.forEach((value, key) => {\n if (key.startsWith('prepr')) {\n newHeaders[key] = value;\n }\n });\n\n return newHeaders;\n}\n\n/**\n * Fetches the segments from the Prepr API\n * @param token Prepr access token with scope 'segments'\n * @returns Array of PreprSegmentResponse\n */\nexport async function getPreprEnvironmentSegments(\n token: string\n): Promise<PreprSegment[]> {\n if (!token) {\n console.error(\n 'No token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n if (!token.startsWith('https://')) {\n console.error(\n 'Invalid token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n try {\n const response = await fetch(token, {\n headers: {\n 'User-Agent': `Prepr-Preview-Bar/${getPackageVersion()}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n query: `{\n _Segments {\n _id\n name\n }\n }`,\n }),\n });\n try {\n const json = await response.json();\n\n if (!json || !json.data || !json.data._Segments) {\n return [];\n }\n\n return json.data?._Segments as PreprSegment[];\n } catch {\n console.error('Error parsing JSON, please contact Prepr support');\n return [];\n }\n } catch (error) {\n console.error('Error fetching segments:', error);\n return [];\n }\n}\n\n/**\n * Fetches all the necessary previewbar props\n * @param token Prepr access token with scope 'segments'\n * @returns Object with activeSegment, activeVariant and data\n */\nexport async function getPreviewBarProps(\n token: string\n): Promise<PreprPreviewBarProps> {\n let data: PreprSegment[] = [];\n let activeSegment: string | null = null;\n let activeVariant: string | null = null;\n\n // Prevent unnecessary function calling in production\n if (process.env.PREPR_ENV === 'preview') {\n data = await getPreprEnvironmentSegments(token);\n activeSegment = await getActiveSegment();\n activeVariant = await getActiveVariant();\n }\n\n return {\n activeSegment,\n activeVariant,\n data,\n };\n}\n\nfunction getPackageVersion() {\n return pjson.version;\n}\n"]}
1
+ {"version":3,"sources":["../../package.json","../../src/server/index.ts"],"names":["package_default","getPreprUUID","__async","headers","getActiveSegment","getActiveVariant","getPreprHeaders","newHeaders","value","key","getPreprEnvironmentSegments","token","_a","response","getPackageVersion","json","e","error","getPreviewBarProps","data","activeSegment","activeVariant"],"mappings":"+EAAA,IAAAA,CAAAA,CAAA,CAEE,OAAA,CAAW,eAkHb,EC7GA,SAAsBC,CAAAA,EAAe,CAAA,OAAAC,GAAAA,CAAA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;AAAA;AAAA,aAAA,CAMT,CAAC,CACH,CAAC,CAAA,CACD,GAAI,CACF,IAAMC,EAAO,MAAMF,CAAAA,CAAS,MAAK,CAEjC,OAAI,CAACE,CAAAA,EAAQ,CAACA,EAAK,IAAA,EAAQ,CAACA,CAAAA,CAAK,IAAA,CAAK,SAAA,CAC7B,IAGFH,CAAAA,CAAAG,CAAAA,CAAK,OAAL,IAAA,CAAA,KAAA,CAAA,CAAAH,CAAAA,CAAW,SACpB,CAAA,MAAQI,CAAAA,CAAA,CACN,OAAA,OAAA,CAAQ,KAAA,CAAM,kDAAkD,EACzD,EACT,CACF,CAAA,MAASC,CAAAA,CAAO,CACd,OAAA,OAAA,CAAQ,KAAA,CAAM,0BAAA,CAA4BA,CAAK,CAAA,CACxC,EACT,CACF,CAAA,CAAA,CAOA,SAAsBC,CAAAA,CACpBP,CAAAA,CAC+B,QAAAT,GAAAA,CAAA,IAAA,CAAA,IAAA,CAAA,WAAA,CAC/B,IAAIiB,CAAAA,CAAuB,GACvBC,CAAAA,CAA+B,IAAA,CAC/BC,EAA+B,IAAA,CAGnC,OAAI,QAAQ,GAAA,CAAI,SAAA,GAAc,SAAA,GAC5BF,CAAAA,CAAO,MAAMT,CAAAA,CAA4BC,CAAK,CAAA,CAC9CS,CAAAA,CAAgB,MAAMhB,CAAAA,EAAiB,CACvCiB,EAAgB,MAAMhB,CAAAA,EAAiB,CAAA,CAGlC,CACL,aAAA,CAAAe,CAAAA,CACA,cAAAC,CAAAA,CACA,IAAA,CAAAF,CACF,CACF,CAAA,CAAA,CAEA,SAASL,CAAAA,EAAoB,CAC3B,OAAOd,CAAAA,CAAM,OACf","file":"index.js","sourcesContent":["{\n \"name\": \"@preprio/prepr-nextjs\",\n \"version\": \"2.0.0-alpha.9\",\n \"description\": \"Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities\",\n \"main\": \"dist/react/index.cjs\",\n \"types\": \"./dist/react/index.d.ts\",\n \"module\": \"./dist/react/index.js\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"dev:css\": \"postcss ./src/globals.css -o ./src/output.css --watch\",\n \"build:css\": \"NODE_ENV=production postcss ./src/globals.css -o ./dist/index.css\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n \"clean\": \"rm -rf dist\",\n \"format\": \"prettier --write \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"format:check\": \"prettier --check \\\"src/**/*.{ts,tsx,js,jsx,json,md}\\\"\",\n \"release\": \"node scripts/release.js\",\n \"check\": \"npm run type-check && npm run lint:check && npm run format:check\",\n \"type-check\": \"tsc --noEmit\",\n \"lint\": \"eslint src --ext .ts,.tsx --fix\",\n \"lint:check\": \"eslint src --ext .ts,.tsx\",\n \"prepublishOnly\": \"npm run check && npm run build\"\n },\n \"exports\": {\n \"./middleware\": {\n \"import\": \"./dist/middleware/index.js\",\n \"types\": \"./dist/middleware/index.d.ts\",\n \"require\": \"./dist/middleware/index.cjs\"\n },\n \"./server\": {\n \"import\": \"./dist/server/index.js\",\n \"types\": \"./dist/server/index.d.ts\",\n \"require\": \"./dist/server/index.cjs\"\n },\n \"./react\": {\n \"import\": \"./dist/react/index.js\",\n \"types\": \"./dist/react/index.d.ts\",\n \"require\": \"./dist/react/index.cjs\"\n },\n \"./contexts\": {\n \"import\": \"./dist/contexts/index.js\",\n \"types\": \"./dist/contexts/index.d.ts\",\n \"require\": \"./dist/contexts/index.cjs\"\n },\n \"./utils\": {\n \"import\": \"./dist/utils/index.js\",\n \"types\": \"./dist/utils/index.d.ts\",\n \"require\": \"./dist/utils/index.cjs\"\n },\n \"./types\": {\n \"import\": \"./dist/types/index.js\",\n \"types\": \"./dist/types/index.d.ts\",\n \"require\": \"./dist/types/index.cjs\"\n },\n \"./index.css\": {\n \"import\": \"./dist/index.css\",\n \"require\": \"./dist/index.css\"\n }\n },\n \"files\": [\n \"dist\",\n \"package.json\"\n ],\n \"keywords\": [\n \"prepr\",\n \"cms\",\n \"nextjs\",\n \"preview\",\n \"visual-editing\",\n \"headless-cms\",\n \"react\",\n \"typescript\",\n \"debug\",\n \"stega\"\n ],\n \"author\": \"Preprio\",\n \"license\": \"MIT\",\n \"packageManager\": \"pnpm@10.5.2\",\n \"devDependencies\": {\n \"@eslint/js\": \"^9.25.1\",\n \"@types/node\": \"^20.11.5\",\n \"@types/react\": \"19.1.0\",\n \"@types/react-dom\": \"19.1.2\",\n \"@typescript-eslint/eslint-plugin\": \"^8.31.1\",\n \"@typescript-eslint/parser\": \"^8.31.1\",\n \"autoprefixer\": \"^10.4.21\",\n \"cssnano\": \"^7.0.7\",\n \"eslint\": \"^9.25.1\",\n \"eslint-config-prettier\": \"^10.1.2\",\n \"eslint-plugin-prettier\": \"^5.2.6\",\n \"eslint-plugin-react\": \"^7.37.2\",\n \"eslint-plugin-react-hooks\": \"^5.0.0\",\n \"next\": \"15.3.1\",\n \"postcss\": \"^8\",\n \"prettier\": \"^3.5.3\",\n \"prettier-plugin-tailwindcss\": \"^0.5.12\",\n \"react\": \"^19.1.0\",\n \"react-dom\": \"^19.1.0\",\n \"tailwindcss\": \"^3.4.17\",\n \"tsup\": \"^8.5.0\",\n \"typescript\": \"^5.8.3\"\n },\n \"peerDependencies\": {\n \"next\": \"^15.0.0 || ^14.0.0 || ^13.0.0\",\n \"react\": \"^19.0.0 || ^18.0.0 || ^17.0.0 \",\n \"react-dom\": \"^19.0.0 || ^18.0.0 || ^17.0.0\"\n },\n \"dependencies\": {\n \"@headlessui/react\": \"^2.2.0\",\n \"@vercel/functions\": \"^2.0.0\",\n \"@vercel/stega\": \"^0.1.2\",\n \"clsx\": \"^2.1.1\",\n \"postcss-cli\": \"^11.0.1\",\n \"tailwind-merge\": \"^3.0.1\"\n }\n}\n","import { headers } from 'next/headers';\nimport { PreprPreviewBarProps, PreprSegment } from '../types';\nimport pjson from '../../package.json';\n\n/**\n * Returns the Prepr Customer ID from the headers\n */\nexport async function getPreprUUID() {\n const headersList = await headers();\n return headersList.get('prepr-customer-id');\n}\n\n/**\n * Retuns the active segment from the headers\n */\nexport async function getActiveSegment() {\n const headersList = await headers();\n return headersList.get('Prepr-Segments');\n}\n\n/**\n * Returns the active variant from the headers\n */\nexport async function getActiveVariant() {\n const headersList = await headers();\n return headersList.get('Prepr-ABtesting');\n}\n\n/**\n * Helper function to retrieve Prepr headers (will filter out customer ID if in preview mode)\n */\nexport async function getPreprHeaders() {\n const newHeaders: {\n [key: string]: string;\n } = {};\n\n const headersList = await headers();\n\n headersList.forEach((value, key) => {\n if (key.startsWith('prepr')) {\n newHeaders[key] = value;\n }\n });\n\n return newHeaders;\n}\n\n/**\n * Fetches the segments from the Prepr API\n * @param token Prepr access token with scope 'segments'\n * @returns Array of PreprSegmentResponse\n */\nexport async function getPreprEnvironmentSegments(\n token: string\n): Promise<PreprSegment[]> {\n if (!token) {\n console.error(\n 'No token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n if (!token.startsWith('https://')) {\n console.error(\n 'Invalid token provided, make sure you are using your Prepr GraphQL URL'\n );\n return [];\n }\n\n try {\n const response = await fetch(token, {\n headers: {\n 'User-Agent': `Prepr-Preview-Bar/${getPackageVersion()}`,\n 'Content-Type': 'application/json',\n },\n method: 'POST',\n body: JSON.stringify({\n query: `{\n _Segments {\n _id\n name\n }\n }`,\n }),\n });\n try {\n const json = await response.json();\n\n if (!json || !json.data || !json.data._Segments) {\n return [];\n }\n\n return json.data?._Segments as PreprSegment[];\n } catch {\n console.error('Error parsing JSON, please contact Prepr support');\n return [];\n }\n } catch (error) {\n console.error('Error fetching segments:', error);\n return [];\n }\n}\n\n/**\n * Fetches all the necessary previewbar props\n * @param token Prepr access token with scope 'segments'\n * @returns Object with activeSegment, activeVariant and data\n */\nexport async function getPreviewBarProps(\n token: string\n): Promise<PreprPreviewBarProps> {\n let data: PreprSegment[] = [];\n let activeSegment: string | null = null;\n let activeVariant: string | null = null;\n\n // Prevent unnecessary function calling in production\n if (process.env.PREPR_ENV === 'preview') {\n data = await getPreprEnvironmentSegments(token);\n activeSegment = await getActiveSegment();\n activeVariant = await getActiveVariant();\n }\n\n return {\n activeSegment,\n activeVariant,\n data,\n };\n}\n\nfunction getPackageVersion() {\n return pjson.version;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preprio/prepr-nextjs",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Next.js package for Prepr CMS preview functionality with advanced debugging and visual editing capabilities",
5
5
  "main": "dist/react/index.cjs",
6
6
  "types": "./dist/react/index.d.ts",