js-mvc-framework
Advanced tools
Comparing version 1.2.13 to 1.2.14
@@ -36,19 +36,37 @@ import { Control } from '/dependencies/mvc-framework.js' | ||
}, | ||
routers: { | ||
location: { | ||
default: { | ||
hashpath: true, | ||
routes: { | ||
"": { | ||
"name": "Index Alias", | ||
"class": "Index", | ||
}, | ||
"/": { | ||
"name": "Index", | ||
"class": "Index", | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
events: {}, | ||
}, { | ||
defineProperties: { | ||
start: { value: function () { | ||
console.log(this.models.default.parse()) | ||
this.views.default.render(this.models.default.parse(), 'default') | ||
console.log(this.views.default.querySelectors) | ||
const controlViewParent = this.views.default.querySelectors['static-cms'] | ||
// Inspector | ||
// console.log(InspectorControl(...InspectorControl(controlViewParent))) | ||
this.controls.inspector = new Control(...InspectorControl(controlViewParent)).start() | ||
// this.controls.https = HTTPSControl(controlViewParent) | ||
// this.controls.browserSync = BrowserSyncControl(controlViewParent) | ||
// this.controls.express = ExpressControl(controlViewParent) | ||
// this.controls.routes = RoutesControl(controlViewParent) | ||
return this | ||
// console.log(this.models.default.parse()) | ||
// this.views.default.render(this.models.default.parse(), 'default') | ||
// console.log(this.views.default.querySelectors) | ||
// const controlViewParent = this.views.default.querySelectors['static-cms'] | ||
// // Inspector | ||
// // console.log(InspectorControl(...InspectorControl(controlViewParent))) | ||
// this.controls.inspector = new Control(...InspectorControl(controlViewParent)).start() | ||
// // this.controls.https = HTTPSControl(controlViewParent) | ||
// // this.controls.browserSync = BrowserSyncControl(controlViewParent) | ||
// // this.controls.express = ExpressControl(controlViewParent) | ||
// // this.controls.routes = RoutesControl(controlViewParent) | ||
// return this | ||
} } | ||
} | ||
}] |
@@ -1,68 +0,11 @@ | ||
import { LocationRouter } from '/dependencies/mvc-framework.js' | ||
const locationRouter = new LocationRouter({ | ||
hashpath: true, | ||
routes: { | ||
'/': { | ||
name: "Static CMS", | ||
enable: true, | ||
}, | ||
"/subpage": { | ||
name: "Static CMS Subpage", | ||
enable: true, | ||
}, | ||
"/subpage/:subpageID": { | ||
name: "Static CMS Subpage", | ||
enable: true, | ||
}, | ||
}, | ||
events: { | ||
'route': ($event) => { console.log($event.type, $event) } | ||
} | ||
}) | ||
console.log(locationRouter) | ||
/* | ||
const locationRouter = new LocationRouter({ | ||
routes: { | ||
"/": { | ||
name: "Index" | ||
routes: { | ||
"/static-cms": { | ||
name: "Static CMS", | ||
routes: { | ||
"/subpage": { | ||
name: "Static CMS Subpage", | ||
routes: { | ||
":subpageID": { | ||
name: "Static CMS Subpage" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
*/ | ||
/* | ||
$routeSettings { | ||
name: String | ||
basename: String | ||
enable: Boolean | ||
} | ||
$route { | ||
[$basename]: $routeSettings | ||
} | ||
$router { | ||
routes: { $route } | ||
} | ||
*/ | ||
/* | ||
import { Control } from '/dependencies/mvc-framework.js' | ||
import ControlParameters from './control.js' | ||
const control = new Control(...ControlParameters) | ||
console.log(control) | ||
/* | ||
document.addEventListener('DOMContentLoaded', ($event) => { | ||
const control = new Control(...ControlParameters) | ||
control.start() | ||
}, { once: true }) | ||
*/ |
@@ -94,3 +94,3 @@ import { typeOf, expandEvents } from '../Coutil/index.js' | ||
) { | ||
this[$className][$routerClassName][$routerClassInstanceName] = $routerClassInstance | ||
routers[$routerClassName][$routerClassInstanceName] = $routerClassInstance | ||
} | ||
@@ -105,5 +105,8 @@ else { | ||
let routerParameters | ||
if(typeOf($routerClassInstance) === 'object') { routerParameters = [$routerClassInstance] } | ||
else if(typeOf($router) === 'array') { routerParameters = [...$routerClassInstance] } | ||
this[$className][$routerClassName][$routerClassInstanceName] = new Router(routerParameters) | ||
if(typeOf($routerClassInstance) === 'object') { | ||
routers[$routerClassName][$routerClassInstanceName] = new Router($routerClassInstance) | ||
} | ||
else if(typeOf($router) === 'array') { | ||
routers[$routerClassName][$routerClassInstanceName] = new Router(...$routerClassInstance) | ||
} | ||
} | ||
@@ -110,0 +113,0 @@ } |
@@ -21,3 +21,3 @@ import { impandEvents, expandEvents, recursiveAssign } from '../Coutil/index.js' | ||
$settings.events = expandEvents($settings.events) | ||
this.#_settings = recursiveAssign({}, Settings, $settings) | ||
this.#_settings = recursiveAssign(structuredClone(Settings), $settings) | ||
} | ||
@@ -27,3 +27,3 @@ get options() { return this.#_options } | ||
if(this.#_options !== undefined) return | ||
this.#_options = recursiveAssign({}, Options, $options) | ||
this.#_options = recursiveAssign(structuredClone(Options), $options) | ||
} | ||
@@ -107,20 +107,18 @@ get events() { | ||
#assign() { | ||
if(Object.keys(this.options.assign).length === 0) return this | ||
for(const [ | ||
$propertyName, $propertyValue | ||
] of Object.entries(this.options.assign)) { | ||
if(typeof $propertyValue === 'function') { | ||
// $propertyValue = $propertyValue.bind(this) | ||
} | ||
Object.assign(this, { [$propertyName]: $propertyValue }) | ||
} | ||
return this | ||
} | ||
#defineProperties() { | ||
if(Object.keys(this.options.defineProperties).length === 0) return this | ||
for(const [ | ||
$propertyName, $propertyDescriptor | ||
] of Object.entries(this.options.defineProperties)) { | ||
if(typeof $propertyDescriptor.value === 'function') { | ||
// $propertyDescriptor.value = $propertyDescriptor.value.bind(this) | ||
} | ||
Object.defineProperty(this, $propertyName, $propertyDescriptor) | ||
} | ||
return this | ||
} | ||
@@ -127,0 +125,0 @@ #toggleEventAbility($eventListenerMethod, $events) { |
@@ -185,3 +185,2 @@ import { recursiveAssign } from '../../Coutil/index.js' | ||
const route = this.matchRoute(path) | ||
console.log('route', route) | ||
if(route && route?.enable) { | ||
@@ -220,3 +219,2 @@ route.active = true | ||
const routeSettings = recursiveAssign({ | ||
window: this.window, | ||
basename: $routePath, | ||
@@ -223,0 +221,0 @@ }, $routeSettings) |
@@ -15,3 +15,6 @@ import { match } from '../../../node_modules/path-to-regexp/dist/index.js' | ||
if(this.#_enable !== undefined) return this.#_enable | ||
this.#_enable = this.#settings.enable | ||
if(this.#settings.enable !== undefined) { | ||
this.#_enable = this.#settings.enable | ||
} | ||
else { this.#_enable = true } | ||
return this.#_enable | ||
@@ -18,0 +21,0 @@ } |
@@ -21,1 +21,36 @@ # Window Router | ||
``` | ||
``` | ||
import { LocationRouter } from '/dependencies/mvc-framework.js' | ||
const locationRouter = new LocationRouter({ | ||
hashpath: true, | ||
routes: { | ||
'/': { | ||
name: "Static CMS", | ||
enable: true, | ||
}, | ||
"/subpage": { | ||
name: "Static CMS Subpage", | ||
enable: true, | ||
}, | ||
"/subpage/:subpageID": { | ||
name: "Static CMS Subpage", | ||
enable: true, | ||
}, | ||
}, | ||
events: { | ||
'route': ($event) => { console.log($event.type, $event) } | ||
} | ||
}) | ||
$routeSettings { | ||
name: String | ||
basename: String | ||
enable: Boolean | ||
} | ||
$route { | ||
[$basename]: $routeSettings | ||
} | ||
$router { | ||
routes: { $route } | ||
} | ||
``` |
{ | ||
"name": "js-mvc-framework", | ||
"author": "Thomas Patrick Welborn", | ||
"version": "1.2.13", | ||
"version": "1.2.14", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "scripts": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1627135
12221