@rws-framework/client 2.3.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/rws.webpack.config.js +4 -3
- package/src/client.ts +0 -2
- package/src/components/_component.ts +14 -13
- package/src/components/_decorator.ts +25 -72
- package/src/components/_decorators/RWSFillBuild.ts +3 -3
- package/src/components/_decorators/RWSInject.ts +50 -0
- package/src/components/_decorators/RWSService.ts +12 -0
- package/src/components/_decorators/_di.ts +15 -0
- package/src/components/router/component.ts +14 -6
- package/src/components/router/template.html +0 -0
- package/src/index.ts +1 -1
- package/src/services/ConfigService.ts +2 -1
- package/_rws_build_configurator.d.ts +0 -14
- package/_rws_build_configurator.js +0 -48
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rws-framework/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs": "typedoc --tsconfig ./tsconfig.json"
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/papablack/rws-client#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@rws-framework/console": "^0.2.0",
|
|
29
30
|
"@microsoft/fast-element": "^1.12.0",
|
|
30
31
|
"@microsoft/fast-foundation": "^2.46.2",
|
|
31
32
|
"@types/moment": "^2.13.0",
|
package/rws.webpack.config.js
CHANGED
|
@@ -7,7 +7,8 @@ const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPl
|
|
|
7
7
|
|
|
8
8
|
const RWSAfterPlugin = require('./webpack/rws_after_plugin');
|
|
9
9
|
const tools = require('./_tools');
|
|
10
|
-
const
|
|
10
|
+
const { _DEFAULT_CONFIG } = require('./cfg/_default.cfg');
|
|
11
|
+
const RWSConfigBuilder = require('@rws-framework/console').RWSConfigBuilder;
|
|
11
12
|
|
|
12
13
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
13
14
|
const HtmlMinifier = require('html-minifier').minify;
|
|
@@ -20,6 +21,8 @@ const json5 = require('json5');
|
|
|
20
21
|
const RWSWebpackWrapper = (config) => {
|
|
21
22
|
const executionDir = config.executionDir || process.cwd();
|
|
22
23
|
|
|
24
|
+
const BuildConfigurator = new RWSConfigBuilder(executionDir + '/.rws.json', _DEFAULT_CONFIG);
|
|
25
|
+
|
|
23
26
|
const isDev = BuildConfigurator.get('dev') || config.dev;
|
|
24
27
|
const isHotReload = BuildConfigurator.get('hot') || config.hot;
|
|
25
28
|
const isReport = BuildConfigurator.get('report') || config.report;
|
|
@@ -46,8 +49,6 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
|
|
|
46
49
|
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/)
|
|
47
50
|
];
|
|
48
51
|
|
|
49
|
-
console.log('PARTED', isParted);
|
|
50
|
-
|
|
51
52
|
// if(isParted){
|
|
52
53
|
// WEBPACK_PLUGINS.push(new webpack.BannerPlugin({
|
|
53
54
|
// banner: `if(!window.RWS_PARTS_LOADED){
|
package/src/client.ts
CHANGED
|
@@ -272,7 +272,6 @@ class RWSClient {
|
|
|
272
272
|
|
|
273
273
|
static defineAllComponents() {
|
|
274
274
|
const richWindowComponents: RWSWindowComponentRegister = (window as Window & RWSWindow).RWS.components;
|
|
275
|
-
console.log('defining', richWindowComponents)
|
|
276
275
|
|
|
277
276
|
Object.keys(richWindowComponents).map(key => richWindowComponents[key].component).forEach((el: IWithCompose<RWSViewComponent>) => {
|
|
278
277
|
el.define(el as any, el.definition);
|
|
@@ -282,7 +281,6 @@ class RWSClient {
|
|
|
282
281
|
|
|
283
282
|
defineComponents(){
|
|
284
283
|
const richWindowComponents: RWSWindowComponentRegister = (window as Window & RWSWindow).RWS.components;
|
|
285
|
-
console.log('defining', richWindowComponents)
|
|
286
284
|
|
|
287
285
|
Object.keys(richWindowComponents).map(key => richWindowComponents[key].component).forEach((el: IWithCompose<RWSViewComponent>) => {
|
|
288
286
|
el.define(el as any, el.definition);
|
|
@@ -5,11 +5,10 @@ import UtilsService, { UtilsServiceInstance } from '../services/UtilsService';
|
|
|
5
5
|
import DOMService, { DOMServiceInstance, DOMOutputType } from '../services/DOMService';
|
|
6
6
|
import ApiService, { ApiServiceInstance } from '../services/ApiService';
|
|
7
7
|
import NotifyService, { NotifyServiceInstance } from '../services/NotifyService';
|
|
8
|
-
import RoutingService, { RoutingServiceInstance } from '../services/RoutingService';
|
|
9
8
|
import WSService, { WSServiceInstance } from '../services/WSService';
|
|
10
9
|
import { IRWSViewComponent, IAssetShowOptions } from '../interfaces/IRWSViewComponent';
|
|
11
10
|
import RWSWindow, { RWSWindowComponentInterface, loadRWSRichWindow } from '../interfaces/RWSWindow';
|
|
12
|
-
import {
|
|
11
|
+
import { applyConstructor, RWSInject } from './_decorator';
|
|
13
12
|
|
|
14
13
|
import 'reflect-metadata';
|
|
15
14
|
|
|
@@ -34,6 +33,7 @@ export interface IWithCompose<T extends RWSViewComponent> {
|
|
|
34
33
|
define<TType extends (...params: any[]) => any>(type: TType, nameOrDef?: string | PartialFASTElementDefinition | undefined): TType;
|
|
35
34
|
_verbose: boolean;
|
|
36
35
|
_toInject: {[key: string]: any};
|
|
36
|
+
_depKeys: {[key: string]: string[]};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
abstract class RWSViewComponent extends FoundationElement implements IRWSViewComponent {
|
|
@@ -46,28 +46,29 @@ abstract class RWSViewComponent extends FoundationElement implements IRWSViewCom
|
|
|
46
46
|
static autoLoadFastElement = true;
|
|
47
47
|
static _defined: { [key: string]: boolean } = {};
|
|
48
48
|
static _toInject: any[] = [];
|
|
49
|
+
static _depKeys: {[key: string]: string[]} = {_all: []};
|
|
49
50
|
static _verbose: boolean = false;
|
|
50
51
|
|
|
52
|
+
@RWSInject(ConfigService, true) protected config: ConfigServiceInstance;
|
|
53
|
+
@RWSInject(DOMService, true) protected domService: DOMServiceInstance;
|
|
54
|
+
@RWSInject(UtilsService, true) protected utilsService: UtilsServiceInstance;
|
|
55
|
+
@RWSInject(ApiService, true) protected apiService: ApiServiceInstance;
|
|
56
|
+
@RWSInject(WSService, true) protected wsService: WSServiceInstance;
|
|
57
|
+
@RWSInject(NotifyService, true) protected notifyService: NotifyServiceInstance;
|
|
58
|
+
|
|
51
59
|
@observable trashIterator: number = 0;
|
|
52
60
|
@observable fileAssets: {
|
|
53
61
|
[key: string]: ViewTemplate
|
|
54
62
|
} = {};
|
|
55
63
|
|
|
56
|
-
constructor(
|
|
57
|
-
@RWSInject(ConfigService) protected config: ConfigServiceInstance,
|
|
58
|
-
@RWSInject(RoutingService) protected routingService: RoutingServiceInstance,
|
|
59
|
-
@RWSInject(DOMService) protected domService: DOMServiceInstance,
|
|
60
|
-
@RWSInject(UtilsService) protected utilsService: UtilsServiceInstance,
|
|
61
|
-
@RWSInject(ApiService) protected apiService: ApiServiceInstance,
|
|
62
|
-
@RWSInject(WSService) protected wsService: WSServiceInstance,
|
|
63
|
-
@RWSInject(NotifyService) protected notifyService: NotifyServiceInstance
|
|
64
|
-
) {
|
|
64
|
+
constructor() {
|
|
65
65
|
super();
|
|
66
|
-
applyConstructor(this);
|
|
66
|
+
applyConstructor(this);
|
|
67
|
+
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
connectedCallback() {
|
|
70
|
-
super.connectedCallback();
|
|
71
|
+
super.connectedCallback();
|
|
71
72
|
applyConstructor(this);
|
|
72
73
|
|
|
73
74
|
// console.trace(this.config);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Key } from '@microsoft/fast-foundation';
|
|
2
1
|
import RWSViewComponent, { IWithCompose } from './_component';
|
|
3
|
-
import
|
|
2
|
+
import { RWSInject } from './_decorators/RWSInject';
|
|
3
|
+
|
|
4
4
|
import 'reflect-metadata';
|
|
5
5
|
|
|
6
6
|
interface RWSDecoratorOptions {
|
|
@@ -10,18 +10,8 @@ interface RWSDecoratorOptions {
|
|
|
10
10
|
ignorePackaging?: boolean
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
type InjectDecoratorReturnType = (target: any, key?: string | number | undefined, parameterIndex?: number) => void;
|
|
14
|
-
|
|
15
13
|
//const _PARAMTYPES_METADATA_KEY = 'design:paramtypes';
|
|
16
14
|
|
|
17
|
-
function RWSInject<T extends RWSViewComponent>(dependencyClass: Key): InjectDecoratorReturnType {
|
|
18
|
-
return (target: IWithCompose<T>, key?: keyof IWithCompose<T>, parameterIndex?: number) => {
|
|
19
|
-
const loadedDependency = RWSContainer().get(dependencyClass);
|
|
20
|
-
const paramNames = getFunctionParamNames(target.prototype.constructor);
|
|
21
|
-
target.prototype.constructor._toInject[paramNames[parameterIndex]] = loadedDependency;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
15
|
function RWSView<T extends RWSViewComponent>(name: string, data?: RWSDecoratorOptions): (type: any) => void {
|
|
26
16
|
return (constructor: T) => {
|
|
27
17
|
};
|
|
@@ -31,15 +21,7 @@ function RWSIgnore(params: { mergeToApp?: boolean } = null): () => void {
|
|
|
31
21
|
return () => { };
|
|
32
22
|
}
|
|
33
23
|
|
|
34
|
-
function
|
|
35
|
-
// Convert the function to its string form and extract the parameter names
|
|
36
|
-
const funcStr = func.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/mg, '');
|
|
37
|
-
return funcStr.slice(funcStr.indexOf('(')+1, funcStr.indexOf(')')).split(',');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function getParentConstructor(instance: any): any
|
|
42
|
-
{
|
|
24
|
+
function getParentConstructor(instance: any): any {
|
|
43
25
|
const proto = Object.getPrototypeOf(instance.constructor.prototype);
|
|
44
26
|
if (proto && proto.constructor) {
|
|
45
27
|
return proto.constructor;
|
|
@@ -48,63 +30,34 @@ function getParentConstructor(instance: any): any
|
|
|
48
30
|
return null;
|
|
49
31
|
}
|
|
50
32
|
|
|
51
|
-
const applyConstructor = (component: RWSViewComponent): void => {
|
|
52
|
-
|
|
33
|
+
const applyConstructor = (component: RWSViewComponent, x: boolean = false): void => {
|
|
34
|
+
const mainConstructor: any = component.constructor;
|
|
53
35
|
const parent = getParentConstructor(component);
|
|
54
36
|
|
|
55
|
-
if(
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let topConstructor = mainConstructor;
|
|
37
|
+
if (parent.name !== 'RWSViewComponent' ) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
60
40
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const existingInjectedDependencies = (topConstructor as IWithCompose<RWSViewComponent>)._toInject;
|
|
66
|
-
Object.keys(existingInjectedDependencies).forEach((depKey: string) => {
|
|
67
|
-
|
|
68
|
-
const loadedDependency = existingInjectedDependencies[depKey];
|
|
69
|
-
if(!(component as any)[depKey]){
|
|
70
|
-
(component as any)[depKey] = loadedDependency;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
};
|
|
41
|
+
const existingInjectedDependencies = (mainConstructor as IWithCompose<RWSViewComponent>)._toInject;
|
|
42
|
+
const defaultDeps = (mainConstructor as IWithCompose<RWSViewComponent>)._depKeys['_all'] || [];
|
|
43
|
+
const depsToInject = (mainConstructor as IWithCompose<RWSViewComponent>)._depKeys[mainConstructor.name] || [];
|
|
74
44
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
mainConstructor = parent;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let topConstructor = mainConstructor;
|
|
84
|
-
|
|
85
|
-
if( parent && parent.name === RWSViewComponent.name){
|
|
86
|
-
topConstructor = parent;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if(typeof propName !== 'string'){
|
|
90
|
-
propName = propName.toString();
|
|
45
|
+
if (x) {
|
|
46
|
+
console.log({
|
|
47
|
+
mainConstructor: mainConstructor.name,
|
|
48
|
+
deps: existingInjectedDependencies
|
|
49
|
+
});
|
|
91
50
|
}
|
|
92
|
-
|
|
93
|
-
const existingInjectedDependencies = (topConstructor as IWithCompose<RWSViewComponent>)._toInject;
|
|
94
51
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const loadedDependency = existingInjectedDependencies[propName];
|
|
52
|
+
Object.keys(existingInjectedDependencies).forEach((depKey: string) => {
|
|
53
|
+
// console.log(`Checking "${mainConstructor.name}" for "${depKey}"`, [...defaultDeps, ...depsToInject]);
|
|
101
54
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
55
|
+
if ([...defaultDeps, ...depsToInject].includes(depKey)) {
|
|
56
|
+
const loadedDependency = existingInjectedDependencies[depKey];
|
|
57
|
+
(component as any)[depKey] = loadedDependency;
|
|
58
|
+
console.log(`Assigned service to "${mainConstructor.name}(${depKey})":`, loadedDependency);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
108
61
|
};
|
|
109
62
|
|
|
110
|
-
export { RWSView, RWSDecoratorOptions, RWSIgnore, RWSInject, applyConstructor
|
|
63
|
+
export { RWSView, RWSDecoratorOptions, RWSIgnore, RWSInject, applyConstructor };
|
|
@@ -27,7 +27,7 @@ function extractEnvVar(envVar: string){
|
|
|
27
27
|
return {
|
|
28
28
|
extractedVars,
|
|
29
29
|
extractedFrontendVars
|
|
30
|
-
}
|
|
30
|
+
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function RWSFillBuild(config: Partial<IRWSConfig> = {}) {
|
|
@@ -45,7 +45,7 @@ function RWSFillBuild(config: Partial<IRWSConfig> = {}) {
|
|
|
45
45
|
...extractedFrontendDefaults
|
|
46
46
|
} as IRWSConfig;
|
|
47
47
|
|
|
48
|
-
const extractedFrontendBuildVars = extractEnvVar(process.env._RWS_BUILD_OVERRIDE).extractedFrontendVars
|
|
48
|
+
const extractedFrontendBuildVars = extractEnvVar(process.env._RWS_BUILD_OVERRIDE).extractedFrontendVars;
|
|
49
49
|
|
|
50
50
|
this._BUILD_OVERRIDE = extractedFrontendBuildVars as IRWSConfig;
|
|
51
51
|
}
|
|
@@ -53,4 +53,4 @@ function RWSFillBuild(config: Partial<IRWSConfig> = {}) {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
export { RWSFillBuild }
|
|
56
|
+
export { RWSFillBuild };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Key } from '@microsoft/fast-foundation';
|
|
2
|
+
import RWSViewComponent, { IWithCompose } from '../_component';
|
|
3
|
+
import { loadDep, getFunctionParamNames } from './_di';
|
|
4
|
+
import TheRWSService from '../../services/_service';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
type InjectDecoratorReturnType = (target: any, key?: string | number | undefined, parameterIndex?: number) => void;
|
|
8
|
+
type TargetType = any;
|
|
9
|
+
|
|
10
|
+
function addToComponentInjection(targetComponentName: string, constructor: any, depKey: string, dependencyClass: Key, isDefaultService: boolean = false){
|
|
11
|
+
|
|
12
|
+
if(isDefaultService){
|
|
13
|
+
targetComponentName = '_all';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if(!Object.keys(constructor._depKeys).includes(targetComponentName)){
|
|
17
|
+
constructor._depKeys = { [targetComponentName]: [] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if(!constructor._depKeys[targetComponentName].includes(depKey)){
|
|
21
|
+
constructor._depKeys[targetComponentName].push(depKey);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if(!Object.keys(constructor._toInject).includes(depKey)){
|
|
25
|
+
const loadedDependency = loadDep<TheRWSService>(dependencyClass);
|
|
26
|
+
constructor._toInject[depKey] = loadedDependency;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
console.log(targetComponentName);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function RWSInject<T extends RWSViewComponent>(dependencyClass: Key, defaultService: boolean = false): InjectDecoratorReturnType {
|
|
33
|
+
return (target: IWithCompose<T>, key?: keyof IWithCompose<T>, parameterIndex?: number) => {
|
|
34
|
+
if(key){
|
|
35
|
+
const targetConstructor = typeof target === 'function' ? target : (target as any).constructor;
|
|
36
|
+
console.log('propt', target.name);
|
|
37
|
+
addToComponentInjection(target.name, targetConstructor, key as string, dependencyClass, defaultService);
|
|
38
|
+
} else{
|
|
39
|
+
const targetConstructor = (target as any).prototype.constructor;
|
|
40
|
+
const paramNames = getFunctionParamNames(targetConstructor);
|
|
41
|
+
const depKey = paramNames[parameterIndex];
|
|
42
|
+
|
|
43
|
+
addToComponentInjection(target.name, targetConstructor, depKey, dependencyClass, defaultService);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
RWSInject
|
|
50
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import RWSViewComponent from '../_component';
|
|
2
|
+
|
|
3
|
+
interface RWSServiceDecoratorOptions {
|
|
4
|
+
_vars?: any
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function RWSService<T extends RWSViewComponent>(options?: RWSServiceDecoratorOptions): (type: any) => void {
|
|
8
|
+
return (constructor: T) => {
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { RWSService };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Key } from '@microsoft/fast-foundation';
|
|
2
|
+
import RWSContainer from '../_container';
|
|
3
|
+
|
|
4
|
+
function getFunctionParamNames(func: () => any): string[] {
|
|
5
|
+
// Convert the function to its string form and extract the parameter names
|
|
6
|
+
const funcStr = func.toString().replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s))/mg, '');
|
|
7
|
+
return funcStr.slice(funcStr.indexOf('(')+1, funcStr.indexOf(')')).split(',');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function loadDep<T>(dependencyKeyClass: Key): T
|
|
11
|
+
{
|
|
12
|
+
return RWSContainer().get(dependencyKeyClass) as T;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { loadDep, getFunctionParamNames };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { observable } from '@microsoft/fast-element';
|
|
2
|
-
import { RWSRouter, _ROUTING_EVENT_NAME, RouteReturn } from '../../services/RoutingService';
|
|
2
|
+
import RoutingService, { RWSRouter, _ROUTING_EVENT_NAME, RouteReturn, RoutingServiceInstance } from '../../services/RoutingService';
|
|
3
3
|
import RWSViewComponent, { IRWSViewComponent } from '../_component';
|
|
4
|
-
import {RWSView} from '../_decorator';
|
|
4
|
+
import {RWSInject, RWSView} from '../_decorator';
|
|
5
5
|
|
|
6
6
|
@RWSView('rws-router')
|
|
7
7
|
export class RouterComponent extends RWSViewComponent {
|
|
@@ -13,20 +13,28 @@ export class RouterComponent extends RWSViewComponent {
|
|
|
13
13
|
@observable childComponents: HTMLElement[] = [];
|
|
14
14
|
slotEl: HTMLElement = null;
|
|
15
15
|
|
|
16
|
+
constructor(@RWSInject(RoutingService) protected routingService: RoutingServiceInstance){
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
16
20
|
connectedCallback() {
|
|
17
21
|
super.connectedCallback();
|
|
18
|
-
|
|
19
|
-
|
|
20
22
|
|
|
23
|
+
|
|
21
24
|
this.routing = this.routingService.apply(this);
|
|
22
|
-
|
|
25
|
+
|
|
23
26
|
if(this.currentUrl){
|
|
24
27
|
this.handleRoute(this.routing.handleRoute(this.currentUrl));
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
currentUrlChanged(oldValue: string, newValue: string){
|
|
29
|
-
if(newValue){
|
|
32
|
+
if(newValue){
|
|
33
|
+
if(!this.routingService){
|
|
34
|
+
console.log(oldValue, newValue);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
if(!this.routing){
|
|
31
39
|
this.routing = this.routingService.apply(this);
|
|
32
40
|
|
|
File without changes
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from './services/RoutingService';
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
import { RWSDecoratorOptions, RWSIgnore,
|
|
30
|
+
import { RWSDecoratorOptions, RWSIgnore, RWSInject, RWSView } from './components/_decorator';
|
|
31
31
|
|
|
32
32
|
import { declareRWSComponents } from './components';
|
|
33
33
|
|
|
@@ -24,7 +24,7 @@ class ConfigService extends TheService {
|
|
|
24
24
|
{
|
|
25
25
|
|
|
26
26
|
if(!this._DEFAULTS){
|
|
27
|
-
throw new Error('No _DEFAULTS loaded!')
|
|
27
|
+
throw new Error('No _DEFAULTS loaded!');
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
@@ -46,6 +46,7 @@ class ConfigService extends TheService {
|
|
|
46
46
|
if(defaultVal && defaultVal[0] === '@'){
|
|
47
47
|
defaultVal = this.data[((defaultVal as string).slice(1)) as keyof IRWSConfig];
|
|
48
48
|
}
|
|
49
|
+
|
|
49
50
|
return defaultVal;
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
declare const _DEFAULT_CONFIG: any;
|
|
2
|
-
|
|
3
|
-
declare function readConfigFile(filePath: string): any;
|
|
4
|
-
declare function get(key: string): any;
|
|
5
|
-
declare function exportDefaultConfig(): any;
|
|
6
|
-
declare function exportBuildConfig(): any;
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
readConfigFile,
|
|
10
|
-
get,
|
|
11
|
-
exportDefaultConfig,
|
|
12
|
-
exportBuildConfig,
|
|
13
|
-
_DEFAULT_CONFIG
|
|
14
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const json5 = require('json5');
|
|
3
|
-
|
|
4
|
-
const _DEFAULT_CONFIG = require('./cfg/_default.cfg')._DEFAULT_CONFIG;
|
|
5
|
-
const STORAGE = require('./cfg/_storage');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function readConfigFile(filePath){
|
|
9
|
-
if(!fs.existsSync(filePath)){
|
|
10
|
-
return _DEFAULT_CONFIG;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const fileConfig = json5.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
...fileConfig
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function get(key){
|
|
21
|
-
_init();
|
|
22
|
-
|
|
23
|
-
return STORAGE.get(key);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function exportDefaultConfig(){
|
|
27
|
-
return _DEFAULT_CONFIG;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function exportBuildConfig(){
|
|
31
|
-
_init();
|
|
32
|
-
|
|
33
|
-
return STORAGE.getAll();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function _init(){
|
|
37
|
-
if(!STORAGE.isLoaded()){
|
|
38
|
-
STORAGE.init(readConfigFile(process.cwd() + '/.rws.json'))
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = {
|
|
43
|
-
readConfigFile,
|
|
44
|
-
exportDefaultConfig,
|
|
45
|
-
exportBuildConfig,
|
|
46
|
-
get,
|
|
47
|
-
_DEFAULT_CONFIG
|
|
48
|
-
};
|