jsf.js_next_gen 4.0.0-RC.31 → 4.0.0-RC.33

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.
@@ -2917,8 +2917,9 @@ exports.Config = Config;
2917
2917
  * limitations under the License.
2918
2918
  */
2919
2919
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2920
- exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.InverseArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.MultiStreamDatasource = exports.ITERATION_STATUS = void 0;
2920
+ exports.QueryFormStringCollector = exports.QueryFormDataCollector = exports.FormDataCollector = exports.ConfigCollector = exports.AssocArrayCollector = exports.Run = exports.ArrayAssocArrayCollector = exports.InverseArrayCollector = exports.ArrayCollector = exports.FlatMapStreamDataSource = exports.MappedStreamDataSource = exports.FilteredStreamDatasource = exports.ArrayStreamDataSource = exports.SequenceDataSource = exports.MultiStreamDatasource = exports.ITERATION_STATUS = void 0;
2921
2921
  const Stream_1 = __webpack_require__(/*! ./Stream */ "./node_modules/mona-dish/src/main/typescript/Stream.ts");
2922
+ const Monad_1 = __webpack_require__(/*! ./Monad */ "./node_modules/mona-dish/src/main/typescript/Monad.ts");
2922
2923
  /**
2923
2924
  * special status of the datasource location pointer
2924
2925
  * if an access, outside of the possible data boundaries is happening
@@ -3208,7 +3209,7 @@ class FlatMapStreamDataSource {
3208
3209
  var _a;
3209
3210
  //easy access trial
3210
3211
  if ((this === null || this === void 0 ? void 0 : this.activeDataSource) && ((_a = this === null || this === void 0 ? void 0 : this.activeDataSource) === null || _a === void 0 ? void 0 : _a.lookAhead(cnt)) != ITERATION_STATUS.EO_STRM) {
3211
- //this should coverr 95% of all accesses
3212
+ //this should cover 95% of all cases
3212
3213
  return this === null || this === void 0 ? void 0 : this.activeDataSource.lookAhead(cnt);
3213
3214
  }
3214
3215
  /**
@@ -3230,25 +3231,33 @@ class FlatMapStreamDataSource {
3230
3231
  if (this.activeDataSource) {
3231
3232
  readjustSkip(this.activeDataSource);
3232
3233
  }
3233
- //the idea is basically to look into the streams subsequentially for a match
3234
+ //the idea is basically to look into the streams sub-sequentially for a match
3234
3235
  //after each stream we have to take into consideration that the skipCnt is
3235
3236
  //reduced by the number of datasets we already have looked into in the previous stream/datasource
3236
- //unfortunately for now we have to loop into them so we introduce a small o2 here
3237
+ //unfortunately for now we have to loop into them, so we introduce a small o2 here
3237
3238
  for (let dsLoop = 1; true; dsLoop++) {
3238
- let currDatasource = this.inputDataSource.lookAhead(dsLoop);
3239
+ let datasourceData = this.inputDataSource.lookAhead(dsLoop);
3239
3240
  //we have looped out
3240
- if (currDatasource === ITERATION_STATUS.EO_STRM) {
3241
+ //no embedded data anymore? we are done, data
3242
+ //can either be a scalar an array or another datasource
3243
+ if (datasourceData === ITERATION_STATUS.EO_STRM) {
3241
3244
  return ITERATION_STATUS.EO_STRM;
3242
3245
  }
3243
- let mapped = this.mapFunc(currDatasource);
3246
+ let mappedData = this.mapFunc(datasourceData);
3244
3247
  //it either comes in as datasource or as array
3245
- let currentDataSource = this.toDatasource(mapped);
3248
+ //both cases must be unified into a datasource
3249
+ let currentDataSource = this.toDatasource(mappedData);
3250
+ //we now run again a lookahead
3246
3251
  let ret = currentDataSource.lookAhead(cnt);
3252
+ //if the value is found then we are set
3247
3253
  if (ret != ITERATION_STATUS.EO_STRM) {
3248
3254
  return ret;
3249
3255
  }
3250
- readjustSkip(currDatasource);
3256
+ //reduce the next lookahead by the number of elements
3257
+ //we are now skipping in the current data source
3258
+ readjustSkip(currentDataSource);
3251
3259
  }
3260
+ return ITERATION_STATUS.EO_STRM;
3252
3261
  }
3253
3262
  toDatasource(mapped) {
3254
3263
  let ds = Array.isArray(mapped) ? new ArrayStreamDataSource(...mapped) : mapped;
@@ -3260,7 +3269,6 @@ class FlatMapStreamDataSource {
3260
3269
  while (!next && this.inputDataSource.hasNext()) {
3261
3270
  let mapped = this.mapFunc(this.inputDataSource.next());
3262
3271
  this.activeDataSource = this.toDatasource(mapped);
3263
- ;
3264
3272
  next = this.activeDataSource.hasNext();
3265
3273
  }
3266
3274
  return next;
@@ -3358,6 +3366,18 @@ class AssocArrayCollector {
3358
3366
  }
3359
3367
  }
3360
3368
  exports.AssocArrayCollector = AssocArrayCollector;
3369
+ /**
3370
+ * A Config collector similar to the FormDFata Collector
3371
+ */
3372
+ class ConfigCollector {
3373
+ constructor() {
3374
+ this.finalValue = new Monad_1.Config({});
3375
+ }
3376
+ collect(element) {
3377
+ this.finalValue.append(element.key).value = element.value;
3378
+ }
3379
+ }
3380
+ exports.ConfigCollector = ConfigCollector;
3361
3381
  /**
3362
3382
  * Form data collector for key value pair streams
3363
3383
  */
