@rws-framework/client 2.15.4 → 2.15.6
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/builder/webpack/loaders/rws_fast_scss_loader.js +1 -0
- package/builder/webpack/loaders/rws_fast_ts_loader.js +2 -1
- package/builder/webpack/rws.webpack.config.js +2 -2
- package/builder/webpack/rws_scss_plugin.js +2 -2
- package/builder/webpack/scss/_import.js +6 -25
- package/cfg/build_steps/vite/_build_config.ts +17 -19
- package/cfg/build_steps/vite/index.ts +2 -2
- package/cfg/build_steps/webpack/_aliases.js +12 -2
- package/cfg/build_steps/webpack/_build_config.js +2 -1
- package/cfg/build_steps/webpack/_env_defines.js +7 -1
- package/cfg/build_steps/webpack/_info.js +1 -1
- package/cfg/build_steps/webpack/_loaders.js +24 -11
- package/cfg/build_steps/webpack/_parser.js +0 -0
- package/cfg/build_steps/webpack/_rws_externals.js +4 -4
- package/cfg/build_steps/webpack/_webpack_config.js +11 -5
- package/package.json +3 -2
- package/src/client/config.ts +4 -6
- package/src/client.ts +3 -3
- package/src/components/_container.ts +2 -2
- package/src/index.ts +2 -3
- package/src/plugins/_plugin.ts +26 -29
- package/src/services/ConfigService.ts +0 -9
- package/src/types/IRWSConfig.ts +2 -5
- package/src/types/IRWSPlugin.ts +15 -10
|
@@ -9,6 +9,7 @@ module.exports = async function(content) {
|
|
|
9
9
|
const isDev = this._compiler.options.mode === 'development';
|
|
10
10
|
const saveFile = content.indexOf('@save') > -1;
|
|
11
11
|
const plugin = new RWSScssPlugin({
|
|
12
|
+
appRootDir: this.query?.appRootDir,
|
|
12
13
|
rwsWorkspaceDir: this.query?.rwsWorkspaceDir
|
|
13
14
|
});
|
|
14
15
|
let fromTs = false;
|
|
@@ -61,6 +61,7 @@ module.exports = async function(content) {
|
|
|
61
61
|
try {
|
|
62
62
|
if(tagName){
|
|
63
63
|
const [template, htmlFastImports, templateExists] = await LoadersHelper.getTemplate(filePath, this.addDependency, templateName, isDev);
|
|
64
|
+
|
|
64
65
|
const styles = await LoadersHelper.getStyles(filePath, this.query?.rwsWorkspaceDir, this.query?.appRootDir,this.addDependency, templateExists, stylesPath, isDev);
|
|
65
66
|
|
|
66
67
|
if(className){
|
|
@@ -69,7 +70,7 @@ module.exports = async function(content) {
|
|
|
69
70
|
if(replacedViewDecoratorContent){
|
|
70
71
|
processedContent = `${template}\n${styles}\n${replacedViewDecoratorContent}`;
|
|
71
72
|
}
|
|
72
|
-
}
|
|
73
|
+
}
|
|
73
74
|
|
|
74
75
|
processedContent = `${htmlFastImports ? htmlFastImports + '\n' : ''}${processedContent}`;
|
|
75
76
|
}
|
|
@@ -68,7 +68,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
|
|
|
68
68
|
let optimConfig = null;
|
|
69
69
|
let aliases = rwsFrontendConfig.aliases || {};
|
|
70
70
|
|
|
71
|
-
aliases = { ...aliases, ...loadAliases(_packageDir, path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
|
|
71
|
+
aliases = { ...aliases, ...loadAliases(_packageDir, tsConfig,path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
|
|
72
72
|
|
|
73
73
|
// #SECTION PLUGIN STARTING HOOKS
|
|
74
74
|
|
|
@@ -115,7 +115,7 @@ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// #SECTION RWS WEBPACK BUILD
|
|
118
|
-
const cfgExport = createWebpackConfig({
|
|
118
|
+
const cfgExport = await createWebpackConfig({
|
|
119
119
|
executionDir,
|
|
120
120
|
_packageDir,
|
|
121
121
|
isDev,
|
|
@@ -52,7 +52,7 @@ class RWSScssPlugin {
|
|
|
52
52
|
scssPath = _scss_import.processImportPath(scssPath, this.getRWSWorkspaceDir(), this.getRWSRootDir(),path.dirname(scssPath))
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
let scssCode = _scss_fs.getCodeFromFile(scssPath, this.getRWSWorkspaceDir());
|
|
55
|
+
let scssCode = _scss_fs.getCodeFromFile(scssPath, this.getRWSWorkspaceDir(), this.getRWSRootDir());
|
|
56
56
|
|
|
57
57
|
return await _scss_compiler.compileScssCode(scssCode, path.dirname(scssPath), this.getRWSWorkspaceDir(), this.getRWSRootDir());
|
|
58
58
|
}
|
|
@@ -70,7 +70,7 @@ class RWSScssPlugin {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
getRWSRootDir() {
|
|
73
|
-
return this.
|
|
73
|
+
return this.appRootDir;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -13,9 +13,9 @@ function processImportPath(importPath, rwsWorkspaceDir, appRootDir, fileRootDir
|
|
|
13
13
|
_scss_fs = _scss_fs_builder(this);
|
|
14
14
|
const workspaceDir = this.getRWSWorkspaceDir ? this.getRWSWorkspaceDir() : rwsWorkspaceDir;
|
|
15
15
|
const appRoot = this.getRWSWorkspaceDir ? this.getRWSRootDir() : appRootDir;
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
if (importPath.split('')[0] === '~') {
|
|
18
|
-
return fillSCSSExt(replaceWithNodeModules(importPath,
|
|
18
|
+
return fillSCSSExt(replaceWithNodeModules(importPath, appRoot, null, true), noext);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (importPath.indexOf('@rws-mixins') === 0) {
|
|
@@ -67,26 +67,6 @@ function underscorePath(path, noext = false) {
|
|
|
67
67
|
return partSplit.join('/');
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function fillSCSSExt(scssPath, noext = false) {
|
|
71
|
-
const underscoredPath = underscorePath(scssPath, noext);
|
|
72
|
-
if (!fs.existsSync(scssPath) && fs.existsSync(underscoredPath)) {
|
|
73
|
-
return underscoredPath;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (noext) {
|
|
77
|
-
return scssPath;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if ((!fs.existsSync(scssPath) || (fs.existsSync(scssPath) && fs.statSync(scssPath).isDirectory())) && fs.existsSync(`${scssPath}.scss`)) {
|
|
81
|
-
return `${scssPath}.scss`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (fs.existsSync(`_${scssPath}.scss`)) {
|
|
85
|
-
return `${scssPath}.scss`;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return scssPath;
|
|
89
|
-
}
|
|
90
70
|
|
|
91
71
|
function fillSCSSExt(scssPath, noext = false) {
|
|
92
72
|
const underscoredPath = underscorePath(scssPath, noext);
|
|
@@ -157,7 +137,8 @@ function detectImports(code) {
|
|
|
157
137
|
|
|
158
138
|
function replaceWithNodeModules(input, appRootDir, fileDir = null, absolute = false, token = '~') {
|
|
159
139
|
_scss_fs = _scss_fs_builder(this);
|
|
160
|
-
|
|
140
|
+
|
|
141
|
+
return input.replace(token, absolute ? `${path.join(appRootDir, 'node_modules')}/` : this.node_modules_dir(fileDir ? fileDir : appRootDir));
|
|
161
142
|
}
|
|
162
143
|
|
|
163
144
|
function processImports(imports, fileRootDir, rwsWorkspaceDir, importStorage = {}, sub = false) {
|
|
@@ -184,8 +165,8 @@ function processImports(imports, fileRootDir, rwsWorkspaceDir, importStorage = {
|
|
|
184
165
|
const appRoot = this.getRWSWorkspaceDir ? this.getRWSRootDir() : importData[4];
|
|
185
166
|
|
|
186
167
|
let importPath = processImportPath(originalImportPath, workspaceDir, appRoot, fileRootDir);
|
|
187
|
-
|
|
188
|
-
let replacedScssContent = getStorage(importPath, _scss_fs.getCodeFromFile(importPath, workspaceDir).replace(/\/\*[\s\S]*?\*\//g, ''));
|
|
168
|
+
|
|
169
|
+
let replacedScssContent = getStorage(importPath, _scss_fs.getCodeFromFile(importPath, workspaceDir, appRoot).replace(/\/\*[\s\S]*?\*\//g, ''));
|
|
189
170
|
|
|
190
171
|
const recursiveImports = extractScssImports(replacedScssContent, workspaceDir, appRoot, importPath)[0];
|
|
191
172
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { RWSConfigBuilder, rwsPath } from '@rws-framework/console';
|
|
3
|
-
import { _DEFAULT_CONFIG } from '../../_default.cfg';
|
|
3
|
+
// import { _DEFAULT_CONFIG } from '../../_default.cfg';
|
|
4
4
|
|
|
5
|
-
import { IRWSPlugin } from '../../../src/types/IRWSPlugin';
|
|
5
|
+
import { IPluginSpawnOption, IRWSPlugin, IStaticRWSPlugin } from '../../../src/types/IRWSPlugin';
|
|
6
6
|
|
|
7
7
|
interface IRWSViteConfig {
|
|
8
8
|
executionDir: string;
|
|
@@ -24,25 +24,23 @@ interface IRWSViteConfig {
|
|
|
24
24
|
devDebug?: any,
|
|
25
25
|
devRouteProxy?: any,
|
|
26
26
|
tsConfigPath: string,
|
|
27
|
-
rwsPlugins?:
|
|
28
|
-
[key: string]: IRWSPlugin
|
|
29
|
-
},
|
|
27
|
+
rwsPlugins?: IPluginSpawnOption<any>[],
|
|
30
28
|
_packageDir?: string,
|
|
31
29
|
BuildConfigurator: RWSConfigBuilder<any>
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
async function getBuildConfig(rwsFrontBuildConfig): Promise<IRWSViteConfig>
|
|
32
|
+
async function getBuildConfig(rwsFrontBuildConfig: Partial<IRWSViteConfig>): Promise<IRWSViteConfig>
|
|
35
33
|
{
|
|
36
|
-
const BuildConfigurator = new RWSConfigBuilder(rwsPath.findPackageDir(process.cwd()) + '/.rws.json', {...
|
|
34
|
+
const BuildConfigurator = new RWSConfigBuilder(rwsPath.findPackageDir(process.cwd()) + '/.rws.json', {...rwsFrontBuildConfig});
|
|
37
35
|
const _packageDir = rwsPath.findPackageDir(process.cwd());
|
|
38
36
|
|
|
39
37
|
const executionDir = rwsPath.relativize(BuildConfigurator.get('executionDir') || rwsFrontBuildConfig.executionDir || process.cwd(), _packageDir);
|
|
40
38
|
const isWatcher = process.argv.includes('--watch') || false;
|
|
41
39
|
|
|
42
|
-
const isDev = isWatcher ? true : (BuildConfigurator.get('dev', rwsFrontBuildConfig.
|
|
43
|
-
const isHotReload = BuildConfigurator.get('
|
|
44
|
-
const isReport = BuildConfigurator.get('
|
|
45
|
-
const isParted = BuildConfigurator.get('
|
|
40
|
+
const isDev = isWatcher ? true : (BuildConfigurator.get('dev', rwsFrontBuildConfig.isDev) || false);
|
|
41
|
+
const isHotReload = BuildConfigurator.get('isHotReload', rwsFrontBuildConfig.isHotReload);
|
|
42
|
+
const isReport = BuildConfigurator.get('isReport', rwsFrontBuildConfig.isReport);
|
|
43
|
+
const isParted = BuildConfigurator.get('isParted', rwsFrontBuildConfig.isParted || false);
|
|
46
44
|
|
|
47
45
|
const partedPrefix = BuildConfigurator.get('partedPrefix', rwsFrontBuildConfig.partedPrefix);
|
|
48
46
|
const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix', rwsFrontBuildConfig.partedDirUrlPrefix);
|
|
@@ -53,7 +51,7 @@ async function getBuildConfig(rwsFrontBuildConfig): Promise<IRWSViteConfig>
|
|
|
53
51
|
|
|
54
52
|
const outputFileName = BuildConfigurator.get('outputFileName') || rwsFrontBuildConfig.outputFileName;
|
|
55
53
|
const publicDir = BuildConfigurator.get('publicDir') || rwsFrontBuildConfig.publicDir;
|
|
56
|
-
const serviceWorkerPath = BuildConfigurator.get('
|
|
54
|
+
const serviceWorkerPath = BuildConfigurator.get('serviceWorkerPath') || rwsFrontBuildConfig.serviceWorkerPath;
|
|
57
55
|
|
|
58
56
|
const publicIndex = BuildConfigurator.get('publicIndex') || rwsFrontBuildConfig.publicIndex;
|
|
59
57
|
|
|
@@ -68,14 +66,14 @@ async function getBuildConfig(rwsFrontBuildConfig): Promise<IRWSViteConfig>
|
|
|
68
66
|
|
|
69
67
|
const tsConfigPath = rwsPath.relativize(BuildConfigurator.get('tsConfigPath') || rwsFrontBuildConfig.tsConfigPath, executionDir);
|
|
70
68
|
|
|
71
|
-
const rwsPlugins =
|
|
69
|
+
const rwsPlugins: IPluginSpawnOption<any>[] = [];
|
|
72
70
|
|
|
73
|
-
if(rwsFrontBuildConfig.rwsPlugins){
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
// if(rwsFrontBuildConfig.rwsPlugins){
|
|
72
|
+
// for(const pluginEntry of Object.values(rwsFrontBuildConfig.rwsPlugins)){
|
|
73
|
+
// const pluginBuilder = (await import(`${pluginEntry}`)).default as IStaticRWSPlugin<any>;
|
|
74
|
+
// rwsPlugins[pluginEntry] = new pluginBuilder(BuildConfigurator, rwsFrontBuildConfig);
|
|
75
|
+
// }
|
|
76
|
+
// }
|
|
79
77
|
|
|
80
78
|
return {
|
|
81
79
|
executionDir,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getBuildConfig } from './_build_config';
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { getBuildConfig };
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
|
|
3
|
-
function loadAliases(packageDir, nodeModulesPath,
|
|
3
|
+
function loadAliases(packageDir, tsConfig, nodeModulesPath, executionDir){
|
|
4
|
+
|
|
5
|
+
const tsPaths = {}
|
|
6
|
+
|
|
7
|
+
for(const aliasKey of Object.keys(tsConfig.config.compilerOptions.paths)){
|
|
8
|
+
const alias = tsConfig.config.compilerOptions.paths[aliasKey];
|
|
9
|
+
tsPaths[aliasKey] = path.resolve(executionDir, alias[0]);
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
return {
|
|
5
|
-
|
|
13
|
+
...tsPaths,
|
|
14
|
+
'@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js'),
|
|
15
|
+
'@rws-framework/foundation/*': path.resolve(packageDir, 'foundation', '*')
|
|
6
16
|
}
|
|
7
17
|
}
|
|
8
18
|
|
|
@@ -5,6 +5,7 @@ const { RWSConfigBuilder } = require('@rws-framework/console')
|
|
|
5
5
|
const { rwsPath } = require('@rws-framework/console');
|
|
6
6
|
const { _DEFAULT_CONFIG } = require('../../_default.cfg');
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
|
|
9
10
|
const BuildConfigurator = new RWSConfigBuilder(path.join(rwsPath.findPackageDir(process.cwd()), '.rws.json'), {..._DEFAULT_CONFIG, ...rwsFrontBuildConfig});
|
|
10
11
|
const executionDir = rwsPath.relativize(BuildConfigurator.get('executionDir') || rwsFrontBuildConfig.executionDir || process.env.RWS_APP_ROOT || process.cwd(), _packageDir);
|
|
@@ -37,7 +38,7 @@ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
|
|
|
37
38
|
|
|
38
39
|
const devRouteProxy = BuildConfigurator.get('devRouteProxy') || rwsFrontBuildConfig.devRouteProxy;
|
|
39
40
|
|
|
40
|
-
const tsConfig = BuildConfigurator.get('tsConfig') || rwsFrontBuildConfig.tsConfig;
|
|
41
|
+
const tsConfig = await (BuildConfigurator.get('tsConfig') || rwsFrontBuildConfig.tsConfig)(_packageDir, true, false);
|
|
41
42
|
|
|
42
43
|
const rwsPlugins = {};
|
|
43
44
|
|
|
@@ -10,8 +10,14 @@ function processEnvDefines(BuildConfigurator, config, devDebug) {
|
|
|
10
10
|
const rwsDefines = BuildConfigurator.get('env') || config.env || null;
|
|
11
11
|
|
|
12
12
|
if (rwsDefines) {
|
|
13
|
-
|
|
13
|
+
const stringifiedDefines = Object.entries(rwsDefines).reduce((acc, [key, value]) => ({
|
|
14
|
+
...acc,
|
|
15
|
+
[`process.env.${key}`]: JSON.stringify(value)
|
|
16
|
+
}), {});
|
|
17
|
+
_rws_defines = { ..._rws_defines, ...stringifiedDefines }
|
|
14
18
|
}
|
|
19
|
+
|
|
20
|
+
console.log({_rws_defines});
|
|
15
21
|
|
|
16
22
|
return _rws_defines;
|
|
17
23
|
}
|
|
@@ -10,11 +10,13 @@ const chalk = require('chalk');
|
|
|
10
10
|
const { timingCounterStart, timingCounterStop } = require('./_timing');
|
|
11
11
|
const { rwsRuntimeHelper, rwsPath } = require('@rws-framework/console');
|
|
12
12
|
|
|
13
|
-
function getRWSLoaders(packageDir, executionDir,
|
|
13
|
+
function getRWSLoaders(packageDir, executionDir, tsConfigData, appRootDir, entrypoint) {
|
|
14
14
|
const scssLoader = path.join(packageDir, 'builder/webpack/loaders/rws_fast_scss_loader.js');
|
|
15
15
|
const tsLoader = path.join(packageDir, 'builder/webpack/loaders/rws_fast_ts_loader.js');
|
|
16
16
|
const htmlLoader = path.join(packageDir, 'builder/webpack/loaders/rws_fast_html_loader.js');
|
|
17
17
|
|
|
18
|
+
const tsConfigPath = tsConfigData.path;
|
|
19
|
+
|
|
18
20
|
const loaders = [
|
|
19
21
|
{
|
|
20
22
|
test: /\.html$/,
|
|
@@ -30,14 +32,20 @@ function getRWSLoaders(packageDir, executionDir, tsConfig, appRootDir, entrypoin
|
|
|
30
32
|
{
|
|
31
33
|
loader: 'ts-loader',
|
|
32
34
|
options: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
configFile: tsConfigPath,
|
|
36
|
+
compilerOptions: {
|
|
37
|
+
emitDecoratorMetadata: true,
|
|
38
|
+
experimentalDecorators: true,
|
|
39
|
+
target: "ES2018",
|
|
40
|
+
module: "commonjs"
|
|
41
|
+
},
|
|
35
42
|
transpileOnly: false,
|
|
36
43
|
logLevel: "info",
|
|
37
44
|
logInfoToStdOut: true,
|
|
38
45
|
context: executionDir,
|
|
39
46
|
errorFormatter: (message, colors) => {
|
|
40
|
-
|
|
47
|
+
console.log({message});
|
|
48
|
+
const messageText = typeof message === 'object' ? JSON.stringify(message, null, 2) : message;
|
|
41
49
|
return `\nTS Error: ${messageText}\n`;
|
|
42
50
|
},
|
|
43
51
|
}
|
|
@@ -51,20 +59,25 @@ function getRWSLoaders(packageDir, executionDir, tsConfig, appRootDir, entrypoin
|
|
|
51
59
|
}
|
|
52
60
|
],
|
|
53
61
|
include: [
|
|
54
|
-
|
|
55
|
-
path.resolve(packageDir, '
|
|
56
|
-
path.resolve(packageDir, 'foundation', 'rws-foundation.d.ts')
|
|
62
|
+
...tsConfigData.includes.map(item => item.abs()),
|
|
63
|
+
path.resolve(packageDir, 'foundation', 'rws-foundation.d.ts')
|
|
57
64
|
],
|
|
58
|
-
exclude: [
|
|
59
|
-
|
|
65
|
+
exclude: [
|
|
66
|
+
...tsConfigData.excludes.map(item => item.abs()),
|
|
60
67
|
/\.debug\.ts$/,
|
|
61
68
|
/\.d\.ts$/
|
|
62
|
-
]
|
|
69
|
+
]
|
|
63
70
|
},
|
|
64
71
|
{
|
|
65
72
|
test: /\.scss$/i,
|
|
66
73
|
use: [
|
|
67
|
-
|
|
74
|
+
{
|
|
75
|
+
loader: scssLoader,
|
|
76
|
+
options: {
|
|
77
|
+
rwsWorkspaceDir: executionDir,
|
|
78
|
+
appRootDir
|
|
79
|
+
}
|
|
80
|
+
},
|
|
68
81
|
],
|
|
69
82
|
},
|
|
70
83
|
];
|
|
File without changes
|
|
@@ -12,7 +12,7 @@ const _defaultOpts = {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const externals = (
|
|
15
|
+
const externals = (declaredCodeBase, nodeModules, automatedChunks, externalOptions = _defaultOpts) => ({context, request}, callback) => {
|
|
16
16
|
let theOptions = _defaultOpts;
|
|
17
17
|
|
|
18
18
|
if(externalOptions !== null){
|
|
@@ -25,18 +25,18 @@ const externals = (pkgPath, declaredCodeBase, nodeModules, automatedChunks, exte
|
|
|
25
25
|
// /css-loader/,
|
|
26
26
|
/tslib/,
|
|
27
27
|
/reflect-metadata/,
|
|
28
|
-
/\@microsoft\/fast-foundation\/.*/
|
|
28
|
+
/\@microsoft\/fast-foundation\/.*/
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
const enforced = [
|
|
32
32
|
/entities/,
|
|
33
33
|
/\@microsoft\/fast-foundation\/.*\/di/,
|
|
34
|
-
/\@microsoft\/fast-foundation\/.*\/foundation-element
|
|
34
|
+
/\@microsoft\/fast-foundation\/.*\/foundation-element/,
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
const frontendDirs = [
|
|
38
38
|
codeBase,
|
|
39
|
-
|
|
39
|
+
path.resolve(__dirname,'..','..','..')
|
|
40
40
|
];
|
|
41
41
|
|
|
42
42
|
const inFrontendContext = frontendDirs.some(dir => context.startsWith(dir)) ||
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const { getRWSLoaders } = require('./_loaders');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
async function createWebpackConfig({
|
|
5
6
|
executionDir,
|
|
6
7
|
_packageDir,
|
|
7
8
|
isDev,
|
|
@@ -20,7 +21,8 @@ function createWebpackConfig({
|
|
|
20
21
|
devExternalsVars,
|
|
21
22
|
appRootDir,
|
|
22
23
|
entrypoint
|
|
23
|
-
}) {
|
|
24
|
+
}) {
|
|
25
|
+
|
|
24
26
|
return {
|
|
25
27
|
context: executionDir,
|
|
26
28
|
entry: {
|
|
@@ -39,15 +41,19 @@ function createWebpackConfig({
|
|
|
39
41
|
modules: modules_setup,
|
|
40
42
|
alias: {
|
|
41
43
|
...aliases
|
|
44
|
+
},
|
|
45
|
+
fallback: {
|
|
46
|
+
fs: false,
|
|
47
|
+
path: false
|
|
42
48
|
}
|
|
43
49
|
},
|
|
44
50
|
module: {
|
|
45
51
|
rules: getRWSLoaders(_packageDir, executionDir, tsConfig, appRootDir, entrypoint),
|
|
46
52
|
},
|
|
47
53
|
plugins: WEBPACK_PLUGINS,
|
|
48
|
-
externals: rwsExternals(_packageDir, executionDir, modules_setup, automatedChunks, {
|
|
49
|
-
|
|
50
|
-
})
|
|
54
|
+
// externals: rwsExternals(_packageDir, executionDir, modules_setup, automatedChunks, {
|
|
55
|
+
// _vars: devExternalsVars
|
|
56
|
+
// })
|
|
51
57
|
}
|
|
52
58
|
}
|
|
53
59
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rws-framework/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.15.
|
|
4
|
+
"version": "2.15.6",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"docs": "typedoc --tsconfig ./tsconfig.json"
|
|
@@ -105,5 +105,6 @@
|
|
|
105
105
|
},
|
|
106
106
|
"overrides": {
|
|
107
107
|
"lodash": "^4.17.21"
|
|
108
|
-
}
|
|
108
|
+
},
|
|
109
|
+
"_rws": true
|
|
109
110
|
}
|
package/src/client/config.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { RWSClientInstance } from "../client";
|
|
|
4
4
|
import { RWSPlugin, DefaultRWSPluginOptionsType } from "../plugins/_plugin";
|
|
5
5
|
import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
|
|
6
6
|
import deepmerge from 'deepmerge';
|
|
7
|
+
import { IPluginSpawnOption } from "../types/IRWSPlugin";
|
|
7
8
|
|
|
8
9
|
type RWSInfoType = { components: string[] };
|
|
9
10
|
|
|
@@ -72,15 +73,12 @@ function get(this: RWSClientInstance, key: string): any | null
|
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
type RWSPluginEntry<T extends DefaultRWSPluginOptionsType = DefaultRWSPluginOptionsType> = IStaticRWSPlugin<T>;
|
|
77
|
-
|
|
78
|
-
function addPlugin<T extends DefaultRWSPluginOptionsType>(this: RWSClientInstance, pluginEntry: RWSPluginEntry){
|
|
76
|
+
function addPlugin<T extends DefaultRWSPluginOptionsType>(this: RWSClientInstance, pluginEntry: IPluginSpawnOption<T>){
|
|
79
77
|
const rwsWindow: RWSWindow = loadRWSRichWindow();
|
|
80
|
-
const pluginClass:
|
|
78
|
+
const pluginClass: IStaticRWSPlugin<T> = pluginEntry.pluginEntry;
|
|
81
79
|
const pluginOptions: T = (Array.isArray(pluginEntry) ? pluginEntry[1] : { enabled: true }) as T;
|
|
82
80
|
|
|
83
|
-
if(!Object.keys(rwsWindow.RWS.plugins).
|
|
81
|
+
if(!Object.keys(rwsWindow.RWS.plugins).find(item => { item === pluginClass.name })){
|
|
84
82
|
const pluginInstance: RWSPlugin<T> = new pluginClass(pluginOptions);
|
|
85
83
|
this.plugins[pluginClass.name] = pluginInstance;
|
|
86
84
|
rwsWindow.RWS.plugins[pluginClass.name] = pluginInstance;
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import IRWSConfig
|
|
1
|
+
import IRWSConfig from './types/IRWSConfig';
|
|
2
2
|
|
|
3
3
|
import RWSNotify from './types/RWSNotify';
|
|
4
4
|
|
|
@@ -74,9 +74,9 @@ class RWSClient {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
addPlugin<T extends DefaultRWSPluginOptionsType>(pluginEntry: IStaticRWSPlugin)
|
|
77
|
+
addPlugin<T extends DefaultRWSPluginOptionsType>(pluginEntry: IStaticRWSPlugin<T>, options?: T)
|
|
78
78
|
{
|
|
79
|
-
this.config.plugins.push(pluginEntry);
|
|
79
|
+
this.config.plugins.push({pluginEntry, options});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async setup(config: IRWSConfig = {}): Promise<IRWSConfig> {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {DI, Container, Registration } from '../../foundation/rws-foundation';
|
|
1
|
+
import {DI, Container, Registration, InterfaceSymbol, Key } from '../../foundation/rws-foundation';
|
|
2
2
|
import {loadRWSRichWindow} from '../types/RWSWindow';
|
|
3
3
|
|
|
4
4
|
export default () => {
|
|
@@ -13,4 +13,4 @@ export default () => {
|
|
|
13
13
|
return richWindow.RWS.container;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export { DI, Container, Registration }
|
|
16
|
+
export { DI, Container, Registration, InterfaceSymbol, Key }
|
package/src/index.ts
CHANGED
|
@@ -21,9 +21,8 @@ import { RWSPlugin } from './plugins/_plugin';
|
|
|
21
21
|
|
|
22
22
|
import type { DefaultRWSPluginOptionsType } from './plugins/_plugin';
|
|
23
23
|
|
|
24
|
-
import type { IRWSPlugin, IStaticRWSPlugin } from './types/IRWSPlugin';
|
|
24
|
+
import type { IRWSPlugin, IStaticRWSPlugin, IPluginSpawnOption } from './types/IRWSPlugin';
|
|
25
25
|
import RWSClient, { RWSClientInstance } from './client';
|
|
26
|
-
import type { RWSPluginEntry } from './types/IRWSConfig';
|
|
27
26
|
import type IRWSUser from './types/IRWSUser';
|
|
28
27
|
import RWSViewComponent from './components/_component';
|
|
29
28
|
import type { IAssetShowOptions } from './components/_component';
|
|
@@ -42,7 +41,7 @@ export {
|
|
|
42
41
|
RWSClientInstance,
|
|
43
42
|
|
|
44
43
|
RWSPlugin,
|
|
45
|
-
|
|
44
|
+
IPluginSpawnOption,
|
|
46
45
|
IRWSPlugin, IStaticRWSPlugin,
|
|
47
46
|
DefaultRWSPluginOptionsType,
|
|
48
47
|
|
package/src/plugins/_plugin.ts
CHANGED
|
@@ -3,62 +3,59 @@ import { Container } from "../components/_container";
|
|
|
3
3
|
import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
|
|
4
4
|
import IRWSUser from "../types/IRWSUser";
|
|
5
5
|
import { RWSInfoType } from "../client/components";
|
|
6
|
-
import { IRWSPlugin } from "../types/IRWSPlugin";
|
|
6
|
+
import { IRWSPlugin, IStaticRWSPlugin } from "../types/IRWSPlugin";
|
|
7
7
|
|
|
8
|
-
type DefaultRWSPluginOptionsType = { enabled
|
|
9
|
-
type PluginInfoType = { name: string }
|
|
8
|
+
export type DefaultRWSPluginOptionsType = { enabled?: boolean };
|
|
9
|
+
type PluginInfoType = { name: string };
|
|
10
10
|
type PluginConstructor<T extends DefaultRWSPluginOptionsType> = new (options: T) => RWSPlugin<T>;
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
abstract class RWSPlugin<T extends DefaultRWSPluginOptionsType> extends IRWSPlugin<T> {
|
|
12
13
|
protected isLoaded: boolean = false;
|
|
13
|
-
protected options
|
|
14
|
-
protected container
|
|
15
|
-
protected window
|
|
14
|
+
protected options!: T;
|
|
15
|
+
protected container!: Container;
|
|
16
|
+
protected window!: RWSWindow;
|
|
16
17
|
|
|
17
18
|
static container: Container;
|
|
18
19
|
static window: RWSWindow;
|
|
19
20
|
|
|
20
|
-
constructor(options:
|
|
21
|
+
constructor(options: T = { enabled: true } as T) {
|
|
22
|
+
super();
|
|
21
23
|
this.isLoaded = true;
|
|
22
24
|
this.container = RWSPlugin.container;
|
|
23
25
|
this.window = RWSPlugin.window;
|
|
24
26
|
this.options = options;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
|
-
async onClientStart(): Promise<void>
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
async onClientStart(): Promise<void> {
|
|
30
|
+
// Implementation
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
async onPartedComponentsLoad(componentParts: RWSInfoType): Promise<void>
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
async onPartedComponentsLoad(componentParts: RWSInfoType): Promise<void> {
|
|
34
|
+
// Implementation
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
async onComponentsDeclare(): Promise<void>
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
async onComponentsDeclare(): Promise<void> {
|
|
38
|
+
// Implementation
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
async onSetUser(user: IRWSUser): Promise<void>{
|
|
43
|
-
|
|
41
|
+
async onSetUser(user: IRWSUser): Promise<void> {
|
|
42
|
+
// Implementation
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
45
|
+
static getPlugin<P extends RWSPlugin<T>, T extends DefaultRWSPluginOptionsType = DefaultRWSPluginOptionsType>(
|
|
46
|
+
pluginClass: IStaticRWSPlugin<T>
|
|
47
|
+
): P | null {
|
|
50
48
|
const plugin = this.window.RWS.plugins[pluginClass.name];
|
|
51
|
-
return plugin ? plugin as
|
|
49
|
+
return plugin ? plugin as P : null;
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return Object.keys(this.window.RWS.plugins).map((key) => this.window.RWS.plugins[key]);
|
|
52
|
+
static getAllPlugins(): Array<RWSPlugin<DefaultRWSPluginOptionsType>> {
|
|
53
|
+
return Object.keys(this.window.RWS.plugins)
|
|
54
|
+
.map((key) => this.window.RWS.plugins[key]);
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
RWSPlugin.window = loadRWSRichWindow();
|
|
62
59
|
RWSPlugin.container = RWSContainer();
|
|
63
60
|
|
|
64
|
-
export { RWSPlugin
|
|
61
|
+
export { RWSPlugin };
|
|
@@ -68,15 +68,6 @@ class ConfigService extends TheService {
|
|
|
68
68
|
public set<V extends keyof IRWSConfig>(key: V, value: IRWSConfig[V]){
|
|
69
69
|
this.data[key] = value;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
public async reloadConfig(cfgString: string): Promise<ConfigService>
|
|
73
|
-
{
|
|
74
|
-
const module = await import(/* webpackIgnore: true */ cfgString);
|
|
75
|
-
const cfg: () => IRWSConfig = module.defaults;
|
|
76
|
-
this.data = cfg();
|
|
77
|
-
|
|
78
|
-
return this;
|
|
79
|
-
}
|
|
80
71
|
|
|
81
72
|
async waitForConfig(tagName: string): Promise<boolean>
|
|
82
73
|
{
|
package/src/types/IRWSConfig.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import RWSViewComponent from '../components/_component';
|
|
2
|
-
import {
|
|
3
|
-
import { IStaticRWSPlugin } from './IRWSPlugin';
|
|
2
|
+
import { IPluginSpawnOption } from './IRWSPlugin';
|
|
4
3
|
|
|
5
4
|
export type IFrontRoutes = Record<string, unknown>;
|
|
6
|
-
export type RWSPluginEntry<T extends DefaultRWSPluginOptionsType = DefaultRWSPluginOptionsType> = new (...args: any[]) => RWSPlugin<T>;
|
|
7
|
-
|
|
8
5
|
export default interface IRWSConfig {
|
|
9
6
|
[key: string]: any
|
|
10
7
|
dev?: boolean
|
|
@@ -25,7 +22,7 @@ export default interface IRWSConfig {
|
|
|
25
22
|
rwsDefines?: {[key: string]: any}
|
|
26
23
|
partedFileDir?: string
|
|
27
24
|
partedPrefix?: string
|
|
28
|
-
plugins?:
|
|
25
|
+
plugins?: IPluginSpawnOption<any>[]
|
|
29
26
|
routing_enabled?: boolean
|
|
30
27
|
_noLoad?: boolean
|
|
31
28
|
}
|
package/src/types/IRWSPlugin.ts
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { DefaultRWSPluginOptionsType } from "../plugins/_plugin";
|
|
1
|
+
import { DefaultRWSPluginOptionsType, RWSPlugin } from "../plugins/_plugin";
|
|
2
2
|
import IRWSUser from "./IRWSUser";
|
|
3
3
|
import { Container } from "../components/_container";
|
|
4
4
|
import RWSWindow from "./RWSWindow";
|
|
5
5
|
import { RWSInfoType } from "../client/components";
|
|
6
6
|
|
|
7
|
+
export abstract class IRWSPlugin<T extends DefaultRWSPluginOptionsType> {
|
|
8
|
+
abstract onClientStart(): Promise<void>;
|
|
9
|
+
abstract onPartedComponentsLoad(componentParts: RWSInfoType): Promise<void>;
|
|
10
|
+
abstract onComponentsDeclare(): Promise<void>;
|
|
11
|
+
abstract onSetUser(user: IRWSUser): Promise<void>;
|
|
12
|
+
protected abstract options: T;
|
|
13
|
+
protected abstract container: Container;
|
|
14
|
+
protected abstract window: RWSWindow;
|
|
15
|
+
}
|
|
7
16
|
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
onPartedComponentsLoad(componentParts: RWSInfoType): Promise<void>
|
|
11
|
-
onComponentsDeclare(): Promise<void>
|
|
12
|
-
onSetUser(user: IRWSUser): Promise<void>
|
|
17
|
+
export interface IStaticRWSPlugin<T extends DefaultRWSPluginOptionsType> {
|
|
18
|
+
new (options: T): RWSPlugin<T>;
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
export interface
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
window: RWSWindow;
|
|
21
|
+
export interface IPluginSpawnOption<T extends DefaultRWSPluginOptionsType = DefaultRWSPluginOptionsType> {
|
|
22
|
+
pluginEntry: IStaticRWSPlugin<T>;
|
|
23
|
+
options?: T;
|
|
19
24
|
}
|