@rws-framework/client 2.3.1 → 2.4.2

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.
Files changed (99) hide show
  1. package/.gitmodules +3 -0
  2. package/README.md +247 -168
  3. package/cfg/_default.cfg.js +1 -1
  4. package/console.js +1 -1
  5. package/docs/assets/highlight.css +24 -17
  6. package/docs/assets/icons.js +15 -0
  7. package/docs/assets/icons.svg +1 -0
  8. package/docs/assets/main.js +4 -4
  9. package/docs/assets/navigation.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/assets/style.css +5 -7
  12. package/docs/classes/ApiServiceInstance.html +22 -20
  13. package/docs/classes/ConfigServiceInstance.html +17 -0
  14. package/docs/classes/DOMServiceInstance.html +13 -10
  15. package/docs/classes/NotifyServiceInstance.html +12 -12
  16. package/docs/classes/RWSRouter.html +10 -9
  17. package/docs/classes/RWSService.html +7 -7
  18. package/docs/classes/RWSViewComponent.html +835 -24
  19. package/docs/classes/RoutingServiceInstance.html +14 -13
  20. package/docs/classes/ServiceWorkerServiceInstance.html +10 -0
  21. package/docs/classes/UtilsServiceInstance.html +12 -11
  22. package/docs/classes/WSServiceInstance.html +34 -32
  23. package/docs/functions/ApiService.html +1 -0
  24. package/docs/functions/ConfigService.html +1 -0
  25. package/docs/functions/DOMService.html +1 -0
  26. package/docs/functions/NotifyService.html +1 -0
  27. package/docs/functions/RWSContainer.html +1 -0
  28. package/docs/functions/RWSIgnore.html +1 -0
  29. package/docs/functions/RWSInject.html +1 -0
  30. package/docs/functions/RWSView.html +1 -1
  31. package/docs/functions/RoutingService.html +1 -0
  32. package/docs/functions/ServiceWorkerService.html +1 -0
  33. package/docs/functions/UtilsService.html +1 -0
  34. package/docs/functions/WSService.html +1 -0
  35. package/docs/functions/attr.html +6 -0
  36. package/docs/functions/declareRWSComponents.html +1 -0
  37. package/docs/functions/ngAttr.html +1 -1
  38. package/docs/functions/observable.html +4 -0
  39. package/docs/functions/provideRWSDesignSystem.html +1 -0
  40. package/docs/functions/realtimeWebSuiteClientPackage.html +1 -0
  41. package/docs/functions/renderRouteComponent.html +1 -1
  42. package/docs/functions/sanitizedAttr.html +1 -0
  43. package/docs/hierarchy.html +1 -1
  44. package/docs/index.html +141 -15
  45. package/docs/interfaces/HTMLAttributes.html +1 -0
  46. package/docs/interfaces/HTMLTag.html +4 -0
  47. package/docs/interfaces/IRWSConfig.html +19 -11
  48. package/docs/interfaces/IRWSDecoratorOptions.html +5 -4
  49. package/docs/interfaces/IRWSHttpRoute.html +3 -3
  50. package/docs/interfaces/IRWSPrefixedHTTProutes.html +3 -3
  51. package/docs/interfaces/IRWSUser.html +6 -0
  52. package/docs/interfaces/IRoutingEvent.html +3 -3
  53. package/docs/modules.html +53 -39
  54. package/docs/types/DOMOutputType.html +1 -1
  55. package/docs/types/HTMLTagTransformerType.html +1 -0
  56. package/docs/types/IRWSAssetShowOptions.html +1 -0
  57. package/docs/types/IRWSBackendRoute.html +1 -1
  58. package/docs/types/IRWSFrontRoutes.html +1 -1
  59. package/docs/types/IRWSRouteResult.html +1 -1
  60. package/docs/types/IRWSWebsocketStatus.html +1 -1
  61. package/docs/types/NotifyLogType.html +1 -1
  62. package/docs/types/NotifyUiType.html +1 -1
  63. package/docs/types/RWSNotify.html +1 -1
  64. package/docs/types/RouteReturn.html +1 -1
  65. package/docs/types/TagsProcessorType.html +1 -0
  66. package/docs/variables/_ROUTING_EVENT_NAME.html +1 -1
  67. package/docs-typings.d.ts +15 -0
  68. package/package.json +7 -3
  69. package/rws.webpack.config.js +4 -3
  70. package/{src/service_worker → service_worker}/src/_service_worker.ts +3 -3
  71. package/{src/service_worker → service_worker}/tsconfig.json +1 -1
  72. package/src/client.ts +0 -2
  73. package/src/components/_component.ts +14 -13
  74. package/src/components/_decorator.ts +20 -74
  75. package/src/components/_decorators/RWSFillBuild.ts +3 -3
  76. package/src/components/_decorators/RWSInject.ts +49 -0
  77. package/src/components/_decorators/RWSService.ts +12 -0
  78. package/src/components/_decorators/_di.ts +15 -0
  79. package/src/components/router/component.ts +14 -7
  80. package/src/components/router/template.html +0 -0
  81. package/src/index.ts +3 -6
  82. package/src/services/ConfigService.ts +2 -1
  83. package/tsconfig.json +7 -6
  84. package/tsdoc.json +0 -0
  85. package/typedoc.json +3 -3
  86. package/_rws_build_configurator.d.ts +0 -14
  87. package/_rws_build_configurator.js +0 -48
  88. package/docs/classes/RWSClient.html +0 -11
  89. package/docs/classes/RWSUploader.html +0 -35
  90. package/docs/classes/RouterComponent.html +0 -31
  91. package/docs/functions/registerRWSComponents.html +0 -1
  92. package/docs/interfaces/IRWSAssetShowOptions.html +0 -1
  93. package/docs/variables/ApiService.html +0 -1
  94. package/docs/variables/DOMService.html +0 -1
  95. package/docs/variables/NotifyService.html +0 -1
  96. package/docs/variables/RoutingService.html +0 -1
  97. package/docs/variables/UtilsService.html +0 -1
  98. package/docs/variables/WSService.html +0 -1
  99. /package/{src/service_worker → service_worker}/webpack.config.js +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.3.1",
