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) #37204

Closed
wants to merge 6 commits into from
Closed
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
1 change: 1 addition & 0 deletions e2e-tests/development-runtime/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/gatsby-image/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
8 changes: 2 additions & 6 deletions e2e-tests/gatsby-image/cypress/integration/traced.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ describe(`fixed`, () => {
cy.visit(`/traced`).waitForRouteChange()
})

it(`renders a traced svg`, () => {
it(`renders a traced svg (fallsback to base64)`, () => {
cy.getTestElement(tracedTestId)
.find(`.gatsby-image-wrapper > img`)
.should(`have.attr`, `src`)
.and(src => {
;[`data:image/svg+xml`, `fill='white'`].forEach(part =>
expect(src).to.include(part)
)
})
.and(`contains`, `base64`)
})
})
1 change: 1 addition & 0 deletions e2e-tests/gatsby-static-image/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
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 e2e-tests/mdx-less-babel/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/mdx/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/path-prefix/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/production-runtime/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/themes/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions e2e-tests/visual-regression/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
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"
}
}
1 change: 1 addition & 0 deletions integration-tests/artifacts/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions integration-tests/cache-resilience/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
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#v2`,
])

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#v2`,
])

logs.should.contain(
Expand Down
1 change: 1 addition & 0 deletions integration-tests/gatsby-pipeline/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions integration-tests/images/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions integration-tests/long-term-caching/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions integration-tests/ssr/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
1 change: 1 addition & 0 deletions integration-tests/structured-logging/.yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ignore-engines true
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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABOklEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2AtWdkWMwZ2cAAkYQwcDCwBDOw/BCGWwELs1wnfxMUJ1MMBIIjNkY3gH1o9qPCCGIfisOkFI2iKUMUFPYwdxcfrCPVDE0/wFbe0QGpIiJAR1AjJJlYXiPajlMMzicpouBFDEz4AQX5KCBj0XzXHECmi/JY9MMCa1zciAXMmLogXhEiYXhqwoigFBCGyLkzQVSBwwhuM+ZYeHXKIQjwKCWqzM8UGRQYUUJNgjDl4vhlxqKtdgSiTrDYyWGGF4GXphucWaGOiGG76rokYw9eQJTItB5L5QYTsqBEulHoD81sSdv7FkK4gRoxlAnOmMgewGSJf/StTAgEgEA1PJk9+Vu8VgAAAAASUVORK5CYII=",
"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,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAIAAAAC64paAAAACXBIWXMAAAsTAAALEwEAmpwYAAABOklEQVQ4y2P4r8ZANmKgvuZ/agy/VaHojyopmv+CNf/XQCCoCEHNf1VBqv+oM5yVY1giwbBakuG2AkjknzoW/eh2AtWdkWMwZ2cAAkYQwcDCwBDOw/BCGWwELs1wnfxMUJ1MMBIIjNkY3gH1o9qPCCGIfisOkFI2iKUMUFPYwdxcfrCPVDE0/wFbe0QGpIiJAR1AjJJlYXiPajlMMzicpouBFDEz4AQX5KCBj0XzXHECmi/JY9MMCa1zciAXMmLogXhEiYXhqwoigFBCGyLkzQVSBwwhuM+ZYeHXKIQjwKCWqzM8UGRQYUUJNgjDl4vhlxqKtdgSiTrDYyWGGF4GXphucWaGOiGG76rokYw9eQJTItB5L5QYTsqBEulHoD81sSdv7FkK4gRoxlAnOmMgewGSJf/StTAgEgEA1PJk9+Vu8VgAAAAASUVORK5CYII=",
}
`;
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
Loading