Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove tracedSVG (#37093) #37137

Merged
merged 12 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion e2e-tests/contentful/cypress/integration/gatsby-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ describe(`gatsby-image`, () => {
it(`fluid`, testConfig, () => testGatsbyImage(`fluid`, hasBase64Placeholder))
it(`fixed`, testConfig, () => testGatsbyImage(`fixed`, hasBase64Placeholder))
it(`webp`, testConfig, () => testGatsbyImage(`webp`, hasBase64Placeholder))
it(`traced`, testConfig, () => testGatsbyImage(`traced`, hasSVGPlaceholder))
it(`traced`, testConfig, () =>
testGatsbyImage(`traced`, hasBase64Placeholder)
)
it(`sqip`, testConfig, () => testGatsbyImage(`sqip`, hasSVGPlaceholder))

it(`english`, testConfig, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe(`gatsby-plugin-image`, () => {
testGatsbyPluginImage(`dominant-color`, hasColorPlaceholder)
)
it(`traced`, testConfig, () =>
testGatsbyPluginImage(`traced`, hasSVGPlaceholder)
testGatsbyPluginImage(`traced`, hasColorPlaceholder)
)
it(`blurred`, testConfig, () =>
testGatsbyPluginImage(`blurred`, hasBase64Placeholder)
Expand Down
2 changes: 1 addition & 1 deletion e2e-tests/contentful/cypress/integration/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe(`tags`, () => {
"have.text",
"numberInteger"
)
cy.get('[data-cy-id^="tag-"]').should("have.length", 2)
cy.get('[data-cy-id^="tag-"]').should("have.length", 5)
})
it(`Filtered Entries`, () => {
cy.get('[data-cy-integers] [data-cy-id="number-integer"]').should(
Expand Down
4 changes: 3 additions & 1 deletion e2e-tests/contentful/src/pages/gatsby-plugin-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ const GatsbyPluginImagePage = ({ data }) => {
))}
</Grid>

<h2>gatsby-plugin-image: Traced SVG Placeholder</h2>
<h2>
gatsby-plugin-image: Traced SVG Placeholder (fallback to DOMINANT_COLOR)
</h2>
<Grid data-cy="traced">
{data.default.nodes.map(node => (
<div>
Expand Down
12 changes: 7 additions & 5 deletions e2e-tests/gatsby-static-image/cypress/integration/traced.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ describe(`fixed`, () => {
cy.visit(`/traced`).waitForRouteChange()
})

it(`renders a traced svg`, () => {
it(`traced svg (falls back to DOMINANT_COLOR)`, () => {
cy.getTestElement(tracedTestId)
.find(`.gatsby-image-wrapper > img`)
.should(`have.attr`, `src`)
.and(src => {
;[`data:image/svg+xml`].forEach(part => expect(src).to.include(part))
.find(`.gatsby-image-wrapper > [data-placeholder-image]`)
.first()
.should($el => {
// traced falls
expect($el.prop("tagName")).to.be.equal("DIV")
expect($el).to.be.empty
})
})

Expand Down
1 change: 1 addition & 0 deletions examples/using-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"scripts": {
"develop": "gatsby develop",
"build": "gatsby build",
"clean": "gatsby clean",
"start": "gatsby serve"
}
}
8 changes: 6 additions & 2 deletions integration-tests/gatsby-cli/__tests__/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ describe(`gatsby new`, () => {
})

it(`creates a gatsby site with the default starter`, () => {
const [code, logs] = GatsbyCLI.from(cwd).invoke([`new`, `gatsby-default`])
const [code, logs] = GatsbyCLI.from(cwd).invoke([
`new`,
`gatsby-default`,
`gatsbyjs/gatsby-starter-default#v3`,
])

logs.should.contain(
`info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-default.git`
Expand All @@ -48,7 +52,7 @@ describe(`gatsby new`, () => {
const [code, logs] = GatsbyCLI.from(cwd).invoke([
`new`,
`gatsby-blog`,
`gatsbyjs/gatsby-starter-blog`,
`gatsbyjs/gatsby-starter-blog#v3`,
])

logs.should.contain(
Expand Down
12 changes: 7 additions & 5 deletions packages/gatsby-cli/src/structured-errors/error-schema.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Joi from "joi"
import { ILocationPosition, IStructuredError } from "./types"

export const Position: Joi.ObjectSchema<ILocationPosition> = Joi.object().keys({
line: Joi.number(),
column: Joi.number(),
})
export const Position: Joi.ObjectSchema<ILocationPosition> = Joi.object()
.keys({
line: Joi.number(),
column: Joi.number(),
})
.unknown()

export const errorSchema: Joi.ObjectSchema<IStructuredError> =
Joi.object().keys({
Expand All @@ -27,7 +29,7 @@ export const errorSchema: Joi.ObjectSchema<IStructuredError> =
location: Joi.object({
start: Position.required(),
end: Position,
}),
}).unknown(),
docsUrl: Joi.string().uri({
allowRelative: false,
relativeOnly: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/gatsby-plugin-image/src/resolver-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ export function getGatsbyImageFieldConfig<TSource, TContext, TArgs>(
type: ImagePlaceholderType.name,
description: stripIndent`
Format of generated placeholder image, displayed while the main image loads.
BLURRED: a blurred, low resolution image, encoded as a base64 data URI (default)
DOMINANT_COLOR: a solid color, calculated from the dominant color of the image.
TRACED_SVG: a low-resolution traced SVG of the image.
BLURRED: a blurred, low resolution image, encoded as a base64 data URI.
DOMINANT_COLOR: a solid color, calculated from the dominant color of the image (default).
TRACED_SVG: deprecated. Will use DOMINANT_COLOR.
NONE: no placeholder. Set the argument "backgroundColor" to use a fixed background color.`,
},
formats: {
Expand Down
3 changes: 0 additions & 3 deletions packages/gatsby-plugin-sharp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
"gatsby-telemetry": "^2.14.0",
"got": "^11.8.2",
"lodash": "^4.17.21",
"mini-svg-data-uri": "^1.3.3",
"potrace": "^2.1.8",
"probe-image-size": "^6.0.0",
"progress": "^2.0.3",
"semver": "^7.3.5",
"sharp": "^0.29.0",
"svgo": "1.3.2",
"uuid": "3.4.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1604,20 +1604,20 @@ Object {
}
`;

exports[`gatsby-plugin-sharp tracedSVG runs on demand 1`] = `
exports[`gatsby-plugin-sharp tracedSVG runs on demand (and falls back to blurred): fixed 1`] = `
Object {
"aspectRatio": 1,
"base64": undefined,
"height": 100,
"originalName": "test.png",
"src": "/static/1234/7e516/test.png",
"srcSet": "/static/1234/7e516/test.png 1x",
"tracedSVG": "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='100'%20height='100'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='none'%3e%3cpath%20d='M41%2024c-18%207-24%2029-11%2043%2015%2017%2044%208%2046-15%201-19-17-34-35-28'%20fill='red'%20fill-rule='evenodd'/%3e%3c/svg%3e",
"tracedSVG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABP0lEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2/tdgOCPHYM7OwMDAwAgiGFgYGMJ5GF4og43ApRmuk58JqpMJRjIwMBizMbxTZviPaj8ihCD6rThAStkgljJATWEHc3P5wT5SxdD8B2ztERmQIiYGdAAxSpaF4T2q5TDN4HCaLgZSxMyAE1yQgwY+Fs1zxQloviSPTTMktM7JgVzIiKEH4hElFoavKogAQgltiJA3F0gdOyPC58yw8GsUwhFgUMvVGR4oMqiwogQbhOHLxfBLDcVabIlEneGxEkMMLwMvTLc4M0OdEMN3VfRIxp48/6mDnPdCieGkHCiRflRh+K+JPXljz1IQJ0AzhjrRGQPZC5As+ZeuhQGRmgHU8mT34D0STQAAAABJRU5ErkJggg==",
"width": 100,
}
`;

exports[`gatsby-plugin-sharp tracedSVG runs on demand 2`] = `
exports[`gatsby-plugin-sharp tracedSVG runs on demand (and falls back to blurred): fluid 1`] = `
Object {
"aspectRatio": 1,
"base64": undefined,
Expand All @@ -1632,6 +1632,6 @@ Object {
/static/1234/a1812/test.png 50w,
/static/1234/7e516/test.png 100w",
"srcSetType": "image/png",
"tracedSVG": "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='100'%20height='100'%20viewBox='0%200%20100%20100'%20preserveAspectRatio='none'%3e%3cpath%20d='M41%2024c-18%207-24%2029-11%2043%2015%2017%2044%208%2046-15%201-19-17-34-35-28'%20fill='red'%20fill-rule='evenodd'/%3e%3c/svg%3e",
"tracedSVG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABP0lEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2/tdgOCPHYM7OwMDAwAgiGFgYGMJ5GF4og43ApRmuk58JqpMJRjIwMBizMbxTZviPaj8ihCD6rThAStkgljJATWEHc3P5wT5SxdD8B2ztERmQIiYGdAAxSpaF4T2q5TDN4HCaLgZSxMyAE1yQgwY+Fs1zxQloviSPTTMktM7JgVzIiKEH4hElFoavKogAQgltiJA3F0gdOyPC58yw8GsUwhFgUMvVGR4oMqiwogQbhOHLxfBLDcVabIlEneGxEkMMLwMvTLc4M0OdEMN3VfRIxp48/6mDnPdCieGkHCiRflRh+K+JPXljz1IQJ0AzhjrRGQPZC5As+ZeuhQGRmgHU8mT34D0STQAAAABJRU5ErkJggg==",
}
`;
12 changes: 9 additions & 3 deletions packages/gatsby-plugin-sharp/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ describe(`gatsby-plugin-sharp`, () => {
expect(result.tracedSVG).toBeUndefined()
})

it(`runs on demand`, async () => {
it(`runs on demand (and falls back to blurred)`, async () => {
const args = {
maxWidth: 100,
width: 100,
Expand All @@ -665,14 +665,20 @@ describe(`gatsby-plugin-sharp`, () => {
args,
})

expect(fixedSvg).toMatchSnapshot()
expect(fixedSvg).toMatchSnapshot(`fixed`)

expect(fixedSvg.tracedSVG).toMatch(`data:image/png;base64`)
expect(fixedSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)

const fluidSvg = await fluid({
file,
args,
})

expect(fluidSvg).toMatchSnapshot()
expect(fluidSvg).toMatchSnapshot(`fluid`)

expect(fluidSvg.tracedSVG).toMatch(`data:image/png;base64`)
expect(fluidSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
})
})

Expand Down
Loading