Skip to content

Commit d9b5795

Browse files
gatsbybotpieh
andcommitted
chore: remove tracedSVG (#37093) (#37137)
* 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 <[email protected]> (cherry picked from commit 0c45654)
1 parent dbfacfb commit d9b5795

File tree

26 files changed

+388
-1149
lines changed

26 files changed

+388
-1149
lines changed

e2e-tests/gatsby-static-image/cypress/integration/traced.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ describe(`fixed`, () => {
55
cy.visit(`/traced`).waitForRouteChange()
66
})
77

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

examples/using-contentful/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"scripts": {
3333
"develop": "gatsby develop",
3434
"build": "gatsby build",
35+
"clean": "gatsby clean",
3536
"start": "gatsby serve"
3637
}
3738
}

integration-tests/gatsby-cli/__tests__/new.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ describe(`gatsby new`, () => {
2929
})
3030

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

3438
logs.should.contain(
3539
`info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-default.git`
@@ -48,7 +52,7 @@ describe(`gatsby new`, () => {
4852
const [code, logs] = GatsbyCLI.from(cwd).invoke([
4953
`new`,
5054
`gatsby-blog`,
51-
`gatsbyjs/gatsby-starter-blog`,
55+
`gatsbyjs/gatsby-starter-blog#v3`,
5256
])
5357

5458
logs.should.contain(

packages/gatsby-cli/src/structured-errors/error-schema.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import Joi from "@hapi/joi"
22
import { ILocationPosition, IStructuredError } from "./types"
33

4-
export const Position: Joi.ObjectSchema<ILocationPosition> = Joi.object().keys({
5-
line: Joi.number(),
6-
column: Joi.number(),
7-
})
4+
export const Position: Joi.ObjectSchema<ILocationPosition> = Joi.object()
5+
.keys({
6+
line: Joi.number(),
7+
column: Joi.number(),
8+
})
9+
.unknown()
810

911
export const errorSchema: Joi.ObjectSchema<IStructuredError> = Joi.object().keys(
1012
{
@@ -27,7 +29,7 @@ export const errorSchema: Joi.ObjectSchema<IStructuredError> = Joi.object().keys
2729
location: Joi.object({
2830
start: Position.required(),
2931
end: Position,
30-
}),
32+
}).unknown(),
3133
docsUrl: Joi.string().uri({
3234
allowRelative: false,
3335
relativeOnly: false,

packages/gatsby-plugin-image/src/resolver-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export function getGatsbyImageFieldConfig<TSource, TContext>(
7777
type: ImagePlaceholderType,
7878
defaultValue: `blurred`,
7979
description: stripIndent`
80-
Format of generated placeholder image, displayed while the main image loads.
81-
BLURRED: a blurred, low resolution image, encoded as a base64 data URI (default)
82-
DOMINANT_COLOR: a solid color, calculated from the dominant color of the image.
83-
TRACED_SVG: a low-resolution traced SVG of the image.
84-
NONE: no placeholder. Set "background" to use a fixed background color.`,
80+
Format of generated placeholder image, displayed while the main image loads.
81+
BLURRED: a blurred, low resolution image, encoded as a base64 data URI.
82+
DOMINANT_COLOR: a solid color, calculated from the dominant color of the image (default).
83+
TRACED_SVG: deprecated. Will use DOMINANT_COLOR.
84+
NONE: no placeholder. Set the argument "backgroundColor" to use a fixed background color.`,
8585
},
8686
formats: {
8787
type: GraphQLList(ImageFormatType),

packages/gatsby-plugin-sharp/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
"imagemin-mozjpeg": "^9.0.0",
2020
"imagemin-pngquant": "^9.0.1",
2121
"lodash": "^4.17.20",
22-
"mini-svg-data-uri": "^1.2.3",
23-
"potrace": "^2.1.8",
2422
"probe-image-size": "^6.0.0",
2523
"progress": "^2.0.3",
2624
"semver": "^7.3.4",
2725
"sharp": "^0.27.0",
28-
"svgo": "1.3.2",
2926
"uuid": "3.4.0"
3027
},
3128
"devDependencies": {

packages/gatsby-plugin-sharp/src/__tests__/__snapshots__/index.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,20 +1604,20 @@ Object {
16041604
}
16051605
`;
16061606

1607-
exports[`gatsby-plugin-sharp tracedSVG runs on demand 1`] = `
1607+
exports[`gatsby-plugin-sharp tracedSVG runs on demand (and falls back to blurred): fixed 1`] = `
16081608
Object {
16091609
"aspectRatio": 1,
16101610
"base64": undefined,
16111611
"height": 100,
16121612
"originalName": "test.png",
16131613
"src": "/static/1234/7e516/test.png",
16141614
"srcSet": "/static/1234/7e516/test.png 1x",
1615-
"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",
1615+
"tracedSVG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABP0lEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2/tdgOCPHYM7OwMDAwAgiGFgYGMJ5GF4og43ApRmuk58JqpMJRjIwMBizMbxTZviPaj8ihCD6rThAStkgljJATWEHc3P5wT5SxdD8B2ztERmQIiYGdAAxSpaF4T2q5TDN4HCaLgZSxMyAE1yQgwY+Fs1zxQloviSPTTMktM7JgVzIiKEH4hElFoavKogAQgltiJA3F0gdOyPC58yw8GsUwhFgUMvVGR4oMqiwogQbhOHLxfBLDcVabIlEneGxEkMMLwMvTLc4M0OdEMN3VfRIxp48/6mDnPdCieGkHCiRflRh+K+JPXljz1IQJ0AzhjrRGQPZC5As+ZeuhQGRmgHU8mT34D0STQAAAABJRU5ErkJggg==",
16161616
"width": 100,
16171617
}
16181618
`;
16191619

1620-
exports[`gatsby-plugin-sharp tracedSVG runs on demand 2`] = `
1620+
exports[`gatsby-plugin-sharp tracedSVG runs on demand (and falls back to blurred): fluid 1`] = `
16211621
Object {
16221622
"aspectRatio": 1,
16231623
"base64": undefined,
@@ -1632,6 +1632,6 @@ Object {
16321632
/static/1234/a1812/test.png 50w,
16331633
/static/1234/7e516/test.png 100w",
16341634
"srcSetType": "image/png",
1635-
"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",
1635+
"tracedSVG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABP0lEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2/tdgOCPHYM7OwMDAwAgiGFgYGMJ5GF4og43ApRmuk58JqpMJRjIwMBizMbxTZviPaj8ihCD6rThAStkgljJATWEHc3P5wT5SxdD8B2ztERmQIiYGdAAxSpaF4T2q5TDN4HCaLgZSxMyAE1yQgwY+Fs1zxQloviSPTTMktM7JgVzIiKEH4hElFoavKogAQgltiJA3F0gdOyPC58yw8GsUwhFgUMvVGR4oMqiwogQbhOHLxfBLDcVabIlEneGxEkMMLwMvTLc4M0OdEMN3VfRIxp48/6mDnPdCieGkHCiRflRh+K+JPXljz1IQJ0AzhjrRGQPZC5As+ZeuhQGRmgHU8mT34D0STQAAAABJRU5ErkJggg==",
16361636
}
16371637
`;

packages/gatsby-plugin-sharp/src/__tests__/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ describe(`gatsby-plugin-sharp`, () => {
657657
expect(result.tracedSVG).toBeUndefined()
658658
})
659659

660-
it(`runs on demand`, async () => {
660+
it(`runs on demand (and falls back to blurred)`, async () => {
661661
const args = {
662662
maxWidth: 100,
663663
width: 100,
@@ -671,14 +671,20 @@ describe(`gatsby-plugin-sharp`, () => {
671671
args,
672672
})
673673

674-
expect(fixedSvg).toMatchSnapshot()
674+
expect(fixedSvg).toMatchSnapshot(`fixed`)
675+
676+
expect(fixedSvg.tracedSVG).toMatch(`data:image/png;base64`)
677+
expect(fixedSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
675678

676679
const fluidSvg = await fluid({
677680
file,
678681
args,
679682
})
680683

681-
expect(fluidSvg).toMatchSnapshot()
684+
expect(fluidSvg).toMatchSnapshot(`fluid`)
685+
686+
expect(fluidSvg.tracedSVG).toMatch(`data:image/png;base64`)
687+
expect(fluidSvg.tracedSVG).not.toMatch(`data:image/svg+xml`)
682688
})
683689
})
684690

packages/gatsby-plugin-sharp/src/__tests__/trace-svg.js

Lines changed: 0 additions & 219 deletions
This file was deleted.

0 commit comments

Comments
 (0)