@rws-framework/client 2.8.1 → 2.8.5

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.
@@ -17,6 +17,7 @@ const _DEFAULT_CONFIG_VARS = {
17
17
  //Universal configs
18
18
  transports: ['websocket'],
19
19
  parted: false,
20
+ plugins: []
20
21
  }
21
22
 
22
23
  const _DEFAULT_CONFIG = Object.freeze(_DEFAULT_CONFIG_VARS);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.8.1",
4
+ "version": "2.8.5",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "@microsoft/fast-element": "^1.12.0",
30
30
  "@microsoft/fast-foundation": "^2.46.2",
31
- "@rws-framework/console": "^0.3.5",
31
+ "@rws-framework/console": "*",
32
32
  "@types/moment": "^2.13.0",
33
33
  "dragula": "^3.7.3",
34
34
  "he": "^1.2.0",
@@ -49,6 +49,7 @@
49
49
  "url-router": "^13.0.0",
50
50
  "uuid": "^9.0.1",
51
51
  "v4": "^0.0.1"
52
+
52
53
  },
53
54
  "devDependencies": {
54
55
  "@types/dragula": "^3.7.4",
@@ -74,6 +75,7 @@
74
75
  "style-loader": "^3.3.3",
75
76
  "terser-webpack-plugin": "^5.3.9",
76
77
  "ts-loader": "^9.4.4",
78
+ "html-loader": "^5.0.0",
77
79
  "ts-node": "^10.9.1",
78
80
  "tsconfig-paths": "^4.2.0",
79
81
  "tsconfig-paths-webpack-plugin": "^4.1.0",
@@ -8,22 +8,19 @@ const chalk = require('chalk');
8
8
  const RWSAfterPlugin = require('./webpack/rws_after_plugin');
9
9
  const tools = require('./_tools');
10
10
  const { _DEFAULT_CONFIG } = require('./cfg/_default.cfg');
11
- const RWSConfigBuilder = require('@rws-framework/console').RWSConfigBuilder;
12
- const RWSPath = require('@rws-framework/console').rwsPath;
13
-
14
11
  const TerserPlugin = require('terser-webpack-plugin');
15
12
  const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
16
13
  const JsMinimizerPlugin = require('terser-webpack-plugin');
17
14
 
18
15
  const json5 = require('json5');
19
- const { rwsPath } = require('@rws-framework/console');
16
+ const { rwsPath, RWSConfigBuilder } = require('@rws-framework/console');
20
17
 
21
18
  const RWSWebpackWrapper = async (config) => {
22
- const BuildConfigurator = new RWSConfigBuilder(RWSPath.findPackageDir(process.cwd()) + '/.rws.json', {..._DEFAULT_CONFIG, ...config});
19
+ const BuildConfigurator = new RWSConfigBuilder(rwsPath.findPackageDir(process.cwd()) + '/.rws.json', {..._DEFAULT_CONFIG, ...config});
23
20
 
24
- config.packageDir = RWSPath.findPackageDir(process.cwd());
21
+ config.packageDir = rwsPath.findPackageDir(process.cwd());
25
22
 
26
- const executionDir = RWSPath.relativize(BuildConfigurator.get('executionDir') || config.executionDir || process.cwd(), config.packageDir);
23
+ const executionDir = rwsPath.relativize(BuildConfigurator.get('executionDir') || config.executionDir || process.cwd(), config.packageDir);
27
24
 
28
25
  const isDev = BuildConfigurator.get('dev', config.dev);
29
26
  const isHotReload = BuildConfigurator.get('hot', config.hot);
@@ -35,7 +32,7 @@ const RWSWebpackWrapper = async (config) => {
35
32
 
36
33
  let partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations', config.partedComponentsLocations);
37
34
  const customServiceLocations = BuildConfigurator.get('customServiceLocations', config.customServiceLocations); //@todo: check if needed
38
- const outputDir = RWSPath.relativize(BuildConfigurator.get('outputDir', config.outputDir), config.packageDir);
35
+ const outputDir = rwsPath.relativize(BuildConfigurator.get('outputDir', config.outputDir), config.packageDir);
39
36
 
40
37
  const outputFileName = BuildConfigurator.get('outputFileName') || config.outputFileName;
41
38
  const publicDir = BuildConfigurator.get('publicDir') || config.publicDir;
@@ -43,6 +40,7 @@ const RWSWebpackWrapper = async (config) => {
43
40
 
44
41
  const publicIndex = BuildConfigurator.get('publicIndex') || config.publicIndex;
45
42
 
43
+ const devTools = isDev ? (config.devtool || 'inline-source-map') : false;
46
44
 
47
45
  const tsConfigPath = rwsPath.relativize(BuildConfigurator.get('tsConfigPath') || config.tsConfigPath, executionDir);
48
46
  const rwsPlugins = {};
@@ -54,7 +52,7 @@ const RWSWebpackWrapper = async (config) => {
54
52
  }
55
53
  }
56
54
 
57
- RWSPath.removeDirectory(outputDir, true);
55
+ rwsPath.removeDirectory(outputDir, true);
58
56
 
59
57
  console.log(chalk.green('Build started with'))
60
58
  console.log({
@@ -65,7 +63,8 @@ const RWSWebpackWrapper = async (config) => {
65
63
  publicDir,
66
64
  parted: isParted,
67
65
  partedPrefix,
68
- partedDirUrlPrefix
66
+ partedDirUrlPrefix,
67
+ devtool: devTools
69
68
  });
70
69
 
71
70
 
@@ -135,17 +134,17 @@ const RWSWebpackWrapper = async (config) => {
135
134
 
136
135
  const optimConfig = {};
137
136
 
138
- if(!isDev){
139
- optimConfig.minimize = true;
140
- optimConfig.minimizer = [
137
+ // if(!isDev){
138
+ optimConfig.minimize = !isDev;
139
+ optimConfig.minimizer = !isDev ? [
141
140
  new TerserPlugin({
142
141
  terserOptions: {
143
142
  keep_classnames: true, // Prevent mangling of class names
144
143
  mangle: false, //@error breaks FAST view stuff if enabled for all assets
145
- compress: {
144
+ compress: !isDev ? {
146
145
  dead_code: true,
147
146
  pure_funcs: ['console.log', 'console.info', 'console.warn']
148
- },
147
+ } : null,
149
148
  output: {
150
149
  comments: false
151
150
  },
@@ -153,9 +152,21 @@ const RWSWebpackWrapper = async (config) => {
153
152
  extractComments: false,
154
153
  parallel: true,
155
154
  }),
156
- new CssMinimizerPlugin(),
157
- ];
158
- }
155
+ new CssMinimizerPlugin()
156
+ ] : [
157
+ new TerserPlugin({
158
+ terserOptions: {
159
+ keep_classnames: true, // Prevent mangling of class names
160
+ mangle: false, //@error breaks FAST view stuff if enabled for all assets
161
+ output: {
162
+ comments: false
163
+ },
164
+ },
165
+ extractComments: false,
166
+ parallel: false,
167
+ })
168
+ ]
169
+ // }
159
170
 
160
171
 
161
172
  if (isParted) {
@@ -227,7 +238,7 @@ const RWSWebpackWrapper = async (config) => {
227
238
  },
228
239
  mode: isDev ? 'development' : 'production',
229
240
  target: 'web',
230
- devtool: isDev ? (config.devtool || 'inline-source-map') : false,
241
+ devtool: devTools,
231
242
  output: {
232
243
  path: outputDir,
233
244
  filename: isParted ? (partedPrefix || 'rws') + '.[name].js' : outputFileName,
@@ -245,6 +256,9 @@ const RWSWebpackWrapper = async (config) => {
245
256
  {
246
257
  test: /\.html$/,
247
258
  use: [
259
+ {
260
+ loader: 'html-loader'
261
+ },
248
262
  path.resolve(__dirname, './webpack/loaders/rws_fast_html_loader.js')
249
263
  ],
250
264
  },
@@ -256,7 +270,7 @@ const RWSWebpackWrapper = async (config) => {
256
270
  },
257
271
  {
258
272
  test: /\.scss$/,
259
- use: [
273
+ use: [
260
274
  path.resolve(__dirname, './webpack/loaders/rws_fast_scss_loader.js'),
261
275
  ],
262
276
  },
@@ -274,7 +288,10 @@ const RWSWebpackWrapper = async (config) => {
274
288
  loader: path.resolve(__dirname, './webpack/loaders/rws_fast_ts_loader.js'),
275
289
  }
276
290
  ],
277
- exclude: [/node_modules\/(?!\@rws-framework\/client)/, /\.debug\.ts$/],
291
+ exclude: [
292
+ /node_modules\/(?!\@rws-framework\/[A-Z0-9a-z])/,
293
+ /\.debug\.ts$/,
294
+ ],
278
295
  }
279
296
  ],
280
297
  },
@@ -283,12 +300,12 @@ const RWSWebpackWrapper = async (config) => {
283
300
  }
284
301
 
285
302
  // if(isDev){
286
- cfgExport.module.rules.push({
287
- test: /\.js$/,
288
- use: [
289
- path.resolve(__dirname, './webpack/loaders/rws_uncomments_loader.js'),
290
- ],
291
- })
303
+ // cfgExport.module.rules.push({
304
+ // test: /\.js$/,
305
+ // use: [
306
+ // path.resolve(__dirname, './webpack/loaders/rws_uncomments_loader.js'),
307
+ // ],
308
+ // })
292
309
  // }
293
310
 
294
311
  if (isHotReload) {
@@ -1,8 +1,7 @@
1
- import IRWSUser from '../../src/interfaces/IRWSUser';
1
+ import IRWSUser from '../../src/types/IRWSUser';
2
2
  import RWSContainer from '../../src/components/_container';
3
3
 
4
4
  //@4DI
5
- import { WSServiceInstance } from '../../src/services/WSService';
6
5
  import { Container } from '@microsoft/fast-foundation';
7
6
 
8
7
  type SWMsgType = {
@@ -14,8 +13,7 @@ type SWMsgType = {
14
13
  abstract class RWSServiceWorker<UserType extends IRWSUser> {
15
14
  protected DI: Container;
16
15
  protected user: UserType = null;
17
- protected ignoredUrls: RegExp[] = [];
18
- protected wsService: WSServiceInstance;
16
+ protected ignoredUrls: RegExp[] = [];
19
17
  protected regExTypes: { [key: string]: RegExp };
20
18
 
21
19
  public workerScope: ServiceWorkerGlobalScope;
@@ -28,8 +26,7 @@ abstract class RWSServiceWorker<UserType extends IRWSUser> {
28
26
  onActivate(): Promise<void> { return; }
29
27
 
30
28
  constructor(workerScope: ServiceWorkerGlobalScope, DI: Container){
31
- this.DI = DI;
32
- this.wsService = DI.get<WSServiceInstance>(WSServiceInstance);
29
+ this.DI = DI;
33
30
  this.workerScope = workerScope;
34
31
 
35
32
  this.onInit().then(() => {
@@ -1,4 +1,4 @@
1
- import RWSWindow, { RWSWindowComponentRegister } from "../interfaces/RWSWindow";
1
+ import RWSWindow, { RWSWindowComponentRegister } from "../types/RWSWindow";
2
2
  import { RWSClientInstance } from "../client";
3
3
  import RWSViewComponent, { IWithCompose } from "../components/_component";
4
4
  import { RWSPlugin } from "../plugins/_plugin";
@@ -2,7 +2,7 @@ import { IRWSConfig, IRWSUser } from "../index";
2
2
  import { RWSClientInstance } from "../client";
3
3
 
4
4
  import { RWSPlugin, DefaultRWSPluginOptionsType } from "../plugins/_plugin";
5
- import RWSWindow, {loadRWSRichWindow } from '../interfaces/RWSWindow';
5
+ import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
6
6
 
7
7
  type RWSInfoType = { components: string[] };
8
8
 
@@ -139,7 +139,7 @@ async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
139
139
  function getBinds(this: RWSClientInstance) {
140
140
  return {
141
141
  start: start.bind(this),
142
- setup: setup.bind(this),
142
+ setup: setup.bind(this),
143
143
  get: get.bind(this),
144
144
  setUser: setUser.bind(this),
145
145
  getUser: getUser.bind(this),
@@ -1,4 +1,4 @@
1
- import { loadRWSRichWindow } from "../interfaces/RWSWindow";
1
+ import { loadRWSRichWindow } from "../types/RWSWindow";
2
2
  import { RWSClientInstance } from "../client";
3
3
  type RWSInfoType = { components: string[] };
4
4
 
package/src/client.ts CHANGED
@@ -1,4 +1,4 @@
1
- import IRWSConfig from './interfaces/IRWSConfig';
1
+ import IRWSConfig, { RWSPluginEntry } from './types/IRWSConfig';
2
2
 
3
3
  import RWSNotify from './types/RWSNotify';
4
4
 
@@ -10,8 +10,8 @@ import NotifyService, { NotifyServiceInstance } from './services/NotifyService';
10
10
 
11
11
  import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/ServiceWorkerService';
12
12
  import { IBackendRoute } from './services/ApiService';
13
- import IRWSUser from './interfaces/IRWSUser';
14
- import RWSWindow, { RWSWindowComponentRegister, loadRWSRichWindow } from './interfaces/RWSWindow';
13
+ import IRWSUser from './types/IRWSUser';
14
+ import RWSWindow, { RWSWindowComponentRegister, loadRWSRichWindow } from './types/RWSWindow';
15
15
 
16
16
  import { DI, Container, Registration } from '@microsoft/fast-foundation';
17
17
 
@@ -65,6 +65,7 @@ class RWSClient {
65
65
 
66
66
  this.loadServices();
67
67
 
68
+ this.config.plugins = [];
68
69
  this.pushDataToServiceWorker('SET_WS_URL', { url: this.appConfig.get('wsUrl') }, 'ws_url');
69
70
 
70
71
  if (this.user) {
@@ -72,6 +73,11 @@ class RWSClient {
72
73
  }
73
74
  }
74
75
 
76
+ addPlugin(pluginEntry: RWSPluginEntry<any>)
77
+ {
78
+ this.config.plugins.push(pluginEntry);
79
+ }
80
+
75
81
  async setup(config: IRWSConfig = {}): Promise<IRWSConfig> {
76
82
  return this.configHelper.setup(config);
77
83
  }
@@ -5,8 +5,8 @@ import UtilsService, { UtilsServiceInstance } from '../services/UtilsService';
5
5
  import DOMService, { DOMServiceInstance, DOMOutputType } from '../services/DOMService';
6
6
  import ApiService, { ApiServiceInstance } from '../services/ApiService';
7
7
  import NotifyService, { NotifyServiceInstance } from '../services/NotifyService';
8
- import { IRWSViewComponent, IAssetShowOptions } from '../interfaces/IRWSViewComponent';
9
- import RWSWindow, { RWSWindowComponentInterface, loadRWSRichWindow } from '../interfaces/RWSWindow';
8
+ import { IRWSViewComponent, IAssetShowOptions } from '../types/IRWSViewComponent';
9
+ import RWSWindow, { RWSWindowComponentInterface, loadRWSRichWindow } from '../types/RWSWindow';
10
10
  import { applyConstructor, RWSInject } from './_decorator';
11
11
 
12
12
  import 'reflect-metadata';
@@ -1,5 +1,5 @@
1
1
  import { DI } from '@microsoft/fast-foundation';
2
- import {loadRWSRichWindow} from '../interfaces/RWSWindow';
2
+ import {loadRWSRichWindow} from '../types/RWSWindow';
3
3
 
4
4
  import 'reflect-metadata';
5
5
 
@@ -13,6 +13,7 @@ interface RWSDecoratorOptions {
13
13
  }
14
14
 
15
15
  //const _PARAMTYPES_METADATA_KEY = 'design:paramtypes';
16
+ type HtmlBinderType = (context: RWSViewComponent) => ViewTemplate;
16
17
 
17
18
  function RWSView<Component extends RWSViewComponent>(name: string, data?: RWSDecoratorOptions | null, override?: { styles?: ElementStyles, template?: ViewTemplate, options?: any }): (type: any, args?: any) => void {
18
19
  return (theComponent: IWithCompose<Component>, args?: any) => {
@@ -24,7 +25,7 @@ function RWSView<Component extends RWSViewComponent>(name: string, data?: RWSDec
24
25
  }
25
26
 
26
27
  if(override.template){
27
- theComponent.definition.template = override.template;
28
+ theComponent.definition.template = override.template;
28
29
  }
29
30
 
30
31
 
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import IRWSConfig from '../../interfaces/IRWSConfig.js';
2
+ import IRWSConfig from '../../types/IRWSConfig.js';
3
3
 
4
4
  function extractEnvVar(envVar: string){
5
5
  const extractedVars = JSON.parse(JSON.stringify(envVar));
@@ -1,5 +1,5 @@
1
1
  //loader
2
-
2
+ //save
3
3
  $loader-color: var(--primary-color, #eb7b13);
4
4
  $loader-size: 56px;
5
5
  $loader-height: 20px;
@@ -7,8 +7,8 @@ $loader-border-size: 8px;
7
7
  $loader-gap: 12px;
8
8
  $loader-animation-duration: 1s;
9
9
 
10
- @import "~/scss-loading-animations/src/loaders";
10
+ // @import "~/scss-loading-animations/src/loaders";
11
11
 
12
- .loader {
13
- @include loader01;
14
- }
12
+ // .loader {
13
+ // @include loader01;
14
+ // }
@@ -3,7 +3,7 @@ import {
3
3
  nullableNumberConverter,
4
4
  } from '@microsoft/fast-element';
5
5
 
6
- @RWSView('rws-progress')
6
+ @RWSView('rws-progress', { debugPackaging: false })
7
7
  class RWSProgress extends RWSViewComponent {
8
8
 
9
9
  @attr({ converter: nullableNumberConverter })
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Transformer as HTMLTagTransformerType, Tag as HTMLTag, Attributes as HTMLAttributes } from 'sanitize-html';
2
2
  import { observable, attr } from '@microsoft/fast-element';
3
- import IRWSConfig from './interfaces/IRWSConfig';
3
+ import IRWSConfig from './types/IRWSConfig';
4
4
  import RWSNotify, { NotifyUiType, NotifyLogType } from './types/RWSNotify';
5
5
  import { provideRWSDesignSystem } from './components/_design_system';
6
6
  import RWSService from './services/_service';
@@ -14,8 +14,8 @@ import { sanitizedAttr } from './components/_attrs/sanitize-html';
14
14
  import { ngAttr } from './components/_attrs/angular-attr';
15
15
  import { RWSPlugin, DefaultRWSPluginOptionsType } from './plugins/_plugin';
16
16
  import RWSClient, { RWSClientInstance } from './client';
17
- import { RWSPluginEntry } from './interfaces/IRWSConfig';
18
- import IRWSUser from './interfaces/IRWSUser';
17
+ import { RWSPluginEntry } from './types/IRWSConfig';
18
+ import IRWSUser from './types/IRWSUser';
19
19
  import RWSViewComponent, { IAssetShowOptions } from './components/_component';
20
20
 
21
21
  import RWSContainer from './components/_container';
@@ -1,7 +1,7 @@
1
1
  import RWSContainer from "../components/_container";
2
2
  import { Container } from "@microsoft/fast-foundation";
3
- import RWSWindow, {loadRWSRichWindow } from '../interfaces/RWSWindow';
4
- import IRWSUser from "../interfaces/IRWSUser";
3
+ import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
4
+ import IRWSUser from "../types/IRWSUser";
5
5
  import { RWSInfoType } from "../client/components";
6
6
 
7
7
  type DefaultRWSPluginOptionsType = { enabled: boolean };
@@ -1,5 +1,5 @@
1
1
  import TheService from './_service';
2
- import IRWSConfig from '../interfaces/IRWSConfig';
2
+ import IRWSConfig from '../types/IRWSConfig';
3
3
  import { RWSFillBuild } from '../components/_decorators/RWSFillBuild';
4
4
 
5
5
 
@@ -117,9 +117,7 @@ class ConfigService extends TheService {
117
117
  mergeConfig(config: IRWSConfig) {
118
118
  const unloaded = ConfigService.isLoaded;
119
119
 
120
- if(!Object.keys(this.data).includes('plugins')){
121
- this.data.plugins = [];
122
- }
120
+ this.data.plugins = [];
123
121
 
124
122
  this.data = Object.assign(this.data, config);
125
123
 
@@ -1,6 +1,6 @@
1
1
  import { DI, InterfaceSymbol, Key, Registration } from '@microsoft/fast-foundation';
2
2
  import RWSContainer from '../components/_container';
3
- import { loadRWSRichWindow } from '../interfaces/RWSWindow';
3
+ import { loadRWSRichWindow } from '../types/RWSWindow';
4
4
 
5
5
  export interface IWithDI<T> {
6
6
  new (...args: any[]): T;
@@ -0,0 +1,30 @@
1
+ $darkreader-base-globals: (
2
+ 'neutral-background': var(--rws-darkreader-neutral-background, #212222),
3
+ 'neutral-text': var(--rws-darkreader-neutral-text, #eae3d9),
4
+ 'selection-background': var(--rws-darkreader-selection-background, #165aaa),
5
+ 'selection-text': var(--rws-darkreader-selection-text, #624e2f)
6
+ );
7
+
8
+ $darkreader-elements: ('text', 'bg', 'border', 'neutral', 'selection');
9
+
10
+ @mixin darkreader-for-var($element, $variable_name, $color){
11
+ --darkreader-#{$element}--#{$variable_name}: #{$color};
12
+ }
13
+
14
+ @mixin darkreader-for-varmap($element, $variable-map){
15
+ @each $key, $value in $variable-map {
16
+ @include darkreader-for-var($element, $key, $value);
17
+ }
18
+ }
19
+
20
+ @mixin darkreader-all-for-varmap($variable-map){
21
+ @each $element in $darkreader-elements {
22
+ @include darkreader-for-varmap($element, $variable-map);
23
+ }
24
+ }
25
+
26
+ @mixin darkreader-global(){
27
+ @each $field, $color in $darkreader-base-globals {
28
+ --darkreader-#{$field}: #{$color};
29
+ }
30
+ }
@@ -0,0 +1,76 @@
1
+ $mediaQuerySteps: (
2
+ 'md': var(--rws-md-width, 1200px),
3
+ 'sm': var(--rws-sm-width, 992px),
4
+ 'xs': var(--rws-xs-width, 768px)
5
+ );
6
+
7
+ // Mixin for the grid container
8
+ @mixin grid-container() {
9
+ display: flex;
10
+ flex-wrap: wrap;
11
+ }
12
+
13
+ @mixin grid-container-gap($gap) {
14
+ gap: $gap;
15
+ margin-right: -#{$gap};
16
+ margin-left: -#{$gap};
17
+ }
18
+
19
+ // Mixin for grid columns
20
+
21
+ @mixin internal-grid-column($columns: 12) {
22
+ flex: 0 0 calc(100% / 12 * $columns);
23
+ max-width: calc(100% / 12 * $columns);
24
+ }
25
+
26
+ @mixin grid-column($columns: 12) {
27
+ @include internal-grid-column($columns);
28
+ }
29
+
30
+ @mixin grid-column($columns: 12, $mdColumns: 12) {
31
+ @include internal-grid-column($columns);
32
+
33
+ @media screen and (max-width: map-get($mediaQuerySteps, 'md')) {
34
+ @include internal-grid-column($mdColumns);
35
+ }
36
+ }
37
+
38
+ @mixin grid-column($columns: 12, $mdColumns: 12, $smColumns: 12) {
39
+ @include internal-grid-column($columns);
40
+
41
+ @media screen and (max-width: map-get($mediaQuerySteps, 'md')) {
42
+ @include internal-grid-column($mdColumns);
43
+ }
44
+
45
+ @media screen and (max-width: map-get($mediaQuerySteps, 'sm')) {
46
+ @include internal-grid-column($smColumns);
47
+ }
48
+ }
49
+
50
+ @mixin grid-column($columns: 12, $mdColumns: 12, $smColumns: 12, $xsColumns: 12) {
51
+ @include internal-grid-column($columns);
52
+
53
+ @media screen and (max-width: map-get($mediaQuerySteps, 'md')) {
54
+ @include internal-grid-column($mdColumns);
55
+ }
56
+
57
+ @media screen and (max-width: map-get($mediaQuerySteps, 'sm')) {
58
+ @include internal-grid-column($smColumns);
59
+ }
60
+
61
+ @media screen and (max-width: map-get($mediaQuerySteps, 'xs')) {
62
+ @include internal-grid-column($xsColumns);
63
+ }
64
+ }
65
+
66
+ // Mixins for grid alignment
67
+
68
+ @mixin grid-flex-align-items($horizontal, $vertical: top) {
69
+ justify-content: $horizontal;
70
+ align-items: $vertical;
71
+ }
72
+
73
+ @mixin center-container() {
74
+ margin-left: auto;
75
+ margin-right: auto;
76
+ }
@@ -0,0 +1,9 @@
1
+ @function px-to-em($pixels, $base-font-size: 16) {
2
+ @return #{calc($pixels / $base-font-size)}em;
3
+ }
4
+
5
+ @mixin vars($variables) {
6
+ @each $name, $value in $variables {
7
+ --#{$name}: #{$value};
8
+ }
9
+ }
@@ -0,0 +1,41 @@
1
+ @mixin customScrollbars($width: 10px, $trackColor: #f1f1f1, $thumbColor: #888) {
2
+
3
+ /* WebKit (Safari/Chrome) */
4
+ &::-webkit-scrollbar {
5
+ width: $width;
6
+ }
7
+
8
+ &::-webkit-scrollbar-track {
9
+ background: $trackColor;
10
+ }
11
+
12
+ &::-webkit-scrollbar-thumb {
13
+ background: $thumbColor;
14
+ }
15
+
16
+ /* Firefox */
17
+ &::-moz-scrollbar {
18
+ width: $width;
19
+ }
20
+
21
+ &::-moz-scrollbar-track {
22
+ background: $trackColor;
23
+ }
24
+
25
+ &::-moz-scrollbar-thumb {
26
+ background: $thumbColor;
27
+ }
28
+
29
+ /* IE/Edge */
30
+ &::-ms-scrollbar {
31
+ width: $width;
32
+ }
33
+
34
+ &::-ms-scrollbar-track {
35
+ background: $trackColor;
36
+ }
37
+
38
+ &::-ms-scrollbar-thumb {
39
+ background: $thumbColor;
40
+ }
41
+ }
@@ -1,99 +1,4 @@
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
-
61
- /* WebKit (Safari/Chrome) */
62
- &::-webkit-scrollbar {
63
- width: $width;
64
- }
65
-
66
- &::-webkit-scrollbar-track {
67
- background: $trackColor;
68
- }
69
-
70
- &::-webkit-scrollbar-thumb {
71
- background: $thumbColor;
72
- }
73
-
74
- /* Firefox */
75
- &::-moz-scrollbar {
76
- width: $width;
77
- }
78
-
79
- &::-moz-scrollbar-track {
80
- background: $trackColor;
81
- }
82
-
83
- &::-moz-scrollbar-thumb {
84
- background: $thumbColor;
85
- }
86
-
87
- /* IE/Edge */
88
- &::-ms-scrollbar {
89
- width: $width;
90
- }
91
-
92
- &::-ms-scrollbar-track {
93
- background: $trackColor;
94
- }
95
-
96
- &::-ms-scrollbar-thumb {
97
- background: $thumbColor;
98
- }
99
- }
1
+ @import "_misc";
2
+ @import "_scrollbars";
3
+ @import "_grid";
4
+ @import "_darkreader";
@@ -1,11 +1,9 @@
1
- //@ts-ignore all
2
-
3
1
  declare module '*.scss' {
4
- const content: import('@microsoft/fast-element').ElementStyles;
2
+ const content: string;
5
3
  export default content;
6
4
  }
7
5
 
8
6
  declare module '*.html' {
9
- const content: import('@microsoft/fast-element').ViewTemplate;
7
+ const content: string;
10
8
  export default content;
11
9
  }
@@ -1,20 +1,8 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
1
 
4
- module.exports = function(content) {
5
- const filePath = this.resourcePath;
6
-
7
- const dirPath = path.dirname(filePath);
8
- const tsPath = `${dirPath}/component.ts`;
9
-
10
- fs.readFile(tsPath, { encoding: 'utf-8' }, (err, content) => {
11
- fs.writeFileSync(tsPath, content);
12
2
 
13
- if (err) {
14
- throw new Error('Error reading file:', tsPath);
15
- }
16
- });
17
-
18
-
19
- return '';
3
+ module.exports = async function(content) {
4
+ const filePath = this.resourcePath;
5
+ const isDev = this._compiler.options.mode === 'development';
6
+
7
+ return content;
20
8
  };
@@ -9,7 +9,7 @@ module.exports = function(content) {
9
9
 
10
10
  const options = this.getOptions() || { minify: false };
11
11
 
12
- const isDev = this._compiler.options.dev;
12
+ const isDev = this._compiler.options.mode === 'development';
13
13
 
14
14
  const saveFile = content.indexOf('@save') > -1;
15
15
  let fromTs = false;
@@ -21,34 +21,26 @@ module.exports = function(content) {
21
21
  try {
22
22
  const code = plugin.compileScssCode(content, path.dirname(filePath), null, filePath, !isDev);
23
23
 
24
- if (fromTs) {
25
- if (saveFile && code) {
26
- plugin.writeCssFile(filePath, code);
27
-
28
- const newContext = this;
29
-
30
- // Properly setup the context for css-loader
31
- const loaderContext = {
32
- ...newContext,
33
- query: { sourceMap: isDev },
34
- async: () => (err, output) => {
35
- if (err) {
36
- callback(err);
37
- return;
38
- }
39
- callback(null, output);
40
- }
41
- };
42
-
43
- // Execute css-loader
44
- cssLoader.call(loaderContext, code);
45
- } else {
46
- const tsCode = `import { css } from '@microsoft/fast-element';\nexport default css\`${code}\`;`;
47
- callback(null, tsCode);
48
- }
49
- } else {
50
- callback(null, code);
24
+ if (fromTs && saveFile && code) {
25
+ plugin.writeCssFile(filePath, code);
51
26
  }
27
+
28
+ // Properly setup the context for css-loader
29
+ const loaderContext = {
30
+ ...this,
31
+ query: { sourceMap: isDev },
32
+ async: () => (err, output) => {
33
+ if (err) {
34
+ callback(err);
35
+ return;
36
+ }
37
+ callback(null, output);
38
+ }
39
+ };
40
+
41
+ // Execute css-loader with the generated CSS code
42
+ cssLoader.call(loaderContext, code);
43
+
52
44
  } catch (e) {
53
45
  console.error(e);
54
46
  callback(e);
@@ -4,6 +4,7 @@ const fs = require('fs');
4
4
  const ts = require('typescript');
5
5
  const tools = require('../../_tools');
6
6
  const chalk = require('chalk');
7
+ const {html_error_proof} = require('./ts/html_error');
7
8
 
8
9
  const _defaultRWSLoaderOptions = {
9
10
  templatePath: 'template.html',
@@ -11,35 +12,14 @@ const _defaultRWSLoaderOptions = {
11
12
  fastOptions: { shadowOptions: { mode: 'open' } }
12
13
  }
13
14
 
14
- const ERROR_HANDLER_CODE = (htmlContent, isDev = false) => {
15
- const code = `
16
- async function handleError(error: Error | any) {
17
- const errorMessage = \`RWS HTML Error:\n\${error.stack}\`;
18
- console.error('RWS HTML error', errorMessage);
19
- return T.html\`<div class="rws-error"><h1>RWS HTML template error</h1>\${errorMessage}</div>\`;
20
- }
21
-
22
- try {
23
- //@ts-ignore
24
- rwsTemplate =
25
- T.html\`
26
- ${isDev ? htmlContent : htmlContent.replace(/\n/g, '')}\`;
27
- } catch (error: Error | any) {
28
- rwsTemplate = handleError(error);
29
- }`;
30
-
31
- if(!isDev){
32
- return code;
33
- }
34
-
35
- return code.replace(/\n/g, '');
36
- };
15
+ let htmlFastImports = null;
37
16
 
38
17
  module.exports = async function(content) {
39
18
  let processedContent = content;
40
19
  const filePath = this.resourcePath;
41
- const isDev = this._compiler.options.dev;
42
- const htmlMinify = this._compiler.options.htmlMnify || true;
20
+ const isDev = this._compiler.options.mode === 'development';
21
+
22
+ const htmlMinify = this._compiler.options.htmlMinify || true;
43
23
 
44
24
  const RWSViewRegex = /(@RWSView\([^)]*)\)/;
45
25
  const tsSourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
@@ -94,25 +74,21 @@ module.exports = async function(content) {
94
74
  let styles = 'const styles: null = null;'
95
75
 
96
76
  if(fs.existsSync(path.dirname(filePath) + '/styles')){
97
- styles = `import styles from './${stylesPath}';`;
77
+ styles = `import componentCSS from './${stylesPath}';\n`;
78
+ styles += `const styles = T.css\`\${componentCSS}\`;`;
98
79
  }
99
80
 
100
81
  const templateName = 'template';
101
82
  const templatePath = path.dirname(filePath) + `/${templateName}.html`;
102
83
  const templateExists = fs.existsSync(templatePath, 'utf-8');
103
- let template = 'const template: null = null;';
84
+ let template = 'const rwsTemplate: null = null;';
104
85
 
105
86
  if(templateExists){
87
+ htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport RWSTemplateHTML from './${templateName}.html';`;
106
88
  this.addDependency(templatePath);
107
-
108
- let htmlContent = fs.readFileSync(templatePath, 'utf-8');
109
- const originalContent = htmlContent;
110
-
111
89
  template = `
112
- import './${templateName}.html';
113
- let rwsTemplate:any = null;
114
- ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
115
- `;
90
+ let rwsTemplate: any = T.html\`\${RWSTemplateHTML}\`;
91
+ `;
116
92
  }
117
93
 
118
94
  const viewReg = /@RWSView\(['"]([a-zA-Z0-9_-]+)['"],?.*\)\sclass\s([a-zA-Z0-9_-]+) extends RWSViewComponent/gs
@@ -142,7 +118,7 @@ ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
142
118
  processedContent = `${template}\n${styles}\n${addedParamDefs.join('\n')}\n` + replacedViewDecoratorContent;
143
119
  }
144
120
 
145
- processedContent = `import * as T from '@microsoft/fast-element';\n${processedContent}`;
121
+ processedContent = `${htmlFastImports ? htmlFastImports + '\n' : ''}${processedContent}`;
146
122
  }
147
123
 
148
124
  const debugTsPath = filePath.replace('.ts','.debug.ts');
@@ -157,9 +133,10 @@ ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
157
133
  }
158
134
 
159
135
  return processedContent;
160
-
161
136
  }catch(e){
162
- console.error(e);
163
- return content;
137
+ console.log(chalk.red('RWS Typescript loader error:'));
138
+ console.error(e);
139
+
140
+ throw new Error('RWS Build failed on: ' + filePath);
164
141
  }
165
142
  };
@@ -0,0 +1,20 @@
1
+ function html_error_proof(htmlContent){
2
+ return `async function handleError(error: Error | any) {
3
+ const errorMessage = \`RWS HTML Error:\n\${error.stack}\`;
4
+ console.error('RWS HTML error', errorMessage);
5
+ return T.html\`<div class="rws-error"><h1>RWS HTML template error</h1>\${errorMessage}</div>\`;
6
+ }
7
+
8
+ try {
9
+ //@rws-template-source
10
+ rwsTemplate =
11
+ T.html\`
12
+ ${htmlContent}\`;
13
+ } catch (error: Error | any) {
14
+ rwsTemplate = handleError(error);
15
+ }`
16
+ }
17
+
18
+ module.exports = {
19
+ html_error_proof
20
+ }
@@ -62,9 +62,16 @@ class RWSScssPlugin {
62
62
  const usesPath = match[1];
63
63
  const usesLine = match[0];
64
64
 
65
- uses.push([usesPath, usesLine]);
65
+ if(!uses.find((item) => {
66
+ console.log(item);
67
+ return item[0] == usesPath
68
+ }) && !usesPath !== 'sass:math'){
69
+ uses.push([usesPath, usesLine]);
70
+ }
66
71
  }
67
72
 
73
+ // console.log(uses);
74
+
68
75
  return [uses];
69
76
  }
70
77
 
@@ -353,8 +360,13 @@ class RWSScssPlugin {
353
360
 
354
361
  uses.forEach(scssUse => {
355
362
  const useLine = scssUse[1];
356
- scssUses += useLine + '\n';
357
- scssCode = scssCode.replace(useLine, '');
363
+ if(scssCode.indexOf(useLine) === -1){
364
+ console.log(scssCode);
365
+ scssUses += useLine + '\n';
366
+ scssCode = scssCode.replace(useLine + '\n', '');
367
+ }else{
368
+ console.log('ommiting @use. detected in:', fileRootDir, scssUse)
369
+ }
358
370
  });
359
371
 
360
372
  scssCode = scssUses + scssCode;
@@ -362,7 +374,7 @@ class RWSScssPlugin {
362
374
  try {
363
375
 
364
376
  const result = sass.compileString(scssCode, { loadPaths: [fileRootDir], style: minify ? 'compressed' : 'expanded' });
365
- let finalCss = result.css;
377
+ let finalCss = result.css.toString();
366
378
 
367
379
  return this.replaceFontUrlWithBase64(finalCss);
368
380
  } catch (err) {
File without changes
File without changes
File without changes
File without changes