Skip to content

Commit

Permalink
chore: remove tracedSVG (#37093) (#37137)
Browse files Browse the repository at this point in the history
* chore: remove tracedSVG (#37093)

* init

* gri

* update shopify snapshot

* gatsby-plugin-sharp tests

* update gatsby-remark-images/gatsby-node tests

* update gatsby-plugin-image tests

* update schema print tests

* remove traceSVG unit tests as it was removed

* legacy gatsby-image fields

* update polyfill tests

* update cypress assertion

* update contentful cypress assertions

* drop few more packages from gatsby-plugin-sharp as they are no onger used

* correct IMAGE_CDN fallback for TRACE_SVG

* update generateImageData

* update e2e-prod/assertions

* update unit test

* update snapshot

* update e2e-dev/assertions

* drop more unused

* sync yarn.lock

* a bit more prod warnings

* adjust gatsby-remark-images plugin options warning

* add link to gatsby-remark-images warning

(cherry picked from commit 94c2d73)

* gatsby recipe tests

* cli tests

* babel config tests

* update assertion

* some reverts?

* update assertion

* contentful extend node type

* fallback in test

* fix tracedSVG fields

* fix(gatsby-cli): relax error location validation and ignore extra fields (#34559)

* package.json removals

Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
(cherry picked from commit 0c45654)
  • Loading branch information
gatsbybot authored and pieh committed Dec 7, 2022
1 parent dbfacfb commit d9b5795
Show file tree
Hide file tree
Showing 26 changed files with 388 additions and 1,149 deletions.
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 @@ -32,6 +32,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 "@hapi/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> = Joi.object().keys
location: Joi.object({
start: Position.required(),
end: Position,
}),
}).unknown(),
docsUrl: Joi.string().uri({
allowRelative: false,
relativeOnly: false,
Expand Down
10 changes: 5 additions & 5 deletions packages/gatsby-plugin-image/src/resolver-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ export function getGatsbyImageFieldConfig<TSource, TContext>(
type: ImagePlaceholderType,
defaultValue: `blurred`,
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.
NONE: no placeholder. Set "background" to use a fixed background color.`,
Format of generated placeholder image, displayed while the main image loads.
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: {
type: GraphQLList(ImageFormatType),
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 @@ -19,13 +19,10 @@
"imagemin-mozjpeg": "^9.0.0",
"imagemin-pngquant": "^9.0.1",
"lodash": "^4.17.20",
"mini-svg-data-uri": "^1.2.3",
"potrace": "^2.1.8",
"probe-image-size": "^6.0.0",
"progress": "^2.0.3",
"semver": "^7.3.4",
"sharp": "^0.27.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 @@ -657,7 +657,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 @@ -671,14 +671,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
219 changes: 0 additions & 219 deletions packages/gatsby-plugin-sharp/src/__tests__/trace-svg.js

This file was deleted.

Loading

0 comments on commit d9b5795

Please sign in to comment.