jsf.js_next_gen 4.0.1-beta.4 → 4.0.1-beta.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/dist/window/faces-development.js +97 -68
- 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 +97 -68
- 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 +1 -1
- package/src/main/typescript/impl/util/FileUtils.ts +1 -1
- package/src/main/typescript/impl/util/XhrQueueController.ts +3 -17
- package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +4 -4
- package/src/main/typescript/impl/xhrCore/XhrRequest.ts +95 -52
- package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/blank.css +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +15 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +40 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +7 -0
- package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/jakarta.faces.resource/faces.js.jsf +15 -0
- package/src/main/typescript/test/myfaces/{OnLoadSpec.ts → OnLoad.spec.ts} +2 -2
- package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +113 -0
- package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +9 -12
- package/target/impl/util/FileUtils.js +1 -1
- package/target/impl/util/FileUtils.js.map +1 -1
- package/target/impl/util/XhrQueueController.js +3 -18
- package/target/impl/util/XhrQueueController.js.map +1 -1
- package/target/impl/xhrCore/ResponseProcessor.js +2 -2
- package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
- package/target/impl/xhrCore/XhrRequest.js +89 -45
- package/target/impl/xhrCore/XhrRequest.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +138 -138
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +39 -0
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js +4 -0
- package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
- package/target/test/myfaces/OnLoad.spec.js +57 -0
- package/target/test/myfaces/OnLoad.spec.js.map +1 -0
- package/target/test/myfaces/OnLoadSpec.js +2 -2
- package/target/test/myfaces/OnLoadSpec.js.map +1 -1
- package/target/test/xhrCore/ErrorChainTest.spec.js +135 -0
- package/target/test/xhrCore/ErrorChainTest.spec.js.map +1 -0
- package/target/test/xhrCore/NamespacesRequestTest.spec.js +8 -5
- package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
|
@@ -162,7 +162,7 @@ function alloc(arr, length, defaultVal = {}) {
|
|
|
162
162
|
arr.push(...toAdd);
|
|
163
163
|
}
|
|
164
164
|
function flattenAccessPath(accessPath) {
|
|
165
|
-
return accessPath.flatMap(path => path.split("["))
|
|
165
|
+
return new Es2019Array_1.Es2019Array(...accessPath).flatMap(path => path.split("["))
|
|
166
166
|
.map(path => path.indexOf("]") != -1 ? "[" + path : path)
|
|
167
167
|
.filter(path => path != "");
|
|
168
168
|
}
|
|
@@ -256,7 +256,7 @@ exports.simpleShallowMerge = simpleShallowMerge;
|
|
|
256
256
|
*/
|
|
257
257
|
function shallowMerge(overwrite = true, withAppend = false, ...assocArrays) {
|
|
258
258
|
let target = {};
|
|
259
|
-
assocArrays.map(arr => {
|
|
259
|
+
new Es2019Array_1.Es2019Array(...assocArrays).map(arr => {
|
|
260
260
|
return { arr, keys: Object.keys(arr) };
|
|
261
261
|
}).forEach(({ arr, keys }) => {
|
|
262
262
|
keys.forEach(key => {
|
|
@@ -6128,7 +6128,7 @@ function resolveViewState(parentItem) {
|
|
|
6128
6128
|
function getFormInputsAsArr(parentItem) {
|
|
6129
6129
|
const standardInputs = resolveViewState(parentItem);
|
|
6130
6130
|
const fileInputs = resolveFiles(parentItem);
|
|
6131
|
-
return standardInputs.concat(
|
|
6131
|
+
return standardInputs.concat(fileInputs);
|
|
6132
6132
|
}
|
|
6133
6133
|
exports.getFormInputsAsArr = getFormInputsAsArr;
|
|
6134
6134
|
|
|
@@ -6570,14 +6570,9 @@ class XhrQueueController {
|
|
|
6570
6570
|
* and clear the queue (theoretically this
|
|
6571
6571
|
* would work with any promise)
|
|
6572
6572
|
*/
|
|
6573
|
-
|
|
6574
|
-
|
|
6575
|
-
|
|
6576
|
-
.catch((e) => this.handleError(e));
|
|
6577
|
-
}
|
|
6578
|
-
catch (e) {
|
|
6579
|
-
this.handleError(e);
|
|
6580
|
-
}
|
|
6573
|
+
return asyncRunnable
|
|
6574
|
+
.then(() => this.next())
|
|
6575
|
+
.catch(() => this.clear());
|
|
6581
6576
|
}
|
|
6582
6577
|
/**
|
|
6583
6578
|
* alerts the queue that a task is running
|
|
@@ -6594,16 +6589,6 @@ class XhrQueueController {
|
|
|
6594
6589
|
updateTaskRunning() {
|
|
6595
6590
|
this.taskRunning = !this.isEmpty;
|
|
6596
6591
|
}
|
|
6597
|
-
/**
|
|
6598
|
-
* standard error handling
|
|
6599
|
-
* we clear the queue and then bomb out
|
|
6600
|
-
* @param e
|
|
6601
|
-
* @private
|
|
6602
|
-
*/
|
|
6603
|
-
handleError(e) {
|
|
6604
|
-
this.clear();
|
|
6605
|
-
throw e;
|
|
6606
|
-
}
|
|
6607
6592
|
}
|
|
6608
6593
|
exports.XhrQueueController = XhrQueueController;
|
|
6609
6594
|
|
|
@@ -7340,8 +7325,8 @@ class ResponseProcessor {
|
|
|
7340
7325
|
const nodesToAdd = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
|
|
7341
7326
|
// this is stored for "post" processing
|
|
7342
7327
|
// after the rest of the "physical build up", head before body
|
|
7343
|
-
const scriptElements = nodesToAdd.
|
|
7344
|
-
.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1)
|
|
7328
|
+
const scriptElements = new mona_dish_1.DomQuery(...nodesToAdd.asArray
|
|
7329
|
+
.filter(item => scriptTags.indexOf(item.tagName.orElse("").value) != -1));
|
|
7345
7330
|
this.addToHeadDeferred(scriptElements);
|
|
7346
7331
|
}
|
|
7347
7332
|
addToHeadDeferred(newElements) {
|
|
@@ -8046,8 +8031,10 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
|
|
|
8046
8031
|
this.sendRequest(formData);
|
|
8047
8032
|
}
|
|
8048
8033
|
catch (e) {
|
|
8049
|
-
//
|
|
8050
|
-
|
|
8034
|
+
// this happens usually in a client side condition, hence we have to deal in with it in a client
|
|
8035
|
+
// side manner
|
|
8036
|
+
this.handleErrorAndClearQueue(e);
|
|
8037
|
+
throw e;
|
|
8051
8038
|
}
|
|
8052
8039
|
return this;
|
|
8053
8040
|
}
|
|
@@ -8071,102 +8058,138 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
|
|
|
8071
8058
|
registerXhrCallbacks(resolve, reject) {
|
|
8072
8059
|
const xhrObject = this.xhrObject;
|
|
8073
8060
|
xhrObject.onabort = () => {
|
|
8074
|
-
this.onAbort(reject);
|
|
8061
|
+
this.onAbort(resolve, reject);
|
|
8075
8062
|
};
|
|
8076
8063
|
xhrObject.ontimeout = () => {
|
|
8077
|
-
this.onTimeout(reject);
|
|
8064
|
+
this.onTimeout(resolve, reject);
|
|
8078
8065
|
};
|
|
8079
8066
|
xhrObject.onload = () => {
|
|
8080
|
-
this.
|
|
8067
|
+
this.onResponseReceived(resolve);
|
|
8081
8068
|
};
|
|
8082
8069
|
xhrObject.onloadend = () => {
|
|
8083
|
-
this.
|
|
8070
|
+
this.onResponseProcessed(this.xhrObject, resolve);
|
|
8084
8071
|
};
|
|
8085
8072
|
xhrObject.onerror = (errorData) => {
|
|
8086
|
-
//
|
|
8087
|
-
// cancel is called from outside
|
|
8073
|
+
// Safari in rare cases triggers an error when cancelling a request internally, or when
|
|
8088
8074
|
// in this case we simply ignore the request and clear up the queue, because
|
|
8089
8075
|
// it is not safe anymore to proceed with the current queue
|
|
8090
8076
|
// This bypasses a Safari issue where it keeps requests hanging after page unload
|
|
8091
8077
|
// and then triggers a cancel error on then instead of just stopping
|
|
8092
8078
|
// and clearing the code
|
|
8079
|
+
// in a page unload case it is safe to clear the queue
|
|
8080
|
+
// in the exact safari case any request after this one in the queue is invalid
|
|
8081
|
+
// because the queue references xhr requests to a page which already is gone!
|
|
8093
8082
|
if (this.isCancelledResponse(this.xhrObject)) {
|
|
8094
8083
|
/*
|
|
8095
8084
|
* this triggers the catch chain and after that finally
|
|
8096
8085
|
*/
|
|
8097
|
-
reject();
|
|
8098
8086
|
this.stopProgress = true;
|
|
8087
|
+
reject();
|
|
8099
8088
|
return;
|
|
8100
8089
|
}
|
|
8101
|
-
|
|
8090
|
+
// error already processed somewhere else
|
|
8091
|
+
if (this.stopProgress) {
|
|
8092
|
+
return;
|
|
8093
|
+
}
|
|
8094
|
+
this.handleError(errorData);
|
|
8102
8095
|
};
|
|
8103
8096
|
}
|
|
8104
8097
|
isCancelledResponse(currentTarget) {
|
|
8105
|
-
return (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.status) === 0 && // cancelled by browser
|
|
8098
|
+
return (currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.status) === 0 && // cancelled internally by browser
|
|
8106
8099
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.readyState) === 4 &&
|
|
8107
8100
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseText) === '' &&
|
|
8108
8101
|
(currentTarget === null || currentTarget === void 0 ? void 0 : currentTarget.responseXML) === null;
|
|
8109
8102
|
}
|
|
8110
8103
|
/*
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8104
|
+
* xhr processing callbacks
|
|
8105
|
+
*
|
|
8106
|
+
* Those methods are the callbacks called by
|
|
8107
|
+
* the xhr object depending on its own state
|
|
8108
|
+
*/
|
|
8109
|
+
/**
|
|
8110
|
+
* client side abort... also here for now we clean the queue
|
|
8111
|
+
*
|
|
8112
|
+
* @param resolve
|
|
8113
|
+
* @param reject
|
|
8114
|
+
* @private
|
|
8115
|
+
*/
|
|
8116
|
+
onAbort(resolve, reject) {
|
|
8117
|
+
// reject means clear queue, in this case we abort entirely the processing
|
|
8118
|
+
// does not happen yet, we have to probably rethink this strategy in the future
|
|
8119
|
+
// when we introduce cancel functionality
|
|
8120
|
+
this.handleGenericError(reject);
|
|
8118
8121
|
}
|
|
8119
|
-
|
|
8122
|
+
/**
|
|
8123
|
+
* request timeout, this must be handled like a generic server error per spec
|
|
8124
|
+
* unfortunately, so we have to jump to the next item (we cancelled before)
|
|
8125
|
+
* @param resolve
|
|
8126
|
+
* @param reject
|
|
8127
|
+
* @private
|
|
8128
|
+
*/
|
|
8129
|
+
onTimeout(resolve, reject) {
|
|
8130
|
+
// timeout also means we we probably should clear the queue,
|
|
8131
|
+
// the state is unsafe for the next requests
|
|
8120
8132
|
this.sendEvent(Const_1.STATE_EVT_TIMEOUT);
|
|
8121
|
-
|
|
8133
|
+
this.handleGenericError(resolve);
|
|
8122
8134
|
}
|
|
8123
|
-
|
|
8124
|
-
|
|
8135
|
+
/**
|
|
8136
|
+
* the response is received and normally is a normal response
|
|
8137
|
+
* but also can be some kind of error (http code >= 300)
|
|
8138
|
+
* In any case the response will be resolved either as error or response
|
|
8139
|
+
* and the next item in the queue will be processed
|
|
8140
|
+
* @param resolve
|
|
8141
|
+
* @private
|
|
8142
|
+
*/
|
|
8143
|
+
onResponseReceived(resolve) {
|
|
8144
|
+
var _a, _b, _c, _d;
|
|
8125
8145
|
this.sendEvent(Const_1.COMPLETE);
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8146
|
+
/*
|
|
8147
|
+
* second on error path
|
|
8148
|
+
*/
|
|
8149
|
+
if (((_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 0) >= 300 || !((_c = this === null || this === void 0 ? void 0 : this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseXML)) {
|
|
8150
|
+
// all errors from the server are resolved without interfering in the queue
|
|
8151
|
+
this.handleGenericError(resolve);
|
|
8130
8152
|
return;
|
|
8131
8153
|
}
|
|
8132
|
-
(0, Const_1.$faces)().ajax.response(this.xhrObject, (
|
|
8154
|
+
(0, Const_1.$faces)().ajax.response(this.xhrObject, (_d = this.responseContext.value) !== null && _d !== void 0 ? _d : {});
|
|
8133
8155
|
}
|
|
8134
|
-
|
|
8135
|
-
var _a;
|
|
8156
|
+
handleGenericError(resolveOrReject) {
|
|
8157
|
+
var _a, _b, _c, _d;
|
|
8136
8158
|
this.stopProgress = true;
|
|
8137
8159
|
const errorData = {
|
|
8138
8160
|
type: Const_1.ERROR,
|
|
8139
8161
|
status: Const_1.MALFORMEDXML,
|
|
8140
|
-
responseCode:
|
|
8141
|
-
responseText: (
|
|
8162
|
+
responseCode: (_b = (_a = this.xhrObject) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : 400,
|
|
8163
|
+
responseText: (_d = (_c = this.xhrObject) === null || _c === void 0 ? void 0 : _c.responseText) !== null && _d !== void 0 ? _d : "Error",
|
|
8142
8164
|
source: this.internalContext.getIf(Const_1.CTX_PARAM_SRC_CTL_ID).value
|
|
8143
8165
|
};
|
|
8144
8166
|
try {
|
|
8145
8167
|
this.handleError(errorData, true);
|
|
8146
8168
|
}
|
|
8147
8169
|
finally {
|
|
8148
|
-
// we issue a
|
|
8170
|
+
// we issue a resolveOrReject in this case to allow the system to recover
|
|
8149
8171
|
// reject would clean up the queue
|
|
8150
|
-
resolve
|
|
8172
|
+
// resolve would trigger the next element in the queue to be processed
|
|
8173
|
+
resolveOrReject(errorData);
|
|
8151
8174
|
}
|
|
8152
8175
|
// non blocking non clearing
|
|
8153
8176
|
}
|
|
8154
|
-
|
|
8155
|
-
|
|
8177
|
+
/**
|
|
8178
|
+
* last minute cleanup, the request now either is fully done
|
|
8179
|
+
* or not by having had a cancel or error event be
|
|
8180
|
+
* @param data
|
|
8181
|
+
* @param resolve
|
|
8182
|
+
* @private
|
|
8183
|
+
*/
|
|
8184
|
+
onResponseProcessed(data, resolve) {
|
|
8185
|
+
// if stop progress true, the cleanup already has been performed
|
|
8156
8186
|
if (this.stopProgress) {
|
|
8157
8187
|
return;
|
|
8158
8188
|
}
|
|
8159
|
-
/**
|
|
8160
|
-
* now call the then chain
|
|
8161
|
-
*/
|
|
8162
|
-
resolve(data);
|
|
8163
|
-
}
|
|
8164
|
-
onError(errorData, reject) {
|
|
8165
|
-
this.handleError(errorData);
|
|
8166
8189
|
/*
|
|
8167
|
-
*
|
|
8190
|
+
* normal case, cleanup == next item if possible
|
|
8168
8191
|
*/
|
|
8169
|
-
|
|
8192
|
+
resolve(data);
|
|
8170
8193
|
}
|
|
8171
8194
|
sendRequest(formData) {
|
|
8172
8195
|
const isPost = this.ajaxType != Const_1.REQ_TYPE_GET;
|
|
@@ -8195,10 +8218,16 @@ class XhrRequest extends AsyncRunnable_1.AsyncRunnable {
|
|
|
8195
8218
|
}
|
|
8196
8219
|
catch (e) {
|
|
8197
8220
|
e.source = (_a = e === null || e === void 0 ? void 0 : e.source) !== null && _a !== void 0 ? _a : this.requestContext.getIf(Const_1.SOURCE).value;
|
|
8198
|
-
this
|
|
8221
|
+
// this is a client error, no save state anymore for queue processing!
|
|
8222
|
+
this.handleErrorAndClearQueue(e);
|
|
8223
|
+
// we forward the error upward like all client side errors
|
|
8199
8224
|
throw e;
|
|
8200
8225
|
}
|
|
8201
8226
|
}
|
|
8227
|
+
handleErrorAndClearQueue(e, responseFormatError = false) {
|
|
8228
|
+
this.handleError(e, responseFormatError);
|
|
8229
|
+
this.reject(e);
|
|
8230
|
+
}
|
|
8202
8231
|
handleError(exception, responseFormatError = false) {
|
|
8203
8232
|
const errorData = (responseFormatError) ? ErrorData_1.ErrorData.fromHttpConnection(exception.source, exception.type, exception.status, exception.responseText, exception.responseCode, exception.status) : ErrorData_1.ErrorData.fromClient(exception);
|
|
8204
8233
|
const eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_ERROR);
|
|
Binary file
|
|
Binary file
|