Skip to content
Snippets Groups Projects
Verified Commit 6078722a authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

chore: update and format

parent 910c9388
No related branches found
No related tags found
No related merge requests found
Showing
with 287 additions and 180 deletions
...@@ -43,6 +43,7 @@ include $(MAKEFILE_IMPORT_PATH)directories-standard.mk ...@@ -43,6 +43,7 @@ include $(MAKEFILE_IMPORT_PATH)directories-standard.mk
#include $(MAKEFILE_IMPORT_PATH)directories-go-lib.mk #include $(MAKEFILE_IMPORT_PATH)directories-go-lib.mk
#include $(MAKEFILE_IMPORT_PATH)directories-go-utilities.mk #include $(MAKEFILE_IMPORT_PATH)directories-go-utilities.mk
#include $(MAKEFILE_IMPORT_PATH)directories-platform-part.mk #include $(MAKEFILE_IMPORT_PATH)directories-platform-part.mk
include $(MAKEFILE_IMPORT_PATH)go.mk
include $(MAKEFILE_IMPORT_PATH)jsdoc.mk include $(MAKEFILE_IMPORT_PATH)jsdoc.mk
include $(MAKEFILE_IMPORT_PATH)output.mk include $(MAKEFILE_IMPORT_PATH)output.mk
include $(MAKEFILE_IMPORT_PATH)placeholder.mk include $(MAKEFILE_IMPORT_PATH)placeholder.mk
...@@ -59,7 +60,6 @@ include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk ...@@ -59,7 +60,6 @@ include $(MAKEFILE_IMPORT_PATH)license-agpl3.mk
#include $(MAKEFILE_IMPORT_PATH)license-unlicensed.mk #include $(MAKEFILE_IMPORT_PATH)license-unlicensed.mk
#include $(MAKEFILE_IMPORT_PATH)license-all-rights-reserved.mk #include $(MAKEFILE_IMPORT_PATH)license-all-rights-reserved.mk
include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk include $(MAKEFILE_IMPORT_PATH)jsdoc-json.mk
include $(MAKEFILE_IMPORT_PATH)go.mk
include $(MAKEFILE_IMPORT_PATH)changelog.mk include $(MAKEFILE_IMPORT_PATH)changelog.mk
#include $(MAKEFILE_IMPORT_PATH)docman.mk #include $(MAKEFILE_IMPORT_PATH)docman.mk
#include $(MAKEFILE_IMPORT_PATH)reqman.mk #include $(MAKEFILE_IMPORT_PATH)reqman.mk
......
...@@ -189,7 +189,10 @@ function fetchData(init, key, callback) { ...@@ -189,7 +189,10 @@ function fetchData(init, key, callback) {
const acceptedStatus = self.getOption(`${key}.acceptedStatus`, [200]); const acceptedStatus = self.getOption(`${key}.acceptedStatus`, [200]);
if (acceptedStatus.indexOf(resp.status) === -1) { if (acceptedStatus.indexOf(resp.status) === -1) {
throw new DataFetchError(`the response does not contain a accepted status (actual: ${resp.status}).`, response); throw new DataFetchError(
`the response does not contain a accepted status (actual: ${resp.status}).`,
response,
);
} }
return resp.text(); return resp.text();
......
...@@ -27,7 +27,7 @@ class DataFetchError extends Error { ...@@ -27,7 +27,7 @@ class DataFetchError extends Error {
constructor(message, response) { constructor(message, response) {
super(message); super(message);
this[internalSymbol] = { this[internalSymbol] = {
response: response response: response,
}; };
} }
...@@ -46,5 +46,4 @@ class DataFetchError extends Error { ...@@ -46,5 +46,4 @@ class DataFetchError extends Error {
getResponse() { getResponse() {
return this[internalSymbol]["response"]; return this[internalSymbol]["response"];
} }
} }
...@@ -674,7 +674,6 @@ function transform(value) { ...@@ -674,7 +674,6 @@ function transform(value) {
} }
case "datetimeformat": case "datetimeformat":
date = new Date(value); date = new Date(value);
if (isNaN(date.getTime())) { if (isNaN(date.getTime())) {
throw new Error("invalid date"); throw new Error("invalid date");
...@@ -687,7 +686,7 @@ function transform(value) { ...@@ -687,7 +686,7 @@ function transform(value) {
try { try {
locale = getLocaleOfDocument(); locale = getLocaleOfDocument();
return new Intl.DateTimeFormat(locale, options).format(date) return new Intl.DateTimeFormat(locale, options).format(date);
} catch (e) { } catch (e) {
throw new Error(`unsupported locale or missing format (${e.message})`); throw new Error(`unsupported locale or missing format (${e.message})`);
} }
......
...@@ -61,7 +61,7 @@ export { ...@@ -61,7 +61,7 @@ export {
customElementUpdaterLinkSymbol, customElementUpdaterLinkSymbol,
initControlCallbackName, initControlCallbackName,
ATTRIBUTE_SCRIPT_HOST, ATTRIBUTE_SCRIPT_HOST,
ATTRIBUTE_INIT_CALLBACK ATTRIBUTE_INIT_CALLBACK,
}; };
/** /**
......
...@@ -49,7 +49,6 @@ const attachedInternalSymbol = Symbol("attachedInternal"); ...@@ -49,7 +49,6 @@ const attachedInternalSymbol = Symbol("attachedInternal");
* @extends Monster.DOM.CustomElement * @extends Monster.DOM.CustomElement
*/ */
class CustomControl extends CustomElement { class CustomControl extends CustomElement {
/** /**
* The constructor method of CustomControl, which is called when creating a new instance. * The constructor method of CustomControl, which is called when creating a new instance.
* It checks whether the element supports `attachInternals()` and initializes an internal form-associated element * It checks whether the element supports `attachInternals()` and initializes an internal form-associated element
...@@ -79,7 +78,6 @@ class CustomControl extends CustomElement { ...@@ -79,7 +78,6 @@ class CustomControl extends CustomElement {
initObserver.call(this); initObserver.call(this);
} }
/** /**
* This method is called by the `instanceof` operator. * This method is called by the `instanceof` operator.
* @returns {symbol} * @returns {symbol}
...@@ -142,7 +140,6 @@ class CustomControl extends CustomElement { ...@@ -142,7 +140,6 @@ class CustomControl extends CustomElement {
throw Error("the value setter must be overwritten by the derived class"); throw Error("the value setter must be overwritten by the derived class");
} }
/** /**
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals) * This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
* *
...@@ -327,14 +324,11 @@ class CustomControl extends CustomElement { ...@@ -327,14 +324,11 @@ class CustomControl extends CustomElement {
} }
} }
/** /**
* @param {string} state * @param {string} state
* @param {string} mode * @param {string} mode
*/ */
formStateRestoreCallback(state, mode) { formStateRestoreCallback(state, mode) {}
}
/** /**
* *
...@@ -342,7 +336,6 @@ class CustomControl extends CustomElement { ...@@ -342,7 +336,6 @@ class CustomControl extends CustomElement {
formResetCallback() { formResetCallback() {
this.value = ""; this.value = "";
} }
} }
/** /**
......
...@@ -27,7 +27,7 @@ import { ...@@ -27,7 +27,7 @@ import {
ATTRIBUTE_OPTIONS_SELECTOR, ATTRIBUTE_OPTIONS_SELECTOR,
ATTRIBUTE_SCRIPT_HOST, ATTRIBUTE_SCRIPT_HOST,
customElementUpdaterLinkSymbol, customElementUpdaterLinkSymbol,
initControlCallbackName initControlCallbackName,
} from "./constants.mjs"; } from "./constants.mjs";
import { findDocumentTemplate, Template } from "./template.mjs"; import { findDocumentTemplate, Template } from "./template.mjs";
import { addObjectWithUpdaterToElement } from "./updater.mjs"; import { addObjectWithUpdaterToElement } from "./updater.mjs";
...@@ -220,7 +220,6 @@ class CustomElement extends HTMLElement { ...@@ -220,7 +220,6 @@ class CustomElement extends HTMLElement {
this[initMethodSymbol](); this[initMethodSymbol]();
initOptionObserver.call(this); initOptionObserver.call(this);
this[scriptHostElementSymbol] = []; this[scriptHostElementSymbol] = [];
} }
/** /**
...@@ -445,8 +444,7 @@ class CustomElement extends HTMLElement { ...@@ -445,8 +444,7 @@ class CustomElement extends HTMLElement {
try { try {
value = new Pathfinder(this[internalSymbol].getRealSubject()["options"]).getVia(path); value = new Pathfinder(this[internalSymbol].getRealSubject()["options"]).getVia(path);
} catch (e) { } catch (e) {}
}
if (value === undefined) return defaultValue; if (value === undefined) return defaultValue;
return value; return value;
...@@ -574,22 +572,18 @@ class CustomElement extends HTMLElement { ...@@ -574,22 +572,18 @@ class CustomElement extends HTMLElement {
// Check if the object has already been initialized // Check if the object has already been initialized
if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) { if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) {
// If not, call the assembleMethod to initialize the object // If not, call the assembleMethod to initialize the object
self[assembleMethodSymbol](); self[assembleMethodSymbol]();
} }
} }
/** /**
* Called every time the element is removed from the DOM. Useful for running clean up code. * Called every time the element is removed from the DOM. Useful for running clean up code.
* *
* @return {void} * @return {void}
* @since 1.7.0 * @since 1.7.0
*/ */
disconnectedCallback() { disconnectedCallback() {}
}
/** /**
* The custom element has been moved into a new document (e.g. someone called document.adoptNode(el)). * The custom element has been moved into a new document (e.g. someone called document.adoptNode(el)).
...@@ -597,8 +591,7 @@ class CustomElement extends HTMLElement { ...@@ -597,8 +591,7 @@ class CustomElement extends HTMLElement {
* @return {void} * @return {void}
* @since 1.7.0 * @since 1.7.0
*/ */
adoptedCallback() { adoptedCallback() {}
}
/** /**
* Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial * Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial
...@@ -615,7 +608,7 @@ class CustomElement extends HTMLElement { ...@@ -615,7 +608,7 @@ class CustomElement extends HTMLElement {
const self = this; const self = this;
if (attrName.startsWith("data-monster-option-")) { if (attrName.startsWith("data-monster-option-")) {
setOptionFromAttribute(self, attrName, this[internalSymbol].getSubject()["options"]) setOptionFromAttribute(self, attrName, this[internalSymbol].getSubject()["options"]);
} }
const callback = self[attributeObserverSymbol]?.[attrName]; const callback = self[attributeObserverSymbol]?.[attrName];
...@@ -625,7 +618,6 @@ class CustomElement extends HTMLElement { ...@@ -625,7 +618,6 @@ class CustomElement extends HTMLElement {
} catch (e) { } catch (e) {
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString()); addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString());
} }
} }
} }
...@@ -661,8 +653,6 @@ class CustomElement extends HTMLElement { ...@@ -661,8 +653,6 @@ class CustomElement extends HTMLElement {
const self = this; const self = this;
return callControlCallback.call(self, name, ...args); return callControlCallback.call(self, name, ...args);
} }
} }
/** /**
...@@ -679,7 +669,6 @@ function callControlCallback(callBackFunctionName, ...args) { ...@@ -679,7 +669,6 @@ function callControlCallback(callBackFunctionName, ...args) {
if (callBackFunctionName in self) { if (callBackFunctionName in self) {
return self[callBackFunctionName](self, ...args); return self[callBackFunctionName](self, ...args);
} }
if (!self.hasAttribute(ATTRIBUTE_SCRIPT_HOST)) { if (!self.hasAttribute(ATTRIBUTE_SCRIPT_HOST)) {
...@@ -687,13 +676,12 @@ function callControlCallback(callBackFunctionName, ...args) { ...@@ -687,13 +676,12 @@ function callControlCallback(callBackFunctionName, ...args) {
} }
if (self[scriptHostElementSymbol].length === 0) { if (self[scriptHostElementSymbol].length === 0) {
const targetId = self.getAttribute(ATTRIBUTE_SCRIPT_HOST); const targetId = self.getAttribute(ATTRIBUTE_SCRIPT_HOST);
if (!targetId) { if (!targetId) {
return; return;
} }
const list = targetId.split(",") const list = targetId.split(",");
for (const id of list) { for (const id of list) {
const host = findElementWithIdUpwards(self, targetId); const host = findElementWithIdUpwards(self, targetId);
if (!(host instanceof HTMLElement)) { if (!(host instanceof HTMLElement)) {
...@@ -715,7 +703,6 @@ function callControlCallback(callBackFunctionName, ...args) { ...@@ -715,7 +703,6 @@ function callControlCallback(callBackFunctionName, ...args) {
} }
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `callback ${callBackFunctionName} not found`); addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, `callback ${callBackFunctionName} not found`);
} }
/** /**
...@@ -746,7 +733,6 @@ function initFromCallbackHost() { ...@@ -746,7 +733,6 @@ function initFromCallbackHost() {
callControlCallback.call(self, callBackFunctionName); callControlCallback.call(self, callBackFunctionName);
} }
/** /**
* This method is called when the element is first created. * This method is called when the element is first created.
* *
...@@ -763,7 +749,11 @@ function attachAttributeChangeMutationObserver() { ...@@ -763,7 +749,11 @@ function attachAttributeChangeMutationObserver() {
self[attributeMutationObserverSymbol] = new MutationObserver(function (mutations, observer) { self[attributeMutationObserverSymbol] = new MutationObserver(function (mutations, observer) {
for (const mutation of mutations) { for (const mutation of mutations) {
if (mutation.type === "attributes") { if (mutation.type === "attributes") {
self.attributeChangedCallback(mutation.attributeName, mutation.oldValue, mutation.target.getAttribute(mutation.attributeName)); self.attributeChangedCallback(
mutation.attributeName,
mutation.oldValue,
mutation.target.getAttribute(mutation.attributeName),
);
} }
} }
}); });
...@@ -773,7 +763,6 @@ function attachAttributeChangeMutationObserver() { ...@@ -773,7 +763,6 @@ function attachAttributeChangeMutationObserver() {
attributes: true, attributes: true,
attributeOldValue: true, attributeOldValue: true,
}); });
} catch (e) { } catch (e) {
addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString()); addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString());
} }
...@@ -971,8 +960,7 @@ function parseOptionsJSON(data) { ...@@ -971,8 +960,7 @@ function parseOptionsJSON(data) {
try { try {
let dataUrl = parseDataURL(data); let dataUrl = parseDataURL(data);
data = dataUrl.content; data = dataUrl.content;
} catch (e) { } catch (e) {}
}
try { try {
obj = JSON.parse(data); obj = JSON.parse(data);
......
...@@ -75,10 +75,8 @@ function getDeviceDPI() { ...@@ -75,10 +75,8 @@ function getDeviceDPI() {
*/ */
function convertToPixels(value, parentElement = document.documentElement, fontSizeElement = document.documentElement) { function convertToPixels(value, parentElement = document.documentElement, fontSizeElement = document.documentElement) {
validateString(value); validateString(value);
const regex = /^(-?[\d.]+)(.*)$/; const regex = /^(-?[\d.]+)(.*)$/;
const matchResult = value.match(regex); const matchResult = value.match(regex);
......
...@@ -209,7 +209,11 @@ function traverseShadowRoots(element) { ...@@ -209,7 +209,11 @@ function traverseShadowRoots(element) {
let currentRoot = element.shadowRoot; let currentRoot = element.shadowRoot;
let currentParent = element.parentNode; let currentParent = element.parentNode;
while (currentParent && currentParent.nodeType !== Node.DOCUMENT_NODE && currentParent.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) { while (
currentParent &&
currentParent.nodeType !== Node.DOCUMENT_NODE &&
currentParent.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
) {
if (currentRoot && currentRoot.parentNode) { if (currentRoot && currentRoot.parentNode) {
currentParent = currentRoot.parentNode; currentParent = currentRoot.parentNode;
currentRoot = currentParent.shadowRoot; currentRoot = currentParent.shadowRoot;
...@@ -238,8 +242,11 @@ function traverseShadowRoots(element) { ...@@ -238,8 +242,11 @@ function traverseShadowRoots(element) {
* @since 3.36.0 * @since 3.36.0
*/ */
function getContainingDocument(element) { function getContainingDocument(element) {
if (!element || !(element instanceof HTMLElement || element instanceof element.ownerDocument.defaultView.HTMLElement)) { if (
throw new Error('Invalid argument. Expected an HTMLElement.'); !element ||
!(element instanceof HTMLElement || element instanceof element.ownerDocument.defaultView.HTMLElement)
) {
throw new Error("Invalid argument. Expected an HTMLElement.");
} }
return traverseShadowRoots(element) || null; return traverseShadowRoots(element) || null;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/ */
export {extractKeys} export { extractKeys };
/** /**
* Extracts the keys from the given object and returns a map with the keys and values. * Extracts the keys from the given object and returns a map with the keys and values.
...@@ -17,17 +17,21 @@ export {extractKeys} ...@@ -17,17 +17,21 @@ export {extractKeys}
* @param {string} valueSeparator * @param {string} valueSeparator
* @returns {Map<any, any>} * @returns {Map<any, any>}
*/ */
function extractKeys(obj, keyPrefix = '', keySeparator = '-', valueSeparator = '.') { function extractKeys(obj, keyPrefix = "", keySeparator = "-", valueSeparator = ".") {
const resultMap = new Map(); const resultMap = new Map();
function helper(currentObj, currentKeyPrefix, currentValuePrefix) { function helper(currentObj, currentKeyPrefix, currentValuePrefix) {
for (const key in currentObj) { for (const key in currentObj) {
if (typeof currentObj[key] === 'object' && !Array.isArray(currentObj[key])) { if (typeof currentObj[key] === "object" && !Array.isArray(currentObj[key])) {
const newKeyPrefix = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase(); const newKeyPrefix = currentKeyPrefix
? currentKeyPrefix + keySeparator + key.toLowerCase()
: key.toLowerCase();
const newValuePrefix = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key; const newValuePrefix = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
helper(currentObj[key], newKeyPrefix, newValuePrefix); helper(currentObj[key], newKeyPrefix, newValuePrefix);
} else { } else {
const finalKey = currentKeyPrefix ? currentKeyPrefix + keySeparator + key.toLowerCase() : key.toLowerCase(); const finalKey = currentKeyPrefix
? currentKeyPrefix + keySeparator + key.toLowerCase()
: key.toLowerCase();
const finalValue = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key; const finalValue = currentValuePrefix ? currentValuePrefix + valueSeparator + key : key;
resultMap.set(finalKey, finalValue); resultMap.set(finalKey, finalValue);
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/ */
import {Pathfinder} from '../../data/pathfinder.mjs'; import { Pathfinder } from "../../data/pathfinder.mjs";
import {isFunction} from '../../types/is.mjs'; import { isFunction } from "../../types/is.mjs";
import { attributeObserverSymbol } from "../customelement.mjs"; import { attributeObserverSymbol } from "../customelement.mjs";
import { extractKeys } from "./extract-keys.mjs"; import { extractKeys } from "./extract-keys.mjs";
...@@ -41,7 +41,7 @@ export {initOptionsFromAttributes}; ...@@ -41,7 +41,7 @@ export {initOptionsFromAttributes};
* @returns {Object} - The initialized options object. * @returns {Object} - The initialized options object.
* @this HTMLElement - The context of the DOM element. * @this HTMLElement - The context of the DOM element.
*/ */
function initOptionsFromAttributes(element, options, mapping = {}, prefix = 'data-monster-option-') { function initOptionsFromAttributes(element, options, mapping = {}, prefix = "data-monster-option-") {
if (!(element instanceof HTMLElement)) return options; if (!(element instanceof HTMLElement)) return options;
if (!element.hasAttributes()) return options; if (!element.hasAttributes()) return options;
...@@ -65,21 +65,19 @@ function initOptionsFromAttributes(element, options, mapping = {}, prefix = 'dat ...@@ -65,21 +65,19 @@ function initOptionsFromAttributes(element, options, mapping = {}, prefix = 'dat
} }
const typeOfOptionValue = typeof finder.getVia(optionName); const typeOfOptionValue = typeof finder.getVia(optionName);
if (typeOfOptionValue === 'boolean') { if (typeOfOptionValue === "boolean") {
value = value === 'true'; value = value === "true";
} else if (typeOfOptionValue === 'number') { } else if (typeOfOptionValue === "number") {
value = Number(value); value = Number(value);
} else if (typeOfOptionValue === 'string') { } else if (typeOfOptionValue === "string") {
value = String(value); value = String(value);
} else if (typeOfOptionValue === 'object') { } else if (typeOfOptionValue === "object") {
value = JSON.parse(value); value = JSON.parse(value);
} }
finder.setVia(optionName, value); finder.setVia(optionName, value);
} }
}) });
return options; return options;
} }
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/ */
import {Pathfinder} from '../../data/pathfinder.mjs'; import { Pathfinder } from "../../data/pathfinder.mjs";
import {isFunction} from '../../types/is.mjs'; import { isFunction } from "../../types/is.mjs";
import { attributeObserverSymbol } from "../customelement.mjs"; import { attributeObserverSymbol } from "../customelement.mjs";
import { extractKeys } from "./extract-keys.mjs"; import { extractKeys } from "./extract-keys.mjs";
...@@ -42,7 +42,7 @@ export {setOptionFromAttribute}; ...@@ -42,7 +42,7 @@ export {setOptionFromAttribute};
* @returns {Object} - The initialized options object. * @returns {Object} - The initialized options object.
* @this HTMLElement - The context of the DOM element. * @this HTMLElement - The context of the DOM element.
*/ */
function setOptionFromAttribute(element, name, options, mapping = {}, prefix = 'data-monster-option-') { function setOptionFromAttribute(element, name, options, mapping = {}, prefix = "data-monster-option-") {
if (!(element instanceof HTMLElement)) return options; if (!(element instanceof HTMLElement)) return options;
if (!element.hasAttributes()) return options; if (!element.hasAttributes()) return options;
...@@ -65,13 +65,13 @@ function setOptionFromAttribute(element, name, options, mapping = {}, prefix = ' ...@@ -65,13 +65,13 @@ function setOptionFromAttribute(element, name, options, mapping = {}, prefix = '
} }
const typeOfOptionValue = typeof finder.getVia(optionName); const typeOfOptionValue = typeof finder.getVia(optionName);
if (typeOfOptionValue === 'boolean') { if (typeOfOptionValue === "boolean") {
value = value === 'true'; value = value === "true";
} else if (typeOfOptionValue === 'number') { } else if (typeOfOptionValue === "number") {
value = Number(value); value = Number(value);
} else if (typeOfOptionValue === 'string') { } else if (typeOfOptionValue === "string") {
value = String(value); value = String(value);
} else if (typeOfOptionValue === 'object') { } else if (typeOfOptionValue === "object") {
value = JSON.parse(value); value = JSON.parse(value);
} }
...@@ -79,5 +79,3 @@ function setOptionFromAttribute(element, name, options, mapping = {}, prefix = ' ...@@ -79,5 +79,3 @@ function setOptionFromAttribute(element, name, options, mapping = {}, prefix = '
return options; return options;
} }
...@@ -21,10 +21,6 @@ export { ConsoleHandler }; ...@@ -21,10 +21,6 @@ export { ConsoleHandler };
* @memberOf Monster.Logging.Handler * @memberOf Monster.Logging.Handler
*/ */
class ConsoleHandler extends Handler { class ConsoleHandler extends Handler {
constructor() {
super();
}
/** /**
* This is the central log function. this method must be * This is the central log function. this method must be
* overwritten by derived handlers with their own logic. * overwritten by derived handlers with their own logic.
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/ */
export {parseBracketedKeyValueHash, createBracketedKeyValueHash} export { parseBracketedKeyValueHash, createBracketedKeyValueHash };
/** /**
* Parses a string containing bracketed key-value pairs and returns an object representing the parsed result. * Parses a string containing bracketed key-value pairs and returns an object representing the parsed result.
...@@ -49,8 +49,7 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -49,8 +49,7 @@ function parseBracketedKeyValueHash(hashString) {
//const keyValueStack = []; //const keyValueStack = [];
const trimmedHashString = hashString.trim(); const trimmedHashString = hashString.trim();
const cleanedHashString = trimmedHashString.charAt(0) === '#' ? trimmedHashString.slice(1) : trimmedHashString; const cleanedHashString = trimmedHashString.charAt(0) === "#" ? trimmedHashString.slice(1) : trimmedHashString;
//const selectors = (keyValueStack.length > 0) ? result[selectorStack[selectorStack.length - 1]] : result; //const selectors = (keyValueStack.length > 0) ? result[selectorStack[selectorStack.length - 1]] : result;
let currentSelector = ""; let currentSelector = "";
...@@ -65,20 +64,20 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -65,20 +64,20 @@ function parseBracketedKeyValueHash(hashString) {
} }
} }
let currentKey = ''; let currentKey = "";
let currentValue = ''; let currentValue = "";
let inKey = true; let inKey = true;
let inValue = false; let inValue = false;
let inQuotedValue = false; let inQuotedValue = false;
let inSelector = true; let inSelector = true;
let escaped = false; let escaped = false;
let quotedValueStartChar = ''; let quotedValueStartChar = "";
for (let i = 0; i < cleanedHashString.length; i++) { for (let i = 0; i < cleanedHashString.length; i++) {
const c = cleanedHashString[i]; const c = cleanedHashString[i];
const nextChar = cleanedHashString?.[i + 1]; const nextChar = cleanedHashString?.[i + 1];
if (c === '\\' && !escaped) { if (c === "\\" && !escaped) {
escaped = true; escaped = true;
continue; continue;
} }
...@@ -96,7 +95,6 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -96,7 +95,6 @@ function parseBracketedKeyValueHash(hashString) {
} }
if (inQuotedValue && quotedValueStartChar !== c) { if (inQuotedValue && quotedValueStartChar !== c) {
if (inSelector) { if (inSelector) {
currentSelector += c; currentSelector += c;
} else if (inKey) { } else if (inKey) {
...@@ -108,19 +106,18 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -108,19 +106,18 @@ function parseBracketedKeyValueHash(hashString) {
continue; continue;
} }
if (c === ';' && inSelector) { if (c === ";" && inSelector) {
inSelector = true; inSelector = true;
currentSelector = ""; currentSelector = "";
continue; continue;
} }
if (inSelector === true && c !== "(") {
if (inSelector === true && c !== '(') {
currentSelector += c; currentSelector += c;
continue; continue;
} }
if (c === '(' && inSelector) { if (c === "(" && inSelector) {
inSelector = false; inSelector = false;
inKey = true; inKey = true;
...@@ -128,13 +125,12 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -128,13 +125,12 @@ function parseBracketedKeyValueHash(hashString) {
continue; continue;
} }
if (inKey === true && c !== '=') { if (inKey === true && c !== "=") {
currentKey += c; currentKey += c;
continue; continue;
} }
if (c === '=' && inKey) { if (c === "=" && inKey) {
inKey = false; inKey = false;
inValue = true; inValue = true;
...@@ -160,7 +156,7 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -160,7 +156,7 @@ function parseBracketedKeyValueHash(hashString) {
continue; continue;
} }
if (c === ',') { if (c === ",") {
inValue = false; inValue = false;
inKey = true; inKey = true;
const decodedCurrentValue = decodeURIComponent(currentValue); const decodedCurrentValue = decodeURIComponent(currentValue);
...@@ -170,7 +166,7 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -170,7 +166,7 @@ function parseBracketedKeyValueHash(hashString) {
continue; continue;
} }
if (c === ')') { if (c === ")") {
inValue = false; inValue = false;
//inKey = true; //inKey = true;
inSelector = true; inSelector = true;
...@@ -189,14 +185,11 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -189,14 +185,11 @@ function parseBracketedKeyValueHash(hashString) {
} }
} }
if (inSelector) { if (inSelector) {
return selectors; return selectors;
} }
return {}; return {};
} }
/** /**
...@@ -208,38 +201,37 @@ function parseBracketedKeyValueHash(hashString) { ...@@ -208,38 +201,37 @@ function parseBracketedKeyValueHash(hashString) {
* @since 3.37.0 * @since 3.37.0
*/ */
function createBracketedKeyValueHash(object, addHashPrefix = true) { function createBracketedKeyValueHash(object, addHashPrefix = true) {
if (!object) { if (!object) {
return addHashPrefix ? '#' : ''; return addHashPrefix ? "#" : "";
} }
let hashString = ''; let hashString = "";
function encodeKeyValue(key, value) { function encodeKeyValue(key, value) {
return encodeURIComponent(key) + '=' + encodeURIComponent(value); return encodeURIComponent(key) + "=" + encodeURIComponent(value);
} }
for (const selector in object) { for (const selector in object) {
if (object.hasOwnProperty(selector)) { if (object.hasOwnProperty(selector)) {
const keyValuePairs = object[selector]; const keyValuePairs = object[selector];
let selectorString = selector; let selectorString = selector;
let keyValueString = ''; let keyValueString = "";
for (const key in keyValuePairs) { for (const key in keyValuePairs) {
if (keyValuePairs.hasOwnProperty(key)) { if (keyValuePairs.hasOwnProperty(key)) {
const value = keyValuePairs[key]; const value = keyValuePairs[key];
keyValueString += keyValueString.length === 0 ? '' : ','; keyValueString += keyValueString.length === 0 ? "" : ",";
keyValueString += encodeKeyValue(key, value); keyValueString += encodeKeyValue(key, value);
} }
} }
if (keyValueString.length > 0) { if (keyValueString.length > 0) {
selectorString += '(' + keyValueString + ')'; selectorString += "(" + keyValueString + ")";
hashString += hashString.length === 0 ? '' : ';'; hashString += hashString.length === 0 ? "" : ";";
hashString += selectorString; hashString += selectorString;
} }
} }
} }
return addHashPrefix ? '#' + hashString : hashString; return addHashPrefix ? "#" + hashString : hashString;
} }
export { generateRangeComparisonExpression } from "./generate-range-comparison-expression.mjs" export { generateRangeComparisonExpression } from "./generate-range-comparison-expression.mjs";
#############################################################################################
#############################################################################################
##
## DEFINE BLACKBOX
##
#############################################################################################
#############################################################################################
EXECUTABLES = $(EXECUTABLES:-) gpgconf git
BLACKBOX_ROOT_DIR = $(PROJECT_ROOT)
BLACKBOX_BUILD_DIR = $(BLACKBOX_ROOT_DIR)build/blackbox
BLACKBOX_CONFIG_PATH = $(BLACKBOX_ROOT_DIR).blackbox
BLACKBOX_GPG_PATH = $(shell gpgconf --list-dirs homedir)
# The default image of blackbox
# only local image is supported
BLACKBOX_IMAGE_NAME= blackbox_local_temp_image
BLACKBOX_IMAGE_HASH = $(shell git log --format="%h" -n 1)
BLACKBOX_IMAGE = $(BLACKBOX_IMAGE_NAME):$(BLACKBOX_IMAGE_HASH)
define BLACKBOX_RUN_SCRIPT
#!/bin/bash
function cleanup()
{
for FILE in $$(blackbox_list_files); do
blackbox_edit_end $${FILE} || exit 1
done
exit 0
}
if [ "$$#" -ne 1 ]; then
## args are: open, close, run
echo "Usage: $$0 open|close|run"
exit 1
fi
## trap if arg is run
if [ "$$1" == "run" ]; then
# Intercepts the signal and then executes the command to encrypt.
trap cleanup INT TERM SIGTERM SIGUSR1
fi
if [ "$$1" == "open" ] || [ "$$1" == "run" ]; then
echo "Opening files..."
for FILE in $$(blackbox_list_files); do
blackbox_edit_start $${FILE} || exit 1
done
fi
if [ "$$1" == "close" ]; then
echo "Closing files..."
for FILE in $$(blackbox_list_files); do
blackbox_edit_end $${FILE} || exit 1
done
elif [ "$$1" == "run" ]; then
echo "Running command..."
while true; do
sleep 1
done
elif [ "$$1" == "open" ]; then
exit 0
else
echo "Unknown command: $$1"
exit 1
fi
endef
define BLACKBOX_DOCKERFILE
FROM docker-registry.schukai.com:443/debian-bullseye-amd64-slim:snapshot AS deb-builder
RUN apt-get update && apt-get install git make rubygems build-essential
RUN cd /opt/ && \
git clone https://github.com/StackExchange/blackbox.git
RUN gem install fpm
RUN cd /opt/blackbox && \
make packages-deb
FROM docker-registry.schukai.com:443/debian-bullseye-amd64-slim:snapshot
RUN apt-get update && apt-get install git gnupg
RUN sed -i /NAME=/s/=.*/'="Blackbox"'/ /etc/container-release ;
COPY --from=deb-builder /root/debbuild-stack_blackbox/ /tmp/
RUN apt-get install /tmp/*.deb
RUN mkdir /repos /root/.gnupg
VOLUME [ "/repos" ]
WORKDIR /repos
COPY ./filesystem/bin /bin/
RUN chmod ugo+x /bin/run-blackbox.sh
ARG UNAME=dummy
ARG UID=1000
ARG GID=1000
RUN groupadd -g $$GID -o $$UNAME
RUN useradd -m -u $$UID -g $$GID -o -s /bin/bash $$UNAME
ENTRYPOINT [ "/bin/run-blackbox.sh" ]
endef
\ No newline at end of file
...@@ -11,6 +11,11 @@ SOURCE_PATH ?= $(PROJECT_ROOT)source/ ...@@ -11,6 +11,11 @@ SOURCE_PATH ?= $(PROJECT_ROOT)source/
RELATIVE_SCRIPT_PATH ?= script/ RELATIVE_SCRIPT_PATH ?= script/
SCRIPT_PATH ?= $(PROJECT_ROOT)$(RELATIVE_SCRIPT_PATH) SCRIPT_PATH ?= $(PROJECT_ROOT)$(RELATIVE_SCRIPT_PATH)
## DEPRECATED ALIAS
SCRIPTS_PATH = $(SCRIPT_PATH)
VENDOR_PATH ?= $(PROJECT_ROOT)vendor/ VENDOR_PATH ?= $(PROJECT_ROOT)vendor/
NODE_PATH ?= $(PROJECT_ROOT)node_modules/ NODE_PATH ?= $(PROJECT_ROOT)node_modules/
TEST_PATH ?= $(PROJECT_ROOT)test/ TEST_PATH ?= $(PROJECT_ROOT)test/
......
...@@ -8,8 +8,9 @@ ...@@ -8,8 +8,9 @@
# path and binaries # path and binaries
GO := go GO := go
GOLINT := golint
EXECUTABLES = $(EXECUTABLES:-) $(GO); EXECUTABLES = $(EXECUTABLES:-) $(GO) $(GOLINT);
ifeq ($(shell command -v $(GO) 2> /dev/null),) ifeq ($(shell command -v $(GO) 2> /dev/null),)
$(error "go is not installed. Please install go <https://go.dev/doc/install>") $(error "go is not installed. Please install go <https://go.dev/doc/install>")
...@@ -25,3 +26,9 @@ ifeq ($(GOPATH),) ...@@ -25,3 +26,9 @@ ifeq ($(GOPATH),)
export PATH=$(PATH):$(GOPATH)/bin export PATH=$(PATH):$(GOPATH)/bin
endif endif
ifdef SOURCE_PATH
PKG_LIST := $(shell if [ -d "SOURCE_PATH" ] ; then cd $(SOURCE_PATH); $(GO) list ./... | grep -v /vendor/ ; fi)
GO_FILES := $(shell if [ -d "SOURCE_PATH" ] ; then cd $(SOURCE_PATH); find . -name '*.go' | grep -v /vendor/ | grep -v _test.go; fi)
endif
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
############################################################################################# #############################################################################################
############################################################################################# #############################################################################################
ifeq ($(GO),)
$(error $(ERRORMARKER) Go is not defined, check your Makefile if go.mk is included)
endif
ifneq "$(wildcard $(SOURCE_PATH) )" "" ifneq "$(wildcard $(SOURCE_PATH) )" ""
## Files wich should be checked for license headers ## Files wich should be checked for license headers
LICENSE_FILE_PATTERN ?= $(shell find $(SOURCE_PATH) -type f \( -iname \*.go -o -iname \*.php -o -iname \*.js -o -iname \*.mjs -o -iname \*.cjs \) ) LICENSE_FILE_PATTERN ?= $(shell find $(SOURCE_PATH) -type f \( -iname \*.go -o -iname \*.php -o -iname \*.js -o -iname \*.mjs -o -iname \*.cjs \) )
......
...@@ -18,14 +18,20 @@ To check out docs and examples, visit .... ...@@ -18,14 +18,20 @@ To check out docs and examples, visit ....
## Installation ## Installation
If you want to install the latest version of this tool, you can use the following command:
```shell ```shell
go get $(shell git config --get remote.origin.url | sed -E 's/^\s*.*:\/\///g') wget -O ./$(COMPONENT_SLUG) http://download.schukai.com/tools/$(COMPONENT_SLUG)/$(COMPONENT_SLUG)-$$( uname -s | tr [:upper:] [:lower:])-$$(echo uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
``` ```
**Note:** This library uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
## Usage ## Usage
The following command will show you the help of the tool:
```shell
$(COMPONENT_SLUG) help
```
## Contributing ## Contributing
Merge requests are welcome. For major changes, please open an issue first to discuss what Merge requests are welcome. For major changes, please open an issue first to discuss what
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment