@rws-framework/client 2.20.1 → 2.20.2

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 (84) hide show
  1. package/.bin/emerge.sh +15 -15
  2. package/builder/vite/index.ts +4 -4
  3. package/builder/vite/rws.vite.config.ts +132 -132
  4. package/builder/vite/rws_scss_plugin.ts +61 -61
  5. package/builder/webpack/index.js +10 -10
  6. package/builder/webpack/rws.webpack.config.js +161 -161
  7. package/builder/webpack/rws_scss_plugin.js +90 -90
  8. package/builder/webpack/rws_webpack_plugin.js +137 -137
  9. package/cfg/_default.cfg.js +26 -26
  10. package/cfg/_storage.d.ts +22 -22
  11. package/cfg/_storage.js +42 -42
  12. package/cfg/tsconfigSetup.js +146 -146
  13. package/docs/assets/26e93147f10415a0ed4a.svg +6 -6
  14. package/docs/assets/75c9471662e97ee24f29.svg +7 -7
  15. package/docs/assets/db90e4df2373980c497d.svg +9 -9
  16. package/docs/assets/highlight.css +127 -127
  17. package/docs/assets/main.js +59 -59
  18. package/docs/assets/style.css +1414 -1414
  19. package/docs/classes/ApiServiceInstance.html +25 -25
  20. package/docs/classes/ConfigServiceInstance.html +21 -21
  21. package/docs/classes/DOMServiceInstance.html +17 -17
  22. package/docs/classes/NotifyServiceInstance.html +15 -15
  23. package/docs/classes/RWSClientInstance.html +45 -45
  24. package/docs/classes/RWSPlugin.html +13 -13
  25. package/docs/classes/RWSService.html +10 -10
  26. package/docs/classes/RWSViewComponent.html +1022 -1022
  27. package/docs/classes/ServiceWorkerServiceInstance.html +13 -13
  28. package/docs/classes/UtilsServiceInstance.html +13 -13
  29. package/docs/functions/attr.html +5 -5
  30. package/docs/functions/observable.html +3 -3
  31. package/docs/index.html +179 -179
  32. package/docs/interfaces/HTMLTag.html +3 -3
  33. package/docs/interfaces/IRWSConfig.html +20 -20
  34. package/docs/interfaces/IRWSDecoratorOptions.html +5 -5
  35. package/docs/interfaces/IRWSHttpRoute.html +2 -2
  36. package/docs/interfaces/IRWSPrefixedHTTProutes.html +2 -2
  37. package/docs/interfaces/IRWSUser.html +5 -5
  38. package/docs/modules.html +45 -45
  39. package/foundation/index.js +1 -1
  40. package/foundation/rws-foundation.d.ts +7 -7
  41. package/foundation/rws-foundation.js +7 -7
  42. package/package.json +1 -1
  43. package/service_worker/src/_service_worker.ts +83 -83
  44. package/service_worker/tsconfig.json +20 -20
  45. package/service_worker/webpack.config.js +66 -66
  46. package/src/client/components.ts +67 -67
  47. package/src/client/config.ts +175 -175
  48. package/src/client/hotReload.ts +22 -22
  49. package/src/client/services.ts +27 -27
  50. package/src/client.ts +208 -208
  51. package/src/components/_component.ts +247 -247
  52. package/src/components/_container.ts +15 -15
  53. package/src/components/_decorator.ts +122 -122
  54. package/src/components/_definitions.ts +64 -64
  55. package/src/components/_event_handling.ts +40 -40
  56. package/src/components/index.ts +25 -25
  57. package/src/index.ts +86 -86
  58. package/src/plugins/_builder.js +31 -31
  59. package/src/plugins/_plugin.ts +60 -60
  60. package/src/services/ApiService.ts +105 -105
  61. package/src/services/ConfigService.ts +125 -125
  62. package/src/services/DOMService.ts +93 -93
  63. package/src/services/NotifyService.ts +47 -47
  64. package/src/services/ServiceWorkerService.ts +60 -60
  65. package/src/services/UtilsService.ts +60 -60
  66. package/src/services/_service.ts +64 -64
  67. package/src/styles/README.md +157 -157
  68. package/src/styles/_darkreader.scss +30 -30
  69. package/src/styles/_grid.scss +75 -75
  70. package/src/styles/_grid_legacy.scss +49 -49
  71. package/src/styles/_misc.scss +8 -8
  72. package/src/styles/_scrollbars.scss +40 -40
  73. package/src/styles/includes.scss +6 -6
  74. package/src/types/IBackendCore.ts +11 -11
  75. package/src/types/IRWSConfig.ts +29 -29
  76. package/src/types/IRWSPlugin.ts +23 -23
  77. package/src/types/IRWSResource.ts +4 -4
  78. package/src/types/IRWSUser.ts +6 -6
  79. package/src/types/IRWSViewComponent.ts +36 -36
  80. package/src/types/IReFormerField.ts +4 -4
  81. package/src/types/RWSNotify.ts +6 -6
  82. package/src/types/RWSWindow.ts +41 -41
  83. package/types/declarations.d.ts +8 -8
  84. package/types/docs-typings.d.ts +15 -15
