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

@zag-js/dom-query

Package Overview
Dependencies
Maintainers
0
Versions
688
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zag-js/dom-query - npm Package Compare versions

Comparing version 0.79.3 to 0.80.0

14

dist/index.d.ts

@@ -19,6 +19,18 @@ interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap {

interface DataUrlOptions {
/**
* The type of the image
*/
type: DataUrlType;
/**
* The quality of the image
* @default 0.92
*/
quality?: number | undefined;
/**
* The background color of the canvas.
* Useful when type is `image/jpeg`
*/
background?: string | undefined;
}
declare function getDataUrl(svg: SVGElement | undefined | null, opts: DataUrlOptions): Promise<string>;
declare function getDataUrl(svg: SVGSVGElement | undefined | null, opts: DataUrlOptions): Promise<string>;

@@ -25,0 +37,0 @@ declare function getDocument(el: Element | Window | Node | Document | null | undefined): Document;

16

dist/index.js

@@ -72,3 +72,3 @@ 'use strict';

function getDataUrl(svg, opts) {
const { type, quality = 0.92 } = opts;
const { type, quality = 0.92, background } = opts;
if (!svg) throw new Error("[zag-js > getDataUrl]: Could not find the svg element");

@@ -79,4 +79,5 @@ const win = getWindow(svg);

const svgClone = svg.cloneNode(true);
svgClone.setAttribute("viewBox", `0 0 ${svgBounds.width} ${svgBounds.height}`);
svg.parentElement.appendChild(svgClone);
if (!svgClone.hasAttribute("viewBox")) {
svgClone.setAttribute("viewBox", `0 0 ${svgBounds.width} ${svgBounds.height}`);
}
const serializer = new win.XMLSerializer();

@@ -86,3 +87,6 @@ const source = '<?xml version="1.0" standalone="no"?>\r\n' + serializer.serializeToString(svgClone);

if (type === "image/svg+xml") {
return Promise.resolve(svgString);
return Promise.resolve(svgString).then((str) => {
svgClone.remove();
return str;
});
}

@@ -96,2 +100,6 @@ const dpr = win.devicePixelRatio || 1;

const context = canvas.getContext("2d");
if (type === "image/jpeg" || background) {
context.fillStyle = background || "white";
context.fillRect(0, 0, canvas.width, canvas.height);
}
return new Promise((resolve) => {

@@ -98,0 +106,0 @@ image.onload = () => {

{
"name": "@zag-js/dom-query",
"version": "0.79.3",
"version": "0.80.0",
"description": "The dom helper library for zag.js machines",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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