@rws-framework/client 2.2.1 → 2.2.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.
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const json5 = require('json5');
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const _STORAGE = { _loaded: false }
|
|
6
|
+
|
|
7
|
+
const _DEFAULT_CONFIG = {
|
|
8
|
+
dev: false,
|
|
9
|
+
hot: false,
|
|
10
|
+
report: false,
|
|
11
|
+
backendUrl: null,
|
|
12
|
+
wsUrl: null,
|
|
13
|
+
transports: ['websocket'],
|
|
14
|
+
parted: true,
|
|
15
|
+
partedFileDir: './build',
|
|
16
|
+
partedPrefix: 'rws',
|
|
17
|
+
publicDir: './public',
|
|
18
|
+
publicIndex: 'index.html',
|
|
19
|
+
pubUrlPrefix: '/',
|
|
20
|
+
outputFileName: 'client.rws.js'
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readConfigFile(filePath){
|
|
24
|
+
const fileConfig = json5.parse(fs.readFileSync(filePath, 'utf-8'));
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
..._DEFAULT_CONFIG,
|
|
28
|
+
...fileConfig
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function get(key){
|
|
33
|
+
if(!_STORAGE._loaded){
|
|
34
|
+
Object.assign(_STORAGE, readConfigFile(process.cwd() + '/.rws.json'));
|
|
35
|
+
|
|
36
|
+
console.log(_STORAGE);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if(Object.keys(_STORAGE).includes(key)){
|
|
40
|
+
return _STORAGE[key];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
readConfigFile,
|
|
49
|
+
get,
|
|
50
|
+
_DEFAULT_CONFIG
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rws-framework/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.2",
|
|
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
|
@@ -11,6 +11,7 @@ const { Console } = require('console');
|
|
|
11
11
|
const { Interface } = require('readline');
|
|
12
12
|
const ts = require('typescript');
|
|
13
13
|
const tools = require('./_tools');
|
|
14
|
+
const BuildConfigurator = require('./_rws_build_configurator');
|
|
14
15
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
15
16
|
const HtmlMinifier = require('html-minifier').minify;
|
|
16
17
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
@@ -46,16 +47,18 @@ let WEBPACK_PLUGINS = [];
|
|
|
46
47
|
const RWSWebpackWrapper = (config) => {
|
|
47
48
|
const executionDir = config.executionDir || process.cwd();
|
|
48
49
|
|
|
49
|
-
const isDev = config.dev;
|
|
50
|
-
const isHotReload = config.hot;
|
|
51
|
-
const isReport = config.report;
|
|
50
|
+
const isDev = config.dev || BuildConfigurator.get('dev');
|
|
51
|
+
const isHotReload = config.hot || BuildConfigurator.get('hot');
|
|
52
|
+
const isReport = config.report || BuildConfigurator.get('report');
|
|
53
|
+
const outputDir = config.outputDir || BuildConfigurator.get('outputDir');
|
|
54
|
+
const outputFileName = config.outputFileName || BuildConfigurator.get('outputFileName');
|
|
52
55
|
|
|
53
|
-
const publicDir = config.publicDir
|
|
54
|
-
const serviceWorkerPath = config.serviceWorker
|
|
56
|
+
const publicDir = config.publicDir || BuildConfigurator.get('publicDir');
|
|
57
|
+
const serviceWorkerPath = config.serviceWorker || BuildConfigurator.get('serviceWorker');
|
|
55
58
|
|
|
56
59
|
const WEBPACK_AFTER_ACTIONS = config.actions || [];
|
|
57
60
|
|
|
58
|
-
const publicIndex = config.publicIndex ||
|
|
61
|
+
const publicIndex = config.publicIndex || BuildConfigurator.get('publicIndex');
|
|
59
62
|
|
|
60
63
|
const aliases = config.aliases = {};
|
|
61
64
|
|
|
@@ -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('pubUrlPrefix') + file).then((response: string) => {
|
|
85
85
|
this.fileAssets = { ...this.fileAssets, [file]: html`${response}` };
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Key } from '@microsoft/fast-foundation';
|
|
2
|
+
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
import IRWSConfig from '../../interfaces/IRWSConfig';
|
|
5
|
+
|
|
6
|
+
type FillBuildDecoratorReturnType = (target: any, key?: string | number | undefined, parameterIndex?: number) => void;
|
|
7
|
+
|
|
8
|
+
function RWSFillBuildConfig(dependencyClass: Key): FillBuildDecoratorReturnType {
|
|
9
|
+
return (target: IRWSConfig, key?: string | number, parameterIndex?: number) => {
|
|
10
|
+
console.log('ONBUILD', target, key, parameterIndex);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { RWSFillBuildConfig }
|
|
@@ -12,11 +12,11 @@ export default interface IRWSConfig {
|
|
|
12
12
|
user?: any
|
|
13
13
|
ignoreRWSComponents?: boolean
|
|
14
14
|
pubUrl?: string
|
|
15
|
-
|
|
15
|
+
pubUrlPrefix?: string
|
|
16
16
|
dontPushToSW?: boolean
|
|
17
17
|
parted?: boolean
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
partedFileDir?: string
|
|
19
|
+
partedPrefix?: string
|
|
20
20
|
routing_enabled?: boolean
|
|
21
21
|
_noLoad?: boolean
|
|
22
22
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import TheService from './_service';
|
|
2
2
|
import IRWSConfig from '../interfaces/IRWSConfig';
|
|
3
|
+
import { RWSFillBuildConfig } from '../components/_decorators/RWSFillBuildConfig';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
const _DEFAULTS:
|
|
6
|
-
|
|
5
|
+
@RWSFillBuildConfig()
|
|
6
|
+
const _DEFAULTS: IRWSConfig = {
|
|
7
|
+
pubUrlPrefix: '/',
|
|
7
8
|
pubUrl : window.origin,
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
partedFileDir: '/',
|
|
10
|
+
partedPrefix: 'rws'
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const __SENT_TO_COMPONENTS: string[] = [];
|