@@ -1,176 +1,176 @@
1
- import { IRWSConfig, IRWSUser, IStaticRWSPlugin } from "../index";
2
- import { RWSClientInstance } from "../client";
3
-
4
- import { RWSPlugin, DefaultRWSPluginOptionsType } from "../plugins/_plugin";
5
- import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
6
- import deepmerge from 'deepmerge';
7
- import { IPluginSpawnOption } from "../types/IRWSPlugin";
8
-
9
- import { _DEFAULT_HR_PORT } from './hotReload';
10
-
11
- function getUser(this: RWSClientInstance): IRWSUser {
12
-
13
- const localSaved = localStorage.getItem('the_rws_user');
14
-
15
- if (localSaved) {
16
- this.setUser(JSON.parse(localSaved) as IRWSUser);
17
- }
18
-
19
- return this.user;
20
- }
21
-
22
- function setUser(this: RWSClientInstance, user: IRWSUser): RWSClientInstance {
23
- if (!user || !user?.jwt_token) {
24
- console.warn('[RWS Client Warning]', 'Passed user is not valid', user);
25
- return this;
26
- }
27
-
28
- this.user = user;
29
-
30
- this.apiService.setToken(this.user.jwt_token);
31
-
32
- localStorage.setItem('the_rws_user', JSON.stringify(this.user));
33
-
34
- for(const plugin of RWSPlugin.getAllPlugins()){
35
- plugin.onSetUser(user);
36
- }
37
-
38
- return this;
39
- }
40
-
41
- function pushDataToServiceWorker(this: RWSClientInstance, type: string, data: any, asset_type: string = 'data_push'): void {
42
- let tries = 0;
43
-
44
- const doIt: () => void = () => {
45
- try {
46
- this.swService.sendDataToServiceWorker(type, data, asset_type);
47
- } catch (e) {
48
- if (tries < 3) {
49
- setTimeout(() => { doIt(); }, 300);
50
- tries++;
51
- }
52
- }
53
- };
54
-
55
- doIt();
56
- }
57
-
58
- function pushUserToServiceWorker(this: RWSClientInstance, userData: any) {
59
- this.setUser(userData);
60
- this.pushDataToServiceWorker('SET_USER', userData, 'logged_user');
61
- }
62
-
63
- function get(this: RWSClientInstance, key: string): any | null
64
- {
65
- if(Object.keys(this.customServices).includes(key)){
66
- return this.customServices[key];
67
- }
68
-
69
- if(Object.keys(this.defaultServices).includes(key)){
70
- return this.defaultServices[key];
71
- }
72
-
73
- return null;
74
- }
75
-
76
- function addPlugin<T extends DefaultRWSPluginOptionsType>(this: RWSClientInstance, pluginEntry: IPluginSpawnOption<T>){
77
- const rwsWindow: RWSWindow = loadRWSRichWindow();
78
- const pluginClass: IStaticRWSPlugin<T> = pluginEntry.pluginEntry;
79
- const pluginOptions: T = (Array.isArray(pluginEntry) ? pluginEntry[1] : { enabled: true }) as T;
80
-
81
- if(!Object.keys(rwsWindow.RWS.plugins).find(item => { item === pluginClass.name })){
82
- const pluginInstance: RWSPlugin<T> = new pluginClass(pluginOptions);
83
- this.plugins[pluginClass.name] = pluginInstance;
84
- rwsWindow.RWS.plugins[pluginClass.name] = pluginInstance;
85
- }
86
- }
87
-
88
- async function setup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<IRWSConfig> {
89
- if (this.isSetup) {
90
- return this.config;
91
- }
92
-
93
- if(this.config){
94
- this.config = deepmerge(this.config, config);
95
- }
96
-
97
- this.appConfig.mergeConfig(this.config);
98
-
99
- if (this.appConfig.get('hotReload') === true) {
100
- if(!this.appConfig.get('hotReloadPort')){
101
- this.appConfig.set('hotReloadPort', _DEFAULT_HR_PORT)
102
- }
103
- }
104
-
105
- if(this.config.plugins){
106
- for (const pluginEntry of this.config.plugins){
107
- addPlugin.bind(this)(pluginEntry);
108
- }
109
- }
110
-
111
- if(config?.user){
112
- this.setUser(config.user);
113
- }
114
-
115
- if (this.appConfig.get('parted')) {
116
- const componentParts = await this.loadPartedComponents();
117
-
118
- for (const plugin of RWSPlugin.getAllPlugins()){
119
- plugin.onPartedComponentsLoad(componentParts);
120
- }
121
- }
122
-
123
- this.isSetup = true;
124
- return this.config;
125
- }
126
-
127
- async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance> {
128
- this.config = { ...this.config, ...config };
129
-
130
- if (!this.isSetup) {
131
- this.config = await this.setup(this.config);
132
- }
133
-
134
- if (Object.keys(config).length) {
135
- this.appConfig.mergeConfig(this.config);
136
- }
137
-
138
- const setThisUser = config?.user || this.getUser();
139
-
140
- if(setThisUser){
141
- this.config.user = setThisUser;
142
- this.setUser(setThisUser);
143
- }
144
-
145
- if (this.config.user && !this.config.dontPushToSW) {
146
- this.pushUserToServiceWorker(this.user);
147
- }
148
-
149
- await this.initCallback();
150
-
151
- for (const plugin of RWSPlugin.getAllPlugins()){
152
- await plugin.onClientStart();
153
- }
154
-
155
- // if(this.appConfig.get('hotReload')){
156
- // if (module.hot) {
157
- // module.hot.accept();
158
- // }
159
- // }
160
-
161
- return this;
162
- }
163
-
164
- function getBinds(this: RWSClientInstance) {
165
- return {
166
- start: start.bind(this),
167
- setup: setup.bind(this),
168
- get: get.bind(this),
169
- setUser: setUser.bind(this),
170
- getUser: getUser.bind(this),
171
- pushDataToServiceWorker: pushDataToServiceWorker.bind(this),
172
- pushUserToServiceWorker: pushUserToServiceWorker.bind(this)
173
- };
174
- }
175
-
1
+ import { IRWSConfig, IRWSUser, IStaticRWSPlugin } from "../index";
2
+ import { RWSClientInstance } from "../client";
3
+
4
+ import { RWSPlugin, DefaultRWSPluginOptionsType } from "../plugins/_plugin";
5
+ import RWSWindow, {loadRWSRichWindow } from '../types/RWSWindow';
6
+ import deepmerge from 'deepmerge';
7
+ import { IPluginSpawnOption } from "../types/IRWSPlugin";
8
+
9
+ import { _DEFAULT_HR_PORT } from './hotReload';
10
+
11
+ function getUser(this: RWSClientInstance): IRWSUser {
12
+
13
+ const localSaved = localStorage.getItem('the_rws_user');
14
+
15
+ if (localSaved) {
16
+ this.setUser(JSON.parse(localSaved) as IRWSUser);
17
+ }
18
+
19
+ return this.user;
20
+ }
21
+
22
+ function setUser(this: RWSClientInstance, user: IRWSUser): RWSClientInstance {
23
+ if (!user || !user?.jwt_token) {
24
+ console.warn('[RWS Client Warning]', 'Passed user is not valid', user);
25
+ return this;
26
+ }
27
+
28
+ this.user = user;
29
+
30
+ this.apiService.setToken(this.user.jwt_token);
31
+
32
+ localStorage.setItem('the_rws_user', JSON.stringify(this.user));
33
+
34
+ for(const plugin of RWSPlugin.getAllPlugins()){
35
+ plugin.onSetUser(user);
36
+ }
37
+
38
+ return this;
39
+ }
40
+
41
+ function pushDataToServiceWorker(this: RWSClientInstance, type: string, data: any, asset_type: string = 'data_push'): void {
42
+ let tries = 0;
43
+
44
+ const doIt: () => void = () => {
45
+ try {
46
+ this.swService.sendDataToServiceWorker(type, data, asset_type);
47
+ } catch (e) {
48
+ if (tries < 3) {
49
+ setTimeout(() => { doIt(); }, 300);
50
+ tries++;
51
+ }
52
+ }
53
+ };
54
+
55
+ doIt();
56
+ }
57
+
58
+ function pushUserToServiceWorker(this: RWSClientInstance, userData: any) {
59
+ this.setUser(userData);
60
+ this.pushDataToServiceWorker('SET_USER', userData, 'logged_user');
61
+ }
62
+
63
+ function get(this: RWSClientInstance, key: string): any | null
64
+ {
65
+ if(Object.keys(this.customServices).includes(key)){
66
+ return this.customServices[key];
67
+ }
68
+
69
+ if(Object.keys(this.defaultServices).includes(key)){
70
+ return this.defaultServices[key];
71
+ }
72
+
73
+ return null;
74
+ }
75
+
76
+ function addPlugin<T extends DefaultRWSPluginOptionsType>(this: RWSClientInstance, pluginEntry: IPluginSpawnOption<T>){
77
+ const rwsWindow: RWSWindow = loadRWSRichWindow();
78
+ const pluginClass: IStaticRWSPlugin<T> = pluginEntry.pluginEntry;
79
+ const pluginOptions: T = (Array.isArray(pluginEntry) ? pluginEntry[1] : { enabled: true }) as T;
80
+
81
+ if(!Object.keys(rwsWindow.RWS.plugins).find(item => { item === pluginClass.name })){
82
+ const pluginInstance: RWSPlugin<T> = new pluginClass(pluginOptions);
83
+ this.plugins[pluginClass.name] = pluginInstance;
84
+ rwsWindow.RWS.plugins[pluginClass.name] = pluginInstance;
85
+ }
86
+ }
87
+
88
+ async function setup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<IRWSConfig> {
89
+ if (this.isSetup) {
90
+ return this.config;
91
+ }
92
+
93
+ if(this.config){
94
+ this.config = deepmerge(this.config, config);
95
+ }
96
+
97
+ this.appConfig.mergeConfig(this.config);
98
+
99
+ if (this.appConfig.get('hotReload') === true) {
100
+ if(!this.appConfig.get('hotReloadPort')){
101
+ this.appConfig.set('hotReloadPort', _DEFAULT_HR_PORT)
102
+ }
103
+ }
104
+
105
+ if(this.config.plugins){
106
+ for (const pluginEntry of this.config.plugins){
107
+ addPlugin.bind(this)(pluginEntry);
108
+ }
109
+ }
110
+
111
+ if(config?.user){
112
+ this.setUser(config.user);
113
+ }
114
+
115
+ if (this.appConfig.get('parted')) {
116
+ const componentParts = await this.loadPartedComponents();
117
+
118
+ for (const plugin of RWSPlugin.getAllPlugins()){
119
+ plugin.onPartedComponentsLoad(componentParts);
120
+ }
121
+ }
122
+
123
+ this.isSetup = true;
124
+ return this.config;
125
+ }
126
+
127
+ async function start(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance> {
128
+ this.config = { ...this.config, ...config };
129
+
130
+ if (!this.isSetup) {
131
+ this.config = await this.setup(this.config);
132
+ }
133
+
134
+ if (Object.keys(config).length) {
135
+ this.appConfig.mergeConfig(this.config);
136
+ }
137
+
138
+ const setThisUser = config?.user || this.getUser();
139
+
140
+ if(setThisUser){
141
+ this.config.user = setThisUser;
142
+ this.setUser(setThisUser);
143
+ }
144
+
145
+ if (this.config.user && !this.config.dontPushToSW) {
146
+ this.pushUserToServiceWorker(this.user);
147
+ }
148
+
149
+ await this.initCallback();
150
+
151
+ for (const plugin of RWSPlugin.getAllPlugins()){
152
+ await plugin.onClientStart();
153
+ }
154
+
155
+ // if(this.appConfig.get('hotReload')){
156
+ // if (module.hot) {
157
+ // module.hot.accept();
158
+ // }
159
+ // }
160
+
161
+ return this;
162
+ }
163
+
164
+ function getBinds(this: RWSClientInstance) {
165
+ return {
166
+ start: start.bind(this),
167
+ setup: setup.bind(this),
168
+ get: get.bind(this),
169
+ setUser: setUser.bind(this),
170
+ getUser: getUser.bind(this),
171
+ pushDataToServiceWorker: pushDataToServiceWorker.bind(this),
172
+ pushUserToServiceWorker: pushUserToServiceWorker.bind(this)
173
+ };
174
+ }
175
+
176
176
  export default getBinds;
@@ -1,23 +1,23 @@
1
- import { RWSClientInstance } from "../client";
2
- import IRWSConfig from "../types/IRWSConfig";
3
-
4
- export const _DEFAULT_HR_PORT = 1030;
5
-
6
- export interface IHotReloadCfg {
7
- enabled: boolean,
8
- port: number
9
- }
10
-
11
- async function hotReloadSetup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance>
12
- {
13
-
14
- return this;
15
- }
16
-
17
- function getBinds(this: RWSClientInstance) {
18
- return {
19
- hotReloadSetup: hotReloadSetup.bind(this)
20
- };
21
- }
22
-
1
+ import { RWSClientInstance } from "../client";
2
+ import IRWSConfig from "../types/IRWSConfig";
3
+
4
+ export const _DEFAULT_HR_PORT = 1030;
5
+
6
+ export interface IHotReloadCfg {
7
+ enabled: boolean,
8
+ port: number
9
+ }
10
+
11
+ async function hotReloadSetup(this: RWSClientInstance, config: IRWSConfig = {}): Promise<RWSClientInstance>
12
+ {
13
+
14
+ return this;
15
+ }
16
+
17
+ function getBinds(this: RWSClientInstance) {
18
+ return {
19
+ hotReloadSetup: hotReloadSetup.bind(this)
20
+ };
21
+ }
22
+
23
23
  export default getBinds;
@@ -1,28 +1,28 @@
1
- import { loadRWSRichWindow } from "../types/RWSWindow";
2
- import { RWSClientInstance } from "../client";
3
- type RWSInfoType = { components: string[] };
4
-
5
- async function loadServices(this: RWSClientInstance){
6
- const richWindow = loadRWSRichWindow();
7
-
8
- for (const serviceKey of Object.keys(richWindow.RWS._registered)){
9
- const currentService = this._container.get(richWindow.RWS._registered[serviceKey]);
10
-
11
- if(currentService.isInClient() && !Object.keys(this.customServices).includes(serviceKey)){
12
- this.customServices[serviceKey] = currentService;
13
- }
14
-
15
- if(currentService.isDefault() && !Object.keys(this.defaultServices).includes(serviceKey)){
16
- this.defaultServices[serviceKey] = currentService;
17
- }
18
- }
19
- }
20
-
21
-
22
- function getBinds(this: RWSClientInstance){
23
- return {
24
- loadServices: loadServices.bind(this),
25
- };
26
- }
27
-
1
+ import { loadRWSRichWindow } from "../types/RWSWindow";
2
+ import { RWSClientInstance } from "../client";
3
+ type RWSInfoType = { components: string[] };
4
+
5
+ async function loadServices(this: RWSClientInstance){
6
+ const richWindow = loadRWSRichWindow();
7
+
8
+ for (const serviceKey of Object.keys(richWindow.RWS._registered)){
9
+ const currentService = this._container.get(richWindow.RWS._registered[serviceKey]);
10
+
11
+ if(currentService.isInClient() && !Object.keys(this.customServices).includes(serviceKey)){
12
+ this.customServices[serviceKey] = currentService;
13
+ }
14
+
15
+ if(currentService.isDefault() && !Object.keys(this.defaultServices).includes(serviceKey)){
16
+ this.defaultServices[serviceKey] = currentService;
17
+ }
18
+ }
19
+ }
20
+
21
+
22
+ function getBinds(this: RWSClientInstance){
23
+ return {
24
+ loadServices: loadServices.bind(this),
25
+ };
26
+ }
27
+
28
28
  export default getBinds;