Browse Source

FEAT,REFA: externalized extension base class

For reusability in the setup of jpclw extensions
dev-feat-component_preview
chris 2 months ago
parent
commit
d361a1bbee
  1. 3
      package-lock.json
  2. 3
      package.json
  3. 78
      src/extensions/extension.js

3
package-lock.json

@ -8,6 +8,9 @@
"name": "jpc-like-websites", "name": "jpc-like-websites",
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": {
"jpclw-extension": "git+https://git.labos.goip.de/chris/jpclw-extension.git"
},
"devDependencies": { "devDependencies": {
} }

3
package.json

@ -18,4 +18,7 @@
}, },
"author": "cm", "author": "cm",
"license": "ISC" "license": "ISC"
"dependencies": {
"jpclw-extension": "git+https://git.labos.goip.de/chris/jpclw-extension.git"
}
} }

78
src/extensions/extension.js

@ -1,78 +0,0 @@
/**
* Defines an extension that can be added to the jpclw-framework
*/
class CompelExtension {
/**
* @type {string}
*/
name;
/**
* @type {string}
*/
diplayTitle;
/**
* @type {Array<SStoreDefinition>}
*/
stylings;
/**
* @type {Array<SStoreDefinition>}
*/
functions;
/**
* Predefined components. Usually of a higher (constructed) kind.
* @type {Object}
*/
components;
/**
* Extensions for/to the Page or the framework in general.
* @type {Object}
*/
frameworkControls;
/**
* Additional elements for the builder (likely referencing components)
* @type {Object}
*/
builderElements;
/**
* Additional helper functions
* @type {{*:Function}}
*/
helperFun;
/**
* functions that are supposed to be executed after install,
* to extend it that way.
* @type {Array<Function>}
*/
funAfterInstall
/**
* defines how jpc-like-websites is to be extended and executes that extension
*/
install() {
if (this.helperFun) {
helperFun.extensions = Object.assign(helperFun.extensions, this.helperFun);
}
if (this.builderElements) {
builder.extensions = Object.assign(builder.extensions, this.builderElements);
}
if (this.frameworkControls) {
Page.extensions = Object.assign(Page.extensions, this.frameworkControls);
}
if (this.stylings) {
for (const key of Object.keys(this.stylings)) {
Page.registerStyling(key, this.stylings[key]);
}
}
if (this.funAfterInstall) {
for (const fun of this.funAfterInstall) {
fun();
}
}
}
}
Loading…
Cancel
Save