@localnerve/sass-asset-functions 4.6.2 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/cjs/index.cjs +2 -2
- package/cjs/lib/processor.cjs +25 -19
- package/lib/processor.js +18 -11
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Sass Asset Functions Change Log
|
|
2
2
|
|
|
3
|
+
## 4.7.1
|
|
4
|
+
* sass 1.69.6
|
|
5
|
+
|
|
6
|
+
## 4.7.0
|
|
7
|
+
* sass 1.69.5
|
|
8
|
+
* dependency change: mime => mime-types@2.1.35
|
|
9
|
+
* image-size@1.1.0
|
|
10
|
+
* Increase coverage, inline-image synchronous readFile to fix error reporting
|
|
11
|
+
* Development dependency updates
|
|
12
|
+
|
|
13
|
+
## 4.6.2
|
|
14
|
+
* sass 1.69.5
|
|
15
|
+
* Development dependency updates
|
|
16
|
+
|
|
17
|
+
## 4.6.1
|
|
18
|
+
* sass 1.69.4
|
|
19
|
+
* Development dependency updates
|
|
20
|
+
|
|
21
|
+
## 4.6.0
|
|
22
|
+
* sass 1.69.3
|
|
23
|
+
* Development dependency updates
|
|
24
|
+
|
|
25
|
+
## 4.5.0
|
|
26
|
+
* sass 1.68.0
|
|
27
|
+
* Development dependency updates
|
|
28
|
+
|
|
3
29
|
## 4.4.0
|
|
4
30
|
* sass 1.67.0
|
|
5
31
|
* Development dependency updates
|
package/cjs/index.cjs
CHANGED
|
@@ -7,8 +7,8 @@ exports.default = sassFunctions;
|
|
|
7
7
|
var defaultSass = _interopRequireWildcard(require("sass"));
|
|
8
8
|
var _processor = _interopRequireDefault(require("./lib/processor.cjs"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function _getRequireWildcardCache(
|
|
11
|
-
function _interopRequireWildcard(
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
12
|
/**
|
|
13
13
|
* Sass asset function suite.
|
|
14
14
|
*
|
package/cjs/lib/processor.cjs
CHANGED
|
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
7
|
+
var fs = _interopRequireWildcard(require("node:fs"));
|
|
8
|
+
var path = _interopRequireWildcard(require("node:path"));
|
|
9
|
+
var url = _interopRequireWildcard(require("node:url"));
|
|
10
|
+
var _mimeTypes = _interopRequireDefault(require("mime-types"));
|
|
11
11
|
var _imageSize = _interopRequireDefault(require("image-size"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
15
|
/**
|
|
14
16
|
* Internal processor for the asset function suite.
|
|
15
17
|
*
|
|
@@ -56,11 +58,11 @@ class Processor {
|
|
|
56
58
|
if (typeof buster !== 'function') {
|
|
57
59
|
throw new Error('asset_cache_buster should be a function');
|
|
58
60
|
}
|
|
59
|
-
const http_path_url =
|
|
61
|
+
const http_path_url = url.parse(http_path);
|
|
60
62
|
buster(http_path, real_path, value => {
|
|
61
63
|
let new_url;
|
|
62
64
|
if (typeof value == 'object') {
|
|
63
|
-
const parsed_path =
|
|
65
|
+
const parsed_path = url.parse(value.path);
|
|
64
66
|
new_url = {
|
|
65
67
|
pathname: parsed_path.pathname,
|
|
66
68
|
search: value.query || http_path_url.search
|
|
@@ -71,7 +73,7 @@ class Processor {
|
|
|
71
73
|
search: value
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
done(
|
|
76
|
+
done(url.format(new_url));
|
|
75
77
|
});
|
|
76
78
|
}
|
|
77
79
|
asset_host(filepath, done) {
|
|
@@ -82,15 +84,15 @@ class Processor {
|
|
|
82
84
|
throw new Error('asset_host should be a function');
|
|
83
85
|
}
|
|
84
86
|
ahost(filepath, host => {
|
|
85
|
-
done(
|
|
87
|
+
done(url.resolve(host, filepath));
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
real_path(filepath, segment) {
|
|
89
91
|
const sanitized_filepath = filepath.replace(/(#|\?).+$/, '');
|
|
90
|
-
return
|
|
92
|
+
return path.resolve(this.paths[`${segment}_path`], sanitized_filepath);
|
|
91
93
|
}
|
|
92
94
|
http_path(filepath, segment) {
|
|
93
|
-
return
|
|
95
|
+
return path.join(this.paths[`http_${segment}_path`], filepath).replace(/\\/g, '/');
|
|
94
96
|
}
|
|
95
97
|
image_width(filepath, done) {
|
|
96
98
|
done((0, _imageSize.default)(this.real_path(filepath, 'images')).width);
|
|
@@ -100,13 +102,17 @@ class Processor {
|
|
|
100
102
|
}
|
|
101
103
|
inline_image(filepath, mime_type, done) {
|
|
102
104
|
const src = this.real_path(filepath, 'images');
|
|
103
|
-
mime_type = mime_type ||
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
mime_type = mime_type || _mimeTypes.default.lookup(src);
|
|
106
|
+
if (!mime_type) {
|
|
107
|
+
throw new Error(`Could not find mime type for filepath '${filepath}'`);
|
|
108
|
+
}
|
|
109
|
+
let data;
|
|
110
|
+
try {
|
|
111
|
+
data = fs.readFileSync(src);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
throw new Error(`inline_image failed to read '${src}': ${err}`);
|
|
114
|
+
}
|
|
115
|
+
done(`data:${mime_type};base64,${data.toString('base64')}`);
|
|
110
116
|
}
|
|
111
117
|
asset_url(filepath, segment, done) {
|
|
112
118
|
let fragment = '';
|
|
@@ -160,11 +166,11 @@ class Processor {
|
|
|
160
166
|
for (; i < files.length; ++i) {
|
|
161
167
|
file = files[i];
|
|
162
168
|
next = files[i + 1];
|
|
163
|
-
parts =
|
|
169
|
+
parts = url.parse(file);
|
|
164
170
|
if (FONT_TYPES[next]) {
|
|
165
171
|
type = files.splice(i + 1, 1);
|
|
166
172
|
} else {
|
|
167
|
-
ext =
|
|
173
|
+
ext = path.extname(parts.path);
|
|
168
174
|
type = ext.substring(1);
|
|
169
175
|
}
|
|
170
176
|
type = FONT_TYPES[type];
|
package/lib/processor.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Copyright (c) 2023 Alex Grant (@localnerve), LocalNerve LLC
|
|
5
5
|
* Licensed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import url from 'node:url';
|
|
10
|
-
import mime from 'mime';
|
|
7
|
+
import * as fs from 'node:fs';
|
|
8
|
+
import * as path from 'node:path';
|
|
9
|
+
import * as url from 'node:url';
|
|
10
|
+
import mime from 'mime-types';
|
|
11
11
|
import sizeOf from 'image-size';
|
|
12
12
|
|
|
13
13
|
const defaultPaths = {
|
|
@@ -103,14 +103,21 @@ export default class Processor {
|
|
|
103
103
|
inline_image (filepath, mime_type, done) {
|
|
104
104
|
const src = this.real_path(filepath, 'images');
|
|
105
105
|
|
|
106
|
-
mime_type = mime_type || mime.
|
|
106
|
+
mime_type = mime_type || mime.lookup(src);
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
if (!mime_type) {
|
|
109
|
+
throw new Error(`Could not find mime type for filepath '${filepath}'`);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
let data;
|
|
113
|
+
|
|
114
|
+
try {
|
|
115
|
+
data = fs.readFileSync(src);
|
|
116
|
+
} catch (err) {
|
|
117
|
+
throw new Error(`inline_image failed to read '${src}': ${err}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
done(`data:${mime_type};base64,${data.toString('base64')}`);
|
|
114
121
|
}
|
|
115
122
|
|
|
116
123
|
asset_url (filepath, segment, done) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localnerve/sass-asset-functions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "compass-style asset functions for dart-sass or other sass compilers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"test-package": "node ./__test-package__/index.js",
|
|
14
|
-
"test": "
|
|
14
|
+
"test-unit": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
15
|
+
"test-unit:debug": "node --inspect-brk --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
16
|
+
"test": "npm run test-unit && npm run test-package",
|
|
15
17
|
"lint": "eslint .",
|
|
16
18
|
"pretranspile": "rimraf ./cjs",
|
|
17
19
|
"transpile": "babel index.js -o ./cjs/index.cjs && babel ./lib/processor.js -o ./cjs/lib/processor.cjs",
|
|
@@ -48,16 +50,16 @@
|
|
|
48
50
|
},
|
|
49
51
|
"homepage": "https://github.com/localnerve/sass-asset-functions",
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"image-size": "^1.0
|
|
52
|
-
"mime": "^
|
|
53
|
-
"sass": "^1.69.
|
|
53
|
+
"image-size": "^1.1.0",
|
|
54
|
+
"mime-types": "^2.1.35",
|
|
55
|
+
"sass": "^1.69.6"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@babel/cli": "^7.23.
|
|
57
|
-
"@babel/preset-env": "^7.23.
|
|
58
|
+
"@babel/cli": "^7.23.4",
|
|
59
|
+
"@babel/preset-env": "^7.23.6",
|
|
58
60
|
"rimraf": "^5.0.5",
|
|
59
61
|
"jest": "^29.7.0",
|
|
60
|
-
"eslint": "^8.
|
|
62
|
+
"eslint": "^8.56.0",
|
|
61
63
|
"node-sass": "^9.0.0",
|
|
62
64
|
"tar": "^6.2.0",
|
|
63
65
|
"glob": "^10.3.10"
|