@rws-framework/client 2.17.0 → 2.17.1

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.
@@ -28,7 +28,6 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
28
28
  executionDir,
29
29
  isWatcher,
30
30
  isDev,
31
- isHotReload,
32
31
  isReport,
33
32
  isParted,
34
33
  partedPrefix,
@@ -45,7 +44,9 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
45
44
  devRouteProxy,
46
45
  tsConfig,
47
46
  rwsPlugins,
48
- BuildConfigurator
47
+ BuildConfigurator,
48
+ hotReload,
49
+ hotReloadPort
49
50
  } = await getBuildConfig(rwsFrontendConfig, _packageDir);
50
51
 
51
52
  timeLog({ devDebug });
@@ -58,7 +59,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
58
59
  buildInfo.start(executionDir, tsConfig, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsFrontendConfig.rwsPlugins);
59
60
 
60
61
  // #SECTION INIT PLUGINS && ENV VARS DEFINES
61
- addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotReload, isReport);
62
+ addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, hotReload, isReport);
62
63
 
63
64
  const WEBPACK_AFTER_ACTIONS = rwsFrontendConfig.actions || [];
64
65
  const WEBPACK_AFTER_ERROR_ACTIONS = rwsFrontendConfig.error_actions || [];
@@ -66,7 +67,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
66
67
  const modules_setup = [path.join(_packageDir, 'node_modules'), path.join(executionDir, 'node_modules'), path.join(tools.findRootWorkspacePath(appRoot), 'node_modules')];
67
68
  let optimConfig = null;
68
69
  let aliases = rwsFrontendConfig.aliases || {};
69
- aliases = { ...aliases, ...loadAliases(_packageDir, tsConfig,path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
70
+ aliases = { ...aliases, ...(await loadAliases(_packageDir, tsConfig,path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir))}
70
71
 
71
72
  // #SECTION PLUGIN STARTING HOOKS
72
73
 
@@ -131,7 +132,9 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
131
132
  rwsExternals,
132
133
  devExternalsVars,
133
134
  appRootDir: appRoot,
134
- entrypoint: rwsFrontendConfig.entrypoint
135
+ entrypoint: rwsFrontendConfig.entrypoint,
136
+ hotReload,
137
+ hotReloadPort
135
138
  });
136
139
 
137
140
  if (optimConfig) {
@@ -145,11 +148,6 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
145
148
  await plugin.onBuild(cfgExport);
146
149
  }
147
150
 
148
- if (isDev) {
149
- // #SECTION RWS DEV SERVERS
150
- webpackDevServer(BuildConfigurator, rwsFrontendConfig, cfgExport);
151
- }
152
-
153
151
  return cfgExport;
154
152
  }
155
153
 
@@ -1,6 +1,12 @@
1
1
  const path = require('path');
2
+ const fs = require('fs');
2
3
 
3
- function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
4
+ const packageNames = [
5
+ 'client',
6
+ 'nest-interconnectors'
7
+ ];
8
+
9
+ async function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
4
10
 
5
11
  const tsPaths = {}
6
12
 
@@ -8,14 +14,26 @@ function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
8
14
  const alias = tsConfig.config.compilerOptions.paths[aliasKey];
9
15
  tsPaths[aliasKey] = path.resolve(executionDir, alias[0]);
10
16
  }
11
-
17
+
18
+ for(const pkgName of packageNames){
19
+ const symlinkPath = path.join(nodeModulesPath, '@rws-framework', pkgName);
20
+
21
+ if(fs.existsSync(symlinkPath)){
22
+ const pkgDirStat = fs.lstatSync(symlinkPath);
23
+
24
+ if(pkgDirStat.isSymbolicLink()){
25
+ const targetPath = await fs.promises.realpath(symlinkPath);
26
+
27
+ tsPaths['@rws-framework/' + pkgName + '/*'] = targetPath + '/*';
28
+ tsPaths['@rws-framework/' + pkgName] = targetPath + '/src/index.ts';
29
+ }
30
+ }
31
+ }
32
+
12
33
  return {
13
34
  ...tsPaths,
14
35
  '@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js'),
15
- '@rws-framework/foundation/*': path.resolve(packageDir, 'foundation', '*'),
16
- // 'entities/lib/maps/entities.json': path.resolve(nodeModulesPath, 'entities/lib/maps/entities.json'),
17
- // 'entities/lib/maps/legacy.json': path.resolve(nodeModulesPath, 'entities/lib/maps/legacy.json'),
18
- // 'entities/lib/maps/xml.json': path.resolve(nodeModulesPath, 'entities/lib/maps/xml.json')
36
+ '@rws-framework/foundation/*': path.resolve(packageDir, 'foundation', '*'),
19
37
  }
