@rws-framework/client 2.2.1 → 2.3.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/_rws_build_configurator.d.ts +12 -0
- package/_rws_build_configurator.js +44 -0
- package/cfg/_default.cfg.js +23 -0
- package/cfg/_storage.d.ts +22 -0
- package/cfg/_storage.js +43 -0
- package/package.json +2 -1
- package/rws.webpack.config.js +62 -61
- package/src/client.ts +9 -29
- package/src/components/_component.ts +1 -1
- package/src/components/_decorators/RWSFillBuild.ts +43 -0
- package/src/components/index.ts +1 -7
- package/src/index.ts +1 -3
- package/src/interfaces/IRWSConfig.ts +4 -3
- package/src/services/ConfigService.ts +19 -14
- package/webpack/rws_after_plugin.js +22 -0
- package/webpack/rws_plugin.js +0 -13
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const _DEFAULT_CONFIG: any;
|
|
2
|
+
|
|
3
|
+
declare function readConfigFile(filePath: string): any;
|
|
4
|
+
declare function get(key: string): any;
|
|
5
|
+
declare function exportConfig(): any;
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
readConfigFile,
|
|
9
|
+
get,
|
|
10
|
+
exportConfig,
|
|
11
|
+
_DEFAULT_CONFIG
|
|
12
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
..._DEFAULT_CONFIG,
|
|
17
|
+
...fileConfig
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function get(key){
|
|
22
|
+
_init();
|
|
23
|
+
|
|
24
|
+
return STORAGE.get(key);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function exportConfig(){
|
|
28
|
+
_init();
|
|
29
|
+
|
|
30
|
+
return STORAGE.getAll();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _init(){
|
|
34
|
+
if(!STORAGE.isLoaded()){
|
|
35
|
+
STORAGE.init(readConfigFile(process.cwd() + '/.rws.json'))
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
readConfigFile,
|
|
41
|
+
exportConfig,
|
|
42
|
+
get,
|
|
43
|
+
_DEFAULT_CONFIG
|
|
44
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const _DEFAULT_CONFIG_VARS = {
|
|
2
|
+
//Build configs
|
|
3
|
+
dev: false,
|
|
4
|
+
hot: false,
|
|
5
|
+
report: false,
|
|
6
|
+
publicDir: './public',
|
|
7
|
+
publicIndex: 'index.html',
|
|
8
|
+
outputFileName: 'client.rws.js',
|
|
9
|
+
outputDir: './build',
|
|
10
|
+
//Frontend RWS client configs
|
|
11
|
+
backendUrl: null,
|
|
12
|
+
wsUrl: null,
|
|
13
|
+
partedDirUrlPrefix: '/lib/rws',
|
|
14
|
+
partedPrefix: 'rws',
|
|
15
|
+
pubUrlFilePrefix: '/',
|
|
16
|
+
//Universal configs
|
|
17
|
+
transports: ['websocket'],
|
|
18
|
+
parted: true,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const _DEFAULT_CONFIG = Object.freeze(_DEFAULT_CONFIG_VARS);
|
|
22
|
+
|
|
23
|
+
module.exports = {_DEFAULT_CONFIG};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface Storage {
|
|
2
|
+
_loaded: boolean;
|
|
3
|
+
data: {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare const _STORAGE: Readonly<Storage>;
|
|
9
|
+
|
|
10
|
+
declare function get(key: string): any | null;
|
|
11
|
+
declare function getAll(): any;
|
|
12
|
+
declare function init(json: any): void;
|
|
13
|
+
declare function has(key: string): boolean;
|
|
14
|
+
declare function isLoaded(): boolean;
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
get,
|
|
18
|
+
getAll,
|
|
19
|
+
has,
|
|
20
|
+
init,
|
|
21
|
+
isLoaded
|
|
22
|
+
};
|
package/cfg/_storage.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class Storage {
|
|
2
|
+
static _instance;
|
|
3
|
+
|
|
4
|
+
_loaded = false;
|
|
5
|
+
data = {}
|
|
6
|
+
|
|
7
|
+
static create(){
|
|
8
|
+
if(!this._instance){
|
|
9
|
+
this._instance = new Storage();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return this._instance;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const _STORAGE = Storage.create();
|
|
17
|
+
|
|
18
|
+
function get(key){
|
|
19
|
+
if(!has(key)){
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return _STORAGE.data[key];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getAll(){
|
|
27
|
+
return _STORAGE.data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function init(json){
|
|
31
|
+
_STORAGE.data = json;
|
|
32
|
+
_STORAGE._loaded = true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function has(key){
|
|
36
|
+
return Object.keys(_STORAGE.data).includes(key);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isLoaded(){
|
|
40
|
+
return _STORAGE._loaded;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
module.exports = {get, getAll, has, init, isLoaded}
|
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.3.0",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs": "typedoc --tsconfig ./tsconfig.json"
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@types/uuid": "^9.0.7",
|
|
60
60
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
61
61
|
"@typescript-eslint/parser": "^7.2.0",
|
|
62
|
+
"clean-webpack-plugin": "^4.0.0",
|
|
62
63
|
"css-loader": "^6.8.1",
|
|
63
64
|
"css-minimizer-webpack-plugin": "^5.0.1",
|
|
64
65
|
"dts-bundle": "^0.7.3",
|
package/rws.webpack.config.js
CHANGED
|
@@ -1,68 +1,66 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const webpack = require('webpack');
|
|
3
2
|
const fs = require('fs');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
3
|
+
const webpack = require('webpack');
|
|
4
|
+
const uglify = require('uglify-js')
|
|
7
5
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
8
6
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
7
|
+
|
|
9
8
|
const RWSAfterPlugin = require('./webpack/rws_after_plugin');
|
|
10
|
-
const { Console } = require('console');
|
|
11
|
-
const { Interface } = require('readline');
|
|
12
|
-
const ts = require('typescript');
|
|
13
9
|
const tools = require('./_tools');
|
|
10
|
+
const BuildConfigurator = require('./_rws_build_configurator');
|
|
11
|
+
|
|
14
12
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
15
13
|
const HtmlMinifier = require('html-minifier').minify;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
let WEBPACK_PLUGINS = [];
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* The RWS webpack configurator.
|
|
22
|
-
*
|
|
23
|
-
* Example usage in importing file:
|
|
24
|
-
*
|
|
25
|
-
* RWSWebpackWrapper({
|
|
26
|
-
dev: true,
|
|
27
|
-
hot: false,
|
|
28
|
-
tsConfigPath: executionDir + '/tsconfig.json',
|
|
29
|
-
entry: `${executionDir}/src/index.ts`,
|
|
30
|
-
executionDir: executionDir,
|
|
31
|
-
publicDir: path.resolve(executionDir, 'public'),
|
|
32
|
-
outputDir: path.resolve(executionDir, 'build'),
|
|
33
|
-
outputFileName: 'jtrainer.client.js',
|
|
34
|
-
copyToDir: {
|
|
35
|
-
'../public/js/' : [
|
|
36
|
-
'./build/jtrainer.client.js',
|
|
37
|
-
'./build/jtrainer.client.js.map',
|
|
38
|
-
'./src/styles/compiled/main.css'
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
plugins: [
|
|
42
|
-
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
*/
|
|
46
|
-
const RWSWebpackWrapper = (config) => {
|
|
47
|
-
const executionDir = config.executionDir || process.cwd();
|
|
14
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
15
|
+
const JsMinimizerPlugin = require('terser-webpack-plugin');
|
|
48
16
|
|
|
49
|
-
|
|
50
|
-
const isHotReload = config.hot;
|
|
51
|
-
const isReport = config.report;
|
|
17
|
+
const json5 = require('json5');
|
|
52
18
|
|
|
53
|
-
const publicDir = config.publicDir || null;
|
|
54
|
-
const serviceWorkerPath = config.serviceWorker || null;
|
|
55
19
|
|
|
56
|
-
|
|
20
|
+
const RWSWebpackWrapper = (config) => {
|
|
21
|
+
const executionDir = config.executionDir || process.cwd();
|
|
22
|
+
|
|
23
|
+
const isDev = BuildConfigurator.get('dev') || config.dev;
|
|
24
|
+
const isHotReload = BuildConfigurator.get('hot') || config.hot;
|
|
25
|
+
const isReport = BuildConfigurator.get('report') || config.report;
|
|
26
|
+
|
|
27
|
+
const isParted = BuildConfigurator.get('parted') || config.parted;
|
|
28
|
+
const partedPrefix = BuildConfigurator.get('partedPrefix') || config.partedPrefix;
|
|
29
|
+
const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix') || config.partedDirUrlPrefix;
|
|
30
|
+
|
|
31
|
+
const partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations') || config.partedComponentsLocations;
|
|
32
|
+
const customServiceLocations = BuildConfigurator.get('customServiceLocations') || config.customServiceLocations;
|
|
33
|
+
const outputDir = BuildConfigurator.get('outputDir') || config.outputDir;
|
|
34
|
+
const outputFileName = BuildConfigurator.get('outputFileName') || config.outputFileName;
|
|
35
|
+
const publicDir = BuildConfigurator.get('publicDir') || config.publicDir;
|
|
36
|
+
const serviceWorkerPath = BuildConfigurator.get('serviceWorker') || config.serviceWorker;
|
|
37
|
+
|
|
38
|
+
const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
let WEBPACK_PLUGINS = [
|
|
42
|
+
new webpack.DefinePlugin({
|
|
43
|
+
'process.env._RWS_DEFAULTS': JSON.stringify(BuildConfigurator.exportConfig())
|
|
44
|
+
}),
|
|
45
|
+
new webpack.BannerPlugin({
|
|
46
|
+
banner: `if(!window.RWS){
|
|
47
|
+
const script = document.createElement('script');
|
|
48
|
+
script.src = '${partedDirUrlPrefix}/${partedPrefix}.vendors.js';
|
|
49
|
+
script.type = 'text/javascript';
|
|
50
|
+
document.body.appendChild(script);
|
|
51
|
+
}`.replace('\n', ''),
|
|
52
|
+
raw: true,
|
|
53
|
+
entryOnly: true,
|
|
54
|
+
// include: 'client'
|
|
55
|
+
}),
|
|
56
|
+
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/)
|
|
57
|
+
];
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
+
const WEBPACK_AFTER_ACTIONS = config.actions || [];
|
|
59
60
|
|
|
60
61
|
const aliases = config.aliases = {};
|
|
61
|
-
|
|
62
62
|
aliases.fs = false;
|
|
63
|
-
|
|
64
63
|
const modules_setup = [path.resolve(__dirname, 'node_modules'), 'node_modules'];
|
|
65
|
-
|
|
66
64
|
const overridePlugins = config.plugins || []
|
|
67
65
|
|
|
68
66
|
if (isHotReload) {
|
|
@@ -78,7 +76,7 @@ const RWSWebpackWrapper = (config) => {
|
|
|
78
76
|
WEBPACK_PLUGINS = [...WEBPACK_PLUGINS, new webpack.optimize.ModuleConcatenationPlugin(), ...overridePlugins];
|
|
79
77
|
|
|
80
78
|
|
|
81
|
-
if (
|
|
79
|
+
if (isReport) {
|
|
82
80
|
WEBPACK_PLUGINS.push(new BundleAnalyzerPlugin({
|
|
83
81
|
analyzerMode: 'static',
|
|
84
82
|
openAnalyzer: false,
|
|
@@ -92,10 +90,12 @@ const RWSWebpackWrapper = (config) => {
|
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
const assetsToCopy = config.copyAssets || BuildConfigurator.get('copyAssets');
|
|
94
|
+
|
|
95
|
+
if (!!assetsToCopy) {
|
|
96
96
|
WEBPACK_AFTER_ACTIONS.push({
|
|
97
97
|
type: 'copy',
|
|
98
|
-
actionHandler:
|
|
98
|
+
actionHandler: assetsToCopy
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -117,13 +117,14 @@ const RWSWebpackWrapper = (config) => {
|
|
|
117
117
|
path.resolve(executionDir, 'src', 'services')
|
|
118
118
|
];
|
|
119
119
|
|
|
120
|
-
if (
|
|
121
|
-
|
|
120
|
+
if (customServiceLocations) {
|
|
121
|
+
customServiceLocations.forEach((serviceDir) => {
|
|
122
122
|
servicesLocations.push(serviceDir);
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
const optimConfig = {
|
|
127
|
+
minimize: true,
|
|
127
128
|
minimizer: isDev ? [] : [
|
|
128
129
|
new TerserPlugin({
|
|
129
130
|
terserOptions: {
|
|
@@ -137,16 +138,16 @@ const RWSWebpackWrapper = (config) => {
|
|
|
137
138
|
comments: false
|
|
138
139
|
},
|
|
139
140
|
},
|
|
140
|
-
extractComments: false
|
|
141
|
+
extractComments: false,
|
|
142
|
+
parallel: true,
|
|
141
143
|
}),
|
|
142
144
|
new CssMinimizerPlugin(),
|
|
143
|
-
|
|
144
145
|
],
|
|
145
146
|
};
|
|
146
147
|
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
149
|
-
|
|
148
|
+
if (isParted) {
|
|
149
|
+
if (partedComponentsLocations) {
|
|
150
|
+
partedComponentsLocations.forEach((componentDir) => {
|
|
150
151
|
RWSComponents = [...RWSComponents, ...(tools.findComponentFilesWithText(path.resolve(componentDir), '@RWSView', ['dist', 'node_modules', '@rws-framework/client']))];
|
|
151
152
|
});
|
|
152
153
|
}
|
|
@@ -204,8 +205,8 @@ const RWSWebpackWrapper = (config) => {
|
|
|
204
205
|
target: 'web',
|
|
205
206
|
devtool: isDev ? (config.devtool || 'inline-source-map') : false,
|
|
206
207
|
output: {
|
|
207
|
-
path:
|
|
208
|
-
filename:
|
|
208
|
+
path: outputDir,
|
|
209
|
+
filename: isParted ? (partedPrefix || 'rws') + '.[name].js' : outputFileName,
|
|
209
210
|
sourceMapFilename: '[file].map',
|
|
210
211
|
},
|
|
211
212
|
resolve: {
|
package/src/client.ts
CHANGED
|
@@ -39,7 +39,7 @@ class RWSClient {
|
|
|
39
39
|
private _container: Container;
|
|
40
40
|
private user: IRWSUser = null;
|
|
41
41
|
|
|
42
|
-
private config: IRWSConfig = { backendUrl: '', routes: {},
|
|
42
|
+
private config: IRWSConfig = { backendUrl: '', routes: {}, partedFileDir: '/', partedPrefix: 'rws' };
|
|
43
43
|
protected initCallback: () => Promise<void> = async () => { };
|
|
44
44
|
|
|
45
45
|
private isSetup = false;
|
|
@@ -106,9 +106,7 @@ class RWSClient {
|
|
|
106
106
|
|
|
107
107
|
if (Object.keys(config).length) {
|
|
108
108
|
this.appConfig.mergeConfig(this.config);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
console.log(this.isSetup, this.config, this.appConfig);
|
|
109
|
+
}
|
|
112
110
|
|
|
113
111
|
if (this.config.user && !this.config.dontPushToSW) {
|
|
114
112
|
this.pushUserToServiceWorker(this.user);
|
|
@@ -116,6 +114,8 @@ class RWSClient {
|
|
|
116
114
|
|
|
117
115
|
await startClient(this.appConfig, this.wsService, this.notifyService, this.routingService);
|
|
118
116
|
|
|
117
|
+
RWSClient.defineAllComponents();
|
|
118
|
+
|
|
119
119
|
await this.initCallback();
|
|
120
120
|
|
|
121
121
|
return this;
|
|
@@ -223,35 +223,17 @@ class RWSClient {
|
|
|
223
223
|
async loadPartedComponents(): Promise<void> {
|
|
224
224
|
this.assignClientToBrowser();
|
|
225
225
|
|
|
226
|
-
const componentParts: string[] = await this.apiService.get<string[]>(this.appConfig.get('
|
|
227
|
-
|
|
228
|
-
const _all: Promise<string>[] = [];
|
|
229
|
-
componentParts.forEach((componentName: string) => {
|
|
230
|
-
|
|
231
|
-
const scriptUrl: string = this.appConfig.get('splitFileDir') + `/${this.appConfig.get('splitPrefix')}.${componentName}.js`; // Replace with the path to your script file
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
const componentParts: string[] = await this.apiService.get<string[]>(this.appConfig.get('partedDirUrlPrefix') + '/rws_chunks_info.json');
|
|
234
227
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
headers['Content-Type'] = 'application/javascript';
|
|
238
|
-
|
|
239
|
-
_all.push(this.apiService.pureGet(scriptUrl, {
|
|
240
|
-
headers
|
|
241
|
-
}));
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
(await Promise.all(_all)).forEach((scriptCnt: string, key: number) => {
|
|
228
|
+
componentParts.forEach((componentName: string, key: number) => {
|
|
245
229
|
const script: HTMLScriptElement = document.createElement('script');
|
|
246
|
-
script.
|
|
230
|
+
script.src = `${this.appConfig.get('partedDirUrlPrefix')}/${this.appConfig.get('partedPrefix')}.${componentName}.js`;
|
|
247
231
|
script.async = true;
|
|
248
232
|
script.type = 'text/javascript';
|
|
249
233
|
document.body.appendChild(script);
|
|
250
234
|
|
|
251
235
|
console.log(`Appended ${componentParts[key]} component`);
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
RWSClient.defineAllComponents();
|
|
236
|
+
});
|
|
255
237
|
}
|
|
256
238
|
|
|
257
239
|
async onDOMLoad(): Promise<void> {
|
|
@@ -290,9 +272,7 @@ class RWSClient {
|
|
|
290
272
|
|
|
291
273
|
static defineAllComponents() {
|
|
292
274
|
const richWindowComponents: RWSWindowComponentRegister = (window as Window & RWSWindow).RWS.components;
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
console.log(richWindowComponents);
|
|
275
|
+
|
|
296
276
|
Object.keys(richWindowComponents).map(key => richWindowComponents[key].component).forEach((el: IWithCompose<RWSViewComponent>) => {
|
|
297
277
|
el.define(el as any, el.definition);
|
|
298
278
|
});
|
|
@@ -81,7 +81,7 @@ abstract class RWSViewComponent extends FoundationElement implements IRWSViewCom
|
|
|
81
81
|
if (this.fileAssets[file]) {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
this.utilsService.getFileContents(this.config.get('
|
|
84
|
+
this.utilsService.getFileContents(this.config.get('pubUrlFilePrefix') + file).then((response: string) => {
|
|
85
85
|
this.fileAssets = { ...this.fileAssets, [file]: html`${response}` };
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import IRWSConfig from '../../interfaces/IRWSConfig.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function RWSFillBuild(config?: Partial<IRWSConfig>) {
|
|
6
|
+
return function <T extends { new(...args: any[]): {} }>(constructor: T) {
|
|
7
|
+
return class extends constructor {
|
|
8
|
+
_DEFAULTS: IRWSConfig;
|
|
9
|
+
constructor(...args: any[]) {
|
|
10
|
+
super(...args);
|
|
11
|
+
|
|
12
|
+
const extractedDefaults = JSON.parse(JSON.stringify(process.env._RWS_DEFAULTS));
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
backendUrl,
|
|
16
|
+
wsUrl,
|
|
17
|
+
partedDirUrlPrefix,
|
|
18
|
+
partedPrefix,
|
|
19
|
+
pubUrlFilePrefix,
|
|
20
|
+
transports,
|
|
21
|
+
parted
|
|
22
|
+
} = extractedDefaults;
|
|
23
|
+
|
|
24
|
+
const extractedFrontendDefaults = {
|
|
25
|
+
backendUrl,
|
|
26
|
+
wsUrl,
|
|
27
|
+
partedDirUrlPrefix,
|
|
28
|
+
partedPrefix,
|
|
29
|
+
pubUrlFilePrefix,
|
|
30
|
+
transports,
|
|
31
|
+
parted
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
this._DEFAULTS = {
|
|
35
|
+
...config,
|
|
36
|
+
...extractedFrontendDefaults
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { RWSFillBuild }
|
package/src/components/index.ts
CHANGED
|
@@ -3,12 +3,6 @@ import { RouterComponent } from './router/component';
|
|
|
3
3
|
import { RWSProgress } from './progress/component';
|
|
4
4
|
import { RWSLoader } from './loader/component';
|
|
5
5
|
|
|
6
|
-
const RWSComponents = {
|
|
7
|
-
RWSUploader,
|
|
8
|
-
RouterComponent,
|
|
9
|
-
RWSProgress,
|
|
10
|
-
RWSLoader
|
|
11
|
-
};
|
|
12
6
|
|
|
13
7
|
function declareRWSComponents(parted: boolean = false): void
|
|
14
8
|
{
|
|
@@ -20,4 +14,4 @@ function declareRWSComponents(parted: boolean = false): void
|
|
|
20
14
|
}
|
|
21
15
|
}
|
|
22
16
|
|
|
23
|
-
export {
|
|
17
|
+
export { declareRWSComponents };
|
package/src/index.ts
CHANGED
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
|
|
30
30
|
import { RWSDecoratorOptions, RWSIgnore, RWSView, RWSInject } from './components/_decorator';
|
|
31
31
|
|
|
32
|
-
import {
|
|
32
|
+
import { declareRWSComponents } from './components';
|
|
33
33
|
|
|
34
34
|
export default RWSClient;
|
|
35
35
|
export {
|
|
@@ -82,8 +82,6 @@ export {
|
|
|
82
82
|
ngAttr,
|
|
83
83
|
|
|
84
84
|
renderRouteComponent,
|
|
85
|
-
|
|
86
|
-
RWSComponents,
|
|
87
85
|
|
|
88
86
|
observable,
|
|
89
87
|
attr,
|
|
@@ -12,11 +12,12 @@ export default interface IRWSConfig {
|
|
|
12
12
|
user?: any
|
|
13
13
|
ignoreRWSComponents?: boolean
|
|
14
14
|
pubUrl?: string
|
|
15
|
-
|
|
15
|
+
pubUrlFilePrefix?: string
|
|
16
|
+
partedDirUrlPrefix?: string
|
|
16
17
|
dontPushToSW?: boolean
|
|
17
18
|
parted?: boolean
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
partedFileDir?: string
|
|
20
|
+
partedPrefix?: string
|
|
20
21
|
routing_enabled?: boolean
|
|
21
22
|
_noLoad?: boolean
|
|
22
23
|
}
|
|
@@ -1,35 +1,40 @@
|
|
|
1
1
|
import TheService from './_service';
|
|
2
2
|
import IRWSConfig from '../interfaces/IRWSConfig';
|
|
3
|
+
import { RWSFillBuild } from '../components/_decorators/RWSFillBuild';
|
|
4
|
+
|
|
3
5
|
|
|
4
6
|
|
|
5
|
-
const _DEFAULTS: {[property: string]: any} = {
|
|
6
|
-
pubPrefix: '/',
|
|
7
|
-
pubUrl : window.origin,
|
|
8
|
-
splitFileDir: '/',
|
|
9
|
-
splitPrefix: 'rws'
|
|
10
|
-
}
|
|
11
7
|
|
|
12
8
|
const __SENT_TO_COMPONENTS: string[] = [];
|
|
13
9
|
|
|
10
|
+
@RWSFillBuild({
|
|
11
|
+
pubUrlFilePrefix: '/',
|
|
12
|
+
pubUrl: window.origin,
|
|
13
|
+
partedFileDir: '/',
|
|
14
|
+
partedPrefix: 'rws',
|
|
15
|
+
})
|
|
14
16
|
class ConfigService extends TheService {
|
|
15
17
|
static isLoaded: boolean = false;
|
|
16
|
-
|
|
18
|
+
_DEFAULTS: any = null;
|
|
17
19
|
private data: IRWSConfig = {};
|
|
18
20
|
|
|
19
21
|
constructor() {
|
|
20
|
-
super();
|
|
22
|
+
super();
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
public get(key: keyof IRWSConfig): any
|
|
24
|
-
{
|
|
25
|
-
|
|
26
|
+
{
|
|
27
|
+
if(!this._DEFAULTS){
|
|
28
|
+
throw new Error('No _DEFAULTS loaded!')
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
const isInData: boolean = Object.keys(this.data).includes(key);
|
|
27
|
-
const isInDefaults: boolean = Object.keys(_DEFAULTS).includes(key);
|
|
32
|
+
const isInDefaults: boolean = Object.keys(this._DEFAULTS).includes(key);
|
|
28
33
|
|
|
29
34
|
if(!isInData && isInDefaults){
|
|
30
|
-
let defaultVal = _DEFAULTS[key];
|
|
31
|
-
|
|
32
|
-
if(defaultVal[0] === '@'){
|
|
35
|
+
let defaultVal = this._DEFAULTS[key];
|
|
36
|
+
console.log(key, 'kk')
|
|
37
|
+
if(defaultVal && defaultVal[0] === '@'){
|
|
33
38
|
defaultVal = this.data[((defaultVal as string).slice(1)) as keyof IRWSConfig];
|
|
34
39
|
}
|
|
35
40
|
|
|
@@ -35,6 +35,28 @@ class RWSAfterPlugin {
|
|
|
35
35
|
return await Promise.all(proms);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
compiler.hooks.emit.tapAsync('RWSAfterPlugin', (compilation, callback) => {
|
|
40
|
+
Object.keys(compilation.assets).forEach((filename) => {
|
|
41
|
+
|
|
42
|
+
if (filename.endsWith('.js')) {
|
|
43
|
+
const asset = compilation.assets[filename];
|
|
44
|
+
let source = asset.source();
|
|
45
|
+
if(source.indexOf('css`') > -1 || source.indexOf('html`') > -1){
|
|
46
|
+
console.log('replacing', filename);
|
|
47
|
+
const updatedSource = source.replace(/\n/g, '');
|
|
48
|
+
|
|
49
|
+
// Update the asset with the new content
|
|
50
|
+
compilation.assets[filename] = {
|
|
51
|
+
source: () => updatedSource,
|
|
52
|
+
size: () => updatedSource.length
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
callback();
|
|
59
|
+
});
|
|
38
60
|
}
|
|
39
61
|
|
|
40
62
|
async _runActionType(actionType, action){
|
package/webpack/rws_plugin.js
CHANGED
|
@@ -124,19 +124,6 @@ class RWSPlugin {
|
|
|
124
124
|
const _self = this;
|
|
125
125
|
|
|
126
126
|
return;
|
|
127
|
-
|
|
128
|
-
compiler.hooks.thisCompilation.tap('RWSSassPlugin', (compilation) => {
|
|
129
|
-
compilation.hooks.buildModule.tap('RWSSassPlugin', (module) => {
|
|
130
|
-
if (module.resource && /\.scss$/.test(module.resource)) {
|
|
131
|
-
|
|
132
|
-
let scssPath = module.resource;
|
|
133
|
-
|
|
134
|
-
this.compileFile(scssPath, true).catch((e) => {
|
|
135
|
-
throw e;
|
|
136
|
-
})
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
127
|
}
|
|
141
128
|
|
|
142
129
|
readSCSSFilesFromDirectory(dirPath) {
|