jsf.js_next_gen 4.0.0-beta-23 → 4.0.1-alpha.0
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/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +1 -0
- package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/README.md +13 -21
- package/dist/docs/assets/main.js +56 -52
- package/dist/docs/assets/search.js +1 -1
- package/dist/docs/assets/style.css +23 -0
- package/dist/docs/functions/faces.ajax.addOnError.html +2 -0
- package/dist/docs/functions/faces.ajax.addOnEvent.html +2 -0
- package/dist/docs/functions/faces.push.close.html +4 -2
- package/dist/docs/functions/faces.push.init.html +19 -7
- package/dist/docs/functions/faces.push.open.html +4 -2
- package/dist/docs/functions/myfaces.ab.html +9 -4
- package/dist/docs/functions/myfaces.onDomReady.html +72 -0
- package/dist/docs/index.html +16 -18
- package/dist/docs/modules/myfaces.html +3 -1
- package/dist/docs/variables/myfaces.oam.html +2 -1
- package/dist/window/faces-development.js +2846 -2085
- 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.LICENSE.txt +17 -2
- 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 +2856 -2084
- 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.LICENSE.txt +17 -2
- 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 +19 -18
- package/plans for 4.0.1.txt +8 -0
- package/src/main/test.xml +23 -0
- package/src/main/typescript/@types/definitions/index.d.ts +19 -2
- package/src/main/typescript/api/_api.ts +68 -25
- package/src/main/typescript/api/jsf.ts +18 -0
- package/src/main/typescript/impl/AjaxImpl.ts +204 -100
- package/src/main/typescript/impl/PushImpl.ts +63 -38
- package/src/main/typescript/impl/core/Const.ts +56 -40
- package/src/main/typescript/impl/util/Assertions.ts +16 -8
- package/src/main/typescript/impl/util/AsyncRunnable.ts +85 -10
- package/src/main/typescript/impl/util/ExtDomQuery.ts +65 -54
- package/src/main/typescript/impl/util/FileUtils.ts +108 -0
- package/src/main/typescript/impl/util/HiddenInputBuilder.ts +93 -0
- package/src/main/typescript/impl/util/Lang.ts +91 -35
- package/src/main/typescript/impl/util/XhrQueueController.ts +112 -0
- package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -10
- package/src/main/typescript/impl/xhrCore/EventData.ts +3 -3
- package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +25 -11
- package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +78 -32
- package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +10 -10
- package/src/main/typescript/impl/xhrCore/Response.ts +66 -49
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +211 -138
- package/src/main/typescript/impl/xhrCore/XhrFormData.ts +92 -166
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +111 -120
- package/src/main/typescript/myfaces/OamSubmit.ts +30 -14
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +163 -27
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +4 -4
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +0 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.ts +921 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.ts +108 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +111 -3
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +40 -1
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +0 -0
- package/src/main/typescript/test/impl/ImplTest.spec.ts +3 -3
- package/src/main/typescript/test/impl/ImplTest_23.spec.ts +3 -7
- package/src/main/typescript/test/myfaces/OnLoadSpec.ts +52 -0
- package/src/main/typescript/test/queue/AsynchronousProbe.ts +5 -5
- package/src/main/typescript/test/queue/AsynchronousQueueTest.spec.ts +4 -3
- package/src/main/typescript/test/xhrCore/EventTests.spec.ts +28 -22
- package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +5 -2
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +203 -0
- package/src/main/typescript/test/xhrCore/OamSubmitTest.spec.ts +177 -0
- package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +158 -17
- package/src/main/typescript/test/xhrCore/RequestTest.spec.ts +320 -15
- package/src/main/typescript/test/xhrCore/RequestTest_23.spec.ts +45 -4
- package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +374 -35
- package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +43 -9
- package/src/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.ts +109 -0
- package/src/main/typescript/test/xhrCore/XhrFormDataTest.spec.ts +67 -49
- package/src/main/typescript/test.xml +6 -0
- package/src/main/typescript/tsconfig.json +1 -1
- package/src/test/resources/jsf-development.js +1 -1
- package/src/tmp/test.html +12 -88
- package/target/api/_api.js +63 -21
- package/target/api/_api.js.map +1 -1
- package/target/api/jsf.js +11 -0
- package/target/api/jsf.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/impl/AjaxImpl.js +177 -81
- package/target/impl/AjaxImpl.js.map +1 -1
- package/target/impl/PushImpl.js +66 -35
- package/target/impl/PushImpl.js.map +1 -1
- package/target/impl/core/Const.js +54 -39
- package/target/impl/core/Const.js.map +1 -1
- package/target/impl/core/Context.js +10 -0
- package/target/impl/core/Context.js.map +1 -0
- package/target/impl/util/Assertions.js +12 -7
- package/target/impl/util/Assertions.js.map +1 -1
- package/target/impl/util/AsyncQueue.js.map +1 -1
- package/target/impl/util/AsyncRunnable.js +60 -0
- package/target/impl/util/AsyncRunnable.js.map +1 -1
- package/target/impl/util/ExtDomQuery.js +66 -48
- package/target/impl/util/ExtDomQuery.js.map +1 -1
- package/target/impl/util/FileUtils.js +97 -0
- package/target/impl/util/FileUtils.js.map +1 -0
- package/target/impl/util/HiddenElementBuilder.js +7 -0
- package/target/impl/util/HiddenElementBuilder.js.map +1 -0
- package/target/impl/util/HiddenInputBuilder.js +83 -0
- package/target/impl/util/HiddenInputBuilder.js.map +1 -0
- package/target/{types/index.js → impl/util/IAsyncRunnable.js} +11 -2
- package/target/impl/util/IAsyncRunnable.js.map +1 -0
- package/target/impl/util/Lang.js +81 -31
- package/target/impl/util/Lang.js.map +1 -1
- package/target/impl/util/URLCodec.js +77 -0
- package/target/impl/util/URLCodec.js.map +1 -0
- package/target/impl/util/XhrQueueController.js +107 -0
- package/target/impl/util/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/ErrorData.js +10 -8
- package/target/impl/xhrCore/ErrorData.js.map +1 -1
- package/target/impl/xhrCore/EventData.js +2 -2
- package/target/impl/xhrCore/EventData.js.map +1 -1
- package/target/impl/xhrCore/RequestContext.js +11 -0
- package/target/impl/xhrCore/RequestContext.js.map +1 -0
- package/target/impl/xhrCore/RequestDataResolver.js +70 -23
- package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
- package/target/impl/xhrCore/ResonseDataResolver.js +9 -9
- package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
- package/target/impl/xhrCore/Response.js +44 -29
- package/target/impl/xhrCore/Response.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +187 -119
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrFormData.js +82 -156
- package/target/impl/xhrCore/XhrFormData.js.map +1 -1
- package/target/impl/xhrCore/XhrQueHandler.js +11 -0
- package/target/impl/xhrCore/XhrQueHandler.js.map +1 -0
- package/target/impl/xhrCore/XhrQueueController.js +62 -0
- package/target/impl/xhrCore/XhrQueueController.js.map +1 -0
- package/target/impl/xhrCore/XhrRequest.js +94 -106
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/myfaces/OamSubmit.js +25 -14
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +124 -23
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js +76 -0
- package/target/test/frameworkBase/_ext/monadish/ExtendedArrayTest.spec.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +4 -4
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js +925 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-with-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js +112 -0
- package/target/test/frameworkBase/_ext/monadish/markups/tobago-without-header.js.map +1 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +103 -3
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +37 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +2 -2
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/ImplTest_23.spec.js +2 -2
- package/target/test/impl/ImplTest_23.spec.js.map +1 -1
- package/target/test/myfaces/OnLoadSpec.js +57 -0
- package/target/test/myfaces/OnLoadSpec.js.map +1 -0
- package/target/test/queue/AsynchronousQueueTest.spec.js +3 -3
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +26 -19
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +2 -1
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +204 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js +180 -0
- package/target/test/xhrCore/OamSubmitTest.spec.js.map +1 -0
- package/target/test/xhrCore/RequestParamsTest.spec.js +142 -10
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +288 -11
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest_23.spec.js +40 -2
- package/target/test/xhrCore/RequestTest_23.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +315 -24
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest23.spec.js +38 -8
- package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js +128 -0
- package/target/test/xhrCore/TobagoFileUploadTest.spec.js.map +1 -0
- package/target/test/xhrCore/XhrFormDataTest.spec.js +57 -34
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
- 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 +24 -0
- package/target/test-classes/jsf-development.js +3559 -0
- 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 +1 -0
- package/target/test-classes/jsf.js +3 -0
- package/target/test-classes/jsf.js.br +0 -0
- package/target/test-classes/jsf.js.gz +0 -0
- package/tmp.xml +36 -0
- package/.nyc_output/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/.nyc_output/processinfo/2303b649-59d9-485c-9228-73b0ec8787a7.json +0 -1
- package/.nyc_output/processinfo/756f2f03-c85b-4cdb-9b92-5799eb45ef1e.json +0 -1
- package/src/main/typescript/impl/util/AsyncQueue.ts +0 -133
- package/src/main/typescript/test/frameworkBase/_ext/monadish/StreamTest.spec.ts +0 -231
- package/target/types/index.js.map +0 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {Config, IValueHolder, Optional, DomQuery, DQ
|
|
16
|
+
import {Config, IValueHolder, Optional, DomQuery, DQ} from "mona-dish";
|
|
17
17
|
import {$nsp, P_WINDOW_ID} from "../core/Const";
|
|
18
18
|
|
|
19
19
|
|
|
@@ -39,9 +39,12 @@ const IS_FACES_SOURCE = (source?: string): boolean => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* namespace myfaces
|
|
43
|
-
* tests, those will be handled similarly to faces.js
|
|
44
|
-
* reload blocking on ajax requests
|
|
42
|
+
* namespace myfaces\.testscripts can be used as extension point for internal
|
|
43
|
+
* tests, those will be handled similarly to faces.js, in regard
|
|
44
|
+
* to reload blocking on ajax requests
|
|
45
|
+
*
|
|
46
|
+
* Note: atm not used, used to be used in the old implementation
|
|
47
|
+
* but still is reserved for now
|
|
45
48
|
*
|
|
46
49
|
* @param source the source to check
|
|
47
50
|
* @constructor
|
|
@@ -55,21 +58,21 @@ const ATTR_SRC = 'src';
|
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Extension which adds implementation specific
|
|
58
|
-
* meta
|
|
61
|
+
* meta-data to our dom query
|
|
59
62
|
*
|
|
60
63
|
* Usage
|
|
61
64
|
* el = new ExtDQ(oldReference)
|
|
62
65
|
* nonce = el.nonce
|
|
63
66
|
* windowId = el.getWindowId
|
|
64
67
|
*/
|
|
65
|
-
export class
|
|
68
|
+
export class ExtDomQuery extends DQ {
|
|
66
69
|
|
|
67
70
|
static get windowId() {
|
|
68
|
-
return new
|
|
71
|
+
return new ExtDomQuery(document.body).windowId;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
74
|
static get nonce(): string {
|
|
72
|
-
return new
|
|
75
|
+
return new ExtDomQuery(document.body).nonce;
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
get windowId(): string | null {
|
|
@@ -112,17 +115,15 @@ export class ExtDomquery extends DQ {
|
|
|
112
115
|
let curScript = new DQ(document.currentScript);
|
|
113
116
|
//since our baseline atm is ie11 we cannot use document.currentScript globally
|
|
114
117
|
if (!!this.extractNonce(curScript)) {
|
|
115
|
-
//
|
|
118
|
+
// fast-path for modern browsers
|
|
116
119
|
return this.extractNonce(curScript);
|
|
117
120
|
}
|
|
118
121
|
// fallback if the currentScript method fails, we just search the jsf tags for nonce, this is
|
|
119
122
|
// the last possibility
|
|
120
|
-
let nonceScript = DQ
|
|
121
|
-
.querySelectorAll("script[src], link[src]")
|
|
122
|
-
.lazyStream
|
|
123
|
+
let nonceScript = Optional.fromNullable(DQ
|
|
124
|
+
.querySelectorAll("script[src], link[src]").asArray
|
|
123
125
|
.filter((item) => this.extractNonce(item) && item.attr(ATTR_SRC) != null)
|
|
124
|
-
.filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
|
|
125
|
-
.first();
|
|
126
|
+
.filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))?.[0]);
|
|
126
127
|
|
|
127
128
|
if (nonceScript.isPresent()) {
|
|
128
129
|
return this.extractNonce(nonceScript.value);
|
|
@@ -130,49 +131,45 @@ export class ExtDomquery extends DQ {
|
|
|
130
131
|
return null;
|
|
131
132
|
}
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
private extractNonce(curScript: DomQuery) {
|
|
136
|
-
return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
134
|
static searchJsfJsFor(item: RegExp): Optional<String> {
|
|
140
|
-
return new
|
|
135
|
+
return new ExtDomQuery(document).searchJsfJsFor(item);
|
|
141
136
|
}
|
|
142
137
|
|
|
143
138
|
/**
|
|
144
|
-
* searches the embedded faces.js for items like separator char etc
|
|
139
|
+
* searches the embedded faces.js for items like separator char etc.
|
|
145
140
|
* expects a match as variable under position 1 in the result match
|
|
146
|
-
* @param
|
|
141
|
+
* @param regExp
|
|
147
142
|
*/
|
|
148
|
-
searchJsfJsFor(
|
|
143
|
+
searchJsfJsFor(regExp: RegExp): Optional<string> {
|
|
149
144
|
//perfect application for lazy stream
|
|
150
|
-
return DQ.querySelectorAll("script[src], link[src]").
|
|
145
|
+
return Optional.fromNullable(DQ.querySelectorAll("script[src], link[src]").asArray
|
|
151
146
|
.filter(item => IS_FACES_SOURCE(item.attr(ATTR_SRC).value))
|
|
152
|
-
.map(item => item.attr(ATTR_SRC).value.match(
|
|
147
|
+
.map(item => item.attr(ATTR_SRC).value.match(regExp))
|
|
153
148
|
.filter(item => item != null && item.length > 1)
|
|
154
149
|
.map((result: string[]) => {
|
|
155
150
|
return decodeURIComponent(result[1]);
|
|
156
|
-
})
|
|
151
|
+
})?.[0]);
|
|
157
152
|
}
|
|
158
153
|
|
|
159
154
|
globalEval(code: string, nonce ?: string): DQ {
|
|
160
|
-
return new
|
|
155
|
+
return new ExtDomQuery(super.globalEval(code, nonce ?? this.nonce));
|
|
161
156
|
}
|
|
162
157
|
|
|
158
|
+
// called from base class runScripts, do not delete
|
|
159
|
+
// noinspection JSUnusedGlobalSymbols
|
|
163
160
|
globalEvalSticky(code: string, nonce ?: string): DQ {
|
|
164
|
-
return new
|
|
161
|
+
return new ExtDomQuery(super.globalEvalSticky(code, nonce ?? this.nonce));
|
|
165
162
|
}
|
|
166
163
|
|
|
167
164
|
/**
|
|
168
165
|
* decorated run scripts which takes our jsf extensions into consideration
|
|
169
166
|
* (standard DomQuery will let you pass anything)
|
|
170
167
|
* @param sticky if set to true the internally generated element for the script is left in the dom
|
|
171
|
-
* @param
|
|
168
|
+
* @param whiteListed
|
|
172
169
|
*/
|
|
173
|
-
runScripts(sticky = false,
|
|
170
|
+
runScripts(sticky = false, whiteListed?: (src: string) => boolean): DomQuery {
|
|
174
171
|
const whitelistFunc = (src: string): boolean => {
|
|
175
|
-
return (
|
|
172
|
+
return (whiteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
|
|
176
173
|
};
|
|
177
174
|
return super.runScripts(sticky, whitelistFunc);
|
|
178
175
|
}
|
|
@@ -183,7 +180,7 @@ export class ExtDomquery extends DQ {
|
|
|
183
180
|
* @param suppressDoubleIncludes checks for existing elements in the head before running the insert
|
|
184
181
|
*/
|
|
185
182
|
runHeadInserts(suppressDoubleIncludes = true): void {
|
|
186
|
-
let head =
|
|
183
|
+
let head = ExtDomQuery.byId(document.head);
|
|
187
184
|
//automated nonce handling
|
|
188
185
|
let processedScripts = [];
|
|
189
186
|
|
|
@@ -197,12 +194,13 @@ export class ExtDomquery extends DQ {
|
|
|
197
194
|
}
|
|
198
195
|
const tagName = element.tagName.value;
|
|
199
196
|
if(!tagName) {
|
|
200
|
-
//
|
|
197
|
+
// text node they do not have tag names, so we can process them as they are without
|
|
198
|
+
// any further ado
|
|
201
199
|
return true;
|
|
202
200
|
}
|
|
203
201
|
let reference = element.attr("href")
|
|
204
|
-
.
|
|
205
|
-
.
|
|
202
|
+
.orElseLazy(() => element.attr("src").value)
|
|
203
|
+
.orElseLazy(() => element.attr("rel").value);
|
|
206
204
|
|
|
207
205
|
if (!reference.isPresent()) {
|
|
208
206
|
return true;
|
|
@@ -217,14 +215,14 @@ export class ExtDomquery extends DQ {
|
|
|
217
215
|
.each(element => {
|
|
218
216
|
if(element.tagName.value != "SCRIPT") {
|
|
219
217
|
//we need to run runScripts properly to deal with the rest
|
|
220
|
-
new
|
|
218
|
+
new ExtDomQuery(...processedScripts).runScripts(true);
|
|
221
219
|
processedScripts = [];
|
|
222
220
|
head.append(element);
|
|
223
221
|
} else {
|
|
224
222
|
processedScripts.push(element);
|
|
225
223
|
}
|
|
226
224
|
});
|
|
227
|
-
new
|
|
225
|
+
new ExtDomQuery(...processedScripts).runScripts(true);
|
|
228
226
|
}
|
|
229
227
|
|
|
230
228
|
|
|
@@ -235,15 +233,21 @@ export class ExtDomquery extends DQ {
|
|
|
235
233
|
* @param deep whether the search should go into embedded shadow dom elements
|
|
236
234
|
* @return a DomQuery containing the found elements
|
|
237
235
|
*/
|
|
238
|
-
static byId(selector: string | DomQuery | Element, deep = false):
|
|
236
|
+
static byId(selector: string | DomQuery | Element, deep = false): ExtDomQuery {
|
|
239
237
|
const ret = DomQuery.byId(selector, deep);
|
|
240
|
-
return new
|
|
238
|
+
return new ExtDomQuery(ret);
|
|
241
239
|
}
|
|
242
240
|
|
|
241
|
+
private extractNonce(curScript: DomQuery) {
|
|
242
|
+
return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
|
|
243
|
+
}
|
|
243
244
|
|
|
245
|
+
filter(func: (item: DomQuery) => boolean): ExtDomQuery {
|
|
246
|
+
return new ExtDomQuery(super.filter(func));
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
249
|
|
|
246
|
-
export const ExtDQ =
|
|
250
|
+
export const ExtDQ = ExtDomQuery;
|
|
247
251
|
|
|
248
252
|
/**
|
|
249
253
|
* in order to reduce the number of interception points for the fallbacks we add
|
|
@@ -251,18 +255,20 @@ export const ExtDQ = ExtDomquery;
|
|
|
251
255
|
*/
|
|
252
256
|
export class ExtConfig extends Config {
|
|
253
257
|
|
|
258
|
+
$nspEnabled = true;
|
|
259
|
+
|
|
254
260
|
constructor(root: any) {
|
|
255
261
|
super(root);
|
|
256
262
|
}
|
|
257
263
|
|
|
258
264
|
assignIf(condition: boolean, ...accessPath): IValueHolder<any> {
|
|
259
|
-
const
|
|
260
|
-
return super.assignIf(condition, ...
|
|
265
|
+
const accessPathMapped = this.remap(accessPath);
|
|
266
|
+
return super.assignIf(condition, ...accessPathMapped);
|
|
261
267
|
}
|
|
262
268
|
|
|
263
269
|
assign(...accessPath): IValueHolder<any> {
|
|
264
|
-
const
|
|
265
|
-
return super.assign(...
|
|
270
|
+
const accessPathMapped = this.remap(accessPath);
|
|
271
|
+
return super.assign(...accessPathMapped);
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
append(...accessPath): IValueHolder<any> {
|
|
@@ -270,13 +276,13 @@ export class ExtConfig extends Config {
|
|
|
270
276
|
}
|
|
271
277
|
|
|
272
278
|
appendIf(condition: boolean, ...accessPath): IValueHolder<any> {
|
|
273
|
-
const
|
|
274
|
-
return super.appendIf(condition, ...
|
|
279
|
+
const accessPathMapped = this.remap(accessPath);
|
|
280
|
+
return super.appendIf(condition, ...accessPathMapped);
|
|
275
281
|
}
|
|
276
282
|
|
|
277
283
|
getIf(...accessPath): Config {
|
|
278
|
-
const
|
|
279
|
-
return super.getIf(...
|
|
284
|
+
const accessPathMapped = this.remap(accessPath);
|
|
285
|
+
return super.getIf(...accessPathMapped);
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
get(defaultVal: any): Config {
|
|
@@ -315,10 +321,15 @@ export class ExtConfig extends Config {
|
|
|
315
321
|
return new ExtConfig(super.deepCopy$());
|
|
316
322
|
}
|
|
317
323
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
324
|
+
/**
|
|
325
|
+
* helper to remap the namespaces of an array of access paths
|
|
326
|
+
* @param accessPath the access paths to be remapped
|
|
327
|
+
* @private returns an array of access paths with version remapped namespaces
|
|
328
|
+
*/
|
|
329
|
+
private remap(accessPath: string[]): string[] {
|
|
330
|
+
if(!this.$nspEnabled) {
|
|
331
|
+
return accessPath;
|
|
332
|
+
}
|
|
333
|
+
return [...accessPath].map(key => $nsp(key));
|
|
321
334
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
335
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {Config, DomQuery, DQ} from "mona-dish";
|
|
2
|
+
import {ExtDomQuery} from "./ExtDomQuery";
|
|
3
|
+
import {$faces, EMPTY_STR} from "../core/Const";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* various routines for encoding and decoding url parameters
|
|
7
|
+
* into configs and vice versa
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* encodes a given form data into a url encoded string
|
|
13
|
+
* @param formData the form data config object
|
|
14
|
+
* @param paramsMapper the params mapper
|
|
15
|
+
* @param defaultStr a default string if nothing comes out of it
|
|
16
|
+
*/
|
|
17
|
+
export function encodeFormData(formData: Config,
|
|
18
|
+
paramsMapper = (inStr, inVal) => [inStr, inVal],
|
|
19
|
+
defaultStr = EMPTY_STR): string {
|
|
20
|
+
if (formData.isAbsent()) {
|
|
21
|
+
return defaultStr;
|
|
22
|
+
}
|
|
23
|
+
const assocValues = formData.value;
|
|
24
|
+
|
|
25
|
+
const expandValueArrAndRename = key => assocValues[key].map(val => paramsMapper(key, val));
|
|
26
|
+
const isPropertyKey = key => assocValues.hasOwnProperty(key);
|
|
27
|
+
const isNotFile = ([, value]) => !(value instanceof ExtDomQuery.global().File);
|
|
28
|
+
const mapIntoUrlParam = keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
|
|
29
|
+
|
|
30
|
+
return Object.keys(assocValues)
|
|
31
|
+
.filter(isPropertyKey)
|
|
32
|
+
.flatMap(expandValueArrAndRename)
|
|
33
|
+
.filter(isNotFile)
|
|
34
|
+
.map(mapIntoUrlParam)
|
|
35
|
+
.join("&");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* splits and decodes encoded values into strings containing of key=value
|
|
40
|
+
* @param encoded encoded string
|
|
41
|
+
*/
|
|
42
|
+
export function decodeEncodedValues(encoded: string): string[][] {
|
|
43
|
+
const filterBlanks = item => !!(item || '').replace(/\s+/g, '');
|
|
44
|
+
const splitKeyValuePair = line => {
|
|
45
|
+
let index = line.indexOf("=");
|
|
46
|
+
if (index == -1) {
|
|
47
|
+
return [line];
|
|
48
|
+
}
|
|
49
|
+
return [line.substring(0, index), line.substring(index + 1)];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
let requestParamEntries = decodeURIComponent(encoded).split(/&/gi);
|
|
53
|
+
return requestParamEntries.filter(filterBlanks).map(splitKeyValuePair);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* gets all the input files and their corresponding file objects
|
|
59
|
+
* @param dataSource
|
|
60
|
+
*/
|
|
61
|
+
export function resolveFiles(dataSource: DQ): [string, File][] {
|
|
62
|
+
|
|
63
|
+
const expandFilesArr = ([key, files]) => {
|
|
64
|
+
return [...files].map(file => [key, file]);
|
|
65
|
+
}
|
|
66
|
+
const remapFileInput = fileInput => {
|
|
67
|
+
return [fileInput.name.value || fileInput.id.value, fileInput.filesFromElem(0)];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const files = dataSource
|
|
71
|
+
.querySelectorAllDeep("input[type='file']")
|
|
72
|
+
.asArray;
|
|
73
|
+
|
|
74
|
+
const ret = files
|
|
75
|
+
.map(remapFileInput)
|
|
76
|
+
.flatMap(expandFilesArr);
|
|
77
|
+
|
|
78
|
+
return ret as any;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
export function fixEmptyParameters(keyVal: any[]): [string, any] {
|
|
83
|
+
return (keyVal.length < 3 ? [keyVal?.[0] ?? [], keyVal?.[1] ?? []] : keyVal) as [string, any];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* returns the decoded viewState from parentItem
|
|
88
|
+
* @param parentItem
|
|
89
|
+
*/
|
|
90
|
+
function resolveViewState(parentItem: DomQuery): string[][] | [string, File][] {
|
|
91
|
+
const viewStateStr = $faces().getViewState(parentItem.getAsElem(0).value);
|
|
92
|
+
|
|
93
|
+
// we now need to decode it and then merge it into the target buf
|
|
94
|
+
// which hosts already our overrides (aka do not override what is already there(
|
|
95
|
+
// after that we need to deal with form elements on a separate level
|
|
96
|
+
return decodeEncodedValues(viewStateStr);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* gets all the inputs under the form parentItem
|
|
101
|
+
* as array
|
|
102
|
+
* @param parentItem
|
|
103
|
+
*/
|
|
104
|
+
export function getFormInputsAsArr(parentItem: DomQuery): string[][] | [string, File][] {
|
|
105
|
+
const standardInputs: any = resolveViewState(parentItem);
|
|
106
|
+
const fileInputs = resolveFiles(parentItem);
|
|
107
|
+
return standardInputs.concat(...fileInputs)
|
|
108
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/*! Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
* contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
* this work for additional information regarding copyright ownership.
|
|
4
|
+
* The ASF licenses this file to you under the Apache License, Version 2.0
|
|
5
|
+
* (the "License"); you may not use this file except in compliance with
|
|
6
|
+
* the License. You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {DomQuery, DQ, DQ$} from "mona-dish";
|
|
19
|
+
import {$faces, $nsp, HTML_CLIENT_WINDOW, HTML_VIEWSTATE, P_CLIENT_WINDOW, P_VIEWSTATE} from "../core/Const";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Builder for hidden inputs.
|
|
23
|
+
* ATM only ViewState and Client window
|
|
24
|
+
* are supported (per spec)
|
|
25
|
+
*
|
|
26
|
+
* Improves readability in the response processor!
|
|
27
|
+
*/
|
|
28
|
+
export class HiddenInputBuilder {
|
|
29
|
+
private namingContainerId?: string;
|
|
30
|
+
private parent?: DomQuery;
|
|
31
|
+
private namedViewRoot: boolean = false;
|
|
32
|
+
private readonly name: string;
|
|
33
|
+
private readonly template: string;
|
|
34
|
+
|
|
35
|
+
constructor(private selector: string) {
|
|
36
|
+
const isViewState = selector.indexOf($nsp(P_VIEWSTATE)) != -1;
|
|
37
|
+
this.name = isViewState ? P_VIEWSTATE : P_CLIENT_WINDOW
|
|
38
|
+
this.template = isViewState ? HTML_VIEWSTATE : HTML_CLIENT_WINDOW
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
withNamingContainerId(namingContainer: string): HiddenInputBuilder {
|
|
42
|
+
this.namingContainerId = namingContainer;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
withParent(parent: DomQuery): HiddenInputBuilder {
|
|
47
|
+
this.parent = parent;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
withNamedViewRoot(namedViewRoot: boolean): HiddenInputBuilder {
|
|
52
|
+
this.namedViewRoot = namedViewRoot;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
build(): DomQuery {
|
|
58
|
+
const SEP = $faces().separatorchar;
|
|
59
|
+
|
|
60
|
+
let existingStates = DQ$(`[name*='${$nsp(this.name)}']`);
|
|
61
|
+
let cnt = existingStates.asArray.map(state => {
|
|
62
|
+
let ident: string = state.id.orElse("-1").value;
|
|
63
|
+
ident = ident.substring(ident.lastIndexOf(SEP)+1);
|
|
64
|
+
return parseInt(ident);
|
|
65
|
+
})
|
|
66
|
+
.filter(item => {
|
|
67
|
+
return !isNaN(item);
|
|
68
|
+
})
|
|
69
|
+
.reduce((item1, item2) => {
|
|
70
|
+
return Math.max(item1, item2);
|
|
71
|
+
}, -1);
|
|
72
|
+
//the maximum new ident is the current max + 1
|
|
73
|
+
cnt++;
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const newElement = DQ.fromMarkup($nsp(this.template));
|
|
77
|
+
newElement.id.value = ((this.namingContainerId?.length) ?
|
|
78
|
+
[this.namingContainerId, $nsp(this.name), cnt]:
|
|
79
|
+
[$nsp(this.name), cnt]).join(SEP);
|
|
80
|
+
|
|
81
|
+
//name must be prefixed with the naming container id as well according to the jsdocs
|
|
82
|
+
if(this.namedViewRoot) {
|
|
83
|
+
newElement.name.value = (this.namingContainerId?.length) ?
|
|
84
|
+
[this.namingContainerId, $nsp(this.name)].join(SEP): $nsp(this.name);
|
|
85
|
+
} else {
|
|
86
|
+
newElement.name.value = $nsp(this.name);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
this?.parent?.append(newElement);
|
|
91
|
+
return newElement;
|
|
92
|
+
}
|
|
93
|
+
}
|