@sanity/image-url
Advanced tools
Comparing version 0.141.0-alpha.12 to 1.0.0
// eslint-disable-next-line import/no-commonjs | ||
module.exports = require('./lib/builder').default | ||
module.exports = require('./lib/node/builder') |
{ | ||
"name": "@sanity/image-url", | ||
"version": "0.141.0-alpha.12+42f8f1f0a", | ||
"version": "1.0.0", | ||
"description": "Tools to generate image urls from Sanity content", | ||
"main": "index.js", | ||
"umd": "umd/sanityImageUrl.min.js", | ||
"unpkg": "umd/sanityImageUrl.min.js", | ||
"source": "src/builder.ts", | ||
"main": "lib/node/index.js", | ||
"browser": "lib/browser/image-url.umd.js", | ||
"umd:main": "lib/browser/image-url.umd.js", | ||
"typings": "lib/types/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"index.js", | ||
"urlForImage.js" | ||
], | ||
"sideEffects": false, | ||
"amdName": "SanityImageUrlBuilder", | ||
"scripts": { | ||
"build": "npm run clean && npm run compile && npm run browserify && npm run minify", | ||
"browserify": "NODE_ENV=production BROWSERIFY_ENV=build DEBUG='' browserify -t envify -g uglifyify index.js -o umd/sanityImageUrl.js --standalone=SanityImageUrlBuilder", | ||
"coverage": "jest --coverage", | ||
"compile": "babel --source-maps --copy-files -d lib/ src/", | ||
"clean": "rimraf lib", | ||
"postpublish": "npm run clean", | ||
"minify": "terser -c -m -- umd/sanityImageUrl.js > umd/sanityImageUrl.min.js", | ||
"prepublishOnly": "npm run build", | ||
"test": "jest" | ||
"prebuild": "rimraf lib coverage .rts2*", | ||
"build": "npm run build:node && npm run build:browser", | ||
"build:node": "tsc -m commonjs", | ||
"build:browser": "microbundle build -i src/browser.ts -o lib/browser -f umd,es --no-compress", | ||
"lint": "tslint --project tsconfig.json -t codeFrame 'src/**/*.ts' 'test/**/*.ts'", | ||
"test": "jest --coverage", | ||
"test:watch": "jest --coverage --watch", | ||
"test:prod": "npm run lint && npm run test -- --no-cache", | ||
"posttest": "npm run lint" | ||
}, | ||
"engines": { | ||
"node": ">=10.0.0" | ||
}, | ||
"jest": { | ||
"transform": { | ||
".(ts|tsx)": "ts-jest" | ||
}, | ||
"testEnvironment": "node", | ||
"testURL": "http://localhost", | ||
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$", | ||
"moduleFileExtensions": [ | ||
"ts", | ||
"tsx", | ||
"js" | ||
], | ||
"coveragePathIgnorePatterns": [ | ||
"/node_modules/", | ||
"/test/" | ||
], | ||
"collectCoverageFrom": [ | ||
"src/*.{js,ts}" | ||
] | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"printWidth": 100 | ||
}, | ||
"author": "Sanity.io <hello@sanity.io>", | ||
@@ -25,17 +64,19 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@babel/cli": "^7.1.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"browserify": "^14.3.0", | ||
"envify": "^4.0.0", | ||
"jest": "^23.6.0", | ||
"rimraf": "^2.6.2", | ||
"terser": "^3.10.11", | ||
"uglifyify": "^5.0.1" | ||
"@types/jest": "^25.2.1", | ||
"@types/node": "^13.13.5", | ||
"jest": "^26.0.1", | ||
"microbundle": "^0.12.0", | ||
"prettier": "^2.0.5", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^25.5.1", | ||
"tslint": "^6.1.2", | ||
"tslint-config-prettier": "^1.15.0", | ||
"typescript": "^3.8.3" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/sanity-io/sanity.git" | ||
"url": "git+https://github.com/sanity-io/image-url.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/sanity-io/sanity/issues" | ||
"url": "https://github.com/sanity-io/image-url/issues" | ||
}, | ||
@@ -53,7 +94,3 @@ "homepage": "https://www.sanity.io/", | ||
"image-url" | ||
], | ||
"jest": { | ||
"testURL": "http://localhost" | ||
}, | ||
"gitHead": "42f8f1f0a39fa9191a1cdda485e726d261fca877" | ||
] | ||
} |
@@ -15,5 +15,5 @@ # @sanity/image-url | ||
The most common way to use this library in your project is to configure it by passing it your configured sanityClient. That way it will automatically be preconfigured to your current project and dataset: | ||
The most common way to use this library in your project is to configure it by passing it [your configured sanityClient](https://www.npmjs.com/package/@sanity/client). That way it will automatically be preconfigured to your current project and dataset: | ||
``` js | ||
```js | ||
import React from 'react' | ||
@@ -32,4 +32,4 @@ import myConfiguredSanityClient from './sanityClient' | ||
``` js | ||
<img src={urlFor(author.image).width(200).url()} /> | ||
```jsx | ||
<img src={urlFor(author.image).width(200).url()} /> | ||
``` | ||
@@ -39,12 +39,14 @@ | ||
``` js | ||
<img src={urlFor(movie.poster).width(500).height(300).url()}> | ||
```jsx | ||
<img src={urlFor(movie.poster).width(500).height(300).url()}> | ||
``` | ||
There are a huge number of useful options you can specify, like e.g. blur: | ||
There are a large number of useful options you can specify, like e.g. blur: | ||
``` js | ||
<img src={urlFor(mysteryPerson.mugshot).width(200).height(200).blur(50).url()}> | ||
```jsx | ||
<img src={urlFor(mysteryPerson.mugshot).width(200).height(200).blur(50).url()}> | ||
``` | ||
Note that the `url()` function needs to be the final one in order to output the url as a string. | ||
## Builder methods | ||
@@ -54,7 +56,7 @@ | ||
Specify the image to be rendered. Accepts either a Sanity `image` record, an `asset` record, or just the asset id as a string. In order for hotspot/crop processing to be applied, the `image` record must be supplied. | ||
Specify the image to be rendered. Accepts either a Sanity `image` record, an `asset` record, or just the asset id as a string. In order for hotspot/crop processing to be applied, the `image` record must be supplied, as well as both width and height. | ||
### `dataset(dataset)`, `projectId(projectId)` | ||
Usually you should preconfigure your builder with dataset and project id, but even whem you did, these let you temporarily override them if you need to render assets from other projects or datasets. | ||
Usually you should preconfigure your builder with dataset and project id, but even when you did, these let you temporarily override them if you need to render assets from other projects or datasets. | ||
@@ -77,6 +79,2 @@ ### `width(pixels)` | ||
### `minWidth(pixels)`, `maxWidth(pixels)`, `minHeight(pixels)`, `maxHeight(pixels)` | ||
Specifies min/max dimensions when cropping | ||
### `blur(amount)`, `sharpen(amount)`, `invert()` | ||
@@ -94,2 +92,8 @@ | ||
### `auto(mode)` | ||
Specify transformations to automatically apply based on browser capabilities. Supported values: | ||
- `format` - Automatically uses WebP if supported | ||
### `orientation(angle)` | ||
@@ -119,2 +123,10 @@ | ||
### `dpr(value)` | ||
Specifies device pixel ratio scaling factor. From 1 to 3. | ||
### `saturation(value)` | ||
Adjusts the saturation of the image. Currently the only supported value is `-100` - meaning it grayscales the image. | ||
### `ignoreImageParams()` | ||
@@ -127,1 +139,11 @@ | ||
Return the url as a string. | ||
### `pad(value)` | ||
Specify the number of pixels to pad the image. | ||
### Deprecated: `minWidth(pixels)`, `maxWidth(pixels)`, `minHeight(pixels)`, `maxHeight(pixels)` | ||
Specifies min/max dimensions when cropping. | ||
**Deprecated**: You usually want to use `width`/`height` with a fit mode of `max` or `min` instead. |
// eslint-disable-next-line import/no-commonjs | ||
module.exports = require('./lib/urlForImage').default | ||
module.exports = require('./lib/node/urlForImage').default |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
153737
37
1907
0
142
0
10