@dreamonkey/responsive-image-plugin
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -17,5 +17,6 @@ "use strict"; | ||
const file_type_1 = require("file-type"); | ||
const image_size_1 = __importDefault(require("image-size")); | ||
const fs_extra_1 = require("fs-extra"); | ||
const lodash_1 = require("lodash"); | ||
const path_1 = require("path"); | ||
const probe_image_size_1 = __importDefault(require("probe-image-size")); | ||
const base_1 = require("./base"); | ||
@@ -70,3 +71,3 @@ const sharp_1 = require("./converters/sharp"); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
width: (0, image_size_1.default)(sourcePath).width, | ||
width: probe_image_size_1.default.sync((0, fs_extra_1.readFileSync)(sourcePath)).width, | ||
}, | ||
@@ -73,0 +74,0 @@ ], |
@@ -19,2 +19,3 @@ import { Dictionary } from 'ts-essentials'; | ||
export declare const urlReplaceMap: Record<string, string>; | ||
export declare const metadataCache: Map<string, ResponsiveImage[]>; | ||
export declare function enhance(source: string, images: ConversionResponsiveImage[]): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.enhance = exports.urlReplaceMap = exports.parse = exports.resolveImagePath = exports.parseProperties = exports.URL_PLACEHOLDER_PATTERN = exports.IMG_TAG_PLACEHOLDER_PATTERN = exports.generateUrlPlaceholder = exports.generateImgTagPlaceholder = void 0; | ||
exports.enhance = exports.metadataCache = exports.urlReplaceMap = exports.parse = exports.resolveImagePath = exports.parseProperties = exports.URL_PLACEHOLDER_PATTERN = exports.IMG_TAG_PLACEHOLDER_PATTERN = exports.generateUrlPlaceholder = exports.generateImgTagPlaceholder = void 0; | ||
const lodash_1 = require("lodash"); | ||
@@ -192,2 +192,3 @@ const mime_types_1 = require("mime-types"); | ||
exports.urlReplaceMap = {}; | ||
exports.metadataCache = new Map(); | ||
// If we don't have the entry in the map, we haven't generated images yet, | ||
@@ -194,0 +195,0 @@ // so we put a placeholder to mark this file as needed for a rebuild later on. |
@@ -7,5 +7,6 @@ "use strict"; | ||
exports.resolveResizer = exports.applyResizes = exports.pendingResizes = exports.byIncreasingWidth = exports.generateResizingUri = void 0; | ||
const image_size_1 = __importDefault(require("image-size")); | ||
const fs_extra_1 = require("fs-extra"); | ||
const lodash_1 = require("lodash"); | ||
const path_1 = require("path"); | ||
const probe_image_size_1 = __importDefault(require("probe-image-size")); | ||
const base_1 = require("./base"); | ||
@@ -27,4 +28,4 @@ const helpers_1 = require("./helpers"); | ||
function getImgRatio(path) { | ||
const { height, width } = (0, image_size_1.default)(path); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const { height, width } = probe_image_size_1.default.sync((0, fs_extra_1.readFileSync)(path)); | ||
return height / width; | ||
@@ -31,0 +32,0 @@ } |
@@ -15,8 +15,12 @@ "use strict"; | ||
parsedImages.forEach((responsiveImage) => this.addDependency(responsiveImage.originalPath)); | ||
parsedImages.forEach((image) => (0, transformation_1.applyTransformations)(pluginContext, this, image)); | ||
parsedImages.forEach((image) => (0, resizing_1.applyResizes)(pluginContext, image)); | ||
parsedImages.forEach((image) => (0, conversion_1.applyConversions)(pluginContext, image)); | ||
return (0, parsing_1.enhance)(sourceWithPlaceholders, parsedImages); | ||
// Skip metadata generation if this is the rebuild run, as we already generated images | ||
if (!parsing_1.metadataCache.has(this.resourcePath)) { | ||
parsedImages.forEach((image) => (0, transformation_1.applyTransformations)(pluginContext, this, image)); | ||
parsedImages.forEach((image) => (0, resizing_1.applyResizes)(pluginContext, image)); | ||
parsedImages.forEach((image) => (0, conversion_1.applyConversions)(pluginContext, image)); | ||
parsing_1.metadataCache.set(this.resourcePath, parsedImages); | ||
} | ||
return (0, parsing_1.enhance)(sourceWithPlaceholders, parsing_1.metadataCache.get(this.resourcePath)); | ||
}; | ||
exports.default = loader; | ||
//# sourceMappingURL=responsive-image-loader.js.map |
@@ -38,2 +38,10 @@ "use strict"; | ||
let generationCompleted; | ||
function getBgHandlerPath() { | ||
// Short circuit the path since it's not available at test time, | ||
// since we don't run an intermediate build step | ||
if (process.env.NODE_ENV === 'test') { | ||
return ''; | ||
} | ||
return require.resolve((0, path_1.join)(__dirname, 'bg-handler')); | ||
} | ||
class ResponsiveImagePlugin { | ||
@@ -196,4 +204,4 @@ constructor(options = {}) { | ||
ResponsiveImagePlugin.loader = require.resolve((0, path_1.join)(__dirname, 'responsive-image-loader')); | ||
ResponsiveImagePlugin.bgHandler = require.resolve((0, path_1.join)(__dirname, 'bg-handler')); | ||
ResponsiveImagePlugin.bgHandler = getBgHandlerPath(); | ||
exports.default = ResponsiveImagePlugin; | ||
//# sourceMappingURL=responsive-image-plugin.js.map |
@@ -101,2 +101,3 @@ "use strict"; | ||
let pathBody = `-tb_${maxViewport}`; | ||
// TODO: path isn't apparently working | ||
if (isCustomTransformation(transformation)) { | ||
@@ -103,0 +104,0 @@ // 'p' stands for 'path' |
{ | ||
"name": "@dreamonkey/responsive-image-plugin", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "A webpack plugin to automagically bring your website images to a whole new level of responsiveness!", | ||
@@ -42,4 +42,4 @@ "keywords": [ | ||
"got": "^11.8.2", | ||
"image-size": "^1.0.1", | ||
"lodash": "^4.17.21", | ||
"probe-image-size": "^7.2.3", | ||
"sharp": "^0.30.1", | ||
@@ -55,2 +55,3 @@ "ts-essentials": "^9.1.2" | ||
"@types/node": "^12.20.47", | ||
"@types/probe-image-size": "^7.0.1", | ||
"@typescript-eslint/eslint-plugin": "5.11.0", | ||
@@ -57,0 +58,0 @@ "@typescript-eslint/parser": "5.11.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
161645
1652
20
7
+ Addedprobe-image-size@^7.2.3
+ Addeddebug@2.6.93.2.7(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedlodash.merge@4.6.2(transitive)
+ Addedms@2.0.02.1.3(transitive)
+ Addedneedle@2.9.1(transitive)
+ Addedprobe-image-size@7.2.3(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.3.0(transitive)
+ Addedstream-parser@0.3.1(transitive)
- Removedimage-size@^1.0.1
- Removedimage-size@1.1.1(transitive)
- Removedqueue@6.0.2(transitive)