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

@prismicio/api-renderer

Package Overview
Dependencies
Maintainers
27
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 3.0.0 to 3.0.2

lib/models/ApiModel/BooleanField.d.ts

25

lib/widgets/nestable/ImageRenderer.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const models_1 = require("../../models");
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 +25,3 @@ dimensions: {

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

@@ -22,3 +35,3 @@ }

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

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

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

@@ -34,10 +47,10 @@ }

type: "Image",
value: { main: renderImageContentView(content, ctx), views: [] },
value: { main: renderImageContentView(content, ctx, models_1.ApiVersion.v1), views: [] },
};
},
renderV2(_def, content) {
const main = renderImageContentView(content, ctx);
const main = renderImageContentView(content, ctx, models_1.ApiVersion.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, models_1.ApiVersion.v2) });
}, {});

@@ -44,0 +57,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": "3.0.0",
"version": "3.0.2",
"description": "Prismic renderers for the content API",

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

@@ -5,5 +5,19 @@ import type { ImageContent, ImageContentView } from "@prismicio/types-internal/lib/content"

import type { RenderContext, Renderer } from "../../models"
import { ApiVersion } from "../../models"
import { writeEmptyStringOrNull } from "../../utils"
function renderImageContentView(imageContentView: ImageContentView, ctx: RenderContext) {
function renderImageContentView(imageContentView: ImageContentView, ctx: RenderContext, apiVersion: 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 {

@@ -17,2 +31,3 @@ dimensions: {

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

@@ -27,3 +42,3 @@ }

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

@@ -33,3 +48,3 @@ }, {})

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

@@ -39,3 +54,3 @@ }

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

@@ -45,6 +60,6 @@ },

renderV2(_def: Image, content: ImageContent): unknown {
const main = renderImageContentView(content, ctx)
const main = renderImageContentView(content, ctx, ApiVersion.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, ApiVersion.v2) })
}, {})

@@ -51,0 +66,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