@rws-framework/client 2.0.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.
Files changed (116) hide show
  1. package/.bin/add-v.sh +10 -0
  2. package/.eslintrc.json +53 -0
  3. package/.setup/.eslintrc.json +11 -0
  4. package/.setup/tsconfig.json +29 -0
  5. package/README.md +691 -0
  6. package/_rws_externals.js +40 -0
  7. package/_tools.js +317 -0
  8. package/console.js +87 -0
  9. package/declarations.d.ts +9 -0
  10. package/docs/.nojekyll +1 -0
  11. package/docs/assets/26e93147f10415a0ed4a.svg +6 -0
  12. package/docs/assets/75c9471662e97ee24f29.svg +7 -0
  13. package/docs/assets/db90e4df2373980c497d.svg +9 -0
  14. package/docs/assets/hierarchy.css +1 -0
  15. package/docs/assets/hierarchy.js +1 -0
  16. package/docs/assets/highlight.css +120 -0
  17. package/docs/assets/main.js +59 -0
  18. package/docs/assets/navigation.js +1 -0
  19. package/docs/assets/search.js +1 -0
  20. package/docs/assets/style.css +1414 -0
  21. package/docs/classes/ApiServiceInstance.html +20 -0
  22. package/docs/classes/DOMServiceInstance.html +10 -0
  23. package/docs/classes/NotifyServiceInstance.html +12 -0
  24. package/docs/classes/RWSClient.html +11 -0
  25. package/docs/classes/RWSRouter.html +9 -0
  26. package/docs/classes/RWSService.html +7 -0
  27. package/docs/classes/RWSUploader.html +35 -0
  28. package/docs/classes/RWSViewComponent.html +24 -0
  29. package/docs/classes/RouterComponent.html +31 -0
  30. package/docs/classes/RoutingServiceInstance.html +13 -0
  31. package/docs/classes/UtilsServiceInstance.html +11 -0
  32. package/docs/classes/WSServiceInstance.html +32 -0
  33. package/docs/functions/RWSView.html +1 -0
  34. package/docs/functions/ngAttr.html +1 -0
  35. package/docs/functions/registerRWSComponents.html +1 -0
  36. package/docs/functions/renderRouteComponent.html +1 -0
  37. package/docs/hierarchy.html +1 -0
  38. package/docs/index.html +53 -0
  39. package/docs/interfaces/IRWSAssetShowOptions.html +1 -0
  40. package/docs/interfaces/IRWSConfig.html +11 -0
  41. package/docs/interfaces/IRWSDecoratorOptions.html +4 -0
  42. package/docs/interfaces/IRWSHttpRoute.html +3 -0
  43. package/docs/interfaces/IRWSPrefixedHTTProutes.html +3 -0
  44. package/docs/interfaces/IRoutingEvent.html +3 -0
  45. package/docs/modules.html +39 -0
  46. package/docs/types/DOMOutputType.html +1 -0
  47. package/docs/types/IRWSBackendRoute.html +1 -0
  48. package/docs/types/IRWSFrontRoutes.html +1 -0
  49. package/docs/types/IRWSRouteResult.html +1 -0
  50. package/docs/types/IRWSWebsocketStatus.html +1 -0
  51. package/docs/types/NotifyLogType.html +1 -0
  52. package/docs/types/NotifyUiType.html +1 -0
  53. package/docs/types/RWSNotify.html +1 -0
  54. package/docs/types/RouteReturn.html +1 -0
  55. package/docs/variables/ApiService.html +1 -0
  56. package/docs/variables/DOMService.html +1 -0
  57. package/docs/variables/NotifyService.html +1 -0
  58. package/docs/variables/RoutingService.html +1 -0
  59. package/docs/variables/UtilsService.html +1 -0
  60. package/docs/variables/WSService.html +1 -0
  61. package/docs/variables/_ROUTING_EVENT_NAME.html +1 -0
  62. package/package.json +93 -0
  63. package/package.webpack.config.js +17 -0
  64. package/rws.webpack.config.js +260 -0
  65. package/src/client.ts +304 -0
  66. package/src/components/_attrs/angular-attr.ts +64 -0
  67. package/src/components/_attrs/sanitize-html.ts +81 -0
  68. package/src/components/_component.ts +290 -0
  69. package/src/components/_container.ts +16 -0
  70. package/src/components/_decorator.ts +112 -0
  71. package/src/components/_design_system.ts +6 -0
  72. package/src/components/index.ts +9 -0
  73. package/src/components/progress/component.ts +55 -0
  74. package/src/components/progress/styles/layout.scss +91 -0
  75. package/src/components/progress/template.html +25 -0
  76. package/src/components/router/component.ts +67 -0
  77. package/src/components/uploader/component.ts +75 -0
  78. package/src/components/uploader/styles/layout.scss +105 -0
  79. package/src/components/uploader/template.html +17 -0
  80. package/src/hmr.ts +19 -0
  81. package/src/index.ts +98 -0
  82. package/src/interfaces/IRWSConfig.ts +24 -0
  83. package/src/interfaces/IRWSUser.ts +7 -0
  84. package/src/interfaces/IRWSViewComponent.ts +37 -0
  85. package/src/interfaces/RWSWindow.ts +39 -0
  86. package/src/routing/_router.ts +59 -0
  87. package/src/routing/index.ts +7 -0
  88. package/src/run.ts +35 -0
  89. package/src/service_worker/src/_service_worker.ts +88 -0
  90. package/src/service_worker/tsconfig.json +21 -0
  91. package/src/service_worker/webpack.config.js +67 -0
  92. package/src/services/ApiService.ts +241 -0
  93. package/src/services/ConfigService.ts +107 -0
  94. package/src/services/DOMService.ts +91 -0
  95. package/src/services/NotifyService.ts +49 -0
  96. package/src/services/RoutingService.ts +46 -0
  97. package/src/services/ServiceWorkerService.ts +60 -0
  98. package/src/services/UtilsService.ts +103 -0
  99. package/src/services/WSService.ts +218 -0
  100. package/src/services/_service.ts +50 -0
  101. package/src/services/_ws_handlers/ConnectionHandler.ts +52 -0
  102. package/src/services/_ws_handlers/EventHandler.ts +28 -0
  103. package/src/services/_ws_handlers/MessageHandler.ts +49 -0
  104. package/src/styles/includes.scss +102 -0
  105. package/src/types/RWSNotify.ts +7 -0
  106. package/tsconfig.json +27 -0
  107. package/typedoc.json +13 -0
  108. package/webpack/after/copy.js +73 -0
  109. package/webpack/after/sw.js +14 -0
  110. package/webpack/index.js +11 -0
  111. package/webpack/rws_after_plugin.js +80 -0
  112. package/webpack/rws_fast_css_loader.js +16 -0
  113. package/webpack/rws_fast_html_loader.js +4 -0
  114. package/webpack/rws_fast_scss_loader.js +50 -0
  115. package/webpack/rws_fast_ts_loader.js +134 -0
  116. package/webpack/rws_plugin.js +337 -0
