chore(deps): update dependency @prettier/parse-srcset to v3.1.0 (#15054)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
renovate[bot]andfisker authored and GitHub committed 2023-08-08 17:41:46 +08:00
1 parent 716382d421
commit 06a8e377a3
3 files changed
+17 -13

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@
"@glimmer/syntax": "0.84.3",
"@iarna/toml": "2.2.5",
"@prettier/is-es5-identifier-name": "0.2.0",
"@prettier/parse-srcset": "3.0.0",
"@prettier/parse-srcset": "3.1.0",
"@typescript-eslint/typescript-estree": "6.2.1",
"@typescript-eslint/visitor-keys": "6.2.1",
"acorn": "8.10.0",
+11 -7
View File
@@ -3,6 +3,8 @@ import { ifBreak, join, line } from "../../document/builders.js";
import { getUnescapedAttributeValue } from "../utils/index.js";
import { printExpand } from "./utils.js";
/** @typedef {import("../../document/builders.js").Doc} Doc */
function printSrcset(path /*, options*/) {
if (
path.node.fullName === "srcset" &&
@@ -12,19 +14,20 @@ function printSrcset(path /*, options*/) {
}
}
const SRCSET_UNITS = { width: "w", height: "h", density: "x" };
const SRCSET_TYPES = Object.keys(SRCSET_UNITS);
function printSrcsetValue(value) {
const srcset = parseSrcset(value);
const types = SRCSET_TYPES.filter((type) =>
srcset.some((candidate) => Object.hasOwn(candidate, type)),
);
const hasW = srcset.some(({ width }) => width);
const hasH = srcset.some(({ height }) => height);
const hasX = srcset.some(({ density }) => density);
if (hasW + hasH + hasX > 1) {
if (types.length > 1) {
throw new Error("Mixed descriptor in srcset is not supported");
}
const key = hasW ? "width" : hasH ? "height" : "density";
const unit = hasW ? "w" : hasH ? "h" : "x";
const [key] = types;
const unit = SRCSET_UNITS[key];
const urls = srcset.map((src) => src.source.value);
const maxUrlLength = Math.max(...urls.map((url) => url.length));
@@ -42,6 +45,7 @@ function printSrcsetValue(value) {
join(
[",", line],
urls.map((url, index) => {
/** @type {Doc[]} */
const parts = [url];
const descriptor = descriptors[index];
+5 -5
View File
@@ -1557,10 +1557,10 @@ __metadata:
languageName: node
linkType: hard
"@prettier/parse-srcset@npm:3.0.0":
version: 3.0.0
resolution: "@prettier/parse-srcset@npm:3.0.0"
checksum: 18f988f2a1d2f6ea3f2dc3357587a3e7c64f3cbb68b8f25e8f6de390c7d42af5babc6651a621b45901bb35f62c8d72c364ad8c06802e729e1470672bce334094
"@prettier/parse-srcset@npm:3.1.0":
version: 3.1.0
resolution: "@prettier/parse-srcset@npm:3.1.0"
checksum: c3394d20609a3da0c205551cf5406746fa7e51060b0adaa5cb343815e78262a16801a2cb2c273964c51842d7a95043c57d86b1a03e17988c0594432d7585f412
languageName: node
linkType: hard
@@ -7003,7 +7003,7 @@ __metadata:
"@glimmer/syntax": 0.84.3
"@iarna/toml": 2.2.5
"@prettier/is-es5-identifier-name": 0.2.0
"@prettier/parse-srcset": 3.0.0
"@prettier/parse-srcset": 3.1.0
"@types/estree": 1.0.1
"@types/file-entry-cache": 5.0.2
"@types/find-cache-dir": 3.2.1