Skip to content

Commit

Permalink
Merge 3e27188 into 7d65516
Browse files Browse the repository at this point in the history
  • Loading branch information
depfu[bot] committed Jul 7, 2023
2 parents 7d65516 + 3e27188 commit 4cf269b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -5,7 +5,7 @@ name: Tests

jobs:
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
name: Node ${{ matrix.node }}
strategy:
matrix:
Expand All @@ -24,7 +24,7 @@ jobs:
- run: npm test

test-targets:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
name: ${{ matrix.targets.name }}
strategy:
matrix:
Expand Down
4 changes: 2 additions & 2 deletions lib/packers/jimScott.js
Expand Up @@ -89,11 +89,11 @@ exports.pack = (imageInfos, config) => {
if (coords) {
packingData.width = Math.max(
packingData.width,
coords.x + imageInfo.width
coords.x + imageInfo.width,
);
packingData.height = Math.max(
packingData.height,
coords.y + imageInfo.height
coords.y + imageInfo.height,
);
} else {
throw new Error('jimScott.pack: Cannot fit image');
Expand Down
50 changes: 25 additions & 25 deletions lib/spriteBackgroundImages.js
Expand Up @@ -14,8 +14,8 @@ async function getCanvasImageFromImageAsset(imageAsset) {
canvasImage.onerror = (err) =>
reject(
new Error(
`Error loading ${imageAsset.urlOrDescription}: ${err.message}`
)
`Error loading ${imageAsset.urlOrDescription}: ${err.message}`,
),
);
canvasImage.onload = resolve;
canvasImage.src = imageAsset.rawSrc;
Expand All @@ -31,7 +31,7 @@ async function getImageAssetFromCanvas(canvas, assetType, assetGraph) {
} catch (err) {
if (
err.message.includes(
'the surface type is not appropriate for the operation'
'the surface type is not appropriate for the operation',
)
) {
err.message += ' (are you trying to add an SVG to a sprite?)';
Expand Down Expand Up @@ -105,7 +105,7 @@ function clampPaddingToDpr(padding, devicePixelRatio) {

function getRelationSpriteInfoFromIncomingRelation(incomingRelation) {
const parsedQueryString = queryString.parse(
incomingRelation.href.match(/\?([^#]*)/)[1]
incomingRelation.href.match(/\?([^#]*)/)[1],
);
return {
groupName: parsedQueryString.sprite || 'default',
Expand Down Expand Up @@ -153,7 +153,7 @@ module.exports = () =>
imageInfo.incomingRelations.push(relation);
imageInfo.padding = maxPaddingDimensions(
relationSpriteInfo.padding,
imageInfo.padding
imageInfo.padding,
);
}
}
Expand All @@ -174,7 +174,7 @@ module.exports = () =>
const spriteGroupName = spriteInfo.selectorForGroup;
if (spriteInfo.location) {
const matchLocation = spriteInfo.location.match(
/^url\((['"]|)(.*?)\1\)$/
/^url\((['"]|)(.*?)\1\)$/,
);
if (matchLocation) {
spriteInfo.location = matchLocation[2];
Expand Down Expand Up @@ -210,7 +210,7 @@ module.exports = () =>
});
} else {
err = new Error(
`assetgraph-sprite: Multiple differing definitions of ${spriteGroupName} sprite.\nThis is most likely an error.`
`assetgraph-sprite: Multiple differing definitions of ${spriteGroupName} sprite.\nThis is most likely an error.`,
);
err.asset = cssAsset;

Expand All @@ -233,7 +233,7 @@ module.exports = () =>
`assetgraph-sprite: Multiple identical definitions of ${spriteGroupName} sprite.`,
'This might happen if you duplicate CSS using a preprocessor.',
...redefinitionErrors[spriteGroupName].map(
(asset) => ` ${asset.urlOrDescription}`
(asset) => ` ${asset.urlOrDescription}`,
),
].join('\n');

Expand All @@ -251,8 +251,8 @@ module.exports = () =>
const spritePadding = parsePadding(spriteInfo.padding);
const canvasImages = await Promise.all(
imageInfos.map((imageInfo) =>
getCanvasImageFromImageAsset(imageInfo.asset)
)
getCanvasImageFromImageAsset(imageInfo.asset),
),
);
for (const [i, imageInfo] of imageInfos.entries()) {
const canvasImage = canvasImages[i];
Expand All @@ -263,7 +263,7 @@ module.exports = () =>
height: canvasImage.height,
padding: clampPaddingToDpr(
maxPaddingDimensions(imageInfo.padding, spritePadding),
imageInfo.asset.devicePixelRatio
imageInfo.asset.devicePixelRatio,
),
});
}
Expand Down Expand Up @@ -291,7 +291,7 @@ module.exports = () =>
imageInfo.x,
imageInfo.y,
imageInfo.width,
imageInfo.height
imageInfo.height,
);
}
const spriteImageType = /^jpe?g$/.test(spriteInfo.imageFormat)
Expand All @@ -300,7 +300,7 @@ module.exports = () =>
const spriteAssetConfig = await getImageAssetFromCanvas(
canvas,
spriteImageType,
assetGraph
assetGraph,
);

const fileName = `sprite-${spriteGroupName}-${imageInfos.length}${assetGraph[spriteImageType].prototype.defaultExtension}`;
Expand Down Expand Up @@ -343,7 +343,7 @@ module.exports = () =>
propertyValue = 'url(...)';
} else {
const existingUrlTokens = propertyValue.match(
assetGraph.CssImage.prototype.tokenRegExp
assetGraph.CssImage.prototype.tokenRegExp,
);
if (existingUrlTokens) {
tokenNumber = existingUrlTokens.length;
Expand All @@ -369,7 +369,7 @@ module.exports = () =>
propertyNode,
tokenNumber,
},
'last'
'last',
);
relation.refreshHref();
spriteInfo.cssRule.walkDecls((decl) => {
Expand All @@ -391,7 +391,7 @@ module.exports = () =>
// If background-size is set, we should update it, The correct size is now the size of the sprite:
const backgroundSizeDecls = getProperties(
spriteInfo.cssRule,
'background-size'
'background-size',
);
if (backgroundSizeDecls.length > 0) {
backgroundSizeDecls[0].value = `${packingData.width}px ${packingData.height}px`;
Expand All @@ -407,7 +407,7 @@ module.exports = () =>
const node = incomingRelation.node;
const existingBackgroundPositionDecls = getProperties(
node,
'background-position'
'background-position',
);
const existingBackgroundDecls = getProperties(node, 'background');
const offsets = [
Expand All @@ -429,7 +429,7 @@ module.exports = () =>
if (/^(?:-?\d+px|0)$/i.test(existingBackgroundValueToken)) {
positionTokenIndices.push(i);
existingOffsets.push(
parseInt(existingBackgroundValueToken, 10)
parseInt(existingBackgroundValueToken, 10),
);
}
}
Expand All @@ -440,7 +440,7 @@ module.exports = () =>
backgroundTokens.splice(
positionTokenIndices[i],
1,
offset ? `${-offset}px` : '0'
offset ? `${-offset}px` : '0',
);
}

Expand Down Expand Up @@ -471,7 +471,7 @@ module.exports = () =>
const err = new Error(
`WARNING: trying to sprite ${
imageInfo.asset.url
} with ${existingBackgroundPositionDecls[0].toString()}`
} with ${existingBackgroundPositionDecls[0].toString()}`,
);
assetGraph.warn(err);
} else {
Expand All @@ -492,7 +492,7 @@ module.exports = () =>
node.append(
`background-position: ${newBackgroundPositionValue}${
backgroundPositionImportant ? ' !important' : ''
}`
}`,
);
}
}
Expand All @@ -515,7 +515,7 @@ module.exports = () =>
// Device pixel ratio is default. Remove property and let the defaults rule
for (const backgroundSizeDecl of getProperties(
incomingRelation.node,
'background-size'
'background-size',
)) {
backgroundSizeDecl.remove();
}
Expand All @@ -528,13 +528,13 @@ module.exports = () =>
const height = packingData.height / dpr;
const existingBackgroundSizeDecls = getProperties(
incomingRelation.node,
'background-size'
'background-size',
);
if (existingBackgroundSizeDecls.length > 0) {
existingBackgroundSizeDecls[0].value = `${width}px ${height}px`;
} else {
incomingRelation.node.append(
`background-size: ${width}px ${height}px`
`background-size: ${width}px ${height}px`,
);
}
}
Expand All @@ -551,7 +551,7 @@ module.exports = () =>
to: spriteAsset,
},
'before',
incomingRelation
incomingRelation,
);
relation.refreshHref();
incomingRelation.remove();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
"mocha": "^7.0.0",
"nyc": "^15.0.0",
"offline-github-changelog": "^3.0.0",
"prettier": "~2.8.0",
"prettier": "~3.0.0",
"sinon": "^15.0.0",
"unexpected": "^13.0.0",
"unexpected-image": "^4.0.0",
Expand Down

0 comments on commit 4cf269b

Please sign in to comment.