@rws-framework/client 2.8.1 → 2.8.4

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/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.4",
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",
@@ -74,6 +74,7 @@
74
74
  "style-loader": "^3.3.3",
75
75
  "terser-webpack-plugin": "^5.3.9",
76
76
  "ts-loader": "^9.4.4",
77
+ "html-loader": "^5.0.0",
77
78
  "ts-node": "^10.9.1",
78
79
  "tsconfig-paths": "^4.2.0",
79
80
  "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
 
@@ -227,7 +226,7 @@ const RWSWebpackWrapper = async (config) => {
227
226
  },
228
227
  mode: isDev ? 'development' : 'production',
229
228
  target: 'web',
230
- devtool: isDev ? (config.devtool || 'inline-source-map') : false,
229
+ devtool: devTools,
231
230
  output: {
232
231
  path: outputDir,
233
232
  filename: isParted ? (partedPrefix || 'rws') + '.[name].js' : outputFileName,
@@ -245,6 +244,9 @@ const RWSWebpackWrapper = async (config) => {
245
244
  {
246
245
  test: /\.html$/,
247
246
  use: [
247
+ {
248
+ loader: 'html-loader'
249
+ },
248
250
  path.resolve(__dirname, './webpack/loaders/rws_fast_html_loader.js')
249
251
  ],
250
252
  },
@@ -274,7 +276,10 @@ const RWSWebpackWrapper = async (config) => {
274
276
  loader: path.resolve(__dirname, './webpack/loaders/rws_fast_ts_loader.js'),
275
277
  }
276
278
  ],
277
- exclude: [/node_modules\/(?!\@rws-framework\/client)/, /\.debug\.ts$/],
279
+ exclude: [
280
+ /node_modules\/(?!\@rws-framework\/client)/,
281
+ /\.debug\.ts$/,
282
+ ],
278
283
  }
279
284
  ],
280
285
  },
@@ -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
 
@@ -72,6 +72,11 @@ class RWSClient {
72
72
  }
73
73
  }
74
74
 
75
+ addPlugin(pluginEntry: RWSPluginEntry<any>)
76
+ {
77
+ this.config.plugins.push(pluginEntry);
78
+ }
79
+
75
80
  async setup(config: IRWSConfig = {}): Promise<IRWSConfig> {
76
81
  return this.configHelper.setup(config);
77
82
  }
@@ -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));
@@ -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
 
@@ -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
2
  const content: import('@microsoft/fast-element').ElementStyles;
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;
@@ -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);
@@ -100,19 +80,14 @@ module.exports = async function(content) {
100
80
  const templateName = 'template';
101
81
  const templatePath = path.dirname(filePath) + `/${templateName}.html`;
102
82
  const templateExists = fs.existsSync(templatePath, 'utf-8');
103
- let template = 'const template: null = null;';
83
+ let template = 'const rwsTemplate: null = null;';
104
84
 
105
85
  if(templateExists){
86
+ htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport RWSTemplateHTML from './${templateName}.html';`;
106
87
  this.addDependency(templatePath);
107
-
108
- let htmlContent = fs.readFileSync(templatePath, 'utf-8');
109
- const originalContent = htmlContent;
110
-
111
88
  template = `
112
- import './${templateName}.html';
113
- let rwsTemplate:any = null;
114
- ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
115
- `;
89
+ let rwsTemplate: any = T.html\`\${RWSTemplateHTML}\`;
90
+ `;
116
91
  }
117
92
 
118
93
  const viewReg = /@RWSView\(['"]([a-zA-Z0-9_-]+)['"],?.*\)\sclass\s([a-zA-Z0-9_-]+) extends RWSViewComponent/gs
@@ -142,7 +117,7 @@ ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
142
117
  processedContent = `${template}\n${styles}\n${addedParamDefs.join('\n')}\n` + replacedViewDecoratorContent;
143
118
  }
144
119
 
145
- processedContent = `import * as T from '@microsoft/fast-element';\n${processedContent}`;
120
+ processedContent = `${htmlFastImports ? htmlFastImports + '\n' : ''}${processedContent}`;
146
121
  }
147
122
 
148
123
  const debugTsPath = filePath.replace('.ts','.debug.ts');
@@ -157,9 +132,10 @@ ${ERROR_HANDLER_CODE(originalContent, isDev && !htmlMinify)}
157
132
  }
158
133
 
159
134
  return processedContent;
160
-
161
135
  }catch(e){
162
- console.error(e);
163
- return content;
136
+ console.log(chalk.red('RWS Typescript loader error:'));
137
+ console.error(e);
138
+
139
+ throw new Error('RWS Build failed on: ' + filePath);
164
140
  }
165
141
  };
@@ -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
+ }
File without changes
File without changes
File without changes
File without changes