less 4.4.2 → 4.6.0
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/bin/lessc +67 -58
- package/dist/less.js +14496 -11811
- package/dist/less.min.js +4 -4
- package/dist/less.min.js.map +1 -1
- package/lib/less/constants.js +5 -7
- package/lib/less/contexts.js +71 -56
- 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 +52 -23
- 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 +65 -46
- package/lib/less/logger.js +11 -14
- package/lib/less/parse-tree.js +94 -38
- package/lib/less/parse.js +44 -44
- package/lib/less/parser/parser-input.js +152 -131
- package/lib/less/parser/parser.js +866 -672
- 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 +57 -44
- 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 +53 -11
- 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 +28 -28
- package/lib/less-node/plugin-loader.js +35 -27
- package/lib/less-node/url-file-manager.js +33 -31
- package/package.json +31 -19
- package/.eslintignore +0 -6
- package/.eslintrc.js +0 -63
- package/Gruntfile.js +0 -404
- 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/chunker.js +0 -148
- package/lib/less/parser/chunker.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/test/.eslintrc.json +0 -9
- package/test/README.md +0 -3
- package/test/browser/common.js +0 -230
- 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 -188
- package/test/browser/generator/runner.js +0 -2
- package/test/browser/generator/template.js +0 -93
- 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-legacy-options.js +0 -6
- package/test/browser/runner-legacy-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 -112
- package/test/less-test.js +0 -625
- 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/custom-props.json +0 -1
- package/test/sourcemaps/index.html +0 -17
- 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/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -21
|
@@ -1,55 +1,59 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* @todo Document why this abstraction exists, and the relationship between
|
|
4
3
|
* environment, file managers, and plugin manager
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
|
|
6
|
+
import logger from '../logger.js';
|
|
7
|
+
|
|
8
|
+
class Environment {
|
|
9
|
+
constructor(externalEnvironment, fileManagers) {
|
|
11
10
|
this.fileManagers = fileManagers || [];
|
|
12
11
|
externalEnvironment = externalEnvironment || {};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
|
|
13
|
+
const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];
|
|
14
|
+
const requiredFunctions = [];
|
|
15
|
+
const functions = requiredFunctions.concat(optionalFunctions);
|
|
16
|
+
|
|
17
|
+
for (let i = 0; i < functions.length; i++) {
|
|
18
|
+
const propName = functions[i];
|
|
19
|
+
const environmentFunc = externalEnvironment[propName];
|
|
19
20
|
if (environmentFunc) {
|
|
20
21
|
this[propName] = environmentFunc.bind(externalEnvironment);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
this.warn("missing required function in environment - ".concat(propName));
|
|
22
|
+
} else if (i < requiredFunctions.length) {
|
|
23
|
+
this.warn(`missing required function in environment - ${propName}`);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
getFileManager(filename, currentDirectory, options, environment, isSync) {
|
|
29
|
+
|
|
28
30
|
if (!filename) {
|
|
29
|
-
|
|
31
|
+
logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
|
|
30
32
|
}
|
|
31
33
|
if (currentDirectory === undefined) {
|
|
32
|
-
|
|
34
|
+
logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
|
|
33
35
|
}
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
let fileManagers = this.fileManagers;
|
|
35
38
|
if (options.pluginManager) {
|
|
36
39
|
fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());
|
|
37
40
|
}
|
|
38
|
-
for (
|
|
39
|
-
|
|
41
|
+
for (let i = fileManagers.length - 1; i >= 0 ; i--) {
|
|
42
|
+
const fileManager = fileManagers[i];
|
|
40
43
|
if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {
|
|
41
44
|
return fileManager;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
return null;
|
|
45
|
-
}
|
|
46
|
-
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
addFileManager(fileManager) {
|
|
47
51
|
this.fileManagers.push(fileManager);
|
|
48
|
-
}
|
|
49
|
-
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
clearFileManagers() {
|
|
50
55
|
this.fileManagers = [];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=environment.js.map
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default Environment;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { Environment } from './environment-api'
|
|
2
|
+
|
|
3
|
+
export interface FileManager {
|
|
4
|
+
/**
|
|
5
|
+
* Given the full path to a file, return the path component
|
|
6
|
+
* Provided by AbstractFileManager
|
|
7
|
+
*/
|
|
8
|
+
getPath(filename: string): string
|
|
9
|
+
/**
|
|
10
|
+
* Append a .less extension if appropriate. Only called if less thinks one could be added.
|
|
11
|
+
* Provided by AbstractFileManager
|
|
12
|
+
*/
|
|
13
|
+
tryAppendLessExtension(filename: string): string
|
|
14
|
+
/**
|
|
15
|
+
* Whether the rootpath should be converted to be absolute.
|
|
16
|
+
* The browser ovverides this to return true because urls must be absolute.
|
|
17
|
+
* Provided by AbstractFileManager (returns false)
|
|
18
|
+
*/
|
|
19
|
+
alwaysMakePathsAbsolute(): boolean
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether a path is absolute
|
|
22
|
+
* Provided by AbstractFileManager
|
|
23
|
+
*/
|
|
24
|
+
isPathAbsolute(path: string): boolean
|
|
25
|
+
/**
|
|
26
|
+
* joins together 2 paths
|
|
27
|
+
* Provided by AbstractFileManager
|
|
28
|
+
*/
|
|
29
|
+
join(basePath: string, laterPath: string): string
|
|
30
|
+
/**
|
|
31
|
+
* Returns the difference between 2 paths
|
|
32
|
+
* E.g. url = a/ baseUrl = a/b/ returns ../
|
|
33
|
+
* url = a/b/ baseUrl = a/ returns b/
|
|
34
|
+
* Provided by AbstractFileManager
|
|
35
|
+
*/
|
|
36
|
+
pathDiff(url: string, baseUrl: string): string
|
|
37
|
+
/**
|
|
38
|
+
* Returns whether this file manager supports this file for syncronous file retrieval
|
|
39
|
+
* If true is returned, loadFileSync will then be called with the file.
|
|
40
|
+
* Provided by AbstractFileManager (returns false)
|
|
41
|
+
*
|
|
42
|
+
* @todo - Narrow Options type
|
|
43
|
+
*/
|
|
44
|
+
supportsSync(
|
|
45
|
+
filename: string,
|
|
46
|
+
currentDirectory: string,
|
|
47
|
+
options: Record<string, any>,
|
|
48
|
+
environment: Environment
|
|
49
|
+
): boolean
|
|
50
|
+
/**
|
|
51
|
+
* If file manager supports async file retrieval for this file type
|
|
52
|
+
*/
|
|
53
|
+
supports(
|
|
54
|
+
filename: string,
|
|
55
|
+
currentDirectory: string,
|
|
56
|
+
options: Record<string, any>,
|
|
57
|
+
environment: Environment
|
|
58
|
+
): boolean
|
|
59
|
+
/**
|
|
60
|
+
* Loads a file asynchronously.
|
|
61
|
+
*/
|
|
62
|
+
loadFile(
|
|
63
|
+
filename: string,
|
|
64
|
+
currentDirectory: string,
|
|
65
|
+
options: Record<string, any>,
|
|
66
|
+
environment: Environment
|
|
67
|
+
): Promise<{ filename: string, contents: string }>
|
|
68
|
+
/**
|
|
69
|
+
* Loads a file synchronously. Expects an immediate return with an object
|
|
70
|
+
*/
|
|
71
|
+
loadFileSync(
|
|
72
|
+
filename: string,
|
|
73
|
+
currentDirectory: string,
|
|
74
|
+
options: Record<string, any>,
|
|
75
|
+
environment: Environment
|
|
76
|
+
): { error?: unknown, filename: string, contents: string }
|
|
77
|
+
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
|
5
|
-
var keyword_1 = tslib_1.__importDefault(require("../tree/keyword"));
|
|
1
|
+
import Anonymous from '../tree/anonymous.js';
|
|
2
|
+
import Keyword from '../tree/keyword.js';
|
|
3
|
+
|
|
6
4
|
function boolean(condition) {
|
|
7
|
-
return condition ?
|
|
5
|
+
return condition ? Keyword.True : Keyword.False;
|
|
8
6
|
}
|
|
7
|
+
|
|
9
8
|
/**
|
|
10
9
|
* Functions with evalArgs set to false are sent context
|
|
11
10
|
* as the first argument.
|
|
12
11
|
*/
|
|
13
12
|
function If(context, condition, trueValue, falseValue) {
|
|
14
13
|
return condition.eval(context) ? trueValue.eval(context)
|
|
15
|
-
: (falseValue ? falseValue.eval(context) : new
|
|
14
|
+
: (falseValue ? falseValue.eval(context) : new Anonymous);
|
|
16
15
|
}
|
|
17
16
|
If.evalArgs = false;
|
|
17
|
+
|
|
18
18
|
function isdefined(context, variable) {
|
|
19
19
|
try {
|
|
20
20
|
variable.eval(context);
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return keyword_1.default.False;
|
|
21
|
+
return Keyword.True;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return Keyword.False;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
26
|
+
|
|
27
27
|
isdefined.evalArgs = false;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
|
|
29
|
+
export default { isdefined, boolean, 'if': If };
|
|
@@ -1,48 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
var color_1 = tslib_1.__importDefault(require("../tree/color"));
|
|
1
|
+
import Color from '../tree/color.js';
|
|
2
|
+
|
|
5
3
|
// Color Blending
|
|
6
4
|
// ref: http://www.w3.org/TR/compositing-1
|
|
5
|
+
|
|
7
6
|
function colorBlend(mode, color1, color2) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
const ab = color1.alpha; // result
|
|
8
|
+
|
|
9
|
+
let // backdrop
|
|
10
|
+
cb;
|
|
11
|
+
|
|
12
|
+
const as = color2.alpha;
|
|
13
|
+
|
|
14
|
+
let // source
|
|
15
|
+
cs;
|
|
16
|
+
|
|
17
|
+
let ar;
|
|
18
|
+
let cr;
|
|
19
|
+
const r = [];
|
|
20
|
+
|
|
17
21
|
ar = as + ab * (1 - as);
|
|
18
|
-
for (
|
|
22
|
+
for (let i = 0; i < 3; i++) {
|
|
19
23
|
cb = color1.rgb[i] / 255;
|
|
20
24
|
cs = color2.rgb[i] / 255;
|
|
21
25
|
cr = mode(cb, cs);
|
|
22
26
|
if (ar) {
|
|
23
27
|
cr = (as * cs + ab * (cb -
|
|
24
|
-
|
|
28
|
+
as * (cb + cs - cr))) / ar;
|
|
25
29
|
}
|
|
26
30
|
r[i] = cr * 255;
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
return new Color(r, ar);
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
|
|
36
|
+
const colorBlendModeFunctions = {
|
|
37
|
+
multiply: function(cb, cs) {
|
|
32
38
|
return cb * cs;
|
|
33
39
|
},
|
|
34
|
-
screen: function
|
|
40
|
+
screen: function(cb, cs) {
|
|
35
41
|
return cb + cs - cb * cs;
|
|
36
42
|
},
|
|
37
|
-
overlay: function
|
|
43
|
+
overlay: function(cb, cs) {
|
|
38
44
|
cb *= 2;
|
|
39
45
|
return (cb <= 1) ?
|
|
40
46
|
colorBlendModeFunctions.multiply(cb, cs) :
|
|
41
47
|
colorBlendModeFunctions.screen(cb - 1, cs);
|
|
42
48
|
},
|
|
43
|
-
softlight: function
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
softlight: function(cb, cs) {
|
|
50
|
+
let d = 1;
|
|
51
|
+
let e = cb;
|
|
46
52
|
if (cs > 0.5) {
|
|
47
53
|
e = 1;
|
|
48
54
|
d = (cb > 0.25) ? Math.sqrt(cb)
|
|
@@ -50,28 +56,30 @@ var colorBlendModeFunctions = {
|
|
|
50
56
|
}
|
|
51
57
|
return cb - (1 - 2 * cs) * e * (d - cb);
|
|
52
58
|
},
|
|
53
|
-
hardlight: function
|
|
59
|
+
hardlight: function(cb, cs) {
|
|
54
60
|
return colorBlendModeFunctions.overlay(cs, cb);
|
|
55
61
|
},
|
|
56
|
-
difference: function
|
|
62
|
+
difference: function(cb, cs) {
|
|
57
63
|
return Math.abs(cb - cs);
|
|
58
64
|
},
|
|
59
|
-
exclusion: function
|
|
65
|
+
exclusion: function(cb, cs) {
|
|
60
66
|
return cb + cs - 2 * cb * cs;
|
|
61
67
|
},
|
|
68
|
+
|
|
62
69
|
// non-w3c functions:
|
|
63
|
-
average: function
|
|
70
|
+
average: function(cb, cs) {
|
|
64
71
|
return (cb + cs) / 2;
|
|
65
72
|
},
|
|
66
|
-
negation: function
|
|
73
|
+
negation: function(cb, cs) {
|
|
67
74
|
return 1 - Math.abs(cb + cs - 1);
|
|
68
75
|
}
|
|
69
76
|
};
|
|
70
|
-
|
|
77
|
+
|
|
78
|
+
for (const f in colorBlendModeFunctions) {
|
|
71
79
|
// eslint-disable-next-line no-prototype-builtins
|
|
72
80
|
if (colorBlendModeFunctions.hasOwnProperty(f)) {
|
|
73
81
|
colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
|
|
85
|
+
export default colorBlend;
|