@rws-framework/client 2.4.2 → 2.5.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/.eslintrc.json CHANGED
@@ -18,9 +18,7 @@
18
18
  "rules": {
19
19
  "no-unused-vars": "off",
20
20
  "no-prototype-builtins": "off",
21
- "no-case-declarations": "off",
22
- "unused-imports/no-unused-imports": "error",
23
- "unused-imports/no-unused-vars": ["warn", { "vars": "all", "args": "none"}],
21
+ "no-case-declarations": "off",
24
22
  "@typescript-eslint/no-var-requires": "off",
25
23
  "@typescript-eslint/semi": ["error", "always"],
26
24
  "@typescript-eslint/no-unused-vars": "off",
@@ -15,9 +15,7 @@
15
15
  "rules": {
16
16
  "no-case-declarations": "off",
17
17
  "no-unused-vars": "off",
18
- "no-prototype-builtins": "off",
19
- "unused-imports/no-unused-imports": "error",
20
- "unused-imports/no-unused-vars": ["warn", { "vars": "all", "args": "none"}],
18
+ "no-prototype-builtins": "off",
21
19
  "@typescript-eslint/no-var-requires": "off",
22
20
  "@typescript-eslint/semi": ["error", "always"],
23
21
  "@typescript-eslint/no-unused-vars": "off",
package/_tools.js CHANGED
@@ -3,6 +3,7 @@ const fs = require('fs');
3
3
  const ts = require('typescript');
4
4
  const { spawn } = require('child_process');
5
5
  const JSON5 = require('json5');
6
+ const chalk = require('chalk');
6
7
 
7
8
  function findRootWorkspacePath(currentPath) {
8
9
  const parentPackageJsonPath = path.join(currentPath + '/..', 'package.json');
@@ -329,6 +330,57 @@ function getAllFilesInFolder(folderPath, ignoreFilenames = [], recursive = false
329
330
  return files;
330
331
  }
331
332
 
333
+ function setupTsConfig(tsConfigPath)
334
+ {
335
+
336
+ if(!fs.existsSync(tsConfigPath)){
337
+ throw new Error(`Typescript config file "${tsConfigPath}" does not exist`);
338
+ }
339
+
340
+ const tsConfigContents = fs.readFileSync(tsConfigPath, 'utf-8');
341
+
342
+ try{
343
+ const tsConfig = JSON.parse(tsConfigContents);
344
+
345
+ const declarationsPath = path.resolve(__dirname, 'types') + '/declarations.d.ts';
346
+ const testsPath = path.resolve(__dirname, 'tests');
347
+
348
+ let changed = false;
349
+
350
+ if(!Object.keys(tsConfig).includes('include')){
351
+ tsConfig['include'] = [];
352
+ }
353
+
354
+ if(!Object.keys(tsConfig).includes('exclude')){
355
+ tsConfig['exclude'] = [];
356
+ }
357
+
358
+ if(!tsConfig['include'].includes(declarationsPath)){
359
+ console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS typescript declarations to project tsconfig.json');
360
+ tsConfig['include'].push(declarationsPath);
361
+ changed = true;
362
+ }
363
+
364
+ if(!tsConfig['exclude'].includes(testsPath)){
365
+ console.log(chalk.blueBright('[RWS TS CONFIG]'), 'adding RWS typescript exclusions to project tsconfig.json');
366
+ tsConfig['exclude'].push(testsPath);
367
+ changed = true;
368
+ }
369
+
370
+ if(changed){
371
+ fs.writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
372
+ console.log(chalk.yellowBright('Typescript config file'), `"${chalk.blueBright(tsConfigPath)}"`, chalk.yellowBright('has been changed'));
373
+ }
374
+
375
+ return true;
376
+ } catch (e) {
377
+ console.log(chalk.red('Error in tsconfig.json:'));
378
+ console.log(chalk.blueBright(e.message));
379
+
380
+ return false;
381
+ }
382
+ }
383
+
332
384
  module.exports = {
333
385
  findRootWorkspacePath,
334
386
  findPackageDir,
@@ -340,5 +392,6 @@ module.exports = {
340
392
  extractRWSIgnoreArguments,
341
393
  findServiceFilesWithClassExtend,
342
394
  findSuperclassFilePath,
343
- getAllFilesInFolder
395
+ getAllFilesInFolder,
396
+ setupTsConfig
344
397
  }
package/bun.lockb ADDED
Binary file
@@ -6,7 +6,7 @@ const _DEFAULT_CONFIG_VARS = {
6
6
  publicDir: './public',
7
7
  publicIndex: 'index.html',
8
8
  outputFileName: 'client.rws.js',
9
- outputDir: process.cwd() + '/build',
9
+ outputDir: './build',
10
10
  //Frontend RWS client configs
11
11
  backendUrl: null,
12
12
  wsUrl: null,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.4.2",
4
+ "version": "2.5.0",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -28,11 +28,12 @@
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
+ "@rws-framework/console": "^0.2.2",
32
32
  "@types/moment": "^2.13.0",
33
33
  "dragula": "^3.7.3",
34
34
  "he": "^1.2.0",
35
35
  "json5": "^2.2.3",
36
+ "lodash": "^4.17.21",
36
37
  "moment": "^2.29.4",
37
38
  "partial-json-parser": "^1.0.0",
38
39
  "reflect-metadata": "^0.1.13",
@@ -50,25 +51,19 @@
50
51
  "v4": "^0.0.1"
51
52
  },
52
53
  "devDependencies": {
53
- "@open-wc/dev-server-hmr": "^0.1.2-next.0",
54
54
  "@types/dragula": "^3.7.4",
55
55
  "@types/express-fileupload": "^1.4.4",
56
56
  "@types/glob": "^8.1.0",
57
- "@types/he": "^1.2.3",
58
- "@types/json5": "^2.2.0",
59
- "@types/sanitize-html": "^2.11.0",
60
- "@types/socket.io-client": "^3.0.0",
57
+ "@types/he": "^1.2.3",
58
+ "@types/sanitize-html": "^2.11.0",
61
59
  "@types/uuid": "^9.0.7",
62
- "@typescript-eslint/eslint-plugin": "^7.2.0",
63
- "@typescript-eslint/parser": "^7.2.0",
60
+ "@types/eslint": "^6.0.0",
61
+ "@typescript-eslint/parser": "^5.0.0",
64
62
  "clean-webpack-plugin": "^4.0.0",
65
63
  "css-loader": "^6.8.1",
66
- "css-minimizer-webpack-plugin": "^5.0.1",
67
- "dts-bundle": "^0.7.3",
68
- "eslint": "^8.57.0",
69
- "eslint-plugin-unused-imports": "^3.1.0",
64
+ "css-minimizer-webpack-plugin": "^5.0.1",
65
+ "eslint": "^6.0.0",
70
66
  "file-loader": "^6.2.0",
71
- "html-minifier": "^4.0.0",
72
67
  "html-webpack-plugin": "^5.5.3",
73
68
  "loader-utils": "^3.2.1",
74
69
  "mini-css-extract-plugin": "^2.7.6",
@@ -88,12 +83,17 @@
88
83
  "typedoc-plugin-rename-defaults": "^0.7.0",
89
84
  "typedoc-theme-hierarchy": "^4.1.2",
90
85
  "typescript": "^5.1.6",
91
- "typescript-eslint": "^7.2.0",
92
86
  "url-loader": "^4.1.1",
93
87
  "webpack": "^5.75.0",
94
88
  "webpack-bundle-analyzer": "^4.10.1",
95
89
  "webpack-cli": "^5.1.4",
96
90
  "webpack-dev-server": "^4.15.1",
97
91
  "webpack-node-externals": "^3.0.0"
92
+ },
93
+ "resolutions": {
94
+ "lodash": "^4.17.21"
95
+ },
96
+ "overrides": {
97
+ "lodash": "^4.17.21"
98
98
  }
99
99
  }
@@ -9,36 +9,39 @@ const RWSAfterPlugin = require('./webpack/rws_after_plugin');
9
9
  const tools = require('./_tools');
10
10
  const { _DEFAULT_CONFIG } = require('./cfg/_default.cfg');
11
11
  const RWSConfigBuilder = require('@rws-framework/console').RWSConfigBuilder;
12
+ const RWSPath = require('@rws-framework/console').rwsPath;
12
13
 
13
14
  const TerserPlugin = require('terser-webpack-plugin');
14
- const HtmlMinifier = require('html-minifier').minify;
15
15
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
16
16
  const JsMinimizerPlugin = require('terser-webpack-plugin');
17
17
 
18
18
  const json5 = require('json5');
19
19
 
20
20
 
21
- const RWSWebpackWrapper = (config) => {
22
- const executionDir = config.executionDir || process.cwd();
21
+ const RWSWebpackWrapper = (config) => {
22
+ const BuildConfigurator = new RWSConfigBuilder(RWSPath.findPackageDir(process.cwd()) + '/.rws.json', _DEFAULT_CONFIG);
23
23
 
24
- const BuildConfigurator = new RWSConfigBuilder(executionDir + '/.rws.json', _DEFAULT_CONFIG);
24
+ config.packageDir = RWSPath.findPackageDir(process.cwd());
25
25
 
26
- const isDev = BuildConfigurator.get('dev') || config.dev;
27
- const isHotReload = BuildConfigurator.get('hot') || config.hot;
28
- const isReport = BuildConfigurator.get('report') || config.report;
26
+ const executionDir = RWSPath.relativize(BuildConfigurator.get('executionDir') || config.executionDir || process.cwd(), config.packageDir);
29
27
 
30
- const isParted = BuildConfigurator.get('parted') || config.parted;
31
- const partedPrefix = BuildConfigurator.get('partedPrefix') || config.partedPrefix;
32
- const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix') || config.partedDirUrlPrefix;
28
+ const isDev = BuildConfigurator.get('dev') || config.dev;
29
+ const isHotReload = BuildConfigurator.get('hot') || config.hot;
30
+ const isReport = BuildConfigurator.get('report') || config.report;
33
31
 
34
- const partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations') || config.partedComponentsLocations;
35
- const customServiceLocations = BuildConfigurator.get('customServiceLocations') || config.customServiceLocations;
36
- const outputDir = BuildConfigurator.get('outputDir') || config.outputDir;
37
- const outputFileName = BuildConfigurator.get('outputFileName') || config.outputFileName;
38
- const publicDir = BuildConfigurator.get('publicDir') || config.publicDir;
39
- const serviceWorkerPath = BuildConfigurator.get('serviceWorker') || config.serviceWorker;
32
+ const isParted = BuildConfigurator.get('parted') || config.parted;
33
+ const partedPrefix = BuildConfigurator.get('partedPrefix') || config.partedPrefix;
34
+ const partedDirUrlPrefix = BuildConfigurator.get('partedDirUrlPrefix') || config.partedDirUrlPrefix;
40
35
 
41
- const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
36
+ const partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations') || config.partedComponentsLocations;
37
+ const customServiceLocations = BuildConfigurator.get('customServiceLocations') || config.customServiceLocations;
38
+ const outputDir = RWSPath.relativize(BuildConfigurator.get('outputDir') || config.outputDir, config.packageDir);
39
+
40
+ const outputFileName = BuildConfigurator.get('outputFileName') || config.outputFileName;
41
+ const publicDir = BuildConfigurator.get('publicDir') || config.publicDir;
42
+ const serviceWorkerPath = BuildConfigurator.get('serviceWorker') || config.serviceWorker;
43
+
44
+ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
42
45
 
43
46
 
44
47
  let WEBPACK_PLUGINS = [
@@ -98,16 +101,16 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
98
101
  });
99
102
  }
100
103
 
101
- const assetsToCopy = config.copyAssets || BuildConfigurator.get('copyAssets');
104
+ const assetsToCopy = BuildConfigurator.get('copyAssets') || config.copyAssets;
102
105
 
103
- if (!!assetsToCopy) {
106
+ if (!!assetsToCopy) {
104
107
  WEBPACK_AFTER_ACTIONS.push({
105
108
  type: 'copy',
106
109
  actionHandler: assetsToCopy
107
110
  });
108
111
  }
109
112
 
110
- if (WEBPACK_AFTER_ACTIONS.length) {
113
+ if (WEBPACK_AFTER_ACTIONS.length) {
111
114
  WEBPACK_PLUGINS.push(new RWSAfterPlugin({ actions: WEBPACK_AFTER_ACTIONS }));
112
115
  }
113
116
 
@@ -134,18 +137,18 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
134
137
  const optimConfig = {
135
138
  minimize: true,
136
139
  minimizer: isDev ? [
137
- new TerserPlugin({
138
- terserOptions: {
140
+ new TerserPlugin({
141
+ terserOptions: {
139
142
  mangle: false, //@error breaks FAST view stuff if enabled for all assets
140
143
  output: {
141
144
  comments: false
142
- },
145
+ },
143
146
  },
144
147
  extractComments: false,
145
148
  parallel: true,
146
149
  })
147
150
  ] : [
148
- new TerserPlugin({
151
+ new TerserPlugin({
149
152
  terserOptions: {
150
153
  keep_classnames: true, // Prevent mangling of class names
151
154
  mangle: false, //@error breaks FAST view stuff if enabled for all assets
@@ -155,7 +158,7 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
155
158
  },
156
159
  output: {
157
160
  comments: false
158
- },
161
+ },
159
162
  },
160
163
  extractComments: false,
161
164
  parallel: true,
@@ -215,6 +218,12 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
215
218
  }
216
219
  }
217
220
 
221
+ const tsValidated = tools.setupTsConfig(path.resolve(config.tsConfigPath));
222
+
223
+ if(!tsValidated){
224
+ throw new Error('RWS Webpack build failed.');
225
+ }
226
+
218
227
  const cfgExport = {
219
228
  entry: {
220
229
  client: config.entry,
@@ -267,7 +276,7 @@ const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
267
276
  loader: 'ts-loader',
268
277
  options: {
269
278
  allowTsInNodeModules: true,
270
- configFile: path.resolve(config.tsConfigPath)
279
+ configFile: path.resolve(config.tsConfigPath)
271
280
  }
272
281
  },
273
282
  {
package/tsconfig.json CHANGED
@@ -19,10 +19,6 @@
19
19
  },
20
20
  "include": [
21
21
  "src",
22
- "docs-typings.d.ts",
23
- "node_modules/@microsoft"
24
- ],
25
- "exclude": [
26
-
22
+ "types/docs-typings.d.ts"
27
23
  ]
28
24
  }
@@ -14,50 +14,56 @@ function collectFiles(dir, fileList = []) {
14
14
  return fileList;
15
15
  }
16
16
 
17
- module.exports = async (copyList = {}) => {
18
- const copyQueue = [];
17
+ module.exports = async (copyList = {}, pluginCfg) => {
18
+ const copyQueue = [];
19
+
20
+ Object.keys(copyList).forEach((targetPath) => {
21
+ const copyListKey = targetPath;
22
+
23
+ if (targetPath[0] === '.') {
24
+ targetPath = path.resolve(pluginCfg.packageDir, targetPath);
25
+ }
26
+
27
+ const sources = copyList[copyListKey];
28
+
29
+ sources.forEach((sourcePath) => {
30
+ const stat = fs.statSync(sourcePath);
31
+ if (stat.isDirectory()) {
32
+ // If sourcePath is a directory, collect all files recursively
33
+ const allFiles = collectFiles(sourcePath);
34
+ allFiles.forEach((file) => {
35
+ const relativePath = path.relative(sourcePath, file);
36
+ const targetFilePath = path.join(targetPath, relativePath);
37
+ const targetFileDir = path.dirname(targetFilePath);
38
+
39
+ // Ensure the target directory exists
40
+ if (!fs.existsSync(targetFileDir)) {
41
+ fs.mkdirSync(targetFileDir, { recursive: true });
42
+ }
19
43
 
20
- Object.keys(copyList).forEach((targetPath) => {
21
- const sources = copyList[targetPath];
22
-
23
- sources.forEach((sourcePath) => {
24
- const stat = fs.statSync(sourcePath);
25
- if (stat.isDirectory()) {
26
- // If sourcePath is a directory, collect all files recursively
27
- const allFiles = collectFiles(sourcePath);
28
- allFiles.forEach((file) => {
29
- const relativePath = path.relative(sourcePath, file);
30
- const targetFilePath = path.join(targetPath, relativePath);
31
- const targetFileDir = path.dirname(targetFilePath);
32
-
33
- // Ensure the target directory exists
34
- if (!fs.existsSync(targetFileDir)) {
35
- fs.mkdirSync(targetFileDir, { recursive: true });
36
- }
37
-
38
- // Check if the file already exists in the target location
39
- if (fs.existsSync(targetFilePath)) {
40
- fs.unlinkSync(targetFilePath);
41
- }
42
-
43
- // Add to copy queue
44
- copyQueue.push({ from: file, to: targetFilePath });
45
- });
46
- } else {
47
- // If sourcePath is not a directory, proceed as before
48
- const fileName = path.basename(sourcePath);
49
- const targetFilePath = path.join(targetPath, fileName);
50
-
51
44
  // Check if the file already exists in the target location
52
45
  if (fs.existsSync(targetFilePath)) {
53
46
  fs.unlinkSync(targetFilePath);
54
47
  }
55
-
48
+
56
49
  // Add to copy queue
57
- copyQueue.push({ from: sourcePath, to: targetFilePath });
50
+ copyQueue.push({ from: file, to: targetFilePath });
51
+ });
52
+ } else {
53
+ // If sourcePath is not a directory, proceed as before
54
+ const fileName = path.basename(sourcePath);
55
+ const targetFilePath = path.join(targetPath, fileName);
56
+
57
+ // Check if the file already exists in the target location
58
+ if (fs.existsSync(targetFilePath)) {
59
+ fs.unlinkSync(targetFilePath);
58
60
  }
59
- });
61
+
62
+ // Add to copy queue
63
+ copyQueue.push({ from: sourcePath, to: targetFilePath });
64
+ }
60
65
  });
66
+ });
61
67
 
62
68
  copyQueue.forEach((copyset) => {
63
69
  if(fs.existsSync(copyset.to)){
@@ -2,7 +2,7 @@ const rwsAfterCopy = require('./after/copy');
2
2
  const rwsAfterSW = require('./after/sw');
3
3
 
4
4
 
5
- const _DEFAULT_CONFIG = {actions: []}
5
+ const _DEFAULT_CONFIG = {actions: [], executionDir: process.cwd(), packageDir: process.cwd()}
6
6
 
7
7
  const _DEFAULT_ACTION = {
8
8
  type: 'copy',
@@ -67,8 +67,8 @@ class RWSAfterPlugin {
67
67
  switch (actionType){
68
68
  case 'copy': {
69
69
  const copyFiles = typeof action === 'function' ? await action() : action;
70
-
71
- await rwsAfterCopy(copyFiles);
70
+
71
+ await rwsAfterCopy(copyFiles, this.config);
72
72
  return;
73
73
  };
74
74
 
@@ -92,8 +92,7 @@ class RWSAfterPlugin {
92
92
  }
93
93
 
94
94
  default:
95
- console.warn('RWSAfterPlugin::_runActionType could not act upon input. Please resolve.');
96
- console.log({ actionType, action })
95
+ console.warn('RWSAfterPlugin::_runActionType could not act upon input. Please resolve.');
97
96
  return;
98
97
  }
99
98
  }
@@ -135,8 +135,6 @@ module.exports = async function(content) {
135
135
  }catch(e){
136
136
  console.error(e);
137
137
  console.warn('IN:\n\n');
138
- // console.log(processedContent);
139
-
140
138
  return content;
141
139
  }
142
140
  };
@@ -303,7 +303,7 @@ class RWSPlugin {
303
303
  return finalCss;
304
304
  } catch(err) {
305
305
  console.error('SASS Error in', fileRootDir);
306
- // console.log(err);
306
+
307
307
  console.error(err);
308
308
  throw err;
309
309
  return '';
package/src/hmr.ts DELETED
@@ -1,19 +0,0 @@
1
- //@ts-expect-error no-types
2
- import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
3
-
4
- const AUTORELOAD_CFG = {
5
- plugins: [
6
- hmrPlugin({
7
- include: ['src/**/*'],
8
- presets: [presets.fastElement],
9
- }),
10
- ],
11
- };
12
-
13
- const HMR = {
14
- autoReloadConfig: (): any => {
15
- return AUTORELOAD_CFG;
16
- }
17
- };
18
-
19
- export default HMR;
File without changes
File without changes