jsf.js_next_gen 1.0.0-beta-17 → 1.0.0-beta-18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/window/jsf-development.js +274 -193
  2. package/dist/window/jsf-development.js.map +1 -1
  3. package/dist/window/jsf.js +1 -1
  4. package/dist/window/jsf.js.br +0 -0
  5. package/dist/window/jsf.js.gz +0 -0
  6. package/dist/window/jsf.js.map +1 -1
  7. package/package.json +1 -1
  8. package/src/main/typescript/impl/AjaxImpl.ts +84 -48
  9. package/src/main/typescript/impl/util/AsyncQueue.ts +30 -17
  10. package/src/main/typescript/impl/util/AsyncRunnable.ts +5 -3
  11. package/src/main/typescript/impl/util/ExtDomQuery.ts +8 -8
  12. package/src/main/typescript/impl/xhrCore/EventData.ts +2 -2
  13. package/src/main/typescript/impl/xhrCore/RequestDataResolver.ts +3 -3
  14. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +3 -3
  15. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +31 -11
  16. package/src/main/typescript/impl/xhrCore/XhrFormData.ts +86 -90
  17. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +34 -28
  18. package/target/impl/AjaxImpl.js +80 -39
  19. package/target/impl/AjaxImpl.js.map +1 -1
  20. package/target/impl/util/AsyncQueue.js +28 -15
  21. package/target/impl/util/AsyncQueue.js.map +1 -1
  22. package/target/impl/util/ExtDomQuery.js +7 -7
  23. package/target/impl/util/ExtDomQuery.js.map +1 -1
  24. package/target/impl/xhrCore/EventData.js +2 -2
  25. package/target/impl/xhrCore/EventData.js.map +1 -1
  26. package/target/impl/xhrCore/RequestDataResolver.js +3 -3
  27. package/target/impl/xhrCore/RequestDataResolver.js.map +1 -1
  28. package/target/impl/xhrCore/ResonseDataResolver.js +3 -3
  29. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  30. package/target/impl/xhrCore/ResponseProcessor.js +31 -9
  31. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  32. package/target/impl/xhrCore/XhrFormData.js +86 -88
  33. package/target/impl/xhrCore/XhrFormData.js.map +1 -1
  34. package/target/impl/xhrCore/XhrRequest.js +32 -27
  35. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
@@ -1575,6 +1575,8 @@ var DomQuery = /** @class */ (function () {
1575
1575
  if (files === null || files === void 0 ? void 0 : files.length) {
1576
1576
  //xhr level2
1577
1577
  target.append(name).value = files[0];
1578
+ //TODO we have to know that the entry is a file element, so that we can reuse
1579
+ //this information
1578
1580
  }
1579
1581
  else {
1580
1582
  target.append(name).value = element.inputValue.value;
@@ -4102,6 +4104,54 @@ var BlockFilter;
4102
4104
  */
4103
4105
  var Implementation;
4104
4106
  (function (Implementation) {
4107
+ /*
4108
+ Small internal explanation, this code is optimized for readability
4109
+ and cuts off a ton of old legacy code.
4110
+ Aka older browsers are not supported anymore.
4111
+ We use a self written helper library to keep the number of exernal
4112
+ code dependencies down.
4113
+ The library is called mona-dish and started as a small sideproject of mine
4114
+ it provides following
4115
+
4116
+ a) Monad like structures for querying because this keeps the code denser and adds abstractions
4117
+ that always was the strong point of jquery and it still is better in this regard than what ecmascript provides
4118
+
4119
+ b) Streams and lazystreams like java has, a pull like construct, ecmascript does not have anything like Lazystreams.
4120
+ Another option would have been rxjs but that would have introduced a code dependency and probably more code. We might
4121
+ move to RXJS if the need arises however. But for now I would rather stick with my small self grown library which works
4122
+ quite well and where I can patch quickly (I have used it in several industrial projects, so it works well
4123
+ and is heavily fortified by unit tests (140 testcases as time of writing this))
4124
+
4125
+ c) A neutral json like configuration which allows assignments of arbitrary values with reduce code which then can be
4126
+ transformed into different data representations
4127
+
4128
+ examples:
4129
+ internalCtx.assign(MYPARAM, CTX_PARAM_SRC_FRM_ID).value = form.id.value;
4130
+ passes a value into context.MYPARAM.CTX_PARAM_SRC_FRM_ID
4131
+
4132
+ basically an abbreviation for
4133
+
4134
+ internalCtxt[MYPARAM] = internalCtxt?.[MYPARAM] ? internalCtxt[MYPARAM] : {};
4135
+ internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] = internalCtxt?.[MYPARAM][CTX_PARAM_SRC_FRM_ID] ? internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] : {};
4136
+ internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] = form.id.value;
4137
+
4138
+
4139
+ internalCtx.assign(condition, MYPARAM, CTX_PARAM_SRC_FRM_ID).value = form.id.value;
4140
+ passes a value into context.MYPARAM.CTX_PARAM_SRC_FRM_ID if condition === true otherwise it is ignored
4141
+
4142
+ abbreviates:
4143
+ if(condition) {
4144
+ internalCtxt[MYPARAM] = internalCtxt?.[MYPARAM] ? internalCtxt[MYPARAM] : {};
4145
+ internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] = internalCtxt?.[MYPARAM][CTX_PARAM_SRC_FRM_ID] ? internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] : {};
4146
+ internalCtxt[MYPARAM][CTX_PARAM_SRC_FRM_ID] = form.id.value;
4147
+ }
4148
+
4149
+
4150
+ d) Optional constructs, while under heavy debate we only use them lightly where the api requires it from mona-dish
4151
+
4152
+ Note the inclusion of this library uses a reduced build which only includes the part of it, which we really use
4153
+
4154
+ */
4105
4155
  var trim = mona_dish_1.Lang.trim;
4106
4156
  var getMessage = Lang_1.ExtLang.getMessage;
4107
4157
  var getGlobalConfig = Lang_1.ExtLang.getGlobalConfig;
@@ -4171,8 +4221,9 @@ var Implementation;
4171
4221
  funcs[_i - 2] = arguments[_i];
4172
4222
  }
4173
4223
  return mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, funcs).map(function (func) { return resolveAndExecute(source, event, func); })
4174
- // we use the return false == stop as an early stop
4224
+ // we use the return false == stop as an early stop, onElem stops at the first false
4175
4225
  .onElem(function (opResult) { return opResult; })
4226
+ //last ensures we run until the first false is returned
4176
4227
  .last().value;
4177
4228
  }
4178
4229
  Implementation.chain = chain;
@@ -4198,14 +4249,25 @@ var Implementation;
4198
4249
  var _a, _b, _c;
4199
4250
  var _d = (0, RequestDataResolver_1.resolveDefaults)(event, opts, el), resolvedEvent = _d.resolvedEvent, options = _d.options, elem = _d.elem, elementId = _d.elementId, requestCtx = _d.requestCtx, internalCtx = _d.internalCtx, windowId = _d.windowId, isResetValues = _d.isResetValues;
4200
4251
  Assertions_1.Assertions.assertRequestIntegrity(options, elem);
4252
+ /**
4253
+ * fetch the parent form
4254
+ *
4255
+ * note we also add an override possibility here
4256
+ * so that people can use dummy forms and work
4257
+ * with detached objects
4258
+ */
4259
+ var form = (0, RequestDataResolver_1.resolveForm)(requestCtx, elem, resolvedEvent);
4260
+ var formId = form.id.value;
4261
+ var delay = (0, RequestDataResolver_1.resolveDelay)(options);
4262
+ var timeout = (0, RequestDataResolver_1.resolveTimeout)(options);
4201
4263
  requestCtx.assignIf(!!windowId, Const_1.P_WINDOW_ID).value = windowId;
4202
4264
  requestCtx.assign(Const_1.CTX_PARAM_PASS_THR).value = filterPassthroughValues(options.value);
4203
4265
  requestCtx.assignIf(!!resolvedEvent, Const_1.CTX_PARAM_PASS_THR, Const_1.P_EVT).value = resolvedEvent === null || resolvedEvent === void 0 ? void 0 : resolvedEvent.type;
4204
4266
  /**
4205
4267
  * ajax pass through context with the source
4206
- * onresolvedEvent and onerror
4268
+ * onresolved Event and onerror Event
4207
4269
  */
4208
- requestCtx.assign(Const_1.SOURCE).value = elementId.value;
4270
+ requestCtx.assign(Const_1.SOURCE).value = elementId;
4209
4271
  /**
4210
4272
  * on resolvedEvent and onError...
4211
4273
  * those values will be traversed later on
@@ -4217,26 +4279,14 @@ var Implementation;
4217
4279
  * lets drag the myfaces config params also in
4218
4280
  */
4219
4281
  requestCtx.assign(Const_1.MYFACES).value = (_c = options.value) === null || _c === void 0 ? void 0 : _c.myfaces;
4220
- /**
4221
- * fetch the parent form
4222
- *
4223
- * note we also add an override possibility here
4224
- * so that people can use dummy forms and work
4225
- * with detached objects
4226
- */
4227
- var form = (0, RequestDataResolver_1.resolveForm)(requestCtx, elem, resolvedEvent);
4228
4282
  /**
4229
4283
  * binding contract the javax.faces.source must be set
4230
4284
  */
4231
- requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value = elementId.value;
4285
+ requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value = elementId;
4232
4286
  /**
4233
4287
  * javax.faces.partial.ajax must be set to true
4234
4288
  */
4235
4289
  requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_AJAX).value = true;
4236
- /**
4237
- * binding contract the javax.faces.source must be set
4238
- */
4239
- requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value = elementId.value;
4240
4290
  /**
4241
4291
  * if resetValues is set to true
4242
4292
  * then we have to set javax.faces.resetValues as well
@@ -4245,22 +4295,20 @@ var Implementation;
4245
4295
  * the specs jsdoc
4246
4296
  */
4247
4297
  requestCtx.assignIf(isResetValues, Const_1.CTX_PARAM_PASS_THR, Const_1.P_RESET_VALUES).value = true;
4248
- //additional meta information to speed things up, note internal non jsf
4249
- //pass through options are stored under _mfInternal in the context
4250
- internalCtx.assign(Const_1.CTX_PARAM_SRC_FRM_ID).value = form.id.value;
4251
- internalCtx.assign(Const_1.CTX_PARAM_SRC_CTL_ID).value = elementId.value;
4298
+ // additional meta information to speed things up, note internal non jsf
4299
+ // pass through options are stored under _mfInternal in the context
4300
+ internalCtx.assign(Const_1.CTX_PARAM_SRC_FRM_ID).value = formId;
4301
+ // mojarra compatibility, mojarra is sending the form id as well
4302
+ // this is not documented behavior but can be determined by running
4303
+ // mojarra under blackbox conditions.
4304
+ // I assume it does the same as our formId_submit=1 so leaving it out
4305
+ // won't hurt but for the sake of compatibility we are going to add it
4306
+ requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, formId).value = formId;
4307
+ internalCtx.assign(Const_1.CTX_PARAM_SRC_CTL_ID).value = elementId;
4252
4308
  internalCtx.assign(Const_1.CTX_PARAM_TR_TYPE).value = Const_1.REQ_TYPE_POST;
