source: trip-planner-front/node_modules/less/lib/less-node/image-size.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var dimension_1 = tslib_1.__importDefault(require("../less/tree/dimension"));
5var expression_1 = tslib_1.__importDefault(require("../less/tree/expression"));
6var function_registry_1 = tslib_1.__importDefault(require("./../less/functions/function-registry"));
7exports.default = (function (environment) {
8 function imageSize(functionContext, filePathNode) {
9 var filePath = filePathNode.value;
10 var currentFileInfo = functionContext.currentFileInfo;
11 var currentDirectory = currentFileInfo.rewriteUrls ?
12 currentFileInfo.currentDirectory : currentFileInfo.entryPath;
13 var fragmentStart = filePath.indexOf('#');
14 var fragment = '';
15 if (fragmentStart !== -1) {
16 fragment = filePath.slice(fragmentStart);
17 filePath = filePath.slice(0, fragmentStart);
18 }
19 var fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);
20 if (!fileManager) {
21 throw {
22 type: 'File',
23 message: "Can not set up FileManager for " + filePathNode
24 };
25 }
26 var fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);
27 if (fileSync.error) {
28 throw fileSync.error;
29 }
30 var sizeOf = require('image-size');
31 return sizeOf(fileSync.filename);
32 }
33 var imageFunctions = {
34 'image-size': function (filePathNode) {
35 var size = imageSize(this, filePathNode);
36 return new expression_1.default([
37 new dimension_1.default(size.width, 'px'),
38 new dimension_1.default(size.height, 'px')
39 ]);
40 },
41 'image-width': function (filePathNode) {
42 var size = imageSize(this, filePathNode);
43 return new dimension_1.default(size.width, 'px');
44 },
45 'image-height': function (filePathNode) {
46 var size = imageSize(this, filePathNode);
47 return new dimension_1.default(size.height, 'px');
48 }
49 };
50 function_registry_1.default.addMultiple(imageFunctions);
51});
52//# sourceMappingURL=image-size.js.map
Note: See TracBrowser for help on using the repository browser.