feat(planning): grille hebdomadaire complète avec API et filtres

- Connexion API via proxy Angular (résolution CORS, base path /api)
- Import CSS ng-zorro global pour les modales et composants
- Filtres Camion/Show câblés sur l'affichage de la grille
- Camions affichés via TrucksService (linkés au show du même créneau)
- Panneau de détails : spectacles + camions du jour sélectionné
- Modale de création de spectacle stylisée avec fond et centrage
- Positionnement précis des events à la minute dans leur créneau
- Auto-scroll vers l'heure courante au chargement
- Ligne "maintenant" sur la colonne du jour actuel
- Régénération des services OpenAPI (nouveaux noms de types)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-27 20:36:03 +02:00
parent 150b97cd2e
commit 654b297e2e
3131 changed files with 149304 additions and 104334 deletions
+13 -23
View File
@@ -1,19 +1,14 @@
import {addDataAttr} from './utils.js';
import browser from './browser.js';
/**
* @param {Window} window
* @param {Record<string, *>} options
*/
export default (window, options) => {
"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) {
// use options from the current script tag data attribues
addDataAttr(options, browser.currentScript(window));
(0, utils_1.addDataAttr)(options, browser_1.default.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
@@ -22,32 +17,27 @@ export default (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');
const dumpLineNumbers = /!dumpLineNumbers:(comments|mediaquery|all)/.exec(window.location.hash);
var 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
+17 -23
View File
@@ -1,38 +1,33 @@
"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
*/
import defaultOptions from '../less/default-options.js';
import addDefaultOptions from './add-default-options.js';
import root from './index.js';
const options = defaultOptions();
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)();
if (window.less) {
for (const key in window.less) {
for (var key in window.less) {
if (Object.prototype.hasOwnProperty.call(window.less, key)) {
options[key] = window.less[key];
}
}
}
addDefaultOptions(window, options);
(0, add_default_options_1.default)(window, options);
options.plugins = options.plugins || [];
if (window.LESS_PLUGINS) {
options.plugins = options.plugins.concat(window.LESS_PLUGINS);
}
const less = root(window, options);
export default less;
var less = (0, index_1.default)(window, options);
exports.default = less;
window.less = less;
let css;
let head;
let style;
var css;
var head;
var style;
// Always restore page visibility
function resolveOrReject(data) {
if (data.filename) {
@@ -42,7 +37,6 @@ function resolveOrReject(data) {
head.removeChild(style);
}
}
if (options.onReady) {
if (/!watch/.test(window.location.hash)) {
less.watch();
@@ -52,16 +46,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
+21 -24
View File
@@ -1,65 +1,62 @@
import * as utils from './utils.js';
export default {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var utils = tslib_1.__importStar(require("./utils"));
exports.default = {
createCSS: function (document, styles, sheet) {
// Strip the query-string
const href = sheet.href || '';
var href = sheet.href || '';
// If there is no title set, use the filename, minus the extension
const id = `less:${sheet.title || utils.extractId(href)}`;
var id = "less:".concat(sheet.title || utils.extractId(href));
// If this has already been inserted into the DOM, we may need to replace it
const oldStyleNode = document.getElementById(id);
let keepOldStyleNode = false;
var oldStyleNode = document.getElementById(id);
var keepOldStyleNode = false;
// Create a new stylesheet node for insertion or (if necessary) replacement
const styleNode = document.createElement('style');
var 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);
}
const head = document.getElementsByTagName('head')[0];
var 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) {
const nextEl = sheet && sheet.nextSibling || null;
var 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) {
const document = window.document;
return document.currentScript || (() => {
const scripts = document.getElementsByTagName('script');
currentScript: function (window) {
var document = window.document;
return document.currentScript || (function () {
var scripts = document.getElementsByTagName('script');
return scripts[scripts.length - 1];
})();
}
};
//# sourceMappingURL=browser.js.map
+19 -17
View File
@@ -1,36 +1,37 @@
"use strict";
// Cache system is a bit outdated and could do with work
export default (window, options, logger) => {
let cache = null;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (function (window, options, logger) {
var 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 ${path} to cache.`);
logger.info("saving ".concat(path, " to cache."));
try {
cache.setItem(path, styles);
cache.setItem(`${path}:timestamp`, lastModified);
cache.setItem("".concat(path, ":timestamp"), lastModified);
if (modifyVars) {
cache.setItem(`${path}:vars`, JSON.stringify(modifyVars));
cache.setItem("".concat(path, ":vars"), JSON.stringify(modifyVars));
}
} catch (e) {
}
catch (e) {
// TODO - could do with adding more robust error handling
logger.error(`failed to save "${path}" to local storage for caching.`);
logger.error("failed to save \"".concat(path, "\" to local storage for caching."));
}
}
},
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`);
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"));
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()) &&
@@ -40,4 +41,5 @@ export default (window, options, logger) => {
}
}
};
};
});
//# sourceMappingURL=cache.js.map
+44 -52
View File
@@ -1,45 +1,41 @@
import * as utils from './utils.js';
import browser from './browser.js';
export default (window, less, options) => {
"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) {
function errorHTML(e, rootHref) {
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;
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;
elem.className = 'less-error-message';
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) => {
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) {
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 ${e.line}, column ${e.column + 1}:</p><ul>${errors.join('')}</ul>`;
content += "on line ".concat(e.line, ", column ").concat(e.column + 1, ":</p><ul>").concat(errors.join(''), "</ul>");
}
if (e.stack && (e.extract || options.logLevel >= 4)) {
content += `<br/>Stack Trace</br />${e.stack.split('\n').slice(1).join('<br/>')}`;
content += "<br/>Stack Trace</br />".concat(e.stack.split('\n').slice(1).join('<br/>'));
}
elem.innerHTML = content;
// CSS for error messages
browser.createCSS(window.document, [
browser_1.default.createCSS(window.document, [
'.less-error-message ul, .less-error-message li {',
'list-style-type: none;',
'margin-right: 15px;',
@@ -77,7 +73,6 @@ export default (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',
@@ -89,15 +84,15 @@ export default (window, less, options) => {
'padding: 15px',
'margin-bottom: 15px'
].join(';');
if (options.env === 'development') {
timer = setInterval(() => {
const document = window.document;
const body = document.body;
timer = setInterval(function () {
var document = window.document;
var body = document.body;
if (body) {
if (document.getElementById(id)) {
body.replaceChild(elem, document.getElementById(id));
} else {
}
else {
body.insertBefore(elem, body.firstChild);
}
clearInterval(timer);
@@ -105,66 +100,63 @@ export default (window, less, options) => {
}, 10);
}
}
function removeErrorHTML(path) {
const node = window.document.getElementById(`less-error-message:${utils.extractId(path)}`);
var node = window.document.getElementById("less-error-message:".concat(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) {
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) => {
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) {
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 ${e.line}, column ${e.column + 1}:\n${errors.join('\n')}`;
content += " on line ".concat(e.line, ", column ").concat(e.column + 1, ":\n").concat(errors.join('\n'));
}
if (e.stack && (e.extract || options.logLevel >= 4)) {
content += `\nStack Trace\n${e.stack}`;
content += "\nStack Trace\n".concat(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
+42 -52
View File
@@ -1,112 +1,102 @@
import AbstractFileManager from '../less/environment/abstract-file-manager.js';
let options;
let logger;
let fileCache = {};
"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 = {};
// TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load
const FileManager = function() {}
FileManager.prototype = Object.assign(new AbstractFileManager(), {
alwaysMakePathsAbsolute() {
var FileManager = function () { };
FileManager.prototype = Object.assign(new abstract_file_manager_js_1.default(), {
alwaysMakePathsAbsolute: function () {
return true;
},
join(basePath, laterPath) {
join: function (basePath, laterPath) {
if (!basePath) {
return laterPath;
}
return this.extractUrlParts(laterPath, basePath).path;
},
doXHR(url, type, callback, errback) {
const xhr = new XMLHttpRequest();
const async = options.isFileProtocol ? options.fileAsync : true;
doXHR: function (url, type, callback, errback) {
var xhr = new XMLHttpRequest();
var async = options.isFileProtocol ? options.fileAsync : true;
if (typeof xhr.overrideMimeType === 'function') {
xhr.overrideMimeType('text/css');
}
logger.debug(`XHR: Getting '${url}'`);
logger.debug("XHR: Getting '".concat(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 = () => {
}
else if (async) {
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
handleResponse(xhr, callback, errback);
}
};
} else {
}
else {
handleResponse(xhr, callback, errback);
}
},
supports() {
supports: function () {
return true;
},
clearFileCache() {
clearFileCache: function () {
fileCache = {};
},
loadFile(filename, currentDirectory, options) {
loadFile: function (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
const hrefParts = this.extractUrlParts(filename, window.location.href);
const href = hrefParts.url;
const self = this;
return new Promise((resolve, reject) => {
var hrefParts = this.extractUrlParts(filename, window.location.href);
var href = hrefParts.url;
var self = this;
return new Promise(function (resolve, reject) {
if (options.useFileCache && fileCache[href]) {
try {
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}` });
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) });
}
}
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 }});
resolve({ contents: data, filename: href, webInfo: { lastModified: lastModified } });
}, function doXHRError(status, url) {
reject({ type: 'File', message: `'${url}' wasn't found (${status})`, href });
reject({ type: 'File', message: "'".concat(url, "' wasn't found (").concat(status, ")"), href: href });
});
});
}
});
export default (opts, log) => {
exports.default = (function (opts, log) {
options = opts;
logger = log;
return FileManager;
}
});
//# sourceMappingURL=file-manager.js.map
+12 -12
View File
@@ -1,28 +1,28 @@
import functionRegistry from './../less/functions/function-registry.js';
export default () => {
"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 () {
function imageSize() {
throw {
type: 'Runtime',
message: 'Image size functions are not supported in browser version of less'
};
}
const imageFunctions = {
'image-size': function(filePathNode) {
var 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;
}
};
functionRegistry.addMultiple(imageFunctions);
};
function_registry_1.default.addMultiple(imageFunctions);
});
//# sourceMappingURL=image-size.js.map
+105 -131
View File
@@ -1,284 +1,258 @@
"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
//
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);
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)();
less.options = options;
const environment = less.environment;
const FileManager = FM(options, less.logger);
const fileManager = new FileManager();
var environment = less.environment;
var FileManager = (0, file_manager_1.default)(options, less.logger);
var fileManager = new FileManager();
environment.addFileManager(fileManager);
less.FileManager = FileManager;
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);
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);
// Setup user functions - Deprecate?
if (options.functions) {
less.functions.functionRegistry.addMultiple(options.functions);
}
const typePattern = /^text\/(x-)?less$/;
var typePattern = /^text\/(x-)?less$/;
function clone(obj) {
const cloned = {};
for (const prop in obj) {
var cloned = {};
for (var 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) {
const styles = document.getElementsByTagName('style');
for (let style of styles) {
var styles = document.getElementsByTagName('style');
var style;
for (var i = 0; i < styles.length; i++) {
style = styles[i];
if (style.type.match(typePattern)) {
const instanceOptions = {
...clone(options),
modifyVars,
filename: document.location.href.replace(/#.*$/, '')
}
const lessText = style.innerHTML || '';
var instanceOptions = clone(options);
instanceOptions.modifyVars = modifyVars;
var lessText = style.innerHTML || '';
instanceOptions.filename = document.location.href.replace(/#.*$/, '');
/* jshint loopfunc:true */
less.render(lessText, instanceOptions, (err, result) => {
if (err) {
errors.add(err, 'inline');
} else {
// use closure to store current style
less.render(lessText, instanceOptions, bind(function (style, e, result) {
if (e) {
errors.add(e, '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) {
const instanceOptions = clone(options);
addDataAttr(instanceOptions, sheet);
var instanceOptions = clone(options);
(0, utils_1.addDataAttr)(instanceOptions, sheet);
instanceOptions.mime = sheet.type;
if (modifyVars) {
instanceOptions.modifyVars = modifyVars;
}
function loadInitialFileCallback(loadedFile) {
const data = loadedFile.contents;
const path = loadedFile.filename;
const webInfo = loadedFile.webInfo;
const newFileInfo = {
var data = loadedFile.contents;
var path = loadedFile.filename;
var webInfo = loadedFile.webInfo;
var 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;
const css = cache.getCSS(path, webInfo, instanceOptions.modifyVars);
var 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, (e, result) => {
less.render(data, instanceOptions, function (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(loadedFile => {
loadInitialFileCallback(loadedFile);
}).catch(err => {
console.log(err);
callback(err);
});
.then(function (loadedFile) {
loadInitialFileCallback(loadedFile);
}).catch(function (err) {
console.log(err);
callback(err);
});
}
function loadStyleSheets(callback, reload, modifyVars) {
for (let i = 0; i < less.sheets.length; i++) {
for (var 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(() => {
less.watchTimer = setInterval(function () {
if (less.watchMode) {
fileManager.clearFileCache();
/**
* @todo remove when this is typed with JSDoc
*/
// eslint-disable-next-line no-unused-vars
loadStyleSheets((e, css, _, sheet, webInfo) => {
loadStyleSheets(function (e, css, _, sheet, webInfo) {
if (e) {
errors.add(e, e.href || sheet.href);
} else if (css) {
browser.createCSS(window.document, css, sheet);
}
else if (css) {
browser_1.default.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 = () => {
const links = document.getElementsByTagName('link');
less.registerStylesheetsImmediately = function () {
var links = document.getElementsByTagName('link');
less.sheets = [];
for (let i = 0; i < links.length; i++) {
for (var 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 = () => new Promise((resolve) => {
less.registerStylesheets = function () { return new Promise(function (resolve) {
less.registerStylesheetsImmediately();
resolve();
});
}); };
//
// With this function, it's possible to alter variables and re-render
// CSS without reloading less-files
//
less.modifyVars = record => less.refresh(true, record, false);
less.refresh = (reload, modifyVars, clearFileCache) => {
less.modifyVars = function (record) { return less.refresh(true, record, false); };
less.refresh = function (reload, modifyVars, clearFileCache) {
if ((reload || clearFileCache) && clearFileCache !== false) {
fileManager.clearFileCache();
}
return new Promise((resolve, reject) => {
let startTime;
let endTime;
let totalMilliseconds;
let remainingSheets;
return new Promise(function (resolve, reject) {
var startTime;
var endTime;
var totalMilliseconds;
var 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,
endTime,
totalMilliseconds,
startTime: startTime,
endTime: endTime,
totalMilliseconds: 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((e, css, _, sheet, webInfo) => {
loadStyleSheets(function (e, css, _, sheet, webInfo) {
if (e) {
errors.add(e, e.href || sheet.href);
reject(e);
return;
}
if (webInfo.local) {
less.logger.info(`Loading ${sheet.href} from cache.`);
} else {
less.logger.info(`Rendered ${sheet.href} successfully.`);
less.logger.info("Loading ".concat(sheet.href, " from cache."));
}
browser.createCSS(window.document, css, sheet);
less.logger.info(`CSS for ${sheet.href} generated in ${new Date() - endTime}ms`);
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"));
// 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 ${totalMilliseconds}ms`);
less.logger.info("Less has finished. CSS generated in ".concat(totalMilliseconds, "ms"));
resolve({
startTime,
endTime,
totalMilliseconds,
startTime: startTime,
endTime: endTime,
totalMilliseconds: totalMilliseconds,
sheets: less.sheets.length
});
}
endTime = new Date();
}, reload, modifyVars);
}
loadStyles(modifyVars);
});
};
less.refreshStyles = loadStyles;
return less;
};
});
//# sourceMappingURL=index.js.map
+31 -30
View File
@@ -1,42 +1,43 @@
export default (less, options) => {
const logLevel_debug = 4;
const logLevel_info = 3;
const logLevel_warn = 2;
const logLevel_error = 1;
"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;
// 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);
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);
}
}
},
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 (let i = 0; i < options.loggers.length; i++) {
for (var i = 0; i < options.loggers.length; i++) {
less.logger.addListener(options.loggers[i]);
}
};
});
//# sourceMappingURL=log-listener.js.map
+10 -10
View File
@@ -1,24 +1,24 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**
* @todo Add tests for browser `@plugin`
*/
import AbstractPluginLoader from '../less/environment/abstract-plugin-loader.js';
var abstract_plugin_loader_js_1 = tslib_1.__importDefault(require("../less/environment/abstract-plugin-loader.js"));
/**
* Browser Plugin Loader
*/
const PluginLoader = function(less) {
var PluginLoader = function (less) {
this.less = less;
// Should we shim this.require for browser? Probably not?
};
PluginLoader.prototype = Object.assign(new AbstractPluginLoader(), {
loadPlugin(filename, basePath, context, environment, fileManager) {
return new Promise((fulfill, reject) => {
PluginLoader.prototype = Object.assign(new abstract_plugin_loader_js_1.default(), {
loadPlugin: function (filename, basePath, context, environment, fileManager) {
return new Promise(function (fulfill, reject) {
fileManager.loadFile(filename, basePath, context, environment)
.then(fulfill).catch(reject);
});
}
});
export default PluginLoader;
exports.default = PluginLoader;
//# sourceMappingURL=plugin-loader.js.map
+21 -19
View File
@@ -1,30 +1,32 @@
/** @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)
"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 {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) {
exports.extractId = extractId;
function addDataAttr(options, tag) {
if (!tag) {
return;
} // in case of tag is null or undefined
for (var 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