|
@ -1,7 +1,17 @@ |
|
|
/** |
|
|
/** |
|
|
* This file is part of the jps-like-websites lib |
|
|
* This module defines the Component generator. |
|
|
* URL: https://git.labos.goip.de/chris/jpc-like-websites
|
|
|
* It externalizes all decision making about script or style storage from the component. |
|
|
* @copyright by its creator Christian Martin |
|
|
* The component stores the generator (if set, if not =default or passed down from parent component). |
|
|
|
|
|
* The CompelGenerator class enables the setup/definition of storage, generation and distribution. |
|
|
|
|
|
* |
|
|
|
|
|
* Further if other frameworks are targeted: |
|
|
|
|
|
* if the components should be generated in a manner |
|
|
|
|
|
* that they fullfill the setup/look of other framework-components. |
|
|
|
|
|
* Only the generator has to be modified, implemented, extended ... |
|
|
|
|
|
* not the component, modifier or any other of the classes. |
|
|
|
|
|
* |
|
|
|
|
|
* Therefore the usages of CompelGenerator-feature-logic resets all style and script storages to local. |
|
|
|
|
|
* Only towards the end (when "generate()" is called) any of that will be resolved. |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
class CompelGenerator { |
|
|
class CompelGenerator { |
|
@ -15,7 +25,7 @@ class CompelGenerator { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* |
|
|
* @param {Component} component |
|
|
* @param {ExtStorage} extStore |
|
|
* @param {ExtStorage} extStore |
|
|
* @returns {Array<SStoreDefinition>} |
|
|
* @returns {Array<SStoreDefinition>} |
|
|
*/ |
|
|
*/ |
|
@ -29,7 +39,7 @@ class CompelGenerator { |
|
|
let forCollection = []; |
|
|
let forCollection = []; |
|
|
|
|
|
|
|
|
let counter = 0; |
|
|
let counter = 0; |
|
|
for (const ssd of this._styles) { |
|
|
for (const ssd of component._styles) { |
|
|
/* Make sure that the type is unified for later processing */ |
|
|
/* Make sure that the type is unified for later processing */ |
|
|
if (ssd._definition instanceof Modifier) { |
|
|
if (ssd._definition instanceof Modifier) { |
|
|
ssd._definition = ssd._definition._modifications; |
|
|
ssd._definition = ssd._definition._modifications; |
|
@ -119,7 +129,7 @@ class CompelGenerator { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
* @param {Comment} component |
|
|
* @param {Component} component |
|
|
* @returns {Array<WebTrinity>} |
|
|
* @returns {Array<WebTrinity>} |
|
|
*/ |
|
|
*/ |
|
|
resolveChildren(component) { |
|
|
resolveChildren(component) { |
|
@ -128,19 +138,11 @@ class CompelGenerator { |
|
|
*/ |
|
|
*/ |
|
|
let wenities = []; |
|
|
let wenities = []; |
|
|
|
|
|
|
|
|
for (let i = 0; i < component._children.length; i++) { |
|
|
for (const child of component._children) { |
|
|
/** |
|
|
|
|
|
* @type {Component} |
|
|
|
|
|
*/ |
|
|
|
|
|
let child = component._children[i]; |
|
|
|
|
|
|
|
|
|
|
|
if (child instanceof ChainableModifier) { |
|
|
if (child instanceof ChainableModifier) { |
|
|
child = child.toComponent(); |
|
|
child = child.toComponent(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (Page._useCssCalc) { |
|
|
|
|
|
child._modifier._updateDimensionsBy(component._modifier._paddingValues); |
|
|
|
|
|
} |
|
|
|
|
|
child = child.generate(); |
|
|
child = child.generate(); |
|
|
|
|
|
|
|
|
let wenity = this.appendChildComponent(component, child); |
|
|
let wenity = this.appendChildComponent(component, child); |
|
@ -168,6 +170,10 @@ class CompelGenerator { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* |
|
|
* |
|
|
* @param {Component} component |
|
|
* @param {Component} component |
|
@ -176,6 +182,17 @@ class CompelGenerator { |
|
|
* @returns {WebTrinity} |
|
|
* @returns {WebTrinity} |
|
|
*/ |
|
|
*/ |
|
|
generate(component, styleStore = null, functionStore = null) { |
|
|
generate(component, styleStore = null, functionStore = null) { |
|
|
|
|
|
/** |
|
|
|
|
|
* check if component is chained child, |
|
|
|
|
|
* if so resolve chaining first. |
|
|
|
|
|
*/ |
|
|
|
|
|
if (component._parentComponent) { |
|
|
|
|
|
let parent = component._parentComponent; |
|
|
|
|
|
component._parentComponent = null; |
|
|
|
|
|
return parent.childContext(component) |
|
|
|
|
|
.generate(this) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* DEAL WITH COMPONENT MODIFICATION FIRST */ |
|
|
/* DEAL WITH COMPONENT MODIFICATION FIRST */ |
|
|
// @todo pay attention to the "overwrite" behaviour - the local modifier styles are the "closest"
|
|
|
// @todo pay attention to the "overwrite" behaviour - the local modifier styles are the "closest"
|
|
@ -204,8 +221,7 @@ class CompelGenerator { |
|
|
*/ |
|
|
*/ |
|
|
let funcCollections = this.processFunctions(functionStore); |
|
|
let funcCollections = this.processFunctions(functionStore); |
|
|
|
|
|
|
|
|
for (let i = 0; i < childrenWenities.length; i++) { |
|
|
for (const child of childrenWenities) { |
|
|
const child = childrenWenities[i]; |
|
|
|
|
|
if (child.js) { |
|
|
if (child.js) { |
|
|
executeOnExtStoreTypeCollectedTriple( |
|
|
executeOnExtStoreTypeCollectedTriple( |
|
|
(extstoretype) => transferCollectedFunctions(child.js, funcCollections, extstoretype) |
|
|
(extstoretype) => transferCollectedFunctions(child.js, funcCollections, extstoretype) |
|
|