@uniformdev/canvas-next 17.5.1-alpha.7 → 17.6.1-alpha.106
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.d.ts +31 -3
- package/dist/index.esm.js +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -0
- package/dist/{models-de4a94fb.d.ts → models-85d88e63.d.ts} +1 -1
- package/dist/slug/index.d.ts +1 -1
- package/dist/slug/index.mjs +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
|
-
export { U as UniformCompositionNextPage, b as UniformGetServerSideProps, a as UniformGetStaticProps } from './models-
|
|
1
|
+
export { U as UniformCompositionNextPage, b as UniformGetServerSideProps, a as UniformGetStaticProps } from './models-85d88e63.js';
|
|
2
|
+
import { NextApiHandler } from 'next';
|
|
3
|
+
import { RootComponentInstance } from '@uniformdev/canvas';
|
|
2
4
|
import '@uniformdev/canvas-react';
|
|
3
|
-
import '@uniformdev/canvas';
|
|
4
|
-
import 'next';
|
|
5
5
|
import 'querystring';
|
|
6
|
+
|
|
7
|
+
declare type ResolveFullPath = (options: {
|
|
8
|
+
id?: string;
|
|
9
|
+
slug?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
}) => string | undefined;
|
|
12
|
+
declare type CreatePreviewHandlerGetOptions = {
|
|
13
|
+
secret?: () => string;
|
|
14
|
+
/**
|
|
15
|
+
* Should return the full path to redirect to. Will respond with `400` error if `undefined` is returned.
|
|
16
|
+
* defaults to a function that returns the `path` if truthy, otherwise returns `slug`.
|
|
17
|
+
*/
|
|
18
|
+
resolveFullPath?: ResolveFullPath;
|
|
19
|
+
};
|
|
20
|
+
declare type CreatePreviewHandlerGet = (options?: CreatePreviewHandlerGetOptions) => NextApiHandler;
|
|
21
|
+
declare const createPreviewHandlerGet: CreatePreviewHandlerGet;
|
|
22
|
+
|
|
23
|
+
declare type CreatePreviewHandlerPostOptions = {
|
|
24
|
+
secret?: () => string;
|
|
25
|
+
enhance?: (composition: RootComponentInstance) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
declare type CreatePreviewHandlerPost = (options?: CreatePreviewHandlerPostOptions) => NextApiHandler;
|
|
28
|
+
declare const createPreviewHandlerPost: CreatePreviewHandlerPost;
|
|
29
|
+
|
|
30
|
+
declare type CreatePreviewHandler = (options?: CreatePreviewHandlerGetOptions & CreatePreviewHandlerPostOptions) => NextApiHandler;
|
|
31
|
+
declare const createPreviewHandler: CreatePreviewHandler;
|
|
32
|
+
|
|
33
|
+
export { CreatePreviewHandler, CreatePreviewHandlerGet, CreatePreviewHandlerGetOptions, CreatePreviewHandlerPost, CreatePreviewHandlerPostOptions, ResolveFullPath, createPreviewHandler, createPreviewHandlerGet, createPreviewHandlerPost };
|
package/dist/index.esm.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IN_CONTEXT_EDITOR_QUERY_STRING_PARAM as v}from"@uniformdev/canvas";var c=({secret:t,resolveFullPath:n=f}={})=>async(e,r)=>{let o=[v],a=Array.isArray(e.query.id)?e.query.id[0]:e.query.id,s=Array.isArray(e.query.slug)?e.query.slug[0]:e.query.slug,p=Array.isArray(e.query.path)?e.query.path[0]:e.query.path,i=n({id:a,slug:s,path:p});if(!i)return r.status(400).json({message:"Could not resolve the full path of the preview page"});if(e.query.disable){r.clearPreviewData(),r.redirect(i);return}let l=typeof t=="function"?t==null?void 0:t():t;if(Boolean(l)&&e.query.secret!==l)return r.status(401).json({message:"Invalid token"});r.setPreviewData({});let u=new URLSearchParams;o.forEach(d=>{let P=e.query[d];typeof P=="string"&&u.append(d,P)});let m=u.toString()?`${i}?${u.toString()}`:i;r.redirect(m)},f=({slug:t,path:n})=>{let e=n||t;return e!=null?e:""};import{generateHash as w}from"@uniformdev/canvas";var y=({secret:t,enhance:n}={})=>async(e,r)=>{let{composition:o,hash:a}=e.body;if(!o)return r.status(422).json({message:'Missing "composition" parameter'});let s=typeof t=="function"?t==null?void 0:t():t,p=Boolean(a),i=Boolean(s);if(p&&i){if(w({composition:o,secret:s})!==a)return r.status(401).json({message:"Not authorized"})}else if(i)return r.status(401).json({message:"Not authorized"});return await(n==null?void 0:n(o)),r.status(200).json({composition:o})};var N=({secret:t,enhance:n,resolveFullPath:e}={})=>async(r,o)=>{var s;let a=(s=r.method)==null?void 0:s.toLocaleLowerCase();return a==="get"?c({secret:t,resolveFullPath:e})(r,o):a==="post"?y({secret:t,enhance:n})(r,o):o.status(501).json({message:`Method "${a}" not implemented`})};export{N as createPreviewHandler,c as createPreviewHandlerGet,y as createPreviewHandlerPost};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var C=(t,r)=>{for(var e in r)d(t,e,{get:r[e],enumerable:!0})},x=(t,r,e,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of h(r))!g.call(t,n)&&n!==e&&d(t,n,{get:()=>r[n],enumerable:!(o=H(r,n))||o.enumerable});return t};var A=t=>x(d({},"__esModule",{value:!0}),t);var O={};C(O,{createPreviewHandler:()=>N,createPreviewHandlerGet:()=>P,createPreviewHandlerPost:()=>c});module.exports=A(O);var v=require("@uniformdev/canvas"),P=({secret:t,resolveFullPath:r=R}={})=>async(e,o)=>{let n=[v.IN_CONTEXT_EDITOR_QUERY_STRING_PARAM],a=Array.isArray(e.query.id)?e.query.id[0]:e.query.id,s=Array.isArray(e.query.slug)?e.query.slug[0]:e.query.slug,p=Array.isArray(e.query.path)?e.query.path[0]:e.query.path,i=r({id:a,slug:s,path:p});if(!i)return o.status(400).json({message:"Could not resolve the full path of the preview page"});if(e.query.disable){o.clearPreviewData(),o.redirect(i);return}let l=typeof t=="function"?t==null?void 0:t():t;if(Boolean(l)&&e.query.secret!==l)return o.status(401).json({message:"Invalid token"});o.setPreviewData({});let u=new URLSearchParams;n.forEach(y=>{let m=e.query[y];typeof m=="string"&&u.append(y,m)});let w=u.toString()?`${i}?${u.toString()}`:i;o.redirect(w)},R=({slug:t,path:r})=>{let e=r||t;return e!=null?e:""};var f=require("@uniformdev/canvas"),c=({secret:t,enhance:r}={})=>async(e,o)=>{let{composition:n,hash:a}=e.body;if(!n)return o.status(422).json({message:'Missing "composition" parameter'});let s=typeof t=="function"?t==null?void 0:t():t,p=Boolean(a),i=Boolean(s);if(p&&i){if((0,f.generateHash)({composition:n,secret:s})!==a)return o.status(401).json({message:"Not authorized"})}else if(i)return o.status(401).json({message:"Not authorized"});return await(r==null?void 0:r(n)),o.status(200).json({composition:n})};var N=({secret:t,enhance:r,resolveFullPath:e}={})=>async(o,n)=>{var s;let a=(s=o.method)==null?void 0:s.toLocaleLowerCase();return a==="get"?P({secret:t,resolveFullPath:e})(o,n):a==="post"?c({secret:t,enhance:r})(o,n):n.status(501).json({message:`Method "${a}" not implemented`})};0&&(module.exports={createPreviewHandler,createPreviewHandlerGet,createPreviewHandlerPost});
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IN_CONTEXT_EDITOR_QUERY_STRING_PARAM as v}from"@uniformdev/canvas";var c=({secret:t,resolveFullPath:n=f}={})=>async(e,r)=>{let o=[v],a=Array.isArray(e.query.id)?e.query.id[0]:e.query.id,s=Array.isArray(e.query.slug)?e.query.slug[0]:e.query.slug,p=Array.isArray(e.query.path)?e.query.path[0]:e.query.path,i=n({id:a,slug:s,path:p});if(!i)return r.status(400).json({message:"Could not resolve the full path of the preview page"});if(e.query.disable){r.clearPreviewData(),r.redirect(i);return}let l=typeof t=="function"?t==null?void 0:t():t;if(Boolean(l)&&e.query.secret!==l)return r.status(401).json({message:"Invalid token"});r.setPreviewData({});let u=new URLSearchParams;o.forEach(d=>{let P=e.query[d];typeof P=="string"&&u.append(d,P)});let m=u.toString()?`${i}?${u.toString()}`:i;r.redirect(m)},f=({slug:t,path:n})=>{let e=n||t;return e!=null?e:""};import{generateHash as w}from"@uniformdev/canvas";var y=({secret:t,enhance:n}={})=>async(e,r)=>{let{composition:o,hash:a}=e.body;if(!o)return r.status(422).json({message:'Missing "composition" parameter'});let s=typeof t=="function"?t==null?void 0:t():t,p=Boolean(a),i=Boolean(s);if(p&&i){if(w({composition:o,secret:s})!==a)return r.status(401).json({message:"Not authorized"})}else if(i)return r.status(401).json({message:"Not authorized"});return await(n==null?void 0:n(o)),r.status(200).json({composition:o})};var N=({secret:t,enhance:n,resolveFullPath:e}={})=>async(r,o)=>{var s;let a=(s=r.method)==null?void 0:s.toLocaleLowerCase();return a==="get"?c({secret:t,resolveFullPath:e})(r,o):a==="post"?y({secret:t,enhance:n})(r,o):o.status(501).json({message:`Method "${a}" not implemented`})};export{N as createPreviewHandler,c as createPreviewHandlerGet,y as createPreviewHandlerPost};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CompositionProps } from '@uniformdev/canvas-react';
|
|
2
1
|
import { RootComponentInstance } from '@uniformdev/canvas';
|
|
2
|
+
import { CompositionProps } from '@uniformdev/canvas-react';
|
|
3
3
|
import { NextPage, PreviewData, GetStaticPropsContext, GetStaticPropsResult, GetServerSidePropsContext, GetServerSidePropsResult } from 'next';
|
|
4
4
|
import { ParsedUrlQuery } from 'querystring';
|
|
5
5
|
|
package/dist/slug/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GetServerSideProps, GetStaticProps } from 'next';
|
|
|
3
3
|
import * as querystring from 'querystring';
|
|
4
4
|
import { ParsedUrlQuery } from 'querystring';
|
|
5
5
|
import { CanvasClient } from '@uniformdev/canvas';
|
|
6
|
-
import { b as UniformGetServerSideProps, a as UniformGetStaticProps } from '../models-
|
|
6
|
+
import { b as UniformGetServerSideProps, a as UniformGetStaticProps } from '../models-85d88e63.js';
|
|
7
7
|
import '@uniformdev/canvas-react';
|
|
8
8
|
|
|
9
9
|
declare const withUniformGetServerSideProps: <TProps extends {
|
package/dist/slug/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{CANVAS_DRAFT_STATE as I,CANVAS_PUBLISHED_STATE as d,CanvasClient as U}from"@uniformdev/canvas";var S=(t,r)=>async function(e){if(!process.env.UNIFORM_API_KEY)throw new Error("UNIFORM_API_KEY is not defined.");if(!process.env.UNIFORM_PROJECT_ID)throw new Error("UNIFORM_PROJECT_ID is not defined.");let a=(r==null?void 0:r.client)||new U({apiKey:process.env.UNIFORM_API_KEY,projectId:process.env.UNIFORM_PROJECT_ID,apiHost:process.env.UNIFORM_CLI_BASE_URL}),{preview:i}=e,n=new URL(e.resolvedUrl,`http://${e.req.headers.host}/`),s=await a.getCompositionBySlug({slug:n.pathname,state:i?I:d});if(!s)return{notFound:!0};let o=t?await t(e,s.composition):{props:{}};if(Object.hasOwn(o,"props")){let p=o;p.props.data=s.composition}return o};import{CANVAS_DRAFT_STATE as v,CANVAS_PUBLISHED_STATE as C,CanvasClient as R}from"@uniformdev/canvas";var f=t=>async function(){var i;if(!process.env.UNIFORM_API_KEY)throw new Error("UNIFORM_API_KEY is not defined.");if(!process.env.UNIFORM_PROJECT_ID)throw new Error("UNIFORM_PROJECT_ID is not defined.");return{paths:(await((i=t==null?void 0:t.client)!=null?i:new R({apiKey:process.env.UNIFORM_API_KEY,projectId:process.env.UNIFORM_PROJECT_ID,apiHost:process.env.UNIFORM_CLI_BASE_URL})).getCompositionList({state:t!=null&&t.preview?v:C})).compositions.filter(n=>{var s;return!!((s=n.composition._slug)!=null&&s.length)}).map(n=>n.composition._slug),fallback:!1}};import{CANVAS_DRAFT_STATE as l,CANVAS_PUBLISHED_STATE as w,CanvasClient as E}from"@uniformdev/canvas";var P=(t,r)=>async function(e){var _;if(!process.env.UNIFORM_API_KEY)throw new Error("UNIFORM_API_KEY is not defined.");if(!process.env.UNIFORM_PROJECT_ID)throw new Error("UNIFORM_PROJECT_ID is not defined.");let a=A({param:r==null?void 0:r.param,params:e==null?void 0:e.params,prefix:r==null?void 0:r.prefix}),i=(_=r==null?void 0:r.client)!=null?_:new E({apiKey:process.env.UNIFORM_API_KEY,projectId:process.env.UNIFORM_PROJECT_ID,apiHost:process.env.UNIFORM_CLI_BASE_URL}),{preview:n}=e,s=await i.getCompositionBySlug({slug:a,state:n?l:w});if(!s.composition)return{notFound:!0};let{composition:o}=s,p=t?await t(e,o):{props:{}};if(Object.hasOwn(p,"props")){let m=p;m.props.data=o}return p},A=({param:t="slug",params:r,prefix:c})=>{let e=(r==null?void 0:r[t])||"";return`/${Array.isArray(e)?e.join("/"):e}`||c||"/"};var G=S(),D=P(),K=f();export{G as getServerSideProps,K as getStaticPaths,D as getStaticProps,S as withUniformGetServerSideProps,f as withUniformGetStaticPaths,P as withUniformGetStaticProps};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-next",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.6.1-alpha.106+a085c31c8",
|
|
4
4
|
"description": "Next.js SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@uniformdev/canvas": "^17.
|
|
46
|
-
"@uniformdev/canvas-react": "^17.
|
|
45
|
+
"@uniformdev/canvas": "^17.6.1-alpha.106+a085c31c8",
|
|
46
|
+
"@uniformdev/canvas-react": "^17.6.1-alpha.106+a085c31c8"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"next": ">= 12.0.0",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
"react-dom": ">=16"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/react": "18.0.
|
|
55
|
-
"next": "12.3.
|
|
54
|
+
"@types/react": "18.0.26",
|
|
55
|
+
"next": "12.3.4",
|
|
56
56
|
"react": "18.2.0",
|
|
57
57
|
"react-dom": "18.2.0"
|
|
58
58
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "a085c31c8c2e927cbe2b2332854a199a75198542"
|
|
66
66
|
}
|