Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@prismicio/api-renderer

Package Overview
Dependencies
Maintainers
26
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prismicio/api-renderer - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2-beta.1

CHANGELOG.md

24

lib/widgets/nestable/ImageRenderer.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../../utils");
function renderImageContentView(imageContentView, ctx) {
function renderImageContentView(imageContentView, ctx, apiVersion) {
const contentV2 = apiVersion === "v2"
? {
id: imageContentView.origin.id,
edit: {
x: imageContentView.edit.crop.x,
y: imageContentView.edit.crop.y,
zoom: imageContentView.edit.zoom,
background: imageContentView.edit.background,
},
}
: {};
return {

@@ -13,2 +24,3 @@ dimensions: {

url: ctx.urlRewriter.rewriteImageUrl(imageContentView),
...contentV2,
};

@@ -22,3 +34,3 @@ }

...acc,
[k.toLowerCase()]: renderImageContentView(v, ctx),
[k.toLowerCase()]: renderImageContentView(v, ctx, "v1"),
};

@@ -28,3 +40,3 @@ }, {});

type: "Image",
value: { main: renderImageContentView(content, ctx), views: views },
value: { main: renderImageContentView(content, ctx, "v1"), views: views },
};

@@ -34,10 +46,10 @@ }

type: "Image",
value: { main: renderImageContentView(content, ctx), views: [] },
value: { main: renderImageContentView(content, ctx, "v1"), views: [] },
};
},
renderV2(_def, content) {
const main = renderImageContentView(content, ctx);
const main = renderImageContentView(content, ctx, "v2");
if (content.thumbnails && content.thumbnails) {
const views = Object.entries(content.thumbnails).reduce((acc, [k, v]) => {
return Object.assign(acc, { [k]: renderImageContentView(v, ctx) });
return Object.assign(acc, { [k]: renderImageContentView(v, ctx, "v2") });
}, {});

@@ -44,0 +56,0 @@ return Object.assign(main, views);

@@ -21,2 +21,3 @@ "use strict";

return {
id: link.id,
link_type: "Media",

@@ -23,0 +24,0 @@ name: link.name,

@@ -56,2 +56,13 @@ "use strict";

const direction = block.direction ? { direction: block.direction } : {};
const contentV2 = apiVersion === models_1.ApiVersion.v2
? {
id: block.data.origin.id,
edit: {
x: block.data.edit.crop.x,
y: block.data.edit.crop.y,
zoom: block.data.edit.zoom,
background: block.data.edit.background,
},
}
: {};
return {

@@ -66,2 +77,3 @@ type: "image",

},
...contentV2,
...linkTo,

@@ -68,0 +80,0 @@ ...label,

{
"name": "@prismicio/api-renderer",
"version": "2.0.1",
"version": "2.0.2-beta.1",
"description": "Prismic renderers for the content API",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,3 +6,16 @@ import type { ImageContent, ImageContentView } from "@prismicio/types-internal/lib/content"

function renderImageContentView(imageContentView: ImageContentView, ctx: RenderContext) {
function renderImageContentView(imageContentView: ImageContentView, ctx: RenderContext, apiVersion: string) {
const contentV2 =
apiVersion === "v2"
? {
id: imageContentView.origin.id,
edit: {
x: imageContentView.edit.crop.x,
y: imageContentView.edit.crop.y,
zoom: imageContentView.edit.zoom,
background: imageContentView.edit.background,
},
}
: {}
return {

@@ -16,2 +29,3 @@ dimensions: {

url: ctx.urlRewriter.rewriteImageUrl(imageContentView),
...contentV2,
}

@@ -26,3 +40,3 @@ }

...acc,
[k.toLowerCase()]: renderImageContentView(v, ctx),
[k.toLowerCase()]: renderImageContentView(v, ctx, "v1"),
}

@@ -32,3 +46,3 @@ }, {})

type: "Image",
value: { main: renderImageContentView(content, ctx), views: views },
value: { main: renderImageContentView(content, ctx, "v1"), views: views },
}

@@ -38,3 +52,3 @@ }

type: "Image",
value: { main: renderImageContentView(content, ctx), views: [] },
value: { main: renderImageContentView(content, ctx, "v1"), views: [] },
}

@@ -44,6 +58,6 @@ },

renderV2(_def: ImageDef, content: ImageContent): unknown {
const main = renderImageContentView(content, ctx)
const main = renderImageContentView(content, ctx, "v2")
if (content.thumbnails && content.thumbnails) {
const views = Object.entries(content.thumbnails).reduce((acc, [k, v]) => {
return Object.assign(acc, { [k]: renderImageContentView(v, ctx) })
return Object.assign(acc, { [k]: renderImageContentView(v, ctx, "v2") })
}, {})

@@ -50,0 +64,0 @@

@@ -25,2 +25,3 @@ import type { ImageLinkContent } from "@prismicio/types-internal/lib/content"

return {
id: link.id,
link_type: "Media",

@@ -27,0 +28,0 @@ name: link.name,

@@ -65,2 +65,15 @@ import {

const contentV2 =
apiVersion === ApiVersion.v2
? {
id: block.data.origin.id,
edit: {
x: block.data.edit.crop.x,
y: block.data.edit.crop.y,
zoom: block.data.edit.zoom,
background: block.data.edit.background,
},
}
: {}
return {

@@ -75,2 +88,3 @@ type: "image",

},
...contentV2,
...linkTo,

@@ -77,0 +91,0 @@ ...label,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc