From c40069e83ef41290d8856d3ed524bb97394d3d30 Mon Sep 17 00:00:00 2001 From: Luke Page Date: Sun, 12 Oct 2014 16:49:38 +0100 Subject: [PATCH] Fix the API files --- lib/less/environment/api.js | 62 ---------------- lib/less/environment/environment-api.js | 25 +++++++ lib/less/environment/file-manager-api.js | 95 ++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 62 deletions(-) delete mode 100644 lib/less/environment/api.js create mode 100644 lib/less/environment/environment-api.js create mode 100644 lib/less/environment/file-manager-api.js diff --git a/lib/less/environment/api.js b/lib/less/environment/api.js deleted file mode 100644 index 2ba3f6d1..00000000 --- a/lib/less/environment/api.js +++ /dev/null @@ -1,62 +0,0 @@ -module.exports = { - /** - * Warns the user about something - * @param {String} msg - the message about the warning - */ - warn: function(msg) { - }, - /** - * Converts a string to a base 64 string - * @param str - */ - encodeBase64: function(str) { - }, - /** - * Lookup the mime-type of a filename - * @param filename - */ - mimeLookup: function (filename) { - }, - /** - * Look up the charset of a mime type - * @param mime - */ - charsetLookup: function (mime) { - }, - /** - * - */ - getSourceMapGenerator: function getSourceMapGenerator() { - }, - /** - * gets the path from the filename, e.g. "http://wwe.files.com/ha/ha.less" would return - * "http://wwe.files.com/ha/" - * If the filename is a file e.g. "file.less" it should return the empty string "" - * @param {String} filename - the filename to extract the path. - * @returns {String} - */ - getPath: function (filename) { - }, - /** - * Returns whether the path is absolute, e.g. "/file.less" = true, "file.less" = false - * @param {String} filename - the filename - * @returns {Boolean} - */ - isPathAbsolute: function(filename) { - }, - /** - * Loads a file for an import aynscronously (or syncronously) - * @param {String} filename - the filename - * @param {String} currentDirectory - the current directory we are in - * @param {Object} options - the context/options object - * @param {Function} callback - a function to callback when finished, - * taking the format callback(error, contents, fullfilename, reserved) - * where error is { type: {string}, message: {string} }, contents is {string} and fullfilename is {string} - * for reserved, see less-browser/index.js which uses this argument for cache information - * @returns {Boolean} - */ - loadFile: function(filename, currentDirectory, options, callback) { - }, - supportsDataURI: function() { - } -}; diff --git a/lib/less/environment/environment-api.js b/lib/less/environment/environment-api.js new file mode 100644 index 00000000..ae6beff4 --- /dev/null +++ b/lib/less/environment/environment-api.js @@ -0,0 +1,25 @@ +module.exports = { + /** + * Converts a string to a base 64 string + * @param str + */ + encodeBase64: function(str) { + }, + /** + * Lookup the mime-type of a filename + * @param filename + */ + mimeLookup: function (filename) { + }, + /** + * Look up the charset of a mime type + * @param mime + */ + charsetLookup: function (mime) { + }, + /** + * Gets a source map generator + */ + getSourceMapGenerator: function getSourceMapGenerator() { + } +}; diff --git a/lib/less/environment/file-manager-api.js b/lib/less/environment/file-manager-api.js new file mode 100644 index 00000000..4138b7cb --- /dev/null +++ b/lib/less/environment/file-manager-api.js @@ -0,0 +1,95 @@ +module.exports = { + /** + * Given the full path to a file, return the path component + * Provided by AbstractFileManager + * @param {string} filename + * @returns {string} + */ + getPath: function(filename) { + }, + /** + * Whether the rootpath should be converted to be absolute. + * The browser ovverides this to return true because urls must be absolute. + * Provided by AbstractFileManager (returns false) + * @returns {bool} + */ + alwaysMakePathsAbsolute: function() { + }, + /** + * Returns whether a path is absolute + * Provided by AbstractFileManager + * @param {string} path + * @returns {bool} + */ + isPathAbsolute: function(path) { + }, + /** + * joins together 2 paths + * Provided by AbstractFileManager + * @param {string} basePath + * @param {string} laterPath + */ + join: function(basePath, laterPath) { + }, + /** + * Returns the difference between 2 paths + * E.g. url = a/ baseUrl = a/b/ returns ../ + * url = a/b/ baseUrl = a/ returns b/ + * Provided by AbstractFileManager + * @param {string} url + * @param {string} baseUrl + * @returns {string} + */ + pathDiff: function(url, baseUrl) { + }, + /** + * Returns whether this file manager supports this file for syncronous file retrieval + * If true is returned, loadFileSync will then be called with the file. + * Provided by AbstractFileManager (returns false) + * @param {string} filename + * @param {string} currentDirectory + * @param {object} options + * @param {less.environment.environment} environment + * @returns {bool} + */ + supportsSync: function(filename, currentDirectory, options, environment) { + }, + /** + * + * @param {string} filename + * @param {string} currentDirectory + * @param {object} options + * @param {less.environment.environment} environment + * @returns {bool} + */ + supports: function(filename, currentDirectory, options, environment) { + }, + /** + * Loads a file asynchronously. Expects a promise that either rejects with an error or fullfills with an + * object containing + * { filename: - full resolved path to file + * contents: - the contents of the file, as a string } + * + * @param {string} filename + * @param {string} currentDirectory + * @param {object} options + * @param {less.environment.environment} environment + * @returns {Promise} + */ + loadFile: function(filename, currentDirectory, options, environment) { + }, + /** + * Loads a file synchronously. Expects an immediate return with an object containing + * { error: - error object if an error occurs + * filename: - full resolved path to file + * contents: - the contents of the file, as a string } + * + * @param {string} filename + * @param {string} currentDirectory + * @param {object} options + * @param {less.environment.environment} environment + * @returns {object} should be an object containing error or contents and filename + */ + loadFileSync: function(filename, currentDirectory, options, environment) { + } +};