4
+ "version": "2.4.2",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -28,6 +28,7 @@
28
28
  "dependencies": {
29
29
  "@microsoft/fast-element": "^1.12.0",
30
30
  "@microsoft/fast-foundation": "^2.46.2",
31
+ "@rws-framework/console": "^0.2.0",
31
32
  "@types/moment": "^2.13.0",
32
33
  "dragula": "^3.7.3",
33
34
  "he": "^1.2.0",
@@ -52,7 +53,8 @@
52
53
  "@open-wc/dev-server-hmr": "^0.1.2-next.0",
53
54
  "@types/dragula": "^3.7.4",
54
55
  "@types/express-fileupload": "^1.4.4",
55
- "@types/he": "^1.2.3",
56
+ "@types/glob": "^8.1.0",
57
+ "@types/he": "^1.2.3",
56
58
  "@types/json5": "^2.2.0",
57
59
  "@types/sanitize-html": "^2.11.0",
58
60
  "@types/socket.io-client": "^3.0.0",
@@ -66,9 +68,11 @@
66
68
  "eslint": "^8.57.0",
67
69
  "eslint-plugin-unused-imports": "^3.1.0",
68
70
  "file-loader": "^6.2.0",
71
+ "html-minifier": "^4.0.0",
69
72
  "html-webpack-plugin": "^5.5.3",
70
- "loader-utils": "^3.2.1",
73
+ "loader-utils": "^3.2.1",
71
74
  "mini-css-extract-plugin": "^2.7.6",
75
+ "minimatch": "^9.0.4",
72
76
  "node-sass": "^9.0.0",
73
77
  "sass-loader": "^13.3.2",
74
78
  "source-map": "^0.7.4",
@@ -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 BuildConfigurator = require('./_rws_build_configurator');
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){
@@ -1,8 +1,8 @@
1
- import IRWSUser from '../../interfaces/IRWSUser';
2
- import RWSContainer from '../../components/_container';
1
+ import IRWSUser from '../../src/interfaces/IRWSUser';
2
+ import RWSContainer from '../../src/components/_container';
3
3
 
4
4
  //@4DI
5
- import { WSServiceInstance } from '../../services/WSService';
5
+ import { WSServiceInstance } from '../../src/services/WSService';
6
6
  import { Container } from '@microsoft/fast-foundation';
7
7
 
8
8
  type SWMsgType = {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "baseUrl": "../",
3
+ "baseUrl": "./",
4
4
  "experimentalDecorators": true,
5
5
  "emitDecoratorMetadata": true,
6
6
  "target": "ES2018",
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 {RWSInject, applyConstructor} from './_decorator';
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 RWSContainer from './_container';
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 getFunctionParamNames(func: () => any): string[] {
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,27 @@ function getParentConstructor(instance: any): any
48
30
  return null;
49
31
  }
50
32
 
51
- const applyConstructor = (component: RWSViewComponent): void => {
52
- let mainConstructor = component.constructor;
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(!mainConstructor.length){
56
- mainConstructor = parent;
57
- }
58
-
59
- let topConstructor = mainConstructor;
37
+ if (parent.name !== 'RWSViewComponent' ) {
38
+ return;
39
+ }
60
40
 
61
- if( parent && parent.name === RWSViewComponent.name){
62
- topConstructor = parent;
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
- const applyProp = (component: RWSViewComponent, propName: string | symbol): any => {
76
- let mainConstructor = component.constructor;
77
- const parent = getParentConstructor(component);
45
+ Object.keys(existingInjectedDependencies).forEach((depKey: string) => {
46
+ // console.log(`Checking "${mainConstructor.name}" for "${depKey}"`, [...defaultDeps, ...depsToInject]);
78
47
 
79
- if(!mainConstructor.length){
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();
91
- }
92
-
93
- const existingInjectedDependencies = (topConstructor as IWithCompose<RWSViewComponent>)._toInject;
94
-
95
- // console.log(propName);
96
- if(!Object.keys(existingInjectedDependencies).includes(propName)){
97
- return null;
98
- }
99
-
100
- const loadedDependency = existingInjectedDependencies[propName];
101
-
102
- if(!(component as any)[propName]){
103
- (component as any)[propName] = loadedDependency;
104
- }
105
-
106
-
107
- return loadedDependency;
48
+ if ([...defaultDeps, ...depsToInject].includes(depKey)) {
49
+ const loadedDependency = existingInjectedDependencies[depKey];
50
+ (component as any)[depKey] = loadedDependency;
51
+ console.log(`Assigned service to "${mainConstructor.name}(${depKey})":`, loadedDependency);
52
+ }
53
+ });
108
54
  };
109
55
 
110
- export { RWSView, RWSDecoratorOptions, RWSIgnore, RWSInject, applyConstructor, applyProp };
56
+ 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,49 @@
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
+
30
+ function RWSInject<T extends RWSViewComponent>(dependencyClass: Key, defaultService: boolean = false): InjectDecoratorReturnType {
31
+ return (target: IWithCompose<T>, key?: keyof IWithCompose<T>, parameterIndex?: number) => {
32
+ if(key){
33
+ const targetConstructor = typeof target === 'function' ? target : (target as any).constructor;
34
+ addToComponentInjection(targetConstructor.name, targetConstructor, key as string, dependencyClass, defaultService);
35
+ } else{
36
+
37
+ const targetConstructor = (target as any).prototype.constructor;
38
+
39
+ const paramNames = getFunctionParamNames(targetConstructor);
40
+ const depKey = paramNames[parameterIndex];
41
+
42
+ addToComponentInjection(targetConstructor.name, targetConstructor, depKey, dependencyClass, defaultService);
43
+ }
44
+ };
45
+ }
46
+
47
+ export {
48
+ RWSInject
49
+ };
@@ -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
+ const constructorMatch = func.toString().match(/constructor\s*\(([^)]*)\)/);
6
+ if (!constructorMatch) return null;
7
+ return constructorMatch[1].split(',').map(param => param.trim());
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,27 @@ 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
+
21
23
  this.routing = this.routingService.apply(this);
22
-
24
+
23
25
  if(this.currentUrl){
24
26
  this.handleRoute(this.routing.handleRoute(this.currentUrl));
25
27
  }
26
28
  }
27
29
 
28
30
  currentUrlChanged(oldValue: string, newValue: string){
29
- if(newValue){
31
+ if(newValue){
32
+ if(!this.routingService){
33
+ console.log(oldValue, newValue);
34
+ return;
35
+ }
36
+
30
37
  if(!this.routing){
31
38
  this.routing = this.routingService.apply(this);
32
39
 
File without changes
package/src/index.ts CHANGED
@@ -14,7 +14,7 @@ import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/S
14
14
  import { sanitizedAttr } from './components/_attrs/sanitize-html';import WSService, {WSServiceInstance, WSStatus} from './services/WSService';
15
15
  import { ngAttr } from './components/_attrs/angular-attr';
16
16
  import RWSClient from './client';
17
- import RWSServiceWorker, { SWMsgType } from './service_worker/src/_service_worker';
17
+
18
18
  import IRWSUser from './interfaces/IRWSUser';
19
19
  import RWSViewComponent, { IAssetShowOptions } from './components/_component';
20
20
 
@@ -27,7 +27,7 @@ import {
27
27
  } from './services/RoutingService';
28
28
 
29
29
 
30
- import { RWSDecoratorOptions, RWSIgnore, RWSView, RWSInject } from './components/_decorator';
30
+ import { RWSDecoratorOptions, RWSIgnore, RWSInject, RWSView } from './components/_decorator';
31
31
 
32
32
  import { declareRWSComponents } from './components';
33
33
 
@@ -85,10 +85,7 @@ export {
85
85
 
86
86
  observable,
87
87
  attr,
88
-
89
- RWSServiceWorker,
90
- SWMsgType,
91
-
88
+
92
89
  RWSService,
93
90
  RWSViewComponent,
94
91
  provideRWSDesignSystem,
@@ -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
 
package/tsconfig.json CHANGED
@@ -11,17 +11,18 @@
11
11
  "resolveJsonModule": true,
12
12
  "outDir": "dist/src",
13
13
  "strictNullChecks": false,
14
+ "skipLibCheck": true,
14
15
  "allowSyntheticDefaultImports": true,
15
16
  "sourceMap": true,
16
17
  "declaration": true,
17
- "lib": ["DOM", "ESNext", "WebWorker"],
18
+ "lib": ["DOM", "ESNext"],
18
19
  },
19
20
  "include": [
20
- "src",
21
- // "declarations.d.ts"
21
+ "src",
22
+ "docs-typings.d.ts",
23
+ "node_modules/@microsoft"
22
24
  ],
23
- "exclude": [
24
- "node_modules",
25
- "**/*.spec.ts"
25
+ "exclude": [
26
+
26
27
  ]
27
28
  }
package/tsdoc.json ADDED
File without changes
package/typedoc.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
- "out": "docs",
3
- "exclude": ["**/node_modules/**", "**/*.spec.ts", "**/*.d.ts"],
2
+ "out": "docs",
4
3
  "plugin": ["typedoc-theme-hierarchy", "typedoc-plugin-rename-defaults"],
5
4
  "theme": "hierarchy",
6
5
  "readme": "./README.md",
@@ -9,5 +8,6 @@
9
8
  "categorizeByGroup": true,
10
9
  "name": "Realtime Web Suite Client package",
11
10
  "jsDocCompatibility": true,
12
- "includes": "src/"
11
+ "includes": "src/",
12
+ "exclude": ["node_modules/"]
13
13
  }
@@ -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
- };