@localnerve/sass-asset-functions 4.0.0 → 4.1.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 +9 -0
- package/cjs/index.cjs +4 -2
- package/cjs/lib/processor.cjs +12 -12
- package/index.js +1 -1
- package/lib/processor.js +3 -3
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Sass Asset Functions Change Log
|
|
2
2
|
|
|
3
|
+
## 4.1.1
|
|
4
|
+
* Package test code cleanup
|
|
5
|
+
|
|
6
|
+
## 4.1.0
|
|
7
|
+
* sass 1.63.4
|
|
8
|
+
* Fix esm loading after unexpected sass api change
|
|
9
|
+
* Add module loading package tests
|
|
10
|
+
* Dev dependencies updates
|
|
11
|
+
|
|
3
12
|
## 4.0.0
|
|
4
13
|
* Node 16+ (Drop Node 14 Support)
|
|
5
14
|
* Dev dependencies updates
|
package/cjs/index.cjs
CHANGED
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = sassFunctions;
|
|
7
|
-
var
|
|
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(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
12
|
/**
|
|
11
13
|
* Sass asset function suite.
|
|
12
14
|
*
|
|
@@ -16,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
18
|
|
|
17
19
|
function sassFunctions(options = {}) {
|
|
18
20
|
const {
|
|
19
|
-
sass =
|
|
21
|
+
sass = defaultSass
|
|
20
22
|
} = options;
|
|
21
23
|
const processor = new _processor.default(options);
|
|
22
24
|
return {
|
package/cjs/lib/processor.cjs
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
7
|
+
var _nodeFs = _interopRequireDefault(require("node:fs"));
|
|
8
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
9
|
+
var _nodeUrl = _interopRequireDefault(require("node:url"));
|
|
10
10
|
var _mime = _interopRequireDefault(require("mime"));
|
|
11
11
|
var _imageSize = _interopRequireDefault(require("image-size"));
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -56,11 +56,11 @@ class Processor {
|
|
|
56
56
|
if (typeof buster !== 'function') {
|
|
57
57
|
throw new Error('asset_cache_buster should be a function');
|
|
58
58
|
}
|
|
59
|
-
const http_path_url =
|
|
59
|
+
const http_path_url = _nodeUrl.default.parse(http_path);
|
|
60
60
|
buster(http_path, real_path, value => {
|
|
61
61
|
let new_url;
|
|
62
62
|
if (typeof value == 'object') {
|
|
63
|
-
const parsed_path =
|
|
63
|
+
const parsed_path = _nodeUrl.default.parse(value.path);
|
|
64
64
|
new_url = {
|
|
65
65
|
pathname: parsed_path.pathname,
|
|
66
66
|
search: value.query || http_path_url.search
|
|
@@ -71,7 +71,7 @@ class Processor {
|
|
|
71
71
|
search: value
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
done(
|
|
74
|
+
done(_nodeUrl.default.format(new_url));
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
asset_host(filepath, done) {
|
|
@@ -82,15 +82,15 @@ class Processor {
|
|
|
82
82
|
throw new Error('asset_host should be a function');
|
|
83
83
|
}
|
|
84
84
|
ahost(filepath, host => {
|
|
85
|
-
done(
|
|
85
|
+
done(_nodeUrl.default.resolve(host, filepath));
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
real_path(filepath, segment) {
|
|
89
89
|
const sanitized_filepath = filepath.replace(/(#|\?).+$/, '');
|
|
90
|
-
return
|
|
90
|
+
return _nodePath.default.resolve(this.paths[`${segment}_path`], sanitized_filepath);
|
|
91
91
|
}
|
|
92
92
|
http_path(filepath, segment) {
|
|
93
|
-
return
|
|
93
|
+
return _nodePath.default.join(this.paths[`http_${segment}_path`], filepath).replace(/\\/g, '/');
|
|
94
94
|
}
|
|
95
95
|
image_width(filepath, done) {
|
|
96
96
|
done((0, _imageSize.default)(this.real_path(filepath, 'images')).width);
|
|
@@ -101,7 +101,7 @@ class Processor {
|
|
|
101
101
|
inline_image(filepath, mime_type, done) {
|
|
102
102
|
const src = this.real_path(filepath, 'images');
|
|
103
103
|
mime_type = mime_type || _mime.default.getType(src);
|
|
104
|
-
|
|
104
|
+
_nodeFs.default.readFile(src, (err, data) => {
|
|
105
105
|
if (err) {
|
|
106
106
|
throw new Error(`inline_image failed to read ${src}: ${err}`);
|
|
107
107
|
}
|
|
@@ -160,11 +160,11 @@ class Processor {
|
|
|
160
160
|
for (; i < files.length; ++i) {
|
|
161
161
|
file = files[i];
|
|
162
162
|
next = files[i + 1];
|
|
163
|
-
parts =
|
|
163
|
+
parts = _nodeUrl.default.parse(file);
|
|
164
164
|
if (FONT_TYPES[next]) {
|
|
165
165
|
type = files.splice(i + 1, 1);
|
|
166
166
|
} else {
|
|
167
|
-
ext =
|
|
167
|
+
ext = _nodePath.default.extname(parts.path);
|
|
168
168
|
type = ext.substring(1);
|
|
169
169
|
}
|
|
170
170
|
type = FONT_TYPES[type];
|
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2023 Alex Grant (@localnerve), LocalNerve LLC
|
|
5
5
|
* Licensed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
-
import defaultSass from 'sass';
|
|
7
|
+
import * as defaultSass from 'sass';
|
|
8
8
|
import Processor from './lib/processor.js';
|
|
9
9
|
|
|
10
10
|
export default function sassFunctions (options = {}) {
|
package/lib/processor.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Copyright (c) 2023 Alex Grant (@localnerve), LocalNerve LLC
|
|
5
5
|
* Licensed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
-
import fs from 'fs';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import url from 'url';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import url from 'node:url';
|
|
10
10
|
import mime from 'mime';
|
|
11
11
|
import sizeOf from 'image-size';
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localnerve/sass-asset-functions",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "compass-style asset functions for dart-sass or other sass compilers",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "
|
|
13
|
+
"test-package": "node ./test-package/index.js",
|
|
14
|
+
"test": "jest && npm run test-package",
|
|
14
15
|
"lint": "eslint .",
|
|
15
16
|
"pretranspile": "rimraf ./cjs",
|
|
16
17
|
"transpile": "babel index.js -o ./cjs/index.cjs && babel ./lib/processor.js -o ./cjs/lib/processor.cjs",
|
|
@@ -49,15 +50,17 @@
|
|
|
49
50
|
"dependencies": {
|
|
50
51
|
"image-size": "^1.0.2",
|
|
51
52
|
"mime": "^3.0.0",
|
|
52
|
-
"sass": "^1.
|
|
53
|
+
"sass": "^1.63.4"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@babel/cli": "^7.21.5",
|
|
56
|
-
"@babel/preset-env": "^7.
|
|
57
|
+
"@babel/preset-env": "^7.22.4",
|
|
57
58
|
"rimraf": "^5.0.1",
|
|
58
59
|
"jest": "^29.5.0",
|
|
59
|
-
"eslint": "^8.
|
|
60
|
-
"node-sass": "^9.0.0"
|
|
60
|
+
"eslint": "^8.42.0",
|
|
61
|
+
"node-sass": "^9.0.0",
|
|
62
|
+
"tar": "^6.1.15",
|
|
63
|
+
"glob": "^10.2.7"
|
|
61
64
|
},
|
|
62
65
|
"engines": {
|
|
63
66
|
"node": ">= 16"
|