@rws-framework/client 2.18.1 → 2.18.3

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.
@@ -15,7 +15,6 @@ const { setComponentsChunks, scanComponents, generateRWSInfoFile, partedComponen
15
15
  const { getBuildConfig } = require('../../cfg/build_steps/webpack/_build_config');
16
16
  const { createWebpackConfig } = require('../../cfg/build_steps/webpack/_webpack_config');
17
17
  const { executeRWSStartActions, timingActions, devActions } = require('../../cfg/build_steps/webpack/_actions');
18
- const { webpackDevServer } = require('../../cfg/build_steps/webpack/_dev_servers');
19
18
  const { RWS_WEBPACK_PLUGINS_BAG, addStartPlugins } = require('../../cfg/build_steps/webpack/_plugins');
20
19
 
21
20
 
@@ -14,7 +14,7 @@ function processImportPath(importPath, rwsWorkspaceDir, appRootDir, fileRootDir
14
14
  const workspaceDir = this.getRWSWorkspaceDir ? this.getRWSWorkspaceDir() : rwsWorkspaceDir;
15
15
  const appRoot = this.getRWSWorkspaceDir ? this.getRWSRootDir() : appRootDir;
16
16
 
17
- if (importPath.split('')[0] === '~') {
17
+ if (importPath.split('')[0] === '~') {
18
18
  return fillSCSSExt(replaceWithNodeModules(importPath, appRoot, null, true), noext);
19
19
  }
20
20
 
@@ -136,8 +136,7 @@ function detectImports(code) {
136
136
  }
137
137
 
138
138
  function replaceWithNodeModules(input, appRootDir, fileDir = null, absolute = false, token = '~') {
139
- _scss_fs = _scss_fs_builder(this);
140
-
139
+ _scss_fs = _scss_fs_builder(this);
141
140
  return input.replace(token, absolute ? `${path.join(appRootDir, 'node_modules')}/` : this.node_modules_dir(fileDir ? fileDir : appRootDir));
142
141
  }
143
142
 
@@ -89,6 +89,8 @@ function getRWSLoaders(packageDir, executionDir, tsConfigData, appRootDir, entry
89
89
  },
90
90
  ];
91
91
 
92
+ console.log(loaders[2].include);
93
+
92
94
  return loaders;
93
95
  }
94
96
 
@@ -252,7 +254,7 @@ async function getTemplate(filePath, addDependency, templateName = null, isDev =
252
254
 
253
255
  if (templateExists) {
254
256
  const templateContent = fs.readFileSync(templatePath, 'utf-8').replace(/<!--[\s\S]*?-->/g, '');
255
- htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport './${templateName}.html';\n`;
257
+ htmlFastImports = `import * as T from '@microsoft/fast-element';\nimport { html, css, ref, when, repeat, slotted, children } from '@microsoft/fast-element'; \nimport './${templateName}.html';\n`;
256
258
  template = `
257
259
  //@ts-ignore
258
260
  let rwsTemplate: any = T.html\`${templateContent}\`;
@@ -54,7 +54,7 @@ async function createWebpackConfig({
54
54
  path: false
55
55
  }
56
56
  },
57
- devServer: hotReload ? getRWSHotReloadSetup(hotReloadPort, outputDir) : null,
57
+ devServer: hotReload ? getRWSHotReloadSetup(hotReloadPort, outputDir) : false,
58
58
  module: {
59
59
  rules: getRWSLoaders(_packageDir, executionDir, tsConfig, appRootDir, entrypoint),
60
60
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.18.1",
4
+ "version": "2.18.3",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -44,7 +44,8 @@
44
44
  "upload": "^1.3.2",
45
45
  "url-router": "^13.0.0",
46
46
  "uuid": "^9.0.1",
47
- "v4": "^0.0.1"
47
+ "v4": "^0.0.1",
48
+ "scss-loading-animations": "^1.0.1"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/dragula": "^3.7.4",
@@ -152,11 +152,11 @@ async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<
152
152
  await plugin.onClientStart();
153
153
  }
154
154
 
155
- if(this.appConfig.get('hotReload')){
156
- if (module.hot) {
157
- module.hot.accept();
158
- }
159
- }
155
+ // if(this.appConfig.get('hotReload')){
156
+ // if (module.hot) {
157
+ // module.hot.accept();
158
+ // }
159
+ // }
160
160
 
161
161
  return this;
162
162
  }
@@ -1,8 +1,9 @@
1
1
  import { RWSView } from '../../_decorator';
2
2
  import { RWSViewComponent } from '../../_component';
3
+ import { attr } from '@microsoft/fast-element';
3
4
 
4
- @RWSView('the-loader')
5
- class RWSLoader extends RWSViewComponent {
5
+ @RWSView('rws-loader')
6
+ class RWSLoader extends RWSViewComponent {
6
7
  connectedCallback(): void {
7
8
  super.connectedCallback();
8
9
  }
@@ -1,14 +1,14 @@
1
1
  //loader
2
2
  //save
3
- $loader-color: var(--primary-color, #eb7b13);
4
- $loader-size: 56px;
3
+ $loader-color: var(--rws-loader-color, #eb7b13);
4
+ $loader-size: 26px;
5
5
  $loader-height: 20px;
6
6
  $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 loader06;
14
+ }
@@ -5,8 +5,13 @@ import { RWSView} from '../../_decorator';
5
5
  @RWSView('rws-modal')
6
6
  class RWSModal extends RWSViewComponent {
7
7
  @observable closeModal: () => void
8
+ @observable onShowModal: ($: ShadowRoot) => void
9
+
8
10
  connectedCallback(): void {
9
- super.connectedCallback();
11
+ super.connectedCallback();
12
+ if(this.onShowModal){
13
+ this.onShowModal(this.shadowRoot);
14
+ }
10
15
  }
11
16
  }
12
17
 
@@ -45,7 +45,7 @@ type IBackendRoute = IHTTProute | IPrefixedHTTProutes;
45
45
 
46
46
  class ApiService extends TheService {
47
47
  static _DEFAULT: boolean = true;
48
- private token?: string;
48
+ public token?: string;
49
49
 
50
50
  constructor(@ConfigService public config: ConfigServiceInstance) {
51
51
  super();
@@ -60,7 +60,7 @@ class ApiService extends TheService {
60
60
 
61
61
  public async isGetTargetReachable(url: string, options: IAPIOptions = {}): Promise<boolean> {
62
62
  try {
63
- return !!(await calls.pureGet(url, options, this.token));
63
+ return !!(await calls.pureGet.bind(this)(url, options));
64
64
  } catch (error) {
65
65
  return false;
66
66
  }
@@ -89,16 +89,16 @@ class ApiService extends TheService {
89
89
  public delete = calls.delete;
90
90
 
91
91
  public back = {
92
- get: <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.get(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options, this.token),
93
- post: <T, P extends object = object>(routeName: string, payload?: P, options?: IAPIOptions): Promise<T> => calls.post(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options, this.token),
94
- put: <T, P extends object = object>(routeName: string, payload: P, options?: IAPIOptions): Promise<T> => calls.put(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options, this.token),
95
- delete: <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.delete(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options, this.token),
96
- uploadFile: (routeName: string, file: File, onProgress: (progress: number) => void, options: IAPIOptions = {}, payload: any = {}): Promise<UploadResponse> => this.uploadFile(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), file, onProgress, payload),
92
+ get: async <T>(routeName: string, options?: IAPIOptions, token?: string): Promise<T> => calls.get.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options) as Promise<T>,
93
+ post: async <T, P extends object = object>(routeName: string, payload?: P, options?: IAPIOptions): Promise<T> => calls.post.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options) as Promise<T>,
94
+ put: async <T, P extends object = object>(routeName: string, payload: P, options?: IAPIOptions): Promise<T> => calls.put.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), payload, options) as Promise<T>,
95
+ delete: async <T>(routeName: string, options?: IAPIOptions): Promise<T> => calls.delete.bind(this)(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), options) as Promise<T>,
96
+ uploadFile: async (routeName: string, file: File, onProgress: (progress: number) => void, options: IAPIOptions = {}, payload: any = {}): Promise<UploadResponse> => this.uploadFile(backend.getBackendUrl.bind(this)(routeName, options?.routeParams), file, onProgress, payload),
97
97
  };
98
98
 
99
99
  async getResource(resourceName: string): Promise<IKDBTypesResponse>
100
100
  {
101
- return calls.get(`${this.config.get('backendUrl')}${this.config.get('apiPrefix') || ''}/api/rws/resource/${resourceName}`)
101
+ return calls.get.bind(this)(`${this.config.get('backendUrl')}${this.config.get('apiPrefix') || ''}/api/rws/resource/${resourceName}`) as Promise<IKDBTypesResponse>
102
102
  }
103
103
  }
104
104
 
@@ -2,7 +2,7 @@ import { ApiServiceInstance, IBackendRoute, IHTTProute } from "../ApiService";
2
2
  import { ConfigServiceInstance } from "../ConfigService";
3
3
 
4
4
  export const backend = {
5
- getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {})
5
+ getBackendUrl(this: ApiServiceInstance, routeName: string, params: {[key: string]: string} = {}): string
6
6
  {
7
7
  const config = this.config;
8
8
  const routesPackage = config.get('backendRoutes');
@@ -1,10 +1,11 @@
1
- import { IAPIOptions } from "../ApiService";
1
+ import { ApiServiceInstance, IAPIOptions } from "../ApiService";
2
2
 
3
3
  const _DEFAULT_CONTENT_TYPE = 'application/json';
4
4
 
5
+ type HeadersType = Headers | [string, string][] | Record<string, string>;
6
+
5
7
  export const calls = {
6
- addHeader(headers: Headers | [string, string][] | {[key: string]: string}, key: string, val: string)
7
- {
8
+ addHeader(headers: HeadersType, key: string, val: string): void {
8
9
  if (headers instanceof Headers) {
9
10
  headers.append(key, val);
10
11
  } else if (Array.isArray(headers)) {
@@ -13,29 +14,31 @@ export const calls = {
13
14
  headers[key] = val;
14
15
  }
15
16
  },
16
- getHeaders(token: string = null, optHeaders: HeadersInit = {}): HeadersInit {
17
- const headers: HeadersInit = { ...optHeaders };
17
+
18
+ getHeaders(token: string | null = null, optHeaders: HeadersInit = {}): HeadersInit {
19
+ const headers: Record<string, string> = { ...(optHeaders as Record<string, string>) };
18
20
 
19
21
  if (!('Content-Type' in headers)) {
20
22
  this.addHeader(headers, 'Content-Type', _DEFAULT_CONTENT_TYPE);
21
- }
22
-
23
+ }
24
+
23
25
  if (token) {
24
- this.addHeader(headers, 'Authorization', `Bearer ${token}`);
25
- }
26
+ this.addHeader(headers, 'Authorization', `Bearer ${token}`);
27
+ }
26
28
 
27
- if((headers as any)['Content-Type']){
29
+ if (headers['Content-Type']) {
28
30
  this.addHeader(headers, 'Accept', '*/*');
29
- }else{
30
- this.addHeader(headers, 'Accept', (headers as any)['Content-Type']);
31
+ } else {
32
+ this.addHeader(headers, 'Accept', headers['Content-Type'] || _DEFAULT_CONTENT_TYPE);
31
33
  }
32
34
 
33
35
  return headers;
34
36
  },
35
- async pureGet(url: string, options: IAPIOptions = {}, token: string = null): Promise<string> {
37
+
38
+ async pureGet(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<string> {
36
39
  try {
37
40
  const response = await fetch(url, {
38
- headers: this.getHeaders(token, options.headers),
41
+ headers: calls.getHeaders(this.token, options.headers),
39
42
  });
40
43
  return await response.text();
41
44
  } catch (error) {
@@ -43,53 +46,71 @@ export const calls = {
43
46
  throw error;
44
47
  }
45
48
  },
46
- async get<T>(url: string, options: IAPIOptions = {}, token: string = null): Promise<T> {
49
+
50
+ async get<T>(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<T> {
47
51
  try {
48
52
  const response = await fetch(url, {
49
- headers: this.getHeaders(token, options.headers),
53
+ headers: calls.getHeaders(this.token, options.headers),
50
54
  });
51
- return await response.json();
55
+ const data: T = await response.json();
56
+ return data;
52
57
  } catch (error) {
53
58
  console.error('GET request failed:', error);
54
59
  throw error;
55
60
  }
56
- },
57
- async post<T, P extends object = object>(url: string, payload?: P, options: IAPIOptions = {}, token: string = null): Promise<T> {
61
+ },
62
+
63
+ async post<T, P extends object = object>(
64
+ this: ApiServiceInstance,
65
+ url: string,
66
+ payload?: P,
67
+ options: IAPIOptions = {}
68
+ ): Promise<T> {
58
69
  try {
59
70
  const response = await fetch(url, {
60
71
  method: 'POST',
61
- headers: this.getHeaders(token, options.headers),
72
+ headers: calls.getHeaders(this.token, options.headers),
62
73
  body: payload ? JSON.stringify(payload) : null,
63
74
  });
64
- return await response.json();
75
+ const data: T = await response.json();
76
+ return data;
65
77
  } catch (error) {
66
78
  console.error('POST request failed:', error);
67
79
  throw error;
68
80
  }
69
- },
70
- async put<T, P extends object = object>(url: string, payload?: P, options: IAPIOptions = {}, token: string = null): Promise<T> {
81
+ },
82
+
83
+ async put<T, P extends object = object>(
84
+ this: ApiServiceInstance,
85
+ url: string,
86
+ payload: P,
87
+ options: IAPIOptions = {}
88
+ ): Promise<T> {
71
89
  try {
72
90
  const response = await fetch(url, {
73
91
  method: 'PUT',
74
- headers: this.getHeaders(token, options.headers),
75
- body: payload ? JSON.stringify(payload) : null,
92
+ headers: calls.getHeaders(this.token, options.headers),
93
+ body: JSON.stringify(payload),
76
94
  });
77
- return await response.json();
95
+ const data: T = await response.json();
96
+ return data;
78
97
  } catch (error) {
79
98
  console.error('PUT request failed:', error);
80
99
  throw error;
81
100
  }
82
- },
83
- async delete<T>(url: string, options: IAPIOptions = {}, token: string = null): Promise<T> {
101
+ },
102
+
103
+ async delete<T>(this: ApiServiceInstance, url: string, options: IAPIOptions = {}): Promise<T> {
84
104
  try {
85
105
  const response = await fetch(url, {
86
106
  method: 'DELETE',
87
- headers: this.getHeaders(token, options.headers),
107
+ headers: calls.getHeaders(this.token, options.headers),
88
108
  });
89
- return await response.json();
109
+ const data: T = await response.json();
110
+ return data;
90
111
  } catch (error) {
91
112
  console.error('DELETE request failed:', error);
92
113
  throw error;
93
114
  }
94
115
  }
95
- }
116
+ };
@@ -1,15 +0,0 @@
1
-
2
-
3
- function webpackDevServer(BuildConfigurator, rwsFrontendConfig, cfgExport){
4
- const backendUrl = BuildConfigurator.get('backendUrl') || rwsFrontendConfig.backendUrl;
5
- const apiPort = BuildConfigurator.get('apiPort') || rwsFrontendConfig.apiPort;
6
-
7
- if (backendUrl && apiPort) {
8
- // cfgExport.devServer = {
9
- // hot: true, // Enable hot module replacement
10
- // open: true, // Automatically open the browser
11
- // }
12
- }
13
- }
14
-
15
- module.exports = { webpackDevServer }