@@ -6159,7 +6179,7 @@ exports.ExtConfig = ExtConfig;
6159
6179
 
6160
6180
 
6161
6181
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6162
- exports.fixKeyWithoutVal = exports.resolveFiles = exports.decodeEncodedValues = exports.encodeFormData = void 0;
6182
+ exports.getFormInputsAsStream = exports.fixKeyWithoutVal = exports.resolveFiles = exports.decodeEncodedValues = exports.encodeFormData = void 0;
6163
6183
  const mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
6164
6184
  const ExtDomQuery_1 = __webpack_require__(/*! ./ExtDomQuery */ "./src/main/typescript/impl/util/ExtDomQuery.ts");
6165
6185
  const Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
@@ -6177,13 +6197,17 @@ function encodeFormData(formData, paramsMapper = (inStr, inVal) => [inStr, inVal
6177
6197
  if (formData.isAbsent()) {
6178
6198
  return defaultStr;
6179
6199
  }
6180
- let assocValues = formData.value;
6181
- let entries = mona_dish_1.LazyStream.of(...Object.keys(assocValues))
6182
- .filter(key => assocValues.hasOwnProperty(key))
6183
- .flatMap(key => mona_dish_1.Stream.of(...assocValues[key]).map(val => paramsMapper(key, val)))
6200
+ const assocValues = formData.value;
6201
+ const expandValueArrAndRename = key => mona_dish_1.Stream.of(...assocValues[key]).map(val => paramsMapper(key, val));
6202
+ const isPropertyKey = key => assocValues.hasOwnProperty(key);
6203
+ const isNotFile = ([, value]) => !(value instanceof ExtDomQuery_1.ExtDomQuery.global().File);
6204
+ const mapIntoUrlParam = keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`;
6205
+ const entries = mona_dish_1.LazyStream.of(...Object.keys(assocValues))
6206
+ .filter(isPropertyKey)
6207
+ .flatMap(expandValueArrAndRename)
6184
6208
  //we cannot encode file elements that is handled by multipart requests anyway
6185
- .filter(([, value]) => !(value instanceof ExtDomQuery_1.ExtDomQuery.global().File))
6186
- .map(keyVal => `${encodeURIComponent(keyVal[0])}=${encodeURIComponent(keyVal[1])}`)
6209
+ .filter(isNotFile)
6210
+ .map(mapIntoUrlParam)
6187
6211
  .collect(new mona_dish_1.ArrayCollector());
6188
6212
  return entries.join("&");
6189
6213
  }
@@ -6193,16 +6217,18 @@ exports.encodeFormData = encodeFormData;
6193
6217
  * @param encoded encoded string
6194
6218
  */
6195
6219
  function decodeEncodedValues(encoded) {
6196
- return mona_dish_1.Stream.of(...decodeURIComponent(encoded).split(/&/gi))
6197
- .filter(item => !!(item || '')
6198
- .replace(/\s+/g, ''))
6199
- .map(line => {
6220
+ const filterBlanks = item => !!(item || '').replace(/\s+/g, '');
6221
+ const splitKeyValuePair = line => {
6200
6222
  let index = line.indexOf("=");
6201
6223
  if (index == -1) {
6202
6224
  return [line];
6203
6225
  }
6204
6226
  return [line.substring(0, index), line.substring(index + 1)];
6205
- });
6227
+ };
6228
+ let requestParamEntries = decodeURIComponent(encoded).split(/&/gi);
6229
+ return mona_dish_1.Stream.of(...requestParamEntries)
6230
+ .filter(filterBlanks)
6231
+ .map(splitKeyValuePair);
6206
6232
  }
6207
6233
  exports.decodeEncodedValues = decodeEncodedValues;
6208
6234
  function resolveFiles(dataSource) {
@@ -6220,6 +6246,23 @@ function fixKeyWithoutVal(keyVal) {
6220
6246
  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;
6221
6247
  }
6222
6248
  exports.fixKeyWithoutVal = fixKeyWithoutVal;
6249
+ /**
6250
+ * gets all the inputs under the form parentItem
6251
+ * as stream
6252
+ * @param parentItem
6253
+ */
6254
+ function getFormInputsAsStream(parentItem) {
6255
+ //encoded String
6256
+ const viewStateStr = (0, Const_1.$faces)().getViewState(parentItem.getAsElem(0).value);
6257
+ // we now need to decode it and then merge it into the target buf
6258
+ // which hosts already our overrides (aka do not override what is already there(
6259
+ // after that we need to deal with form elements on a separate level
6260
+ const standardInputs = decodeEncodedValues(viewStateStr);
6261
+ const fileInputs = resolveFiles(parentItem);
6262
+ const allInputs = standardInputs.concat(fileInputs);
6263
+ return allInputs;
6264
+ }
6265
+ exports.getFormInputsAsStream = getFormInputsAsStream;
6223
6266
 
6224
6267
 
6225
6268
  /***/ }),
@@ -7677,7 +7720,6 @@ exports.XhrFormData = void 0;
7677
7720
  */
7678
7721
  const mona_dish_1 = __webpack_require__(/*! mona-dish */ "./node_modules/mona-dish/src/main/typescript/index_core.ts");
7679
7722
  const Const_1 = __webpack_require__(/*! ../core/Const */ "./src/main/typescript/impl/core/Const.ts");
7680
- const ExtDomQuery_1 = __webpack_require__(/*! ../util/ExtDomQuery */ "./src/main/typescript/impl/util/ExtDomQuery.ts");
7681
7723
  const FileUtils_1 = __webpack_require__(/*! ../util/FileUtils */ "./src/main/typescript/impl/util/FileUtils.ts");
7682
7724
  const defaultParamsMapper = (key, item) => [key, item];
7683
7725
  /**
@@ -7688,9 +7730,6 @@ const defaultParamsMapper = (key, item) => [key, item];
7688
7730
  * due to api constraints on the HTML Form object in IE11
7689
7731
  * and due to the url encoding constraint given by the faces.js spec
7690
7732
  *
7691
- * probably only one needed and one overlay!
7692
- * the entire file input storing probably is redundant now
7693
- * that dom query has been fixed
7694
7733
  *
7695
7734
  * internal storage format
7696
7735
  * every value is stored as an array
@@ -7729,40 +7768,15 @@ class XhrFormData extends mona_dish_1.Config {
7729
7768
  this.encodeSubmittableFields(this.dataSource, this.partialIds);
7730
7769
  this.applyViewState(this.dataSource);
7731
7770
  }
7732
- /**
7733
- * generic post init code, for now, this performs some post assign data post-processing
7734
- * @param executes the executable dom nodes which need to be processed into the form data, which we can send
7735
- * in our ajax request
7736
- */
7737
- resolveRequestType(rootElement, executes) {
7738
- if (!executes || executes.indexOf(Const_1.IDENT_NONE) != -1) {
7739
- return;
7740
- }
7741
- this.isMultipartRequest = rootElement.isMultipartCandidate(true);
7742
- }
7743
- /**
7744
- * special case view state handling
7745
- *
7746
- * @param form the form holding the view state value
7747
- */
7748
- applyViewState(form) {
7749
- if (this.getIf((0, Const_1.$nsp)(Const_1.P_VIEWSTATE)).isPresent()) {
7750
- return;
7751
- }
7752
- let viewStateElement = form.querySelectorAllDeep(`[name*='${(0, Const_1.$nsp)(Const_1.P_VIEWSTATE)}'`);
7753
- let viewState = viewStateElement.inputValue;
7754
- this.appendIf(viewState.isPresent(), this.remapKeyForNamingContainer(viewStateElement.name.value)).value = viewState.value;
7755
- }
7756
7771
  /**
7757
7772
  * @returns a Form data representation, this is needed for file submits
7758
7773
  */
7759
7774
  toFormData() {
7760
- let ret = new FormData();
7761
7775
  /*
7762
7776
  * expands key: [item1, item2]
7763
7777
  * to: [{key: item1}, {key, item2}]
7764
7778
  */
7765
- let expandArrayedData = ([key, item]) => mona_dish_1.Stream.of(...item).map(item => {
7779
+ let expandAssocArray = ([key, item]) => mona_dish_1.Stream.of(...item).map(item => {
7766
7780
  return { key, item };
7767
7781
  });
7768
7782
  /*
@@ -7776,11 +7790,12 @@ class XhrFormData extends mona_dish_1.Config {
7776
7790
  /*
7777
7791
  * collects everything into a FormData object
7778
7792
  */
7793
+ let ret = new FormData();
7779
7794
  let collectFormData = ({ key, item }) => {
7780
7795
  ret.append(key, item);
7781
7796
  };
7782
7797
  mona_dish_1.Stream.ofAssoc(this.value)
7783
- .flatMap(expandArrayedData)
7798
+ .flatMap(expandAssocArray)
7784
7799
  .map(remapForNamingContainer)
7785
7800
  .each(collectFormData);
7786
7801
  return ret;
@@ -7793,6 +7808,30 @@ class XhrFormData extends mona_dish_1.Config {
7793
7808
  toString(defaultStr = Const_1.EMPTY_STR) {
7794
7809
  return (0, FileUtils_1.encodeFormData)(this, this.paramsMapper, defaultStr);
7795
7810
  }
7811
+ /**
7812
+ * generic post init code, for now, this performs some post assign data post-processing
7813
+ * @param executes the executable dom nodes which need to be processed into the form data, which we can send
7814
+ * in our ajax request
7815
+ */
7816
+ resolveRequestType(rootElement, executes) {
7817
+ if (!executes || executes.indexOf(Const_1.IDENT_NONE) != -1) {
7818
+ return;
7819
+ }
7820
+ this.isMultipartRequest = rootElement.isMultipartCandidate(true);
7821
+ }
7822
+ /**
7823
+ * special case view state handling
7824
+ *
7825
+ * @param form the form holding the view state value
7826
+ */
7827
+ applyViewState(form) {
7828
+ if (this.getIf((0, Const_1.$nsp)(Const_1.P_VIEWSTATE)).isPresent()) {
7829
+ return;
7830
+ }
7831
+ let viewStateElement = form.querySelectorAllDeep(`[name*='${(0, Const_1.$nsp)(Const_1.P_VIEWSTATE)}'`);
7832
+ let viewState = viewStateElement.inputValue;
7833
+ this.appendIf(viewState.isPresent(), this.remapKeyForNamingContainer(viewStateElement.name.value)).value = viewState.value;
7834
+ }
7796
7835
  /**
7797
7836
  * determines fields to submit
7798
7837
  * @param {Object} targetBuf - the target form buffer receiving the data
@@ -7800,22 +7839,11 @@ class XhrFormData extends mona_dish_1.Config {
7800
7839
  * @param {Array} partialIds - ids fo PPS
7801
7840
  */
7802
7841
  encodeSubmittableFields(parentItem, partialIds) {
7803
- //encoded String
7804
- let viewStateStr = (0, Const_1.$faces)().getViewState(parentItem.getAsElem(0).value);
7805
- // we now need to decode it and then merge it into the target buf
7806
- // which hosts already our overrides (aka do not override what is already there(
7807
- // after that we need to deal with form elements on a separate level
7808
- const keyValueEntries = (0, FileUtils_1.decodeEncodedValues)(viewStateStr);
7809
- const fileEntries = (0, FileUtils_1.resolveFiles)(parentItem);
7810
- const concatted = keyValueEntries.concat(fileEntries);
7811
- const formData = new ExtDomQuery_1.ExtConfig({});
7812
- concatted
7842
+ const formInputs = (0, FileUtils_1.getFormInputsAsStream)(parentItem);
7843
+ formInputs
7813
7844
  .map(FileUtils_1.fixKeyWithoutVal)
7814
- .map(keyVal => this.paramsMapper(keyVal[0], keyVal[1]))
7815
- .each((entry) => {
7816
- formData.append(entry[0]).value = entry[1];
7817
- });
7818
- this.shallowMerge(formData, true, true);
7845
+ .map(([key, value]) => this.paramsMapper(key, value))
7846
+ .each(([key, value]) => this.append(key).value = value);
7819
7847
  }
7820
7848
  remapKeyForNamingContainer(key) {
7821
7849
  return this.paramsMapper(key, "")[0];
Binary file
Binary file