@@ -0,0 +1,102 @@
1
+ $mdWidth: 1120px;
2
+
3
+ @function px-to-em($pixels, $base-font-size: 16) {
4
+ @return #{calc($pixels / $base-font-size)}em;
5
+ }
6
+
7
+ // Mixin for the grid container
8
+ @mixin grid-container {
9
+ display: flex;
10
+ flex-wrap: wrap;
11
+ // gap: px-to-em(15);
12
+ // margin-right: -#{px-to-em(15)}; // Adjust as needed
13
+ // margin-left: -#{px-to-em(15)}; // Adjust as needed
14
+ }
15
+
16
+ // Mixin for grid columns
17
+
18
+ @mixin grid-column($columns: 12) {
19
+ flex: 0 0 calc(100% / 12 * $columns);
20
+ max-width: calc(100% / 12 * $columns);
21
+ // padding-right: #{px-to-em(15)}; // Adjust as needed
22
+ // padding-left: #{px-to-em(15)}; // Adjust as needed
23
+ }
24
+
25
+ @mixin grid-column($columns: 12, $mdColumns: 12) {
26
+ flex: 0 0 calc(100% / 12 * $columns);
27
+ max-width: calc(100% / 12 * $columns);
28
+ // padding-right: #{px-to-em(15)}; // Adjust as needed
29
+ // padding-left: #{px-to-em(15)}; // Adjust as needed
30
+
31
+ @media screen and (max-width: $mdWidth) {
32
+ flex: 0 0 calc(100% / 12 * $mdColumns);
33
+ max-width: calc(100% / 12 * $mdColumns);
34
+ }
35
+ }
36
+
37
+ @mixin grid-flex-self-align($alignment) {
38
+ align-self: $alignment;
39
+ }
40
+
41
+ @mixin grid-flex-align-items($horizontal, $vertical: top) {
42
+ justify-content: $horizontal;
43
+ align-items: $vertical;
44
+ }
45
+
46
+ @mixin auto-left() {
47
+ margin-left: auto;
48
+ }
49
+
50
+ @mixin auto-right() {
51
+ margin-right: auto;
52
+ }
53
+
54
+ @mixin center-container() {
55
+ margin-left: auto;
56
+ margin-right: auto;
57
+ }
58
+
59
+ @mixin customScrollbars($width: 10px, $trackColor: #f1f1f1, $thumbColor: #888) {
60
+ /* WebKit (Safari/Chrome) */
61
+ &::-webkit-scrollbar {
62
+ width: $width;
63
+ }
64
+
65
+ &::-webkit-scrollbar-track {
66
+ background: $trackColor;
67
+ }
68
+
69
+ &::-webkit-scrollbar-thumb {
70
+ background: $thumbColor;
71
+ }
72
+
73
+ /* Firefox */
74
+ &::-moz-scrollbar {
75
+ width: $width;
76
+ }
77
+
78
+ &::-moz-scrollbar-track {
79
+ background: $trackColor;
80
+ }
81
+
82
+ &::-moz-scrollbar-thumb {
83
+ background: $thumbColor;
84
+ }
85
+
86
+ /* IE/Edge */
87
+ &::-ms-scrollbar {
88
+ width: $width;
89
+ }
90
+
91
+ &::-ms-scrollbar-track {
92
+ background: $trackColor;
93
+ }
94
+
95
+ &::-ms-scrollbar-thumb {
96
+ background: $thumbColor;
97
+ }
98
+ }
99
+
100
+ * {
101
+ box-sizing: border-box;
102
+ }
@@ -0,0 +1,7 @@
1
+ type NotifyUiType = 'alert' | 'notification' | 'silent';
2
+ type NotifyLogType = 'info' | 'error' | 'warning';
3
+
4
+ type RWSNotify = (message: string, logType?: NotifyLogType, uiType?: NotifyUiType, onConfirm?: (params?: any) => void) => any;
5
+
6
+ export default RWSNotify;
7
+ export { NotifyUiType, NotifyLogType };
package/tsconfig.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "baseUrl": "./",
4
+ "experimentalDecorators": true,
5
+ "emitDecoratorMetadata": true,
6
+ "target": "ES2018",
7
+ "module": "es2022",
8
+ "moduleResolution": "node",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "resolveJsonModule": true,
12
+ "outDir": "dist/src",
13
+ "strictNullChecks": false,
14
+ "allowSyntheticDefaultImports": true,
15
+ "sourceMap": true,
16
+ "declaration": true,
17
+ "lib": ["DOM", "ESNext", "WebWorker"],
18
+ },
19
+ "include": [
20
+ "src",
21
+ // "declarations.d.ts"
22
+ ],
23
+ "exclude": [
24
+ "node_modules",
25
+ "**/*.spec.ts"
26
+ ]
27
+ }
package/typedoc.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "out": "docs",
3
+ "exclude": ["**/node_modules/**", "**/*.spec.ts"],
4
+ "plugin": ["typedoc-theme-hierarchy", "typedoc-plugin-rename-defaults"],
5
+ "theme": "hierarchy",
6
+ "readme": "./README.md",
7
+ "entryPoints": ["./src/index.ts"],
8
+ "entryPointStrategy": "expand",
9
+ "categorizeByGroup": true,
10
+ "name": "Realtime Web Suite Client package",
11
+ "jsDocCompatibility": true,
12
+ "includes": "src/"
13
+ }
@@ -0,0 +1,73 @@
1
+ const fs = require('fs');
2
+ const chalk = require('chalk');
3
+ const path = require('path');
4
+
5
+ function collectFiles(dir, fileList = []) {
6
+ const files = fs.readdirSync(dir, { withFileTypes: true });
7
+ files.forEach(file => {
8
+ if (file.isDirectory()) {
9
+ collectFiles(path.join(dir, file.name), fileList);
10
+ } else {
11
+ fileList.push(path.join(dir, file.name));
12
+ }
13
+ });
14
+ return fileList;
15
+ }
16
+
17
+ module.exports = async (copyList = {}) => {
18
+ const copyQueue = [];
19
+
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
+ // Check if the file already exists in the target location
52
+ if (fs.existsSync(targetFilePath)) {
53
+ fs.unlinkSync(targetFilePath);
54
+ }
55
+
56
+ // Add to copy queue
57
+ copyQueue.push({ from: sourcePath, to: targetFilePath });
58
+ }
59
+ });
60
+ });
61
+
62
+ copyQueue.forEach((copyset) => {
63
+ if(fs.existsSync(copyset.to)){
64
+ fs.unlinkSync(copyset.to);
65
+ }
66
+
67
+ fs.copyFileSync(copyset.from, copyset.to);
68
+
69
+ console.log(`${chalk.yellow('[RWS]')} Copied "${chalk.blue(copyset.from)}" to "${chalk.blue(copyset.to)}"`)
70
+ })
71
+
72
+ return new Promise((resolve) => resolve());
73
+ }
@@ -0,0 +1,14 @@
1
+ const fs = require('fs');
2
+ const chalk = require('chalk');
3
+ const path = require('path');
4
+ const tools = require('../../_tools');
5
+
6
+ module.exports = async (swPath) => {
7
+ const swFilePath = path.resolve(process.cwd(), swPath);
8
+
9
+ if(swPath.indexOf('.ts') === -1 || !fs.existsSync(swFilePath)){
10
+ throw new Error('[RWS] Service worker TS file does not exist');
11
+ }
12
+
13
+ await tools.runCommand(`yarn rws-client build:sw ${swPath}`);
14
+ }
@@ -0,0 +1,11 @@
1
+ const cssLoader = require('./rws_fast_css_loader');
2
+ const scssLoader = require('./rws_fast_scss_loader');
3
+ const htmlLoader = require('./rws_fast_html_loader');
4
+ const tsLoader = require('./rws_fast_ts_loader');
5
+
6
+ module.exports = {
7
+ cssLoader,
8
+ scssLoader,
9
+ htmlLoader,
10
+ tsLoader
11
+ }
@@ -0,0 +1,80 @@
1
+ const rwsAfterCopy = require('./after/copy');
2
+ const rwsAfterSW = require('./after/sw');
3
+
4
+
5
+ const _DEFAULT_CONFIG = {actions: []}
6
+
7
+ const _DEFAULT_ACTION = {
8
+ type: 'copy',
9
+ actionHandler: {
10
+ 'targetDir': [
11
+ 'filePath0',
12
+ 'filePath1'
13
+ ]
14
+ },
15
+ event: 'done'
16
+ }
17
+
18
+ class RWSAfterPlugin {
19
+ config = _DEFAULT_CONFIG;
20
+ _allowedActionTypes = ['copy', 'custom', 'service_worker'];
21
+
22
+ constructor(config = {}){
23
+ this.config = Object.assign(this.config, config);
24
+ }
25
+
26
+ apply(compiler) {
27
+ const actionsEvents = this.config.actions.map(item => item.event ? item.event : 'done');
28
+
29
+ Array.from(new Set(actionsEvents)).forEach((eventName) => {
30
+ compiler.hooks[eventName].tapPromise('RWSAfterPlugin', async (buildInfo) => {
31
+ const proms = this.config.actions.filter(item => item.event === _DEFAULT_ACTION.event || !item.event).map(async (rwsAfterAction) => {
32
+ return await this._runActionType(rwsAfterAction.type, rwsAfterAction.actionHandler);
33
+ });
34
+
35
+ return await Promise.all(proms);
36
+ });
37
+ });
38
+ }
39
+
40
+ async _runActionType(actionType, action){
41
+ if(!this._allowedActionTypes.includes(actionType)){
42
+ throw new Error(`[RWSAfter webpack plugin] Action type ${actionType} is not allowed`);
43
+ }
44
+
45
+ switch (actionType){
46
+ case 'copy': {
47
+ const copyFiles = typeof action === 'function' ? await action() : action;
48
+
49
+ await rwsAfterCopy(copyFiles);
50
+ return;
51
+ };
52
+
53
+ //@TODO
54
+ case 'service_worker': {
55
+
56
+ const serviceWorkerPath = typeof action === 'function' ? await action() : action;
57
+ await rwsAfterSW(serviceWorkerPath);
58
+ return;
59
+ };
60
+
61
+ case 'custom': {
62
+
63
+ if(typeof action !== 'function'){
64
+ console.error('Custom RWS action must be a function.')
65
+ return;
66
+ }
67
+
68
+ await action();
69
+ return;
70
+ }
71
+
72
+ default:
73
+ console.warn('RWSAfterPlugin::_runActionType could not act upon input. Please resolve.');
74
+ console.log({ actionType, action })
75
+ return;
76
+ }
77
+ }
78
+ }
79
+
80
+ module.exports = RWSAfterPlugin;
@@ -0,0 +1,16 @@
1
+ // custom-css-loader.js
2
+ const RWSPlugin = require("./rws_plugin");
3
+ const plugin = new RWSPlugin();
4
+
5
+ module.exports = function(content) {
6
+
7
+ if(this.resourcePath == '/app/frontend/src/styles/main.scss'){
8
+ console.log('zzzzz',content, plugin.checkForImporterType(this._module, 'ts'));
9
+ }
10
+
11
+ if(!plugin.checkForImporterType(this._module, 'ts')){
12
+ return content;
13
+ }
14
+
15
+ return `import { css } from '@microsoft/fast-element';\nexport default css\`${content}\`;`;
16
+ };
@@ -0,0 +1,4 @@
1
+ // custom-html-loader.js
2
+ module.exports = function(content) {
3
+ return `import * as T from '@microsoft/fast-element';\nexport default T.html\`${content}\`;`;
4
+ };
@@ -0,0 +1,50 @@
1
+ const RWSPlugin = require("./rws_plugin");
2
+ const path = require('path');
3
+ const cssLoader = require('css-loader');
4
+
5
+ module.exports = function(content) {
6
+ const callback = this.async();
7
+ const plugin = new RWSPlugin();
8
+ const filePath = this.resourcePath;
9
+
10
+ const saveFile = content.indexOf('@save') > -1;
11
+ let fromTs = false;
12
+
13
+ if (plugin.checkForImporterType(this._module, 'ts')) {
14
+ fromTs = true;
15
+ }
16
+
17
+ try {
18
+ const code = plugin.compileScssCode(content, path.dirname(filePath));
19
+
20
+ if (fromTs) {
21
+ if (saveFile && code) {
22
+ plugin.writeCssFile(filePath, code);
23
+
24
+ // Properly setup the context for css-loader
25
+ const loaderContext = {
26
+ ...this,
27
+ query: { sourceMap: true }, // Assuming you want source maps
28
+ async: () => (err, output) => {
29
+ if (err) {
30
+ callback(err);
31
+ return;
32
+ }
33
+ callback(null, output);
34
+ }
35
+ };
36
+
37
+ // Execute css-loader
38
+ cssLoader.call(loaderContext, code);
39
+ } else {
40
+ const tsCode = `import { css } from '@microsoft/fast-element';\nexport default css\`${code}\`;`;
41
+ callback(null, tsCode);
42
+ }
43
+ } else {
44
+ callback(null, code);
45
+ }
46
+ } catch (e) {
47
+ console.error(e);
48
+ callback(e);
49
+ }
50
+ };
@@ -0,0 +1,134 @@
1
+ // custom-html-loader.js
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const ts = require('typescript');
5
+ const tools = require('../_tools');
6
+ const RWSPlugin = require("./rws_plugin");
7
+
8
+ const _defaultRWSLoaderOptions = {
9
+ templatePath: 'template.html',
10
+ stylesPath: 'styles.scss',
11
+ fastOptions: { shadowOptions: { mode: 'open' } }
12
+ }
13
+
14
+ function toJsonString(str) {
15
+ // Replace single quotes with double quotes
16
+ str = str.replace(/'/g, '"');
17
+
18
+ // Add double quotes around keys
19
+ str = str.replace(/([a-zA-Z0-9_]+)(?=\s*:)/g, '"$1"');
20
+
21
+ try {
22
+ // Parse the string as JSON and then stringify it to get a JSON string
23
+ const jsonObj = JSON.parse(str);
24
+ return JSON.stringify(jsonObj);
25
+ } catch (error) {
26
+ console.error("Error in parsing:", error);
27
+ return null;
28
+ }
29
+ }
30
+
31
+ module.exports = function(content) {
32
+
33
+ let processedContent = content;
34
+ const filePath = this.resourcePath;
35
+ const options = this.getOptions() || {};
36
+ const tsConfigPath = options.tsConfigPath || path.resolve(process.cwd(), 'tsconfig.json');
37
+ const regex = /@RWSView/;
38
+
39
+ const tsSourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
40
+
41
+ let templatePath = 'template.html';
42
+ let stylesPath = 'styles/layout.scss';
43
+ let isIgnored = false;
44
+ let fastOptions = _defaultRWSLoaderOptions.fastOptions;
45
+ const addedParamDefs = [];
46
+ const addedParams = [];
47
+
48
+ const decoratorData = tools.extractRWSViewArguments(tsSourceFile);
49
+
50
+ if(!decoratorData){
51
+ return content;
52
+ }
53
+
54
+ if(decoratorData.options){
55
+ if(decoratorData.options.template){
56
+ templatePath = decoratorData.options.template;
57
+ }
58
+
59
+ if(decoratorData.options.styles){
60
+ stylesPath = decoratorData.options.styles;
61
+ }
62
+
63
+ if(decoratorData.options.fastElementOptions){
64
+ fastOptions = decoratorData.options.fastElementOptions;
65
+ }
66
+
67
+ for (const key in fastOptions){
68
+ addedParamDefs.push(`const ${key} = ${JSON.stringify(fastOptions[key])};`);
69
+ addedParams.push(key);
70
+ }
71
+ }
72
+
73
+ const tagName = decoratorData.tagName;
74
+
75
+
76
+ try {
77
+ if(tagName){
78
+
79
+ const lines = content.split('\n');
80
+ const textToInsert = ` static definition = { name: '${tagName}', template, styles${addedParams.length? ', ' + (addedParams.join(', ')) : ''} };`;
81
+
82
+ let modifiedContent = '';
83
+ let insertIndex = -1;
84
+
85
+ lines.forEach((line, index) => {
86
+ modifiedContent += line + '\n';
87
+
88
+ if (regex.test(line)) {
89
+ insertIndex = index + 2; // Set the position two lines below the match
90
+ }
91
+
92
+ if (index === insertIndex) {
93
+ modifiedContent += textToInsert + '\n'; // Insert the text
94
+ }
95
+ });
96
+
97
+ replaced = modifiedContent;
98
+ replaced = replaced.replace(`@RWSView('${tagName}')`, '');
99
+ const plugin = new RWSPlugin();
100
+ let styles = 'const styles: null = null;'
101
+
102
+ if(fs.existsSync(path.dirname(filePath) + '/styles')){
103
+ // const scssCode = fs.readFileSync(path.dirname(filePath) + '/styles/layout.scss', 'utf-8');
104
+ // styles = 'const styles = T.css`' + plugin.compileScssCode(scssCode, path.dirname(filePath) + '/styles') + '`;'
105
+
106
+ styles = `import styles from './${stylesPath}'`;
107
+ }
108
+
109
+ const templateExists = fs.existsSync(path.dirname(filePath) + '/template.html', 'utf-8');
110
+ let template = 'const template: null = null;';
111
+
112
+ if(templateExists){
113
+ template = `import template from './${templatePath}'`;
114
+ }
115
+
116
+ processedContent = `
117
+ import * as T from '@microsoft/fast-element';\n
118
+ ${template}\n
119
+ ${styles}\n
120
+ ${addedParamDefs.join('\n')}
121
+ \n
122
+ ` + replaced;
123
+ }
124
+
125
+ return processedContent;
126
+
127
+ }catch(e){
128
+ console.error(e);
129
+ console.warn('IN:\n\n');
130
+ console.log(processedContent);
131
+
132
+ return content;
133
+ }
134
+ };