20
38
  }
21
39
 
@@ -12,9 +12,10 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
12
12
  const isWatcher = process.argv.includes('--watch') || false;
13
13
 
14
14
  const isDev = isWatcher ? true : (BuildConfigurator.get('dev', rwsFrontBuildConfig.dev) || false);
15
- const isHotReload = BuildConfigurator.get('hotReload', rwsFrontBuildConfig.hotReload);
16
15
  const isReport = BuildConfigurator.get('pkgReport', rwsFrontBuildConfig.pkgReport);
17
16
  const isParted = BuildConfigurator.get('parted', rwsFrontBuildConfig.parted || false);
17
+ const hotReload = BuildConfigurator.get('hotReload', rwsFrontBuildConfig.hotReload || false);
18
+ const hotReloadPort = BuildConfigurator.get('hotReloadtPort', rwsFrontBuildConfig.hotReloadPort || 1030);
18
19
 
19
20
  const partedPrefix = BuildConfigurator.get('partedPrefix', rwsFrontBuildConfig.partedPrefix);
20
21
  const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix', rwsFrontBuildConfig.partedDirUrlPrefix);
@@ -53,7 +54,6 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
53
54
  executionDir,
54
55
  isWatcher,
55
56
  isDev,
56
- isHotReload,
57
57
  isReport,
58
58
  isParted,
59
59
  partedPrefix,
@@ -70,7 +70,9 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
70
70
  devRouteProxy,
71
71
  tsConfig,
72
72
  rwsPlugins,
73
- BuildConfigurator
73
+ BuildConfigurator,
74
+ hotReload,
75
+ hotReloadPort
74
76
  }
75
77
  }
76
78
 
@@ -17,8 +17,6 @@ function processEnvDefines(BuildConfigurator, config, devDebug) {
17
17
  _rws_defines = { ..._rws_defines, ...stringifiedDefines }
18
18
  }
19
19
 
20
- console.log({_rws_defines});
21
-
22
20
  return _rws_defines;
23
21
  }
24
22
 
@@ -0,0 +1,14 @@
1
+ function getRWSHotReloadSetup(port, outputDir){
2
+ return {
3
+ hot: true,
4
+ port,
5
+ static: {
6
+ directory: outputDir,
7
+ },
8
+ devMiddleware: {
9
+ publicPath: '/'
10
+ }
11
+ }
12
+ }
13
+
14
+ module.exports = { getRWSHotReloadSetup };
@@ -89,7 +89,6 @@ function getRWSLoaders(packageDir, executionDir, tsConfigData, appRootDir, entry
89
89
  },
90
90
  ];
91
91
 
92
-
93
92
  return loaders;
94
93
  }
95
94
 
@@ -78,16 +78,6 @@ function addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotRe
78
78
  ...getPackageModPlugins()
79
79
  ]);
80
80
 
81
- if (isHotReload) {
82
- if (!publicDir) {
83
- throw new Error('No public dir set')
84
- }
85
-
86
- RWS_WEBPACK_PLUGINS_BAG.add(new HtmlWebpackPlugin({
87
- template: path.join(publicDir, '/', publicIndex),
88
- }));
89
- }
90
-
91
81
  const overridePlugins = rwsFrontendConfig.plugins || []
92
82
 
93
83
  RWS_WEBPACK_PLUGINS_BAG.add(overridePlugins);
@@ -1,5 +1,6 @@
1
+ const { getRWSHotReloadSetup } = require('./_hot_reload');
1
2
  const { getRWSLoaders } = require('./_loaders');
2
- const path = require('path');
3
+ const webpack = require('webpack');
3
4
 
4
5
 