4253
- //mojarra compatibility, mojarra is sending the form id as well
4254
- //this is not documented behavior but can be determined by running
4255
- //mojarra under blackbox conditions
4256
- //i assume it does the same as our formId_submit=1 so leaving it out
4257
- //wont hurt but for the sake of compatibility we are going to add it
4258
- requestCtx.assign(Const_1.CTX_PARAM_PASS_THR, form.id.value).value = form.id.value;
4259
4309
  assignClientWindowId(form, requestCtx);
4260
- assignExecute(options, requestCtx, form, elementId.value);
4261
- assignRender(options, requestCtx, form, elementId.value);
4262
- var delay = (0, RequestDataResolver_1.resolveDelay)(options);
4263
- var timeout = (0, RequestDataResolver_1.resolveTimeout)(options);
4310
+ assignExecute(options, requestCtx, form, elementId);
4311
+ assignRender(options, requestCtx, form, elementId);
4264
4312
  //now we enqueue the request as asynchronous runnable into our request
4265
4313
  //queue and let the queue take over the rest
4266
4314
  Implementation.queueHandler.addRequestToQueue(elem, form, requestCtx, internalCtx, delay, timeout);
@@ -4282,7 +4330,6 @@ var Implementation;
4282
4330
  * @param errorListener the error listener handler
4283
4331
  */
4284
4332
  function addOnError(errorListener) {
4285
- /*error handling already done in the assert of the queue*/
4286
4333
  errorQueue.push(errorListener);
4287
4334
  }
4288
4335
  Implementation.addOnError = addOnError;
@@ -4292,7 +4339,6 @@ var Implementation;
4292
4339
  * @param eventListener the event listener handler
4293
4340
  */
4294
4341
  function addOnEvent(eventListener) {
4295
- /*error handling already done in the assert of the queue*/
4296
4342
  eventQueue.push(eventListener);
4297
4343
  }
4298
4344
  Implementation.addOnEvent = addOnEvent;
@@ -4445,7 +4491,7 @@ var Implementation;
4445
4491
  Implementation.getViewState = getViewState;
4446
4492
  /**
4447
4493
  * this at the first sight looks like a weird construct, but we need to do it this way
4448
- * for testing, we cannot proxy addRequestToQueue from the testing frameworks directly
4494
+ * for testing, we cannot proxy addRequestToQueue from the testing frameworks directly,
4449
4495
  * but we need to keep it under unit tests.
4450
4496
  */
