avancement planning
This commit is contained in:
-6
@@ -1,6 +0,0 @@
|
||||
Gruntfile.js
|
||||
dist/*
|
||||
tmp/*
|
||||
lib/*
|
||||
test/browser/less.min.js
|
||||
node_modules
|
||||
-63
@@ -1,63 +0,0 @@
|
||||
module.exports = {
|
||||
'parser': '@typescript-eslint/parser',
|
||||
'extends': 'eslint:recommended',
|
||||
'parserOptions': {
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
},
|
||||
'plugins': ['@typescript-eslint'],
|
||||
'env': {
|
||||
'browser': true,
|
||||
'node': true,
|
||||
'mocha': true
|
||||
},
|
||||
'globals': {},
|
||||
'rules': {
|
||||
indent: ['error', 4, {
|
||||
SwitchCase: 1
|
||||
}],
|
||||
'no-empty': ['error', { 'allowEmptyCatch': true }],
|
||||
quotes: ['error', 'single', {
|
||||
avoidEscape: true
|
||||
}],
|
||||
/**
|
||||
* The codebase uses some while(true) statements.
|
||||
* Refactor to remove this rule.
|
||||
*/
|
||||
'no-constant-condition': 0,
|
||||
/**
|
||||
* Less combines assignments with conditionals sometimes
|
||||
*/
|
||||
'no-cond-assign': 0,
|
||||
/**
|
||||
* @todo - remove when some kind of code style (XO?) is added
|
||||
*/
|
||||
'no-multiple-empty-lines': 'error'
|
||||
},
|
||||
'overrides': [
|
||||
{
|
||||
files: ['*.ts'],
|
||||
extends: ['plugin:@typescript-eslint/recommended'],
|
||||
rules: {
|
||||
/**
|
||||
* Suppress until Less has better-defined types
|
||||
* @see https://github.com/less/less.js/discussions/3786
|
||||
*/
|
||||
'@typescript-eslint/no-explicit-any': 0
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['test/**/*.{js,ts}', 'benchmark/index.js'],
|
||||
/**
|
||||
* @todo - fix later
|
||||
*/
|
||||
rules: {
|
||||
'no-undef': 0,
|
||||
'no-useless-escape': 0,
|
||||
'no-unused-vars': 0,
|
||||
'no-redeclare': 0,
|
||||
'@typescript-eslint/no-unused-vars': 0
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
-404
@@ -1,404 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var resolve = require('resolve');
|
||||
var path = require('path');
|
||||
|
||||
var testFolder = path.relative(process.cwd(), path.dirname(resolve.sync('@less/test-data')));
|
||||
var lessFolder = path.join(testFolder, 'less');
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.option("stack", true);
|
||||
|
||||
// Report the elapsed execution time of tasks.
|
||||
require("time-grunt")(grunt);
|
||||
|
||||
var git = require("git-rev");
|
||||
|
||||
// Sauce Labs browser
|
||||
var browsers = [
|
||||
// Desktop browsers
|
||||
{
|
||||
browserName: "chrome",
|
||||
version: "latest",
|
||||
platform: "Windows 7"
|
||||
},
|
||||
{
|
||||
browserName: "firefox",
|
||||
version: "latest",
|
||||
platform: "Linux"
|
||||
},
|
||||
{
|
||||
browserName: "safari",
|
||||
version: "9",
|
||||
platform: "OS X 10.11"
|
||||
},
|
||||
{
|
||||
browserName: "internet explorer",
|
||||
version: "8",
|
||||
platform: "Windows XP"
|
||||
},
|
||||
{
|
||||
browserName: "internet explorer",
|
||||
version: "11",
|
||||
platform: "Windows 8.1"
|
||||
},
|
||||
{
|
||||
browserName: "edge",
|
||||
version: "13",
|
||||
platform: "Windows 10"
|
||||
},
|
||||
// Mobile browsers
|
||||
{
|
||||
browserName: "ipad",
|
||||
deviceName: "iPad Air Simulator",
|
||||
deviceOrientation: "portrait",
|
||||
version: "8.4",
|
||||
platform: "OS X 10.9"
|
||||
},
|
||||
{
|
||||
browserName: "iphone",
|
||||
deviceName: "iPhone 5 Simulator",
|
||||
deviceOrientation: "portrait",
|
||||
version: "9.3",
|
||||
platform: "OS X 10.11"
|
||||
},
|
||||
{
|
||||
browserName: "android",
|
||||
deviceName: "Google Nexus 7 HD Emulator",
|
||||
deviceOrientation: "portrait",
|
||||
version: "4.4",
|
||||
platform: "Linux"
|
||||
}
|
||||
];
|
||||
|
||||
var sauceJobs = {};
|
||||
|
||||
var browserTests = [
|
||||
"filemanager-plugin",
|
||||
"visitor-plugin",
|
||||
"global-vars",
|
||||
"modify-vars",
|
||||
"production",
|
||||
"rootpath-relative",
|
||||
"rootpath-rewrite-urls",
|
||||
"rootpath",
|
||||
"relative-urls",
|
||||
"rewrite-urls",
|
||||
"browser",
|
||||
"no-js-errors",
|
||||
"legacy"
|
||||
];
|
||||
|
||||
function makeJob(testName) {
|
||||
sauceJobs[testName] = {
|
||||
options: {
|
||||
urls:
|
||||
testName === "all"
|
||||
? browserTests.map(function(name) {
|
||||
return (
|
||||
"http://localhost:8081/tmp/browser/test-runner-" +
|
||||
name +
|
||||
".html"
|
||||
);
|
||||
})
|
||||
: [
|
||||
"http://localhost:8081/tmp/browser/test-runner-" +
|
||||
testName +
|
||||
".html"
|
||||
],
|
||||
testname:
|
||||
testName === "all" ? "Unit Tests for Less.js" : testName,
|
||||
browsers: browsers,
|
||||
public: "public",
|
||||
recordVideo: false,
|
||||
videoUploadOnPass: false,
|
||||
recordScreenshots: process.env.TRAVIS_BRANCH !== "master",
|
||||
build:
|
||||
process.env.TRAVIS_BRANCH === "master"
|
||||
? process.env.TRAVIS_JOB_ID
|
||||
: undefined,
|
||||
tags: [
|
||||
process.env.TRAVIS_BUILD_NUMBER,
|
||||
process.env.TRAVIS_PULL_REQUEST,
|
||||
process.env.TRAVIS_BRANCH
|
||||
],
|
||||
statusCheckAttempts: -1,
|
||||
sauceConfig: {
|
||||
"idle-timeout": 100
|
||||
},
|
||||
throttled: 5,
|
||||
onTestComplete: function(result, callback) {
|
||||
// Called after a unit test is done, per page, per browser
|
||||
// 'result' param is the object returned by the test framework's reporter
|
||||
// 'callback' is a Node.js style callback function. You must invoke it after you
|
||||
// finish your work.
|
||||
// Pass a non-null value as the callback's first parameter if you want to throw an
|
||||
// exception. If your function is synchronous you can also throw exceptions
|
||||
// directly.
|
||||
// Passing true or false as the callback's second parameter passes or fails the
|
||||
// test. Passing undefined does not alter the test result. Please note that this
|
||||
// only affects the grunt task's result. You have to explicitly update the Sauce
|
||||
// Labs job's status via its REST API, if you want so.
|
||||
|
||||
// This should be the encrypted value in Travis
|
||||
var user = process.env.SAUCE_USERNAME;
|
||||
var pass = process.env.SAUCE_ACCESS_KEY;
|
||||
|
||||
git.short(function(hash) {
|
||||
require("phin")(
|
||||
{
|
||||
method: "PUT",
|
||||
url: [
|
||||
"https://saucelabs.com/rest/v1",
|
||||
user,
|
||||
"jobs",
|
||||
result.job_id
|
||||
].join("/"),
|
||||
auth: { user: user, pass: pass },
|
||||
data: {
|
||||
passed: result.passed,
|
||||
build: "build-" + hash
|
||||
}
|
||||
},
|
||||
function(error, response) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
callback(error);
|
||||
} else if (response.statusCode !== 200) {
|
||||
console.log(response);
|
||||
callback(
|
||||
new Error("Unexpected response status")
|
||||
);
|
||||
} else {
|
||||
callback(null, result.passed);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Make the SauceLabs jobs
|
||||
["all"].concat(browserTests).map(makeJob);
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
shell: {
|
||||
options: {
|
||||
stdout: true,
|
||||
failOnError: true,
|
||||
execOptions: {
|
||||
maxBuffer: Infinity
|
||||
}
|
||||
},
|
||||
build: {
|
||||
command: [
|
||||
/** Browser runtime */
|
||||
"node build/rollup.js --dist",
|
||||
/** Node.js runtime */
|
||||
"npm run build"
|
||||
].join(" && ")
|
||||
},
|
||||
testbuild: {
|
||||
command: [
|
||||
"npm run build",
|
||||
"node build/rollup.js --browser --out=./tmp/browser/less.min.js"
|
||||
].join(" && ")
|
||||
},
|
||||
testcjs: {
|
||||
command: "npm run build"
|
||||
},
|
||||
testbrowser: {
|
||||
command: "node build/rollup.js --browser --out=./tmp/browser/less.min.js"
|
||||
},
|
||||
test: {
|
||||
command: 'ts-node test/test-es6.ts && node test/index.js'
|
||||
},
|
||||
generatebrowser: {
|
||||
command: 'node test/browser/generator/generate.js'
|
||||
},
|
||||
runbrowser: {
|
||||
command: 'node test/browser/generator/runner.js'
|
||||
},
|
||||
benchmark: {
|
||||
command: "node benchmark/index.js"
|
||||
},
|
||||
opts: {
|
||||
// test running with all current options (using `opts` since `options` means something already)
|
||||
command: [
|
||||
// @TODO: make this more thorough
|
||||
// CURRENT OPTIONS
|
||||
`node bin/lessc --ie-compat ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
// --math
|
||||
`node bin/lessc --math=always ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
`node bin/lessc --math=parens-division ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
`node bin/lessc --math=parens ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
`node bin/lessc --math=strict ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
`node bin/lessc --math=strict-legacy ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
|
||||
// DEPRECATED OPTIONS
|
||||
// --strict-math
|
||||
`node bin/lessc --strict-math=on ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`
|
||||
].join(" && ")
|
||||
},
|
||||
plugin: {
|
||||
command: [
|
||||
`node bin/lessc --clean-css="--s1 --advanced" ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`,
|
||||
"cd lib",
|
||||
`node ../bin/lessc --clean-css="--s1 --advanced" ../${lessFolder}/_main/lazy-eval.less ../tmp/lazy-eval.css`,
|
||||
`node ../bin/lessc --source-map=lazy-eval.css.map --autoprefix ../${lessFolder}/_main/lazy-eval.less ../tmp/lazy-eval.css`,
|
||||
"cd ..",
|
||||
// Test multiple plugins
|
||||
`node bin/lessc --plugin=clean-css="--s1 --advanced" --plugin=autoprefix="ie 11,Edge >= 13,Chrome >= 47,Firefox >= 45,iOS >= 9.2,Safari >= 9" ${lessFolder}/_main/lazy-eval.less tmp/lazy-eval.css`
|
||||
].join(" && ")
|
||||
},
|
||||
"sourcemap-test": {
|
||||
// quoted value doesn't seem to get picked up by time-grunt, or isn't output, at least; maybe just "sourcemap" is fine?
|
||||
command: [
|
||||
`node bin/lessc --source-map=test/sourcemaps/maps/import-map.map ${lessFolder}/_main/import.less test/sourcemaps/import.css`,
|
||||
`node bin/lessc --source-map ${lessFolder}/sourcemaps/basic.less test/sourcemaps/basic.css`
|
||||
].join(" && ")
|
||||
}
|
||||
},
|
||||
|
||||
eslint: {
|
||||
target: [
|
||||
"test/**/*.js",
|
||||
"src/less*/**/*.js",
|
||||
"!test/less/errors/plugin/plugin-error.js"
|
||||
],
|
||||
options: {
|
||||
configFile: ".eslintrc.js",
|
||||
fix: true
|
||||
}
|
||||
},
|
||||
|
||||
connect: {
|
||||
server: {
|
||||
options: {
|
||||
port: 8081,
|
||||
base: '../..'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"saucelabs-mocha": sauceJobs,
|
||||
|
||||
// Clean the version of less built for the tests
|
||||
clean: {
|
||||
test: ["test/browser/less.js", "tmp", "test/less-bom"],
|
||||
"sourcemap-test": [
|
||||
"test/sourcemaps/*.css",
|
||||
"test/sourcemaps/*.map"
|
||||
],
|
||||
sauce_log: ["sc_*.log"]
|
||||
}
|
||||
});
|
||||
|
||||
// Load these plugins to provide the necessary tasks
|
||||
grunt.loadNpmTasks("grunt-saucelabs");
|
||||
|
||||
require("jit-grunt")(grunt);
|
||||
|
||||
// by default, run tests
|
||||
grunt.registerTask("default", ["test"]);
|
||||
|
||||
// Release
|
||||
grunt.registerTask("dist", [
|
||||
"shell:build"
|
||||
]);
|
||||
|
||||
// Create the browser version of less.js
|
||||
grunt.registerTask("browsertest-lessjs", [
|
||||
"shell:testbrowser"
|
||||
]);
|
||||
|
||||
// Run all browser tests
|
||||
grunt.registerTask("browsertest", [
|
||||
"browsertest-lessjs",
|
||||
"connect",
|
||||
"shell:runbrowser"
|
||||
]);
|
||||
|
||||
// setup a web server to run the browser tests in a browser rather than phantom
|
||||
grunt.registerTask("browsertest-server", [
|
||||
"browsertest-lessjs",
|
||||
"shell:generatebrowser",
|
||||
"connect::keepalive"
|
||||
]);
|
||||
|
||||
var previous_force_state = grunt.option("force");
|
||||
|
||||
grunt.registerTask("force", function(set) {
|
||||
if (set === "on") {
|
||||
grunt.option("force", true);
|
||||
} else if (set === "off") {
|
||||
grunt.option("force", false);
|
||||
} else if (set === "restore") {
|
||||
grunt.option("force", previous_force_state);
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask("sauce", [
|
||||
"browsertest-lessjs",
|
||||
"shell:generatebrowser",
|
||||
"connect",
|
||||
"sauce-after-setup"
|
||||
]);
|
||||
|
||||
grunt.registerTask("sauce-after-setup", [
|
||||
"saucelabs-mocha:all",
|
||||
"clean:sauce_log"
|
||||
]);
|
||||
|
||||
var testTasks = [
|
||||
"clean",
|
||||
"eslint",
|
||||
"shell:testbuild",
|
||||
"shell:test",
|
||||
"shell:opts",
|
||||
"shell:plugin",
|
||||
"connect",
|
||||
"shell:runbrowser"
|
||||
];
|
||||
|
||||
if (
|
||||
isNaN(Number(process.env.TRAVIS_PULL_REQUEST, 10)) &&
|
||||
(process.env.TRAVIS_BRANCH === "master")
|
||||
) {
|
||||
testTasks.push("force:on");
|
||||
testTasks.push("sauce-after-setup");
|
||||
testTasks.push("force:off");
|
||||
}
|
||||
|
||||
// Run all tests
|
||||
grunt.registerTask("test", testTasks);
|
||||
|
||||
// Run shell option tests (includes deprecated options)
|
||||
grunt.registerTask("shell-options", ["shell:opts"]);
|
||||
|
||||
// Run shell plugin test
|
||||
grunt.registerTask("shell-plugin", ["shell:plugin"]);
|
||||
|
||||
// Quickly build and run Node tests
|
||||
grunt.registerTask("quicktest", [
|
||||
"shell:testcjs",
|
||||
"shell:test"
|
||||
]);
|
||||
|
||||
// generate a good test environment for testing sourcemaps
|
||||
grunt.registerTask("sourcemap-test", [
|
||||
"clean:sourcemap-test",
|
||||
"shell:build:lessc",
|
||||
"shell:sourcemap-test",
|
||||
"connect::keepalive"
|
||||
]);
|
||||
|
||||
// Run benchmark
|
||||
grunt.registerTask("benchmark", [
|
||||
"shell:testcjs",
|
||||
"shell:benchmark"
|
||||
]);
|
||||
};
|
||||
+70
-5
@@ -1,13 +1,78 @@
|
||||
# [Less.js](http://lesscss.org)
|
||||
<p align="center"><img src="http://lesscss.org/public/img/less_logo.png" width="264" height="117" alt="Less.js logo"></p>
|
||||
|
||||
> The **dynamic** stylesheet language. [http://lesscss.org](http://lesscss.org).
|
||||
<p align="center">
|
||||
<a href="https://github.com/less/less.js/actions?query=branch%3Amaster"><img src="https://github.com/less/less.js/actions/workflows/ci.yml/badge.svg?branch=master" alt="Github Actions CI"/></a>
|
||||
<a href="https://www.npmtrends.com/less"><img src="https://img.shields.io/npm/dm/less.svg?sanitize=true" alt="Downloads"></a>
|
||||
<a href="https://www.npmjs.com/package/less"><img src="https://img.shields.io/npm/v/less.svg?sanitize=true" alt="npm version" /></a>
|
||||
</p>
|
||||
|
||||
This is the JavaScript, official, stable version of Less.
|
||||
# Less.js
|
||||
|
||||
> The dynamic stylesheet language. [lesscss.org](http://lesscss.org)
|
||||
|
||||
## Getting Started
|
||||
Less extends CSS with variables, mixins, functions, nesting, and more — then compiles to standard CSS. Write cleaner stylesheets with less code.
|
||||
|
||||
```less
|
||||
@primary: #4a90d9;
|
||||
|
||||
.button {
|
||||
color: @primary;
|
||||
&:hover {
|
||||
color: darken(@primary, 10%);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
Add Less.js to your project:
|
||||
```sh
|
||||
npm install less
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Node.js
|
||||
|
||||
```js
|
||||
import less from 'less';
|
||||
|
||||
const output = await less.render('.class { width: (1 + 1) }');
|
||||
console.log(output.css);
|
||||
```
|
||||
|
||||
### Command Line
|
||||
|
||||
```sh
|
||||
npx lessc styles.less styles.css
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
```html
|
||||
<link rel="stylesheet/less" type="text/css" href="styles.less" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/less"></script>
|
||||
```
|
||||
|
||||
## Why Less?
|
||||
|
||||
- **Variables** — define reusable values once
|
||||
- **Mixins** — reuse groups of declarations across rulesets
|
||||
- **Nesting** — mirror HTML structure in your stylesheets
|
||||
- **Functions** — transform colors, manipulate strings, do math
|
||||
- **Imports** — split stylesheets into manageable pieces
|
||||
- **Extend** — reduce output size by combining selectors
|
||||
|
||||
## Documentation
|
||||
|
||||
Full documentation, usage guides, and configuration options at **[lesscss.org](http://lesscss.org)**.
|
||||
|
||||
## Contributing
|
||||
|
||||
Less.js is open source. [Report bugs](https://github.com/less/less.js/issues), submit pull requests, or help improve the [documentation](https://github.com/less/less-docs).
|
||||
|
||||
See [CONTRIBUTING.md](https://github.com/less/less.js/blob/master/CONTRIBUTING.md) for development setup.
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2009-2025 [Alexis Sellier](http://cloudhead.io) & The Core Less Team
|
||||
Licensed under the [Apache License](https://github.com/less/less.js/blob/master/LICENSE).
|
||||
|
||||
+67
-58
@@ -2,18 +2,17 @@
|
||||
|
||||
/* eslint indent: [2, 2, {"SwitchCase": 1}] */
|
||||
|
||||
'use strict';
|
||||
import path from 'path';
|
||||
import os from 'os';
|
||||
import { createRequire } from 'module';
|
||||
import fs from '../lib/less-node/fs.js';
|
||||
import * as utils from '../lib/less/utils.js';
|
||||
import * as Constants from '../lib/less/constants.js';
|
||||
import less from '../lib/less-node/index.js';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('../lib/less-node/fs').default;
|
||||
var os = require('os');
|
||||
var utils = require('../lib/less/utils');
|
||||
var Constants = require('../lib/less/constants');
|
||||
|
||||
var less = require('../lib/less-node').default;
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
var errno;
|
||||
var mkdirp;
|
||||
|
||||
try {
|
||||
errno = require('errno');
|
||||
@@ -65,6 +64,7 @@ var parseVariableOption = function parseVariableOption(option, variables) {
|
||||
};
|
||||
|
||||
var sourceMapFileInline = false;
|
||||
var pendingDeprecations = [];
|
||||
|
||||
function printUsage() {
|
||||
less.lesscHelper.printUsage();
|
||||
@@ -98,53 +98,48 @@ function render() {
|
||||
}
|
||||
|
||||
if (options.sourceMap) {
|
||||
sourceMapOptions.sourceMapInputFilename = input;
|
||||
|
||||
if (!sourceMapOptions.sourceMapFullFilename) {
|
||||
if (!output && !sourceMapFileInline) {
|
||||
console.error('the sourcemap option only has an optional filename if the css filename is given');
|
||||
console.error('consider adding --source-map-map-inline which embeds the sourcemap into the css');
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
} // its in the same directory, so always just the basename
|
||||
|
||||
|
||||
if (output) {
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output);
|
||||
sourceMapOptions.sourceMapFullFilename = ''.concat(output, '.map');
|
||||
} // its in the same directory, so always just the basename
|
||||
|
||||
|
||||
if ('sourceMapFullFilename' in sourceMapOptions) {
|
||||
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
|
||||
}
|
||||
} else if (options.sourceMap && !sourceMapFileInline) {
|
||||
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
|
||||
var mapDir = path.dirname(mapFilename);
|
||||
var outputDir = path.dirname(output); // find the path from the map to the output file
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
sourceMapOptions.sourceMapOutputFilename = path.join(path.relative(mapDir, outputDir), path.basename(output)); // make the sourcemap filename point to the sourcemap relative to the css file output directory
|
||||
|
||||
sourceMapOptions.sourceMapFilename = path.join(path.relative(outputDir, mapDir), path.basename(sourceMapOptions.sourceMapFullFilename));
|
||||
}
|
||||
|
||||
// Validate conflicting options
|
||||
if (sourceMapOptions.sourceMapURL && sourceMapOptions.disableSourcemapAnnotation) {
|
||||
console.error('You cannot provide flag --source-map-url with --source-map-no-annotation.');
|
||||
console.error('Please remove one of those flags.');
|
||||
process.exitcode = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (sourceMapOptions.sourceMapBasepath === undefined) {
|
||||
sourceMapOptions.sourceMapBasepath = input ? path.dirname(input) : process.cwd();
|
||||
}
|
||||
// Handle explicit sourceMapFullFilename (from --source-map=filename)
|
||||
// Normalization of other options (sourceMapBasepath, sourceMapRootpath, etc.)
|
||||
// is handled automatically in parse-tree.js
|
||||
if (sourceMapOptions.sourceMapFullFilename && !sourceMapFileInline) {
|
||||
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
|
||||
var mapDir = path.dirname(mapFilename);
|
||||
|
||||
if (sourceMapOptions.sourceMapRootpath === undefined) {
|
||||
var pathToMap = path.dirname((sourceMapFileInline ? output : sourceMapOptions.sourceMapFullFilename) || '.');
|
||||
var pathToInput = path.dirname(sourceMapOptions.sourceMapInputFilename || '.');
|
||||
sourceMapOptions.sourceMapRootpath = path.relative(pathToMap, pathToInput);
|
||||
if (output) {
|
||||
var outputDir = path.dirname(output);
|
||||
// Set sourceMapOutputFilename relative to map directory
|
||||
sourceMapOptions.sourceMapOutputFilename = path.join(
|
||||
path.relative(mapDir, outputDir),
|
||||
path.basename(output)
|
||||
);
|
||||
// Set sourceMapFilename relative to output directory (for sourceMappingURL comment)
|
||||
sourceMapOptions.sourceMapFilename = path.join(
|
||||
path.relative(outputDir, mapDir),
|
||||
path.basename(sourceMapOptions.sourceMapFullFilename)
|
||||
);
|
||||
} else {
|
||||
// No output filename, just use basename
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output || 'output.css');
|
||||
sourceMapOptions.sourceMapFilename = path.basename(sourceMapOptions.sourceMapFullFilename);
|
||||
}
|
||||
} else if (!sourceMapOptions.sourceMapFullFilename && output && !sourceMapFileInline) {
|
||||
// No explicit sourcemap filename, derive from output
|
||||
sourceMapOptions.sourceMapOutputFilename = path.basename(output);
|
||||
sourceMapOptions.sourceMapFullFilename = ''.concat(output, '.map');
|
||||
} else if (!output && !sourceMapFileInline) {
|
||||
console.error('the sourcemap option only has an optional filename if the css filename is given');
|
||||
console.error('consider adding --source-map-map-inline which embeds the sourcemap into the css');
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
@@ -155,6 +150,7 @@ function render() {
|
||||
return;
|
||||
}
|
||||
|
||||
var mkdirp;
|
||||
var ensureDirectory = function ensureDirectory(filepath) {
|
||||
var dir = path.dirname(filepath);
|
||||
var cmd;
|
||||
@@ -193,7 +189,7 @@ function render() {
|
||||
|
||||
// To fix https://github.com/less/less.js/issues/3646
|
||||
output = output.toString();
|
||||
|
||||
|
||||
fs.writeFile(filename, output, 'utf8', function (err) {
|
||||
if (err) {
|
||||
var description = 'Error: ';
|
||||
@@ -408,11 +404,15 @@ function processPluginQueue() {
|
||||
case 'silent':
|
||||
options.silent = silent = true;
|
||||
break;
|
||||
|
||||
|
||||
case 'quiet':
|
||||
options.quiet = quiet = true;
|
||||
break;
|
||||
|
||||
case 'quiet-deprecations':
|
||||
options.quietDeprecations = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
case 'lint':
|
||||
options.lint = true;
|
||||
@@ -458,6 +458,7 @@ function processPluginQueue() {
|
||||
|
||||
case 'js':
|
||||
options.javascriptEnabled = true;
|
||||
pendingDeprecations.push('Warning: Inline JavaScript (--js) is deprecated and will be removed in Less 5.x. Use Less functions or custom plugins instead. (js-eval)');
|
||||
break;
|
||||
|
||||
case 'no-js':
|
||||
@@ -481,6 +482,7 @@ function processPluginQueue() {
|
||||
case 'line-numbers':
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
options.dumpLineNumbers = match[2];
|
||||
pendingDeprecations.push('Warning: The --line-numbers option is deprecated and will be removed in Less 5.x. Use source maps instead (--source-map). (dump-line-numbers)');
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -537,13 +539,13 @@ function processPluginQueue() {
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'ie-compat':
|
||||
console.warn('The --ie-compat option is deprecated, as it has no effect on compilation.');
|
||||
pendingDeprecations.push('Warning: The --ie-compat option is deprecated, as it has no effect on compilation.');
|
||||
break;
|
||||
|
||||
case 'relative-urls':
|
||||
console.warn('The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
|
||||
pendingDeprecations.push('Warning: The --relative-urls option has been deprecated. Use --rewrite-urls=all.');
|
||||
options.rewriteUrls = Constants.RewriteUrls.ALL;
|
||||
break;
|
||||
|
||||
@@ -571,7 +573,7 @@ function processPluginQueue() {
|
||||
|
||||
case 'sm':
|
||||
case 'strict-math':
|
||||
console.warn('The --strict-math option has been deprecated. Use --math=strict.');
|
||||
pendingDeprecations.push('Warning: The --strict-math option has been deprecated. Use --math=strict.');
|
||||
|
||||
if (checkArgFunc(arg, match[2])) {
|
||||
if (checkBooleanArg(match[2])) {
|
||||
@@ -586,14 +588,14 @@ function processPluginQueue() {
|
||||
let m = match[2];
|
||||
if (checkArgFunc(arg, m)) {
|
||||
if (m === 'always') {
|
||||
console.warn('--math=always is deprecated and will be removed in the future.');
|
||||
pendingDeprecations.push('Warning: --math=always is deprecated and will be removed in Less 5.x. Use --math=parens-division (default) or --math=parens. (math-always)');
|
||||
options.math = Constants.Math.ALWAYS;
|
||||
} else if (m === 'parens-division') {
|
||||
options.math = Constants.Math.PARENS_DIVISION;
|
||||
} else if (m === 'parens' || m === 'strict') {
|
||||
options.math = Constants.Math.PARENS;
|
||||
} else if (m === 'strict-legacy') {
|
||||
console.warn('--math=strict-legacy has been removed. Defaulting to --math=strict');
|
||||
pendingDeprecations.push('Warning: --math=strict-legacy has been removed. Defaulting to --math=strict.');
|
||||
options.math = Constants.Math.PARENS;
|
||||
}
|
||||
}
|
||||
@@ -650,7 +652,7 @@ function processPluginQueue() {
|
||||
case 'disable-plugin-rule':
|
||||
options.disablePluginRule = true;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
queuePlugins.push({
|
||||
name: arg,
|
||||
@@ -661,9 +663,16 @@ function processPluginQueue() {
|
||||
}
|
||||
});
|
||||
|
||||
// Flush queued deprecation warnings (respects --silent, --quiet, --quiet-deprecations)
|
||||
if (!silent && !quiet && !options.quietDeprecations) {
|
||||
pendingDeprecations.forEach(function (msg) {
|
||||
console.warn(msg);
|
||||
});
|
||||
}
|
||||
|
||||
if (queuePlugins.length > 0) {
|
||||
processPluginQueue();
|
||||
} else {
|
||||
render();
|
||||
}
|
||||
})();
|
||||
})();
|
||||
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
{
|
||||
"name": "less",
|
||||
"main": "dist/less.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"benchmark",
|
||||
"bin",
|
||||
"lib",
|
||||
"src",
|
||||
"build",
|
||||
"test",
|
||||
"*.md",
|
||||
"LICENSE",
|
||||
"Gruntfile.js",
|
||||
"*.json",
|
||||
"*.yml",
|
||||
".gitattributes",
|
||||
".npmignore",
|
||||
".eslintignore",
|
||||
"tsconfig.json"
|
||||
]
|
||||
}
|
||||
+7884
-5186
File diff suppressed because it is too large
Load Diff
+4
-4
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
-1
@@ -1 +0,0 @@
|
||||
module.exports = require('./lib/less-node').default;
|
||||
+23
-13
@@ -1,14 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var utils_1 = require("./utils");
|
||||
var browser_1 = tslib_1.__importDefault(require("./browser"));
|
||||
exports.default = (function (window, options) {
|
||||
import {addDataAttr} from './utils.js';
|
||||
import browser from './browser.js';
|
||||
|
||||
/**
|
||||
* @param {Window} window
|
||||
* @param {Record<string, *>} options
|
||||
*/
|
||||
export default (window, options) => {
|
||||
|
||||
// use options from the current script tag data attribues
|
||||
(0, utils_1.addDataAttr)(options, browser_1.default.currentScript(window));
|
||||
addDataAttr(options, browser.currentScript(window));
|
||||
|
||||
if (options.isFileProtocol === undefined) {
|
||||
options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);
|
||||
}
|
||||
|
||||
// Load styles asynchronously (default: false)
|
||||
//
|
||||
// This is set to `false` by default, so that the body
|
||||
@@ -17,27 +22,32 @@ exports.default = (function (window, options) {
|
||||
//
|
||||
options.async = options.async || false;
|
||||
options.fileAsync = options.fileAsync || false;
|
||||
|
||||
// Interval between watch polls
|
||||
options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);
|
||||
|
||||
options.env = options.env || (window.location.hostname == '127.0.0.1' ||
|
||||
window.location.hostname == '0.0.0.0' ||
|
||||
window.location.hostname == '0.0.0.0' ||
|
||||
window.location.hostname == 'localhost' ||
|
||||
(window.location.port &&
|
||||
window.location.port.length > 0) ||
|
||||
options.isFileProtocol ? 'development'
|
||||
window.location.port.length > 0) ||
|
||||
options.isFileProtocol ? 'development'
|
||||
: 'production');
|
||||
var dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);
|
||||
|
||||
const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);
|
||||
if (dumpLineNumbers) {
|
||||
options.dumpLineNumbers = dumpLineNumbers[1];
|
||||
}
|
||||
|
||||
if (options.useFileCache === undefined) {
|
||||
options.useFileCache = true;
|
||||
}
|
||||
|
||||
if (options.onReady === undefined) {
|
||||
options.onReady = true;
|
||||
}
|
||||
|
||||
if (options.relativeUrls) {
|
||||
options.rewriteUrls = 'all';
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=add-default-options.js.map
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"add-default-options.js","sourceRoot":"","sources":["../../src/less-browser/add-default-options.js"],"names":[],"mappings":";;;AAAA,iCAAoC;AACpC,8DAAgC;AAEhC,mBAAe,UAAC,MAAM,EAAE,OAAO;IAE3B,yDAAyD;IACzD,IAAA,mBAAW,EAAC,OAAO,EAAE,iBAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpD,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE;QACtC,OAAO,CAAC,cAAc,GAAG,wDAAwD,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACpH;IAED,8CAA8C;IAC9C,EAAE;IACF,sDAAsD;IACtD,2DAA2D;IAC3D,mDAAmD;IACnD,EAAE;IACF,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACvC,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAE/C,+BAA+B;IAC/B,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,WAAW;QACjE,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,SAAS;QACrC,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,WAAW;QACvC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI;YACjB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QACpC,OAAO,CAAC,cAAc,CAAmB,CAAC,CAAC,aAAa;QACxD,CAAC,CAAC,YAAY,CAAC,CAAC;IAEpB,IAAM,eAAe,GAAG,4CAA4C,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAChG,IAAI,eAAe,EAAE;QACjB,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS,EAAE;QACpC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;KAC/B;IAED,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,EAAE;QAC/B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;KAC1B;IAED,IAAI,OAAO,CAAC,YAAY,EAAE;QACtB,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;KAC/B;AACL,CAAC,EAAC","sourcesContent":["import {addDataAttr} from './utils';\nimport browser from './browser';\n\nexport default (window, options) => {\n\n // use options from the current script tag data attribues\n addDataAttr(options, browser.currentScript(window));\n\n if (options.isFileProtocol === undefined) {\n options.isFileProtocol = /^(file|(chrome|safari)(-extension)?|resource|qrc|app):/.test(window.location.protocol);\n }\n\n // Load styles asynchronously (default: false)\n //\n // This is set to `false` by default, so that the body\n // doesn't start loading before the stylesheets are parsed.\n // Setting this to `true` can result in flickering.\n //\n options.async = options.async || false;\n options.fileAsync = options.fileAsync || false;\n\n // Interval between watch polls\n options.poll = options.poll || (options.isFileProtocol ? 1000 : 1500);\n\n options.env = options.env || (window.location.hostname == '127.0.0.1' ||\n window.location.hostname == '0.0.0.0' ||\n window.location.hostname == 'localhost' ||\n (window.location.port &&\n window.location.port.length > 0) ||\n options.isFileProtocol ? 'development'\n : 'production');\n\n const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);\n if (dumpLineNumbers) {\n options.dumpLineNumbers = dumpLineNumbers[1];\n }\n\n if (options.useFileCache === undefined) {\n options.useFileCache = true;\n }\n\n if (options.onReady === undefined) {\n options.onReady = true;\n }\n\n if (options.relativeUrls) {\n options.rewriteUrls = 'all';\n }\n};\n"]}
|
||||
+23
-17
@@ -1,33 +1,38 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
/**
|
||||
* Kicks off less and compiles any stylesheets
|
||||
* used in the browser distributed version of less
|
||||
* to kick-start less using the browser api
|
||||
*/
|
||||
var default_options_1 = tslib_1.__importDefault(require("../less/default-options"));
|
||||
var add_default_options_1 = tslib_1.__importDefault(require("./add-default-options"));
|
||||
var index_1 = tslib_1.__importDefault(require("./index"));
|
||||
var options = (0, default_options_1.default)();
|
||||
import defaultOptions from '../less/default-options.js';
|
||||
import addDefaultOptions from './add-default-options.js';
|
||||
import root from './index.js';
|
||||
|
||||
const options = defaultOptions();
|
||||
|
||||
if (window.less) {
|
||||
for (var key in window.less) {
|
||||
for (const key in window.less) {
|
||||
if (Object.prototype.hasOwnProperty.call(window.less, key)) {
|
||||
options[key] = window.less[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
(0, add_default_options_1.default)(window, options);
|
||||
addDefaultOptions(window, options);
|
||||
|
||||
options.plugins = options.plugins || [];
|
||||
|
||||
if (window.LESS_PLUGINS) {
|
||||
options.plugins = options.plugins.concat(window.LESS_PLUGINS);
|
||||
}
|
||||
var less = (0, index_1.default)(window, options);
|
||||
exports.default = less;
|
||||
|
||||
const less = root(window, options);
|
||||
export default less;
|
||||
|
||||
window.less = less;
|
||||
var css;
|
||||
var head;
|
||||
var style;
|
||||
|
||||
let css;
|
||||
let head;
|
||||
let style;
|
||||
|
||||
// Always restore page visibility
|
||||
function resolveOrReject(data) {
|
||||
if (data.filename) {
|
||||
@@ -37,6 +42,7 @@ function resolveOrReject(data) {
|
||||
head.removeChild(style);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.onReady) {
|
||||
if (/!watch/.test(window.location.hash)) {
|
||||
less.watch();
|
||||
@@ -46,16 +52,16 @@ if (options.onReady) {
|
||||
css = 'body { display: none !important }';
|
||||
head = document.head || document.getElementsByTagName('head')[0];
|
||||
style = document.createElement('style');
|
||||
|
||||
style.type = 'text/css';
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = css;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(css));
|
||||
}
|
||||
|
||||
head.appendChild(style);
|
||||
}
|
||||
less.registerStylesheetsImmediately();
|
||||
less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);
|
||||
}
|
||||
//# sourceMappingURL=bootstrap.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/less-browser/bootstrap.js"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,oFAAqD;AACrD,sFAAsD;AACtD,0DAA2B;AAE3B,IAAM,OAAO,GAAG,IAAA,yBAAc,GAAE,CAAC;AAEjC,IAAI,MAAM,CAAC,IAAI,EAAE;IACb,KAAK,IAAM,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;YACxD,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACnC;KACJ;CACJ;AACD,IAAA,6BAAiB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEnC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AAExC,IAAI,MAAM,CAAC,YAAY,EAAE;IACrB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;CACjE;AAED,IAAM,IAAI,GAAG,IAAA,eAAI,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnC,kBAAe,IAAI,CAAC;AAEpB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;AAEnB,IAAI,GAAG,CAAC;AACR,IAAI,IAAI,CAAC;AACT,IAAI,KAAK,CAAC;AAEV,iCAAiC;AACjC,SAAS,eAAe,CAAC,IAAI;IACzB,IAAI,IAAI,CAAC,QAAQ,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACtB;IACD,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;AACL,CAAC;AAED,IAAI,OAAO,CAAC,OAAO,EAAE;IACjB,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;QACrC,IAAI,CAAC,KAAK,EAAE,CAAC;KAChB;IACD,mEAAmE;IACnE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;QAChB,GAAG,GAAG,mCAAmC,CAAC;QAC1C,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACjE,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAExC,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC;QACxB,IAAI,KAAK,CAAC,UAAU,EAAE;YAClB,KAAK,CAAC,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;SAClC;aAAM;YACH,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;SACnD;QAED,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAC3B;IACD,IAAI,CAAC,8BAA8B,EAAE,CAAC;IACtC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;CAC3G","sourcesContent":["/**\n * Kicks off less and compiles any stylesheets\n * used in the browser distributed version of less\n * to kick-start less using the browser api\n */\nimport defaultOptions from '../less/default-options';\nimport addDefaultOptions from './add-default-options';\nimport root from './index';\n\nconst options = defaultOptions();\n\nif (window.less) {\n for (const key in window.less) {\n if (Object.prototype.hasOwnProperty.call(window.less, key)) {\n options[key] = window.less[key];\n }\n }\n}\naddDefaultOptions(window, options);\n\noptions.plugins = options.plugins || [];\n\nif (window.LESS_PLUGINS) {\n options.plugins = options.plugins.concat(window.LESS_PLUGINS);\n}\n\nconst less = root(window, options);\nexport default less;\n\nwindow.less = less;\n\nlet css;\nlet head;\nlet style;\n\n// Always restore page visibility\nfunction resolveOrReject(data) {\n if (data.filename) {\n console.warn(data);\n }\n if (!options.async) {\n head.removeChild(style);\n }\n}\n\nif (options.onReady) {\n if (/!watch/.test(window.location.hash)) {\n less.watch();\n }\n // Simulate synchronous stylesheet loading by hiding page rendering\n if (!options.async) {\n css = 'body { display: none !important }';\n head = document.head || document.getElementsByTagName('head')[0];\n style = document.createElement('style');\n\n style.type = 'text/css';\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n\n head.appendChild(style);\n }\n less.registerStylesheetsImmediately();\n less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject);\n}\n"]}
|
||||
+24
-21
@@ -1,62 +1,65 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var utils = tslib_1.__importStar(require("./utils"));
|
||||
exports.default = {
|
||||
import * as utils from './utils.js';
|
||||
|
||||
export default {
|
||||
createCSS: function (document, styles, sheet) {
|
||||
// Strip the query-string
|
||||
var href = sheet.href || '';
|
||||
const href = sheet.href || '';
|
||||
|
||||
// If there is no title set, use the filename, minus the extension
|
||||
var id = "less:".concat(sheet.title || utils.extractId(href));
|
||||
const id = `less:${sheet.title || utils.extractId(href)}`;
|
||||
|
||||
// If this has already been inserted into the DOM, we may need to replace it
|
||||
var oldStyleNode = document.getElementById(id);
|
||||
var keepOldStyleNode = false;
|
||||
const oldStyleNode = document.getElementById(id);
|
||||
let keepOldStyleNode = false;
|
||||
|
||||
// Create a new stylesheet node for insertion or (if necessary) replacement
|
||||
var styleNode = document.createElement('style');
|
||||
const styleNode = document.createElement('style');
|
||||
styleNode.setAttribute('type', 'text/css');
|
||||
if (sheet.media) {
|
||||
styleNode.setAttribute('media', sheet.media);
|
||||
}
|
||||
styleNode.id = id;
|
||||
|
||||
if (!styleNode.styleSheet) {
|
||||
styleNode.appendChild(document.createTextNode(styles));
|
||||
|
||||
// If new contents match contents of oldStyleNode, don't replace oldStyleNode
|
||||
keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 &&
|
||||
oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);
|
||||
}
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
// If there is no oldStyleNode, just append; otherwise, only append if we need
|
||||
// to replace oldStyleNode with an updated stylesheet
|
||||
if (oldStyleNode === null || keepOldStyleNode === false) {
|
||||
var nextEl = sheet && sheet.nextSibling || null;
|
||||
const nextEl = sheet && sheet.nextSibling || null;
|
||||
if (nextEl) {
|
||||
nextEl.parentNode.insertBefore(styleNode, nextEl);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
head.appendChild(styleNode);
|
||||
}
|
||||
}
|
||||
if (oldStyleNode && keepOldStyleNode === false) {
|
||||
oldStyleNode.parentNode.removeChild(oldStyleNode);
|
||||
}
|
||||
|
||||
// For IE.
|
||||
// This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.
|
||||
// See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head
|
||||
if (styleNode.styleSheet) {
|
||||
try {
|
||||
styleNode.styleSheet.cssText = styles;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
throw new Error('Couldn\'t reassign styleSheet.cssText.');
|
||||
}
|
||||
}
|
||||
},
|
||||
currentScript: function (window) {
|
||||
var document = window.document;
|
||||
return document.currentScript || (function () {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
currentScript: function(window) {
|
||||
const document = window.document;
|
||||
return document.currentScript || (() => {
|
||||
const scripts = document.getElementsByTagName('script');
|
||||
return scripts[scripts.length - 1];
|
||||
})();
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=browser.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/less-browser/browser.js"],"names":[],"mappings":";;;AAAA,qDAAiC;AAEjC,kBAAe;IACX,SAAS,EAAE,UAAU,QAAQ,EAAE,MAAM,EAAE,KAAK;QACxC,yBAAyB;QACzB,IAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;QAE9B,kEAAkE;QAClE,IAAM,EAAE,GAAG,eAAQ,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAE,CAAC;QAE1D,4EAA4E;QAC5E,IAAM,YAAY,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACjD,IAAI,gBAAgB,GAAG,KAAK,CAAC;QAE7B,2EAA2E;QAC3E,IAAM,SAAS,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAClD,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC3C,IAAI,KAAK,CAAC,KAAK,EAAE;YACb,SAAS,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;SAChD;QACD,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;QAElB,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE;YACvB,SAAS,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;YAEvD,6EAA6E;YAC7E,gBAAgB,GAAG,CAAC,YAAY,KAAK,IAAI,IAAI,YAAY,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC;gBAC9G,YAAY,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAC7E;QAED,IAAM,IAAI,GAAG,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtD,8EAA8E;QAC9E,qDAAqD;QACrD,IAAI,YAAY,KAAK,IAAI,IAAI,gBAAgB,KAAK,KAAK,EAAE;YACrD,IAAM,MAAM,GAAG,KAAK,IAAI,KAAK,CAAC,WAAW,IAAI,IAAI,CAAC;YAClD,IAAI,MAAM,EAAE;gBACR,MAAM,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;aACrD;iBAAM;gBACH,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;aAC/B;SACJ;QACD,IAAI,YAAY,IAAI,gBAAgB,KAAK,KAAK,EAAE;YAC5C,YAAY,CAAC,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;SACrD;QAED,UAAU;QACV,sGAAsG;QACtG,mJAAmJ;QACnJ,IAAI,SAAS,CAAC,UAAU,EAAE;YACtB,IAAI;gBACA,SAAS,CAAC,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;aACzC;YAAC,OAAO,CAAC,EAAE;gBACR,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;aAC7D;SACJ;IACL,CAAC;IACD,aAAa,EAAE,UAAS,MAAM;QAC1B,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACjC,OAAO,QAAQ,CAAC,aAAa,IAAI,CAAC;YAC9B,IAAM,OAAO,GAAG,QAAQ,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YACxD,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvC,CAAC,CAAC,EAAE,CAAC;IACT,CAAC;CACJ,CAAC","sourcesContent":["import * as utils from './utils';\n\nexport default {\n createCSS: function (document, styles, sheet) {\n // Strip the query-string\n const href = sheet.href || '';\n\n // If there is no title set, use the filename, minus the extension\n const id = `less:${sheet.title || utils.extractId(href)}`;\n\n // If this has already been inserted into the DOM, we may need to replace it\n const oldStyleNode = document.getElementById(id);\n let keepOldStyleNode = false;\n\n // Create a new stylesheet node for insertion or (if necessary) replacement\n const styleNode = document.createElement('style');\n styleNode.setAttribute('type', 'text/css');\n if (sheet.media) {\n styleNode.setAttribute('media', sheet.media);\n }\n styleNode.id = id;\n\n if (!styleNode.styleSheet) {\n styleNode.appendChild(document.createTextNode(styles));\n\n // If new contents match contents of oldStyleNode, don't replace oldStyleNode\n keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 &&\n oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue);\n }\n\n const head = document.getElementsByTagName('head')[0];\n\n // If there is no oldStyleNode, just append; otherwise, only append if we need\n // to replace oldStyleNode with an updated stylesheet\n if (oldStyleNode === null || keepOldStyleNode === false) {\n const nextEl = sheet && sheet.nextSibling || null;\n if (nextEl) {\n nextEl.parentNode.insertBefore(styleNode, nextEl);\n } else {\n head.appendChild(styleNode);\n }\n }\n if (oldStyleNode && keepOldStyleNode === false) {\n oldStyleNode.parentNode.removeChild(oldStyleNode);\n }\n\n // For IE.\n // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.\n // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head\n if (styleNode.styleSheet) {\n try {\n styleNode.styleSheet.cssText = styles;\n } catch (e) {\n throw new Error('Couldn\\'t reassign styleSheet.cssText.');\n }\n }\n },\n currentScript: function(window) {\n const document = window.document;\n return document.currentScript || (() => {\n const scripts = document.getElementsByTagName('script');\n return scripts[scripts.length - 1];\n })();\n }\n};\n"]}
|
||||
+17
-19
@@ -1,37 +1,36 @@
|
||||
"use strict";
|
||||
// Cache system is a bit outdated and could do with work
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = (function (window, options, logger) {
|
||||
var cache = null;
|
||||
|
||||
export default (window, options, logger) => {
|
||||
let cache = null;
|
||||
if (options.env !== 'development') {
|
||||
try {
|
||||
cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;
|
||||
}
|
||||
catch (_) { }
|
||||
} catch (_) {}
|
||||
}
|
||||
return {
|
||||
setCSS: function (path, lastModified, modifyVars, styles) {
|
||||
setCSS: function(path, lastModified, modifyVars, styles) {
|
||||
if (cache) {
|
||||
logger.info("saving ".concat(path, " to cache."));
|
||||
logger.info(`saving ${path} to cache.`);
|
||||
try {
|
||||
cache.setItem(path, styles);
|
||||
cache.setItem("".concat(path, ":timestamp"), lastModified);
|
||||
cache.setItem(`${path}:timestamp`, lastModified);
|
||||
if (modifyVars) {
|
||||
cache.setItem("".concat(path, ":vars"), JSON.stringify(modifyVars));
|
||||
cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
// TODO - could do with adding more robust error handling
|
||||
logger.error("failed to save \"".concat(path, "\" to local storage for caching."));
|
||||
logger.error(`failed to save "${path}" to local storage for caching.`);
|
||||
}
|
||||
}
|
||||
},
|
||||
getCSS: function (path, webInfo, modifyVars) {
|
||||
var css = cache && cache.getItem(path);
|
||||
var timestamp = cache && cache.getItem("".concat(path, ":timestamp"));
|
||||
var vars = cache && cache.getItem("".concat(path, ":vars"));
|
||||
getCSS: function(path, webInfo, modifyVars) {
|
||||
const css = cache && cache.getItem(path);
|
||||
const timestamp = cache && cache.getItem(`${path}:timestamp`);
|
||||
let vars = cache && cache.getItem(`${path}:vars`);
|
||||
|
||||
modifyVars = modifyVars || {};
|
||||
vars = vars || '{}'; // if not set, treat as the JSON representation of an empty object
|
||||
|
||||
if (timestamp && webInfo.lastModified &&
|
||||
(new Date(webInfo.lastModified).valueOf() ===
|
||||
new Date(timestamp).valueOf()) &&
|
||||
@@ -41,5 +40,4 @@ exports.default = (function (window, options, logger) {
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=cache.js.map
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/less-browser/cache.js"],"names":[],"mappings":";AAAA,wDAAwD;;AAExD,mBAAe,UAAC,MAAM,EAAE,OAAO,EAAE,MAAM;IACnC,IAAI,KAAK,GAAG,IAAI,CAAC;IACjB,IAAI,OAAO,CAAC,GAAG,KAAK,aAAa,EAAE;QAC/B,IAAI;YACA,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;SACrF;QAAC,OAAO,CAAC,EAAE,GAAE;KACjB;IACD,OAAO;QACH,MAAM,EAAE,UAAS,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM;YACnD,IAAI,KAAK,EAAE;gBACP,MAAM,CAAC,IAAI,CAAC,iBAAU,IAAI,eAAY,CAAC,CAAC;gBACxC,IAAI;oBACA,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;oBAC5B,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,eAAY,EAAE,YAAY,CAAC,CAAC;oBACjD,IAAI,UAAU,EAAE;wBACZ,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,UAAO,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;qBAC7D;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,yDAAyD;oBACzD,MAAM,CAAC,KAAK,CAAC,2BAAmB,IAAI,qCAAiC,CAAC,CAAC;iBAC1E;aACJ;QACL,CAAC;QACD,MAAM,EAAE,UAAS,IAAI,EAAE,OAAO,EAAE,UAAU;YACtC,IAAM,GAAG,GAAS,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC/C,IAAM,SAAS,GAAG,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,eAAY,CAAC,CAAC;YAC9D,IAAI,IAAI,GAAQ,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,UAAG,IAAI,UAAO,CAAC,CAAC;YAEvD,UAAU,GAAG,UAAU,IAAI,EAAE,CAAC;YAC9B,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC,CAAC,kEAAkE;YAEvF,IAAI,SAAS,IAAI,OAAO,CAAC,YAAY;gBACjC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE;oBACrC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC;gBAClC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;gBACrC,iBAAiB;gBACjB,OAAO,GAAG,CAAC;aACd;QACL,CAAC;KACJ,CAAC;AACN,CAAC,EAAC","sourcesContent":["// Cache system is a bit outdated and could do with work\n\nexport default (window, options, logger) => {\n let cache = null;\n if (options.env !== 'development') {\n try {\n cache = (typeof window.localStorage === 'undefined') ? null : window.localStorage;\n } catch (_) {}\n }\n return {\n setCSS: function(path, lastModified, modifyVars, styles) {\n if (cache) {\n logger.info(`saving ${path} to cache.`);\n try {\n cache.setItem(path, styles);\n cache.setItem(`${path}:timestamp`, lastModified);\n if (modifyVars) {\n cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));\n }\n } catch (e) {\n // TODO - could do with adding more robust error handling\n logger.error(`failed to save \"${path}\" to local storage for caching.`);\n }\n }\n },\n getCSS: function(path, webInfo, modifyVars) {\n const css = cache && cache.getItem(path);\n const timestamp = cache && cache.getItem(`${path}:timestamp`);\n let vars = cache && cache.getItem(`${path}:vars`);\n\n modifyVars = modifyVars || {};\n vars = vars || '{}'; // if not set, treat as the JSON representation of an empty object\n\n if (timestamp && webInfo.lastModified &&\n (new Date(webInfo.lastModified).valueOf() ===\n new Date(timestamp).valueOf()) &&\n JSON.stringify(modifyVars) === vars) {\n // Use local copy\n return css;\n }\n }\n };\n};\n"]}
|
||||
+52
-44
@@ -1,41 +1,45 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var utils = tslib_1.__importStar(require("./utils"));
|
||||
var browser_1 = tslib_1.__importDefault(require("./browser"));
|
||||
exports.default = (function (window, less, options) {
|
||||
import * as utils from './utils.js';
|
||||
import browser from './browser.js';
|
||||
|
||||
export default (window, less, options) => {
|
||||
|
||||
function errorHTML(e, rootHref) {
|
||||
var id = "less-error-message:".concat(utils.extractId(rootHref || ''));
|
||||
var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
|
||||
var elem = window.document.createElement('div');
|
||||
var timer;
|
||||
var content;
|
||||
var errors = [];
|
||||
var filename = e.filename || rootHref;
|
||||
var filenameNoPath = filename.match(/([^/]+(\?.*)?)$/)[1];
|
||||
elem.id = id;
|
||||
const id = `less-error-message:${utils.extractId(rootHref || '')}`;
|
||||
const template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
|
||||
const elem = window.document.createElement('div');
|
||||
let timer;
|
||||
let content;
|
||||
const errors = [];
|
||||
const filename = e.filename || rootHref;
|
||||
const filenameNoPath = filename.match(/([^/]+(\?.*)?)$/)[1];
|
||||
|
||||
elem.id = id;
|
||||
elem.className = 'less-error-message';
|
||||
content = "<h3>".concat(e.type || 'Syntax', "Error: ").concat(e.message || 'There is an error in your .less file') +
|
||||
"</h3><p>in <a href=\"".concat(filename, "\">").concat(filenameNoPath, "</a> ");
|
||||
var errorline = function (e, i, classname) {
|
||||
|
||||
content = `<h3>${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'}` +
|
||||
`</h3><p>in <a href="${filename}">${filenameNoPath}</a> `;
|
||||
|
||||
const errorline = (e, i, classname) => {
|
||||
if (e.extract[i] !== undefined) {
|
||||
errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1))
|
||||
.replace(/\{class\}/, classname)
|
||||
.replace(/\{content\}/, e.extract[i]));
|
||||
}
|
||||
};
|
||||
|
||||
if (e.line) {
|
||||
errorline(e, 0, '');
|
||||
errorline(e, 1, 'line');
|
||||
errorline(e, 2, '');
|
||||
content += "on line ".concat(e.line, ", column ").concat(e.column + 1, ":</p><ul>").concat(errors.join(''), "</ul>");
|
||||
content += `on line ${e.line}, column ${e.column + 1}:</p><ul>${errors.join('')}</ul>`;
|
||||
}
|
||||
if (e.stack && (e.extract || options.logLevel >= 4)) {
|
||||
content += "<br/>Stack Trace</br />".concat(e.stack.split('\n').slice(1).join('<br/>'));
|
||||
content += `<br/>Stack Trace</br />${e.stack.split('\n').slice(1).join('<br/>')}`;
|
||||
}
|
||||
elem.innerHTML = content;
|
||||
|
||||
// CSS for error messages
|
||||
browser_1.default.createCSS(window.document, [
|
||||
browser.createCSS(window.document, [
|
||||
'.less-error-message ul, .less-error-message li {',
|
||||
'list-style-type: none;',
|
||||
'margin-right: 15px;',
|
||||
@@ -73,6 +77,7 @@ exports.default = (function (window, less, options) {
|
||||
'border-bottom: 1px dashed red;',
|
||||
'}'
|
||||
].join('\n'), { title: 'error-message' });
|
||||
|
||||
elem.style.cssText = [
|
||||
'font-family: Arial, sans-serif',
|
||||
'border: 1px solid #e00',
|
||||
@@ -84,15 +89,15 @@ exports.default = (function (window, less, options) {
|
||||
'padding: 15px',
|
||||
'margin-bottom: 15px'
|
||||
].join(';');
|
||||
|
||||
if (options.env === 'development') {
|
||||
timer = setInterval(function () {
|
||||
var document = window.document;
|
||||
var body = document.body;
|
||||
timer = setInterval(() => {
|
||||
const document = window.document;
|
||||
const body = document.body;
|
||||
if (body) {
|
||||
if (document.getElementById(id)) {
|
||||
body.replaceChild(elem, document.getElementById(id));
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
body.insertBefore(elem, body.firstChild);
|
||||
}
|
||||
clearInterval(timer);
|
||||
@@ -100,63 +105,66 @@ exports.default = (function (window, less, options) {
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function removeErrorHTML(path) {
|
||||
var node = window.document.getElementById("less-error-message:".concat(utils.extractId(path)));
|
||||
const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);
|
||||
if (node) {
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
function removeErrorConsole() {
|
||||
// no action
|
||||
}
|
||||
|
||||
function removeError(path) {
|
||||
if (!options.errorReporting || options.errorReporting === 'html') {
|
||||
removeErrorHTML(path);
|
||||
}
|
||||
else if (options.errorReporting === 'console') {
|
||||
} else if (options.errorReporting === 'console') {
|
||||
removeErrorConsole(path);
|
||||
}
|
||||
else if (typeof options.errorReporting === 'function') {
|
||||
} else if (typeof options.errorReporting === 'function') {
|
||||
options.errorReporting('remove', path);
|
||||
}
|
||||
}
|
||||
|
||||
function errorConsole(e, rootHref) {
|
||||
var template = '{line} {content}';
|
||||
var filename = e.filename || rootHref;
|
||||
var errors = [];
|
||||
var content = "".concat(e.type || 'Syntax', "Error: ").concat(e.message || 'There is an error in your .less file', " in ").concat(filename);
|
||||
var errorline = function (e, i, classname) {
|
||||
const template = '{line} {content}';
|
||||
const filename = e.filename || rootHref;
|
||||
const errors = [];
|
||||
let content = `${e.type || 'Syntax'}Error: ${e.message || 'There is an error in your .less file'} in ${filename}`;
|
||||
|
||||
const errorline = (e, i, classname) => {
|
||||
if (e.extract[i] !== undefined) {
|
||||
errors.push(template.replace(/\{line\}/, (parseInt(e.line, 10) || 0) + (i - 1))
|
||||
.replace(/\{class\}/, classname)
|
||||
.replace(/\{content\}/, e.extract[i]));
|
||||
}
|
||||
};
|
||||
|
||||
if (e.line) {
|
||||
errorline(e, 0, '');
|
||||
errorline(e, 1, 'line');
|
||||
errorline(e, 2, '');
|
||||
content += " on line ".concat(e.line, ", column ").concat(e.column + 1, ":\n").concat(errors.join('\n'));
|
||||
content += ` on line ${e.line}, column ${e.column + 1}:\n${errors.join('\n')}`;
|
||||
}
|
||||
if (e.stack && (e.extract || options.logLevel >= 4)) {
|
||||
content += "\nStack Trace\n".concat(e.stack);
|
||||
content += `\nStack Trace\n${e.stack}`;
|
||||
}
|
||||
less.logger.error(content);
|
||||
}
|
||||
|
||||
function error(e, rootHref) {
|
||||
if (!options.errorReporting || options.errorReporting === 'html') {
|
||||
errorHTML(e, rootHref);
|
||||
}
|
||||
else if (options.errorReporting === 'console') {
|
||||
} else if (options.errorReporting === 'console') {
|
||||
errorConsole(e, rootHref);
|
||||
}
|
||||
else if (typeof options.errorReporting === 'function') {
|
||||
} else if (typeof options.errorReporting === 'function') {
|
||||
options.errorReporting('add', e, rootHref);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
add: error,
|
||||
remove: removeError
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=error-reporting.js.map
|
||||
};
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+52
-42
@@ -1,102 +1,112 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js"));
|
||||
var options;
|
||||
var logger;
|
||||
var fileCache = {};
|
||||
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
|
||||
|
||||
let options;
|
||||
let logger;
|
||||
let fileCache = {};
|
||||
|
||||
// TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
|
||||
var FileManager = function () { };
|
||||
FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), {
|
||||
alwaysMakePathsAbsolute: function () {
|
||||
const FileManager = function() {}
|
||||
FileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||
alwaysMakePathsAbsolute() {
|
||||
return true;
|
||||
},
|
||||
join: function (basePath, laterPath) {
|
||||
|
||||
join(basePath, laterPath) {
|
||||
if (!basePath) {
|
||||
return laterPath;
|
||||
}
|
||||
return this.extractUrlParts(laterPath, basePath).path;
|
||||
},
|
||||
doXHR: function (url, type, callback, errback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
var async = options.isFileProtocol ? options.fileAsync : true;
|
||||
|
||||
doXHR(url, type, callback, errback) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
const async = options.isFileProtocol ? options.fileAsync : true;
|
||||
|
||||
if (typeof xhr.overrideMimeType === 'function') {
|
||||
xhr.overrideMimeType('text/css');
|
||||
}
|
||||
logger.debug("XHR: Getting '".concat(url, "'"));
|
||||
logger.debug(`XHR: Getting '${url}'`);
|
||||
xhr.open('GET', url, async);
|
||||
xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
|
||||
xhr.send(null);
|
||||
|
||||
function handleResponse(xhr, callback, errback) {
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
callback(xhr.responseText, xhr.getResponseHeader('Last-Modified'));
|
||||
}
|
||||
else if (typeof errback === 'function') {
|
||||
callback(xhr.responseText,
|
||||
xhr.getResponseHeader('Last-Modified'));
|
||||
} else if (typeof errback === 'function') {
|
||||
errback(xhr.status, url);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.isFileProtocol && !options.fileAsync) {
|
||||
if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
|
||||
callback(xhr.responseText);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
errback(xhr.status, url);
|
||||
}
|
||||
}
|
||||
else if (async) {
|
||||
xhr.onreadystatechange = function () {
|
||||
} else if (async) {
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState == 4) {
|
||||
handleResponse(xhr, callback, errback);
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
handleResponse(xhr, callback, errback);
|
||||
}
|
||||
},
|
||||
supports: function () {
|
||||
|
||||
supports() {
|
||||
return true;
|
||||
},
|
||||
clearFileCache: function () {
|
||||
|
||||
clearFileCache() {
|
||||
fileCache = {};
|
||||
},
|
||||
loadFile: function (filename, currentDirectory, options) {
|
||||
|
||||
loadFile(filename, currentDirectory, options) {
|
||||
// TODO: Add prefix support like less-node?
|
||||
// What about multiple paths?
|
||||
|
||||
if (currentDirectory && !this.isPathAbsolute(filename)) {
|
||||
filename = currentDirectory + filename;
|
||||
}
|
||||
|
||||
filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// sheet may be set to the stylesheet for the initial load or a collection of properties including
|
||||
// some context variables for imports
|
||||
var hrefParts = this.extractUrlParts(filename, window.location.href);
|
||||
var href = hrefParts.url;
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
const hrefParts = this.extractUrlParts(filename, window.location.href);
|
||||
const href = hrefParts.url;
|
||||
const self = this;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
if (options.useFileCache && fileCache[href]) {
|
||||
try {
|
||||
var lessText = fileCache[href];
|
||||
return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() } });
|
||||
}
|
||||
catch (e) {
|
||||
return reject({ filename: href, message: "Error loading file ".concat(href, " error was ").concat(e.message) });
|
||||
const lessText = fileCache[href];
|
||||
return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }});
|
||||
} catch (e) {
|
||||
return reject({ filename: href, message: `Error loading file ${href} error was ${e.message}` });
|
||||
}
|
||||
}
|
||||
|
||||
self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) {
|
||||
// per file cache
|
||||
fileCache[href] = data;
|
||||
|
||||
// Use remote copy (re-parse)
|
||||
resolve({ contents: data, filename: href, webInfo: { lastModified: lastModified } });
|
||||
resolve({ contents: data, filename: href, webInfo: { lastModified }});
|
||||
}, function doXHRError(status, url) {
|
||||
reject({ type: 'File', message: "'".concat(url, "' wasn't found (").concat(status, ")"), href: href });
|
||||
reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
exports.default = (function (opts, log) {
|
||||
|
||||
export default (opts, log) => {
|
||||
options = opts;
|
||||
logger = log;
|
||||
return FileManager;
|
||||
});
|
||||
//# sourceMappingURL=file-manager.js.map
|
||||
}
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+12
-12
@@ -1,28 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var function_registry_1 = tslib_1.__importDefault(require("./../less/functions/function-registry"));
|
||||
exports.default = (function () {
|
||||
|
||||
import functionRegistry from './../less/functions/function-registry.js';
|
||||
|
||||
export default () => {
|
||||
function imageSize() {
|
||||
throw {
|
||||
type: 'Runtime',
|
||||
message: 'Image size functions are not supported in browser version of less'
|
||||
};
|
||||
}
|
||||
var imageFunctions = {
|
||||
'image-size': function (filePathNode) {
|
||||
|
||||
const imageFunctions = {
|
||||
'image-size': function(filePathNode) {
|
||||
imageSize(this, filePathNode);
|
||||
return -1;
|
||||
},
|
||||
'image-width': function (filePathNode) {
|
||||
'image-width': function(filePathNode) {
|
||||
imageSize(this, filePathNode);
|
||||
return -1;
|
||||
},
|
||||
'image-height': function (filePathNode) {
|
||||
'image-height': function(filePathNode) {
|
||||
imageSize(this, filePathNode);
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
function_registry_1.default.addMultiple(imageFunctions);
|
||||
});
|
||||
//# sourceMappingURL=image-size.js.map
|
||||
|
||||
functionRegistry.addMultiple(imageFunctions);
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"image-size.js","sourceRoot":"","sources":["../../src/less-browser/image-size.js"],"names":[],"mappings":";;;AACA,oGAAqE;AAErE,mBAAe;IACX,SAAS,SAAS;QACd,MAAM;YACF,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,mEAAmE;SAC/E,CAAC;IACN,CAAC;IAED,IAAM,cAAc,GAAG;QACnB,YAAY,EAAE,UAAS,YAAY;YAC/B,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,aAAa,EAAE,UAAS,YAAY;YAChC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;QACD,cAAc,EAAE,UAAS,YAAY;YACjC,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC9B,OAAO,CAAC,CAAC,CAAC;QACd,CAAC;KACJ,CAAC;IAEF,2BAAgB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC,EAAC","sourcesContent":["\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default () => {\n function imageSize() {\n throw {\n type: 'Runtime',\n message: 'Image size functions are not supported in browser version of less'\n };\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-width': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n },\n 'image-height': function(filePathNode) {\n imageSize(this, filePathNode);\n return -1;\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"]}
|
||||
+131
-105
@@ -1,258 +1,284 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
//
|
||||
// index.js
|
||||
// Should expose the additional browser functions on to the less object
|
||||
//
|
||||
var utils_1 = require("./utils");
|
||||
var less_1 = tslib_1.__importDefault(require("../less"));
|
||||
var browser_1 = tslib_1.__importDefault(require("./browser"));
|
||||
var file_manager_1 = tslib_1.__importDefault(require("./file-manager"));
|
||||
var plugin_loader_1 = tslib_1.__importDefault(require("./plugin-loader"));
|
||||
var log_listener_1 = tslib_1.__importDefault(require("./log-listener"));
|
||||
var error_reporting_1 = tslib_1.__importDefault(require("./error-reporting"));
|
||||
var cache_1 = tslib_1.__importDefault(require("./cache"));
|
||||
var image_size_1 = tslib_1.__importDefault(require("./image-size"));
|
||||
exports.default = (function (window, options) {
|
||||
var document = window.document;
|
||||
var less = (0, less_1.default)();
|
||||
import {addDataAttr} from './utils.js';
|
||||
import lessRoot from '../less/index.js';
|
||||
import browser from './browser.js';
|
||||
import FM from './file-manager.js';
|
||||
import PluginLoader from './plugin-loader.js';
|
||||
import LogListener from './log-listener.js';
|
||||
import ErrorReporting from './error-reporting.js';
|
||||
import Cache from './cache.js';
|
||||
import ImageSize from './image-size.js';
|
||||
import pkg from '../../package.json';
|
||||
|
||||
/**
|
||||
* @param {Window} window
|
||||
* @param {Object} options
|
||||
*/
|
||||
export default (window, options) => {
|
||||
const document = window.document;
|
||||
const less = lessRoot(undefined, undefined, pkg.version);
|
||||
|
||||
less.options = options;
|
||||
var environment = less.environment;
|
||||
var FileManager = (0, file_manager_1.default)(options, less.logger);
|
||||
var fileManager = new FileManager();
|
||||
const environment = less.environment;
|
||||
const FileManager = FM(options, less.logger);
|
||||
const fileManager = new FileManager();
|
||||
environment.addFileManager(fileManager);
|
||||
less.FileManager = FileManager;
|
||||
less.PluginLoader = plugin_loader_1.default;
|
||||
(0, log_listener_1.default)(less, options);
|
||||
var errors = (0, error_reporting_1.default)(window, less, options);
|
||||
var cache = less.cache = options.cache || (0, cache_1.default)(window, options, less.logger);
|
||||
(0, image_size_1.default)(less.environment);
|
||||
less.PluginLoader = PluginLoader;
|
||||
|
||||
LogListener(less, options);
|
||||
const errors = ErrorReporting(window, less, options);
|
||||
const cache = less.cache = options.cache || Cache(window, options, less.logger);
|
||||
ImageSize(less.environment);
|
||||
|
||||
// Setup user functions - Deprecate?
|
||||
if (options.functions) {
|
||||
less.functions.functionRegistry.addMultiple(options.functions);
|
||||
}
|
||||
var typePattern = /^text\/(x-)?less$/;
|
||||
|
||||
const typePattern = /^text\/(x-)?less$/;
|
||||
|
||||
function clone(obj) {
|
||||
var cloned = {};
|
||||
for (var prop in obj) {
|
||||
const cloned = {};
|
||||
for (const prop in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
|
||||
cloned[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
return cloned;
|
||||
}
|
||||
// only really needed for phantom
|
||||
function bind(func, thisArg) {
|
||||
var curryArgs = Array.prototype.slice.call(arguments, 2);
|
||||
return function () {
|
||||
var args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
|
||||
return func.apply(thisArg, args);
|
||||
};
|
||||
}
|
||||
|
||||
function loadStyles(modifyVars) {
|
||||
var styles = document.getElementsByTagName('style');
|
||||
var style;
|
||||
for (var i = 0; i < styles.length; i++) {
|
||||
style = styles[i];
|
||||
const styles = document.getElementsByTagName('style');
|
||||
|
||||
for (let style of styles) {
|
||||
if (style.type.match(typePattern)) {
|
||||
var instanceOptions = clone(options);
|
||||
instanceOptions.modifyVars = modifyVars;
|
||||
var lessText = style.innerHTML || '';
|
||||
instanceOptions.filename = document.location.href.replace(/#.*$/, '');
|
||||
const instanceOptions = {
|
||||
...clone(options),
|
||||
modifyVars,
|
||||
filename: document.location.href.replace(/#.*$/, '')
|
||||
}
|
||||
|
||||
const lessText = style.innerHTML || '';
|
||||
|
||||
/* jshint loopfunc:true */
|
||||
// use closure to store current style
|
||||
less.render(lessText, instanceOptions, bind(function (style, e, result) {
|
||||
if (e) {
|
||||
errors.add(e, 'inline');
|
||||
}
|
||||
else {
|
||||
less.render(lessText, instanceOptions, (err, result) => {
|
||||
if (err) {
|
||||
errors.add(err, 'inline');
|
||||
} else {
|
||||
style.type = 'text/css';
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = result.css;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
style.innerHTML = result.css;
|
||||
}
|
||||
}
|
||||
}, null, style));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadStyleSheet(sheet, callback, reload, remaining, modifyVars) {
|
||||
var instanceOptions = clone(options);
|
||||
(0, utils_1.addDataAttr)(instanceOptions, sheet);
|
||||
|
||||
const instanceOptions = clone(options);
|
||||
addDataAttr(instanceOptions, sheet);
|
||||
instanceOptions.mime = sheet.type;
|
||||
|
||||
if (modifyVars) {
|
||||
instanceOptions.modifyVars = modifyVars;
|
||||
}
|
||||
|
||||
function loadInitialFileCallback(loadedFile) {
|
||||
var data = loadedFile.contents;
|
||||
var path = loadedFile.filename;
|
||||
var webInfo = loadedFile.webInfo;
|
||||
var newFileInfo = {
|
||||
const data = loadedFile.contents;
|
||||
const path = loadedFile.filename;
|
||||
const webInfo = loadedFile.webInfo;
|
||||
|
||||
const newFileInfo = {
|
||||
currentDirectory: fileManager.getPath(path),
|
||||
filename: path,
|
||||
rootFilename: path,
|
||||
rewriteUrls: instanceOptions.rewriteUrls
|
||||
};
|
||||
|
||||
newFileInfo.entryPath = newFileInfo.currentDirectory;
|
||||
newFileInfo.rootpath = instanceOptions.rootpath || newFileInfo.currentDirectory;
|
||||
|
||||
if (webInfo) {
|
||||
webInfo.remaining = remaining;
|
||||
var css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);
|
||||
|
||||
const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);
|
||||
if (!reload && css) {
|
||||
webInfo.local = true;
|
||||
callback(null, css, data, sheet, webInfo, path);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO add tests around how this behaves when reloading
|
||||
errors.remove(path);
|
||||
|
||||
instanceOptions.rootFileInfo = newFileInfo;
|
||||
less.render(data, instanceOptions, function (e, result) {
|
||||
less.render(data, instanceOptions, (e, result) => {
|
||||
if (e) {
|
||||
e.href = path;
|
||||
callback(e);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css);
|
||||
callback(null, result.css, data, sheet, webInfo, path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fileManager.loadFile(sheet.href, null, instanceOptions, environment)
|
||||
.then(function (loadedFile) {
|
||||
loadInitialFileCallback(loadedFile);
|
||||
}).catch(function (err) {
|
||||
console.log(err);
|
||||
callback(err);
|
||||
});
|
||||
.then(loadedFile => {
|
||||
loadInitialFileCallback(loadedFile);
|
||||
}).catch(err => {
|
||||
console.log(err);
|
||||
callback(err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function loadStyleSheets(callback, reload, modifyVars) {
|
||||
for (var i = 0; i < less.sheets.length; i++) {
|
||||
for (let i = 0; i < less.sheets.length; i++) {
|
||||
loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1), modifyVars);
|
||||
}
|
||||
}
|
||||
|
||||
function initRunningMode() {
|
||||
if (less.env === 'development') {
|
||||
less.watchTimer = setInterval(function () {
|
||||
less.watchTimer = setInterval(() => {
|
||||
if (less.watchMode) {
|
||||
fileManager.clearFileCache();
|
||||
/**
|
||||
* @todo remove when this is typed with JSDoc
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
||||
loadStyleSheets((e, css, _, sheet, webInfo) => {
|
||||
if (e) {
|
||||
errors.add(e, e.href || sheet.href);
|
||||
}
|
||||
else if (css) {
|
||||
browser_1.default.createCSS(window.document, css, sheet);
|
||||
} else if (css) {
|
||||
browser.createCSS(window.document, css, sheet);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, options.poll);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Watch mode
|
||||
//
|
||||
less.watch = function () {
|
||||
if (!less.watchMode) {
|
||||
if (!less.watchMode ) {
|
||||
less.env = 'development';
|
||||
initRunningMode();
|
||||
}
|
||||
this.watchMode = true;
|
||||
return true;
|
||||
};
|
||||
less.unwatch = function () { clearInterval(less.watchTimer); this.watchMode = false; return false; };
|
||||
|
||||
less.unwatch = function () {clearInterval(less.watchTimer); this.watchMode = false; return false; };
|
||||
|
||||
//
|
||||
// Synchronously get all <link> tags with the 'rel' attribute set to
|
||||
// "stylesheet/less".
|
||||
//
|
||||
less.registerStylesheetsImmediately = function () {
|
||||
var links = document.getElementsByTagName('link');
|
||||
less.registerStylesheetsImmediately = () => {
|
||||
const links = document.getElementsByTagName('link');
|
||||
less.sheets = [];
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
|
||||
(links[i].type.match(typePattern)))) {
|
||||
less.sheets.push(links[i]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Asynchronously get all <link> tags with the 'rel' attribute set to
|
||||
// "stylesheet/less", returning a Promise.
|
||||
//
|
||||
less.registerStylesheets = function () { return new Promise(function (resolve) {
|
||||
less.registerStylesheets = () => new Promise((resolve) => {
|
||||
less.registerStylesheetsImmediately();
|
||||
resolve();
|
||||
}); };
|
||||
});
|
||||
|
||||
//
|
||||
// With this function, it's possible to alter variables and re-render
|
||||
// CSS without reloading less-files
|
||||
//
|
||||
less.modifyVars = function (record) { return less.refresh(true, record, false); };
|
||||
less.refresh = function (reload, modifyVars, clearFileCache) {
|
||||
less.modifyVars = record => less.refresh(true, record, false);
|
||||
|
||||
less.refresh = (reload, modifyVars, clearFileCache) => {
|
||||
if ((reload || clearFileCache) && clearFileCache !== false) {
|
||||
fileManager.clearFileCache();
|
||||
}
|
||||
return new Promise(function (resolve, reject) {
|
||||
var startTime;
|
||||
var endTime;
|
||||
var totalMilliseconds;
|
||||
var remainingSheets;
|
||||
return new Promise((resolve, reject) => {
|
||||
let startTime;
|
||||
let endTime;
|
||||
let totalMilliseconds;
|
||||
let remainingSheets;
|
||||
startTime = endTime = new Date();
|
||||
|
||||
// Set counter for remaining unprocessed sheets
|
||||
remainingSheets = less.sheets.length;
|
||||
|
||||
if (remainingSheets === 0) {
|
||||
|
||||
endTime = new Date();
|
||||
totalMilliseconds = endTime - startTime;
|
||||
less.logger.info('Less has finished and no sheets were loaded.');
|
||||
resolve({
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
totalMilliseconds: totalMilliseconds,
|
||||
startTime,
|
||||
endTime,
|
||||
totalMilliseconds,
|
||||
sheets: less.sheets.length
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
// Relies on less.sheets array, callback seems to be guaranteed to be called for every element of the array
|
||||
loadStyleSheets(function (e, css, _, sheet, webInfo) {
|
||||
loadStyleSheets((e, css, _, sheet, webInfo) => {
|
||||
if (e) {
|
||||
errors.add(e, e.href || sheet.href);
|
||||
reject(e);
|
||||
return;
|
||||
}
|
||||
if (webInfo.local) {
|
||||
less.logger.info("Loading ".concat(sheet.href, " from cache."));
|
||||
less.logger.info(`Loading ${sheet.href} from cache.`);
|
||||
} else {
|
||||
less.logger.info(`Rendered ${sheet.href} successfully.`);
|
||||
}
|
||||
else {
|
||||
less.logger.info("Rendered ".concat(sheet.href, " successfully."));
|
||||
}
|
||||
browser_1.default.createCSS(window.document, css, sheet);
|
||||
less.logger.info("CSS for ".concat(sheet.href, " generated in ").concat(new Date() - endTime, "ms"));
|
||||
browser.createCSS(window.document, css, sheet);
|
||||
less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`);
|
||||
|
||||
// Count completed sheet
|
||||
remainingSheets--;
|
||||
|
||||
// Check if the last remaining sheet was processed and then call the promise
|
||||
if (remainingSheets === 0) {
|
||||
totalMilliseconds = new Date() - startTime;
|
||||
less.logger.info("Less has finished. CSS generated in ".concat(totalMilliseconds, "ms"));
|
||||
less.logger.info(`Less has finished. CSS generated in ${totalMilliseconds}ms`);
|
||||
resolve({
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
totalMilliseconds: totalMilliseconds,
|
||||
startTime,
|
||||
endTime,
|
||||
totalMilliseconds,
|
||||
sheets: less.sheets.length
|
||||
});
|
||||
}
|
||||
endTime = new Date();
|
||||
}, reload, modifyVars);
|
||||
}
|
||||
|
||||
loadStyles(modifyVars);
|
||||
});
|
||||
};
|
||||
|
||||
less.refreshStyles = loadStyles;
|
||||
return less;
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
};
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+30
-31
@@ -1,43 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = (function (less, options) {
|
||||
var logLevel_debug = 4;
|
||||
var logLevel_info = 3;
|
||||
var logLevel_warn = 2;
|
||||
var logLevel_error = 1;
|
||||
export default (less, options) => {
|
||||
const logLevel_debug = 4;
|
||||
const logLevel_info = 3;
|
||||
const logLevel_warn = 2;
|
||||
const logLevel_error = 1;
|
||||
|
||||
// The amount of logging in the javascript console.
|
||||
// 3 - Debug, information and errors
|
||||
// 2 - Information and errors
|
||||
// 1 - Errors
|
||||
// 0 - None
|
||||
// Defaults to 2
|
||||
options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);
|
||||
options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);
|
||||
|
||||
if (!options.loggers) {
|
||||
options.loggers = [{
|
||||
debug: function (msg) {
|
||||
if (options.logLevel >= logLevel_debug) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
info: function (msg) {
|
||||
if (options.logLevel >= logLevel_info) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
warn: function (msg) {
|
||||
if (options.logLevel >= logLevel_warn) {
|
||||
console.warn(msg);
|
||||
}
|
||||
},
|
||||
error: function (msg) {
|
||||
if (options.logLevel >= logLevel_error) {
|
||||
console.error(msg);
|
||||
}
|
||||
debug: function(msg) {
|
||||
if (options.logLevel >= logLevel_debug) {
|
||||
console.log(msg);
|
||||
}
|
||||
}];
|
||||
},
|
||||
info: function(msg) {
|
||||
if (options.logLevel >= logLevel_info) {
|
||||
console.log(msg);
|
||||
}
|
||||
},
|
||||
warn: function(msg) {
|
||||
if (options.logLevel >= logLevel_warn) {
|
||||
console.warn(msg);
|
||||
}
|
||||
},
|
||||
error: function(msg) {
|
||||
if (options.logLevel >= logLevel_error) {
|
||||
console.error(msg);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
for (var i = 0; i < options.loggers.length; i++) {
|
||||
for (let i = 0; i < options.loggers.length; i++) {
|
||||
less.logger.addListener(options.loggers[i]);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=log-listener.js.map
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"log-listener.js","sourceRoot":"","sources":["../../src/less-browser/log-listener.js"],"names":[],"mappings":";;AAAA,mBAAe,UAAC,IAAI,EAAE,OAAO;IACzB,IAAM,cAAc,GAAG,CAAC,CAAC;IACzB,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,aAAa,GAAG,CAAC,CAAC;IACxB,IAAM,cAAc,GAAG,CAAC,CAAC;IAEzB,mDAAmD;IACnD,oCAAoC;IACpC,6BAA6B;IAC7B,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,OAAO,CAAC,QAAQ,GAAG,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,KAAK,aAAa,CAAC,CAAC,CAAE,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IAElJ,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;QAClB,OAAO,CAAC,OAAO,GAAG,CAAC;gBACf,KAAK,EAAE,UAAS,GAAG;oBACf,IAAI,OAAO,CAAC,QAAQ,IAAI,cAAc,EAAE;wBACpC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;qBACpB;gBACL,CAAC;gBACD,IAAI,EAAE,UAAS,GAAG;oBACd,IAAI,OAAO,CAAC,QAAQ,IAAI,aAAa,EAAE;wBACnC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;qBACpB;gBACL,CAAC;gBACD,IAAI,EAAE,UAAS,GAAG;oBACd,IAAI,OAAO,CAAC,QAAQ,IAAI,aAAa,EAAE;wBACnC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;qBACrB;gBACL,CAAC;gBACD,KAAK,EAAE,UAAS,GAAG;oBACf,IAAI,OAAO,CAAC,QAAQ,IAAI,cAAc,EAAE;wBACpC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;qBACtB;gBACL,CAAC;aACJ,CAAC,CAAC;KACN;IACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC7C,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;KAC/C;AACL,CAAC,EAAC","sourcesContent":["export default (less, options) => {\n const logLevel_debug = 4;\n const logLevel_info = 3;\n const logLevel_warn = 2;\n const logLevel_error = 1;\n\n // The amount of logging in the javascript console.\n // 3 - Debug, information and errors\n // 2 - Information and errors\n // 1 - Errors\n // 0 - None\n // Defaults to 2\n options.logLevel = typeof options.logLevel !== 'undefined' ? options.logLevel : (options.env === 'development' ? logLevel_info : logLevel_error);\n\n if (!options.loggers) {\n options.loggers = [{\n debug: function(msg) {\n if (options.logLevel >= logLevel_debug) {\n console.log(msg);\n }\n },\n info: function(msg) {\n if (options.logLevel >= logLevel_info) {\n console.log(msg);\n }\n },\n warn: function(msg) {\n if (options.logLevel >= logLevel_warn) {\n console.warn(msg);\n }\n },\n error: function(msg) {\n if (options.logLevel >= logLevel_error) {\n console.error(msg);\n }\n }\n }];\n }\n for (let i = 0; i < options.loggers.length; i++) {\n less.logger.addListener(options.loggers[i]);\n }\n};\n"]}
|
||||
+10
-10
@@ -1,24 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
/**
|
||||
* @todo Add tests for browser `@plugin`
|
||||
*/
|
||||
var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js"));
|
||||
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
|
||||
|
||||
/**
|
||||
* Browser Plugin Loader
|
||||
*/
|
||||
var PluginLoader = function (less) {
|
||||
const PluginLoader = function(less) {
|
||||
this.less = less;
|
||||
// Should we shim this.require for browser? Probably not?
|
||||
};
|
||||
PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), {
|
||||
loadPlugin: function (filename, basePath, context, environment, fileManager) {
|
||||
return new Promise(function (fulfill, reject) {
|
||||
|
||||
PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {
|
||||
loadPlugin(filename, basePath, context, environment, fileManager) {
|
||||
return new Promise((fulfill, reject) => {
|
||||
fileManager.loadFile(filename, basePath, context, environment)
|
||||
.then(fulfill).catch(reject);
|
||||
});
|
||||
}
|
||||
});
|
||||
exports.default = PluginLoader;
|
||||
//# sourceMappingURL=plugin-loader.js.map
|
||||
|
||||
export default PluginLoader;
|
||||
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../src/less-browser/plugin-loader.js"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,oHAAiF;AAEjF;;GAEG;AACH,IAAM,YAAY,GAAG,UAAS,IAAI;IAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,yDAAyD;AAC7D,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,mCAAoB,EAAE,EAAE;IAC/D,UAAU,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAC5D,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC;iBACzD,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["/**\n * @todo Add tests for browser `@plugin`\n */\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Browser Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n // Should we shim this.require for browser? Probably not?\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment)\n .then(fulfill).catch(reject);\n });\n }\n});\n\nexport default PluginLoader;\n\n"]}
|
||||
+19
-21
@@ -1,32 +1,30 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addDataAttr = exports.extractId = void 0;
|
||||
function extractId(href) {
|
||||
return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain
|
||||
.replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster
|
||||
.replace(/^\//, '') // Remove root /
|
||||
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
|
||||
.replace(/[^.\w-]+/g, '-') // Replace illegal characters
|
||||
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
|
||||
|
||||
/** @param {string} href */
|
||||
export function extractId(href) {
|
||||
return href.replace(/^[a-z-]+:\/+?[^/]+/, '') // Remove protocol & domain
|
||||
.replace(/[?&]livereload=\w+/, '') // Remove LiveReload cachebuster
|
||||
.replace(/^\//, '') // Remove root /
|
||||
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
|
||||
.replace(/[^.\w-]+/g, '-') // Replace illegal characters
|
||||
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
|
||||
}
|
||||
exports.extractId = extractId;
|
||||
function addDataAttr(options, tag) {
|
||||
if (!tag) {
|
||||
return;
|
||||
} // in case of tag is null or undefined
|
||||
for (var opt in tag.dataset) {
|
||||
|
||||
/**
|
||||
* @param {Record<string, *>} options
|
||||
* @param {HTMLElement | null} tag
|
||||
*/
|
||||
export function addDataAttr(options, tag) {
|
||||
if (!tag) {return;} // in case of tag is null or undefined
|
||||
for (const opt in tag.dataset) {
|
||||
if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) {
|
||||
if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {
|
||||
options[opt] = tag.dataset[opt];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
options[opt] = JSON.parse(tag.dataset[opt]);
|
||||
}
|
||||
catch (_) { }
|
||||
catch (_) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.addDataAttr = addDataAttr;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/less-browser/utils.js"],"names":[],"mappings":";;;AACA,SAAgB,SAAS,CAAC,IAAI;IAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAE,2BAA2B;SACrE,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAQ,gCAAgC;SACzE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAyB,gBAAgB;SAC3D,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAgB,0BAA0B;SACrE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAiB,6BAA6B;SACvE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAuB,yCAAyC;AAC7F,CAAC;AAPD,8BAOC;AAED,SAAgB,WAAW,CAAC,OAAO,EAAE,GAAG;IACpC,IAAI,CAAC,GAAG,EAAE;QAAC,OAAO;KAAC,CAAC,sCAAsC;IAC1D,KAAK,IAAM,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE;QAC3B,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;YACxD,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,iBAAiB,IAAI,GAAG,KAAK,UAAU,IAAI,GAAG,KAAK,gBAAgB,EAAE;gBAC9F,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;aACnC;iBAAM;gBACH,IAAI;oBACA,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;iBAC/C;gBACD,OAAO,CAAC,EAAE,GAAE;aACf;SACJ;KACJ;AACL,CAAC;AAdD,kCAcC","sourcesContent":["\nexport function extractId(href) {\n return href.replace(/^[a-z-]+:\\/+?[^/]+/, '') // Remove protocol & domain\n .replace(/[?&]livereload=\\w+/, '') // Remove LiveReload cachebuster\n .replace(/^\\//, '') // Remove root /\n .replace(/\\.[a-zA-Z]+$/, '') // Remove simple extension\n .replace(/[^.\\w-]+/g, '-') // Replace illegal characters\n .replace(/\\./g, ':'); // Replace dots with colons(for valid id)\n}\n\nexport function addDataAttr(options, tag) {\n if (!tag) {return;} // in case of tag is null or undefined\n for (const opt in tag.dataset) {\n if (Object.prototype.hasOwnProperty.call(tag.dataset, opt)) {\n if (opt === 'env' || opt === 'dumpLineNumbers' || opt === 'rootpath' || opt === 'errorReporting') {\n options[opt] = tag.dataset[opt];\n } else {\n try {\n options[opt] = JSON.parse(tag.dataset[opt]);\n }\n catch (_) {}\n }\n }\n }\n}\n"]}
|
||||
+32
-8
@@ -1,19 +1,43 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = {
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
class SourceMapGeneratorFallback {
|
||||
addMapping(){}
|
||||
setSourceContent(){}
|
||||
toJSON(){
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
encodeBase64: function encodeBase64(str) {
|
||||
// Avoid Buffer constructor on newer versions of Node.js.
|
||||
var buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));
|
||||
const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));
|
||||
return buffer.toString('base64');
|
||||
},
|
||||
mimeLookup: function (filename) {
|
||||
return require('mime').lookup(filename);
|
||||
try {
|
||||
const mimeModule = require('mime');
|
||||
return mimeModule ? mimeModule.lookup(filename) : "application/octet-stream";
|
||||
} catch (e) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
},
|
||||
charsetLookup: function (mime) {
|
||||
return require('mime').charsets.lookup(mime);
|
||||
try {
|
||||
const mimeModule = require('mime');
|
||||
return mimeModule ? mimeModule.charsets.lookup(mime) : undefined;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
getSourceMapGenerator: function getSourceMapGenerator() {
|
||||
return require('source-map').SourceMapGenerator;
|
||||
try {
|
||||
const sourceMapModule = require('source-map');
|
||||
return sourceMapModule ? sourceMapModule.SourceMapGenerator : SourceMapGeneratorFallback;
|
||||
} catch (e) {
|
||||
return SourceMapGeneratorFallback;
|
||||
}
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=environment.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../src/less-node/environment.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,YAAY,EAAE,SAAS,YAAY,CAAC,GAAG;QACnC,yDAAyD;QACzD,IAAM,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,UAAU,EAAE,UAAU,QAAQ;QAC1B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5C,CAAC;IACD,aAAa,EAAE,UAAU,IAAI;QACzB,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;IACD,qBAAqB,EAAE,SAAS,qBAAqB;QACjD,OAAO,OAAO,CAAC,YAAY,CAAC,CAAC,kBAAkB,CAAC;IACpD,CAAC;CACJ,CAAC","sourcesContent":["export default {\n encodeBase64: function encodeBase64(str) {\n // Avoid Buffer constructor on newer versions of Node.js.\n const buffer = (Buffer.from ? Buffer.from(str) : (new Buffer(str)));\n return buffer.toString('base64');\n },\n mimeLookup: function (filename) {\n return require('mime').lookup(filename);\n },\n charsetLookup: function (mime) {\n return require('mime').charsets.lookup(mime);\n },\n getSourceMapGenerator: function getSourceMapGenerator() {\n return require('source-map').SourceMapGenerator;\n }\n};\n"]}
|
||||
+62
-45
@@ -1,37 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var path_1 = tslib_1.__importDefault(require("path"));
|
||||
var fs_1 = tslib_1.__importDefault(require("./fs"));
|
||||
var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js"));
|
||||
var FileManager = function () { };
|
||||
FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), {
|
||||
supports: function () {
|
||||
import path from 'path';
|
||||
import { createRequire } from 'module';
|
||||
import fs from './fs.js';
|
||||
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const FileManager = function() {}
|
||||
FileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||
supports() {
|
||||
return true;
|
||||
},
|
||||
supportsSync: function () {
|
||||
|
||||
supportsSync() {
|
||||
return true;
|
||||
},
|
||||
loadFile: function (filename, currentDirectory, options, environment, callback) {
|
||||
var fullFilename;
|
||||
var isAbsoluteFilename = this.isPathAbsolute(filename);
|
||||
var filenamesTried = [];
|
||||
var self = this;
|
||||
var prefix = filename.slice(0, 1);
|
||||
var explicit = prefix === '.' || prefix === '/';
|
||||
var result = null;
|
||||
var isNodeModule = false;
|
||||
var npmPrefix = 'npm://';
|
||||
|
||||
loadFile(filename, currentDirectory, options, environment, callback) {
|
||||
let fullFilename;
|
||||
const isAbsoluteFilename = this.isPathAbsolute(filename);
|
||||
const filenamesTried = [];
|
||||
const self = this;
|
||||
const prefix = filename.slice(0, 1);
|
||||
const explicit = prefix === '.' || prefix === '/';
|
||||
let result = null;
|
||||
let isNodeModule = false;
|
||||
const npmPrefix = 'npm://';
|
||||
|
||||
options = options || {};
|
||||
var paths = isAbsoluteFilename ? [''] : [currentDirectory];
|
||||
if (options.paths) {
|
||||
paths.push.apply(paths, options.paths);
|
||||
}
|
||||
if (!isAbsoluteFilename && paths.indexOf('.') === -1) {
|
||||
paths.push('.');
|
||||
}
|
||||
var prefixes = options.prefixes || [''];
|
||||
var fileParts = this.extractUrlParts(filename);
|
||||
|
||||
const paths = isAbsoluteFilename ? [''] : [currentDirectory];
|
||||
|
||||
if (options.paths) { paths.push.apply(paths, options.paths); }
|
||||
|
||||
if (!isAbsoluteFilename && paths.indexOf('.') === -1) { paths.push('.'); }
|
||||
|
||||
const prefixes = options.prefixes || [''];
|
||||
const fileParts = this.extractUrlParts(filename);
|
||||
|
||||
if (options.syncImport) {
|
||||
getFileData(returnData, returnData);
|
||||
if (callback) {
|
||||
@@ -47,6 +52,7 @@ FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(),
|
||||
// to be closed before it continues with the next file
|
||||
return new Promise(getFileData);
|
||||
}
|
||||
|
||||
function returnData(data) {
|
||||
if (!data.filename) {
|
||||
result = { error: data };
|
||||
@@ -55,10 +61,12 @@ FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(),
|
||||
result = data;
|
||||
}
|
||||
}
|
||||
|
||||
function getFileData(fulfill, reject) {
|
||||
(function tryPathIndex(i) {
|
||||
function tryWithExtension() {
|
||||
var extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
|
||||
const extFilename = options.ext ? self.tryAppendExtension(fullFilename, options.ext) : fullFilename;
|
||||
|
||||
if (extFilename !== fullFilename && !explicit && paths[i] === '.') {
|
||||
try {
|
||||
fullFilename = require.resolve(extFilename);
|
||||
@@ -78,9 +86,16 @@ FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(),
|
||||
if (j < prefixes.length) {
|
||||
isNodeModule = false;
|
||||
fullFilename = fileParts.rawPath + prefixes[j] + fileParts.filename;
|
||||
|
||||
if (paths[i]) {
|
||||
fullFilename = path_1.default.join(paths[i], fullFilename);
|
||||
if (paths[i].startsWith('#')) {
|
||||
// Handling paths starting with '#'
|
||||
fullFilename = paths[i].substr(1) + fullFilename;
|
||||
}else{
|
||||
fullFilename = path.join(paths[i], fullFilename);
|
||||
}
|
||||
}
|
||||
|
||||
if (!explicit && paths[i] === '.') {
|
||||
try {
|
||||
fullFilename = require.resolve(fullFilename);
|
||||
@@ -93,15 +108,16 @@ FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(),
|
||||
}
|
||||
else {
|
||||
tryWithExtension();
|
||||
}
|
||||
var readFileArgs = [fullFilename];
|
||||
}
|
||||
|
||||
const readFileArgs = [fullFilename];
|
||||
if (!options.rawBuffer) {
|
||||
readFileArgs.push('utf-8');
|
||||
}
|
||||
if (options.syncImport) {
|
||||
try {
|
||||
var data = fs_1.default.readFileSync.apply(this, readFileArgs);
|
||||
fulfill({ contents: data, filename: fullFilename });
|
||||
const data = fs.readFileSync.apply(this, readFileArgs);
|
||||
fulfill({ contents: data, filename: fullFilename});
|
||||
}
|
||||
catch (e) {
|
||||
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
|
||||
@@ -109,31 +125,32 @@ FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(),
|
||||
}
|
||||
}
|
||||
else {
|
||||
readFileArgs.push(function (e, data) {
|
||||
readFileArgs.push(function(e, data) {
|
||||
if (e) {
|
||||
filenamesTried.push(isNodeModule ? npmPrefix + fullFilename : fullFilename);
|
||||
return tryPrefix(j + 1);
|
||||
}
|
||||
fulfill({ contents: data, filename: fullFilename });
|
||||
}
|
||||
fulfill({ contents: data, filename: fullFilename});
|
||||
});
|
||||
fs_1.default.readFile.apply(this, readFileArgs);
|
||||
fs.readFile.apply(this, readFileArgs);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
tryPathIndex(i + 1);
|
||||
}
|
||||
})(0);
|
||||
}
|
||||
else {
|
||||
reject({ type: 'File', message: "'".concat(filename, "' wasn't found. Tried - ").concat(filenamesTried.join(',')) });
|
||||
} else {
|
||||
reject({ type: 'File', message: `'${filename}' wasn't found. Tried - ${filenamesTried.join(',')}` });
|
||||
}
|
||||
}(0));
|
||||
}
|
||||
},
|
||||
loadFileSync: function (filename, currentDirectory, options, environment) {
|
||||
|
||||
loadFileSync(filename, currentDirectory, options, environment) {
|
||||
options.syncImport = true;
|
||||
return this.loadFile(filename, currentDirectory, options, environment);
|
||||
}
|
||||
});
|
||||
exports.default = FileManager;
|
||||
//# sourceMappingURL=file-manager.js.map
|
||||
|
||||
export default FileManager;
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+11
-8
@@ -1,11 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var fs;
|
||||
/** @typedef {import('fs')} FS */
|
||||
import nodeFs from 'fs';
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
/** @type {FS} */
|
||||
let fs;
|
||||
try {
|
||||
fs = require('graceful-fs');
|
||||
} catch (e) {
|
||||
fs = nodeFs;
|
||||
}
|
||||
catch (e) {
|
||||
fs = require('fs');
|
||||
}
|
||||
exports.default = fs;
|
||||
//# sourceMappingURL=fs.js.map
|
||||
export default fs;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/less-node/fs.js"],"names":[],"mappings":";;AAAA,IAAI,EAAE,CAAC;AACP,IACA;IACI,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/B;AACD,OAAO,CAAC,EACR;IACI,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AACD,kBAAe,EAAE,CAAC","sourcesContent":["let fs;\ntry\n{\n fs = require('graceful-fs');\n}\ncatch (e)\n{\n fs = require('fs');\n}\nexport default fs;\n"]}
|
||||
+40
-31
@@ -1,50 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var dimension_1 = tslib_1.__importDefault(require("../less/tree/dimension"));
|
||||
var expression_1 = tslib_1.__importDefault(require("../less/tree/expression"));
|
||||
var function_registry_1 = tslib_1.__importDefault(require("./../less/functions/function-registry"));
|
||||
exports.default = (function (environment) {
|
||||
import { createRequire } from 'module';
|
||||
import Dimension from '../less/tree/dimension.js';
|
||||
import Expression from '../less/tree/expression.js';
|
||||
import functionRegistry from './../less/functions/function-registry.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
export default environment => {
|
||||
|
||||
function imageSize(functionContext, filePathNode) {
|
||||
var filePath = filePathNode.value;
|
||||
var currentFileInfo = functionContext.currentFileInfo;
|
||||
var currentDirectory = currentFileInfo.rewriteUrls ?
|
||||
let filePath = filePathNode.value;
|
||||
const currentFileInfo = functionContext.currentFileInfo;
|
||||
const currentDirectory = currentFileInfo.rewriteUrls ?
|
||||
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
|
||||
var fragmentStart = filePath.indexOf('#');
|
||||
|
||||
const fragmentStart = filePath.indexOf('#');
|
||||
if (fragmentStart !== -1) {
|
||||
filePath = filePath.slice(0, fragmentStart);
|
||||
}
|
||||
var fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);
|
||||
|
||||
const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);
|
||||
|
||||
if (!fileManager) {
|
||||
throw {
|
||||
type: 'File',
|
||||
message: "Can not set up FileManager for ".concat(filePathNode)
|
||||
message: `Can not set up FileManager for ${filePathNode}`
|
||||
};
|
||||
}
|
||||
var fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);
|
||||
|
||||
const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);
|
||||
|
||||
if (fileSync.error) {
|
||||
throw fileSync.error;
|
||||
}
|
||||
var sizeOf = require('image-size');
|
||||
return sizeOf(fileSync.filename);
|
||||
|
||||
const sizeOf = require('image-size');
|
||||
return sizeOf ? sizeOf(fileSync.filename) : {width: 0, height: 0};
|
||||
}
|
||||
var imageFunctions = {
|
||||
'image-size': function (filePathNode) {
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new expression_1.default([
|
||||
new dimension_1.default(size.width, 'px'),
|
||||
new dimension_1.default(size.height, 'px')
|
||||
|
||||
const imageFunctions = {
|
||||
'image-size': function(filePathNode) {
|
||||
const size = imageSize(this, filePathNode);
|
||||
return new Expression([
|
||||
new Dimension(size.width, 'px'),
|
||||
new Dimension(size.height, 'px')
|
||||
]);
|
||||
},
|
||||
'image-width': function (filePathNode) {
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new dimension_1.default(size.width, 'px');
|
||||
'image-width': function(filePathNode) {
|
||||
const size = imageSize(this, filePathNode);
|
||||
return new Dimension(size.width, 'px');
|
||||
},
|
||||
'image-height': function (filePathNode) {
|
||||
var size = imageSize(this, filePathNode);
|
||||
return new dimension_1.default(size.height, 'px');
|
||||
'image-height': function(filePathNode) {
|
||||
const size = imageSize(this, filePathNode);
|
||||
return new Dimension(size.height, 'px');
|
||||
}
|
||||
};
|
||||
function_registry_1.default.addMultiple(imageFunctions);
|
||||
});
|
||||
//# sourceMappingURL=image-size.js.map
|
||||
|
||||
functionRegistry.addMultiple(imageFunctions);
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"image-size.js","sourceRoot":"","sources":["../../src/less-node/image-size.js"],"names":[],"mappings":";;;AAAA,6EAA+C;AAC/C,+EAAiD;AACjD,oGAAqE;AAErE,mBAAe,UAAA,WAAW;IAEtB,SAAS,SAAS,CAAC,eAAe,EAAE,YAAY;QAC5C,IAAI,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,IAAM,eAAe,GAAG,eAAe,CAAC,eAAe,CAAC;QACxD,IAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;YAClD,eAAe,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC;QAEjE,IAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,aAAa,KAAK,CAAC,CAAC,EAAE;YACtB,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;SAC/C;QAED,IAAM,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,QAAQ,EAAE,gBAAgB,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QAEvH,IAAI,CAAC,WAAW,EAAE;YACd,MAAM;gBACF,IAAI,EAAE,MAAM;gBACZ,OAAO,EAAE,yCAAkC,YAAY,CAAE;aAC5D,CAAC;SACL;QAED,IAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAE5G,IAAI,QAAQ,CAAC,KAAK,EAAE;YAChB,MAAM,QAAQ,CAAC,KAAK,CAAC;SACxB;QAED,IAAM,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,IAAM,cAAc,GAAG;QACnB,YAAY,EAAE,UAAS,YAAY;YAC/B,IAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC3C,OAAO,IAAI,oBAAU,CAAC;gBAClB,IAAI,mBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC;gBAC/B,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;aACnC,CAAC,CAAC;QACP,CAAC;QACD,aAAa,EAAE,UAAS,YAAY;YAChC,IAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC3C,OAAO,IAAI,mBAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3C,CAAC;QACD,cAAc,EAAE,UAAS,YAAY;YACjC,IAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAC3C,OAAO,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC5C,CAAC;KACJ,CAAC;IAEF,2BAAgB,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;AACjD,CAAC,EAAC","sourcesContent":["import Dimension from '../less/tree/dimension';\nimport Expression from '../less/tree/expression';\nimport functionRegistry from './../less/functions/function-registry';\n\nexport default environment => {\n\n function imageSize(functionContext, filePathNode) {\n let filePath = filePathNode.value;\n const currentFileInfo = functionContext.currentFileInfo;\n const currentDirectory = currentFileInfo.rewriteUrls ?\n currentFileInfo.currentDirectory : currentFileInfo.entryPath;\n\n const fragmentStart = filePath.indexOf('#');\n if (fragmentStart !== -1) {\n filePath = filePath.slice(0, fragmentStart);\n }\n\n const fileManager = environment.getFileManager(filePath, currentDirectory, functionContext.context, environment, true);\n\n if (!fileManager) {\n throw {\n type: 'File',\n message: `Can not set up FileManager for ${filePathNode}`\n };\n }\n\n const fileSync = fileManager.loadFileSync(filePath, currentDirectory, functionContext.context, environment);\n\n if (fileSync.error) {\n throw fileSync.error;\n }\n\n const sizeOf = require('image-size');\n return sizeOf(fileSync.filename);\n }\n\n const imageFunctions = {\n 'image-size': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Expression([\n new Dimension(size.width, 'px'),\n new Dimension(size.height, 'px')\n ]);\n },\n 'image-width': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Dimension(size.width, 'px');\n },\n 'image-height': function(filePathNode) {\n const size = imageSize(this, filePathNode);\n return new Dimension(size.height, 'px');\n }\n };\n\n functionRegistry.addMultiple(imageFunctions);\n};\n"]}
|
||||
+28
-19
@@ -1,22 +1,31 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var environment_1 = tslib_1.__importDefault(require("./environment"));
|
||||
var file_manager_1 = tslib_1.__importDefault(require("./file-manager"));
|
||||
var url_file_manager_1 = tslib_1.__importDefault(require("./url-file-manager"));
|
||||
var less_1 = tslib_1.__importDefault(require("../less"));
|
||||
var less = (0, less_1.default)(environment_1.default, [new file_manager_1.default(), new url_file_manager_1.default()]);
|
||||
var lessc_helper_1 = tslib_1.__importDefault(require("./lessc-helper"));
|
||||
import { createRequire } from 'module';
|
||||
import environment from './environment.js';
|
||||
import FileManager from './file-manager.js';
|
||||
import UrlFileManager from './url-file-manager.js';
|
||||
import createFromEnvironment from '../less/index.js';
|
||||
import lesscHelper from './lessc-helper.js';
|
||||
import PluginLoader from './plugin-loader.js';
|
||||
import fs from './fs.js';
|
||||
import defaultOptions from '../less/default-options.js';
|
||||
import imageSize from './image-size.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { version } = require('../../package.json');
|
||||
|
||||
const less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()], version);
|
||||
|
||||
// allow people to create less with their own environment
|
||||
less.createFromEnvironment = less_1.default;
|
||||
less.lesscHelper = lessc_helper_1.default;
|
||||
less.PluginLoader = require('./plugin-loader').default;
|
||||
less.fs = require('./fs').default;
|
||||
less.FileManager = file_manager_1.default;
|
||||
less.UrlFileManager = url_file_manager_1.default;
|
||||
less.createFromEnvironment = createFromEnvironment;
|
||||
less.lesscHelper = lesscHelper;
|
||||
less.PluginLoader = PluginLoader;
|
||||
less.fs = fs;
|
||||
less.FileManager = FileManager;
|
||||
less.UrlFileManager = UrlFileManager;
|
||||
|
||||
// Set up options
|
||||
less.options = require('../less/default-options').default();
|
||||
less.options = defaultOptions();
|
||||
|
||||
// provide image-size functionality
|
||||
require('./image-size').default(less.environment);
|
||||
exports.default = less;
|
||||
//# sourceMappingURL=index.js.map
|
||||
imageSize(less.environment);
|
||||
|
||||
export default less;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/less-node/index.js"],"names":[],"mappings":";;;AAAA,sEAAwC;AACxC,wEAAyC;AACzC,gFAAgD;AAChD,yDAA4C;AAC5C,IAAM,IAAI,GAAG,IAAA,cAAqB,EAAC,qBAAW,EAAE,CAAC,IAAI,sBAAW,EAAE,EAAE,IAAI,0BAAc,EAAE,CAAC,CAAC,CAAC;AAC3F,wEAAyC;AAEzC,yDAAyD;AACzD,IAAI,CAAC,qBAAqB,GAAG,cAAqB,CAAC;AACnD,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC;AAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC;AACvD,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;AAClC,IAAI,CAAC,WAAW,GAAG,sBAAW,CAAC;AAC/B,IAAI,CAAC,cAAc,GAAG,0BAAc,CAAC;AAErC,iBAAiB;AACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,CAAC;AAE5D,mCAAmC;AACnC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAElD,kBAAe,IAAI,CAAC","sourcesContent":["import environment from './environment';\nimport FileManager from './file-manager';\nimport UrlFileManager from './url-file-manager';\nimport createFromEnvironment from '../less';\nconst less = createFromEnvironment(environment, [new FileManager(), new UrlFileManager()]);\nimport lesscHelper from './lessc-helper';\n\n// allow people to create less with their own environment\nless.createFromEnvironment = createFromEnvironment;\nless.lesscHelper = lesscHelper;\nless.PluginLoader = require('./plugin-loader').default;\nless.fs = require('./fs').default;\nless.FileManager = FileManager;\nless.UrlFileManager = UrlFileManager;\n\n// Set up options\nless.options = require('../less/default-options').default();\n\n// provide image-size functionality\nrequire('./image-size').default(less.environment);\n\nexport default less;\n"]}
|
||||
+28
-28
@@ -1,23 +1,25 @@
|
||||
// lessc_helper.js
|
||||
//
|
||||
// helper functions for lessc
|
||||
var lessc_helper = {
|
||||
const lessc_helper = {
|
||||
|
||||
// Stylize a string
|
||||
stylize: function (str, style) {
|
||||
var styles = {
|
||||
'reset': [0, 0],
|
||||
'bold': [1, 22],
|
||||
'inverse': [7, 27],
|
||||
'underline': [4, 24],
|
||||
'yellow': [33, 39],
|
||||
'green': [32, 39],
|
||||
'red': [31, 39],
|
||||
'grey': [90, 39]
|
||||
stylize : function(str, style) {
|
||||
const styles = {
|
||||
'reset' : [0, 0],
|
||||
'bold' : [1, 22],
|
||||
'inverse' : [7, 27],
|
||||
'underline' : [4, 24],
|
||||
'yellow' : [33, 39],
|
||||
'green' : [32, 39],
|
||||
'red' : [31, 39],
|
||||
'grey' : [90, 39]
|
||||
};
|
||||
return "\u001B[".concat(styles[style][0], "m").concat(str, "\u001B[").concat(styles[style][1], "m");
|
||||
return `\x1b[${styles[style][0]}m${str}\x1b[${styles[style][1]}m`;
|
||||
},
|
||||
|
||||
// Print command line options
|
||||
printUsage: function () {
|
||||
printUsage: function() {
|
||||
console.log('usage: lessc [option option=parameter ...] <source> [destination]');
|
||||
console.log('');
|
||||
console.log('If source is set to `-\' (dash or hyphen-minus), input is read from stdin.');
|
||||
@@ -32,7 +34,7 @@ var lessc_helper = {
|
||||
console.log(' -l, --lint Syntax check only (lint).');
|
||||
console.log(' -s, --silent Suppresses output of error messages.');
|
||||
console.log(' --quiet Suppresses output of warnings.');
|
||||
console.log(' --strict-imports Forces evaluation of imports.');
|
||||
console.log(' --strict-imports (DEPRECATED) Ignores .less imports inside selector blocks. Has confusing behavior.');
|
||||
console.log(' --insecure Allows imports from insecure https hosts.');
|
||||
console.log(' -v, --version Prints version number and exit.');
|
||||
console.log(' --verbose Be verbose.');
|
||||
@@ -68,16 +70,19 @@ var lessc_helper = {
|
||||
console.log(' or --clean-css="advanced"');
|
||||
console.log(' --disable-plugin-rule Disallow @plugin statements');
|
||||
console.log('');
|
||||
console.log(' --quiet-deprecations Suppress deprecation warnings only (keeps other warnings).');
|
||||
console.log('');
|
||||
console.log('-------------------------- Deprecated ----------------');
|
||||
console.log(' -sm=on|off Legacy parens-only math. Use --math');
|
||||
console.log(' --strict-math=on|off ');
|
||||
console.log('');
|
||||
console.log(' --line-numbers=TYPE Outputs filename and line numbers.');
|
||||
console.log(' TYPE can be either \'comments\', which will output');
|
||||
console.log(' the debug info within comments, \'mediaquery\'');
|
||||
console.log(' that will output the information within a fake');
|
||||
console.log(' media query which is compatible with the SASS');
|
||||
console.log(' format, and \'all\' which will do both.');
|
||||
console.log(' --line-numbers=TYPE (DEPRECATED) Outputs filename and line numbers.');
|
||||
console.log(' TYPE can be either \'comments\', \'mediaquery\', or \'all\'.');
|
||||
console.log(' The entire dumpLineNumbers option is deprecated.');
|
||||
console.log(' Use sourcemaps (--source-map) instead.');
|
||||
console.log(' All modes will be removed in a future version.');
|
||||
console.log(' Note: \'mediaquery\' and \'all\' modes generate @media -sass-debug-info');
|
||||
console.log(' which had short-lived usage and is no longer recommended.');
|
||||
console.log(' -x, --compress Compresses output by removing some whitespaces.');
|
||||
console.log(' We recommend you use a dedicated minifer like less-plugin-clean-css');
|
||||
console.log('');
|
||||
@@ -85,11 +90,6 @@ var lessc_helper = {
|
||||
console.log('Home page: <http://lesscss.org/>');
|
||||
}
|
||||
};
|
||||
// Exports helper functions
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
for (var h in lessc_helper) {
|
||||
if (lessc_helper.hasOwnProperty(h)) {
|
||||
exports[h] = lessc_helper[h];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=lessc-helper.js.map
|
||||
|
||||
export const { stylize, printUsage } = lessc_helper;
|
||||
export default lessc_helper;
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+35
-27
@@ -1,19 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var path_1 = tslib_1.__importDefault(require("path"));
|
||||
var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js"));
|
||||
import path from 'path';
|
||||
import { createRequire } from 'module';
|
||||
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
/**
|
||||
* Node Plugin Loader
|
||||
*/
|
||||
var PluginLoader = function (less) {
|
||||
const PluginLoader = function(less) {
|
||||
this.less = less;
|
||||
this.require = function (prefix) {
|
||||
prefix = path_1.default.dirname(prefix);
|
||||
return function (id) {
|
||||
var str = id.substr(0, 2);
|
||||
this.require = prefix => {
|
||||
prefix = path.dirname(prefix);
|
||||
return id => {
|
||||
const str = id.slice(0, 2);
|
||||
if (str === '..' || str === './') {
|
||||
return require(path_1.default.join(prefix, id));
|
||||
return require(path.join(prefix, id));
|
||||
}
|
||||
else {
|
||||
return require(id);
|
||||
@@ -21,34 +22,41 @@ var PluginLoader = function (less) {
|
||||
};
|
||||
};
|
||||
};
|
||||
PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), {
|
||||
loadPlugin: function (filename, basePath, context, environment, fileManager) {
|
||||
var prefix = filename.slice(0, 1);
|
||||
var explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';
|
||||
|
||||
PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {
|
||||
loadPlugin(filename, basePath, context, environment, fileManager) {
|
||||
const prefix = filename.slice(0, 1);
|
||||
const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';
|
||||
if (!explicit) {
|
||||
context.prefixes = ['less-plugin-', ''];
|
||||
}
|
||||
|
||||
if (context.syncImport) {
|
||||
return fileManager.loadFileSync(filename, basePath, context, environment);
|
||||
}
|
||||
return new Promise(function (fulfill, reject) {
|
||||
fileManager.loadFile(filename, basePath, context, environment).then(function (data) {
|
||||
try {
|
||||
fulfill(data);
|
||||
|
||||
return new Promise((fulfill, reject) => {
|
||||
fileManager.loadFile(filename, basePath, context, environment).then(
|
||||
data => {
|
||||
try {
|
||||
fulfill(data);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
reject(e);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
reject(e);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
).catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
},
|
||||
loadPluginSync: function (filename, basePath, context, environment, fileManager) {
|
||||
|
||||
loadPluginSync(filename, basePath, context, environment, fileManager) {
|
||||
context.syncImport = true;
|
||||
return this.loadPlugin(filename, basePath, context, environment, fileManager);
|
||||
}
|
||||
});
|
||||
exports.default = PluginLoader;
|
||||
//# sourceMappingURL=plugin-loader.js.map
|
||||
|
||||
export default PluginLoader;
|
||||
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"plugin-loader.js","sourceRoot":"","sources":["../../src/less-node/plugin-loader.js"],"names":[],"mappings":";;;AAAA,sDAAwB;AACxB,oHAAiF;AAEjF;;GAEG;AACH,IAAM,YAAY,GAAG,UAAS,IAAI;IAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,OAAO,GAAG,UAAA,MAAM;QACjB,MAAM,GAAG,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC9B,OAAO,UAAA,EAAE;YACL,IAAM,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC5B,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE;gBAC9B,OAAO,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;aACzC;iBACI;gBACD,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;aACtB;QACL,CAAC,CAAC;IACN,CAAC,CAAC;AACN,CAAC,CAAC;AAEF,YAAY,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,mCAAoB,EAAE,EAAE;IAC/D,UAAU,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAC5D,IAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAM,QAAQ,GAAG,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC;QAChG,IAAI,CAAC,QAAQ,EAAE;YACX,OAAO,CAAC,QAAQ,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;SAC3C;QAED,IAAI,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,WAAW,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;SAC7E;QAED,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,IAAI,CAC/D,UAAA,IAAI;gBACA,IAAI;oBACA,OAAO,CAAC,IAAI,CAAC,CAAC;iBACjB;gBACD,OAAO,CAAC,EAAE;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBACf,MAAM,CAAC,CAAC,CAAC,CAAC;iBACb;YACL,CAAC,CACJ,CAAC,KAAK,CAAC,UAAA,GAAG;gBACP,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAED,cAAc,YAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW;QAChE,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IAClF,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import path from 'path';\nimport AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';\n\n/**\n * Node Plugin Loader\n */\nconst PluginLoader = function(less) {\n this.less = less;\n this.require = prefix => {\n prefix = path.dirname(prefix);\n return id => {\n const str = id.substr(0, 2);\n if (str === '..' || str === './') {\n return require(path.join(prefix, id));\n }\n else {\n return require(id);\n }\n };\n };\n};\n\nPluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {\n loadPlugin(filename, basePath, context, environment, fileManager) {\n const prefix = filename.slice(0, 1);\n const explicit = prefix === '.' || prefix === '/' || filename.slice(-3).toLowerCase() === '.js';\n if (!explicit) {\n context.prefixes = ['less-plugin-', ''];\n }\n\n if (context.syncImport) {\n return fileManager.loadFileSync(filename, basePath, context, environment);\n }\n\n return new Promise((fulfill, reject) => {\n fileManager.loadFile(filename, basePath, context, environment).then(\n data => {\n try {\n fulfill(data);\n }\n catch (e) {\n console.log(e);\n reject(e);\n }\n }\n ).catch(err => {\n reject(err);\n });\n });\n },\n\n loadPluginSync(filename, basePath, context, environment, fileManager) {\n context.syncImport = true;\n return this.loadPlugin(filename, basePath, context, environment, fileManager);\n }\n});\n\nexport default PluginLoader;\n\n"]}
|
||||
+33
-31
@@ -1,58 +1,60 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
/* eslint-disable no-unused-vars */
|
||||
/**
|
||||
* @todo - remove top eslint rule when FileManagers have JSDoc type
|
||||
* and are TS-type-checked
|
||||
*/
|
||||
var isUrlRe = /^(?:https?:)?\/\//i;
|
||||
var url_1 = tslib_1.__importDefault(require("url"));
|
||||
var request;
|
||||
var abstract_file_manager_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-file-manager.js"));
|
||||
var logger_1 = tslib_1.__importDefault(require("../less/logger"));
|
||||
var UrlFileManager = function () { };
|
||||
UrlFileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), {
|
||||
supports: function (filename, currentDirectory, options, environment) {
|
||||
return isUrlRe.test(filename) || isUrlRe.test(currentDirectory);
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
const isUrlRe = /^(?:https?:)?\/\//i;
|
||||
import url from 'url';
|
||||
let request;
|
||||
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
|
||||
import logger from '../less/logger.js';
|
||||
|
||||
const UrlFileManager = function() {}
|
||||
UrlFileManager.prototype = Object.assign(new AbstractFileManager(), {
|
||||
supports(filename, currentDirectory, options, environment) {
|
||||
return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);
|
||||
},
|
||||
loadFile: function (filename, currentDirectory, options, environment) {
|
||||
return new Promise(function (fulfill, reject) {
|
||||
|
||||
loadFile(filename, currentDirectory, options, environment) {
|
||||
return new Promise((fulfill, reject) => {
|
||||
if (request === undefined) {
|
||||
try {
|
||||
request = require('needle');
|
||||
}
|
||||
catch (e) {
|
||||
request = null;
|
||||
}
|
||||
try { request = require('needle'); }
|
||||
catch (e) { request = null; }
|
||||
}
|
||||
if (!request) {
|
||||
reject({ type: 'File', message: 'optional dependency \'needle\' required to import over http(s)\n' });
|
||||
return;
|
||||
}
|
||||
var urlStr = isUrlRe.test(filename) ? filename : url_1.default.resolve(currentDirectory, filename);
|
||||
|
||||
let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);
|
||||
|
||||
/** native-request currently has a bug */
|
||||
var hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr;
|
||||
request.get(hackUrlStr, { follow_max: 5 }, function (err, resp, body) {
|
||||
const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr
|
||||
|
||||
request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {
|
||||
if (err || resp && resp.statusCode >= 400) {
|
||||
var message = resp && resp.statusCode === 404
|
||||
? "resource '".concat(urlStr, "' was not found\n")
|
||||
: "resource '".concat(urlStr, "' gave this Error:\n ").concat(err || resp.statusMessage || resp.statusCode, "\n");
|
||||
reject({ type: 'File', message: message });
|
||||
const message = resp && resp.statusCode === 404
|
||||
? `resource '${urlStr}' was not found\n`
|
||||
: `resource '${urlStr}' gave this Error:\n ${err || resp.statusMessage || resp.statusCode}\n`;
|
||||
reject({ type: 'File', message });
|
||||
return;
|
||||
}
|
||||
if (resp.statusCode >= 300) {
|
||||
reject({ type: 'File', message: "resource '".concat(urlStr, "' caused too many redirects") });
|
||||
reject({ type: 'File', message: `resource '${urlStr}' caused too many redirects` });
|
||||
return;
|
||||
}
|
||||
body = body.toString('utf8');
|
||||
if (!body) {
|
||||
logger_1.default.warn("Warning: Empty body (HTTP ".concat(resp.statusCode, ") returned by \"").concat(urlStr, "\""));
|
||||
logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by "${urlStr}"`);
|
||||
}
|
||||
fulfill({ contents: body || '', filename: urlStr });
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
exports.default = UrlFileManager;
|
||||
//# sourceMappingURL=url-file-manager.js.map
|
||||
|
||||
export default UrlFileManager;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"url-file-manager.js","sourceRoot":"","sources":["../../src/less-node/url-file-manager.js"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC;;;GAGG;AACH,IAAM,OAAO,GAAG,oBAAoB,CAAC;AACrC,oDAAsB;AACtB,IAAI,OAAO,CAAC;AACZ,kHAA+E;AAC/E,kEAAoC;AAEpC,IAAM,cAAc,GAAG,cAAY,CAAC,CAAA;AACpC,cAAc,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,kCAAmB,EAAE,EAAE;IAChE,QAAQ,YAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW;QACrD,OAAO,OAAO,CAAC,IAAI,CAAE,QAAQ,CAAE,IAAI,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;IAED,QAAQ,YAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW;QACrD,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,IAAI,OAAO,KAAK,SAAS,EAAE;gBACvB,IAAI;oBAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;iBAAE;gBACpC,OAAO,CAAC,EAAE;oBAAE,OAAO,GAAG,IAAI,CAAC;iBAAE;aAChC;YACD,IAAI,CAAC,OAAO,EAAE;gBACV,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kEAAkE,EAAE,CAAC,CAAC;gBACtG,OAAO;aACV;YAED,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,CAAE,QAAQ,CAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;YAE3F,yCAAyC;YACzC,IAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAA;YAErE,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,UAAC,GAAG,EAAE,IAAI,EAAE,IAAI;gBACvD,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE;oBACvC,IAAM,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG;wBAC3C,CAAC,CAAC,oBAAa,MAAM,sBAAmB;wBACxC,CAAC,CAAC,oBAAa,MAAM,mCAAyB,GAAG,IAAI,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,UAAU,OAAI,CAAC;oBACnG,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;oBAClC,OAAO;iBACV;gBACD,IAAI,IAAI,CAAC,UAAU,IAAI,GAAG,EAAE;oBACxB,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAa,MAAM,gCAA6B,EAAE,CAAC,CAAC;oBACpF,OAAO;iBACV;gBACD,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAC7B,IAAI,CAAC,IAAI,EAAE;oBACP,gBAAM,CAAC,IAAI,CAAC,oCAA6B,IAAI,CAAC,UAAU,6BAAkB,MAAM,OAAG,CAAC,CAAC;iBACxF;gBACD,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC,CAAC;AAEH,kBAAe,cAAc,CAAC","sourcesContent":["/* eslint-disable no-unused-vars */\n/**\n * @todo - remove top eslint rule when FileManagers have JSDoc type\n * and are TS-type-checked\n */\nconst isUrlRe = /^(?:https?:)?\\/\\//i;\nimport url from 'url';\nlet request;\nimport AbstractFileManager from '../less/environment/abstract-file-manager.js';\nimport logger from '../less/logger';\n\nconst UrlFileManager = function() {}\nUrlFileManager.prototype = Object.assign(new AbstractFileManager(), {\n supports(filename, currentDirectory, options, environment) {\n return isUrlRe.test( filename ) || isUrlRe.test(currentDirectory);\n },\n\n loadFile(filename, currentDirectory, options, environment) {\n return new Promise((fulfill, reject) => {\n if (request === undefined) {\n try { request = require('needle'); }\n catch (e) { request = null; }\n }\n if (!request) {\n reject({ type: 'File', message: 'optional dependency \\'needle\\' required to import over http(s)\\n' });\n return;\n }\n\n let urlStr = isUrlRe.test( filename ) ? filename : url.resolve(currentDirectory, filename);\n\n /** native-request currently has a bug */\n const hackUrlStr = urlStr.indexOf('?') === -1 ? urlStr + '?' : urlStr\n\n request.get(hackUrlStr, { follow_max: 5 }, (err, resp, body) => {\n if (err || resp && resp.statusCode >= 400) {\n const message = resp && resp.statusCode === 404\n ? `resource '${urlStr}' was not found\\n`\n : `resource '${urlStr}' gave this Error:\\n ${err || resp.statusMessage || resp.statusCode}\\n`;\n reject({ type: 'File', message });\n return;\n }\n if (resp.statusCode >= 300) {\n reject({ type: 'File', message: `resource '${urlStr}' caused too many redirects` });\n return;\n }\n body = body.toString('utf8');\n if (!body) {\n logger.warn(`Warning: Empty body (HTTP ${resp.statusCode}) returned by \"${urlStr}\"`);\n }\n fulfill({ contents: body || '', filename: urlStr });\n });\n });\n }\n});\n\nexport default UrlFileManager;\n"]}
|
||||
+5
-7
@@ -1,15 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RewriteUrls = exports.Math = void 0;
|
||||
exports.Math = {
|
||||
|
||||
export const Math = {
|
||||
ALWAYS: 0,
|
||||
PARENS_DIVISION: 1,
|
||||
PARENS: 2
|
||||
// removed - STRICT_LEGACY: 3
|
||||
};
|
||||
exports.RewriteUrls = {
|
||||
|
||||
export const RewriteUrls = {
|
||||
OFF: 0,
|
||||
LOCAL: 1,
|
||||
ALL: 2
|
||||
};
|
||||
//# sourceMappingURL=constants.js.map
|
||||
};
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/less/constants.js"],"names":[],"mappings":";;;AACa,QAAA,IAAI,GAAG;IAChB,MAAM,EAAE,CAAC;IACT,eAAe,EAAE,CAAC;IAClB,MAAM,EAAE,CAAC;IACT,6BAA6B;CAChC,CAAC;AAEW,QAAA,WAAW,GAAG;IACvB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC;CACT,CAAC","sourcesContent":["\nexport const Math = {\n ALWAYS: 0,\n PARENS_DIVISION: 1,\n PARENS: 2\n // removed - STRICT_LEGACY: 3\n};\n\nexport const RewriteUrls = {\n OFF: 0,\n LOCAL: 1,\n ALL: 2\n};"]}
|
||||
+71
-56
@@ -1,68 +1,69 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var contexts = {};
|
||||
exports.default = contexts;
|
||||
var Constants = tslib_1.__importStar(require("./constants"));
|
||||
var copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {
|
||||
if (!original) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < propertiesToCopy.length; i++) {
|
||||
const contexts = {};
|
||||
export default contexts;
|
||||
import * as Constants from './constants.js';
|
||||
|
||||
const copyFromOriginal = function copyFromOriginal(original, destination, propertiesToCopy) {
|
||||
if (!original) { return; }
|
||||
|
||||
for (let i = 0; i < propertiesToCopy.length; i++) {
|
||||
if (Object.prototype.hasOwnProperty.call(original, propertiesToCopy[i])) {
|
||||
destination[propertiesToCopy[i]] = original[propertiesToCopy[i]];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
parse is used whilst parsing
|
||||
*/
|
||||
var parseCopyProperties = [
|
||||
const parseCopyProperties = [
|
||||
// options
|
||||
'paths',
|
||||
'rewriteUrls',
|
||||
'rootpath',
|
||||
'strictImports',
|
||||
'insecure',
|
||||
'dumpLineNumbers',
|
||||
'compress',
|
||||
'syncImport',
|
||||
'chunkInput',
|
||||
'mime',
|
||||
'useFileCache',
|
||||
'paths', // option - unmodified - paths to search for imports on
|
||||
'rewriteUrls', // option - whether to adjust URL's to be relative
|
||||
'rootpath', // option - rootpath to append to URL's
|
||||
'strictImports', // option -
|
||||
'insecure', // option - whether to allow imports from insecure ssl hosts
|
||||
'dumpLineNumbers', // option - @deprecated The dumpLineNumbers option is deprecated. Use sourcemaps instead. All modes ('comments', 'mediaquery', 'all') will be removed in a future version.
|
||||
'compress', // option - whether to compress
|
||||
'syncImport', // option - whether to import synchronously
|
||||
'mime', // browser only - mime type for sheet import
|
||||
'useFileCache', // browser only - whether to use the per file session cache
|
||||
// context
|
||||
'processImports',
|
||||
'processImports', // option & context - whether to process imports. if false then imports will not be imported.
|
||||
// Used by the import manager to stop multiple import visitors being created.
|
||||
'pluginManager',
|
||||
'quiet', // option - whether to log warnings
|
||||
'pluginManager', // Used as the plugin manager for the session
|
||||
'quiet', // option - whether to log warnings
|
||||
'quietDeprecations', // option - whether to suppress deprecation warnings only
|
||||
];
|
||||
contexts.Parse = function (options) {
|
||||
|
||||
contexts.Parse = function(options) {
|
||||
copyFromOriginal(options, this, parseCopyProperties);
|
||||
if (typeof this.paths === 'string') {
|
||||
this.paths = [this.paths];
|
||||
}
|
||||
|
||||
if (typeof this.paths === 'string') { this.paths = [this.paths]; }
|
||||
};
|
||||
var evalCopyProperties = [
|
||||
'paths',
|
||||
'compress',
|
||||
'math',
|
||||
'strictUnits',
|
||||
'sourceMap',
|
||||
'importMultiple',
|
||||
'urlArgs',
|
||||
'javascriptEnabled',
|
||||
'pluginManager',
|
||||
'importantScope',
|
||||
'rewriteUrls' // option - whether to adjust URL's to be relative
|
||||
|
||||
const evalCopyProperties = [
|
||||
'paths', // additional include paths
|
||||
'compress', // whether to compress
|
||||
'math', // whether math has to be within parenthesis
|
||||
'strictUnits', // whether units need to evaluate correctly
|
||||
'sourceMap', // whether to output a source map
|
||||
'importMultiple', // whether we are currently importing multiple copies
|
||||
'urlArgs', // whether to add args into url tokens
|
||||
'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false
|
||||
'pluginManager', // Used as the plugin manager for the session
|
||||
'importantScope', // used to bubble up !important statements
|
||||
'rewriteUrls' // option - whether to adjust URL's to be relative
|
||||
];
|
||||
contexts.Eval = function (options, frames) {
|
||||
|
||||
contexts.Eval = function(options, frames) {
|
||||
copyFromOriginal(options, this, evalCopyProperties);
|
||||
if (typeof this.paths === 'string') {
|
||||
this.paths = [this.paths];
|
||||
}
|
||||
|
||||
if (typeof this.paths === 'string') { this.paths = [this.paths]; }
|
||||
|
||||
this.frames = frames || [];
|
||||
this.importantScope = this.importantScope || [];
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.enterCalc = function () {
|
||||
if (!this.calcStack) {
|
||||
this.calcStack = [];
|
||||
@@ -70,21 +71,25 @@ contexts.Eval.prototype.enterCalc = function () {
|
||||
this.calcStack.push(true);
|
||||
this.inCalc = true;
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.exitCalc = function () {
|
||||
this.calcStack.pop();
|
||||
if (!this.calcStack.length) {
|
||||
this.inCalc = false;
|
||||
}
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.inParenthesis = function () {
|
||||
if (!this.parensStack) {
|
||||
this.parensStack = [];
|
||||
}
|
||||
this.parensStack.push(true);
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.outOfParenthesis = function () {
|
||||
this.parensStack.pop();
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.inCalc = false;
|
||||
contexts.Eval.prototype.mathOn = true;
|
||||
contexts.Eval.prototype.isMathOn = function (op) {
|
||||
@@ -99,37 +104,44 @@ contexts.Eval.prototype.isMathOn = function (op) {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.pathRequiresRewrite = function (path) {
|
||||
var isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;
|
||||
const isRelative = this.rewriteUrls === Constants.RewriteUrls.LOCAL ? isPathLocalRelative : isPathRelative;
|
||||
|
||||
return isRelative(path);
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.rewritePath = function (path, rootpath) {
|
||||
var newPath;
|
||||
let newPath;
|
||||
|
||||
rootpath = rootpath || '';
|
||||
newPath = this.normalizePath(rootpath + path);
|
||||
|
||||
// If a path was explicit relative and the rootpath was not an absolute path
|
||||
// we must ensure that the new path is also explicit relative.
|
||||
if (isPathLocalRelative(path) &&
|
||||
isPathRelative(rootpath) &&
|
||||
isPathLocalRelative(newPath) === false) {
|
||||
newPath = "./".concat(newPath);
|
||||
newPath = `./${newPath}`;
|
||||
}
|
||||
|
||||
return newPath;
|
||||
};
|
||||
|
||||
contexts.Eval.prototype.normalizePath = function (path) {
|
||||
var segments = path.split('/').reverse();
|
||||
var segment;
|
||||
const segments = path.split('/').reverse();
|
||||
let segment;
|
||||
|
||||
path = [];
|
||||
while (segments.length !== 0) {
|
||||
segment = segments.pop();
|
||||
switch (segment) {
|
||||
switch ( segment ) {
|
||||
case '.':
|
||||
break;
|
||||
case '..':
|
||||
if ((path.length === 0) || (path[path.length - 1] === '..')) {
|
||||
path.push(segment);
|
||||
}
|
||||
else {
|
||||
path.push( segment );
|
||||
} else {
|
||||
path.pop();
|
||||
}
|
||||
break;
|
||||
@@ -138,13 +150,16 @@ contexts.Eval.prototype.normalizePath = function (path) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return path.join('/');
|
||||
};
|
||||
|
||||
function isPathRelative(path) {
|
||||
return !/^(?:[a-z-]+:|\/|#)/i.test(path);
|
||||
}
|
||||
|
||||
function isPathLocalRelative(path) {
|
||||
return path.charAt(0) === '.';
|
||||
}
|
||||
|
||||
// todo - do the same for the toCSS ?
|
||||
//# sourceMappingURL=contexts.js.map
|
||||
-1
File diff suppressed because one or more lines are too long
+150
-153
@@ -1,153 +1,150 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = {
|
||||
'aliceblue': '#f0f8ff',
|
||||
'antiquewhite': '#faebd7',
|
||||
'aqua': '#00ffff',
|
||||
'aquamarine': '#7fffd4',
|
||||
'azure': '#f0ffff',
|
||||
'beige': '#f5f5dc',
|
||||
'bisque': '#ffe4c4',
|
||||
'black': '#000000',
|
||||
'blanchedalmond': '#ffebcd',
|
||||
'blue': '#0000ff',
|
||||
'blueviolet': '#8a2be2',
|
||||
'brown': '#a52a2a',
|
||||
'burlywood': '#deb887',
|
||||
'cadetblue': '#5f9ea0',
|
||||
'chartreuse': '#7fff00',
|
||||
'chocolate': '#d2691e',
|
||||
'coral': '#ff7f50',
|
||||
'cornflowerblue': '#6495ed',
|
||||
'cornsilk': '#fff8dc',
|
||||
'crimson': '#dc143c',
|
||||
'cyan': '#00ffff',
|
||||
'darkblue': '#00008b',
|
||||
'darkcyan': '#008b8b',
|
||||
'darkgoldenrod': '#b8860b',
|
||||
'darkgray': '#a9a9a9',
|
||||
'darkgrey': '#a9a9a9',
|
||||
'darkgreen': '#006400',
|
||||
'darkkhaki': '#bdb76b',
|
||||
'darkmagenta': '#8b008b',
|
||||
'darkolivegreen': '#556b2f',
|
||||
'darkorange': '#ff8c00',
|
||||
'darkorchid': '#9932cc',
|
||||
'darkred': '#8b0000',
|
||||
'darksalmon': '#e9967a',
|
||||
'darkseagreen': '#8fbc8f',
|
||||
'darkslateblue': '#483d8b',
|
||||
'darkslategray': '#2f4f4f',
|
||||
'darkslategrey': '#2f4f4f',
|
||||
'darkturquoise': '#00ced1',
|
||||
'darkviolet': '#9400d3',
|
||||
'deeppink': '#ff1493',
|
||||
'deepskyblue': '#00bfff',
|
||||
'dimgray': '#696969',
|
||||
'dimgrey': '#696969',
|
||||
'dodgerblue': '#1e90ff',
|
||||
'firebrick': '#b22222',
|
||||
'floralwhite': '#fffaf0',
|
||||
'forestgreen': '#228b22',
|
||||
'fuchsia': '#ff00ff',
|
||||
'gainsboro': '#dcdcdc',
|
||||
'ghostwhite': '#f8f8ff',
|
||||
'gold': '#ffd700',
|
||||
'goldenrod': '#daa520',
|
||||
'gray': '#808080',
|
||||
'grey': '#808080',
|
||||
'green': '#008000',
|
||||
'greenyellow': '#adff2f',
|
||||
'honeydew': '#f0fff0',
|
||||
'hotpink': '#ff69b4',
|
||||
'indianred': '#cd5c5c',
|
||||
'indigo': '#4b0082',
|
||||
'ivory': '#fffff0',
|
||||
'khaki': '#f0e68c',
|
||||
'lavender': '#e6e6fa',
|
||||
'lavenderblush': '#fff0f5',
|
||||
'lawngreen': '#7cfc00',
|
||||
'lemonchiffon': '#fffacd',
|
||||
'lightblue': '#add8e6',
|
||||
'lightcoral': '#f08080',
|
||||
'lightcyan': '#e0ffff',
|
||||
'lightgoldenrodyellow': '#fafad2',
|
||||
'lightgray': '#d3d3d3',
|
||||
'lightgrey': '#d3d3d3',
|
||||
'lightgreen': '#90ee90',
|
||||
'lightpink': '#ffb6c1',
|
||||
'lightsalmon': '#ffa07a',
|
||||
'lightseagreen': '#20b2aa',
|
||||
'lightskyblue': '#87cefa',
|
||||
'lightslategray': '#778899',
|
||||
'lightslategrey': '#778899',
|
||||
'lightsteelblue': '#b0c4de',
|
||||
'lightyellow': '#ffffe0',
|
||||
'lime': '#00ff00',
|
||||
'limegreen': '#32cd32',
|
||||
'linen': '#faf0e6',
|
||||
'magenta': '#ff00ff',
|
||||
'maroon': '#800000',
|
||||
'mediumaquamarine': '#66cdaa',
|
||||
'mediumblue': '#0000cd',
|
||||
'mediumorchid': '#ba55d3',
|
||||
'mediumpurple': '#9370d8',
|
||||
'mediumseagreen': '#3cb371',
|
||||
'mediumslateblue': '#7b68ee',
|
||||
'mediumspringgreen': '#00fa9a',
|
||||
'mediumturquoise': '#48d1cc',
|
||||
'mediumvioletred': '#c71585',
|
||||
'midnightblue': '#191970',
|
||||
'mintcream': '#f5fffa',
|
||||
'mistyrose': '#ffe4e1',
|
||||
'moccasin': '#ffe4b5',
|
||||
'navajowhite': '#ffdead',
|
||||
'navy': '#000080',
|
||||
'oldlace': '#fdf5e6',
|
||||
'olive': '#808000',
|
||||
'olivedrab': '#6b8e23',
|
||||
'orange': '#ffa500',
|
||||
'orangered': '#ff4500',
|
||||
'orchid': '#da70d6',
|
||||
'palegoldenrod': '#eee8aa',
|
||||
'palegreen': '#98fb98',
|
||||
'paleturquoise': '#afeeee',
|
||||
'palevioletred': '#d87093',
|
||||
'papayawhip': '#ffefd5',
|
||||
'peachpuff': '#ffdab9',
|
||||
'peru': '#cd853f',
|
||||
'pink': '#ffc0cb',
|
||||
'plum': '#dda0dd',
|
||||
'powderblue': '#b0e0e6',
|
||||
'purple': '#800080',
|
||||
'rebeccapurple': '#663399',
|
||||
'red': '#ff0000',
|
||||
'rosybrown': '#bc8f8f',
|
||||
'royalblue': '#4169e1',
|
||||
'saddlebrown': '#8b4513',
|
||||
'salmon': '#fa8072',
|
||||
'sandybrown': '#f4a460',
|
||||
'seagreen': '#2e8b57',
|
||||
'seashell': '#fff5ee',
|
||||
'sienna': '#a0522d',
|
||||
'silver': '#c0c0c0',
|
||||
'skyblue': '#87ceeb',
|
||||
'slateblue': '#6a5acd',
|
||||
'slategray': '#708090',
|
||||
'slategrey': '#708090',
|
||||
'snow': '#fffafa',
|
||||
'springgreen': '#00ff7f',
|
||||
'steelblue': '#4682b4',
|
||||
'tan': '#d2b48c',
|
||||
'teal': '#008080',
|
||||
'thistle': '#d8bfd8',
|
||||
'tomato': '#ff6347',
|
||||
'turquoise': '#40e0d0',
|
||||
'violet': '#ee82ee',
|
||||
'wheat': '#f5deb3',
|
||||
'white': '#ffffff',
|
||||
'whitesmoke': '#f5f5f5',
|
||||
'yellow': '#ffff00',
|
||||
'yellowgreen': '#9acd32'
|
||||
};
|
||||
//# sourceMappingURL=colors.js.map
|
||||
export default {
|
||||
'aliceblue':'#f0f8ff',
|
||||
'antiquewhite':'#faebd7',
|
||||
'aqua':'#00ffff',
|
||||
'aquamarine':'#7fffd4',
|
||||
'azure':'#f0ffff',
|
||||
'beige':'#f5f5dc',
|
||||
'bisque':'#ffe4c4',
|
||||
'black':'#000000',
|
||||
'blanchedalmond':'#ffebcd',
|
||||
'blue':'#0000ff',
|
||||
'blueviolet':'#8a2be2',
|
||||
'brown':'#a52a2a',
|
||||
'burlywood':'#deb887',
|
||||
'cadetblue':'#5f9ea0',
|
||||
'chartreuse':'#7fff00',
|
||||
'chocolate':'#d2691e',
|
||||
'coral':'#ff7f50',
|
||||
'cornflowerblue':'#6495ed',
|
||||
'cornsilk':'#fff8dc',
|
||||
'crimson':'#dc143c',
|
||||
'cyan':'#00ffff',
|
||||
'darkblue':'#00008b',
|
||||
'darkcyan':'#008b8b',
|
||||
'darkgoldenrod':'#b8860b',
|
||||
'darkgray':'#a9a9a9',
|
||||
'darkgrey':'#a9a9a9',
|
||||
'darkgreen':'#006400',
|
||||
'darkkhaki':'#bdb76b',
|
||||
'darkmagenta':'#8b008b',
|
||||
'darkolivegreen':'#556b2f',
|
||||
'darkorange':'#ff8c00',
|
||||
'darkorchid':'#9932cc',
|
||||
'darkred':'#8b0000',
|
||||
'darksalmon':'#e9967a',
|
||||
'darkseagreen':'#8fbc8f',
|
||||
'darkslateblue':'#483d8b',
|
||||
'darkslategray':'#2f4f4f',
|
||||
'darkslategrey':'#2f4f4f',
|
||||
'darkturquoise':'#00ced1',
|
||||
'darkviolet':'#9400d3',
|
||||
'deeppink':'#ff1493',
|
||||
'deepskyblue':'#00bfff',
|
||||
'dimgray':'#696969',
|
||||
'dimgrey':'#696969',
|
||||
'dodgerblue':'#1e90ff',
|
||||
'firebrick':'#b22222',
|
||||
'floralwhite':'#fffaf0',
|
||||
'forestgreen':'#228b22',
|
||||
'fuchsia':'#ff00ff',
|
||||
'gainsboro':'#dcdcdc',
|
||||
'ghostwhite':'#f8f8ff',
|
||||
'gold':'#ffd700',
|
||||
'goldenrod':'#daa520',
|
||||
'gray':'#808080',
|
||||
'grey':'#808080',
|
||||
'green':'#008000',
|
||||
'greenyellow':'#adff2f',
|
||||
'honeydew':'#f0fff0',
|
||||
'hotpink':'#ff69b4',
|
||||
'indianred':'#cd5c5c',
|
||||
'indigo':'#4b0082',
|
||||
'ivory':'#fffff0',
|
||||
'khaki':'#f0e68c',
|
||||
'lavender':'#e6e6fa',
|
||||
'lavenderblush':'#fff0f5',
|
||||
'lawngreen':'#7cfc00',
|
||||
'lemonchiffon':'#fffacd',
|
||||
'lightblue':'#add8e6',
|
||||
'lightcoral':'#f08080',
|
||||
'lightcyan':'#e0ffff',
|
||||
'lightgoldenrodyellow':'#fafad2',
|
||||
'lightgray':'#d3d3d3',
|
||||
'lightgrey':'#d3d3d3',
|
||||
'lightgreen':'#90ee90',
|
||||
'lightpink':'#ffb6c1',
|
||||
'lightsalmon':'#ffa07a',
|
||||
'lightseagreen':'#20b2aa',
|
||||
'lightskyblue':'#87cefa',
|
||||
'lightslategray':'#778899',
|
||||
'lightslategrey':'#778899',
|
||||
'lightsteelblue':'#b0c4de',
|
||||
'lightyellow':'#ffffe0',
|
||||
'lime':'#00ff00',
|
||||
'limegreen':'#32cd32',
|
||||
'linen':'#faf0e6',
|
||||
'magenta':'#ff00ff',
|
||||
'maroon':'#800000',
|
||||
'mediumaquamarine':'#66cdaa',
|
||||
'mediumblue':'#0000cd',
|
||||
'mediumorchid':'#ba55d3',
|
||||
'mediumpurple':'#9370d8',
|
||||
'mediumseagreen':'#3cb371',
|
||||
'mediumslateblue':'#7b68ee',
|
||||
'mediumspringgreen':'#00fa9a',
|
||||
'mediumturquoise':'#48d1cc',
|
||||
'mediumvioletred':'#c71585',
|
||||
'midnightblue':'#191970',
|
||||
'mintcream':'#f5fffa',
|
||||
'mistyrose':'#ffe4e1',
|
||||
'moccasin':'#ffe4b5',
|
||||
'navajowhite':'#ffdead',
|
||||
'navy':'#000080',
|
||||
'oldlace':'#fdf5e6',
|
||||
'olive':'#808000',
|
||||
'olivedrab':'#6b8e23',
|
||||
'orange':'#ffa500',
|
||||
'orangered':'#ff4500',
|
||||
'orchid':'#da70d6',
|
||||
'palegoldenrod':'#eee8aa',
|
||||
'palegreen':'#98fb98',
|
||||
'paleturquoise':'#afeeee',
|
||||
'palevioletred':'#d87093',
|
||||
'papayawhip':'#ffefd5',
|
||||
'peachpuff':'#ffdab9',
|
||||
'peru':'#cd853f',
|
||||
'pink':'#ffc0cb',
|
||||
'plum':'#dda0dd',
|
||||
'powderblue':'#b0e0e6',
|
||||
'purple':'#800080',
|
||||
'rebeccapurple':'#663399',
|
||||
'red':'#ff0000',
|
||||
'rosybrown':'#bc8f8f',
|
||||
'royalblue':'#4169e1',
|
||||
'saddlebrown':'#8b4513',
|
||||
'salmon':'#fa8072',
|
||||
'sandybrown':'#f4a460',
|
||||
'seagreen':'#2e8b57',
|
||||
'seashell':'#fff5ee',
|
||||
'sienna':'#a0522d',
|
||||
'silver':'#c0c0c0',
|
||||
'skyblue':'#87ceeb',
|
||||
'slateblue':'#6a5acd',
|
||||
'slategray':'#708090',
|
||||
'slategrey':'#708090',
|
||||
'snow':'#fffafa',
|
||||
'springgreen':'#00ff7f',
|
||||
'steelblue':'#4682b4',
|
||||
'tan':'#d2b48c',
|
||||
'teal':'#008080',
|
||||
'thistle':'#d8bfd8',
|
||||
'tomato':'#ff6347',
|
||||
'turquoise':'#40e0d0',
|
||||
'violet':'#ee82ee',
|
||||
'wheat':'#f5deb3',
|
||||
'white':'#ffffff',
|
||||
'whitesmoke':'#f5f5f5',
|
||||
'yellow':'#ffff00',
|
||||
'yellowgreen':'#9acd32'
|
||||
};
|
||||
-1
File diff suppressed because one or more lines are too long
+4
-7
@@ -1,7 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var colors_1 = tslib_1.__importDefault(require("./colors"));
|
||||
var unit_conversions_1 = tslib_1.__importDefault(require("./unit-conversions"));
|
||||
exports.default = { colors: colors_1.default, unitConversions: unit_conversions_1.default };
|
||||
//# sourceMappingURL=index.js.map
|
||||
import colors from './colors.js';
|
||||
import unitConversions from './unit-conversions.js';
|
||||
|
||||
export default { colors, unitConversions };
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/data/index.js"],"names":[],"mappings":";;;AAAA,4DAA8B;AAC9B,gFAAiD;AAEjD,kBAAe,EAAE,MAAM,kBAAA,EAAE,eAAe,4BAAA,EAAE,CAAC","sourcesContent":["import colors from './colors';\nimport unitConversions from './unit-conversions';\n\nexport default { colors, unitConversions };\n"]}
|
||||
+2
-5
@@ -1,6 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = {
|
||||
export default {
|
||||
length: {
|
||||
'm': 1,
|
||||
'cm': 0.01,
|
||||
@@ -20,5 +18,4 @@ exports.default = {
|
||||
'grad': 1 / 400,
|
||||
'turn': 1
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=unit-conversions.js.map
|
||||
};
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"unit-conversions.js","sourceRoot":"","sources":["../../../src/less/data/unit-conversions.js"],"names":[],"mappings":";;AAAA,kBAAe;IACX,MAAM,EAAE;QACJ,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,IAAI;QACV,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM,GAAG,EAAE;QACjB,IAAI,EAAE,MAAM,GAAG,EAAE;QACjB,IAAI,EAAE,MAAM,GAAG,EAAE,GAAG,EAAE;KACzB;IACD,QAAQ,EAAE;QACN,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,KAAK;KACd;IACD,KAAK,EAAE;QACH,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;QACxB,KAAK,EAAE,CAAC,GAAG,GAAG;QACd,MAAM,EAAE,CAAC,GAAG,GAAG;QACf,MAAM,EAAE,CAAC;KACZ;CACJ,CAAC","sourcesContent":["export default {\n length: {\n 'm': 1,\n 'cm': 0.01,\n 'mm': 0.001,\n 'in': 0.0254,\n 'px': 0.0254 / 96,\n 'pt': 0.0254 / 72,\n 'pc': 0.0254 / 72 * 12\n },\n duration: {\n 's': 1,\n 'ms': 0.001\n },\n angle: {\n 'rad': 1 / (2 * Math.PI),\n 'deg': 1 / 360,\n 'grad': 1 / 400,\n 'turn': 1\n }\n};"]}
|
||||
+52
-23
@@ -1,60 +1,89 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Export a new default each time
|
||||
function default_1() {
|
||||
export default function() {
|
||||
return {
|
||||
/* Inline Javascript - @plugin still allowed */
|
||||
javascriptEnabled: false,
|
||||
|
||||
/* Outputs a makefile import dependency list to stdout. */
|
||||
depends: false,
|
||||
/* (DEPRECATED) Compress using less built-in compression.
|
||||
* This does an okay job but does not utilise all the tricks of
|
||||
|
||||
/* (DEPRECATED) Compress using less built-in compression.
|
||||
* This does an okay job but does not utilise all the tricks of
|
||||
* dedicated css compression. */
|
||||
compress: false,
|
||||
|
||||
/* Runs the less parser and just reports errors without any output. */
|
||||
lint: false,
|
||||
|
||||
/* Sets available include paths.
|
||||
* If the file in an @import rule does not exist at that exact location,
|
||||
* less will look for it at the location(s) passed to this option.
|
||||
* You might use this for instance to specify a path to a library which
|
||||
* If the file in an @import rule does not exist at that exact location,
|
||||
* less will look for it at the location(s) passed to this option.
|
||||
* You might use this for instance to specify a path to a library which
|
||||
* you want to be referenced simply and relatively in the less files. */
|
||||
paths: [],
|
||||
|
||||
/* color output in the terminal */
|
||||
color: true,
|
||||
/* The strictImports controls whether the compiler will allow an @import inside of either
|
||||
* @media blocks or (a later addition) other selector blocks.
|
||||
* See: https://github.com/less/less.js/issues/656 */
|
||||
|
||||
/**
|
||||
* @deprecated This option has confusing behavior and may be removed in a future version.
|
||||
*
|
||||
* When true, prevents @import statements for .less files from being evaluated inside
|
||||
* selector blocks (rulesets). The imports are silently ignored and not output.
|
||||
*
|
||||
* Behavior:
|
||||
* - @import at root level: Always processed
|
||||
* - @import inside @-rules (@media, @supports, etc.): Processed (these are not selector blocks)
|
||||
* - @import inside selector blocks (.class, #id, etc.): NOT processed (silently ignored)
|
||||
*
|
||||
* When false (default): All @import statements are processed regardless of context.
|
||||
*
|
||||
* Note: Despite the name "strict", this option does NOT throw an error when imports
|
||||
* are used in selector blocks - it silently ignores them. This is confusing
|
||||
* behavior that may catch users off guard.
|
||||
*
|
||||
* Note: Only affects .less file imports. CSS imports (url(...) or .css files) are
|
||||
* always output as CSS @import statements regardless of this setting.
|
||||
*
|
||||
* @see https://github.com/less/less.js/issues/656
|
||||
*/
|
||||
strictImports: false,
|
||||
|
||||
/* Allow Imports from Insecure HTTPS Hosts */
|
||||
insecure: false,
|
||||
/* Allows you to add a path to every generated import and url in your css.
|
||||
* This does not affect less import statements that are processed, just ones
|
||||
|
||||
/* Allows you to add a path to every generated import and url in your css.
|
||||
* This does not affect less import statements that are processed, just ones
|
||||
* that are left in the output css. */
|
||||
rootpath: '',
|
||||
/* By default URLs are kept as-is, so if you import a file in a sub-directory
|
||||
* that references an image, exactly the same URL will be output in the css.
|
||||
* This option allows you to re-write URL's in imported files so that the
|
||||
|
||||
/* By default URLs are kept as-is, so if you import a file in a sub-directory
|
||||
* that references an image, exactly the same URL will be output in the css.
|
||||
* This option allows you to re-write URL's in imported files so that the
|
||||
* URL is always relative to the base imported file */
|
||||
rewriteUrls: false,
|
||||
/* How to process math
|
||||
|
||||
/* How to process math
|
||||
* 0 always - eagerly try to solve all operations
|
||||
* 1 parens-division - require parens for division "/"
|
||||
* 2 parens | strict - require parens for all operations
|
||||
* 3 strict-legacy - legacy strict behavior (super-strict)
|
||||
*/
|
||||
math: 1,
|
||||
|
||||
/* Without this option, less attempts to guess at the output unit when it does maths. */
|
||||
strictUnits: false,
|
||||
/* Effectively the declaration is put at the top of your base Less file,
|
||||
* meaning it can be used but it also can be overridden if this variable
|
||||
|
||||
/* Effectively the declaration is put at the top of your base Less file,
|
||||
* meaning it can be used but it also can be overridden if this variable
|
||||
* is defined in the file. */
|
||||
globalVars: null,
|
||||
|
||||
/* As opposed to the global variable option, this puts the declaration at the
|
||||
* end of your base file, meaning it will override anything defined in your Less file. */
|
||||
modifyVars: null,
|
||||
|
||||
/* This option allows you to specify a argument to go on to every URL. */
|
||||
urlArgs: ''
|
||||
};
|
||||
}
|
||||
exports.default = default_1;
|
||||
//# sourceMappingURL=default-options.js.map
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"default-options.js","sourceRoot":"","sources":["../../src/less/default-options.js"],"names":[],"mappings":";;AAAA,iCAAiC;AACjC;IACI,OAAO;QACH,+CAA+C;QAC/C,iBAAiB,EAAE,KAAK;QAExB,0DAA0D;QAC1D,OAAO,EAAE,KAAK;QAEd;;wCAEgC;QAChC,QAAQ,EAAE,KAAK;QAEf,sEAAsE;QACtE,IAAI,EAAE,KAAK;QAEX;;;;gFAIwE;QACxE,KAAK,EAAE,EAAE;QAET,kCAAkC;QAClC,KAAK,EAAE,IAAI;QAEX;;6DAEqD;QACrD,aAAa,EAAE,KAAK;QAEpB,6CAA6C;QAC7C,QAAQ,EAAE,KAAK;QAEf;;8CAEsC;QACtC,QAAQ,EAAE,EAAE;QAEZ;;;8DAGsD;QACtD,WAAW,EAAE,KAAK;QAElB;;;;;WAKG;QACH,IAAI,EAAE,CAAC;QAEP,wFAAwF;QACxF,WAAW,EAAE,KAAK;QAElB;;qCAE6B;QAC7B,UAAU,EAAE,IAAI;QAEhB;iGACyF;QACzF,UAAU,EAAE,IAAI;QAEhB,0EAA0E;QAC1E,OAAO,EAAE,EAAE;KACd,CAAA;AACL,CAAC;AApED,4BAoEC","sourcesContent":["// Export a new default each time\nexport default function() {\n return {\n /* Inline Javascript - @plugin still allowed */\n javascriptEnabled: false,\n\n /* Outputs a makefile import dependency list to stdout. */\n depends: false,\n\n /* (DEPRECATED) Compress using less built-in compression. \n * This does an okay job but does not utilise all the tricks of \n * dedicated css compression. */\n compress: false,\n\n /* Runs the less parser and just reports errors without any output. */\n lint: false,\n\n /* Sets available include paths.\n * If the file in an @import rule does not exist at that exact location, \n * less will look for it at the location(s) passed to this option. \n * You might use this for instance to specify a path to a library which \n * you want to be referenced simply and relatively in the less files. */\n paths: [],\n\n /* color output in the terminal */\n color: true,\n\n /* The strictImports controls whether the compiler will allow an @import inside of either \n * @media blocks or (a later addition) other selector blocks.\n * See: https://github.com/less/less.js/issues/656 */\n strictImports: false,\n\n /* Allow Imports from Insecure HTTPS Hosts */\n insecure: false,\n\n /* Allows you to add a path to every generated import and url in your css. \n * This does not affect less import statements that are processed, just ones \n * that are left in the output css. */\n rootpath: '',\n\n /* By default URLs are kept as-is, so if you import a file in a sub-directory \n * that references an image, exactly the same URL will be output in the css. \n * This option allows you to re-write URL's in imported files so that the \n * URL is always relative to the base imported file */\n rewriteUrls: false,\n\n /* How to process math \n * 0 always - eagerly try to solve all operations\n * 1 parens-division - require parens for division \"/\"\n * 2 parens | strict - require parens for all operations\n * 3 strict-legacy - legacy strict behavior (super-strict)\n */\n math: 1,\n\n /* Without this option, less attempts to guess at the output unit when it does maths. */\n strictUnits: false,\n\n /* Effectively the declaration is put at the top of your base Less file, \n * meaning it can be used but it also can be overridden if this variable \n * is defined in the file. */\n globalVars: null,\n\n /* As opposed to the global variable option, this puts the declaration at the\n * end of your base file, meaning it will override anything defined in your Less file. */\n modifyVars: null,\n\n /* This option allows you to specify a argument to go on to every URL. */\n urlArgs: ''\n }\n}"]}
|
||||
+62
-50
@@ -1,10 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var AbstractFileManager = /** @class */ (function () {
|
||||
function AbstractFileManager() {
|
||||
}
|
||||
AbstractFileManager.prototype.getPath = function (filename) {
|
||||
var j = filename.lastIndexOf('?');
|
||||
class AbstractFileManager {
|
||||
getPath(filename) {
|
||||
let j = filename.lastIndexOf('?');
|
||||
if (j > 0) {
|
||||
filename = filename.slice(0, j);
|
||||
}
|
||||
@@ -16,46 +12,53 @@ var AbstractFileManager = /** @class */ (function () {
|
||||
return '';
|
||||
}
|
||||
return filename.slice(0, j + 1);
|
||||
};
|
||||
AbstractFileManager.prototype.tryAppendExtension = function (path, ext) {
|
||||
}
|
||||
|
||||
tryAppendExtension(path, ext) {
|
||||
return /(\.[a-z]*$)|([?;].*)$/.test(path) ? path : path + ext;
|
||||
};
|
||||
AbstractFileManager.prototype.tryAppendLessExtension = function (path) {
|
||||
}
|
||||
|
||||
tryAppendLessExtension(path) {
|
||||
return this.tryAppendExtension(path, '.less');
|
||||
};
|
||||
AbstractFileManager.prototype.supportsSync = function () {
|
||||
}
|
||||
|
||||
supportsSync() {
|
||||
return false;
|
||||
};
|
||||
AbstractFileManager.prototype.alwaysMakePathsAbsolute = function () {
|
||||
}
|
||||
|
||||
alwaysMakePathsAbsolute() {
|
||||
return false;
|
||||
};
|
||||
AbstractFileManager.prototype.isPathAbsolute = function (filename) {
|
||||
}
|
||||
|
||||
isPathAbsolute(filename) {
|
||||
return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: pull out / replace?
|
||||
AbstractFileManager.prototype.join = function (basePath, laterPath) {
|
||||
join(basePath, laterPath) {
|
||||
if (!basePath) {
|
||||
return laterPath;
|
||||
}
|
||||
return basePath + laterPath;
|
||||
};
|
||||
AbstractFileManager.prototype.pathDiff = function (url, baseUrl) {
|
||||
}
|
||||
|
||||
pathDiff(url, baseUrl) {
|
||||
// diff between two paths to create a relative path
|
||||
var urlParts = this.extractUrlParts(url);
|
||||
var baseUrlParts = this.extractUrlParts(baseUrl);
|
||||
var i;
|
||||
var max;
|
||||
var urlDirectories;
|
||||
var baseUrlDirectories;
|
||||
var diff = '';
|
||||
|
||||
const urlParts = this.extractUrlParts(url);
|
||||
|
||||
const baseUrlParts = this.extractUrlParts(baseUrl);
|
||||
let i;
|
||||
let max;
|
||||
let urlDirectories;
|
||||
let baseUrlDirectories;
|
||||
let diff = '';
|
||||
if (urlParts.hostPart !== baseUrlParts.hostPart) {
|
||||
return '';
|
||||
}
|
||||
max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
|
||||
for (i = 0; i < max; i++) {
|
||||
if (baseUrlParts.directories[i] !== urlParts.directories[i]) {
|
||||
break;
|
||||
}
|
||||
if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
|
||||
}
|
||||
baseUrlDirectories = baseUrlParts.directories.slice(i);
|
||||
urlDirectories = urlParts.directories.slice(i);
|
||||
@@ -63,56 +66,66 @@ var AbstractFileManager = /** @class */ (function () {
|
||||
diff += '../';
|
||||
}
|
||||
for (i = 0; i < urlDirectories.length - 1; i++) {
|
||||
diff += "".concat(urlDirectories[i], "/");
|
||||
diff += `${urlDirectories[i]}/`;
|
||||
}
|
||||
return diff;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function, not part of API.
|
||||
* This should be replaceable by newer Node / Browser APIs
|
||||
*
|
||||
* @param {string} url
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} baseUrl
|
||||
*/
|
||||
AbstractFileManager.prototype.extractUrlParts = function (url, baseUrl) {
|
||||
extractUrlParts(url, baseUrl) {
|
||||
// urlParts[1] = protocol://hostname/ OR /
|
||||
// urlParts[2] = / if path relative to host base
|
||||
// urlParts[3] = directories
|
||||
// urlParts[4] = filename
|
||||
// urlParts[5] = parameters
|
||||
var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i;
|
||||
var urlParts = url.match(urlPartsRegex);
|
||||
var returner = {};
|
||||
var rawDirectories = [];
|
||||
var directories = [];
|
||||
var i;
|
||||
var baseUrlParts;
|
||||
|
||||
const urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^/?#]*\/)|([/\\]))?((?:[^/\\?#]*[/\\])*)([^/\\?#]*)([#?].*)?$/i;
|
||||
|
||||
const urlParts = url.match(urlPartsRegex);
|
||||
const returner = {};
|
||||
let rawDirectories = [];
|
||||
const directories = [];
|
||||
let i;
|
||||
let baseUrlParts;
|
||||
|
||||
if (!urlParts) {
|
||||
throw new Error("Could not parse sheet href - '".concat(url, "'"));
|
||||
throw new Error(`Could not parse sheet href - '${url}'`);
|
||||
}
|
||||
|
||||
// Stylesheets in IE don't always return the full path
|
||||
if (baseUrl && (!urlParts[1] || urlParts[2])) {
|
||||
baseUrlParts = baseUrl.match(urlPartsRegex);
|
||||
if (!baseUrlParts) {
|
||||
throw new Error("Could not parse page url - '".concat(baseUrl, "'"));
|
||||
throw new Error(`Could not parse page url - '${baseUrl}'`);
|
||||
}
|
||||
urlParts[1] = urlParts[1] || baseUrlParts[1] || '';
|
||||
if (!urlParts[2]) {
|
||||
urlParts[3] = baseUrlParts[3] + urlParts[3];
|
||||
}
|
||||
}
|
||||
|
||||
if (urlParts[3]) {
|
||||
rawDirectories = urlParts[3].replace(/\\/g, '/').split('/');
|
||||
|
||||
// collapse '..' and skip '.'
|
||||
for (i = 0; i < rawDirectories.length; i++) {
|
||||
|
||||
if (rawDirectories[i] === '..') {
|
||||
directories.pop();
|
||||
}
|
||||
else if (rawDirectories[i] !== '.') {
|
||||
directories.push(rawDirectories[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
returner.hostPart = urlParts[1];
|
||||
returner.directories = directories;
|
||||
returner.rawPath = (urlParts[1] || '') + rawDirectories.join('/');
|
||||
@@ -121,8 +134,7 @@ var AbstractFileManager = /** @class */ (function () {
|
||||
returner.fileUrl = returner.path + (urlParts[4] || '');
|
||||
returner.url = returner.fileUrl + (urlParts[5] || '');
|
||||
return returner;
|
||||
};
|
||||
return AbstractFileManager;
|
||||
}());
|
||||
exports.default = AbstractFileManager;
|
||||
//# sourceMappingURL=abstract-file-manager.js.map
|
||||
}
|
||||
}
|
||||
|
||||
export default AbstractFileManager;
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+69
-46
@@ -1,18 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var function_registry_1 = tslib_1.__importDefault(require("../functions/function-registry"));
|
||||
var less_error_1 = tslib_1.__importDefault(require("../less-error"));
|
||||
var AbstractPluginLoader = /** @class */ (function () {
|
||||
function AbstractPluginLoader() {
|
||||
import functionRegistry from '../functions/function-registry.js';
|
||||
import LessError from '../less-error.js';
|
||||
|
||||
class AbstractPluginLoader {
|
||||
constructor() {
|
||||
// Implemented by Node.js plugin loader
|
||||
this.require = function () {
|
||||
this.require = function() {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
AbstractPluginLoader.prototype.evalPlugin = function (contents, context, imports, pluginOptions, fileInfo) {
|
||||
var loader, registry, pluginObj, localModule, pluginManager, filename, result;
|
||||
|
||||
evalPlugin(contents, context, imports, pluginOptions, fileInfo) {
|
||||
|
||||
let loader, registry, pluginObj, localModule, pluginManager, filename, result;
|
||||
|
||||
pluginManager = context.pluginManager;
|
||||
|
||||
if (fileInfo) {
|
||||
if (typeof fileInfo === 'string') {
|
||||
filename = fileInfo;
|
||||
@@ -21,9 +23,11 @@ var AbstractPluginLoader = /** @class */ (function () {
|
||||
filename = fileInfo.filename;
|
||||
}
|
||||
}
|
||||
var shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;
|
||||
const shortname = (new this.less.FileManager()).extractUrlParts(filename).filename;
|
||||
|
||||
if (filename) {
|
||||
pluginObj = pluginManager.get(filename);
|
||||
|
||||
if (pluginObj) {
|
||||
result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
|
||||
if (result) {
|
||||
@@ -36,52 +40,62 @@ var AbstractPluginLoader = /** @class */ (function () {
|
||||
}
|
||||
catch (e) {
|
||||
e.message = e.message || 'Error during @plugin call';
|
||||
return new less_error_1.default(e, imports, filename);
|
||||
return new LessError(e, imports, filename);
|
||||
}
|
||||
return pluginObj;
|
||||
}
|
||||
}
|
||||
localModule = {
|
||||
exports: {},
|
||||
pluginManager: pluginManager,
|
||||
fileInfo: fileInfo
|
||||
pluginManager,
|
||||
fileInfo
|
||||
};
|
||||
registry = function_registry_1.default.create();
|
||||
var registerPlugin = function (obj) {
|
||||
registry = functionRegistry.create();
|
||||
|
||||
const registerPlugin = function(obj) {
|
||||
pluginObj = obj;
|
||||
};
|
||||
|
||||
try {
|
||||
loader = new Function('module', 'require', 'registerPlugin', 'functions', 'tree', 'less', 'fileInfo', contents);
|
||||
loader(localModule, this.require(filename), registerPlugin, registry, this.less.tree, this.less, fileInfo);
|
||||
}
|
||||
catch (e) {
|
||||
return new less_error_1.default(e, imports, filename);
|
||||
return new LessError(e, imports, filename);
|
||||
}
|
||||
|
||||
if (!pluginObj) {
|
||||
pluginObj = localModule.exports;
|
||||
}
|
||||
pluginObj = this.validatePlugin(pluginObj, filename, shortname);
|
||||
if (pluginObj instanceof less_error_1.default) {
|
||||
|
||||
if (pluginObj instanceof LessError) {
|
||||
return pluginObj;
|
||||
}
|
||||
|
||||
if (pluginObj) {
|
||||
pluginObj.imports = imports;
|
||||
pluginObj.filename = filename;
|
||||
|
||||
// For < 3.x (or unspecified minVersion) - setOptions() before install()
|
||||
if (!pluginObj.minVersion || this.compareVersion('3.0.0', pluginObj.minVersion) < 0) {
|
||||
result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Run on first load
|
||||
pluginManager.addPlugin(pluginObj, fileInfo.filename, registry);
|
||||
pluginObj.functions = registry.getLocalFunctions();
|
||||
|
||||
// Need to call setOptions again because the pluginObj might have functions
|
||||
result = this.trySetOptions(pluginObj, filename, shortname, pluginOptions);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Run every @plugin call
|
||||
try {
|
||||
if (pluginObj.use) {
|
||||
@@ -90,73 +104,82 @@ var AbstractPluginLoader = /** @class */ (function () {
|
||||
}
|
||||
catch (e) {
|
||||
e.message = e.message || 'Error during @plugin call';
|
||||
return new less_error_1.default(e, imports, filename);
|
||||
return new LessError(e, imports, filename);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
return new less_error_1.default({ message: 'Not a valid plugin' }, imports, filename);
|
||||
return new LessError({ message: 'Not a valid plugin' }, imports, filename);
|
||||
}
|
||||
|
||||
return pluginObj;
|
||||
};
|
||||
AbstractPluginLoader.prototype.trySetOptions = function (plugin, filename, name, options) {
|
||||
|
||||
}
|
||||
|
||||
trySetOptions(plugin, filename, name, options) {
|
||||
if (options && !plugin.setOptions) {
|
||||
return new less_error_1.default({
|
||||
message: "Options have been provided but the plugin ".concat(name, " does not support any options.")
|
||||
return new LessError({
|
||||
message: `Options have been provided but the plugin ${name} does not support any options.`
|
||||
});
|
||||
}
|
||||
try {
|
||||
plugin.setOptions && plugin.setOptions(options);
|
||||
}
|
||||
catch (e) {
|
||||
return new less_error_1.default(e);
|
||||
return new LessError(e);
|
||||
}
|
||||
};
|
||||
AbstractPluginLoader.prototype.validatePlugin = function (plugin, filename, name) {
|
||||
}
|
||||
|
||||
validatePlugin(plugin, filename, name) {
|
||||
if (plugin) {
|
||||
// support plugins being a function
|
||||
// so that the plugin can be more usable programmatically
|
||||
if (typeof plugin === 'function') {
|
||||
plugin = new plugin();
|
||||
}
|
||||
|
||||
if (plugin.minVersion) {
|
||||
if (this.compareVersion(plugin.minVersion, this.less.version) < 0) {
|
||||
return new less_error_1.default({
|
||||
message: "Plugin ".concat(name, " requires version ").concat(this.versionToString(plugin.minVersion))
|
||||
return new LessError({
|
||||
message: `Plugin ${name} requires version ${this.versionToString(plugin.minVersion)}`
|
||||
});
|
||||
}
|
||||
}
|
||||
return plugin;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
AbstractPluginLoader.prototype.compareVersion = function (aVersion, bVersion) {
|
||||
}
|
||||
|
||||
compareVersion(aVersion, bVersion) {
|
||||
if (typeof aVersion === 'string') {
|
||||
aVersion = aVersion.match(/^(\d+)\.?(\d+)?\.?(\d+)?/);
|
||||
aVersion.shift();
|
||||
}
|
||||
for (var i = 0; i < aVersion.length; i++) {
|
||||
for (let i = 0; i < aVersion.length; i++) {
|
||||
if (aVersion[i] !== bVersion[i]) {
|
||||
return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
AbstractPluginLoader.prototype.versionToString = function (version) {
|
||||
var versionString = '';
|
||||
for (var i = 0; i < version.length; i++) {
|
||||
}
|
||||
|
||||
versionToString(version) {
|
||||
let versionString = '';
|
||||
for (let i = 0; i < version.length; i++) {
|
||||
versionString += (versionString ? '.' : '') + version[i];
|
||||
}
|
||||
return versionString;
|
||||
};
|
||||
AbstractPluginLoader.prototype.printUsage = function (plugins) {
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
var plugin = plugins[i];
|
||||
}
|
||||
|
||||
printUsage(plugins) {
|
||||
for (let i = 0; i < plugins.length; i++) {
|
||||
const plugin = plugins[i];
|
||||
if (plugin.printUsage) {
|
||||
plugin.printUsage();
|
||||
}
|
||||
}
|
||||
};
|
||||
return AbstractPluginLoader;
|
||||
}());
|
||||
exports.default = AbstractPluginLoader;
|
||||
//# sourceMappingURL=abstract-plugin-loader.js.map
|
||||
}
|
||||
}
|
||||
|
||||
export default AbstractPluginLoader;
|
||||
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
-3
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=environment-api.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"environment-api.js","sourceRoot":"","sources":["../../../src/less/environment/environment-api.ts"],"names":[],"mappings":"","sourcesContent":["export interface Environment {\n /**\n * Converts a string to a base 64 string\n */\n encodeBase64(str: string): string\n /**\n * Lookup the mime-type of a filename\n */\n mimeLookup(filename: string): string\n /**\n * Look up the charset of a mime type\n * @param mime\n */\n charsetLookup(mime: string): string\n /**\n * Gets a source map generator\n *\n * @todo - Figure out precise type\n */\n getSourceMapGenerator(): any\n}\n"]}
|
||||
+34
-30
@@ -1,55 +1,59 @@
|
||||
"use strict";
|
||||
/**
|
||||
* @todo Document why this abstraction exists, and the relationship between
|
||||
* environment, file managers, and plugin manager
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var logger_1 = tslib_1.__importDefault(require("../logger"));
|
||||
var Environment = /** @class */ (function () {
|
||||
function Environment(externalEnvironment, fileManagers) {
|
||||
|
||||
import logger from '../logger.js';
|
||||
|
||||
class Environment {
|
||||
constructor(externalEnvironment, fileManagers) {
|
||||
this.fileManagers = fileManagers || [];
|
||||
externalEnvironment = externalEnvironment || {};
|
||||
var optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];
|
||||
var requiredFunctions = [];
|
||||
var functions = requiredFunctions.concat(optionalFunctions);
|
||||
for (var i = 0; i < functions.length; i++) {
|
||||
var propName = functions[i];
|
||||
var environmentFunc = externalEnvironment[propName];
|
||||
|
||||
const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];
|
||||
const requiredFunctions = [];
|
||||
const functions = requiredFunctions.concat(optionalFunctions);
|
||||
|
||||
for (let i = 0; i < functions.length; i++) {
|
||||
const propName = functions[i];
|
||||
const environmentFunc = externalEnvironment[propName];
|
||||
if (environmentFunc) {
|
||||
this[propName] = environmentFunc.bind(externalEnvironment);
|
||||
}
|
||||
else if (i < requiredFunctions.length) {
|
||||
this.warn("missing required function in environment - ".concat(propName));
|
||||
} else if (i < requiredFunctions.length) {
|
||||
this.warn(`missing required function in environment - ${propName}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Environment.prototype.getFileManager = function (filename, currentDirectory, options, environment, isSync) {
|
||||
|
||||
getFileManager(filename, currentDirectory, options, environment, isSync) {
|
||||
|
||||
if (!filename) {
|
||||
logger_1.default.warn('getFileManager called with no filename.. Please report this issue. continuing.');
|
||||
logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');
|
||||
}
|
||||
if (currentDirectory === undefined) {
|
||||
logger_1.default.warn('getFileManager called with null directory.. Please report this issue. continuing.');
|
||||
logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');
|
||||
}
|
||||
var fileManagers = this.fileManagers;
|
||||
|
||||
let fileManagers = this.fileManagers;
|
||||
if (options.pluginManager) {
|
||||
fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());
|
||||
}
|
||||
for (var i = fileManagers.length - 1; i >= 0; i--) {
|
||||
var fileManager = fileManagers[i];
|
||||
for (let i = fileManagers.length - 1; i >= 0 ; i--) {
|
||||
const fileManager = fileManagers[i];
|
||||
if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {
|
||||
return fileManager;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
Environment.prototype.addFileManager = function (fileManager) {
|
||||
}
|
||||
|
||||
addFileManager(fileManager) {
|
||||
this.fileManagers.push(fileManager);
|
||||
};
|
||||
Environment.prototype.clearFileManagers = function () {
|
||||
}
|
||||
|
||||
clearFileManagers() {
|
||||
this.fileManagers = [];
|
||||
};
|
||||
return Environment;
|
||||
}());
|
||||
exports.default = Environment;
|
||||
//# sourceMappingURL=environment.js.map
|
||||
}
|
||||
}
|
||||
|
||||
export default Environment;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/less/environment/environment.js"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAA+B;AAE/B;IACI,qBAAY,mBAAmB,EAAE,YAAY;QACzC,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,mBAAmB,GAAG,mBAAmB,IAAI,EAAE,CAAC;QAEhD,IAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,uBAAuB,CAAC,CAAC;QACnG,IAAM,iBAAiB,GAAG,EAAE,CAAC;QAC7B,IAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAE9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvC,IAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC9B,IAAM,eAAe,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YACtD,IAAI,eAAe,EAAE;gBACjB,IAAI,CAAC,QAAQ,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;aAC9D;iBAAM,IAAI,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE;gBACrC,IAAI,CAAC,IAAI,CAAC,qDAA8C,QAAQ,CAAE,CAAC,CAAC;aACvE;SACJ;IACL,CAAC;IAED,oCAAc,GAAd,UAAe,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM;QAEnE,IAAI,CAAC,QAAQ,EAAE;YACX,gBAAM,CAAC,IAAI,CAAC,gFAAgF,CAAC,CAAC;SACjG;QACD,IAAI,gBAAgB,KAAK,SAAS,EAAE;YAChC,gBAAM,CAAC,IAAI,CAAC,mFAAmF,CAAC,CAAC;SACpG;QAED,IAAI,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACrC,IAAI,OAAO,CAAC,aAAa,EAAE;YACvB,YAAY,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC;SAC1F;QACD,KAAK,IAAI,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAG,CAAC,EAAE,EAAE;YAChD,IAAM,WAAW,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE;gBACrG,OAAO,WAAW,CAAC;aACtB;SACJ;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,oCAAc,GAAd,UAAe,WAAW;QACtB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACxC,CAAC;IAED,uCAAiB,GAAjB;QACI,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IAC3B,CAAC;IACL,kBAAC;AAAD,CAAC,AAjDD,IAiDC;AAED,kBAAe,WAAW,CAAC","sourcesContent":["/**\n * @todo Document why this abstraction exists, and the relationship between\n * environment, file managers, and plugin manager\n */\n\nimport logger from '../logger';\n\nclass Environment {\n constructor(externalEnvironment, fileManagers) {\n this.fileManagers = fileManagers || [];\n externalEnvironment = externalEnvironment || {};\n\n const optionalFunctions = ['encodeBase64', 'mimeLookup', 'charsetLookup', 'getSourceMapGenerator'];\n const requiredFunctions = [];\n const functions = requiredFunctions.concat(optionalFunctions);\n\n for (let i = 0; i < functions.length; i++) {\n const propName = functions[i];\n const environmentFunc = externalEnvironment[propName];\n if (environmentFunc) {\n this[propName] = environmentFunc.bind(externalEnvironment);\n } else if (i < requiredFunctions.length) {\n this.warn(`missing required function in environment - ${propName}`);\n }\n }\n }\n\n getFileManager(filename, currentDirectory, options, environment, isSync) {\n\n if (!filename) {\n logger.warn('getFileManager called with no filename.. Please report this issue. continuing.');\n }\n if (currentDirectory === undefined) {\n logger.warn('getFileManager called with null directory.. Please report this issue. continuing.');\n }\n\n let fileManagers = this.fileManagers;\n if (options.pluginManager) {\n fileManagers = [].concat(fileManagers).concat(options.pluginManager.getFileManagers());\n }\n for (let i = fileManagers.length - 1; i >= 0 ; i--) {\n const fileManager = fileManagers[i];\n if (fileManager[isSync ? 'supportsSync' : 'supports'](filename, currentDirectory, options, environment)) {\n return fileManager;\n }\n }\n return null;\n }\n\n addFileManager(fileManager) {\n this.fileManagers.push(fileManager);\n }\n\n clearFileManagers() {\n this.fileManagers = [];\n }\n}\n\nexport default Environment;\n"]}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=file-manager-api.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"file-manager-api.js","sourceRoot":"","sources":["../../../src/less/environment/file-manager-api.ts"],"names":[],"mappings":"","sourcesContent":["import type { Environment } from './environment-api'\n\nexport interface FileManager {\n /**\n * Given the full path to a file, return the path component\n * Provided by AbstractFileManager\n */\n getPath(filename: string): string\n /**\n * Append a .less extension if appropriate. Only called if less thinks one could be added.\n * Provided by AbstractFileManager\n */\n tryAppendLessExtension(filename: string): string\n /**\n * Whether the rootpath should be converted to be absolute.\n * The browser ovverides this to return true because urls must be absolute.\n * Provided by AbstractFileManager (returns false)\n */\n alwaysMakePathsAbsolute(): boolean\n /**\n * Returns whether a path is absolute\n * Provided by AbstractFileManager\n */\n isPathAbsolute(path: string): boolean\n /**\n * joins together 2 paths\n * Provided by AbstractFileManager\n */\n join(basePath: string, laterPath: string): string\n /**\n * Returns the difference between 2 paths\n * E.g. url = a/ baseUrl = a/b/ returns ../\n * url = a/b/ baseUrl = a/ returns b/\n * Provided by AbstractFileManager\n */\n pathDiff(url: string, baseUrl: string): string\n /**\n * Returns whether this file manager supports this file for syncronous file retrieval\n * If true is returned, loadFileSync will then be called with the file.\n * Provided by AbstractFileManager (returns false)\n * \n * @todo - Narrow Options type\n */\n supportsSync(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): boolean\n /**\n * If file manager supports async file retrieval for this file type\n */\n supports(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): boolean\n /**\n * Loads a file asynchronously.\n */\n loadFile(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): Promise<{ filename: string, contents: string }>\n /**\n * Loads a file synchronously. Expects an immediate return with an object\n */\n loadFileSync(\n filename: string,\n currentDirectory: string,\n options: Record<string, any>,\n environment: Environment\n ): { error?: unknown, filename: string, contents: string }\n}\n"]}
|
||||
+13
-13
@@ -1,29 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
||||
var keyword_1 = tslib_1.__importDefault(require("../tree/keyword"));
|
||||
import Anonymous from '../tree/anonymous.js';
|
||||
import Keyword from '../tree/keyword.js';
|
||||
|
||||
function boolean(condition) {
|
||||
return condition ? keyword_1.default.True : keyword_1.default.False;
|
||||
return condition ? Keyword.True : Keyword.False;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions with evalArgs set to false are sent context
|
||||
* as the first argument.
|
||||
*/
|
||||
function If(context, condition, trueValue, falseValue) {
|
||||
return condition.eval(context) ? trueValue.eval(context)
|
||||
: (falseValue ? falseValue.eval(context) : new anonymous_1.default);
|
||||
: (falseValue ? falseValue.eval(context) : new Anonymous);
|
||||
}
|
||||
If.evalArgs = false;
|
||||
|
||||
function isdefined(context, variable) {
|
||||
try {
|
||||
variable.eval(context);
|
||||
return keyword_1.default.True;
|
||||
}
|
||||
catch (e) {
|
||||
return keyword_1.default.False;
|
||||
return Keyword.True;
|
||||
} catch (e) {
|
||||
return Keyword.False;
|
||||
}
|
||||
}
|
||||
|
||||
isdefined.evalArgs = false;
|
||||
exports.default = { isdefined: isdefined, boolean: boolean, 'if': If };
|
||||
//# sourceMappingURL=boolean.js.map
|
||||
|
||||
export default { isdefined, boolean, 'if': If };
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/less/functions/boolean.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAC1C,oEAAsC;AAEtC,SAAS,OAAO,CAAC,SAAS;IACtB,OAAO,SAAS,CAAC,CAAC,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAO,CAAC,KAAK,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH,SAAS,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU;IACjD,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC;QACpD,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,mBAAS,CAAC,CAAC;AAClE,CAAC;AACD,EAAE,CAAC,QAAQ,GAAG,KAAK,CAAC;AAEpB,SAAS,SAAS,CAAC,OAAO,EAAE,QAAQ;IAChC,IAAI;QACA,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,iBAAO,CAAC,IAAI,CAAC;KACvB;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,iBAAO,CAAC,KAAK,CAAC;KACxB;AACL,CAAC;AAED,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC;AAE3B,kBAAe,EAAE,SAAS,WAAA,EAAE,OAAO,SAAA,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC","sourcesContent":["import Anonymous from '../tree/anonymous';\nimport Keyword from '../tree/keyword';\n\nfunction boolean(condition) {\n return condition ? Keyword.True : Keyword.False;\n}\n\n/**\n * Functions with evalArgs set to false are sent context\n * as the first argument.\n */\nfunction If(context, condition, trueValue, falseValue) {\n return condition.eval(context) ? trueValue.eval(context)\n : (falseValue ? falseValue.eval(context) : new Anonymous);\n}\nIf.evalArgs = false;\n\nfunction isdefined(context, variable) {\n try {\n variable.eval(context);\n return Keyword.True;\n } catch (e) {\n return Keyword.False;\n }\n}\n\nisdefined.evalArgs = false;\n\nexport default { isdefined, boolean, 'if': If };\n"]}
|
||||
+39
-31
@@ -1,48 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var color_1 = tslib_1.__importDefault(require("../tree/color"));
|
||||
import Color from '../tree/color.js';
|
||||
|
||||
// Color Blending
|
||||
// ref: http://www.w3.org/TR/compositing-1
|
||||
|
||||
function colorBlend(mode, color1, color2) {
|
||||
var ab = color1.alpha; // result
|
||||
var // backdrop
|
||||
cb;
|
||||
var as = color2.alpha;
|
||||
var // source
|
||||
cs;
|
||||
var ar;
|
||||
var cr;
|
||||
var r = [];
|
||||
const ab = color1.alpha; // result
|
||||
|
||||
let // backdrop
|
||||
cb;
|
||||
|
||||
const as = color2.alpha;
|
||||
|
||||
let // source
|
||||
cs;
|
||||
|
||||
let ar;
|
||||
let cr;
|
||||
const r = [];
|
||||
|
||||
ar = as + ab * (1 - as);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
cb = color1.rgb[i] / 255;
|
||||
cs = color2.rgb[i] / 255;
|
||||
cr = mode(cb, cs);
|
||||
if (ar) {
|
||||
cr = (as * cs + ab * (cb -
|
||||
as * (cb + cs - cr))) / ar;
|
||||
as * (cb + cs - cr))) / ar;
|
||||
}
|
||||
r[i] = cr * 255;
|
||||
}
|
||||
return new color_1.default(r, ar);
|
||||
|
||||
return new Color(r, ar);
|
||||
}
|
||||
var colorBlendModeFunctions = {
|
||||
multiply: function (cb, cs) {
|
||||
|
||||
const colorBlendModeFunctions = {
|
||||
multiply: function(cb, cs) {
|
||||
return cb * cs;
|
||||
},
|
||||
screen: function (cb, cs) {
|
||||
screen: function(cb, cs) {
|
||||
return cb + cs - cb * cs;
|
||||
},
|
||||
overlay: function (cb, cs) {
|
||||
overlay: function(cb, cs) {
|
||||
cb *= 2;
|
||||
return (cb <= 1) ?
|
||||
colorBlendModeFunctions.multiply(cb, cs) :
|
||||
colorBlendModeFunctions.screen(cb - 1, cs);
|
||||
},
|
||||
softlight: function (cb, cs) {
|
||||
var d = 1;
|
||||
var e = cb;
|
||||
softlight: function(cb, cs) {
|
||||
let d = 1;
|
||||
let e = cb;
|
||||
if (cs > 0.5) {
|
||||
e = 1;
|
||||
d = (cb > 0.25) ? Math.sqrt(cb)
|
||||
@@ -50,28 +56,30 @@ var colorBlendModeFunctions = {
|
||||
}
|
||||
return cb - (1 - 2 * cs) * e * (d - cb);
|
||||
},
|
||||
hardlight: function (cb, cs) {
|
||||
hardlight: function(cb, cs) {
|
||||
return colorBlendModeFunctions.overlay(cs, cb);
|
||||
},
|
||||
difference: function (cb, cs) {
|
||||
difference: function(cb, cs) {
|
||||
return Math.abs(cb - cs);
|
||||
},
|
||||
exclusion: function (cb, cs) {
|
||||
exclusion: function(cb, cs) {
|
||||
return cb + cs - 2 * cb * cs;
|
||||
},
|
||||
|
||||
// non-w3c functions:
|
||||
average: function (cb, cs) {
|
||||
average: function(cb, cs) {
|
||||
return (cb + cs) / 2;
|
||||
},
|
||||
negation: function (cb, cs) {
|
||||
negation: function(cb, cs) {
|
||||
return 1 - Math.abs(cb + cs - 1);
|
||||
}
|
||||
};
|
||||
for (var f in colorBlendModeFunctions) {
|
||||
|
||||
for (const f in colorBlendModeFunctions) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (colorBlendModeFunctions.hasOwnProperty(f)) {
|
||||
colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);
|
||||
}
|
||||
}
|
||||
exports.default = colorBlend;
|
||||
//# sourceMappingURL=color-blending.js.map
|
||||
|
||||
export default colorBlend;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"color-blending.js","sourceRoot":"","sources":["../../../src/less/functions/color-blending.js"],"names":[],"mappings":";;;AAAA,gEAAkC;AAElC,iBAAiB;AACjB,0CAA0C;AAE1C,SAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM;IACpC,IAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAQ,SAAS;IAEzC,IAAI,WAAW;IACX,EAAE,CAAC;IAEP,IAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;IAExB,IAAI,SAAS;IACT,EAAE,CAAC;IAEP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAM,CAAC,GAAG,EAAE,CAAC;IAEb,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QACxB,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;QACzB,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAClB,IAAI,EAAE,EAAE;YACJ,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;gBAClB,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;SACpC;QACD,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;KACnB;IAED,OAAO,IAAI,eAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC5B,CAAC;AAED,IAAM,uBAAuB,GAAG;IAC5B,QAAQ,EAAE,UAAS,EAAE,EAAE,EAAE;QACrB,OAAO,EAAE,GAAG,EAAE,CAAC;IACnB,CAAC;IACD,MAAM,EAAE,UAAS,EAAE,EAAE,EAAE;QACnB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAC7B,CAAC;IACD,OAAO,EAAE,UAAS,EAAE,EAAE,EAAE;QACpB,EAAE,IAAI,CAAC,CAAC;QACR,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;YACd,uBAAuB,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;YAC1C,uBAAuB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,SAAS,EAAE,UAAS,EAAE,EAAE,EAAE;QACtB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,EAAE,GAAG,GAAG,EAAE;YACV,CAAC,GAAG,CAAC,CAAC;YACN,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;SACxC;QACD,OAAO,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C,CAAC;IACD,SAAS,EAAE,UAAS,EAAE,EAAE,EAAE;QACtB,OAAO,uBAAuB,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,UAAU,EAAE,UAAS,EAAE,EAAE,EAAE;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7B,CAAC;IACD,SAAS,EAAE,UAAS,EAAE,EAAE,EAAE;QACtB,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,qBAAqB;IACrB,OAAO,EAAE,UAAS,EAAE,EAAE,EAAE;QACpB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IACD,QAAQ,EAAE,UAAS,EAAE,EAAE,EAAE;QACrB,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,KAAK,IAAM,CAAC,IAAI,uBAAuB,EAAE;IACrC,iDAAiD;IACjD,IAAI,uBAAuB,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QAC3C,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;KACrE;CACJ;AAED,kBAAe,UAAU,CAAC","sourcesContent":["import Color from '../tree/color';\n\n// Color Blending\n// ref: http://www.w3.org/TR/compositing-1\n\nfunction colorBlend(mode, color1, color2) {\n const ab = color1.alpha; // result\n\n let // backdrop\n cb;\n\n const as = color2.alpha;\n\n let // source\n cs;\n\n let ar;\n let cr;\n const r = [];\n\n ar = as + ab * (1 - as);\n for (let i = 0; i < 3; i++) {\n cb = color1.rgb[i] / 255;\n cs = color2.rgb[i] / 255;\n cr = mode(cb, cs);\n if (ar) {\n cr = (as * cs + ab * (cb -\n as * (cb + cs - cr))) / ar;\n }\n r[i] = cr * 255;\n }\n\n return new Color(r, ar);\n}\n\nconst colorBlendModeFunctions = {\n multiply: function(cb, cs) {\n return cb * cs;\n },\n screen: function(cb, cs) {\n return cb + cs - cb * cs;\n },\n overlay: function(cb, cs) {\n cb *= 2;\n return (cb <= 1) ?\n colorBlendModeFunctions.multiply(cb, cs) :\n colorBlendModeFunctions.screen(cb - 1, cs);\n },\n softlight: function(cb, cs) {\n let d = 1;\n let e = cb;\n if (cs > 0.5) {\n e = 1;\n d = (cb > 0.25) ? Math.sqrt(cb)\n : ((16 * cb - 12) * cb + 4) * cb;\n }\n return cb - (1 - 2 * cs) * e * (d - cb);\n },\n hardlight: function(cb, cs) {\n return colorBlendModeFunctions.overlay(cs, cb);\n },\n difference: function(cb, cs) {\n return Math.abs(cb - cs);\n },\n exclusion: function(cb, cs) {\n return cb + cs - 2 * cb * cs;\n },\n\n // non-w3c functions:\n average: function(cb, cs) {\n return (cb + cs) / 2;\n },\n negation: function(cb, cs) {\n return 1 - Math.abs(cb + cs - 1);\n }\n};\n\nfor (const f in colorBlendModeFunctions) {\n // eslint-disable-next-line no-prototype-builtins\n if (colorBlendModeFunctions.hasOwnProperty(f)) {\n colorBlend[f] = colorBlend.bind(null, colorBlendModeFunctions[f]);\n }\n}\n\nexport default colorBlend;\n"]}
|
||||
+152
-136
@@ -1,24 +1,21 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
|
||||
var color_1 = tslib_1.__importDefault(require("../tree/color"));
|
||||
var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
|
||||
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
||||
var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
|
||||
var operation_1 = tslib_1.__importDefault(require("../tree/operation"));
|
||||
var colorFunctions;
|
||||
import Dimension from '../tree/dimension.js';
|
||||
import Color from '../tree/color.js';
|
||||
import Quoted from '../tree/quoted.js';
|
||||
import Anonymous from '../tree/anonymous.js';
|
||||
import Expression from '../tree/expression.js';
|
||||
import Operation from '../tree/operation.js';
|
||||
let colorFunctions;
|
||||
|
||||
function clamp(val) {
|
||||
return Math.min(1, Math.max(0, val));
|
||||
}
|
||||
function hsla(origColor, hsl) {
|
||||
var color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
|
||||
const color = colorFunctions.hsla(hsl.h, hsl.s, hsl.l, hsl.a);
|
||||
if (color) {
|
||||
if (origColor.value &&
|
||||
if (origColor.value &&
|
||||
/^(rgb|hsl)/.test(origColor.value)) {
|
||||
color.value = origColor.value;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
color.value = 'rgb';
|
||||
}
|
||||
return color;
|
||||
@@ -27,27 +24,25 @@ function hsla(origColor, hsl) {
|
||||
function toHSL(color) {
|
||||
if (color.toHSL) {
|
||||
return color.toHSL();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('Argument cannot be evaluated to a color');
|
||||
}
|
||||
}
|
||||
|
||||
function toHSV(color) {
|
||||
if (color.toHSV) {
|
||||
return color.toHSV();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Error('Argument cannot be evaluated to a color');
|
||||
}
|
||||
}
|
||||
|
||||
function number(n) {
|
||||
if (n instanceof dimension_1.default) {
|
||||
if (n instanceof Dimension) {
|
||||
return parseFloat(n.unit.is('%') ? n.value / 100 : n.value);
|
||||
}
|
||||
else if (typeof n === 'number') {
|
||||
} else if (typeof n === 'number') {
|
||||
return n;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw {
|
||||
type: 'Argument',
|
||||
message: 'color functions take numbers as parameters'
|
||||
@@ -55,36 +50,35 @@ function number(n) {
|
||||
}
|
||||
}
|
||||
function scaled(n, size) {
|
||||
if (n instanceof dimension_1.default && n.unit.is('%')) {
|
||||
if (n instanceof Dimension && n.unit.is('%')) {
|
||||
return parseFloat(n.value * size / 100);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return number(n);
|
||||
}
|
||||
}
|
||||
colorFunctions = {
|
||||
rgb: function (r, g, b) {
|
||||
var a = 1;
|
||||
let a = 1
|
||||
/**
|
||||
* Comma-less syntax
|
||||
* e.g. rgb(0 128 255 / 50%)
|
||||
*/
|
||||
if (r instanceof expression_1.default) {
|
||||
var val = r.value;
|
||||
r = val[0];
|
||||
g = val[1];
|
||||
b = val[2];
|
||||
/**
|
||||
if (r instanceof Expression) {
|
||||
const val = r.value
|
||||
r = val[0]
|
||||
g = val[1]
|
||||
b = val[2]
|
||||
/**
|
||||
* @todo - should this be normalized in
|
||||
* function caller? Or parsed differently?
|
||||
*/
|
||||
if (b instanceof operation_1.default) {
|
||||
var op = b;
|
||||
b = op.operands[0];
|
||||
a = op.operands[1];
|
||||
if (b instanceof Operation) {
|
||||
const op = b
|
||||
b = op.operands[0]
|
||||
a = op.operands[1]
|
||||
}
|
||||
}
|
||||
var color = colorFunctions.rgba(r, g, b, a);
|
||||
const color = colorFunctions.rgba(r, g, b, a);
|
||||
if (color) {
|
||||
color.value = 'rgb';
|
||||
return color;
|
||||
@@ -92,43 +86,44 @@ colorFunctions = {
|
||||
},
|
||||
rgba: function (r, g, b, a) {
|
||||
try {
|
||||
if (r instanceof color_1.default) {
|
||||
if (r instanceof Color) {
|
||||
if (g) {
|
||||
a = number(g);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
a = r.alpha;
|
||||
}
|
||||
return new color_1.default(r.rgb, a, 'rgba');
|
||||
return new Color(r.rgb, a, 'rgba');
|
||||
}
|
||||
var rgb = [r, g, b].map(function (c) { return scaled(c, 255); });
|
||||
const rgb = [r, g, b].map(c => scaled(c, 255));
|
||||
a = number(a);
|
||||
return new color_1.default(rgb, a, 'rgba');
|
||||
return new Color(rgb, a, 'rgba');
|
||||
}
|
||||
catch (e) { }
|
||||
catch (e) {}
|
||||
},
|
||||
hsl: function (h, s, l) {
|
||||
var a = 1;
|
||||
if (h instanceof expression_1.default) {
|
||||
var val = h.value;
|
||||
h = val[0];
|
||||
s = val[1];
|
||||
l = val[2];
|
||||
if (l instanceof operation_1.default) {
|
||||
var op = l;
|
||||
l = op.operands[0];
|
||||
a = op.operands[1];
|
||||
let a = 1
|
||||
if (h instanceof Expression) {
|
||||
const val = h.value
|
||||
h = val[0]
|
||||
s = val[1]
|
||||
l = val[2]
|
||||
|
||||
if (l instanceof Operation) {
|
||||
const op = l
|
||||
l = op.operands[0]
|
||||
a = op.operands[1]
|
||||
}
|
||||
}
|
||||
var color = colorFunctions.hsla(h, s, l, a);
|
||||
const color = colorFunctions.hsla(h, s, l, a);
|
||||
if (color) {
|
||||
color.value = 'hsl';
|
||||
return color;
|
||||
}
|
||||
},
|
||||
hsla: function (h, s, l, a) {
|
||||
var m1;
|
||||
var m2;
|
||||
let m1;
|
||||
let m2;
|
||||
|
||||
function hue(h) {
|
||||
h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
|
||||
if (h * 6 < 1) {
|
||||
@@ -144,94 +139,104 @@ colorFunctions = {
|
||||
return m1;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (h instanceof color_1.default) {
|
||||
if (h instanceof Color) {
|
||||
if (s) {
|
||||
a = number(s);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
a = h.alpha;
|
||||
}
|
||||
return new color_1.default(h.rgb, a, 'hsla');
|
||||
return new Color(h.rgb, a, 'hsla');
|
||||
}
|
||||
|
||||
h = (number(h) % 360) / 360;
|
||||
s = clamp(number(s));
|
||||
l = clamp(number(l));
|
||||
a = clamp(number(a));
|
||||
s = clamp(number(s));l = clamp(number(l));a = clamp(number(a));
|
||||
|
||||
m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
||||
m1 = l * 2 - m2;
|
||||
var rgb = [
|
||||
|
||||
const rgb = [
|
||||
hue(h + 1 / 3) * 255,
|
||||
hue(h) * 255,
|
||||
hue(h) * 255,
|
||||
hue(h - 1 / 3) * 255
|
||||
];
|
||||
a = number(a);
|
||||
return new color_1.default(rgb, a, 'hsla');
|
||||
return new Color(rgb, a, 'hsla');
|
||||
}
|
||||
catch (e) { }
|
||||
catch (e) {}
|
||||
},
|
||||
hsv: function (h, s, v) {
|
||||
|
||||
hsv: function(h, s, v) {
|
||||
return colorFunctions.hsva(h, s, v, 1.0);
|
||||
},
|
||||
hsva: function (h, s, v, a) {
|
||||
|
||||
hsva: function(h, s, v, a) {
|
||||
h = ((number(h) % 360) / 360) * 360;
|
||||
s = number(s);
|
||||
v = number(v);
|
||||
a = number(a);
|
||||
var i;
|
||||
var f;
|
||||
s = number(s);v = number(v);a = number(a);
|
||||
|
||||
let i;
|
||||
let f;
|
||||
i = Math.floor((h / 60) % 6);
|
||||
f = (h / 60) - i;
|
||||
var vs = [v,
|
||||
|
||||
const vs = [v,
|
||||
v * (1 - s),
|
||||
v * (1 - f * s),
|
||||
v * (1 - (1 - f) * s)];
|
||||
var perm = [[0, 3, 1],
|
||||
const perm = [[0, 3, 1],
|
||||
[2, 0, 1],
|
||||
[1, 0, 3],
|
||||
[1, 2, 0],
|
||||
[3, 1, 0],
|
||||
[0, 1, 2]];
|
||||
return colorFunctions.rgba(vs[perm[i][0]] * 255, vs[perm[i][1]] * 255, vs[perm[i][2]] * 255, a);
|
||||
|
||||
return colorFunctions.rgba(vs[perm[i][0]] * 255,
|
||||
vs[perm[i][1]] * 255,
|
||||
vs[perm[i][2]] * 255,
|
||||
a);
|
||||
},
|
||||
|
||||
hue: function (color) {
|
||||
return new dimension_1.default(toHSL(color).h);
|
||||
return new Dimension(toHSL(color).h);
|
||||
},
|
||||
saturation: function (color) {
|
||||
return new dimension_1.default(toHSL(color).s * 100, '%');
|
||||
return new Dimension(toHSL(color).s * 100, '%');
|
||||
},
|
||||
lightness: function (color) {
|
||||
return new dimension_1.default(toHSL(color).l * 100, '%');
|
||||
return new Dimension(toHSL(color).l * 100, '%');
|
||||
},
|
||||
hsvhue: function (color) {
|
||||
return new dimension_1.default(toHSV(color).h);
|
||||
hsvhue: function(color) {
|
||||
return new Dimension(toHSV(color).h);
|
||||
},
|
||||
hsvsaturation: function (color) {
|
||||
return new dimension_1.default(toHSV(color).s * 100, '%');
|
||||
return new Dimension(toHSV(color).s * 100, '%');
|
||||
},
|
||||
hsvvalue: function (color) {
|
||||
return new dimension_1.default(toHSV(color).v * 100, '%');
|
||||
return new Dimension(toHSV(color).v * 100, '%');
|
||||
},
|
||||
red: function (color) {
|
||||
return new dimension_1.default(color.rgb[0]);
|
||||
return new Dimension(color.rgb[0]);
|
||||
},
|
||||
green: function (color) {
|
||||
return new dimension_1.default(color.rgb[1]);
|
||||
return new Dimension(color.rgb[1]);
|
||||
},
|
||||
blue: function (color) {
|
||||
return new dimension_1.default(color.rgb[2]);
|
||||
return new Dimension(color.rgb[2]);
|
||||
},
|
||||
alpha: function (color) {
|
||||
return new dimension_1.default(toHSL(color).a);
|
||||
return new Dimension(toHSL(color).a);
|
||||
},
|
||||
luma: function (color) {
|
||||
return new dimension_1.default(color.luma() * color.alpha * 100, '%');
|
||||
return new Dimension(color.luma() * color.alpha * 100, '%');
|
||||
},
|
||||
luminance: function (color) {
|
||||
var luminance = (0.2126 * color.rgb[0] / 255) +
|
||||
(0.7152 * color.rgb[1] / 255) +
|
||||
(0.0722 * color.rgb[2] / 255);
|
||||
return new dimension_1.default(luminance * color.alpha * 100, '%');
|
||||
const luminance =
|
||||
(0.2126 * color.rgb[0] / 255) +
|
||||
(0.7152 * color.rgb[1] / 255) +
|
||||
(0.0722 * color.rgb[2] / 255);
|
||||
|
||||
return new Dimension(luminance * color.alpha * 100, '%');
|
||||
},
|
||||
saturate: function (color, amount, method) {
|
||||
// filter: saturate(3.2);
|
||||
@@ -239,9 +244,10 @@ colorFunctions = {
|
||||
if (!color.rgb) {
|
||||
return null;
|
||||
}
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.s += hsl.s * amount.value / 100;
|
||||
hsl.s += hsl.s * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.s += amount.value / 100;
|
||||
@@ -250,9 +256,10 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
desaturate: function (color, amount, method) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.s -= hsl.s * amount.value / 100;
|
||||
hsl.s -= hsl.s * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.s -= amount.value / 100;
|
||||
@@ -261,9 +268,10 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
lighten: function (color, amount, method) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.l += hsl.l * amount.value / 100;
|
||||
hsl.l += hsl.l * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.l += amount.value / 100;
|
||||
@@ -272,9 +280,10 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
darken: function (color, amount, method) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.l -= hsl.l * amount.value / 100;
|
||||
hsl.l -= hsl.l * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.l -= amount.value / 100;
|
||||
@@ -283,9 +292,10 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
fadein: function (color, amount, method) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.a += hsl.a * amount.value / 100;
|
||||
hsl.a += hsl.a * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.a += amount.value / 100;
|
||||
@@ -294,9 +304,10 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
fadeout: function (color, amount, method) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
if (typeof method !== 'undefined' && method.value === 'relative') {
|
||||
hsl.a -= hsl.a * amount.value / 100;
|
||||
hsl.a -= hsl.a * amount.value / 100;
|
||||
}
|
||||
else {
|
||||
hsl.a -= amount.value / 100;
|
||||
@@ -305,15 +316,18 @@ colorFunctions = {
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
fade: function (color, amount) {
|
||||
var hsl = toHSL(color);
|
||||
const hsl = toHSL(color);
|
||||
|
||||
hsl.a = amount.value / 100;
|
||||
hsl.a = clamp(hsl.a);
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
spin: function (color, amount) {
|
||||
var hsl = toHSL(color);
|
||||
var hue = (hsl.h + amount.value) % 360;
|
||||
const hsl = toHSL(color);
|
||||
const hue = (hsl.h + amount.value) % 360;
|
||||
|
||||
hsl.h = hue < 0 ? 360 + hue : hue;
|
||||
|
||||
return hsla(color, hsl);
|
||||
},
|
||||
//
|
||||
@@ -322,21 +336,25 @@ colorFunctions = {
|
||||
//
|
||||
mix: function (color1, color2, weight) {
|
||||
if (!weight) {
|
||||
weight = new dimension_1.default(50);
|
||||
weight = new Dimension(50);
|
||||
}
|
||||
var p = weight.value / 100.0;
|
||||
var w = p * 2 - 1;
|
||||
var a = toHSL(color1).a - toHSL(color2).a;
|
||||
var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
|
||||
var w2 = 1 - w1;
|
||||
var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
|
||||
const p = weight.value / 100.0;
|
||||
const w = p * 2 - 1;
|
||||
const a = toHSL(color1).a - toHSL(color2).a;
|
||||
|
||||
const w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
|
||||
const w2 = 1 - w1;
|
||||
|
||||
const rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
|
||||
color1.rgb[1] * w1 + color2.rgb[1] * w2,
|
||||
color1.rgb[2] * w1 + color2.rgb[2] * w2];
|
||||
var alpha = color1.alpha * p + color2.alpha * (1 - p);
|
||||
return new color_1.default(rgb, alpha);
|
||||
|
||||
const alpha = color1.alpha * p + color2.alpha * (1 - p);
|
||||
|
||||
return new Color(rgb, alpha);
|
||||
},
|
||||
greyscale: function (color) {
|
||||
return colorFunctions.desaturate(color, new dimension_1.default(100));
|
||||
return colorFunctions.desaturate(color, new Dimension(100));
|
||||
},
|
||||
contrast: function (color, dark, light, threshold) {
|
||||
// filter: contrast(3.2);
|
||||
@@ -352,20 +370,18 @@ colorFunctions = {
|
||||
}
|
||||
// Figure out which is actually light and dark:
|
||||
if (dark.luma() > light.luma()) {
|
||||
var t = light;
|
||||
const t = light;
|
||||
light = dark;
|
||||
dark = t;
|
||||
}
|
||||
if (typeof threshold === 'undefined') {
|
||||
threshold = 0.43;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
threshold = number(threshold);
|
||||
}
|
||||
if (color.luma() < threshold) {
|
||||
return light;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return dark;
|
||||
}
|
||||
},
|
||||
@@ -408,29 +424,29 @@ colorFunctions = {
|
||||
// }
|
||||
// },
|
||||
argb: function (color) {
|
||||
return new anonymous_1.default(color.toARGB());
|
||||
return new Anonymous(color.toARGB());
|
||||
},
|
||||
color: function (c) {
|
||||
if ((c instanceof quoted_1.default) &&
|
||||
color: function(c) {
|
||||
if ((c instanceof Quoted) &&
|
||||
(/^#([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3,4})$/i.test(c.value))) {
|
||||
var val = c.value.slice(1);
|
||||
return new color_1.default(val, undefined, "#".concat(val));
|
||||
const val = c.value.slice(1);
|
||||
return new Color(val, undefined, `#${val}`);
|
||||
}
|
||||
if ((c instanceof color_1.default) || (c = color_1.default.fromKeyword(c.value))) {
|
||||
if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
|
||||
c.value = undefined;
|
||||
return c;
|
||||
}
|
||||
throw {
|
||||
type: 'Argument',
|
||||
type: 'Argument',
|
||||
message: 'argument must be a color keyword or 3|4|6|8 digit hex e.g. #FFF'
|
||||
};
|
||||
},
|
||||
tint: function (color, amount) {
|
||||
tint: function(color, amount) {
|
||||
return colorFunctions.mix(colorFunctions.rgb(255, 255, 255), color, amount);
|
||||
},
|
||||
shade: function (color, amount) {
|
||||
shade: function(color, amount) {
|
||||
return colorFunctions.mix(colorFunctions.rgb(0, 0, 0), color, amount);
|
||||
}
|
||||
};
|
||||
exports.default = colorFunctions;
|
||||
//# sourceMappingURL=color.js.map
|
||||
|
||||
export default colorFunctions;
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+73
-64
@@ -1,65 +1,74 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
|
||||
var url_1 = tslib_1.__importDefault(require("../tree/url"));
|
||||
var utils = tslib_1.__importStar(require("../utils"));
|
||||
var logger_1 = tslib_1.__importDefault(require("../logger"));
|
||||
exports.default = (function (environment) {
|
||||
var fallback = function (functionThis, node) { return new url_1.default(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); };
|
||||
return { 'data-uri': function (mimetypeNode, filePathNode) {
|
||||
if (!filePathNode) {
|
||||
filePathNode = mimetypeNode;
|
||||
mimetypeNode = null;
|
||||
import Quoted from '../tree/quoted.js';
|
||||
import URL from '../tree/url.js';
|
||||
import * as utils from '../utils.js';
|
||||
import logger from '../logger.js';
|
||||
|
||||
export default environment => {
|
||||
|
||||
const fallback = (functionThis, node) => new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context);
|
||||
|
||||
return { 'data-uri': function(mimetypeNode, filePathNode) {
|
||||
|
||||
if (!filePathNode) {
|
||||
filePathNode = mimetypeNode;
|
||||
mimetypeNode = null;
|
||||
}
|
||||
|
||||
let mimetype = mimetypeNode && mimetypeNode.value;
|
||||
let filePath = filePathNode.value;
|
||||
const currentFileInfo = this.currentFileInfo;
|
||||
const currentDirectory = currentFileInfo.rewriteUrls ?
|
||||
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
|
||||
|
||||
const fragmentStart = filePath.indexOf('#');
|
||||
let fragment = '';
|
||||
if (fragmentStart !== -1) {
|
||||
fragment = filePath.slice(fragmentStart);
|
||||
filePath = filePath.slice(0, fragmentStart);
|
||||
}
|
||||
const context = utils.clone(this.context);
|
||||
context.rawBuffer = true;
|
||||
|
||||
const fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);
|
||||
|
||||
if (!fileManager) {
|
||||
return fallback(this, filePathNode);
|
||||
}
|
||||
|
||||
let useBase64 = false;
|
||||
|
||||
// detect the mimetype if not given
|
||||
if (!mimetypeNode) {
|
||||
|
||||
mimetype = environment.mimeLookup(filePath);
|
||||
|
||||
if (mimetype === 'image/svg+xml') {
|
||||
useBase64 = false;
|
||||
} else {
|
||||
// use base 64 unless it's an ASCII or UTF-8 format
|
||||
const charset = environment.charsetLookup(mimetype);
|
||||
useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
|
||||
}
|
||||
var mimetype = mimetypeNode && mimetypeNode.value;
|
||||
var filePath = filePathNode.value;
|
||||
var currentFileInfo = this.currentFileInfo;
|
||||
var currentDirectory = currentFileInfo.rewriteUrls ?
|
||||
currentFileInfo.currentDirectory : currentFileInfo.entryPath;
|
||||
var fragmentStart = filePath.indexOf('#');
|
||||
var fragment = '';
|
||||
if (fragmentStart !== -1) {
|
||||
fragment = filePath.slice(fragmentStart);
|
||||
filePath = filePath.slice(0, fragmentStart);
|
||||
}
|
||||
var context = utils.clone(this.context);
|
||||
context.rawBuffer = true;
|
||||
var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true);
|
||||
if (!fileManager) {
|
||||
return fallback(this, filePathNode);
|
||||
}
|
||||
var useBase64 = false;
|
||||
// detect the mimetype if not given
|
||||
if (!mimetypeNode) {
|
||||
mimetype = environment.mimeLookup(filePath);
|
||||
if (mimetype === 'image/svg+xml') {
|
||||
useBase64 = false;
|
||||
}
|
||||
else {
|
||||
// use base 64 unless it's an ASCII or UTF-8 format
|
||||
var charset = environment.charsetLookup(mimetype);
|
||||
useBase64 = ['US-ASCII', 'UTF-8'].indexOf(charset) < 0;
|
||||
}
|
||||
if (useBase64) {
|
||||
mimetype += ';base64';
|
||||
}
|
||||
}
|
||||
else {
|
||||
useBase64 = /;base64$/.test(mimetype);
|
||||
}
|
||||
var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
|
||||
if (!fileSync.contents) {
|
||||
logger_1.default.warn("Skipped data-uri embedding of ".concat(filePath, " because file not found"));
|
||||
return fallback(this, filePathNode || mimetypeNode);
|
||||
}
|
||||
var buf = fileSync.contents;
|
||||
if (useBase64 && !environment.encodeBase64) {
|
||||
return fallback(this, filePathNode);
|
||||
}
|
||||
buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);
|
||||
var uri = "data:".concat(mimetype, ",").concat(buf).concat(fragment);
|
||||
return new url_1.default(new quoted_1.default("\"".concat(uri, "\""), uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
||||
} };
|
||||
});
|
||||
//# sourceMappingURL=data-uri.js.map
|
||||
if (useBase64) { mimetype += ';base64'; }
|
||||
}
|
||||
else {
|
||||
useBase64 = /;base64$/.test(mimetype);
|
||||
}
|
||||
|
||||
const fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment);
|
||||
if (!fileSync.contents) {
|
||||
logger.warn(`Skipped data-uri embedding of ${filePath} because file not found`);
|
||||
return fallback(this, filePathNode || mimetypeNode);
|
||||
}
|
||||
let buf = fileSync.contents;
|
||||
if (useBase64 && !environment.encodeBase64) {
|
||||
return fallback(this, filePathNode);
|
||||
}
|
||||
|
||||
buf = useBase64 ? environment.encodeBase64(buf) : encodeURIComponent(buf);
|
||||
|
||||
const uri = `data:${mimetype},${buf}${fragment}`;
|
||||
|
||||
return new URL(new Quoted(`"${uri}"`, uri, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
||||
}};
|
||||
};
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
+9
-11
@@ -1,17 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var keyword_1 = tslib_1.__importDefault(require("../tree/keyword"));
|
||||
var utils = tslib_1.__importStar(require("../utils"));
|
||||
var defaultFunc = {
|
||||
import Keyword from '../tree/keyword.js';
|
||||
import * as utils from '../utils.js';
|
||||
|
||||
const defaultFunc = {
|
||||
eval: function () {
|
||||
var v = this.value_;
|
||||
var e = this.error_;
|
||||
const v = this.value_;
|
||||
const e = this.error_;
|
||||
if (e) {
|
||||
throw e;
|
||||
}
|
||||
if (!utils.isNullOrUndefined(v)) {
|
||||
return v ? keyword_1.default.True : keyword_1.default.False;
|
||||
return v ? Keyword.True : Keyword.False;
|
||||
}
|
||||
},
|
||||
value: function (v) {
|
||||
@@ -24,5 +22,5 @@ var defaultFunc = {
|
||||
this.value_ = this.error_ = null;
|
||||
}
|
||||
};
|
||||
exports.default = defaultFunc;
|
||||
//# sourceMappingURL=default.js.map
|
||||
|
||||
export default defaultFunc;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../../src/less/functions/default.js"],"names":[],"mappings":";;;AAAA,oEAAsC;AACtC,sDAAkC;AAElC,IAAM,WAAW,GAAG;IAChB,IAAI,EAAE;QACF,IAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE;YACH,MAAM,CAAC,CAAC;SACX;QACD,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE;YAC7B,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAO,CAAC,KAAK,CAAC;SAC3C;IACL,CAAC;IACD,KAAK,EAAE,UAAU,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,KAAK,EAAE,UAAU,CAAC;QACd,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IACD,KAAK,EAAE;QACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrC,CAAC;CACJ,CAAC;AAEF,kBAAe,WAAW,CAAC","sourcesContent":["import Keyword from '../tree/keyword';\nimport * as utils from '../utils';\n\nconst defaultFunc = {\n eval: function () {\n const v = this.value_;\n const e = this.error_;\n if (e) {\n throw e;\n }\n if (!utils.isNullOrUndefined(v)) {\n return v ? Keyword.True : Keyword.False;\n }\n },\n value: function (v) {\n this.value_ = v;\n },\n error: function (e) {\n this.error_ = e;\n },\n reset: function () {\n this.value_ = this.error_ = null;\n }\n};\n\nexport default defaultFunc;\n"]}
|
||||
+35
-34
@@ -1,54 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
|
||||
var functionCaller = /** @class */ (function () {
|
||||
function functionCaller(name, context, index, currentFileInfo) {
|
||||
import Expression from '../tree/expression.js';
|
||||
|
||||
class functionCaller {
|
||||
constructor(name, context, index, currentFileInfo) {
|
||||
this.name = name.toLowerCase();
|
||||
this.index = index;
|
||||
this.context = context;
|
||||
this.currentFileInfo = currentFileInfo;
|
||||
|
||||
this.func = context.frames[0].functionRegistry.get(this.name);
|
||||
}
|
||||
functionCaller.prototype.isValid = function () {
|
||||
|
||||
isValid() {
|
||||
return Boolean(this.func);
|
||||
};
|
||||
functionCaller.prototype.call = function (args) {
|
||||
var _this = this;
|
||||
}
|
||||
|
||||
call(args) {
|
||||
if (!(Array.isArray(args))) {
|
||||
args = [args];
|
||||
}
|
||||
var evalArgs = this.func.evalArgs;
|
||||
const evalArgs = this.func.evalArgs;
|
||||
if (evalArgs !== false) {
|
||||
args = args.map(function (a) { return a.eval(_this.context); });
|
||||
args = args.map(a => a.eval(this.context));
|
||||
}
|
||||
var commentFilter = function (item) { return !(item.type === 'Comment'); };
|
||||
const commentFilter = item => !(item.type === 'Comment');
|
||||
|
||||
// This code is terrible and should be replaced as per this issue...
|
||||
// https://github.com/less/less.js/issues/2477
|
||||
args = args
|
||||
.filter(commentFilter)
|
||||
.map(function (item) {
|
||||
if (item.type === 'Expression') {
|
||||
var subNodes = item.value.filter(commentFilter);
|
||||
if (subNodes.length === 1) {
|
||||
// https://github.com/less/less.js/issues/3616
|
||||
if (item.parens && subNodes[0].op === '/') {
|
||||
return item;
|
||||
.map(item => {
|
||||
if (item.type === 'Expression') {
|
||||
const subNodes = item.value.filter(commentFilter);
|
||||
if (subNodes.length === 1) {
|
||||
// https://github.com/less/less.js/issues/3616
|
||||
if (item.parens && subNodes[0].op === '/') {
|
||||
return item;
|
||||
}
|
||||
return subNodes[0];
|
||||
} else {
|
||||
return new Expression(subNodes);
|
||||
}
|
||||
return subNodes[0];
|
||||
}
|
||||
else {
|
||||
return new expression_1.default(subNodes);
|
||||
}
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return item;
|
||||
});
|
||||
|
||||
if (evalArgs === false) {
|
||||
return this.func.apply(this, tslib_1.__spreadArray([this.context], args, false));
|
||||
return this.func(this.context, ...args);
|
||||
}
|
||||
return this.func.apply(this, args);
|
||||
};
|
||||
return functionCaller;
|
||||
}());
|
||||
exports.default = functionCaller;
|
||||
//# sourceMappingURL=function-caller.js.map
|
||||
|
||||
return this.func(...args);
|
||||
}
|
||||
}
|
||||
|
||||
export default functionCaller;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"function-caller.js","sourceRoot":"","sources":["../../../src/less/functions/function-caller.js"],"names":[],"mappings":";;;AAAA,0EAA4C;AAE5C;IACI,wBAAY,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe;QAC7C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QAEvC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,gCAAO,GAAP;QACI,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,6BAAI,GAAJ,UAAK,IAAI;QAAT,iBAmCC;QAlCG,IAAI,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE;YACxB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;SACjB;QACD,IAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;QACpC,IAAI,QAAQ,KAAK,KAAK,EAAE;YACpB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,KAAI,CAAC,OAAO,CAAC,EAApB,CAAoB,CAAC,CAAC;SAC9C;QACD,IAAM,aAAa,GAAG,UAAA,IAAI,IAAI,OAAA,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,EAA1B,CAA0B,CAAC;QAEzD,oEAAoE;QACpE,8CAA8C;QAC9C,IAAI,GAAG,IAAI;aACN,MAAM,CAAC,aAAa,CAAC;aACrB,GAAG,CAAC,UAAA,IAAI;YACL,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,EAAE;gBAC5B,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;oBACvB,8CAA8C;oBAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG,EAAE;wBACvC,OAAO,IAAI,CAAC;qBACf;oBACD,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;iBACtB;qBAAM;oBACH,OAAO,IAAI,oBAAU,CAAC,QAAQ,CAAC,CAAC;iBACnC;aACJ;YACD,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC,CAAC;QAEP,IAAI,QAAQ,KAAK,KAAK,EAAE;YACpB,OAAO,IAAI,CAAC,IAAI,OAAT,IAAI,yBAAM,IAAI,CAAC,OAAO,GAAK,IAAI,UAAE;SAC3C;QAED,OAAO,IAAI,CAAC,IAAI,OAAT,IAAI,EAAS,IAAI,EAAE;IAC9B,CAAC;IACL,qBAAC;AAAD,CAAC,AAlDD,IAkDC;AAED,kBAAe,cAAc,CAAC","sourcesContent":["import Expression from '../tree/expression';\n\nclass functionCaller {\n constructor(name, context, index, currentFileInfo) {\n this.name = name.toLowerCase();\n this.index = index;\n this.context = context;\n this.currentFileInfo = currentFileInfo;\n\n this.func = context.frames[0].functionRegistry.get(this.name);\n }\n\n isValid() {\n return Boolean(this.func);\n }\n\n call(args) {\n if (!(Array.isArray(args))) {\n args = [args];\n }\n const evalArgs = this.func.evalArgs;\n if (evalArgs !== false) {\n args = args.map(a => a.eval(this.context));\n }\n const commentFilter = item => !(item.type === 'Comment');\n\n // This code is terrible and should be replaced as per this issue...\n // https://github.com/less/less.js/issues/2477\n args = args\n .filter(commentFilter)\n .map(item => {\n if (item.type === 'Expression') {\n const subNodes = item.value.filter(commentFilter);\n if (subNodes.length === 1) {\n // https://github.com/less/less.js/issues/3616\n if (item.parens && subNodes[0].op === '/') {\n return item;\n }\n return subNodes[0];\n } else {\n return new Expression(subNodes);\n }\n }\n return item;\n });\n\n if (evalArgs === false) {\n return this.func(this.context, ...args);\n }\n\n return this.func(...args);\n }\n}\n\nexport default functionCaller;\n"]}
|
||||
+16
-17
@@ -1,37 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function makeRegistry(base) {
|
||||
function makeRegistry( base ) {
|
||||
return {
|
||||
_data: {},
|
||||
add: function (name, func) {
|
||||
add: function(name, func) {
|
||||
// precautionary case conversion, as later querying of
|
||||
// the registry by function-caller uses lower case as well.
|
||||
name = name.toLowerCase();
|
||||
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (this._data.hasOwnProperty(name)) {
|
||||
// TODO warn
|
||||
}
|
||||
this._data[name] = func;
|
||||
},
|
||||
addMultiple: function (functions) {
|
||||
var _this = this;
|
||||
Object.keys(functions).forEach(function (name) {
|
||||
_this.add(name, functions[name]);
|
||||
});
|
||||
addMultiple: function(functions) {
|
||||
Object.keys(functions).forEach(
|
||||
name => {
|
||||
this.add(name, functions[name]);
|
||||
});
|
||||
},
|
||||
get: function (name) {
|
||||
return this._data[name] || (base && base.get(name));
|
||||
get: function(name) {
|
||||
return this._data[name] || ( base && base.get( name ));
|
||||
},
|
||||
getLocalFunctions: function () {
|
||||
getLocalFunctions: function() {
|
||||
return this._data;
|
||||
},
|
||||
inherit: function () {
|
||||
return makeRegistry(this);
|
||||
inherit: function() {
|
||||
return makeRegistry( this );
|
||||
},
|
||||
create: function (base) {
|
||||
create: function(base) {
|
||||
return makeRegistry(base);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.default = makeRegistry(null);
|
||||
//# sourceMappingURL=function-registry.js.map
|
||||
|
||||
export default makeRegistry( null );
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"function-registry.js","sourceRoot":"","sources":["../../../src/less/functions/function-registry.js"],"names":[],"mappings":";;AAAA,SAAS,YAAY,CAAE,IAAI;IACvB,OAAO;QACH,KAAK,EAAE,EAAE;QACT,GAAG,EAAE,UAAS,IAAI,EAAE,IAAI;YACpB,sDAAsD;YACtD,2DAA2D;YAC3D,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YAE1B,iDAAiD;YACjD,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;gBACjC,YAAY;aACf;YACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,WAAW,EAAE,UAAS,SAAS;YAAlB,iBAKZ;YAJG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,CAC1B,UAAA,IAAI;gBACA,KAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YACpC,CAAC,CAAC,CAAC;QACX,CAAC;QACD,GAAG,EAAE,UAAS,IAAI;YACd,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAE,IAAI,IAAI,IAAI,CAAC,GAAG,CAAE,IAAI,CAAE,CAAC,CAAC;QAC3D,CAAC;QACD,iBAAiB,EAAE;YACf,OAAO,IAAI,CAAC,KAAK,CAAC;QACtB,CAAC;QACD,OAAO,EAAE;YACL,OAAO,YAAY,CAAE,IAAI,CAAE,CAAC;QAChC,CAAC;QACD,MAAM,EAAE,UAAS,IAAI;YACjB,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,kBAAe,YAAY,CAAE,IAAI,CAAE,CAAC","sourcesContent":["function makeRegistry( base ) {\n return {\n _data: {},\n add: function(name, func) {\n // precautionary case conversion, as later querying of\n // the registry by function-caller uses lower case as well.\n name = name.toLowerCase();\n\n // eslint-disable-next-line no-prototype-builtins\n if (this._data.hasOwnProperty(name)) {\n // TODO warn\n }\n this._data[name] = func;\n },\n addMultiple: function(functions) {\n Object.keys(functions).forEach(\n name => {\n this.add(name, functions[name]);\n });\n },\n get: function(name) {\n return this._data[name] || ( base && base.get( name ));\n },\n getLocalFunctions: function() {\n return this._data;\n },\n inherit: function() {\n return makeRegistry( this );\n },\n create: function(base) {\n return makeRegistry(base);\n }\n };\n}\n\nexport default makeRegistry( null );"]}
|
||||
+33
-33
@@ -1,35 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var function_registry_1 = tslib_1.__importDefault(require("./function-registry"));
|
||||
var function_caller_1 = tslib_1.__importDefault(require("./function-caller"));
|
||||
var boolean_1 = tslib_1.__importDefault(require("./boolean"));
|
||||
var default_1 = tslib_1.__importDefault(require("./default"));
|
||||
var color_1 = tslib_1.__importDefault(require("./color"));
|
||||
var color_blending_1 = tslib_1.__importDefault(require("./color-blending"));
|
||||
var data_uri_1 = tslib_1.__importDefault(require("./data-uri"));
|
||||
var list_1 = tslib_1.__importDefault(require("./list"));
|
||||
var math_1 = tslib_1.__importDefault(require("./math"));
|
||||
var number_1 = tslib_1.__importDefault(require("./number"));
|
||||
var string_1 = tslib_1.__importDefault(require("./string"));
|
||||
var svg_1 = tslib_1.__importDefault(require("./svg"));
|
||||
var types_1 = tslib_1.__importDefault(require("./types"));
|
||||
var style_1 = tslib_1.__importDefault(require("./style"));
|
||||
exports.default = (function (environment) {
|
||||
var functions = { functionRegistry: function_registry_1.default, functionCaller: function_caller_1.default };
|
||||
import functionRegistry from './function-registry.js';
|
||||
import functionCaller from './function-caller.js';
|
||||
|
||||
import boolean from './boolean.js';
|
||||
import defaultFunc from './default.js';
|
||||
import color from './color.js';
|
||||
import colorBlending from './color-blending.js';
|
||||
import dataUri from './data-uri.js';
|
||||
import list from './list.js';
|
||||
import math from './math.js';
|
||||
import number from './number.js';
|
||||
import string from './string.js';
|
||||
import svg from './svg.js';
|
||||
import types from './types.js';
|
||||
import style from './style.js';
|
||||
|
||||
export default environment => {
|
||||
const functions = { functionRegistry, functionCaller };
|
||||
|
||||
// register functions
|
||||
function_registry_1.default.addMultiple(boolean_1.default);
|
||||
function_registry_1.default.add('default', default_1.default.eval.bind(default_1.default));
|
||||
function_registry_1.default.addMultiple(color_1.default);
|
||||
function_registry_1.default.addMultiple(color_blending_1.default);
|
||||
function_registry_1.default.addMultiple((0, data_uri_1.default)(environment));
|
||||
function_registry_1.default.addMultiple(list_1.default);
|
||||
function_registry_1.default.addMultiple(math_1.default);
|
||||
function_registry_1.default.addMultiple(number_1.default);
|
||||
function_registry_1.default.addMultiple(string_1.default);
|
||||
function_registry_1.default.addMultiple((0, svg_1.default)(environment));
|
||||
function_registry_1.default.addMultiple(types_1.default);
|
||||
function_registry_1.default.addMultiple(style_1.default);
|
||||
functionRegistry.addMultiple(boolean);
|
||||
functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));
|
||||
functionRegistry.addMultiple(color);
|
||||
functionRegistry.addMultiple(colorBlending);
|
||||
functionRegistry.addMultiple(dataUri(environment));
|
||||
functionRegistry.addMultiple(list);
|
||||
functionRegistry.addMultiple(math);
|
||||
functionRegistry.addMultiple(number);
|
||||
functionRegistry.addMultiple(string);
|
||||
functionRegistry.addMultiple(svg(environment));
|
||||
functionRegistry.addMultiple(types);
|
||||
functionRegistry.addMultiple(style);
|
||||
|
||||
return functions;
|
||||
});
|
||||
//# sourceMappingURL=index.js.map
|
||||
};
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/less/functions/index.js"],"names":[],"mappings":";;;AAAA,kFAAmD;AACnD,8EAA+C;AAE/C,8DAAgC;AAChC,8DAAoC;AACpC,0DAA4B;AAC5B,4EAA6C;AAC7C,gEAAiC;AACjC,wDAA0B;AAC1B,wDAA0B;AAC1B,4DAA8B;AAC9B,4DAA8B;AAC9B,sDAAwB;AACxB,0DAA4B;AAC5B,0DAA4B;AAE5B,mBAAe,UAAA,WAAW;IACtB,IAAM,SAAS,GAAG,EAAE,gBAAgB,6BAAA,EAAE,cAAc,2BAAA,EAAE,CAAC;IAEvD,qBAAqB;IACrB,2BAAgB,CAAC,WAAW,CAAC,iBAAO,CAAC,CAAC;IACtC,2BAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,iBAAW,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAW,CAAC,CAAC,CAAC;IACpE,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IACpC,2BAAgB,CAAC,WAAW,CAAC,wBAAa,CAAC,CAAC;IAC5C,2BAAgB,CAAC,WAAW,CAAC,IAAA,kBAAO,EAAC,WAAW,CAAC,CAAC,CAAC;IACnD,2BAAgB,CAAC,WAAW,CAAC,cAAI,CAAC,CAAC;IACnC,2BAAgB,CAAC,WAAW,CAAC,cAAI,CAAC,CAAC;IACnC,2BAAgB,CAAC,WAAW,CAAC,gBAAM,CAAC,CAAC;IACrC,2BAAgB,CAAC,WAAW,CAAC,gBAAM,CAAC,CAAC;IACrC,2BAAgB,CAAC,WAAW,CAAC,IAAA,aAAG,EAAC,WAAW,CAAC,CAAC,CAAC;IAC/C,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IACpC,2BAAgB,CAAC,WAAW,CAAC,eAAK,CAAC,CAAC;IAEpC,OAAO,SAAS,CAAC;AACrB,CAAC,EAAC","sourcesContent":["import functionRegistry from './function-registry';\nimport functionCaller from './function-caller';\n\nimport boolean from './boolean';\nimport defaultFunc from './default';\nimport color from './color';\nimport colorBlending from './color-blending';\nimport dataUri from './data-uri';\nimport list from './list';\nimport math from './math';\nimport number from './number';\nimport string from './string';\nimport svg from './svg';\nimport types from './types';\nimport style from './style';\n\nexport default environment => {\n const functions = { functionRegistry, functionCaller };\n\n // register functions\n functionRegistry.addMultiple(boolean);\n functionRegistry.add('default', defaultFunc.eval.bind(defaultFunc));\n functionRegistry.addMultiple(color);\n functionRegistry.addMultiple(colorBlending);\n functionRegistry.addMultiple(dataUri(environment));\n functionRegistry.addMultiple(list);\n functionRegistry.addMultiple(math);\n functionRegistry.addMultiple(number);\n functionRegistry.addMultiple(string);\n functionRegistry.addMultiple(svg(environment));\n functionRegistry.addMultiple(types);\n functionRegistry.addMultiple(style);\n\n return functions;\n};\n"]}
|
||||
+88
-75
@@ -1,58 +1,55 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var comment_1 = tslib_1.__importDefault(require("../tree/comment"));
|
||||
var node_1 = tslib_1.__importDefault(require("../tree/node"));
|
||||
var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
|
||||
var declaration_1 = tslib_1.__importDefault(require("../tree/declaration"));
|
||||
var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
|
||||
var ruleset_1 = tslib_1.__importDefault(require("../tree/ruleset"));
|
||||
var selector_1 = tslib_1.__importDefault(require("../tree/selector"));
|
||||
var element_1 = tslib_1.__importDefault(require("../tree/element"));
|
||||
var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
|
||||
var value_1 = tslib_1.__importDefault(require("../tree/value"));
|
||||
var getItemsFromNode = function (node) {
|
||||
import Comment from '../tree/comment.js';
|
||||
import Node from '../tree/node.js';
|
||||
import Dimension from '../tree/dimension.js';
|
||||
import Declaration from '../tree/declaration.js';
|
||||
import Expression from '../tree/expression.js';
|
||||
import Ruleset from '../tree/ruleset.js';
|
||||
import Selector from '../tree/selector.js';
|
||||
import Element from '../tree/element.js';
|
||||
import Quote from '../tree/quoted.js';
|
||||
import Value from '../tree/value.js';
|
||||
|
||||
const getItemsFromNode = node => {
|
||||
// handle non-array values as an array of length 1
|
||||
// return 'undefined' if index is invalid
|
||||
var items = Array.isArray(node.value) ?
|
||||
const items = Array.isArray(node.value) ?
|
||||
node.value : Array(node);
|
||||
|
||||
return items;
|
||||
};
|
||||
exports.default = {
|
||||
_SELF: function (n) {
|
||||
|
||||
export default {
|
||||
_SELF: function(n) {
|
||||
return n;
|
||||
},
|
||||
'~': function () {
|
||||
var expr = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
expr[_i] = arguments[_i];
|
||||
}
|
||||
'~': function(...expr) {
|
||||
if (expr.length === 1) {
|
||||
return expr[0];
|
||||
}
|
||||
return new value_1.default(expr);
|
||||
return new Value(expr);
|
||||
},
|
||||
extract: function (values, index) {
|
||||
extract: function(values, index) {
|
||||
// (1-based index)
|
||||
index = index.value - 1;
|
||||
|
||||
return getItemsFromNode(values)[index];
|
||||
},
|
||||
length: function (values) {
|
||||
return new dimension_1.default(getItemsFromNode(values).length);
|
||||
length: function(values) {
|
||||
return new Dimension(getItemsFromNode(values).length);
|
||||
},
|
||||
/**
|
||||
* Creates a Less list of incremental values.
|
||||
* Modeled after Lodash's range function, also exists natively in PHP
|
||||
*
|
||||
*
|
||||
* @param {Dimension} [start=1]
|
||||
* @param {Dimension} end - e.g. 10 or 10px - unit is added to output
|
||||
* @param {Dimension} [step=1]
|
||||
* @param {Dimension} [step=1]
|
||||
*/
|
||||
range: function (start, end, step) {
|
||||
var from;
|
||||
var to;
|
||||
var stepValue = 1;
|
||||
var list = [];
|
||||
range: function(start, end, step) {
|
||||
let from;
|
||||
let to;
|
||||
let stepValue = 1;
|
||||
const list = [];
|
||||
if (end) {
|
||||
to = end;
|
||||
from = start.value;
|
||||
@@ -64,82 +61,98 @@ exports.default = {
|
||||
from = 1;
|
||||
to = start;
|
||||
}
|
||||
for (var i = from; i <= to.value; i += stepValue) {
|
||||
list.push(new dimension_1.default(i, to.unit));
|
||||
|
||||
for (let i = from; i <= to.value; i += stepValue) {
|
||||
list.push(new Dimension(i, to.unit));
|
||||
}
|
||||
return new expression_1.default(list);
|
||||
|
||||
return new Expression(list);
|
||||
},
|
||||
each: function (list, rs) {
|
||||
var _this = this;
|
||||
var rules = [];
|
||||
var newRules;
|
||||
var iterator;
|
||||
var tryEval = function (val) {
|
||||
if (val instanceof node_1.default) {
|
||||
return val.eval(_this.context);
|
||||
each: function(list, rs) {
|
||||
const rules = [];
|
||||
let newRules;
|
||||
let iterator;
|
||||
|
||||
const tryEval = val => {
|
||||
if (val instanceof Node) {
|
||||
return val.eval(this.context);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
if (list.value && !(list instanceof quoted_1.default)) {
|
||||
|
||||
if (list.value && !(list instanceof Quote)) {
|
||||
if (Array.isArray(list.value)) {
|
||||
iterator = list.value.map(tryEval);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
iterator = [tryEval(list.value)];
|
||||
}
|
||||
}
|
||||
else if (list.ruleset) {
|
||||
} else if (list.ruleset) {
|
||||
iterator = tryEval(list.ruleset).rules;
|
||||
}
|
||||
else if (list.rules) {
|
||||
} else if (list.rules) {
|
||||
iterator = list.rules.map(tryEval);
|
||||
}
|
||||
else if (Array.isArray(list)) {
|
||||
} else if (Array.isArray(list)) {
|
||||
iterator = list.map(tryEval);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
iterator = [tryEval(list)];
|
||||
}
|
||||
var valueName = '@value';
|
||||
var keyName = '@key';
|
||||
var indexName = '@index';
|
||||
|
||||
let valueName = '@value';
|
||||
let keyName = '@key';
|
||||
let indexName = '@index';
|
||||
|
||||
if (rs.params) {
|
||||
valueName = rs.params[0] && rs.params[0].name;
|
||||
keyName = rs.params[1] && rs.params[1].name;
|
||||
indexName = rs.params[2] && rs.params[2].name;
|
||||
rs = rs.rules;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
rs = rs.ruleset;
|
||||
}
|
||||
for (var i = 0; i < iterator.length; i++) {
|
||||
var key = void 0;
|
||||
var value = void 0;
|
||||
var item = iterator[i];
|
||||
if (item instanceof declaration_1.default) {
|
||||
|
||||
for (let i = 0; i < iterator.length; i++) {
|
||||
let key;
|
||||
let value;
|
||||
const item = iterator[i];
|
||||
if (item instanceof Declaration) {
|
||||
key = typeof item.name === 'string' ? item.name : item.name[0].value;
|
||||
value = item.value;
|
||||
}
|
||||
else {
|
||||
key = new dimension_1.default(i + 1);
|
||||
} else {
|
||||
key = new Dimension(i + 1);
|
||||
value = item;
|
||||
}
|
||||
if (item instanceof comment_1.default) {
|
||||
|
||||
if (item instanceof Comment) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newRules = rs.rules.slice(0);
|
||||
if (valueName) {
|
||||
newRules.push(new declaration_1.default(valueName, value, false, false, this.index, this.currentFileInfo));
|
||||
newRules.push(new Declaration(valueName,
|
||||
value,
|
||||
false, false, this.index, this.currentFileInfo));
|
||||
}
|
||||
if (indexName) {
|
||||
newRules.push(new declaration_1.default(indexName, new dimension_1.default(i + 1), false, false, this.index, this.currentFileInfo));
|
||||
newRules.push(new Declaration(indexName,
|
||||
new Dimension(i + 1),
|
||||
false, false, this.index, this.currentFileInfo));
|
||||
}
|
||||
if (keyName) {
|
||||
newRules.push(new declaration_1.default(keyName, key, false, false, this.index, this.currentFileInfo));
|
||||
newRules.push(new Declaration(keyName,
|
||||
key,
|
||||
false, false, this.index, this.currentFileInfo));
|
||||
}
|
||||
rules.push(new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], newRules, rs.strictImports, rs.visibilityInfo()));
|
||||
|
||||
rules.push(new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
|
||||
newRules,
|
||||
rs.strictImports,
|
||||
rs.visibilityInfo()
|
||||
));
|
||||
}
|
||||
return new ruleset_1.default([new (selector_1.default)([new element_1.default('', '&')])], rules, rs.strictImports, rs.visibilityInfo()).eval(this.context);
|
||||
|
||||
return new Ruleset([ new(Selector)([ new Element('', '&') ]) ],
|
||||
rules,
|
||||
rs.strictImports,
|
||||
rs.visibilityInfo()
|
||||
).eval(this.context);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=list.js.map
|
||||
-1
File diff suppressed because one or more lines are too long
+8
-11
@@ -1,18 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
|
||||
var MathHelper = function (fn, unit, n) {
|
||||
if (!(n instanceof dimension_1.default)) {
|
||||
import Dimension from '../tree/dimension.js';
|
||||
|
||||
const MathHelper = (fn, unit, n) => {
|
||||
if (!(n instanceof Dimension)) {
|
||||
throw { type: 'Argument', message: 'argument must be a number' };
|
||||
}
|
||||
if (unit === null) {
|
||||
unit = n.unit;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
n = n.unify();
|
||||
}
|
||||
return new dimension_1.default(fn(parseFloat(n.value)), unit);
|
||||
return new Dimension(fn(parseFloat(n.value)), unit);
|
||||
};
|
||||
exports.default = MathHelper;
|
||||
//# sourceMappingURL=math-helper.js.map
|
||||
|
||||
export default MathHelper;
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"math-helper.js","sourceRoot":"","sources":["../../../src/less/functions/math-helper.js"],"names":[],"mappings":";;;AAAA,wEAA0C;AAE1C,IAAM,UAAU,GAAG,UAAC,EAAE,EAAE,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,CAAC,CAAC,YAAY,mBAAS,CAAC,EAAE;QAC3B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;KACpE;IACD,IAAI,IAAI,KAAK,IAAI,EAAE;QACf,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;KACjB;SAAM;QACH,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;KACjB;IACD,OAAO,IAAI,mBAAS,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import Dimension from '../tree/dimension';\n\nconst MathHelper = (fn, unit, n) => {\n if (!(n instanceof Dimension)) {\n throw { type: 'Argument', message: 'argument must be a number' };\n }\n if (unit === null) {\n unit = n.unit;\n } else {\n n = n.unify();\n }\n return new Dimension(fn(parseFloat(n.value)), unit);\n};\n\nexport default MathHelper;"]}
|
||||
+21
-21
@@ -1,29 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
|
||||
var mathFunctions = {
|
||||
import mathHelper from './math-helper.js';
|
||||
|
||||
const mathFunctions = {
|
||||
// name, unit
|
||||
ceil: null,
|
||||
ceil: null,
|
||||
floor: null,
|
||||
sqrt: null,
|
||||
abs: null,
|
||||
tan: '',
|
||||
sin: '',
|
||||
cos: '',
|
||||
atan: 'rad',
|
||||
asin: 'rad',
|
||||
acos: 'rad'
|
||||
sqrt: null,
|
||||
abs: null,
|
||||
tan: '',
|
||||
sin: '',
|
||||
cos: '',
|
||||
atan: 'rad',
|
||||
asin: 'rad',
|
||||
acos: 'rad'
|
||||
};
|
||||
for (var f in mathFunctions) {
|
||||
|
||||
for (const f in mathFunctions) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if (mathFunctions.hasOwnProperty(f)) {
|
||||
mathFunctions[f] = math_helper_js_1.default.bind(null, Math[f], mathFunctions[f]);
|
||||
mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);
|
||||
}
|
||||
}
|
||||
mathFunctions.round = function (n, f) {
|
||||
var fraction = typeof f === 'undefined' ? 0 : f.value;
|
||||
return (0, math_helper_js_1.default)(function (num) { return num.toFixed(fraction); }, null, n);
|
||||
|
||||
mathFunctions.round = (n, f) => {
|
||||
const fraction = typeof f === 'undefined' ? 0 : f.value;
|
||||
return mathHelper(num => num.toFixed(fraction), null, n);
|
||||
};
|
||||
exports.default = mathFunctions;
|
||||
//# sourceMappingURL=math.js.map
|
||||
|
||||
export default mathFunctions;
|
||||
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/less/functions/math.js"],"names":[],"mappings":";;;AAAA,4EAA0C;AAE1C,IAAM,aAAa,GAAG;IAClB,cAAc;IACd,IAAI,EAAG,IAAI;IACX,KAAK,EAAE,IAAI;IACX,IAAI,EAAG,IAAI;IACX,GAAG,EAAI,IAAI;IACX,GAAG,EAAI,EAAE;IACT,GAAG,EAAI,EAAE;IACT,GAAG,EAAI,EAAE;IACT,IAAI,EAAG,KAAK;IACZ,IAAI,EAAG,KAAK;IACZ,IAAI,EAAG,KAAK;CACf,CAAC;AAEF,KAAK,IAAM,CAAC,IAAI,aAAa,EAAE;IAC3B,iDAAiD;IACjD,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE;QACjC,aAAa,CAAC,CAAC,CAAC,GAAG,wBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KACvE;CACJ;AAED,aAAa,CAAC,KAAK,GAAG,UAAC,CAAC,EAAE,CAAC;IACvB,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACxD,OAAO,IAAA,wBAAU,EAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EAArB,CAAqB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC","sourcesContent":["import mathHelper from './math-helper.js';\n\nconst mathFunctions = {\n // name, unit\n ceil: null,\n floor: null,\n sqrt: null,\n abs: null,\n tan: '',\n sin: '',\n cos: '',\n atan: 'rad',\n asin: 'rad',\n acos: 'rad'\n};\n\nfor (const f in mathFunctions) {\n // eslint-disable-next-line no-prototype-builtins\n if (mathFunctions.hasOwnProperty(f)) {\n mathFunctions[f] = mathHelper.bind(null, Math[f], mathFunctions[f]);\n }\n}\n\nmathFunctions.round = (n, f) => {\n const fraction = typeof f === 'undefined' ? 0 : f.value;\n return mathHelper(num => num.toFixed(fraction), null, n);\n};\n\nexport default mathFunctions;\n"]}
|
||||
+42
-53
@@ -1,39 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
|
||||
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
||||
var math_helper_js_1 = tslib_1.__importDefault(require("./math-helper.js"));
|
||||
var minMax = function (isMin, args) {
|
||||
var _this = this;
|
||||
import Dimension from '../tree/dimension.js';
|
||||
import Anonymous from '../tree/anonymous.js';
|
||||
import mathHelper from './math-helper.js';
|
||||
|
||||
const minMax = function (isMin, args) {
|
||||
args = Array.prototype.slice.call(args);
|
||||
switch (args.length) {
|
||||
case 0: throw { type: 'Argument', message: 'one or more arguments required' };
|
||||
}
|
||||
var i; // key is the unit.toString() for unified Dimension values,
|
||||
var j;
|
||||
var current;
|
||||
var currentUnified;
|
||||
var referenceUnified;
|
||||
var unit;
|
||||
var unitStatic;
|
||||
var unitClone;
|
||||
var // elems only contains original argument values.
|
||||
order = [];
|
||||
var values = {};
|
||||
let i; // key is the unit.toString() for unified Dimension values,
|
||||
let j;
|
||||
let current;
|
||||
let currentUnified;
|
||||
let referenceUnified;
|
||||
let unit;
|
||||
let unitStatic;
|
||||
let unitClone;
|
||||
|
||||
const // elems only contains original argument values.
|
||||
order = [];
|
||||
|
||||
const values = {};
|
||||
// value is the index into the order array.
|
||||
for (i = 0; i < args.length; i++) {
|
||||
current = args[i];
|
||||
if (!(current instanceof dimension_1.default)) {
|
||||
if (!(current instanceof Dimension)) {
|
||||
if (Array.isArray(args[i].value)) {
|
||||
Array.prototype.push.apply(args, Array.prototype.slice.call(args[i].value));
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw { type: 'Argument', message: 'incompatible types' };
|
||||
}
|
||||
}
|
||||
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(current.value, unitClone).unify() : current.unify();
|
||||
currentUnified = current.unit.toString() === '' && unitClone !== undefined ? new Dimension(current.value, unitClone).unify() : current.unify();
|
||||
unit = currentUnified.unit.toString() === '' && unitStatic !== undefined ? unitStatic : currentUnified.unit.toString();
|
||||
unitStatic = unit !== '' && unitStatic === undefined || unit !== '' && order[0].unify().unit.toString() === '' ? unit : unitStatic;
|
||||
unitClone = unit !== '' && unitClone === undefined ? current.unit.toString() : unitClone;
|
||||
@@ -46,8 +44,8 @@ var minMax = function (isMin, args) {
|
||||
order.push(current);
|
||||
continue;
|
||||
}
|
||||
referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new dimension_1.default(order[j].value, unitClone).unify() : order[j].unify();
|
||||
if (isMin && currentUnified.value < referenceUnified.value ||
|
||||
referenceUnified = order[j].unit.toString() === '' && unitClone !== undefined ? new Dimension(order[j].value, unitClone).unify() : order[j].unify();
|
||||
if ( isMin && currentUnified.value < referenceUnified.value ||
|
||||
!isMin && currentUnified.value > referenceUnified.value) {
|
||||
order[j] = current;
|
||||
}
|
||||
@@ -55,52 +53,43 @@ var minMax = function (isMin, args) {
|
||||
if (order.length == 1) {
|
||||
return order[0];
|
||||
}
|
||||
args = order.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', ');
|
||||
return new anonymous_1.default("".concat(isMin ? 'min' : 'max', "(").concat(args, ")"));
|
||||
args = order.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
|
||||
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
|
||||
};
|
||||
exports.default = {
|
||||
min: function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
|
||||
export default {
|
||||
min: function(...args) {
|
||||
try {
|
||||
return minMax.call(this, true, args);
|
||||
}
|
||||
catch (e) { }
|
||||
} catch (e) {}
|
||||
},
|
||||
max: function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
max: function(...args) {
|
||||
try {
|
||||
return minMax.call(this, false, args);
|
||||
}
|
||||
catch (e) { }
|
||||
} catch (e) {}
|
||||
},
|
||||
convert: function (val, unit) {
|
||||
return val.convertTo(unit.value);
|
||||
},
|
||||
pi: function () {
|
||||
return new dimension_1.default(Math.PI);
|
||||
return new Dimension(Math.PI);
|
||||
},
|
||||
mod: function (a, b) {
|
||||
return new dimension_1.default(a.value % b.value, a.unit);
|
||||
mod: function(a, b) {
|
||||
return new Dimension(a.value % b.value, a.unit);
|
||||
},
|
||||
pow: function (x, y) {
|
||||
pow: function(x, y) {
|
||||
if (typeof x === 'number' && typeof y === 'number') {
|
||||
x = new dimension_1.default(x);
|
||||
y = new dimension_1.default(y);
|
||||
}
|
||||
else if (!(x instanceof dimension_1.default) || !(y instanceof dimension_1.default)) {
|
||||
x = new Dimension(x);
|
||||
y = new Dimension(y);
|
||||
} else if (!(x instanceof Dimension) || !(y instanceof Dimension)) {
|
||||
throw { type: 'Argument', message: 'arguments must be numbers' };
|
||||
}
|
||||
return new dimension_1.default(Math.pow(x.value, y.value), x.unit);
|
||||
|
||||
return new Dimension(Math.pow(x.value, y.value), x.unit);
|
||||
},
|
||||
percentage: function (n) {
|
||||
var result = (0, math_helper_js_1.default)(function (num) { return num * 100; }, '%', n);
|
||||
const result = mathHelper(num => num * 100, '%', n);
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=number.js.map
|
||||
-1
File diff suppressed because one or more lines are too long
+18
-22
@@ -1,40 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
|
||||
var anonymous_1 = tslib_1.__importDefault(require("../tree/anonymous"));
|
||||
var javascript_1 = tslib_1.__importDefault(require("../tree/javascript"));
|
||||
exports.default = {
|
||||
import Quoted from '../tree/quoted.js';
|
||||
import Anonymous from '../tree/anonymous.js';
|
||||
import JavaScript from '../tree/javascript.js';
|
||||
|
||||
export default {
|
||||
e: function (str) {
|
||||
return new quoted_1.default('"', str instanceof javascript_1.default ? str.evaluated : str.value, true);
|
||||
return new Quoted('"', str instanceof JavaScript ? str.evaluated : str.value, true);
|
||||
},
|
||||
escape: function (str) {
|
||||
return new anonymous_1.default(encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
|
||||
.replace(/\(/g, '%28').replace(/\)/g, '%29'));
|
||||
return new Anonymous(
|
||||
encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')
|
||||
.replace(/\(/g, '%28').replace(/\)/g, '%29'));
|
||||
},
|
||||
replace: function (string, pattern, replacement, flags) {
|
||||
var result = string.value;
|
||||
let result = string.value;
|
||||
replacement = (replacement.type === 'Quoted') ?
|
||||
replacement.value : replacement.toCSS();
|
||||
result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);
|
||||
return new quoted_1.default(string.quote || '', result, string.escaped);
|
||||
return new Quoted(string.quote || '', result, string.escaped);
|
||||
},
|
||||
'%': function (string /* arg, arg, ... */) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
var result = string.value;
|
||||
var _loop_1 = function (i) {
|
||||
const args = Array.prototype.slice.call(arguments, 1);
|
||||
let result = string.value;
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
/* jshint loopfunc:true */
|
||||
result = result.replace(/%[sda]/i, function (token) {
|
||||
var value = ((args[i].type === 'Quoted') &&
|
||||
result = result.replace(/%[sda]/i, token => {
|
||||
const value = ((args[i].type === 'Quoted') &&
|
||||
token.match(/s/i)) ? args[i].value : args[i].toCSS();
|
||||
return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
|
||||
});
|
||||
};
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
_loop_1(i);
|
||||
}
|
||||
result = result.replace(/%%/g, '%');
|
||||
return new quoted_1.default(string.quote || '', result, string.escaped);
|
||||
return new Quoted(string.quote || '', result, string.escaped);
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=string.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/less/functions/string.js"],"names":[],"mappings":";;;AAAA,kEAAoC;AACpC,wEAA0C;AAC1C,0EAA4C;AAE5C,kBAAe;IACX,CAAC,EAAE,UAAU,GAAG;QACZ,OAAO,IAAI,gBAAM,CAAC,GAAG,EAAE,GAAG,YAAY,oBAAU,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,EAAE,UAAU,GAAG;QACjB,OAAO,IAAI,mBAAS,CAChB,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;aACnG,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,EAAE,UAAU,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK;QAClD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;QAC1B,WAAW,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;YAC3C,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC5C,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC;QAC1F,OAAO,IAAI,gBAAM,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;IACD,GAAG,EAAE,UAAU,MAAM,CAAC,mBAAmB;QACrC,IAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;QACtD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC;gCAEjB,CAAC;YACN,0BAA0B;YAC1B,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,UAAA,KAAK;gBACpC,IAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;oBACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;gBACzD,OAAO,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACrE,CAAC,CAAC,CAAC;;QANP,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE;oBAA3B,CAAC;SAOT;QACD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACpC,OAAO,IAAI,gBAAM,CAAC,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAClE,CAAC;CACJ,CAAC","sourcesContent":["import Quoted from '../tree/quoted';\nimport Anonymous from '../tree/anonymous';\nimport JavaScript from '../tree/javascript';\n\nexport default {\n e: function (str) {\n return new Quoted('\"', str instanceof JavaScript ? str.evaluated : str.value, true);\n },\n escape: function (str) {\n return new Anonymous(\n encodeURI(str.value).replace(/=/g, '%3D').replace(/:/g, '%3A').replace(/#/g, '%23').replace(/;/g, '%3B')\n .replace(/\\(/g, '%28').replace(/\\)/g, '%29'));\n },\n replace: function (string, pattern, replacement, flags) {\n let result = string.value;\n replacement = (replacement.type === 'Quoted') ?\n replacement.value : replacement.toCSS();\n result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement);\n return new Quoted(string.quote || '', result, string.escaped);\n },\n '%': function (string /* arg, arg, ... */) {\n const args = Array.prototype.slice.call(arguments, 1);\n let result = string.value;\n\n for (let i = 0; i < args.length; i++) {\n /* jshint loopfunc:true */\n result = result.replace(/%[sda]/i, token => {\n const value = ((args[i].type === 'Quoted') &&\n token.match(/s/i)) ? args[i].value : args[i].toCSS();\n return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;\n });\n }\n result = result.replace(/%%/g, '%');\n return new Quoted(string.quote || '', result, string.escaped);\n }\n};\n"]}
|
||||
+21
-20
@@ -1,28 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var variable_1 = tslib_1.__importDefault(require("../tree/variable"));
|
||||
var variable_2 = tslib_1.__importDefault(require("../tree/variable"));
|
||||
var styleExpression = function (args) {
|
||||
var _this = this;
|
||||
import Variable from '../tree/variable.js';
|
||||
import Anonymous from '../tree/anonymous.js';
|
||||
|
||||
/** @param {*[]} args */
|
||||
const styleExpression = function (args) {
|
||||
args = Array.prototype.slice.call(args);
|
||||
switch (args.length) {
|
||||
case 0: throw { type: 'Argument', message: 'one or more arguments required' };
|
||||
if (args.length === 0) {
|
||||
throw { type: 'Argument', message: 'one or more arguments required' };
|
||||
}
|
||||
var entityList = [new variable_1.default(args[0].value, this.index, this.currentFileInfo).eval(this.context)];
|
||||
args = entityList.map(function (a) { return a.toCSS(_this.context); }).join(this.context.compress ? ',' : ', ');
|
||||
return new variable_2.default("style(".concat(args, ")"));
|
||||
|
||||
const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)];
|
||||
|
||||
const result = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');
|
||||
|
||||
return new Anonymous(`style(${result})`);
|
||||
};
|
||||
exports.default = {
|
||||
style: function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i] = arguments[_i];
|
||||
}
|
||||
|
||||
export default {
|
||||
/** @param {...*} args */
|
||||
style: function(...args) {
|
||||
try {
|
||||
return styleExpression.call(this, args);
|
||||
} catch (e) {
|
||||
// When style() is used as a CSS function (e.g. @container style(--responsive: true)),
|
||||
// arguments won't be valid Less variables. Return undefined to let the
|
||||
// parser fall through and treat it as plain CSS.
|
||||
}
|
||||
catch (e) { }
|
||||
},
|
||||
};
|
||||
//# sourceMappingURL=style.js.map
|
||||
-1
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../../src/less/functions/style.js"],"names":[],"mappings":";;;AAAA,sEAAwC;AACxC,sEAAyC;AAEzC,IAAM,eAAe,GAAG,UAAU,IAAI;IAAd,iBAWvB;IAVG,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,QAAQ,IAAI,CAAC,MAAM,EAAE;QACjB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;KACjF;IAED,IAAM,UAAU,GAAG,CAAC,IAAI,kBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtG,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,UAAA,CAAC,IAAM,OAAO,CAAC,CAAC,KAAK,CAAC,KAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEvG,OAAO,IAAI,kBAAS,CAAC,gBAAS,IAAI,MAAG,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,kBAAe;IACX,KAAK,EAAE;QAAS,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QACnB,IAAI;YACA,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAC3C;QAAC,OAAO,CAAC,EAAE,GAAE;IAClB,CAAC;CACJ,CAAC","sourcesContent":["import Variable from '../tree/variable';\nimport Anonymous from '../tree/variable';\n\nconst styleExpression = function (args) {\n args = Array.prototype.slice.call(args);\n switch (args.length) {\n case 0: throw { type: 'Argument', message: 'one or more arguments required' };\n }\n \n const entityList = [new Variable(args[0].value, this.index, this.currentFileInfo).eval(this.context)];\n \n args = entityList.map(a => { return a.toCSS(this.context); }).join(this.context.compress ? ',' : ', ');\n \n return new Anonymous(`style(${args})`);\n};\n\nexport default {\n style: function(...args) {\n try {\n return styleExpression.call(this, args);\n } catch (e) {}\n },\n};\n"]}
|
||||
+83
-82
@@ -1,86 +1,87 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var dimension_1 = tslib_1.__importDefault(require("../tree/dimension"));
|
||||
var color_1 = tslib_1.__importDefault(require("../tree/color"));
|
||||
var expression_1 = tslib_1.__importDefault(require("../tree/expression"));
|
||||
var quoted_1 = tslib_1.__importDefault(require("../tree/quoted"));
|
||||
var url_1 = tslib_1.__importDefault(require("../tree/url"));
|
||||
exports.default = (function () {
|
||||
return { 'svg-gradient': function (direction) {
|
||||
var stops;
|
||||
var gradientDirectionSvg;
|
||||
var gradientType = 'linear';
|
||||
var rectangleDimension = 'x="0" y="0" width="1" height="1"';
|
||||
var renderEnv = { compress: false };
|
||||
var returner;
|
||||
var directionValue = direction.toCSS(renderEnv);
|
||||
var i;
|
||||
var color;
|
||||
var position;
|
||||
var positionValue;
|
||||
var alpha;
|
||||
function throwArgumentDescriptor() {
|
||||
throw { type: 'Argument',
|
||||
message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
|
||||
' end_color [end_position] or direction, color list' };
|
||||
}
|
||||
if (arguments.length == 2) {
|
||||
if (arguments[1].value.length < 2) {
|
||||
throwArgumentDescriptor();
|
||||
}
|
||||
stops = arguments[1].value;
|
||||
}
|
||||
else if (arguments.length < 3) {
|
||||
import Dimension from '../tree/dimension.js';
|
||||
import Color from '../tree/color.js';
|
||||
import Expression from '../tree/expression.js';
|
||||
import Quoted from '../tree/quoted.js';
|
||||
import URL from '../tree/url.js';
|
||||
|
||||
export default () => {
|
||||
return { 'svg-gradient': function(direction) {
|
||||
let stops;
|
||||
let gradientDirectionSvg;
|
||||
let gradientType = 'linear';
|
||||
let rectangleDimension = 'x="0" y="0" width="1" height="1"';
|
||||
const renderEnv = {compress: false};
|
||||
let returner;
|
||||
const directionValue = direction.toCSS(renderEnv);
|
||||
let i;
|
||||
let color;
|
||||
let position;
|
||||
let positionValue;
|
||||
let alpha;
|
||||
|
||||
function throwArgumentDescriptor() {
|
||||
throw { type: 'Argument',
|
||||
message: 'svg-gradient expects direction, start_color [start_position], [color position,]...,' +
|
||||
' end_color [end_position] or direction, color list' };
|
||||
}
|
||||
|
||||
if (arguments.length == 2) {
|
||||
if (arguments[1].value.length < 2) {
|
||||
throwArgumentDescriptor();
|
||||
}
|
||||
else {
|
||||
stops = Array.prototype.slice.call(arguments, 1);
|
||||
stops = arguments[1].value;
|
||||
} else if (arguments.length < 3) {
|
||||
throwArgumentDescriptor();
|
||||
} else {
|
||||
stops = Array.prototype.slice.call(arguments, 1);
|
||||
}
|
||||
|
||||
switch (directionValue) {
|
||||
case 'to bottom':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
|
||||
break;
|
||||
case 'to right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
|
||||
break;
|
||||
case 'to bottom right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
|
||||
break;
|
||||
case 'to top right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
|
||||
break;
|
||||
case 'ellipse':
|
||||
case 'ellipse at center':
|
||||
gradientType = 'radial';
|
||||
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
|
||||
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
|
||||
break;
|
||||
default:
|
||||
throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
|
||||
' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
|
||||
}
|
||||
returner = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 1"><${gradientType}Gradient id="g" ${gradientDirectionSvg}>`;
|
||||
|
||||
for (i = 0; i < stops.length; i += 1) {
|
||||
if (stops[i] instanceof Expression) {
|
||||
color = stops[i].value[0];
|
||||
position = stops[i].value[1];
|
||||
} else {
|
||||
color = stops[i];
|
||||
position = undefined;
|
||||
}
|
||||
switch (directionValue) {
|
||||
case 'to bottom':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"';
|
||||
break;
|
||||
case 'to right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="0%"';
|
||||
break;
|
||||
case 'to bottom right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="0%" x2="100%" y2="100%"';
|
||||
break;
|
||||
case 'to top right':
|
||||
gradientDirectionSvg = 'x1="0%" y1="100%" x2="100%" y2="0%"';
|
||||
break;
|
||||
case 'ellipse':
|
||||
case 'ellipse at center':
|
||||
gradientType = 'radial';
|
||||
gradientDirectionSvg = 'cx="50%" cy="50%" r="75%"';
|
||||
rectangleDimension = 'x="-50" y="-50" width="101" height="101"';
|
||||
break;
|
||||
default:
|
||||
throw { type: 'Argument', message: 'svg-gradient direction must be \'to bottom\', \'to right\',' +
|
||||
' \'to bottom right\', \'to top right\' or \'ellipse at center\'' };
|
||||
|
||||
if (!(color instanceof Color) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof Dimension))) {
|
||||
throwArgumentDescriptor();
|
||||
}
|
||||
returner = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1 1\"><".concat(gradientType, "Gradient id=\"g\" ").concat(gradientDirectionSvg, ">");
|
||||
for (i = 0; i < stops.length; i += 1) {
|
||||
if (stops[i] instanceof expression_1.default) {
|
||||
color = stops[i].value[0];
|
||||
position = stops[i].value[1];
|
||||
}
|
||||
else {
|
||||
color = stops[i];
|
||||
position = undefined;
|
||||
}
|
||||
if (!(color instanceof color_1.default) || (!((i === 0 || i + 1 === stops.length) && position === undefined) && !(position instanceof dimension_1.default))) {
|
||||
throwArgumentDescriptor();
|
||||
}
|
||||
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
|
||||
alpha = color.alpha;
|
||||
returner += "<stop offset=\"".concat(positionValue, "\" stop-color=\"").concat(color.toRGB(), "\"").concat(alpha < 1 ? " stop-opacity=\"".concat(alpha, "\"") : '', "/>");
|
||||
}
|
||||
returner += "</".concat(gradientType, "Gradient><rect ").concat(rectangleDimension, " fill=\"url(#g)\" /></svg>");
|
||||
returner = encodeURIComponent(returner);
|
||||
returner = "data:image/svg+xml,".concat(returner);
|
||||
return new url_1.default(new quoted_1.default("'".concat(returner, "'"), returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
||||
} };
|
||||
});
|
||||
//# sourceMappingURL=svg.js.map
|
||||
positionValue = position ? position.toCSS(renderEnv) : i === 0 ? '0%' : '100%';
|
||||
alpha = color.alpha;
|
||||
returner += `<stop offset="${positionValue}" stop-color="${color.toRGB()}"${alpha < 1 ? ` stop-opacity="${alpha}"` : ''}/>`;
|
||||
}
|
||||
returner += `</${gradientType}Gradient><rect ${rectangleDimension} fill="url(#g)" /></svg>`;
|
||||
|
||||
returner = encodeURIComponent(returner);
|
||||
|
||||
returner = `data:image/svg+xml,${returner}`;
|
||||
return new URL(new Quoted(`'${returner}'`, returner, false, this.index, this.currentFileInfo), this.index, this.currentFileInfo);
|
||||
}};
|
||||
};
|
||||
|
||||
-1
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user