@rws-framework/client 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.bin/add-v.sh +10 -0
- package/.eslintrc.json +53 -0
- package/.setup/.eslintrc.json +11 -0
- package/.setup/tsconfig.json +29 -0
- package/README.md +691 -0
- package/_rws_externals.js +40 -0
- package/_tools.js +317 -0
- package/console.js +87 -0
- package/declarations.d.ts +9 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/26e93147f10415a0ed4a.svg +6 -0
- package/docs/assets/75c9471662e97ee24f29.svg +7 -0
- package/docs/assets/db90e4df2373980c497d.svg +9 -0
- package/docs/assets/hierarchy.css +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +120 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1414 -0
- package/docs/classes/ApiServiceInstance.html +20 -0
- package/docs/classes/DOMServiceInstance.html +10 -0
- package/docs/classes/NotifyServiceInstance.html +12 -0
- package/docs/classes/RWSClient.html +11 -0
- package/docs/classes/RWSRouter.html +9 -0
- package/docs/classes/RWSService.html +7 -0
- package/docs/classes/RWSUploader.html +35 -0
- package/docs/classes/RWSViewComponent.html +24 -0
- package/docs/classes/RouterComponent.html +31 -0
- package/docs/classes/RoutingServiceInstance.html +13 -0
- package/docs/classes/UtilsServiceInstance.html +11 -0
- package/docs/classes/WSServiceInstance.html +32 -0
- package/docs/functions/RWSView.html +1 -0
- package/docs/functions/ngAttr.html +1 -0
- package/docs/functions/registerRWSComponents.html +1 -0
- package/docs/functions/renderRouteComponent.html +1 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +53 -0
- package/docs/interfaces/IRWSAssetShowOptions.html +1 -0
- package/docs/interfaces/IRWSConfig.html +11 -0
- package/docs/interfaces/IRWSDecoratorOptions.html +4 -0
- package/docs/interfaces/IRWSHttpRoute.html +3 -0
- package/docs/interfaces/IRWSPrefixedHTTProutes.html +3 -0
- package/docs/interfaces/IRoutingEvent.html +3 -0
- package/docs/modules.html +39 -0
- package/docs/types/DOMOutputType.html +1 -0
- package/docs/types/IRWSBackendRoute.html +1 -0
- package/docs/types/IRWSFrontRoutes.html +1 -0
- package/docs/types/IRWSRouteResult.html +1 -0
- package/docs/types/IRWSWebsocketStatus.html +1 -0
- package/docs/types/NotifyLogType.html +1 -0
- package/docs/types/NotifyUiType.html +1 -0
- package/docs/types/RWSNotify.html +1 -0
- package/docs/types/RouteReturn.html +1 -0
- package/docs/variables/ApiService.html +1 -0
- package/docs/variables/DOMService.html +1 -0
- package/docs/variables/NotifyService.html +1 -0
- package/docs/variables/RoutingService.html +1 -0
- package/docs/variables/UtilsService.html +1 -0
- package/docs/variables/WSService.html +1 -0
- package/docs/variables/_ROUTING_EVENT_NAME.html +1 -0
- package/package.json +93 -0
- package/package.webpack.config.js +17 -0
- package/rws.webpack.config.js +260 -0
- package/src/client.ts +304 -0
- package/src/components/_attrs/angular-attr.ts +64 -0
- package/src/components/_attrs/sanitize-html.ts +81 -0
- package/src/components/_component.ts +290 -0
- package/src/components/_container.ts +16 -0
- package/src/components/_decorator.ts +112 -0
- package/src/components/_design_system.ts +6 -0
- package/src/components/index.ts +9 -0
- package/src/components/progress/component.ts +55 -0
- package/src/components/progress/styles/layout.scss +91 -0
- package/src/components/progress/template.html +25 -0
- package/src/components/router/component.ts +67 -0
- package/src/components/uploader/component.ts +75 -0
- package/src/components/uploader/styles/layout.scss +105 -0
- package/src/components/uploader/template.html +17 -0
- package/src/hmr.ts +19 -0
- package/src/index.ts +98 -0
- package/src/interfaces/IRWSConfig.ts +24 -0
- package/src/interfaces/IRWSUser.ts +7 -0
- package/src/interfaces/IRWSViewComponent.ts +37 -0
- package/src/interfaces/RWSWindow.ts +39 -0
- package/src/routing/_router.ts +59 -0
- package/src/routing/index.ts +7 -0
- package/src/run.ts +35 -0
- package/src/service_worker/src/_service_worker.ts +88 -0
- package/src/service_worker/tsconfig.json +21 -0
- package/src/service_worker/webpack.config.js +67 -0
- package/src/services/ApiService.ts +241 -0
- package/src/services/ConfigService.ts +107 -0
- package/src/services/DOMService.ts +91 -0
- package/src/services/NotifyService.ts +49 -0
- package/src/services/RoutingService.ts +46 -0
- package/src/services/ServiceWorkerService.ts +60 -0
- package/src/services/UtilsService.ts +103 -0
- package/src/services/WSService.ts +218 -0
- package/src/services/_service.ts +50 -0
- package/src/services/_ws_handlers/ConnectionHandler.ts +52 -0
- package/src/services/_ws_handlers/EventHandler.ts +28 -0
- package/src/services/_ws_handlers/MessageHandler.ts +49 -0
- package/src/styles/includes.scss +102 -0
- package/src/types/RWSNotify.ts +7 -0
- package/tsconfig.json +27 -0
- package/typedoc.json +13 -0
- package/webpack/after/copy.js +73 -0
- package/webpack/after/sw.js +14 -0
- package/webpack/index.js +11 -0
- package/webpack/rws_after_plugin.js +80 -0
- package/webpack/rws_fast_css_loader.js +16 -0
- package/webpack/rws_fast_html_loader.js +4 -0
- package/webpack/rws_fast_scss_loader.js +50 -0
- package/webpack/rws_fast_ts_loader.js +134 -0
- package/webpack/rws_plugin.js +337 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
align-items: center;
|
|
3
|
+
display: flex;
|
|
4
|
+
contain: content;
|
|
5
|
+
outline: none;
|
|
6
|
+
height: calc(var(--design-unit) * 1px);
|
|
7
|
+
margin: calc(var(--design-unit) * 1px) 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.progress {
|
|
11
|
+
background-color: var(--neutral-fill-rest);
|
|
12
|
+
border-radius: calc(var(--design-unit) * 1px);
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.determinate {
|
|
21
|
+
background-color: var(--accent-foreground-rest);
|
|
22
|
+
border-radius: calc(var(--design-unit) * 1px);
|
|
23
|
+
height: 100%;
|
|
24
|
+
transition: all 0.2s ease-in-out;
|
|
25
|
+
display: flex;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.indeterminate {
|
|
29
|
+
border-radius: calc(var(--design-unit) * 1px);
|
|
30
|
+
display: flex;
|
|
31
|
+
height: 100%;
|
|
32
|
+
overflow: hidden;
|
|
33
|
+
position: relative;
|
|
34
|
+
width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.indeterminate-indicator-1 {
|
|
38
|
+
animation: indeterminate-1 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
39
|
+
background-color: var(--accent-foreground-rest);
|
|
40
|
+
border-radius: calc(var(--design-unit) * 1px);
|
|
41
|
+
height: 100%;
|
|
42
|
+
opacity: 0;
|
|
43
|
+
position: absolute;
|
|
44
|
+
width: 40%;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.indeterminate-indicator-2 {
|
|
48
|
+
position: absolute;
|
|
49
|
+
opacity: 0;
|
|
50
|
+
height: 100%;
|
|
51
|
+
background-color: var(--accent-foreground-rest);
|
|
52
|
+
border-radius: calc(var(--design-unit) * 1px);
|
|
53
|
+
width: 60%;
|
|
54
|
+
animation: indeterminate-2 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@keyframes indeterminate-1 {
|
|
58
|
+
0% {
|
|
59
|
+
opacity: 1;
|
|
60
|
+
transform: translateX(-100%);
|
|
61
|
+
}
|
|
62
|
+
70% {
|
|
63
|
+
opacity: 1;
|
|
64
|
+
transform: translateX(300%);
|
|
65
|
+
}
|
|
66
|
+
70.01% {
|
|
67
|
+
opacity: 0;
|
|
68
|
+
}
|
|
69
|
+
100% {
|
|
70
|
+
opacity: 0;
|
|
71
|
+
transform: translateX(300%);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@keyframes indeterminate-2 {
|
|
76
|
+
0% {
|
|
77
|
+
opacity: 0;
|
|
78
|
+
transform: translateX(-150%);
|
|
79
|
+
}
|
|
80
|
+
29.99% {
|
|
81
|
+
opacity: 0;
|
|
82
|
+
}
|
|
83
|
+
30% {
|
|
84
|
+
opacity: 1;
|
|
85
|
+
transform: translateX(-150%);
|
|
86
|
+
}
|
|
87
|
+
100% {
|
|
88
|
+
transform: translateX(166.66%);
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template
|
|
2
|
+
role="progressbar"
|
|
3
|
+
aria-valuenow="${x => x.value}"
|
|
4
|
+
aria-valuemin="${x => x.min}"
|
|
5
|
+
aria-valuemax="${x => x.max}"
|
|
6
|
+
>
|
|
7
|
+
${T.when(
|
|
8
|
+
x => typeof x.value === "number",
|
|
9
|
+
T.html`
|
|
10
|
+
<div class="progress rws-progress" part="progress" slot="determinate">
|
|
11
|
+
<div
|
|
12
|
+
class="determinate"
|
|
13
|
+
part="determinate"
|
|
14
|
+
style="width: ${x => x.percentComplete}%"
|
|
15
|
+
></div>
|
|
16
|
+
</div>
|
|
17
|
+
`,
|
|
18
|
+
T.html`
|
|
19
|
+
<div class="progress rws-progress" part="progress" slot="indeterminate">
|
|
20
|
+
<slot name="indeterminate">
|
|
21
|
+
</slot>
|
|
22
|
+
</div>
|
|
23
|
+
`
|
|
24
|
+
)}
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { observable } from '@microsoft/fast-element';
|
|
2
|
+
import { DI, Container, inject } from "@microsoft/fast-foundation";
|
|
3
|
+
import { RWSRouter, _ROUTING_EVENT_NAME, RouteReturn } from '../../services/RoutingService';
|
|
4
|
+
import RWSViewComponent, { IRWSViewComponent, IWithCompose } from '../_component';
|
|
5
|
+
import {RWSView} from '../_decorator';
|
|
6
|
+
import RWSContainer from '../_container';
|
|
7
|
+
|
|
8
|
+
@RWSView('rws-router', { ignorePackaging: true })
|
|
9
|
+
export class RouterComponent extends RWSViewComponent {
|
|
10
|
+
static autoLoadFastElement = false;
|
|
11
|
+
private routing: RWSRouter;
|
|
12
|
+
private currentComponent: IRWSViewComponent;
|
|
13
|
+
|
|
14
|
+
@observable currentUrl: string;
|
|
15
|
+
@observable childComponents: HTMLElement[] = [];
|
|
16
|
+
slotEl: HTMLElement = null;
|
|
17
|
+
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
super.connectedCallback();
|
|
20
|
+
this.routing = this.routingService.apply(this);
|
|
21
|
+
|
|
22
|
+
if(this.currentUrl){
|
|
23
|
+
this.handleRoute(this.routing.handleRoute(this.currentUrl));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
currentUrlChanged(oldValue: string, newValue: string){
|
|
28
|
+
if(!this.routing){
|
|
29
|
+
this.routing = this.routingService.apply(this);
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
this.handleRoute(this.routing.handleRoute(newValue));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private handleRoute(route: RouteReturn){
|
|
36
|
+
const [routeName, childComponent, routeParams] = route;
|
|
37
|
+
|
|
38
|
+
this.$emit(_ROUTING_EVENT_NAME, {
|
|
39
|
+
routeName,
|
|
40
|
+
component: childComponent
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
console.log('handleroute',{
|
|
44
|
+
routeName,
|
|
45
|
+
component: childComponent
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const newComponent = document.createElement((childComponent as any).definition.name);
|
|
49
|
+
newComponent.routeParams = routeParams;
|
|
50
|
+
|
|
51
|
+
if(this.currentComponent){
|
|
52
|
+
this.getShadowRoot().removeChild(this.currentComponent);
|
|
53
|
+
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.currentComponent = newComponent;
|
|
57
|
+
|
|
58
|
+
this.getShadowRoot().appendChild(newComponent);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
addComponent(component: any) {
|
|
62
|
+
|
|
63
|
+
this.slotEl = component;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
RouterComponent.defineComponent();
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { RWSView, RWSViewComponent, observable, attr } from '../../index';
|
|
2
|
+
|
|
3
|
+
@RWSView('rws-uploader')
|
|
4
|
+
class RWSUploader extends RWSViewComponent {
|
|
5
|
+
|
|
6
|
+
@observable uploadProgress: number = 0;
|
|
7
|
+
|
|
8
|
+
@observable uploadedFile: File;
|
|
9
|
+
@observable chosenFile: File;
|
|
10
|
+
@observable uploadParams: any;
|
|
11
|
+
|
|
12
|
+
@attr onFinish: (uploadResponse: any) => void;
|
|
13
|
+
@attr onStart: (chosenFile: File, context: any) => void = (chosenFile: File) => null;
|
|
14
|
+
@attr onProgress: (progress: number) => void = (progress: number) => null;
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
async onUploadStart(): Promise<void>
|
|
18
|
+
{
|
|
19
|
+
const response = await this.onStart(this.chosenFile, this);
|
|
20
|
+
|
|
21
|
+
if(response === null){
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.onFinish(response);
|
|
26
|
+
|
|
27
|
+
this.uploadedFile = this.chosenFile;
|
|
28
|
+
this.chosenFile = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
onChoose(): void
|
|
32
|
+
{
|
|
33
|
+
const _self = this;
|
|
34
|
+
const fileInput = this.createFileInput();
|
|
35
|
+
|
|
36
|
+
this.triggerUpload(fileInput);
|
|
37
|
+
|
|
38
|
+
fileInput.addEventListener('change', () => {
|
|
39
|
+
_self.chosenFile = fileInput.files[0];
|
|
40
|
+
|
|
41
|
+
_self.uploadedFile = null;
|
|
42
|
+
|
|
43
|
+
_self.removeFileInput(fileInput);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
removeFile(){
|
|
48
|
+
this.chosenFile = null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private createFileInput(): HTMLInputElement
|
|
52
|
+
{
|
|
53
|
+
const fileInput: HTMLInputElement = document.createElement('input');
|
|
54
|
+
fileInput.type = 'file';
|
|
55
|
+
fileInput.style.display = 'none';
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
this.shadowRoot.appendChild(fileInput);
|
|
59
|
+
return fileInput;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private triggerUpload(fileInput: HTMLInputElement): void
|
|
63
|
+
{
|
|
64
|
+
fileInput.click();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private removeFileInput(fileInput: HTMLInputElement): void
|
|
68
|
+
{
|
|
69
|
+
this.shadowRoot.removeChild(fileInput);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
RWSUploader.defineComponent();
|
|
74
|
+
|
|
75
|
+
export { RWSUploader };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
@import "../../../styles/includes.scss";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
.upload_area {
|
|
6
|
+
padding: 25px;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
section{
|
|
10
|
+
&::after{
|
|
11
|
+
content: '';
|
|
12
|
+
display: table;
|
|
13
|
+
clear: both;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
display: block;
|
|
17
|
+
contain: content;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
background: #424242;
|
|
20
|
+
border-radius: 10px;
|
|
21
|
+
box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
|
|
22
|
+
|
|
23
|
+
.drag-and-drop {
|
|
24
|
+
@include grid-container();
|
|
25
|
+
@include grid-flex-align-items(center, center);
|
|
26
|
+
|
|
27
|
+
border: 4px dashed #FFF; // Adjust color as needed
|
|
28
|
+
width: 100%; // Adjust width as needed
|
|
29
|
+
height: 100%; // Adjust height as needed
|
|
30
|
+
padding: 30px;
|
|
31
|
+
|
|
32
|
+
margin-bottom: 30px;
|
|
33
|
+
|
|
34
|
+
text-align: center;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
|
|
37
|
+
.file-block {
|
|
38
|
+
border: 1px solid #FFF;
|
|
39
|
+
|
|
40
|
+
font-size: 10px;
|
|
41
|
+
padding: 15px;
|
|
42
|
+
border-radius: 15px;
|
|
43
|
+
|
|
44
|
+
.close-btn {
|
|
45
|
+
border: 1px solid #FFF;
|
|
46
|
+
padding: 5px;
|
|
47
|
+
font-weight: bold;
|
|
48
|
+
margin-left: 10px;
|
|
49
|
+
border-radius: 15px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&.hover{
|
|
54
|
+
position: relative;
|
|
55
|
+
|
|
56
|
+
&:before{
|
|
57
|
+
content: '';
|
|
58
|
+
background: #CCC;
|
|
59
|
+
opacity: 0.4;
|
|
60
|
+
|
|
61
|
+
position: absolute;
|
|
62
|
+
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
p{
|
|
68
|
+
font-weight: bold;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
h3{
|
|
74
|
+
padding: 0 15px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
article {
|
|
78
|
+
padding: 15px;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
button {
|
|
83
|
+
background: var(--accent-fill-rest);
|
|
84
|
+
color: var(--foreground-on-accent-rest);
|
|
85
|
+
font-size: 14px;
|
|
86
|
+
padding: 10px;
|
|
87
|
+
box-shadow: none;
|
|
88
|
+
border-radius: 5px;
|
|
89
|
+
border-style: solid;
|
|
90
|
+
border-color: var(--accent-fill-rest);
|
|
91
|
+
border-width: 1px;
|
|
92
|
+
|
|
93
|
+
fill: currentcolor;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
|
|
96
|
+
&.outline{
|
|
97
|
+
background: none;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&.next{
|
|
101
|
+
float: right;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<div class="upload_area">
|
|
2
|
+
<section>
|
|
3
|
+
<h3>Upload file</h3>
|
|
4
|
+
<rws-progress :value="${x => x.uploadProgress}" max="100"></rws-progress>
|
|
5
|
+
<article>
|
|
6
|
+
<div class="drag-and-drop">
|
|
7
|
+
<div @click="${x => !x.chosenFile ? x.onChoose() : (() => {})()}" class="upl-background"></div>
|
|
8
|
+
${T.when(x => !x.chosenFile, T.html`<p @click="${x => !x.chosenFile ? x.onChoose() : (() => {})()}" class="dropinfo">Drag and drop here to upload</p>`)}
|
|
9
|
+
${T.when(x => x.chosenFile, T.html`<div class="file-block">${ x => x.chosenFile.name} <span @click="${ x => x.removeFile() }" class="close-btn">X</span></div>`)}
|
|
10
|
+
</div>
|
|
11
|
+
<div class="upl-controls">
|
|
12
|
+
<button @click="${ x => x.onChoose() }" class="outline">Choose file</button>
|
|
13
|
+
</div>
|
|
14
|
+
</article>
|
|
15
|
+
<button @click="${ x => x.onUploadStart() }" :disabled="${ x => x.chosenFile ? false : true }" appearance="accent" class="next">Upload</button>
|
|
16
|
+
</section>
|
|
17
|
+
</div>
|
package/src/hmr.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//@ts-expect-error no-types
|
|
2
|
+
import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
3
|
+
|
|
4
|
+
const AUTORELOAD_CFG = {
|
|
5
|
+
plugins: [
|
|
6
|
+
hmrPlugin({
|
|
7
|
+
include: ['src/**/*'],
|
|
8
|
+
presets: [presets.fastElement],
|
|
9
|
+
}),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const HMR = {
|
|
14
|
+
autoReloadConfig: (): any => {
|
|
15
|
+
return AUTORELOAD_CFG;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default HMR;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Transformer as HTMLTagTransformerType, Tag as HTMLTag, Attributes as HTMLAttributes } from 'sanitize-html';
|
|
2
|
+
import { observable, attr } from '@microsoft/fast-element';
|
|
3
|
+
import IRWSConfig from './interfaces/IRWSConfig';
|
|
4
|
+
import RWSNotify, { NotifyUiType, NotifyLogType } from './types/RWSNotify';
|
|
5
|
+
import { provideRWSDesignSystem } from './components/_design_system';
|
|
6
|
+
import RWSService from './services/_service';
|
|
7
|
+
import ConfigService, { ConfigServiceInstance } from './services/ConfigService';
|
|
8
|
+
import RoutingService, { RoutingServiceInstance } from './services/RoutingService';
|
|
9
|
+
import NotifyService, {NotifyServiceInstance} from './services/NotifyService';
|
|
10
|
+
import DOMService, { DOMServiceInstance, DOMOutputType, TagsProcessorType } from './services/DOMService';
|
|
11
|
+
import ApiService, { IBackendRoute, ApiServiceInstance, IHTTProute, IPrefixedHTTProutes } from './services/ApiService';
|
|
12
|
+
import UtilsService, {UtilsServiceInstance} from './services/UtilsService';
|
|
13
|
+
import ServiceWorkerService, { ServiceWorkerServiceInstance } from './services/ServiceWorkerService';
|
|
14
|
+
import { sanitizedAttr } from './components/_attrs/sanitize-html';import WSService, {WSServiceInstance, WSStatus} from './services/WSService';
|
|
15
|
+
import { ngAttr } from './components/_attrs/angular-attr';
|
|
16
|
+
import RWSClient from './client';
|
|
17
|
+
import RWSServiceWorker, { SWMsgType } from './service_worker/src/_service_worker';
|
|
18
|
+
import IRWSUser from './interfaces/IRWSUser';
|
|
19
|
+
import RWSContainer from './components/_container';
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
IFrontRoutes, renderRouteComponent, RouteReturn,
|
|
23
|
+
_ROUTING_EVENT_NAME, IRoutingEvent,
|
|
24
|
+
RWSRouter, IRWSRouteResult
|
|
25
|
+
} from './services/RoutingService';
|
|
26
|
+
|
|
27
|
+
// import { RWSComponents } from './components';
|
|
28
|
+
import RWSViewComponent, { IAssetShowOptions } from './components/_component';
|
|
29
|
+
import { RWSDecoratorOptions, RWSIgnore, RWSView, RWSInject } from './components/_decorator';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export default RWSClient;
|
|
34
|
+
export {
|
|
35
|
+
NotifyUiType,
|
|
36
|
+
NotifyLogType,
|
|
37
|
+
|
|
38
|
+
RouteReturn,
|
|
39
|
+
_ROUTING_EVENT_NAME,
|
|
40
|
+
IRoutingEvent,
|
|
41
|
+
|
|
42
|
+
RoutingServiceInstance,
|
|
43
|
+
RoutingService,
|
|
44
|
+
ApiServiceInstance,
|
|
45
|
+
ApiService,
|
|
46
|
+
WSServiceInstance,
|
|
47
|
+
WSService,
|
|
48
|
+
UtilsServiceInstance,
|
|
49
|
+
UtilsService,
|
|
50
|
+
DOMServiceInstance,
|
|
51
|
+
DOMService,
|
|
52
|
+
DOMOutputType,
|
|
53
|
+
NotifyServiceInstance,
|
|
54
|
+
NotifyService,
|
|
55
|
+
ConfigServiceInstance,
|
|
56
|
+
ConfigService,
|
|
57
|
+
ServiceWorkerServiceInstance,
|
|
58
|
+
ServiceWorkerService,
|
|
59
|
+
|
|
60
|
+
RWSNotify,
|
|
61
|
+
RWSRouter,
|
|
62
|
+
IFrontRoutes as IRWSFrontRoutes,
|
|
63
|
+
IBackendRoute as IRWSBackendRoute,
|
|
64
|
+
RWSDecoratorOptions as IRWSDecoratorOptions,
|
|
65
|
+
IRWSRouteResult,
|
|
66
|
+
IHTTProute as IRWSHttpRoute,
|
|
67
|
+
IPrefixedHTTProutes as IRWSPrefixedHTTProutes,
|
|
68
|
+
WSStatus as IRWSWebsocketStatus,
|
|
69
|
+
IAssetShowOptions as IRWSAssetShowOptions,
|
|
70
|
+
IRWSConfig,
|
|
71
|
+
IRWSUser,
|
|
72
|
+
TagsProcessorType,
|
|
73
|
+
HTMLTagTransformerType,
|
|
74
|
+
HTMLTag,
|
|
75
|
+
HTMLAttributes,
|
|
76
|
+
|
|
77
|
+
RWSView,
|
|
78
|
+
sanitizedAttr,
|
|
79
|
+
RWSIgnore,
|
|
80
|
+
RWSInject,
|
|
81
|
+
ngAttr,
|
|
82
|
+
|
|
83
|
+
renderRouteComponent,
|
|
84
|
+
|
|
85
|
+
// RWSComponents,
|
|
86
|
+
|
|
87
|
+
observable,
|
|
88
|
+
attr,
|
|
89
|
+
|
|
90
|
+
RWSServiceWorker,
|
|
91
|
+
SWMsgType,
|
|
92
|
+
|
|
93
|
+
RWSService,
|
|
94
|
+
RWSViewComponent,
|
|
95
|
+
provideRWSDesignSystem,
|
|
96
|
+
|
|
97
|
+
RWSContainer
|
|
98
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IFrontRoutes } from '../services/RoutingService';
|
|
2
|
+
import RWSViewComponent from '../components/_component';
|
|
3
|
+
import { DI, InterfaceSymbol, Key } from "@microsoft/fast-foundation";
|
|
4
|
+
import { RWSContainer } from '..';
|
|
5
|
+
|
|
6
|
+
export default interface IRWSConfig {
|
|
7
|
+
defaultLayout?: typeof RWSViewComponent
|
|
8
|
+
backendUrl?: string
|
|
9
|
+
wsUrl?: string
|
|
10
|
+
backendRoutes?: any[]
|
|
11
|
+
apiPrefix?: string
|
|
12
|
+
routes?: IFrontRoutes
|
|
13
|
+
transports?: string[]
|
|
14
|
+
user?: any
|
|
15
|
+
ignoreRWSComponents?: boolean
|
|
16
|
+
pubUrl?: string
|
|
17
|
+
pubPrefix?: string
|
|
18
|
+
dontPushToSW?: boolean
|
|
19
|
+
parted?: boolean
|
|
20
|
+
splitFileDir?: string
|
|
21
|
+
splitPrefix?: string
|
|
22
|
+
routing_enabled?: boolean
|
|
23
|
+
_noLoad?: boolean
|
|
24
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ViewTemplate, ElementStyles } from "@microsoft/fast-element";
|
|
2
|
+
import { DOMOutputType } from "../services/DOMService";
|
|
3
|
+
|
|
4
|
+
type IAssetShowOptions = {}
|
|
5
|
+
|
|
6
|
+
interface IRWSViewComponent extends Node {
|
|
7
|
+
__isLoading: boolean;
|
|
8
|
+
routeParams: Record<string, string>;
|
|
9
|
+
trashIterator: number;
|
|
10
|
+
fileAssets: { [key: string]: ViewTemplate };
|
|
11
|
+
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
|
|
14
|
+
passRouteParams(routeParams?: Record<string, string>): void;
|
|
15
|
+
|
|
16
|
+
showAsset(assetName: string, options?: IAssetShowOptions): ViewTemplate<any>;
|
|
17
|
+
|
|
18
|
+
on<T>(type: string, listener: (event: CustomEvent<T>) => any): void;
|
|
19
|
+
|
|
20
|
+
$emitDown<T>(eventName: string, payload: T): void;
|
|
21
|
+
|
|
22
|
+
parse$<T extends Element>(input: NodeListOf<T>, directReturn?: boolean): DOMOutputType<T>;
|
|
23
|
+
|
|
24
|
+
$<T extends Element>(selectors: string, directReturn?: boolean): DOMOutputType<T>;
|
|
25
|
+
|
|
26
|
+
loadingString<T, C>(item: T, addContent: (cnt: C | { output: string }, paste?: boolean, error?: boolean) => void, shouldStop: (stopItem: T, addContent: (cnt: C | { output: string }, paste?: boolean,error?: boolean) => void) => Promise<boolean>): Promise<void>
|
|
27
|
+
|
|
28
|
+
onDOMLoad(): Promise<void>;
|
|
29
|
+
|
|
30
|
+
forceReload(): void;
|
|
31
|
+
|
|
32
|
+
hotReplacedCallback(): void;
|
|
33
|
+
|
|
34
|
+
sendEventToOutside<T>(eventName: string, data: T): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {IRWSViewComponent, IAssetShowOptions}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RWSClientInstance } from "../client";
|
|
2
|
+
import { Container, InterfaceSymbol } from '@microsoft/fast-foundation';
|
|
3
|
+
import { v1 as uuid} from 'uuid';
|
|
4
|
+
import { IWithDI } from "../services/_service";
|
|
5
|
+
export type RWSWindowComponentInterface = (params?: any) => void;
|
|
6
|
+
export type RWSWindowComponentEntry = { interface: RWSWindowComponentInterface, component: any };
|
|
7
|
+
export type RWSWindowComponentRegister = { [key: string]: RWSWindowComponentEntry};
|
|
8
|
+
|
|
9
|
+
export function loadRWSRichWindow(): RWSWindow
|
|
10
|
+
{
|
|
11
|
+
const richWindow: RWSWindow = window;
|
|
12
|
+
|
|
13
|
+
if(!richWindow.RWS){
|
|
14
|
+
const newNode = document.createElement('main');
|
|
15
|
+
newNode.id = 'rws-cntr-id-' + uuid();
|
|
16
|
+
|
|
17
|
+
console.log('Created container on node: ', newNode.id);
|
|
18
|
+
|
|
19
|
+
richWindow.RWS = {
|
|
20
|
+
client: null,
|
|
21
|
+
components: {},
|
|
22
|
+
container: null,
|
|
23
|
+
container_node: newNode,
|
|
24
|
+
_registered: {}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return richWindow;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default interface RWSWindow extends Window {
|
|
32
|
+
RWS?:{
|
|
33
|
+
client?: RWSClientInstance
|
|
34
|
+
components: RWSWindowComponentRegister
|
|
35
|
+
container: Container | null
|
|
36
|
+
container_node: Element | null
|
|
37
|
+
_registered: {[key: string]: InterfaceSymbol<any>};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Router from 'url-router';
|
|
2
|
+
import UtilsService, {UtilsServiceInstance} from '../services/UtilsService';
|
|
3
|
+
import { IRWSViewComponent } from '../interfaces/IRWSViewComponent';
|
|
4
|
+
export type RouteReturn = [string, IRWSViewComponent, Record<string, string>];
|
|
5
|
+
export type IRWSRouteResult = {
|
|
6
|
+
handler: () => RouteReturn;
|
|
7
|
+
params: Record<string, string>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
class RWSRouter {
|
|
11
|
+
private baseComponent: IRWSViewComponent;
|
|
12
|
+
private urlRouter: Router<any>;
|
|
13
|
+
private utilsService: UtilsServiceInstance;
|
|
14
|
+
|
|
15
|
+
constructor(routerComponent: IRWSViewComponent, urlRouter: Router<any>, utilsService: UtilsServiceInstance){
|
|
16
|
+
this.baseComponent = routerComponent;
|
|
17
|
+
this.urlRouter = urlRouter;
|
|
18
|
+
this.utilsService = utilsService;
|
|
19
|
+
|
|
20
|
+
window.addEventListener('popstate', (event: Event) => {
|
|
21
|
+
console.log('pop', event);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public routeComponent(newComponent: IRWSViewComponent)
|
|
26
|
+
{
|
|
27
|
+
this.baseComponent.appendChild(newComponent);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public fireHandler(route: IRWSRouteResult): RouteReturn
|
|
31
|
+
{ const handler = route.handler();
|
|
32
|
+
return [handler[0], handler[1], this.utilsService.mergeDeep(route.params, handler[2])];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public handleRoute(url: string): RouteReturn
|
|
36
|
+
{
|
|
37
|
+
const currentRoute = this.find(url);
|
|
38
|
+
|
|
39
|
+
if (history.pushState) {
|
|
40
|
+
window.history.pushState({ path: url }, '', url);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return this.fireHandler(currentRoute);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public handleCurrentRoute(): RouteReturn
|
|
47
|
+
{
|
|
48
|
+
const currentRoute = this.find(window.location.pathname);
|
|
49
|
+
|
|
50
|
+
return this.fireHandler(currentRoute);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public find(url: string): IRWSRouteResult
|
|
54
|
+
{
|
|
55
|
+
return this.urlRouter.find(url);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export { RWSRouter }
|