jsf.js_next_gen 4.0.0-RC.1 → 4.0.0-RC.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.
- package/dist/docs/functions/faces.push.init.html +5 -1
- package/dist/docs/functions/myfaces.ab.html +2 -2
- package/dist/window/faces-development.js +2784 -2036
- package/dist/window/faces-development.js.br +0 -0
- package/dist/window/faces-development.js.gz +0 -0
- package/dist/window/faces-development.js.map +1 -1
- package/dist/window/faces.js +1 -1
- package/dist/window/faces.js.br +0 -0
- package/dist/window/faces.js.gz +0 -0
- package/dist/window/faces.js.map +1 -1
- package/dist/window/jsf-development.js +2796 -2037
- package/dist/window/jsf-development.js.br +0 -0
- package/dist/window/jsf-development.js.gz +0 -0
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +2 -2
- package/src/main/typescript/@types/definitions/index.d.ts +13 -1
- package/src/main/typescript/api/_api.ts +4 -2
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +22 -2
- package/src/main/typescript/impl/PushImpl.ts +38 -12
- package/src/main/typescript/impl/core/Const.ts +2 -0
- package/src/main/typescript/impl/util/AsyncQueue.ts +1 -1
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +2 -2
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +24 -12
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +172 -8
- package/src/main/typescript/tsconfig.json +1 -1
- package/target/api/_api.js +28 -13
- package/target/api/_api.js.map +1 -1
- package/target/api/faces.js +4 -4
- package/target/api/faces.js.map +1 -1
- package/target/api/jsf.js +16 -5
- package/target/api/jsf.js.map +1 -1
- package/target/impl/AjaxImpl.js +79 -53
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +81 -48
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +5 -4
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/ImplTypes.js +14 -9
- package/target/impl/core/ImplTypes.js.map +1 -1
- package/target/impl/i18n/Messages.js +4 -3
- package/target/impl/i18n/Messages.js.map +1 -1
- package/target/impl/util/Assertions.js +18 -9
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js +36 -28
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +219 -144
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/Lang.js +28 -21
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/xhrCore/ErrorData.js +61 -36
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +13 -10
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestDataResolver.js +18 -16
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +16 -16
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +16 -16
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +133 -119
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +114 -69
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +95 -85
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +15 -15
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/LangTest.spec.js +32 -46
- package/target/test/frameworkBase/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +228 -238
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js +31 -45
- package/target/test/frameworkBase/_ext/monadish/LangTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js +33 -24
- package/target/test/frameworkBase/_ext/monadish/MappingProbes.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js +8 -8
- package/target/test/frameworkBase/_ext/monadish/MappingTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +31 -31
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js +48 -50
- package/target/test/frameworkBase/_ext/monadish/StreamTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +132 -247
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +22 -199
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +59 -32
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +59 -32
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/impl/SeparatorCharsTest.spec.js +17 -17
- package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
- package/target/test/myfaces/OamSubmit.spec.js +25 -25
- package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
- package/target/test/queue/AsynchronousProbe.js +29 -23
- package/target/test/queue/AsynchronousProbe.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +70 -39
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +73 -42
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FakeWebsocket.js +16 -14
- package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +77 -46
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js +68 -37
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +268 -84
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +140 -93
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +91 -122
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +83 -114
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/ShadowDomTest.spec.js +61 -30
- package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
- package/target/test/xhrCore/WebsocketTest.js +93 -60
- package/target/test/xhrCore/WebsocketTest.js.map +1 -1
- package/target/test/xhrCore/XhrFormDataTest.spec.js +15 -41
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
- package/target/classes/com/example/jsfs_js_ts/DecoratedFacesJS.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/DecoratingResourceHandlerWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMapFileResourceWrapper.class +0 -0
- package/target/classes/com/example/jsfs_js_ts/FacesJSMappingDecorator.class +0 -0
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -4
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst +0 -1
- package/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst +0 -1
- package/target/surefire-reports/TEST-com.example.jsfs_js_ts.JsfsJsTsApplicationTests.xml +0 -78
- package/target/surefire-reports/com.example.jsfs_js_ts.JsfsJsTsApplicationTests.txt +0 -7
- package/target/test-classes/.gz +0 -0
- package/target/test-classes/com/example/jsfs_js_ts/JsfsJsTsApplicationTests.class +0 -0
- package/target/test-classes/fileuploadtest.html +0 -24
- package/target/test-classes/jsf-development.js +0 -3559
- package/target/test-classes/jsf-development.js.br +0 -0
- package/target/test-classes/jsf-development.js.gz +0 -0
- package/target/test-classes/jsf-development.js.map +0 -1
- package/target/test-classes/jsf.js +0 -3
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsf.js_next_gen",
|
|
3
|
-
"version": "4.0.0-RC.
|
|
3
|
+
"version": "4.0.0-RC.3",
|
|
4
4
|
"description": "A next generation typescript reimplementation of jsf.js",
|
|
5
5
|
"main": "dist/window/faces.js",
|
|
6
6
|
"scripts": {
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
"webpack-dev-server": "^4.11.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"mona-dish": "0.23.
|
|
51
|
+
"mona-dish": "^0.23.6"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -25,7 +25,19 @@ declare global {
|
|
|
25
25
|
type Consumer<T> = (s?: T) => void;
|
|
26
26
|
type AssocArr<T> = { [key: string]: T };
|
|
27
27
|
type EvalFuncs = Array<Function | string>;
|
|
28
|
-
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
type Options = {
|
|
31
|
+
execute ?: string, //space separated list of client ids
|
|
32
|
+
onevent ?: Function, // event handler callback
|
|
33
|
+
onerror ?: Function, // error handler callback
|
|
34
|
+
params ?: {[key: string]: any} | [[string, any]], //passthrough params
|
|
35
|
+
delay ?: number, // delay in milliseconds
|
|
36
|
+
resetValues ?: boolean, //if set to true jakarta.faces.partial.resetValues is sent
|
|
37
|
+
/* @deprecated non-spec conform fallback behavior that anything can be passed and is used as passthrough */
|
|
38
|
+
[key: string]: any
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
type Context = AssocArr<any>;
|
|
30
42
|
type ElemDef = Element | string;
|
|
31
43
|
|
|
@@ -201,6 +201,7 @@ export module faces {
|
|
|
201
201
|
* @param channel the channel name/id
|
|
202
202
|
* @param onopen The function to be invoked when the web socket is opened.
|
|
203
203
|
* @param onmessage The function to be invoked when a message is received.
|
|
204
|
+
* @param onerror The function to be invoked when an error occurs.
|
|
204
205
|
* @param onclose The function to be invoked when the web socket is closed.
|
|
205
206
|
* @param behaviors functions which are invoked whenever a message is received
|
|
206
207
|
* @param autoConnect Whether or not to automatically open the socket. Defaults to <code>false</code>.
|
|
@@ -210,10 +211,11 @@ export module faces {
|
|
|
210
211
|
channel: string,
|
|
211
212
|
onopen: Function,
|
|
212
213
|
onmessage: Function,
|
|
214
|
+
onerror: Function,
|
|
213
215
|
onclose: Function,
|
|
214
216
|
behaviors: any,
|
|
215
217
|
autoConnect: boolean): void {
|
|
216
|
-
PushImpl.init(socketClientId, url, channel, onopen, onmessage, onclose, behaviors, autoConnect);
|
|
218
|
+
PushImpl.init(socketClientId, url, channel, onopen, onmessage, onerror, onclose, behaviors, autoConnect);
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
/**
|
|
@@ -250,7 +252,7 @@ export module myfaces {
|
|
|
250
252
|
* @param render
|
|
251
253
|
* @param options
|
|
252
254
|
*/
|
|
253
|
-
export function ab(source: Element, event: Event, eventName: string, execute: string, render: string, options:
|
|
255
|
+
export function ab(source: Element, event: Event, eventName: string, execute: string, render: string, options: Options = {}): void {
|
|
254
256
|
if (eventName) {
|
|
255
257
|
options[$nsp(P_BEHAVIOR_EVENT)] = eventName;
|
|
256
258
|
}
|
|
@@ -26,6 +26,24 @@ if(!window?.jsf) {
|
|
|
26
26
|
(window as any)['jsf'] = window?.jsf ?? faces;
|
|
27
27
|
window.jsf.specversion = 230000;
|
|
28
28
|
delete window.jsf.contextpath;
|
|
29
|
+
|
|
30
|
+
let faces4Init = faces.push.init;
|
|
31
|
+
/*
|
|
32
|
+
* we shim back the breaking api change from 3.0 to 4.0
|
|
33
|
+
* onerror is gone
|
|
34
|
+
*/
|
|
35
|
+
faces.push.init = (socketClientId: string,
|
|
36
|
+
url: string,
|
|
37
|
+
channel: string,
|
|
38
|
+
onopen: Function,
|
|
39
|
+
onmessage: Function,
|
|
40
|
+
// no on error api change for 4.0
|
|
41
|
+
//onerror: Function,
|
|
42
|
+
onclose: Function,
|
|
43
|
+
behaviors: any,
|
|
44
|
+
autoConnect: boolean) => {
|
|
45
|
+
faces4Init(socketClientId, url, channel, onopen, onmessage, null, onclose, behaviors, autoConnect);
|
|
46
|
+
}
|
|
29
47
|
}
|
|
30
48
|
if(!window?.myfaces?.ab) {
|
|
31
49
|
const myfaces = require("./_api").myfaces;
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
CTX_PARAM_RENDER,
|
|
51
51
|
REQ_TYPE_POST,
|
|
52
52
|
SOURCE,
|
|
53
|
-
TAG_FORM
|
|
53
|
+
TAG_FORM, CTX_PARAM_SPEC_PARAMS
|
|
54
54
|
} from "./core/Const";
|
|
55
55
|
import {
|
|
56
56
|
resolveDefaults,
|
|
@@ -81,7 +81,9 @@ enum BlockFilter {
|
|
|
81
81
|
myfaces = "myfaces",
|
|
82
82
|
delay = "delay",
|
|
83
83
|
timeout = "timeout",
|
|
84
|
-
|
|
84
|
+
resetValues = "resetValues",
|
|
85
|
+
windowId = "windowId",
|
|
86
|
+
params = "params"
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/**
|
|
@@ -267,7 +269,12 @@ export module Implementation {
|
|
|
267
269
|
|
|
268
270
|
requestCtx.assignIf(!!windowId, P_WINDOW_ID).value = windowId;
|
|
269
271
|
|
|
272
|
+
// old non spec behavior will be removed after it is clear whether the removal breaks any code
|
|
270
273
|
requestCtx.assign(CTX_PARAM_PASS_THR).value = filterPassThroughValues(options.value);
|
|
274
|
+
|
|
275
|
+
// spec conform behavior, all passthrough params must be under "passthrough
|
|
276
|
+
const params = remapArrayToAssocArr(options.getIf(CTX_PARAM_SPEC_PARAMS).orElse({}).value);
|
|
277
|
+
requestCtx.getIf(CTX_PARAM_PASS_THR).shallowMerge(new Config(params), true);
|
|
271
278
|
requestCtx.assignIf(!!resolvedEvent, CTX_PARAM_PASS_THR, P_EVT).value = resolvedEvent?.type;
|
|
272
279
|
|
|
273
280
|
/**
|
|
@@ -653,7 +660,13 @@ export module Implementation {
|
|
|
653
660
|
* Filter the options given with a blacklist, so that only
|
|
654
661
|
* the values required for pass-through are processed in the ajax request
|
|
655
662
|
*
|
|
663
|
+
* Note this is a bug carried over from the old implementation
|
|
664
|
+
* the spec conform behavior is to use params for passthrough values
|
|
665
|
+
* this will be removed soon, after it is cleared up wheter removing
|
|
666
|
+
* it breaks any legacy code
|
|
667
|
+
*
|
|
656
668
|
* @param {Context} mappedOpts the options to be filtered
|
|
669
|
+
* @deprecated
|
|
657
670
|
*/
|
|
658
671
|
function filterPassThroughValues(mappedOpts: Context): Context {
|
|
659
672
|
//we now can use the full code reduction given by our stream api
|
|
@@ -663,6 +676,13 @@ export module Implementation {
|
|
|
663
676
|
.collect(new AssocArrayCollector());
|
|
664
677
|
}
|
|
665
678
|
|
|
679
|
+
function remapArrayToAssocArr(arrayedParams: [[string, any]] | {[key: string]: any}): {[key: string]: any} {
|
|
680
|
+
if(Array.isArray(arrayedParams)) {
|
|
681
|
+
return Stream.of(... arrayedParams).collect(new AssocArrayCollector());
|
|
682
|
+
}
|
|
683
|
+
return arrayedParams;
|
|
684
|
+
}
|
|
685
|
+
|
|
666
686
|
function resolveGlobalConfig(): any {
|
|
667
687
|
return window?.[MYFACES]?.config ?? {};
|
|
668
688
|
}
|
|
@@ -18,13 +18,14 @@
|
|
|
18
18
|
* Typescript port of the faces\.push part in the myfaces implementation
|
|
19
19
|
*/
|
|
20
20
|
import {MAX_RECONNECT_ATTEMPTS, REASON_EXPIRED, RECONNECT_INTERVAL} from "./core/Const";
|
|
21
|
+
import {DQ} from "mona-dish";
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Implementation class for the push functionality
|
|
24
25
|
*/
|
|
25
26
|
export module PushImpl {
|
|
26
27
|
|
|
27
|
-
const URL_PROTOCOL =
|
|
28
|
+
const URL_PROTOCOL = DQ.global().location.protocol.replace("http", "ws") + "//";
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
// we expose the member variables for testing purposes
|
|
@@ -55,6 +56,7 @@ export module PushImpl {
|
|
|
55
56
|
* @param channel the channel name/id
|
|
56
57
|
* @param onopen The function to be invoked when the web socket is opened.
|
|
57
58
|
* @param onmessage The function to be invoked when a message is received.
|
|
59
|
+
* @param onerror The function to be invoked when an error occurs.
|
|
58
60
|
* @param onclose The function to be invoked when the web socket is closed.
|
|
59
61
|
* @param behaviors functions which are invoked whenever a message is received
|
|
60
62
|
* @param autoConnect Whether or not to automatically open the socket. Defaults to <code>false</code>.
|
|
@@ -64,12 +66,13 @@ export module PushImpl {
|
|
|
64
66
|
channel: string,
|
|
65
67
|
onopen: Function,
|
|
66
68
|
onmessage: Function,
|
|
69
|
+
onerror: Function,
|
|
67
70
|
onclose: Function,
|
|
68
71
|
behaviors: any,
|
|
69
72
|
autoConnect: boolean) {
|
|
70
73
|
onclose = resolveFunction(onclose);
|
|
71
74
|
|
|
72
|
-
if (!
|
|
75
|
+
if (!DQ.global().WebSocket) { // IE6-9.
|
|
73
76
|
onclose(-1, channel);
|
|
74
77
|
return;
|
|
75
78
|
}
|
|
@@ -81,6 +84,7 @@ export module PushImpl {
|
|
|
81
84
|
'channelToken': channelToken,
|
|
82
85
|
'onopen': resolveFunction(onopen),
|
|
83
86
|
'onmessage' : resolveFunction(onmessage),
|
|
87
|
+
'onerror' : resolveFunction(onerror),
|
|
84
88
|
'onclose': onclose,
|
|
85
89
|
'behaviors': behaviors,
|
|
86
90
|
'autoconnect': autoConnect};
|
|
@@ -95,16 +99,16 @@ export module PushImpl {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
if (autoConnect) {
|
|
98
|
-
(
|
|
102
|
+
(DQ.global()?.faces ?? DQ.global()?.jsf).push.open(socketClientId);
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
export function open(socketClientId: string) {
|
|
103
|
-
getSocket(components
|
|
107
|
+
getSocket(components[socketClientId]?.channelToken).open();
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
export function close(socketClientId: string) {
|
|
107
|
-
getSocket(components
|
|
111
|
+
getSocket(components[socketClientId].channelToken).close();
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
// Private helper classes
|
|
@@ -142,24 +146,45 @@ export module PushImpl {
|
|
|
142
146
|
let clientIds = clientIdsByTokens[this.channelToken];
|
|
143
147
|
for (let i = clientIds.length - 1; i >= 0; i--) {
|
|
144
148
|
let socketClientId = clientIds[i];
|
|
145
|
-
components[socketClientId]['onopen'](this.channel);
|
|
149
|
+
components[socketClientId]?.['onopen']?.(this.channel);
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
this.reconnectAttempts = 0;
|
|
149
153
|
}
|
|
150
154
|
|
|
155
|
+
onerror(event: any) {
|
|
156
|
+
let message = JSON.parse(event.data);
|
|
157
|
+
//TODO replace this with a more readable Stream code
|
|
158
|
+
for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
|
|
159
|
+
let socketClientId = clientIdsByTokens[this.channelToken][i];
|
|
160
|
+
if (document.getElementById(socketClientId)) {
|
|
161
|
+
try {
|
|
162
|
+
components[socketClientId]?.['onerror']?.(message, this.channel, event);
|
|
163
|
+
} catch (e) {
|
|
164
|
+
//Ignore
|
|
165
|
+
}
|
|
166
|
+
} else {
|
|
167
|
+
clientIdsByTokens[this.channelToken].splice(i, 1);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (clientIdsByTokens[this.channelToken].length == 0) {
|
|
171
|
+
// tag disappeared
|
|
172
|
+
this.close();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
151
176
|
onmmessage(event: any) {
|
|
152
177
|
let message = JSON.parse(event.data);
|
|
153
178
|
for (let i = clientIdsByTokens[this.channelToken].length - 1; i >= 0; i--) {
|
|
154
179
|
let socketClientId = clientIdsByTokens[this.channelToken][i];
|
|
155
180
|
if (document.getElementById(socketClientId)) {
|
|
156
181
|
try {
|
|
157
|
-
components[socketClientId]['onmessage'](message, this.channel, event);
|
|
182
|
+
components[socketClientId]?.['onmessage']?.(message, this.channel, event);
|
|
158
183
|
} catch (e) {
|
|
159
184
|
//Ignore
|
|
160
185
|
}
|
|
161
|
-
let behaviors = components[socketClientId]['behaviors'];
|
|
162
|
-
let functions = behaviors[message];
|
|
186
|
+
let behaviors = components?.[socketClientId]?.['behaviors'];
|
|
187
|
+
let functions = behaviors?.[message];
|
|
163
188
|
if (functions && functions.length) {
|
|
164
189
|
for (let j = 0; j < functions.length; j++) {
|
|
165
190
|
try {
|
|
@@ -188,7 +213,7 @@ export module PushImpl {
|
|
|
188
213
|
let clientIds = clientIdsByTokens[this.channelToken];
|
|
189
214
|
for (let i = clientIds.length - 1; i >= 0; i--) {
|
|
190
215
|
let socketClientId = clientIds[i];
|
|
191
|
-
components[socketClientId]['onclose'](event?.code, this?.channel, event);
|
|
216
|
+
components?.[socketClientId]?.['onclose']?.(event?.code, this?.channel, event);
|
|
192
217
|
}
|
|
193
218
|
} else {
|
|
194
219
|
setTimeout(this.open, RECONNECT_INTERVAL * this.reconnectAttempts++);
|
|
@@ -210,6 +235,7 @@ export module PushImpl {
|
|
|
210
235
|
this.socket.onopen = (event: Event) => this.onopen(event);
|
|
211
236
|
this.socket.onmessage = (event: Event) => this.onmmessage(event);
|
|
212
237
|
this.socket.onclose = (event: Event) => this.onclose(event);
|
|
238
|
+
this.socket.onerror = (event: Event) => this.onerror(event);
|
|
213
239
|
}
|
|
214
240
|
}
|
|
215
241
|
|
|
@@ -217,7 +243,7 @@ export module PushImpl {
|
|
|
217
243
|
|
|
218
244
|
function getBaseURL(url: string) {
|
|
219
245
|
if (url.indexOf("://") < 0) {
|
|
220
|
-
let base =
|
|
246
|
+
let base = DQ.global().location.hostname + ":" + DQ.global().location.port;
|
|
221
247
|
return URL_PROTOCOL + base + url;
|
|
222
248
|
} else {
|
|
223
249
|
return url;
|
|
@@ -242,7 +268,7 @@ export module PushImpl {
|
|
|
242
268
|
|
|
243
269
|
function resolveFunction(fn: Function | string = () => {
|
|
244
270
|
}): Function {
|
|
245
|
-
return <Function>((typeof fn !== "function") && (fn =
|
|
271
|
+
return <Function>((typeof fn !== "function") && (fn = DQ.global()[fn]), fn);
|
|
246
272
|
}
|
|
247
273
|
|
|
248
274
|
}
|
|
@@ -93,6 +93,8 @@ export const CTX_PARAM_SRC_FRM_ID = "_mfSourceFormId";
|
|
|
93
93
|
export const CTX_PARAM_SRC_CTL_ID = "_mfSourceControlId";
|
|
94
94
|
export const CTX_PARAM_TR_TYPE = "_mfTransportType";
|
|
95
95
|
export const CTX_PARAM_PASS_THR = "passThrgh";
|
|
96
|
+
export const CTX_PARAM_SPEC_PARAMS = "params";
|
|
97
|
+
|
|
96
98
|
export const CTX_PARAM_DELAY = "delay";
|
|
97
99
|
export const CTX_PARAM_TIMEOUT = "timeout";
|
|
98
100
|
export const CTX_PARAM_RST = "resetValues";
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {Config, DomQuery, DQ} from "mona-dish";
|
|
17
|
+
import {AssocArrayCollector, Config, DomQuery, DQ, Stream} from "mona-dish";
|
|
18
18
|
import {
|
|
19
19
|
CTX_PARAM_DELAY,
|
|
20
20
|
CTX_PARAM_TIMEOUT,
|
|
@@ -138,7 +138,7 @@ export function getEventTarget(evt: Event): Element {
|
|
|
138
138
|
* @param opts
|
|
139
139
|
* @param el
|
|
140
140
|
*/
|
|
141
|
-
export function resolveDefaults(event: Event, opts:
|
|
141
|
+
export function resolveDefaults(event: Event, opts: Options | [[string, any]] , el: Element | string = null) {
|
|
142
142
|
//deep copy the options, so that further transformations to not backfire into the callers
|
|
143
143
|
const resolvedEvent = event,
|
|
144
144
|
options = new ExtConfig(opts).deepCopy,
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import {ArrayCollector, Config, DQ, Lang, LazyStream, Stream} from "mona-dish";
|
|
17
17
|
import {EMPTY_STR, IDENT_ALL, IDENT_FORM, P_VIEWSTATE} from "../core/Const";
|
|
18
18
|
import isString = Lang.isString;
|
|
19
|
-
import {ExtConfig} from "../util/ExtDomQuery";
|
|
19
|
+
import {ExtConfig, ExtDomQuery} from "../util/ExtDomQuery";
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -54,15 +54,20 @@ export class XhrFormData extends Config {
|
|
|
54
54
|
//a call to getViewState before must pass the encoded line
|
|
55
55
|
//a call from getViewState passes the form element as datasource,
|
|
56
56
|
//so we have two call points
|
|
57
|
+
// atm we basically encode twice, to keep the code leaner
|
|
58
|
+
// this will be later optmized, practically elements
|
|
59
|
+
// which are already covered by an external viewstate do not need
|
|
60
|
+
// the encoding a second time, because they are overwritten by the viewstate again
|
|
57
61
|
if (isString(dataSource)) {
|
|
58
62
|
this.assignEncodedString(<string>this.dataSource);
|
|
59
63
|
} else {
|
|
60
64
|
this.applyFormDataToConfig();
|
|
61
65
|
}
|
|
62
|
-
|
|
66
|
+
//now assign the external viewstate overrides
|
|
67
|
+
if ('undefined' != typeof viewState) {
|
|
63
68
|
this.assignEncodedString(viewState)
|
|
64
69
|
}
|
|
65
|
-
if(executes) {
|
|
70
|
+
if (executes) {
|
|
66
71
|
this.postInit(...executes);
|
|
67
72
|
}
|
|
68
73
|
}
|
|
@@ -73,14 +78,17 @@ export class XhrFormData extends Config {
|
|
|
73
78
|
* in our ajax request
|
|
74
79
|
*/
|
|
75
80
|
postInit(...executes: Array<string>) {
|
|
76
|
-
let
|
|
81
|
+
let fetchFileInputs = (id: string): DQ => {
|
|
82
|
+
const INPUT_FILE = "input[type='file']";
|
|
77
83
|
if (id == IDENT_ALL) {
|
|
78
|
-
return DQ.querySelectorAllDeep(
|
|
84
|
+
return DQ.querySelectorAllDeep(INPUT_FILE);
|
|
79
85
|
} else if (id == IDENT_FORM) {
|
|
80
|
-
return (<DQ>this.dataSource).
|
|
86
|
+
return (<DQ>this.dataSource).matchesSelector(INPUT_FILE) ?
|
|
87
|
+
(<DQ>this.dataSource) :
|
|
88
|
+
(<DQ>this.dataSource).querySelectorAllDeep(INPUT_FILE);
|
|
81
89
|
} else {
|
|
82
90
|
let element = DQ.byId(id, true);
|
|
83
|
-
return this.getFileInputs(element);
|
|
91
|
+
return element.matchesSelector(INPUT_FILE) ? element : this.getFileInputs(element);
|
|
84
92
|
}
|
|
85
93
|
};
|
|
86
94
|
|
|
@@ -90,7 +98,7 @@ export class XhrFormData extends Config {
|
|
|
90
98
|
|
|
91
99
|
|
|
92
100
|
this.isMultipartRequest = LazyStream.of(...executes)
|
|
93
|
-
.map(
|
|
101
|
+
.map(fetchFileInputs)
|
|
94
102
|
.filter(inputExists)
|
|
95
103
|
.first().isPresent();
|
|
96
104
|
}
|
|
@@ -113,8 +121,8 @@ export class XhrFormData extends Config {
|
|
|
113
121
|
assignEncodedString(encoded: string) {
|
|
114
122
|
// this code filters out empty strings as key value pairs
|
|
115
123
|
let keyValueEntries = decodeURIComponent(encoded).split(/&/gi)
|
|
116
|
-
|
|
117
|
-
.replace(/\s+/g,''));
|
|
124
|
+
.filter(item => !!(item || '')
|
|
125
|
+
.replace(/\s+/g, ''));
|
|
118
126
|
this.assignString(keyValueEntries);
|
|
119
127
|
}
|
|
120
128
|
|
|
@@ -133,8 +141,8 @@ export class XhrFormData extends Config {
|
|
|
133
141
|
return keyVal.length < 3 ? [keyVal?.[0] ?? [], keyVal?.[1] ?? []] : keyVal;
|
|
134
142
|
}
|
|
135
143
|
|
|
144
|
+
//TODO fix files...
|
|
136
145
|
Stream.of(...keyValueEntries)
|
|
137
|
-
//split only the first =
|
|
138
146
|
.map(line => splitToKeyVal(line))
|
|
139
147
|
//special case of having keys without values
|
|
140
148
|
.map(keyVal => fixKeyWithoutVal(keyVal))
|
|
@@ -171,7 +179,11 @@ export class XhrFormData extends Config {
|
|
|
171
179
|
}
|
|
172
180
|
let entries = LazyStream.of(...Object.keys(this.value))
|
|
173
181
|
.filter(key => this.value.hasOwnProperty(key))
|
|
174
|
-
.flatMap(key => Stream.of(...this.value[key]).map(val => [key, val])
|
|
182
|
+
.flatMap(key => Stream.of(...this.value[key]).map(val => [key, val])
|
|
183
|
+
//we cannot encode file elements that is handled by multipart requests anyway
|
|
184
|
+
.filter(([, value]) => !(value instanceof ExtDomQuery.global().File))
|
|
185
|
+
.collect(new ArrayCollector()))
|
|
186
|
+
|
|
175
187
|
.map(keyVal => {
|
|
176
188
|
return `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
|
|
177
189
|
})
|