5
6
  async function createWebpackConfig({
@@ -20,9 +21,15 @@ async function createWebpackConfig({
20
21
  rwsExternals,
21
22
  devExternalsVars,
22
23
  appRootDir,
23
- entrypoint
24
+ entrypoint,
25
+ hotReload,
26
+ hotReloadPort
24
27
  }) {
25
28
 
29
+ if(hotReload){
30
+ WEBPACK_PLUGINS.push(new webpack.HotModuleReplacementPlugin());
31
+ }
32
+
26
33
  return {
27
34
  context: executionDir,
28
35
  entry: {
@@ -47,6 +54,7 @@ async function createWebpackConfig({
47
54
  path: false
48
55
  }
49
56
  },
57
+ devServer: hotReload ? getRWSHotReloadSetup(hotReloadPort, outputDir) : null,
50
58
  module: {
51
59
  rules: getRWSLoaders(_packageDir, executionDir, tsConfig, appRootDir, entrypoint),
52
60
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.17.0",
4
+ "version": "2.17.1",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -6,7 +6,7 @@ import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
6
6
  import deepmerge from 'deepmerge';
7
7
  import { IPluginSpawnOption } from "../types/IRWSPlugin";
8
8
 
9
- type RWSInfoType = { components: string[] };
9
+ import { _DEFAULT_HR_PORT } from './hotReload';
10
10
 
11
11
  function getUser(this: RWSClientInstance): IRWSUser {
12
12
 
@@ -96,6 +96,12 @@ async function setup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
96
96
 
97
97
  this.appConfig.mergeConfig(this.config);
98
98
 
99
+ if (this.appConfig.get('hotReload') === true) {
100
+ if(!this.appConfig.get('hotReloadPort')){
101
+ this.appConfig.set('hotReloadPort', _DEFAULT_HR_PORT)
102
+ }
103
+ }
104
+
99
105
  if(this.config.plugins){
100
106
  for (const pluginEntry of this.config.plugins){
101
107
  addPlugin.bind(this)(pluginEntry);
@@ -146,6 +152,12 @@ async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
146
152
  await plugin.onClientStart();
147
153
  }
148
154
 
155
+ if(this.appConfig.get('hotReload')){
156
+ if (module.hot) {
157
+ module.hot.accept();
158
+ }
159
+ }
160
+
149
161
  return this;
150
162
  }
151
163
 
@@ -0,0 +1,23 @@
1
+ import { RWSClientInstance } from "../client";
2
+ import IRWSConfig from "../types/IRWSConfig";
3
+
4
+ export const _DEFAULT_HR_PORT = 1030;
5
+
6
+ export interface IHotReloadCfg {
7
+ enabled: boolean,
8
+ port: number
9
+ }
10
+
11
+ async function hotReloadSetup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance>
12
+ {
13
+
14
+ return this;
15
+ }
16
+
17
+ function getBinds(this: RWSClientInstance) {
18
+ return {
19
+ hotReloadSetup: hotReloadSetup.bind(this)
20
+ };
21
+ }
22
+
23
+ export default getBinds;
package/src/client.ts CHANGED
@@ -22,6 +22,7 @@ import TheRWSService from './services/_service';
22
22
  import ComponentHelper, { ComponentHelperStatic, RWSInfoType } from './client/components';
23
23
  import ServicesHelper from './client/services';
24
24
  import ConfigHelper from './client/config';
25
+ import HotReloadHelper, { IHotReloadCfg, _DEFAULT_HR_PORT } from './client/hotReload';
25
26
  import { DefaultRWSPluginOptionsType, RWSPlugin } from './plugins/_plugin';
26
27
  import { IStaticRWSPlugin } from './types/IRWSPlugin'
27
28
 
@@ -38,10 +39,13 @@ class RWSClient {
38
39
  protected devStorage: { [key: string]: any } = {};
39
40
  protected customServices: { [serviceName: string]: TheRWSService} = {};
40
41
  protected defaultServices: { [serviceName: string]: TheRWSService} = {};
42
+ protected hrSetup: IHotReloadCfg = { enabled: false, port: _DEFAULT_HR_PORT }
41
43
 
42
44
  private componentHelper = ComponentHelper.bind(this)();
43
45
  private servicesHelper = ServicesHelper.bind(this)();
44
46
  private configHelper = ConfigHelper.bind(this)();
47
+ private hotReloadHelper = HotReloadHelper.bind(this)();
48
+
45
49
 
46
50
  protected initCallback: () => Promise<void> = async () => { };
47
51
 
package/src/index.ts CHANGED
@@ -1,60 +1,38 @@
1
1
  import { Transformer as HTMLTagTransformerType, Tag as HTMLTag, Attributes as HTMLAttributes } from 'sanitize-html';
2
2
  import { observable, attr } from '@microsoft/fast-element';
3
- import type IRWSConfig from './types/IRWSConfig';
4
- import type RWSNotify from './types/RWSNotify';
5
- import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
3
+
6
4
  import RWSService from './services/_service';
7
5
  import ConfigService, { ConfigServiceInstance } from './services/ConfigService';
8
6
  import NotifyService, {NotifyServiceInstance} from './services/NotifyService';
9
7
  import DOMService, { DOMServiceInstance } from './services/DOMService';
10
- import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
11
8
  import ApiService, { ApiServiceInstance } from './services/ApiService';
12
- import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
13
-
14
9
  import UtilsService, {UtilsServiceInstance} from './services/UtilsService';
15
10
  import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/ServiceWorkerService';
16
- // import { sanitizedAttr } from './components/_attrs/sanitize-html';
17
11
  import { ngAttr } from './components/_attrs/angular-attr';
18
12
  import { externalObservable } from './components/_attrs/external-observable';
19
13
  import { externalAttr } from './components/_attrs/external-attr';
20
14
  import { RWSPlugin } from './plugins/_plugin';
15
+ import RWSClient, { RWSClientInstance } from './client';
16
+ import RWSViewComponent from './components/_component';
17
+ import RWSContainer from './components/_container';
21
18
 
22
- import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
19
+ import { RWSIgnore, RWSInject, RWSView } from './components/_decorator';
20
+ import { declareRWSComponents } from './components';
23
21
 
22
+ import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
24
23
  import type { IRWSPlugin, IStaticRWSPlugin, IPluginSpawnOption } from './types/IRWSPlugin';
25
- import RWSClient, { RWSClientInstance } from './client';
26
24
  import type IRWSUser from './types/IRWSUser';
27
- import RWSViewComponent from './components/_component';
28
25
  import type { IAssetShowOptions } from './components/_component';
29
-
30
- import RWSContainer from './components/_container';
31
-
32
26
  import type { RWSDecoratorOptions } from './components/_decorator';
33
27
  import type { IKDBTypeInfo, IKDBTypesResponse } from './types/IBackendCore';
34
-
35
- import { RWSIgnore, RWSInject, RWSView } from './components/_decorator';
36
-
37
- import { declareRWSComponents } from './components';
28
+ import type { DOMOutputType, TagsProcessorType } from './services/DOMService';
29
+ import type { IBackendRoute, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
30
+ import type IRWSConfig from './types/IRWSConfig';
31
+ import type RWSNotify from './types/RWSNotify';
32
+ import type { NotifyUiType, NotifyLogType } from './types/RWSNotify';
38
33
 
39
34
  export default RWSClient;
40
35
 
41
- export type {
42
- IKDBTypeInfo, IKDBTypesResponse,
43
- NotifyUiType,
44
- NotifyLogType,
45
- IBackendRoute as IRWSBackendRoute,
46
- RWSDecoratorOptions as IRWSDecoratorOptions,
47
- IHTTProute as IRWSHttpRoute,
48
- IPrefixedHTTProutes as IRWSPrefixedHTTProutes,
49
- IAssetShowOptions as IRWSAssetShowOptions,
50
- IRWSConfig,
51
- IRWSUser,
52
- TagsProcessorType,
53
- HTMLTagTransformerType,
54
- HTMLTag,
55
- HTMLAttributes
56
- }
57
-
58
36
  export {
59
37
  RWSClient,
60
38
  RWSClientInstance,
@@ -79,8 +57,7 @@ export {
79
57
 
80
58
  RWSNotify,
81
59
 
82
- RWSView,
83
- // sanitizedAttr,
60
+ RWSView,
84
61
  RWSIgnore,
85
62
  RWSInject,
86
63
  observable,
@@ -94,4 +71,21 @@ export {
94
71
  declareRWSComponents,
95
72
 
96
73
  RWSContainer
97
- };
74
+ };
75
+
76
+ export type {
77
+ IKDBTypeInfo, IKDBTypesResponse,
78
+ NotifyUiType,
79
+ NotifyLogType,
80
+ IBackendRoute as IRWSBackendRoute,
81
+ RWSDecoratorOptions as IRWSDecoratorOptions,
82
+ IHTTProute as IRWSHttpRoute,
83
+ IPrefixedHTTProutes as IRWSPrefixedHTTProutes,
84
+ IAssetShowOptions as IRWSAssetShowOptions,
85
+ IRWSConfig,
86
+ IRWSUser,
87
+ TagsProcessorType,
88
+ HTMLTagTransformerType,
89
+ HTMLTag,
90
+ HTMLAttributes
91
+ }
@@ -22,6 +22,8 @@ export default interface IRWSConfig {
22
22
  rwsDefines?: {[key: string]: any}
23
23
  partedFileDir?: string
24
24
  partedPrefix?: string
25
+ hotReload?: boolean,
26
+ hotReloadPort?: number,
25
27
  plugins?: IPluginSpawnOption<any>[]
26
28
  routing_enabled?: boolean
27
29
  _noLoad?: boolean