less 4.5.1 → 4.6.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/README.md +70 -5
- package/bin/lessc +37 -23
- package/dist/less.js +14501 -11745
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/index.cjs +41 -0
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -55
- package/lib/less/data/colors.js +150 -153
- package/lib/less/data/index.js +4 -7
- package/lib/less/data/unit-conversions.js +2 -5
- package/lib/less/default-options.js +36 -26
- package/lib/less/deprecation.js +67 -0
- package/lib/less/environment/abstract-file-manager.js +62 -50
- package/lib/less/environment/abstract-plugin-loader.js +69 -46
- package/lib/less/environment/environment-api.ts +21 -0
- package/lib/less/environment/environment.js +34 -30
- package/lib/less/environment/file-manager-api.ts +77 -0
- package/lib/less/functions/boolean.js +13 -13
- package/lib/less/functions/color-blending.js +39 -31
- package/lib/less/functions/color.js +153 -137
- package/lib/less/functions/data-uri.js +73 -64
- package/lib/less/functions/default.js +9 -11
- package/lib/less/functions/function-caller.js +35 -34
- package/lib/less/functions/function-registry.js +16 -17
- package/lib/less/functions/index.js +33 -33
- package/lib/less/functions/list.js +88 -75
- package/lib/less/functions/math-helper.js +8 -11
- package/lib/less/functions/math.js +21 -21
- package/lib/less/functions/number.js +42 -53
- package/lib/less/functions/string.js +18 -22
- package/lib/less/functions/style.js +21 -20
- package/lib/less/functions/svg.js +83 -82
- package/lib/less/functions/types.js +28 -32
- package/lib/less/import-manager.js +73 -64
- package/lib/less/index.js +65 -65
- package/lib/less/less-error.js +63 -45
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +52 -53
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +151 -113
- package/lib/less/parser/parser.js +864 -658
- package/lib/less/plugin-manager.js +57 -46
- package/lib/less/render.js +17 -23
- package/lib/less/source-map-builder.js +52 -43
- package/lib/less/source-map-output.js +56 -43
- package/lib/less/transform-tree.js +40 -30
- package/lib/less/tree/anonymous.js +52 -28
- package/lib/less/tree/assignment.js +44 -27
- package/lib/less/tree/atrule-syntax.js +4 -6
- package/lib/less/tree/atrule.js +247 -140
- package/lib/less/tree/attribute.js +55 -24
- package/lib/less/tree/call.js +70 -42
- package/lib/less/tree/color.js +194 -145
- package/lib/less/tree/combinator.js +31 -21
- package/lib/less/tree/comment.js +44 -23
- package/lib/less/tree/condition.js +61 -36
- package/lib/less/tree/container.js +90 -34
- package/lib/less/tree/debug-info.js +28 -15
- package/lib/less/tree/declaration.js +97 -52
- package/lib/less/tree/detached-ruleset.js +42 -24
- package/lib/less/tree/dimension.js +127 -71
- package/lib/less/tree/element.js +82 -52
- package/lib/less/tree/expression.js +75 -50
- package/lib/less/tree/extend.js +71 -42
- package/lib/less/tree/import.js +184 -110
- package/lib/less/tree/index.js +52 -81
- package/lib/less/tree/javascript.js +43 -32
- package/lib/less/tree/js-eval-node.js +46 -32
- package/lib/less/tree/keyword.js +25 -17
- package/lib/less/tree/media.js +77 -35
- package/lib/less/tree/merge-rules.js +47 -0
- package/lib/less/tree/mixin-call.js +181 -98
- package/lib/less/tree/mixin-definition.js +211 -117
- package/lib/less/tree/namespace-value.js +63 -44
- package/lib/less/tree/negative.js +34 -21
- package/lib/less/tree/nested-at-rule.js +149 -66
- package/lib/less/tree/node.js +225 -90
- package/lib/less/tree/operation.js +59 -34
- package/lib/less/tree/paren.js +34 -17
- package/lib/less/tree/property.js +66 -35
- package/lib/less/tree/query-in-parens.js +52 -60
- package/lib/less/tree/quoted.js +93 -44
- package/lib/less/tree/ruleset.js +632 -318
- package/lib/less/tree/selector.js +151 -77
- package/lib/less/tree/unicode-descriptor.js +14 -12
- package/lib/less/tree/unit.js +111 -63
- package/lib/less/tree/url.js +62 -38
- package/lib/less/tree/value.js +50 -34
- package/lib/less/tree/variable-call.js +47 -30
- package/lib/less/tree/variable.js +53 -31
- package/lib/less/utils.js +44 -47
- package/lib/less/visitors/extend-visitor.js +233 -172
- package/lib/less/visitors/import-sequencer.js +24 -24
- package/lib/less/visitors/import-visitor.js +62 -52
- package/lib/less/visitors/index.js +14 -17
- package/lib/less/visitors/join-selector-visitor.js +40 -37
- package/lib/less/visitors/set-tree-visibility-visitor.js +32 -18
- package/lib/less/visitors/to-css-visitor.js +135 -128
- package/lib/less/visitors/visitor.js +60 -45
- package/lib/less-browser/add-default-options.js +23 -13
- package/lib/less-browser/bootstrap.js +23 -17
- package/lib/less-browser/browser.js +24 -21
- package/lib/less-browser/cache.js +17 -19
- package/lib/less-browser/error-reporting.js +52 -44
- package/lib/less-browser/file-manager.js +52 -42
- package/lib/less-browser/image-size.js +12 -12
- package/lib/less-browser/index.js +131 -105
- package/lib/less-browser/log-listener.js +30 -31
- package/lib/less-browser/plugin-loader.js +10 -10
- package/lib/less-browser/utils.js +19 -21
- package/lib/less-node/environment.js +32 -8
- package/lib/less-node/file-manager.js +62 -45
- package/lib/less-node/fs.js +11 -8
- package/lib/less-node/image-size.js +40 -31
- package/lib/less-node/index.js +28 -19
- package/lib/less-node/lessc-helper.js +20 -21
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +29 -18
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -403
- package/bower.json +0 -22
- package/lib/less/constants.js.map +0 -1
- package/lib/less/contexts.js.map +0 -1
- package/lib/less/data/colors.js.map +0 -1
- package/lib/less/data/index.js.map +0 -1
- package/lib/less/data/unit-conversions.js.map +0 -1
- package/lib/less/default-options.js.map +0 -1
- package/lib/less/environment/abstract-file-manager.js.map +0 -1
- package/lib/less/environment/abstract-plugin-loader.js.map +0 -1
- package/lib/less/environment/environment-api.js +0 -3
- package/lib/less/environment/environment-api.js.map +0 -1
- package/lib/less/environment/environment.js.map +0 -1
- package/lib/less/environment/file-manager-api.js +0 -3
- package/lib/less/environment/file-manager-api.js.map +0 -1
- package/lib/less/functions/boolean.js.map +0 -1
- package/lib/less/functions/color-blending.js.map +0 -1
- package/lib/less/functions/color.js.map +0 -1
- package/lib/less/functions/data-uri.js.map +0 -1
- package/lib/less/functions/default.js.map +0 -1
- package/lib/less/functions/function-caller.js.map +0 -1
- package/lib/less/functions/function-registry.js.map +0 -1
- package/lib/less/functions/index.js.map +0 -1
- package/lib/less/functions/list.js.map +0 -1
- package/lib/less/functions/math-helper.js.map +0 -1
- package/lib/less/functions/math.js.map +0 -1
- package/lib/less/functions/number.js.map +0 -1
- package/lib/less/functions/string.js.map +0 -1
- package/lib/less/functions/style.js.map +0 -1
- package/lib/less/functions/svg.js.map +0 -1
- package/lib/less/functions/types.js.map +0 -1
- package/lib/less/import-manager.js.map +0 -1
- package/lib/less/index.js.map +0 -1
- package/lib/less/less-error.js.map +0 -1
- package/lib/less/logger.js.map +0 -1
- package/lib/less/parse-tree.js.map +0 -1
- package/lib/less/parse.js.map +0 -1
- package/lib/less/parser/parser-input.js.map +0 -1
- package/lib/less/parser/parser.js.map +0 -1
- package/lib/less/plugin-manager.js.map +0 -1
- package/lib/less/render.js.map +0 -1
- package/lib/less/source-map-builder.js.map +0 -1
- package/lib/less/source-map-output.js.map +0 -1
- package/lib/less/transform-tree.js.map +0 -1
- package/lib/less/tree/anonymous.js.map +0 -1
- package/lib/less/tree/assignment.js.map +0 -1
- package/lib/less/tree/atrule-syntax.js.map +0 -1
- package/lib/less/tree/atrule.js.map +0 -1
- package/lib/less/tree/attribute.js.map +0 -1
- package/lib/less/tree/call.js.map +0 -1
- package/lib/less/tree/color.js.map +0 -1
- package/lib/less/tree/combinator.js.map +0 -1
- package/lib/less/tree/comment.js.map +0 -1
- package/lib/less/tree/condition.js.map +0 -1
- package/lib/less/tree/container.js.map +0 -1
- package/lib/less/tree/debug-info.js.map +0 -1
- package/lib/less/tree/declaration.js.map +0 -1
- package/lib/less/tree/detached-ruleset.js.map +0 -1
- package/lib/less/tree/dimension.js.map +0 -1
- package/lib/less/tree/element.js.map +0 -1
- package/lib/less/tree/expression.js.map +0 -1
- package/lib/less/tree/extend.js.map +0 -1
- package/lib/less/tree/import.js.map +0 -1
- package/lib/less/tree/index.js.map +0 -1
- package/lib/less/tree/javascript.js.map +0 -1
- package/lib/less/tree/js-eval-node.js.map +0 -1
- package/lib/less/tree/keyword.js.map +0 -1
- package/lib/less/tree/media.js.map +0 -1
- package/lib/less/tree/mixin-call.js.map +0 -1
- package/lib/less/tree/mixin-definition.js.map +0 -1
- package/lib/less/tree/namespace-value.js.map +0 -1
- package/lib/less/tree/negative.js.map +0 -1
- package/lib/less/tree/nested-at-rule.js.map +0 -1
- package/lib/less/tree/node.js.map +0 -1
- package/lib/less/tree/operation.js.map +0 -1
- package/lib/less/tree/paren.js.map +0 -1
- package/lib/less/tree/property.js.map +0 -1
- package/lib/less/tree/query-in-parens.js.map +0 -1
- package/lib/less/tree/quoted.js.map +0 -1
- package/lib/less/tree/ruleset.js.map +0 -1
- package/lib/less/tree/selector.js.map +0 -1
- package/lib/less/tree/unicode-descriptor.js.map +0 -1
- package/lib/less/tree/unit.js.map +0 -1
- package/lib/less/tree/url.js.map +0 -1
- package/lib/less/tree/value.js.map +0 -1
- package/lib/less/tree/variable-call.js.map +0 -1
- package/lib/less/tree/variable.js.map +0 -1
- package/lib/less/utils.js.map +0 -1
- package/lib/less/visitors/extend-visitor.js.map +0 -1
- package/lib/less/visitors/import-sequencer.js.map +0 -1
- package/lib/less/visitors/import-visitor.js.map +0 -1
- package/lib/less/visitors/index.js.map +0 -1
- package/lib/less/visitors/join-selector-visitor.js.map +0 -1
- package/lib/less/visitors/set-tree-visibility-visitor.js.map +0 -1
- package/lib/less/visitors/to-css-visitor.js.map +0 -1
- package/lib/less/visitors/visitor.js.map +0 -1
- package/lib/less-browser/add-default-options.js.map +0 -1
- package/lib/less-browser/bootstrap.js.map +0 -1
- package/lib/less-browser/browser.js.map +0 -1
- package/lib/less-browser/cache.js.map +0 -1
- package/lib/less-browser/error-reporting.js.map +0 -1
- package/lib/less-browser/file-manager.js.map +0 -1
- package/lib/less-browser/image-size.js.map +0 -1
- package/lib/less-browser/index.js.map +0 -1
- package/lib/less-browser/log-listener.js.map +0 -1
- package/lib/less-browser/plugin-loader.js.map +0 -1
- package/lib/less-browser/utils.js.map +0 -1
- package/lib/less-node/environment.js.map +0 -1
- package/lib/less-node/file-manager.js.map +0 -1
- package/lib/less-node/fs.js.map +0 -1
- package/lib/less-node/image-size.js.map +0 -1
- package/lib/less-node/index.js.map +0 -1
- package/lib/less-node/lessc-helper.js.map +0 -1
- package/lib/less-node/plugin-loader.js.map +0 -1
- package/lib/less-node/url-file-manager.js.map +0 -1
- package/scripts/coverage-lines.js +0 -207
- package/scripts/coverage-report.js +0 -158
- package/scripts/postinstall.js +0 -61
- package/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -251
- package/test/browser/css/global-vars/simple.css +0 -3
- package/test/browser/css/modify-vars/simple.css +0 -8
- package/test/browser/css/plugin/plugin.css +0 -3
- package/test/browser/css/postProcessor/postProcessor.css +0 -4
- package/test/browser/css/relative-urls/urls.css +0 -36
- package/test/browser/css/rewrite-urls/urls.css +0 -36
- package/test/browser/css/rootpath/urls.css +0 -35
- package/test/browser/css/rootpath-relative/urls.css +0 -35
- package/test/browser/css/rootpath-rewrite-urls/urls.css +0 -35
- package/test/browser/css/urls.css +0 -54
- package/test/browser/generator/benchmark.config.js +0 -50
- package/test/browser/generator/generate.js +0 -78
- package/test/browser/generator/runner.config.js +0 -184
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -104
- package/test/browser/generator/utils.js +0 -14
- package/test/browser/less/console-errors/test-error.less +0 -3
- package/test/browser/less/console-errors/test-error.txt +0 -2
- package/test/browser/less/errors/image-height-error.less +0 -3
- package/test/browser/less/errors/image-height-error.txt +0 -4
- package/test/browser/less/errors/image-size-error.less +0 -3
- package/test/browser/less/errors/image-size-error.txt +0 -4
- package/test/browser/less/errors/image-width-error.less +0 -3
- package/test/browser/less/errors/image-width-error.txt +0 -4
- package/test/browser/less/global-vars/simple.less +0 -3
- package/test/browser/less/imports/urls.less +0 -4
- package/test/browser/less/imports/urls2.less +0 -4
- package/test/browser/less/modify-vars/imports/simple2.less +0 -4
- package/test/browser/less/modify-vars/simple.less +0 -8
- package/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +0 -5
- package/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +0 -15
- package/test/browser/less/plugin/plugin.js +0 -4
- package/test/browser/less/plugin/plugin.less +0 -4
- package/test/browser/less/postProcessor/postProcessor.less +0 -4
- package/test/browser/less/relative-urls/urls.less +0 -34
- package/test/browser/less/rewrite-urls/urls.less +0 -34
- package/test/browser/less/rootpath/urls.less +0 -33
- package/test/browser/less/rootpath-relative/urls.less +0 -33
- package/test/browser/less/rootpath-rewrite-urls/urls.less +0 -33
- package/test/browser/less/urls.less +0 -62
- package/test/browser/runner-VisitorPlugin-options.js +0 -3
- package/test/browser/runner-VisitorPlugin.js +0 -3
- package/test/browser/runner-browser-options.js +0 -51
- package/test/browser/runner-browser-spec.js +0 -12
- package/test/browser/runner-console-errors.js +0 -5
- package/test/browser/runner-errors-options.js +0 -6
- package/test/browser/runner-errors-spec.js +0 -3
- package/test/browser/runner-filemanagerPlugin-options.js +0 -5
- package/test/browser/runner-filemanagerPlugin.js +0 -3
- package/test/browser/runner-global-vars-options.js +0 -7
- package/test/browser/runner-global-vars-spec.js +0 -3
- package/test/browser/runner-main-options.js +0 -17
- package/test/browser/runner-main-spec.js +0 -7
- package/test/browser/runner-modify-vars-options.js +0 -5
- package/test/browser/runner-modify-vars-spec.js +0 -33
- package/test/browser/runner-no-js-errors-options.js +0 -4
- package/test/browser/runner-no-js-errors-spec.js +0 -3
- package/test/browser/runner-postProcessorPlugin-options.js +0 -3
- package/test/browser/runner-postProcessorPlugin.js +0 -3
- package/test/browser/runner-preProcessorPlugin-options.js +0 -3
- package/test/browser/runner-preProcessorPlugin.js +0 -3
- package/test/browser/runner-production-options.js +0 -3
- package/test/browser/runner-production-spec.js +0 -5
- package/test/browser/runner-relative-urls-options.js +0 -3
- package/test/browser/runner-relative-urls-spec.js +0 -3
- package/test/browser/runner-rewrite-urls-options.js +0 -3
- package/test/browser/runner-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-options.js +0 -3
- package/test/browser/runner-rootpath-relative-options.js +0 -4
- package/test/browser/runner-rootpath-relative-spec.js +0 -3
- package/test/browser/runner-rootpath-rewrite-urls-options.js +0 -4
- package/test/browser/runner-rootpath-rewrite-urls-spec.js +0 -3
- package/test/browser/runner-rootpath-spec.js +0 -3
- package/test/browser/runner-strict-units-options.js +0 -5
- package/test/browser/runner-strict-units-spec.js +0 -3
- package/test/index.js +0 -307
- package/test/less-test.js +0 -984
- package/test/mocha-playwright/runner.js +0 -210
- package/test/modify-vars.js +0 -28
- package/test/plugins/filemanager/index.js +0 -19
- package/test/plugins/postprocess/index.js +0 -14
- package/test/plugins/preprocess/index.js +0 -19
- package/test/plugins/visitor/index.js +0 -24
- package/test/sourcemaps/basic.json +0 -1
- package/test/sourcemaps/comprehensive.json +0 -1
- package/test/sourcemaps/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- package/test/sourcemaps/sourcemaps-basepath.json +0 -1
- package/test/sourcemaps/sourcemaps-include-source.json +0 -1
- package/test/sourcemaps/sourcemaps-rootpath.json +0 -1
- package/test/sourcemaps/sourcemaps-url.json +0 -1
- package/test/sourcemaps-disable-annotation/basic.json +0 -1
- package/test/sourcemaps-variable-selector/basic.json +0 -1
- package/test/test-es6.ts +0 -17
- package/test.less +0 -1
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var operation_1 = tslib_1.__importDefault(require("../tree/operation"));
|
|
10
|
-
var colorFunctions;
|
|
1
|
+
import Dimension from '../tree/dimension.js';
|
|
2
|
+
import Color from '../tree/color.js';
|
|
3
|
+
import Quoted from '../tree/quoted.js';
|
|
4
|
+
import Anonymous from '../tree/anonymous.js';
|
|
5
|
+
import Expression from '../tree/expression.js';
|
|
6
|
+
import Operation from '../tree/operation.js';
|
|
7
|
+
let colorFunctions;
|
|
8
|
+
|
|
11
9
|
function clamp(val) {
|
|
12
10
|
return Math.min(1, Math.max(0, val));
|
|
13
11
|
}
|
|
14
12
|
function hsla(origColor, hsl) {
|
|
15
|
-
|
|
13
|
+
const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
|
|
16
14
|
if (color) {
|
|
17
|
-
if (origColor.value &&
|
|
15
|
+
if (origColor.value &&
|
|
18
16
|
/^(rgb|hsl)/.test(origColor.value)) {
|
|
19
17
|
color.value = origColor.value;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
18
|
+
} else {
|
|
22
19
|
color.value = 'rgb';
|
|
23
20
|
}
|
|
24
21
|
return color;
|
|
@@ -27,27 +24,25 @@ function hsla(origColor, hsl) {
|
|
|
27
24
|
function toHSL(color) {
|
|
28
25
|
if (color.toHSL) {
|
|
29
26
|
return color.toHSL();
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
27
|
+
} else {
|
|
32
28
|
throw new Error('Argument cannot be evaluated to a color');
|
|
33
29
|
}
|
|
34
30
|
}
|
|
31
|
+
|
|
35
32
|
function toHSV(color) {
|
|
36
33
|
if (color.toHSV) {
|
|
37
34
|
return color.toHSV();
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
35
|
+
} else {
|
|
40
36
|
throw new Error('Argument cannot be evaluated to a color');
|
|
41
37
|
}
|
|
42
38
|
}
|
|
39
|
+
|
|
43
40
|
function number(n) {
|
|
44
|
-
if (n instanceof
|
|
41
|
+
if (n instanceof Dimension) {
|
|
45
42
|
return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
|
|
46
|
-
}
|
|
47
|
-
else if (typeof n === 'number') {
|
|
43
|
+
} else if (typeof n === 'number') {
|
|
48
44
|
return n;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
45
|
+
} else {
|
|
51
46
|
throw {
|
|
52
47
|
type: 'Argument',
|
|
53
48
|
message: 'color functions take numbers as parameters'
|
|
@@ -55,36 +50,35 @@ function number(n) {
|
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
52
|
function scaled(n, size) {
|
|
58
|
-
if (n instanceof
|
|
53
|
+
if (n instanceof Dimension && n.unit.is('%')) {
|
|
59
54
|
return parseFloat(n.value * size / 100);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
55
|
+
} else {
|
|
62
56
|
return number(n);
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
colorFunctions = {
|
|
66
60
|
rgb: function (r, g, b) {
|
|
67
|
-
|
|
61
|
+
let a = 1
|
|
68
62
|
/**
|
|
69
63
|
* Comma-less syntax
|
|
70
64
|
* e.g. rgb(0 128 255 / 50%)
|
|
71
65
|
*/
|
|
72
|
-
if (r instanceof
|
|
73
|
-
|
|
74
|
-
r = val[0]
|
|
75
|
-
g = val[1]
|
|
76
|
-
b = val[2]
|
|
77
|
-
/**
|
|
66
|
+
if (r instanceof Expression) {
|
|
67
|
+
const val = r.value
|
|
68
|
+
r = val[0]
|
|
69
|
+
g = val[1]
|
|
70
|
+
b = val[2]
|
|
71
|
+
/**
|
|
78
72
|
* @todo - should this be normalized in
|
|
79
73
|
* function caller? Or parsed differently?
|
|
80
74
|
*/
|
|
81
|
-
if (b instanceof
|
|
82
|
-
|
|
83
|
-
b = op.operands[0]
|
|
84
|
-
a = op.operands[1]
|
|
75
|
+
if (b instanceof Operation) {
|
|
76
|
+
const op = b
|
|
77
|
+
b = op.operands[0]
|
|
78
|
+
a = op.operands[1]
|
|
85
79
|
}
|
|
86
80
|
}
|
|
87
|
-
|
|
81
|
+
const color = colorFunctions.rgba(r, g, b, a);
|
|
88
82
|
if (color) {
|
|
89
83
|
color.value = 'rgb';
|
|
90
84
|
return color;
|
|
@@ -92,43 +86,44 @@ colorFunctions = {
|
|
|
92
86
|
},
|
|
93
87
|
rgba: function (r, g, b, a) {
|
|
94
88
|
try {
|
|
95
|
-
if (r instanceof
|
|
89
|
+
if (r instanceof Color) {
|
|
96
90
|
if (g) {
|
|
97
91
|
a = number(g);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
92
|
+
} else {
|
|
100
93
|
a = r.alpha;
|
|
101
94
|
}
|
|
102
|
-
return new
|
|
95
|
+
return new Color(r.rgb, a, 'rgba');
|
|
103
96
|
}
|
|
104
|
-
|
|
97
|
+
const rgb = [r, g, b].map(c => scaled(c, 255));
|
|
105
98
|
a = number(a);
|
|
106
|
-
return new
|
|
99
|
+
return new Color(rgb, a, 'rgba');
|
|
107
100
|
}
|
|
108
|
-
catch (e) {
|
|
101
|
+
catch (e) {}
|
|
109
102
|
},
|
|
110
103
|
hsl: function (h, s, l) {
|
|
111
|
-
|
|
112
|
-
if (h instanceof
|
|
113
|
-
|
|
114
|
-
h = val[0]
|
|
115
|
-
s = val[1]
|
|
116
|
-
l = val[2]
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
104
|
+
let a = 1
|
|
105
|
+
if (h instanceof Expression) {
|
|
106
|
+
const val = h.value
|
|
107
|
+
h = val[0]
|
|
108
|
+
s = val[1]
|
|
109
|
+
l = val[2]
|
|
110
|
+
|
|
111
|
+
if (l instanceof Operation) {
|
|
112
|
+
const op = l
|
|
113
|
+
l = op.operands[0]
|
|
114
|
+
a = op.operands[1]
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
|
-
|
|
117
|
+
const color = colorFunctions.hsla(h, s, l, a);
|
|
124
118
|
if (color) {
|
|
125
119
|
color.value = 'hsl';
|
|
126
120
|
return color;
|
|
127
121
|
}
|
|
128
122
|
},
|
|
129
123
|
hsla: function (h, s, l, a) {
|
|
130
|
-
|
|
131
|
-
|
|
124
|
+
let m1;
|
|
125
|
+
let m2;
|
|
126
|
+
|
|
132
127
|
function hue(h) {
|
|
133
128
|
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
|
134
129
|
if (h * 6 < 1) {
|
|
@@ -144,94 +139,104 @@ colorFunctions = {
|
|
|
144
139
|
return m1;
|
|
145
140
|
}
|
|
146
141
|
}
|
|
142
|
+
|
|
147
143
|
try {
|
|
148
|
-
if (h instanceof
|
|
144
|
+
if (h instanceof Color) {
|
|
149
145
|
if (s) {
|
|
150
146
|
a = number(s);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
147
|
+
} else {
|
|
153
148
|
a = h.alpha;
|
|
154
149
|
}
|
|
155
|
-
return new
|
|
150
|
+
return new Color(h.rgb, a, 'hsla');
|
|
156
151
|
}
|
|
152
|
+
|
|
157
153
|
h = (number(h) % 360) / 360;
|
|
158
|
-
s = clamp(number(s));
|
|
159
|
-
|
|
160
|
-
a = clamp(number(a));
|
|
154
|
+
s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));
|
|
155
|
+
|
|
161
156
|
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
|
162
157
|
m1 = l * 2 - m2;
|
|
163
|
-
|
|
158
|
+
|
|
159
|
+
const rgb = [
|
|
164
160
|
hue(h + 1 / 3) * 255,
|
|
165
|
-
hue(h)
|
|
161
|
+
hue(h) * 255,
|
|
166
162
|
hue(h - 1 / 3) * 255
|
|
167
163
|
];
|
|
168
164
|
a = number(a);
|
|
169
|
-
return new
|
|
165
|
+
return new Color(rgb, a, 'hsla');
|
|
170
166
|
}
|
|
171
|
-
catch (e) {
|
|
167
|
+
catch (e) {}
|
|
172
168
|
},
|
|
173
|
-
|
|
169
|
+
|
|
170
|
+
hsv: function(h, s, v) {
|
|
174
171
|
return colorFunctions.hsva(h, s, v, 1.0);
|
|
175
172
|
},
|
|
176
|
-
|
|
173
|
+
|
|
174
|
+
hsva: function(h, s, v, a) {
|
|
177
175
|
h = ((number(h) % 360) / 360) * 360;
|
|
178
|
-
s = number(s);
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
var f;
|
|
176
|
+
s = number(s);v = number(v);a = number(a);
|
|
177
|
+
|
|
178
|
+
let i;
|
|
179
|
+
let f;
|
|
183
180
|
i = Math.floor((h / 60) % 6);
|
|
184
181
|
f = (h / 60) - i;
|
|
185
|
-
|
|
182
|
+
|
|
183
|
+
const vs = [v,
|
|
186
184
|
v * (1 - s),
|
|
187
185
|
v * (1 - f * s),
|
|
188
186
|
v * (1 - (1 - f) * s)];
|
|
189
|
-
|
|
187
|
+
const perm = [[0, 3, 1],
|
|
190
188
|
[2, 0, 1],
|
|
191
189
|
[1, 0, 3],
|
|
192
190
|
[1, 2, 0],
|
|
193
191
|
[3, 1, 0],
|
|
194
192
|
[0, 1, 2]];
|
|
195
|
-
|
|
193
|
+
|
|
194
|
+
return colorFunctions.rgba(vs[perm[i][0]] * 255,
|
|
195
|
+
vs[perm[i][1]] * 255,
|
|
196
|
+
vs[perm[i][2]] * 255,
|
|
197
|
+
a);
|
|
196
198
|
},
|
|
199
|
+
|
|
197
200
|
hue: function (color) {
|
|
198
|
-
return new
|
|
201
|
+
return new Dimension(toHSL(color).h);
|
|
199
202
|
},
|
|
200
203
|
saturation: function (color) {
|
|
201
|
-
return new
|
|
204
|
+
return new Dimension(toHSL(color).s * 100, '%');
|
|
202
205
|
},
|
|
203
206
|
lightness: function (color) {
|
|
204
|
-
return new
|
|
207
|
+
return new Dimension(toHSL(color).l * 100, '%');
|
|
205
208
|
},
|
|
206
|
-
hsvhue: function
|
|
207
|
-
return new
|
|
209
|
+
hsvhue: function(color) {
|
|
210
|
+
return new Dimension(toHSV(color).h);
|
|
208
211
|
},
|
|
209
212
|
hsvsaturation: function (color) {
|
|
210
|
-
return new
|
|
213
|
+
return new Dimension(toHSV(color).s * 100, '%');
|
|
211
214
|
},
|
|
212
215
|
hsvvalue: function (color) {
|
|
213
|
-
return new
|
|
216
|
+
return new Dimension(toHSV(color).v * 100, '%');
|
|
214
217
|
},
|
|
215
218
|
red: function (color) {
|
|
216
|
-
return new
|
|
219
|
+
return new Dimension(color.rgb[0]);
|
|
217
220
|
},
|
|
218
221
|
green: function (color) {
|
|
219
|
-
return new
|
|
222
|
+
return new Dimension(color.rgb[1]);
|
|
220
223
|
},
|
|
221
224
|
blue: function (color) {
|
|
222
|
-
return new
|
|
225
|
+
return new Dimension(color.rgb[2]);
|
|
223
226
|
},
|
|
224
227
|
alpha: function (color) {
|
|
225
|
-
return new
|
|
228
|
+
return new Dimension(toHSL(color).a);
|
|
226
229
|
},
|
|
227
230
|
luma: function (color) {
|
|
228
|
-
return new
|
|
231
|
+
return new Dimension(color.luma() * color.alpha * 100, '%');
|
|
229
232
|
},
|
|
230
233
|
luminance: function (color) {
|
|
231
|
-
|
|
232
|
-
(0.
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
const luminance =
|
|
235
|
+
(0.2126 * color.rgb[0] / 255) +
|
|
236
|
+
(0.7152 * color.rgb[1] / 255) +
|
|
237
|
+
(0.0722 * color.rgb[2] / 255);
|
|
238
|
+
|
|
239
|
+
return new Dimension(luminance * color.alpha * 100, '%');
|
|
235
240
|
},
|
|
236
241
|
saturate: function (color, amount, method) {
|
|
237
242
|
// filter: saturate(3.2);
|
|
@@ -239,9 +244,10 @@ colorFunctions = {
|
|
|
239
244
|
if (!color.rgb) {
|
|
240
245
|
return null;
|
|
241
246
|
}
|
|
242
|
-
|
|
247
|
+
const hsl = toHSL(color);
|
|
248
|
+
|
|
243
249
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
244
|
-
hsl.s +=
|
|
250
|
+
hsl.s += hsl.s * amount.value / 100;
|
|
245
251
|
}
|
|
246
252
|
else {
|
|
247
253
|
hsl.s += amount.value / 100;
|
|
@@ -250,9 +256,10 @@ colorFunctions = {
|
|
|
250
256
|
return hsla(color, hsl);
|
|
251
257
|
},
|
|
252
258
|
desaturate: function (color, amount, method) {
|
|
253
|
-
|
|
259
|
+
const hsl = toHSL(color);
|
|
260
|
+
|
|
254
261
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
255
|
-
hsl.s -=
|
|
262
|
+
hsl.s -= hsl.s * amount.value / 100;
|
|
256
263
|
}
|
|
257
264
|
else {
|
|
258
265
|
hsl.s -= amount.value / 100;
|
|
@@ -261,9 +268,10 @@ colorFunctions = {
|
|
|
261
268
|
return hsla(color, hsl);
|
|
262
269
|
},
|
|
263
270
|
lighten: function (color, amount, method) {
|
|
264
|
-
|
|
271
|
+
const hsl = toHSL(color);
|
|
272
|
+
|
|
265
273
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
266
|
-
hsl.l +=
|
|
274
|
+
hsl.l += hsl.l * amount.value / 100;
|
|
267
275
|
}
|
|
268
276
|
else {
|
|
269
277
|
hsl.l += amount.value / 100;
|
|
@@ -272,9 +280,10 @@ colorFunctions = {
|
|
|
272
280
|
return hsla(color, hsl);
|
|
273
281
|
},
|
|
274
282
|
darken: function (color, amount, method) {
|
|
275
|
-
|
|
283
|
+
const hsl = toHSL(color);
|
|
284
|
+
|
|
276
285
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
277
|
-
hsl.l -=
|
|
286
|
+
hsl.l -= hsl.l * amount.value / 100;
|
|
278
287
|
}
|
|
279
288
|
else {
|
|
280
289
|
hsl.l -= amount.value / 100;
|
|
@@ -283,9 +292,10 @@ colorFunctions = {
|
|
|
283
292
|
return hsla(color, hsl);
|
|
284
293
|
},
|
|
285
294
|
fadein: function (color, amount, method) {
|
|
286
|
-
|
|
295
|
+
const hsl = toHSL(color);
|
|
296
|
+
|
|
287
297
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
288
|
-
hsl.a +=
|
|
298
|
+
hsl.a += hsl.a * amount.value / 100;
|
|
289
299
|
}
|
|
290
300
|
else {
|
|
291
301
|
hsl.a += amount.value / 100;
|
|
@@ -294,9 +304,10 @@ colorFunctions = {
|
|
|
294
304
|
return hsla(color, hsl);
|
|
295
305
|
},
|
|
296
306
|
fadeout: function (color, amount, method) {
|
|
297
|
-
|
|
307
|
+
const hsl = toHSL(color);
|
|
308
|
+
|
|
298
309
|
if (typeof method !== 'undefined' && method.value === 'relative') {
|
|
299
|
-
hsl.a -=
|
|
310
|
+
hsl.a -= hsl.a * amount.value / 100;
|
|
300
311
|
}
|
|
301
312
|
else {
|
|
302
313
|
hsl.a -= amount.value / 100;
|
|
@@ -305,15 +316,18 @@ colorFunctions = {
|
|
|
305
316
|
return hsla(color, hsl);
|
|
306
317
|
},
|
|
307
318
|
fade: function (color, amount) {
|
|
308
|
-
|
|
319
|
+
const hsl = toHSL(color);
|
|
320
|
+
|
|
309
321
|
hsl.a = amount.value / 100;
|
|
310
322
|
hsl.a = clamp(hsl.a);
|
|
311
323
|
return hsla(color, hsl);
|
|
312
324
|
},
|
|
313
325
|
spin: function (color, amount) {
|
|
314
|
-
|
|
315
|
-
|
|
326
|
+
const hsl = toHSL(color);
|
|
327
|
+
const hue = (hsl.h + amount.value) % 360;
|
|
328
|
+
|
|
316
329
|
hsl.h = hue < 0 ? 360 + hue : hue;
|
|
330
|
+
|
|
317
331
|
return hsla(color, hsl);
|
|
318
332
|
},
|
|
319
333
|
//
|
|
@@ -322,21 +336,25 @@ colorFunctions = {
|
|
|
322
336
|
//
|
|
323
337
|
mix: function (color1, color2, weight) {
|
|
324
338
|
if (!weight) {
|
|
325
|
-
weight = new
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
339
|
+
weight = new Dimension(50);
|
|
340
|
+
}
|
|
341
|
+
const p = weight.value / 100.0;
|
|
342
|
+
const w = p * 2 - 1;
|
|
343
|
+
const a = toHSL(color1).a - toHSL(color2).a;
|
|
344
|
+
|
|
345
|
+
const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
|
|
346
|
+
const w2 = 1 - w1;
|
|
347
|
+
|
|
348
|
+
const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
|
|
333
349
|
color1.rgb[1] * w1 + color2.rgb[1] * w2,
|
|
334
350
|
color1.rgb[2] * w1 + color2.rgb[2] * w2];
|
|
335
|
-
|
|
336
|
-
|
|
351
|
+
|
|
352
|
+
const alpha = color1.alpha * p + color2.alpha * (1 - p);
|
|
353
|
+
|
|
354
|
+
return new Color(rgb, alpha);
|
|
337
355
|
},
|
|
338
356
|
greyscale: function (color) {
|
|
339
|
-
return colorFunctions.desaturate(color, new
|
|
357
|
+
return colorFunctions.desaturate(color, new Dimension(100));
|
|
340
358
|
},
|
|
341
359
|
contrast: function (color, dark, light, threshold) {
|
|
342
360
|
// filter: contrast(3.2);
|
|
@@ -352,20 +370,18 @@ colorFunctions = {
|
|
|
352
370
|
}
|
|
353
371
|
// Figure out which is actually light and dark:
|
|
354
372
|
if (dark.luma() > light.luma()) {
|
|
355
|
-
|
|
373
|
+
const t = light;
|
|
356
374
|
light = dark;
|
|
357
375
|
dark = t;
|
|
358
376
|
}
|
|
359
377
|
if (typeof threshold === 'undefined') {
|
|
360
378
|
threshold = 0.43;
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
379
|
+
} else {
|
|
363
380
|
threshold = number(threshold);
|
|
364
381
|
}
|
|
365
382
|
if (color.luma() < threshold) {
|
|
366
383
|
return light;
|
|
367
|
-
}
|
|
368
|
-
else {
|
|
384
|
+
} else {
|
|
369
385
|
return dark;
|
|
370
386
|
}
|
|
371
387
|
},
|
|
@@ -408,29 +424,29 @@ colorFunctions = {
|
|
|
408
424
|
// }
|
|
409
425
|
// },
|
|
410
426
|
argb: function (color) {
|
|
411
|
-
return new
|
|
427
|
+
return new Anonymous(color.toARGB());
|
|
412
428
|
},
|
|
413
|
-
color: function
|
|
414
|
-
if ((c instanceof
|
|
429
|
+
color: function(c) {
|
|
430
|
+
if ((c instanceof Quoted) &&
|
|
415
431
|
(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {
|
|
416
|
-
|
|
417
|
-
return new
|
|
432
|
+
const val = c.value.slice(1);
|
|
433
|
+
return new Color(val, undefined, `#${val}`);
|
|
418
434
|
}
|
|
419
|
-
if ((c instanceof
|
|
435
|
+
if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
|
|
420
436
|
c.value = undefined;
|
|
421
437
|
return c;
|
|
422
438
|
}
|
|
423
439
|
throw {
|
|
424
|
-
type:
|
|
440
|
+
type: 'Argument',
|
|
425
441
|
message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'
|
|
426
442
|
};
|
|
427
443
|
},
|
|
428
|
-
tint: function
|
|
444
|
+
tint: function(color, amount) {
|
|
429
445
|
return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);
|
|
430
446
|
},
|
|
431
|
-
shade: function
|
|
447
|
+
shade: function(color, amount) {
|
|
432
448
|
return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);
|
|
433
449
|
}
|
|
434
450
|
};
|
|
435
|
-
|
|
436
|
-
|
|
451
|
+
|
|
452
|
+
export default colorFunctions;
|
|
@@ -1,65 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return { 'data-uri': function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import Quoted from '../tree/quoted.js';
|
|
2
|
+
import URL from '../tree/url.js';
|
|
3
|
+
import * as utils from '../utils.js';
|
|
4
|
+
import logger from '../logger.js';
|
|
5
|
+
|
|
6
|
+
export default environment => {
|
|
7
|
+
|
|
8
|
+
const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context);
|
|
9
|
+
|
|
10
|
+
return { 'data-uri': function(mimetypeNode, filePathNode) {
|
|
11
|
+
|
|
12
|
+
if (!filePathNode) {
|
|
13
|
+
filePathNode = mimetypeNode;
|
|
14
|
+
mimetypeNode = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let mimetype = mimetypeNode && mimetypeNode.value;
|
|
18
|
+
let filePath = filePathNode.value;
|
|
19
|
+
const currentFileInfo = this.currentFileInfo;
|
|
20
|
+
const currentDirectory = currentFileInfo.rewriteUrls ?
|
|
21
|
+
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
|
|
22
|
+
|
|
23
|
+
const fragmentStart = filePath.indexOf('#');
|
|
24
|
+
let fragment = '';
|
|
25
|
+
if (fragmentStart !== -1) {
|
|
26
|
+
fragment = filePath.slice(fragmentStart);
|
|
27
|
+
filePath = filePath.slice(0, fragmentStart);
|
|
28
|
+
}
|
|
29
|
+
const context = utils.clone(this.context);
|
|
30
|
+
context.rawBuffer = true;
|
|
31
|
+
|
|
32
|
+
const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);
|
|
33
|
+
|
|
34
|
+
if (!fileManager) {
|
|
35
|
+
return fallback(this, filePathNode);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let useBase64 = false;
|
|
39
|
+
|
|
40
|
+
// detect the mimetype if not given
|
|
41
|
+
if (!mimetypeNode) {
|
|
42
|
+
|
|
43
|
+
mimetype = environment.mimeLookup(filePath);
|
|
44
|
+
|
|
45
|
+
if (mimetype === 'image/svg+xml') {
|
|
46
|
+
useBase64 = false;
|
|
47
|
+
} else {
|
|
48
|
+
// use base 64 unless it's an ASCII or UTF-8 format
|
|
49
|
+
const charset = environment.charsetLookup(mimetype);
|
|
50
|
+
useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
|
|
14
51
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
// use base 64 unless it's an ASCII or UTF-8 format
|
|
41
|
-
var charset = environment.charsetLookup(mimetype);
|
|
42
|
-
useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
|
|
43
|
-
}
|
|
44
|
-
if (useBase64) {
|
|
45
|
-
mimetype += ';base64';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
useBase64 = /;base64$/.test(mimetype);
|
|
50
|
-
}
|
|
51
|
-
var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
|
|
52
|
-
if (!fileSync.contents) {
|
|
53
|
-
logger_1.default.warn("Skipped data-uri embedding of ".concat(filePath, " because file not found"));
|
|
54
|
-
return fallback(this, filePathNode || mimetypeNode);
|
|
55
|
-
}
|
|
56
|
-
var buf = fileSync.contents;
|
|
57
|
-
if (useBase64 && !environment.encodeBase64) {
|
|
58
|
-
return fallback(this, filePathNode);
|
|
59
|
-
}
|
|
60
|
-
buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);
|
|
61
|
-
var uri = "data:".concat(mimetype, ",").concat(buf).concat(fragment);
|
|
62
|
-
return new url_1.default(new quoted_1.default("\"".concat(uri, "\""), uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
|
63
|
-
} };
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=data-uri.js.map
|
|
52
|
+
if (useBase64) { mimetype += ';base64'; }
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
useBase64 = /;base64$/.test(mimetype);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
|
|
59
|
+
if (!fileSync.contents) {
|
|
60
|
+
logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`);
|
|
61
|
+
return fallback(this, filePathNode || mimetypeNode);
|
|
62
|
+
}
|
|
63
|
+
let buf = fileSync.contents;
|
|
64
|
+
if (useBase64 && !environment.encodeBase64) {
|
|
65
|
+
return fallback(this, filePathNode);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);
|
|
69
|
+
|
|
70
|
+
const uri = `data:${mimetype},${buf}${fragment}`;
|
|
71
|
+
|
|
72
|
+
return new URL(new Quoted(`"${uri}"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
|
73
|
+
}};
|
|
74
|
+
};
|