4451
4497
  Implementation.queueHandler = {
@@ -4536,11 +4582,8 @@ var Implementation;
4536
4582
  var iterValues = (userValues) ? trim(userValues).split(/\s+/gi) : [];
4537
4583
  var ret = [];
4538
4584
  var processed = {};
4539
- //the idea is simply to loop over all values and then replace
4540
- //their generic values and filter out doubles
4541
- //this is more readable than the old indexed based solution
4542
- //and not really slower because we had to build up the index in our old solution
4543
- //anyway
4585
+ // in this case we do not use lazy stream because it wont bring any code reduction
4586
+ // or speedup
4544
4587
  for (var cnt = 0; cnt < iterValues.length; cnt++) {
4545
4588
  //avoid doubles
4546
4589
  if (iterValues[cnt] in processed) {
@@ -4608,7 +4651,7 @@ var Implementation;
4608
4651
  }
4609
4652
  else {
4610
4653
  //either a function or a string can be passed in case of a string we have to wrap it into another function
4611
- //it it is not a plain executable code but a definition
4654
+ //it is not a plain executable code but a definition
4612
4655
  var sourceCode = trim(func);
4613
4656
  if (sourceCode.indexOf("function ") == 0) {
4614
4657
  sourceCode = "return ".concat(sourceCode, " (event)");
@@ -5278,7 +5321,7 @@ exports.AsynchronousQueue = void 0;
5278
5321
  *
5279
5322
  * Every callback must be of async runnable
5280
5323
  * which is sort of an extended promise which has
5281
- * added a decicated cancel and start point
5324
+ * added a dedicated cancel and start point
5282
5325
  *
5283
5326
  * This interface can be used as wrapper contract
5284
5327
  * for normal promises if needed.
@@ -5288,6 +5331,9 @@ var AsynchronousQueue = /** @class */ (function () {
5288
5331
  this.runnableQueue = [];
5289
5332
  }
5290
5333
  Object.defineProperty(AsynchronousQueue.prototype, "isEmpty", {
5334
+ /**
5335
+ * simple is empty accessor, returns true if queue is empty atm
5336
+ */
5291
5337
  get: function () {
5292
5338
  return !this.runnableQueue.length;
5293
5339
  },
@@ -5295,7 +5341,7 @@ var AsynchronousQueue = /** @class */ (function () {
5295
5341
  configurable: true
5296
5342
  });
5297
5343
  /**
5298
- * enequeues an element and starts the
5344
+ * enqueues an element and starts the
5299
5345
  * asynchronous work loop if not already running
5300
5346
  *
5301
5347
  * @param element the element to be queued and processed
@@ -5317,13 +5363,36 @@ var AsynchronousQueue = /** @class */ (function () {
5317
5363
  this.appendElement(element);
5318
5364
  }
5319
5365
  };
5366
+ /**
5367
+ * fetches the next element from the queue (first in first out order)
5368
+ */
5320
5369
  AsynchronousQueue.prototype.dequeue = function () {
5321
5370
  return this.runnableQueue.shift();
5322
5371
  };
5372
+ /**
5373
+ * clears up all elements from the queue
5374
+ */
5323
5375
  AsynchronousQueue.prototype.cleanup = function () {
5324
5376
  this.currentlyRunning = null;
5325
5377
  this.runnableQueue.length = 0;
5326
5378
  };
5379
+ /**
5380
+ * cancels the currently running element and then cleans up the queue
5381
+ * aka cancel the queue entirely
5382
+ */
5383
+ AsynchronousQueue.prototype.cancel = function () {
5384
+ try {
5385
+ if (this.currentlyRunning) {
5386
+ this.currentlyRunning.cancel();
5387
+ }
5388
+ }
5389
+ finally {
5390
+ this.cleanup();
5391
+ }
5392
+ };
5393
+ AsynchronousQueue.prototype.callForNextElementToProcess = function () {
5394
+ this.runEntry();
5395
+ };
5327
5396
  AsynchronousQueue.prototype.appendElement = function (element) {
5328
5397
  //only if the first element is added we start with a trigger
5329
5398
  //otherwise a process already is running and not finished yet at that
@@ -5356,19 +5425,6 @@ var AsynchronousQueue = /** @class */ (function () {
5356
5425
  //(the browser engine will take care of that)
5357
5426
  function () { return _this.callForNextElementToProcess(); }).start();
5358
5427
  };
5359
- AsynchronousQueue.prototype.cancel = function () {
5360
- try {
5361
- if (this.currentlyRunning) {
5362
- this.currentlyRunning.cancel();
5363
- }
5364
- }
5365
- finally {
5366
- this.cleanup();
5367
- }
5368
- };
5369
- AsynchronousQueue.prototype.callForNextElementToProcess = function () {
5370
- this.runEntry();
5371
- };
5372
5428
  return AsynchronousQueue;
5373
5429
  }());
5374
5430
  exports.AsynchronousQueue = AsynchronousQueue;
@@ -5411,9 +5467,9 @@ var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/im
5411
5467
  */
5412
5468
  var IS_JSF_SOURCE = function (source) {
5413
5469
  return source && !!((source === null || source === void 0 ? void 0 : source.search(/\/javax\.faces\.resource.*\/jsf\.js.*/)) != -1 ||
5414
- (source === null || source === void 0 ? void 0 : source.search(/\/jsf\-development\.js.*/)) != -1 ||
5415
- (source === null || source === void 0 ? void 0 : source.search(/\/jsf\-uncompressed\.js.*/)) != -1 ||
5416
- (source === null || source === void 0 ? void 0 : source.search(/\/jsf[^\.]\.js.*ln\=javax.faces.*/gi)) != -1);
5470
+ (source === null || source === void 0 ? void 0 : source.search(/\/jsf-development\.js.*/)) != -1 ||
5471
+ (source === null || source === void 0 ? void 0 : source.search(/\/jsf-uncompressed\.js.*/)) != -1 ||
5472
+ (source === null || source === void 0 ? void 0 : source.search(/\/jsf[^.]*\.js.*ln=javax.faces.*/gi)) != -1);
5417
5473
  };
5418
5474
  /**
5419
5475
  * namespace myfaces.testscripts can be used as extension point for internal
@@ -5424,7 +5480,7 @@ var IS_JSF_SOURCE = function (source) {
5424
5480
  * @constructor
5425
5481
  */
5426
5482
  var IS_INTERNAL_SOURCE = function (source) {
5427
- return source.search(/\/jsf[^\.]\.js.*ln\=myfaces.testscripts.*/gi) != -1;
5483
+ return source.search(/\/jsf[^.]*\.js.*ln=myfaces.testscripts.*/gi) != -1;
5428
5484
  };
5429
5485
  var ATTR_SRC = 'src';
5430
5486
  /**
@@ -5535,7 +5591,7 @@ var ExtDomquery = /** @class */ (function (_super) {
5535
5591
  }).first();
5536
5592
  };
5537
5593
  ExtDomquery.prototype.globalEval = function (code, nonce) {
5538
- return _super.prototype.globalEval.call(this, code, nonce !== null && nonce !== void 0 ? nonce : this.nonce);
5594
+ return new ExtDomquery(_super.prototype.globalEval.call(this, code, nonce !== null && nonce !== void 0 ? nonce : this.nonce));
5539
5595
  };
5540
5596
  /**
5541
5597
  * decorated run scripts which takes our jsf extensions into consideration
@@ -5553,13 +5609,13 @@ var ExtDomquery = /** @class */ (function (_super) {
5553
5609
  * byId producer
5554
5610
  *
5555
5611
  * @param selector id
5612
+ * @param deep whether the search should go into embedded shadow dom elements
5556
5613
  * @return a DomQuery containing the found elements
5557
5614
  */
5558
5615
  ExtDomquery.byId = function (selector, deep) {
5559
5616
  if (deep === void 0) { deep = false; }
5560
5617
  var ret = mona_dish_1.DomQuery.byId(selector, deep);
5561
- //return new ExtDomquery(ret);
5562
- return ret;
5618
+ return new ExtDomquery(ret);
5563
5619
  };
5564
5620
  return ExtDomquery;
5565
5621
  }(mona_dish_1.DQ));
@@ -5913,8 +5969,8 @@ var EventData = /** @class */ (function () {
5913
5969
  eventData.type = Const_1.EVENT;
5914
5970
  eventData.status = name;
5915
5971
  var sourceId = context.getIf(Const_1.SOURCE)
5916
- .orElse(context.getIf(Const_1.P_PARTIAL_SOURCE).value)
5917
- .orElse(context.getIf(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value).value;
5972
+ .orElseLazy(function () { return context.getIf(Const_1.P_PARTIAL_SOURCE).value; })
5973
+ .orElseLazy(function () { return context.getIf(Const_1.CTX_PARAM_PASS_THR, Const_1.P_PARTIAL_SOURCE).value; }).value;
5918
5974
  if (sourceId) {
5919
5975
  eventData.source = mona_dish_1.DQ.byId(sourceId, true).first().value.value;
5920
5976
  }
@@ -5976,7 +6032,7 @@ var ExtDomQuery_1 = __webpack_require__(/*! ../util/ExtDomQuery */ "./src/main/t
5976
6032
  */
5977
6033
  function resolveHandlerFunc(requestContext, responseContext, funcName) {
5978
6034
  return responseContext.getIf(funcName)
5979
- .orElse(requestContext.getIf(funcName).value)
6035
+ .orElseLazy(function () { return requestContext.getIf(funcName).value; })
5980
6036
  .orElse(Const_1.EMPTY_FUNC).value;
5981
6037
  }
5982
6038
  exports.resolveHandlerFunc = resolveHandlerFunc;
@@ -6003,7 +6059,7 @@ exports.resolveFinalUrl = resolveFinalUrl;
6003
6059
  */
6004
6060
  function resolveForm(requestCtx, elem, event) {
6005
6061
  var _a, _b, _c;
6006
- var configId = (_c = (_b = (_a = requestCtx.value) === null || _a === void 0 ? void 0 : _a.myfaces) === null || _b === void 0 ? void 0 : _b.form) !== null && _c !== void 0 ? _c : Const_1.MF_NONE; //requestCtx.getIf(MYFACES, "form").orElse(MF_NONE).value;
6062
+ var configId = (_c = (_b = (_a = requestCtx.value) === null || _a === void 0 ? void 0 : _a.myfaces) === null || _b === void 0 ? void 0 : _b.form) !== null && _c !== void 0 ? _c : Const_1.MF_NONE;
6007
6063
  return mona_dish_1.DQ
6008
6064
  .byId(configId, true)
6009
6065
  .orElseLazy(function () { return Lang_1.ExtLang.getForm(elem.getAsElem(0).value, event); });
@@ -6076,7 +6132,7 @@ function resolveDefaults(event, opts, el) {
6076
6132
  if (opts === void 0) { opts = {}; }
6077
6133
  if (el === void 0) { el = null; }
6078
6134
  //deep copy the options, so that further transformations to not backfire into the callers
6079
- var resolvedEvent = event, options = new mona_dish_1.Config(opts).deepCopy, elem = mona_dish_1.DQ.byId(el || resolvedEvent.target, true), elementId = elem.id, requestCtx = new mona_dish_1.Config({}), internalCtx = new mona_dish_1.Config({}), windowId = resolveWindowId(options), isResetValues = true === ((_a = options.value) === null || _a === void 0 ? void 0 : _a.resetValues);
6135
+ var resolvedEvent = event, options = new mona_dish_1.Config(opts).deepCopy, elem = mona_dish_1.DQ.byId(el || resolvedEvent.target, true), elementId = elem.id.value, requestCtx = new mona_dish_1.Config({}), internalCtx = new mona_dish_1.Config({}), windowId = resolveWindowId(options), isResetValues = true === ((_a = options.value) === null || _a === void 0 ? void 0 : _a.resetValues);
6080
6136
  return { resolvedEvent: resolvedEvent, options: options, elem: elem, elementId: elementId, requestCtx: requestCtx, internalCtx: internalCtx, windowId: windowId, isResetValues: isResetValues };
6081
6137
  }
6082
6138
  exports.resolveDefaults = resolveDefaults;
@@ -6181,9 +6237,9 @@ exports.resolveSourceElement = resolveSourceElement;
6181
6237
  function resolveSourceForm(internalContext, elem) {
6182
6238
  var sourceFormId = internalContext.getIf(Const_1.CTX_PARAM_SRC_FRM_ID);
6183
6239
  var sourceForm = new mona_dish_2.DQ(sourceFormId.isPresent() ? document.forms[sourceFormId.value] : null);
6184
- sourceForm = sourceForm.orElse(elem.parents(Const_1.TAG_FORM))
6185
- .orElse(elem.querySelectorAll(Const_1.TAG_FORM))
6186
- .orElse(mona_dish_2.DQ.querySelectorAll(Const_1.TAG_FORM));
6240
+ sourceForm = sourceForm.orElseLazy(function () { return elem.parents(Const_1.TAG_FORM); })
6241
+ .orElseLazy(function () { return elem.querySelectorAll(Const_1.TAG_FORM); })
6242
+ .orElseLazy(function () { return mona_dish_2.DQ.querySelectorAll(Const_1.TAG_FORM); });
6187
6243
  return sourceForm;
6188
6244
  }
6189
6245
  exports.resolveSourceForm = resolveSourceForm;
@@ -6433,6 +6489,11 @@ var ResponseProcessor = /** @class */ (function () {
6433
6489
  this.externalContext = externalContext;
6434
6490
  this.internalContext = internalContext;
6435
6491
  }
6492
+ /**
6493
+ * head replacement
6494
+ * @param shadowDocument incoming shadow head data (aka cdata as xml reference or dom element)
6495
+ * the data incoming must represent the html representation of the head itself one way or the other
6496
+ */
6436
6497
  ResponseProcessor.prototype.replaceHead = function (shadowDocument) {
6437
6498
  var shadowHead = shadowDocument.querySelectorAll(Const_1.TAG_HEAD);
6438
6499
  if (!shadowHead.isPresent()) {
@@ -6441,6 +6502,9 @@ var ResponseProcessor = /** @class */ (function () {
6441
6502
  var oldHead = mona_dish_1.DQ.querySelectorAll(Const_1.TAG_HEAD);
6442
6503
  //delete all to avoid script and style overlays
6443
6504
  oldHead.querySelectorAll(Const_1.SEL_SCRIPTS_STYLES).delete();
6505
+ // we cannot replace new elements in the head, but we can eval the elements
6506
+ // eval means the scripts will get attached (eval script attach method)
6507
+ // but this is done by DomQuery not in this code
6444
6508
  this.storeForEval(shadowHead);
6445
6509
  };
6446
6510
  /**
@@ -6459,6 +6523,8 @@ var ResponseProcessor = /** @class */ (function () {
6459
6523
  var shadowInnerHTML = shadowBody.html().value;
6460
6524
  var resultingBody = mona_dish_1.DQ.querySelectorAll(Const_1.TAG_BODY).html(shadowInnerHTML);
6461
6525
  var updateForms = resultingBody.querySelectorAll(Const_1.TAG_FORM);
6526
+ // main difference, we cannot replace the body itself, but only its content
6527
+ // we need a separate step for post processing the incoming attributes, like classes, styles etc...
6462
6528
  resultingBody.copyAttrs(shadowBody);
6463
6529
  this.storeForPostProcessing(updateForms, resultingBody);
6464
6530
  };
@@ -6498,9 +6564,6 @@ var ResponseProcessor = /** @class */ (function () {
6498
6564
  this.triggerOnError(errorData);
6499
6565
  AjaxImpl_1.Implementation.sendError(errorData);
6500
6566
  };
6501
- ResponseProcessor.prototype.triggerOnError = function (errorData) {
6502
- this.externalContext.getIf(Const_1.ON_ERROR).orElse(this.internalContext.getIf(Const_1.ON_ERROR).value).orElse(Const_1.EMPTY_FUNC).value(errorData);
6503
- };
6504
6567
  /**
6505
6568
  * process the redirect operation
6506
6569
  *
@@ -6520,11 +6583,15 @@ var ResponseProcessor = /** @class */ (function () {
6520
6583
  */
6521
6584
  ResponseProcessor.prototype.update = function (node, cdataBlock) {
6522
6585
  var result = ExtDomQuery_1.ExtDomquery.byId(node.id.value, true).outerHTML(cdataBlock, false, false);
6523
- var sourceForm = result === null || result === void 0 ? void 0 : result.parents(Const_1.TAG_FORM).orElse(result.byTagName(Const_1.TAG_FORM, true));
6586
+ var sourceForm = result === null || result === void 0 ? void 0 : result.parents(Const_1.TAG_FORM).orElseLazy(function () { return result.byTagName(Const_1.TAG_FORM, true); });
6524
6587
  if (sourceForm) {
6525
6588
  this.storeForPostProcessing(sourceForm, result);
6526
6589
  }
6527
6590
  };
6591
+ /**
6592
+ * Delete handler, simply deleetes the node referenced by the xml data
6593
+ * @param node
6594
+ */
6528
6595
  ResponseProcessor.prototype.delete = function (node) {
6529
6596
  mona_dish_1.DQ.byId(node.id.value, true).delete();
6530
6597
  };
@@ -6547,7 +6614,7 @@ var ResponseProcessor = /** @class */ (function () {
6547
6614
  this.replaceBody(shadowDocument);
6548
6615
  };
6549
6616
  /**
6550
- * insert handling, either before or after
6617
+ * Insert handling, either before or after
6551
6618
  *
6552
6619
  * @param node
6553
6620
  */
@@ -6567,7 +6634,7 @@ var ResponseProcessor = /** @class */ (function () {
6567
6634
  }
6568
6635
  };
6569
6636
  /**
6570
- * handler for the case &lt;insert <&lt; before id="...
6637
+ * Handler for the case &lt;insert <&lt; before id="...
6571
6638
  *
6572
6639
  * @param node the node hosting the insert data
6573
6640
  */
@@ -6593,7 +6660,7 @@ var ResponseProcessor = /** @class */ (function () {
6593
6660
  });
6594
6661
  };
6595
6662
  /**
6596
- * process the viewState update, update the affected
6663
+ * Process the viewState update, update the affected
6597
6664
  * forms with their respective new viewstate values
6598
6665
  *
6599
6666
  */
@@ -6621,7 +6688,10 @@ var ResponseProcessor = /** @class */ (function () {
6621
6688
  updateElems.runScripts();
6622
6689
  };
6623
6690
  /**
6624
- * post processing viewstate fixing
6691
+ * Postprocessing view state fixing
6692
+ * this appends basically the incoming view states to the forms.
6693
+ * It is called from outside after all forms have been processed basically
6694
+ * as last lifecycle step, before going into the next request.
6625
6695
  */
6626
6696
  ResponseProcessor.prototype.fixViewStates = function () {
6627
6697
  var _this = this;
@@ -6634,6 +6704,10 @@ var ResponseProcessor = /** @class */ (function () {
6634
6704
  _this.appendViewStateToForms(new mona_dish_1.DomQuery(affectedForms, affectedForms2), value.value);
6635
6705
  });
6636
6706
  };
6707
+ /**
6708
+ * same as with view states before applies the incoming client windows as last step after the rest of the processing
6709
+ * is done.
6710
+ */
6637
6711
  ResponseProcessor.prototype.fixClientWindow = function () {
6638
6712
  var _this = this;
6639
6713
  mona_dish_1.Stream.ofAssoc(this.internalContext.getIf(Const_1.APPLIED_CLIENT_WINDOW).orElse({}).value)
@@ -6649,9 +6723,10 @@ var ResponseProcessor = /** @class */ (function () {
6649
6723
  * all processing done we can close the request and send the appropriate events
6650
6724
  */
6651
6725
  ResponseProcessor.prototype.done = function () {
6726
+ var _this = this;
6652
6727
  var eventData = EventData_1.EventData.createFromRequest(this.request.value, this.externalContext, Const_1.SUCCESS);
6653
6728
  //because some frameworks might decorate them over the context in the response
6654
- var eventHandler = this.externalContext.getIf(Const_1.ON_EVENT).orElse(this.internalContext.getIf(Const_1.ON_EVENT).value).orElse(Const_1.EMPTY_FUNC).value;
6729
+ var eventHandler = this.externalContext.getIf(Const_1.ON_EVENT).orElseLazy(function () { return _this.internalContext.getIf(Const_1.ON_EVENT).value; }).orElse(Const_1.EMPTY_FUNC).value;
6655
6730
  AjaxImpl_1.Implementation.sendEvent(eventData, eventHandler);
6656
6731
  };
6657
6732
  /**
@@ -6751,6 +6826,9 @@ var ResponseProcessor = /** @class */ (function () {
6751
6826
  ((_d = (_c = node === null || node === void 0 ? void 0 : node.id) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.indexOf([separatorChar, Const_1.P_CLIENT_WINDOW].join(Const_1.EMPTY_STR))) != -1 ||
6752
6827
  ((_f = (_e = node === null || node === void 0 ? void 0 : node.id) === null || _e === void 0 ? void 0 : _e.value) === null || _f === void 0 ? void 0 : _f.indexOf([Const_1.P_CLIENT_WINDOW, separatorChar].join(Const_1.EMPTY_STR))) != -1);
6753
6828
  };
6829
+ ResponseProcessor.prototype.triggerOnError = function (errorData) {
6830
+ this.externalContext.getIf(Const_1.ON_ERROR).orElse(this.internalContext.getIf(Const_1.ON_ERROR).value).orElse(Const_1.EMPTY_FUNC).value(errorData);
6831
+ };
6754
6832
  return ResponseProcessor;
6755
6833
  }());
6756
6834
  exports.ResponseProcessor = ResponseProcessor;
@@ -6807,9 +6885,8 @@ exports.XhrFormData = void 0;
6807
6885
  * limitations under the License.
6808
6886
  */
6809
6887
  var mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
6810
- var mona_dish_2 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
6811
- var isString = mona_dish_1.Lang.isString;
6812
6888
  var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
6889
+ var isString = mona_dish_1.Lang.isString;
6813
6890
  /**
6814
6891
  * A unified form data class
6815
6892
  * which builds upon our configuration.
@@ -6818,10 +6895,9 @@ var Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/im
6818
6895
  * due to api constraints on the HTML Form object in IE11
6819
6896
  * and due to the url encoding constraint given by the jsf.js spec
6820
6897
  *
6821
- * TODO not ideal. too many encoding calls
6822
6898
  * probably only one needed and one overlay!
6823
- * the entire fileinput storing probably is redundant now
6824
- * that domquery has been fixed
6899
+ * the entire file input storing probably is redundant now
6900
+ * that dom query has been fixed //TODO check this
6825
6901
  */
6826
6902
  var XhrFormData = /** @class */ (function (_super) {
6827
6903
  __extends(XhrFormData, _super);
@@ -6829,101 +6905,93 @@ var XhrFormData = /** @class */ (function (_super) {
6829
6905
  * data collector from a given form
6830
6906
  *
6831
6907
  * @param dataSource either a form as DomQuery object or an encoded url string
6832
- * @param partialIdsArray partial ids to collect, to reduce the data sent down
6908
+ * @param viewState the form view state or an external viewstate coming in as string
6909
+ * @param executes the executes id list for the elements to being processed
6910
+ * @param partialIds partial ids to collect, to reduce the data sent down
6833
6911
  */
6834
- function XhrFormData(dataSource, partialIdsArray) {
6912
+ function XhrFormData(dataSource, viewState, executes, partialIds) {
6835
6913
  var _this = _super.call(this, {}) || this;
6836
6914
  _this.dataSource = dataSource;
6837
- _this.partialIdsArray = partialIdsArray;
6838
- _this.fileInputs = {};
6915
+ _this.partialIds = partialIds;
6916
+ /**
6917
+ * Checks if the given datasource is a multipart request source
6918
+ * multipart is only needed if one of the executes is a file input
6919
+ * since file inputs are stateless, they fall out of the view state
6920
+ * and need special handling. With file submits we have to send a formData object
6921
+ * instead of an encoded string files cannot be sent that way
6922
+ */
6923
+ _this.isMultipartRequest = false;
6839
6924
  //a call to getViewState before must pass the encoded line
6840
- //a call from getViewState passes the form element as datasource
6925
+ //a call from getViewState passes the form element as datasource,
6841
6926
  //so we have two call points
6842
6927
  if (isString(dataSource)) {
6843
6928
  _this.assignEncodedString(_this.dataSource);
6844
6929
  }
6845
6930
  else {
6846
- _this.handleFormSource();
6931
+ _this.applyFormDataToConfig();
6932
+ }
6933
+ if ('undefined' != typeof viewState) {
6934
+ _this.assignEncodedString(viewState);
6935
+ }
6936
+ if (executes) {
6937
+ _this.postInit.apply(_this, executes);
6847
6938
  }
6848
6939
  return _this;
6849
6940
  }
6850
6941
  /**
6851
- * generic application of ids
6942
+ * generic post init code, for now, this peforms some post assign data post processing
6852
6943
  * @param executes
6853
6944
  */
6854
- XhrFormData.prototype.applyFileInputs = function () {
6945
+ XhrFormData.prototype.postInit = function () {
6855
6946
  var _this = this;
6856
6947
  var executes = [];
6857
6948
  for (var _i = 0; _i < arguments.length; _i++) {
6858
6949
  executes[_i] = arguments[_i];
6859
6950
  }
6860
6951
  var fetchInput = function (id) {
6861
- if (id == "@all") {
6862
- return mona_dish_2.DQ.querySelectorAllDeep("input[type='file']");
6952
+ if (id == Const_1.IDENT_ALL) {
6953
+ return mona_dish_1.DQ.querySelectorAllDeep("input[type='file']");
6863
6954
  }
6864
- else if (id == "@form") {
6955
+ else if (id == Const_1.IDENT_FORM) {
6865
6956
  return _this.dataSource.querySelectorAllDeep("input[type='file']");
6866
6957
  }
6867
6958
  else {
6868
- var element = mona_dish_2.DQ.byId(id, true);
6959
+ var element = mona_dish_1.DQ.byId(id, true);
6869
6960
  return _this.getFileInputs(element);
6870
6961
  }
6871
6962
  };
6872
6963
  var inputExists = function (item) {
6873
6964
  return item.isPresent();
6874
6965
  };
6875
- var applyInput = function (item) {
6876
- _this.fileInputs[_this.resolveSubmitIdentifier(item.getAsElem(0).value)] = true;
6877
- };
6878
- mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, executes).map(fetchInput)
6966
+ this.isMultipartRequest = mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, executes).map(fetchInput)
6879
6967
  .filter(inputExists)
6880
- .each(applyInput);
6881
- };
6882
- XhrFormData.prototype.getFileInputs = function (rootElment) {
6883
- var rootFileInputs = rootElment
6884
- .filter(function (elem) { return elem.matchesSelector("input[type='file']"); });
6885
- var childFileInputs = rootElment
6886
- .querySelectorAll("input[type='file']");
6887
- var ret = rootFileInputs.concat(childFileInputs);
6888
- return ret;
6889
- };
6890
- XhrFormData.prototype.handleFormSource = function () {
6891
- //encode and append the issuing item if not a partial ids array of ids is passed
6892
- /*
6893
- * Spec. 13.3.1
6894
- * Collect and encode input elements.
6895
- * Additionally the hidden element javax.faces.ViewState
6896
- * Enhancement partial page submit
6897
- *
6898
- */
6899
- this.encodeSubmittableFields(this, this.dataSource, this.partialIdsArray);
6900
- if (this.getIf(Const_1.P_VIEWSTATE).isPresent()) {
6901
- return;
6902
- }
6903
- this.applyViewState(this.dataSource);
6968
+ .first().isPresent();
6904
6969
  };
6905
6970
  /**
6906
- * special case viewstate handling
6971
+ * special case view state handling
6907
6972
  *
6908
- * @param form the form holding the viewstate value
6973
+ * @param form the form holding the view state value
6909
6974
  */
6910
6975
  XhrFormData.prototype.applyViewState = function (form) {
6911
6976
  var viewState = form.byId(Const_1.P_VIEWSTATE, true).inputValue;
6912
6977
  this.appendIf(viewState.isPresent(), Const_1.P_VIEWSTATE).value = viewState.value;
6913
6978
  };
6914
6979
  /**
6915
- * assignes a url encoded string to this xhrFormData object
6980
+ * assigns an url encoded string to this xhrFormData object
6916
6981
  * as key value entry
6917
6982
  * @param encoded
6918
6983
  */
6919
6984
  XhrFormData.prototype.assignEncodedString = function (encoded) {
6920
- //TODO reevaluate this method
6921
- //this code filters out empty strings as key value pairs
6985
+ // this code filters out empty strings as key value pairs
6922
6986
  var keyValueEntries = decodeURIComponent(encoded).split(/&/gi)
6923
6987
  .filter(function (item) { return !!(item || '')
6924
6988
  .replace(/\s+/g, ''); });
6925
6989
  this.assignString(keyValueEntries);
6926
6990
  };
6991
+ /**
6992
+ * assign a set of key value pairs passed as array ['key=val1', 'key2=val2']
6993
+ * @param keyValueEntries
6994
+ */
6927
6995
  XhrFormData.prototype.assignString = function (keyValueEntries) {
6928
6996
  var toMerge = new mona_dish_1.Config({});
6929
6997
  function splitToKeyVal(line) {
@@ -6933,7 +7001,7 @@ var XhrFormData = /** @class */ (function (_super) {
6933
7001
  var _a, _b;
6934
7002
  return keyVal.length < 3 ? [(_a = keyVal === null || keyVal === void 0 ? void 0 : keyVal[0]) !== null && _a !== void 0 ? _a : [], (_b = keyVal === null || keyVal === void 0 ? void 0 : keyVal[1]) !== null && _b !== void 0 ? _b : []] : keyVal;
6935
7003
  }
6936
- mona_dish_2.Stream.of.apply(mona_dish_2.Stream, keyValueEntries).map(function (line) { return splitToKeyVal(line); })
7004
+ mona_dish_1.Stream.of.apply(mona_dish_1.Stream, keyValueEntries).map(function (line) { return splitToKeyVal(line); })
6937
7005
  //special case of having keys without values
6938
7006
  .map(function (keyVal) { return fixKeyWithoutVal(keyVal); })
6939
7007
  .each(function (keyVal) {
@@ -6943,28 +7011,12 @@ var XhrFormData = /** @class */ (function (_super) {
6943
7011
  //merge with overwrite but no append! (aka no double entries are allowed)
6944
7012
  this.shallowMerge(toMerge);
6945
7013
  };
6946
- // noinspection JSUnusedGlobalSymbols
6947
7014
  /**
6948
- * @returns a Form data representation
7015
+ * @returns a Form data representation, this is needed for file submits
6949
7016
  */
6950
7017
  XhrFormData.prototype.toFormData = function () {
6951
- var _this = this;
6952
7018
  var ret = new FormData();
6953
- mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, Object.keys(this.value)).filter(function (key) { return !(key in _this.fileInputs); })
6954
- .each(function (key) {
6955
- mona_dish_2.Stream.of.apply(mona_dish_2.Stream, _this.value[key]).each(function (item) { return ret.append(key, item); });
6956
- });
6957
- mona_dish_2.Stream.of.apply(mona_dish_2.Stream, Object.keys(this.fileInputs)).each(function (key) {
6958
- mona_dish_2.DQ.querySelectorAllDeep("[name='".concat(key, "'], [id=\"").concat(key, "\"]")).eachElem(function (elem) {
6959
- var _a;
6960
- var identifier = _this.resolveSubmitIdentifier(elem);
6961
- if (!((_a = elem === null || elem === void 0 ? void 0 : elem.files) === null || _a === void 0 ? void 0 : _a.length)) {
6962
- ret.append(identifier, elem.value);
6963
- return;
6964
- }
6965
- ret.append(identifier, elem.files[0]);
6966
- });
6967
- });
7019
+ this.appendInputs(ret);
6968
7020
  return ret;
6969
7021
  };
6970
7022
  XhrFormData.prototype.resolveSubmitIdentifier = function (elem) {
@@ -6985,13 +7037,44 @@ var XhrFormData = /** @class */ (function (_super) {
6985
7037
  return defaultStr;
6986
7038
  }
6987
7039
  var entries = mona_dish_1.LazyStream.of.apply(mona_dish_1.LazyStream, Object.keys(this.value)).filter(function (key) { return _this.value.hasOwnProperty(key); })
6988
- .flatMap(function (key) { return mona_dish_2.Stream.of.apply(mona_dish_2.Stream, _this.value[key]).map(function (val) { return [key, val]; }).collect(new mona_dish_1.ArrayCollector()); })
7040
+ .flatMap(function (key) { return mona_dish_1.Stream.of.apply(mona_dish_1.Stream, _this.value[key]).map(function (val) { return [key, val]; }).collect(new mona_dish_1.ArrayCollector()); })
6989
7041
  .map(function (keyVal) {
6990
7042
  return "".concat(encodeURIComponent(keyVal[0]), "=").concat(encodeURIComponent(keyVal[1]));
6991
7043
  })
6992
7044
  .collect(new mona_dish_1.ArrayCollector());
6993
7045
  return entries.join("&");
6994
7046
  };
7047
+ /**
7048
+ * helper to fetch all file inputs from as given root element
7049
+ * @param rootElement
7050
+ * @private
7051
+ */
7052
+ XhrFormData.prototype.getFileInputs = function (rootElement) {
7053
+ var rootFileInputs = rootElement
7054
+ .filter(function (elem) { return elem.matchesSelector("input[type='file']"); });
7055
+ var childFileInputs = rootElement
7056
+ .querySelectorAll("input[type='file']");
7057
+ return rootFileInputs.concat(childFileInputs);
7058
+ };
7059
+ /**
7060
+ * encode the given fields and apply the view state
7061
+ * @private
7062
+ */
7063
+ XhrFormData.prototype.applyFormDataToConfig = function () {
7064
+ //encode and append the issuing item if not a partial ids array of ids is passed
7065
+ /*
7066
+ * Spec. 13.3.1
7067
+ * Collect and encode input elements.
7068
+ * Additionally the hidden element javax.faces.ViewState
7069
+ * Enhancement partial page submit
7070
+ *
7071
+ */
7072
+ this.encodeSubmittableFields(this, this.dataSource, this.partialIds);
7073
+ if (this.getIf(Const_1.P_VIEWSTATE).isPresent()) {
7074
+ return;
7075
+ }
7076
+ this.applyViewState(this.dataSource);
7077
+ };
6995
7078
  /**
6996
7079
  * determines fields to submit
6997
7080
  * @param {Object} targetBuf - the target form buffer receiving the data
@@ -7000,33 +7083,26 @@ var XhrFormData = /** @class */ (function (_super) {
7000
7083
  */
7001
7084
  XhrFormData.prototype.encodeSubmittableFields = function (targetBuf, parentItem, partialIds) {
7002
7085
  var toEncode = null;
7003
- if (this.partialIdsArray && this.partialIdsArray.length) {
7004
- //in case of our myfaces reduced ppr we only
7005
- //only submit the partials
7086
+ if (this.partialIds && this.partialIds.length) {
7087
+ // in case of our myfaces reduced ppr we
7088
+ // only submit the partials
7006
7089
  this._value = {};
7007
- toEncode = new (mona_dish_2.DQ.bind.apply(mona_dish_2.DQ, __spreadArray([void 0], this.partialIdsArray, false)))();
7090
+ toEncode = new (mona_dish_1.DQ.bind.apply(mona_dish_1.DQ, __spreadArray([void 0], this.partialIds, false)))();
7008
7091
  }
7009
7092
  else {
7010
7093
  if (parentItem.isAbsent())
7011
- throw "NO_PARITEM";
7094
+ throw 'NO_PAR_ITEM';
7012
7095
  toEncode = parentItem;
7013
7096
  }
7014
7097
  //lets encode the form elements
7015
7098
  this.shallowMerge(toEncode.deepElements.encodeFormElement());
7016
7099
  };
7017
- Object.defineProperty(XhrFormData.prototype, "isMultipartRequest", {
7018
- /**
7019
- * checks if the given datasource is a multipart request source
7020
- * multipart is only needed if one of the executes is a file input
7021
- * since file inputs are stateless, they fall out of the viewstate
7022
- * and need special handling
7023
- */
7024
- get: function () {
7025
- return !!Object.keys(this.fileInputs).length;
7026
- },
7027
- enumerable: false,
7028
- configurable: true
7029
- });
7100
+ XhrFormData.prototype.appendInputs = function (ret) {
7101
+ var _this = this;
7102
+ mona_dish_1.Stream.of.apply(mona_dish_1.Stream, Object.keys(this.value)).each(function (key) {
7103
+ mona_dish_1.Stream.of.apply(mona_dish_1.Stream, _this.value[key]).each(function (item) { return ret.append(key, item); });
7104
+ });
7105
+ };
7030
7106
  return XhrFormData;
7031
7107
  }(mona_dish_1.Config));
7032
7108
  exports.XhrFormData = XhrFormData;
@@ -7077,6 +7153,7 @@ var XhrRequest = /** @class */ (function () {
7077
7153
  *
7078
7154
  * Optional Parameters
7079
7155
  *
7156
+ * @param internalContext internal context with internal info which is passed through, not used by the user
7080
7157
  * @param partialIdsArray an optional restricting partial ids array for encoding
7081
7158
  * @param timeout optional xhr timeout
7082
7159
  * @param ajaxType optional request type, default "POST"
@@ -7127,17 +7204,21 @@ var XhrRequest = /** @class */ (function () {
7127
7204
  var viewState = jsf.getViewState(formElement);
7128
7205
  //encoded we need to decode
7129
7206
  //We generated a base representation of the current form
7130
- var formData = new XhrFormData_1.XhrFormData(this.sourceForm);
7131
7207
  //in case someone has overloaded the viewstate with addtional decorators we merge
7132
7208
  //that in, there is no way around it, the spec allows it and getViewState
7133
7209
  //must be called, so whatever getViewState delivers has higher priority then
7134
7210
  //whatever the formData object delivers
7135
- formData.assignEncodedString(viewState);
7136
- formData.applyFileInputs.apply(formData, executesArr());
7211
+ //the partialIdsArray arr is almost deprecated legacy code where we allowed to send a separate list of partial
7212
+ //ids for reduced load and server processing, this will be removed soon, we can handle the same via execute
7213
+ //anyway TODO remove the partial ids array
7214
+ var formData = new XhrFormData_1.XhrFormData(this.sourceForm, viewState, executesArr(), this.partialIdsArray);
7137
7215
  this.contentType = formData.isMultipartRequest ? "undefined" : this.contentType;
7138
7216
  //next step the pass through parameters are merged in for post params
7139
7217
  var requestContext = this.requestContext;
7140
7218
  var passThroughParams = requestContext.getIf(Const_1.CTX_PARAM_PASS_THR);
7219
+ // this is an extension where we allow pass through parameters to be sent down additionally
7220
+ // this can be used and is used in the impl to enrich the post request parameters with additional
7221
+ // information
7141
7222
  formData.shallowMerge(passThroughParams, true, true);
7142
7223
  this.responseContext = passThroughParams.deepCopy;
7143
7224
  //we have to shift the internal passthroughs around to build up our response context
@@ -7158,7 +7239,7 @@ var XhrRequest = /** @class */ (function () {
7158
7239
  ignoreErr(function () { return xhrObject.setRequestHeader(Const_1.HEAD_FACES_REQ, Const_1.VAL_AJAX); });
7159
7240
  //probably not needed anymore, will test this
7160
7241
  //some webkit based mobile browsers do not follow the w3c spec of
7161
- // setting the accept headers automatically
7242
+ // setting, they accept headers automatically
7162
7243
  ignoreErr(function () { return xhrObject.setRequestHeader(Const_1.REQ_ACCEPT, Const_1.STD_ACCEPT); });
7163
7244
  this.sendEvent(Const_1.BEGIN);
7164
7245
  this.sendRequest(formData);
@@ -7215,19 +7296,19 @@ var XhrRequest = /** @class */ (function () {
7215
7296
  var _this = this;
7216
7297
  var xhrObject = this.xhrObject;
7217
7298
  xhrObject.onabort = function () {
7218
- _this.onAbort(resolve, reject);
7299
+ _this.onAbort(reject);
7219
7300
  };
7220
7301
  xhrObject.ontimeout = function () {
7221
- _this.onTimeout(resolve, reject);
7302
+ _this.onTimeout(reject);
7222
7303
  };
7223
7304
  xhrObject.onload = function () {
7224
- _this.onSuccess(_this.xhrObject, resolve, reject);
7305
+ _this.onSuccess(resolve);
7225
7306
  };
7226
7307
  xhrObject.onloadend = function () {
7227
- _this.onDone(_this.xhrObject, resolve, reject);
7308
+ _this.onDone(_this.xhrObject, resolve);
7228
7309
  };
7229
7310
  xhrObject.onerror = function (errorData) {
7230
- _this.onError(errorData, resolve, reject);
7311
+ _this.onError(errorData, reject);
7231
7312
  };
7232
7313
  };
7233
7314
  /*
@@ -7236,24 +7317,24 @@ var XhrRequest = /** @class */ (function () {
7236
7317
  * Those methods are the callbacks called by
7237
7318
  * the xhr object depending on its own state
7238
7319
  */
7239
- XhrRequest.prototype.onAbort = function (resolve, reject) {
7320
+ XhrRequest.prototype.onAbort = function (reject) {
7240
7321
  reject();
7241
7322
  };
7242
- XhrRequest.prototype.onTimeout = function (resolve, reject) {
7323
+ XhrRequest.prototype.onTimeout = function (reject) {
7243
7324
  this.sendEvent(Const_1.STATE_EVT_TIMEOUT);
7244
7325
  reject();
7245
7326
  };
7246
- XhrRequest.prototype.onSuccess = function (data, resolve, reject) {
7327
+ XhrRequest.prototype.onSuccess = function (resolve) {
7247
7328
  var _a, _b;
7248
7329
  this.sendEvent(Const_1.COMPLETE);
7249
7330
  //malforms always result in empty response xml
7250
7331
  if (!((_a = this === null || this === void 0 ? void 0 : this.xhrObject) === null || _a === void 0 ? void 0 : _a.responseXML)) {
7251
- this.handleMalFormedXML(resolve, reject);
7332
+ this.handleMalFormedXML(resolve);
7252
7333
  return;
7253
7334
  }
7254
7335
  jsf.ajax.response(this.xhrObject, (_b = this.responseContext.value) !== null && _b !== void 0 ? _b : {});
7255
7336
  };
7256
- XhrRequest.prototype.handleMalFormedXML = function (resolve, reject) {
7337
+ XhrRequest.prototype.handleMalFormedXML = function (resolve) {
7257
7338
  var _a;
7258
7339
  this.stopProgress = true;
7259
7340
  var errorData = {
@@ -7275,16 +7356,27 @@ var XhrRequest = /** @class */ (function () {
7275
7356
  }
7276
7357
  //non blocking non clearing
7277
7358
  };
7278
- XhrRequest.prototype.onDone = function (data, resolve, reject) {
7359
+ XhrRequest.prototype.onDone = function (data, resolve) {
7279
7360
  if (this.stopProgress) {
7280
7361
  return;
7281
7362
  }
7282
7363
  resolve(data);
7283
7364
  };
7284
- XhrRequest.prototype.onError = function (errorData, resolve, reject) {
7365
+ XhrRequest.prototype.onError = function (errorData, reject) {
7285
7366
  this.handleError(errorData);
7286
7367
  reject();
7287
7368
  };
7369
+ XhrRequest.prototype.sendRequest = function (formData) {
7370
+ var isPost = this.ajaxType != Const_1.REQ_TYPE_GET;
7371
+ if (formData.isMultipartRequest) {
7372
+ //in case of a multipart request we send in a formData object as body
7373
+ this.xhrObject.send((isPost) ? formData.toFormData() : null);
7374
+ }
7375
+ else {
7376
+ //in case of a normal request we send it normally
7377
+ this.xhrObject.send((isPost) ? formData.toString() : null);
7378
+ }
7379
+ };
7288
7380
  /*
7289
7381
  * other helpers
7290
7382
  */
@@ -7309,17 +7401,6 @@ var XhrRequest = /** @class */ (function () {
7309
7401
  var eventHandler = (0, RequestDataResolver_1.resolveHandlerFunc)(this.requestContext, this.responseContext, Const_1.ON_ERROR);
7310
7402
  AjaxImpl_1.Implementation.sendError(errorData, eventHandler);
7311
7403
  };
7312
- XhrRequest.prototype.sendRequest = function (formData) {
7313
- var isPost = this.ajaxType != Const_1.REQ_TYPE_GET;
7314
- if (formData.isMultipartRequest) {
7315
- //in case of a multipart request we send in a formData object as body
7316
- this.xhrObject.send((isPost) ? formData.toFormData() : null);
7317
- }
7318
- else {
7319
- //in case of a normal request we send it normally
7320
- this.xhrObject.send((isPost) ? formData.toString() : null);
7321
- }
7322
- };
7323
7404
  return XhrRequest;
7324
7405
  }());
7325
7406
  exports.XhrRequest = XhrRequest;