jsf.js_next_gen 4.0.0-beta-20 → 4.0.0-beta-21

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 (41) hide show
  1. package/dist/window/faces-development.js +124 -78
  2. package/dist/window/faces-development.js.br +0 -0
  3. package/dist/window/faces-development.js.gz +0 -0
  4. package/dist/window/faces-development.js.map +1 -1
  5. package/dist/window/faces.js +1 -1
  6. package/dist/window/faces.js.br +0 -0
  7. package/dist/window/faces.js.gz +0 -0
  8. package/dist/window/faces.js.map +1 -1
  9. package/dist/window/jsf-development.js +124 -78
  10. package/dist/window/jsf-development.js.br +0 -0
  11. package/dist/window/jsf-development.js.gz +0 -0
  12. package/dist/window/jsf-development.js.map +1 -1
  13. package/dist/window/jsf.js +1 -1
  14. package/dist/window/jsf.js.br +0 -0
  15. package/dist/window/jsf.js.gz +0 -0
  16. package/dist/window/jsf.js.map +1 -1
  17. package/package.json +3 -3
  18. package/src/main/typescript/impl/util/ExtDomQuery.ts +51 -2
  19. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +1 -23
  20. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +283 -68
  21. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +1 -0
  22. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +1 -0
  23. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +9 -2
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +8 -6
  25. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +34 -10
  26. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +1 -0
  27. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +3 -0
  28. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +1 -0
  29. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +3 -0
  30. package/target/impl/util/ExtDomQuery.js +45 -1
  31. package/target/impl/util/ExtDomQuery.js.map +1 -1
  32. package/target/impl/xhrCore/ResponseProcessor.js +1 -23
  33. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  34. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +243 -83
  35. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  36. package/target/test/frameworkBase/_ext/shared/StandardInits.js +9 -2
  37. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  38. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +8 -6
  39. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  40. package/target/test/xhrCore/ResponseTest.spec.js +27 -10
  41. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "4.0.0-beta-20",
3
+ "version": "4.0.0-beta-21",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/faces.js",
6
6
  "scripts": {
@@ -41,13 +41,13 @@
41
41
  "terser-webpack-plugin": "^5.3.6",
42
42
  "ts-loader": "^9.4.1",
43
43
  "ts-node": "^10.9.1",
44
- "typedoc": "^0.23.19",
44
+ "typedoc": "^0.23.20",
45
45
  "typescript": "^4.8.4",
46
46
  "webpack": "^5.74.0",
47
47
  "webpack-cli": "^4.10.0",
48
48
  "webpack-dev-server": "^4.11.1"
49
49
  },
50
50
  "dependencies": {
51
- "mona-dish": "0.22.24"
51
+ "mona-dish": "0.23.2"
52
52
  }
53
53
  }
@@ -13,8 +13,10 @@
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, Stream, ArrayCollector} from "mona-dish";
16
+ import {Config, IValueHolder, Optional, DomQuery, DQ, Stream, ArrayCollector, Lang} from "mona-dish";
17
17
  import {$nsp, P_WINDOW_ID} from "../core/Const";
18
+ import equalsIgnoreCase = Lang.equalsIgnoreCase;
19
+ import trim = Lang.trim;
18
20
 
19
21
 
20
22
 
@@ -175,9 +177,55 @@ export class ExtDomquery extends DQ {
175
177
  const whitelistFunc = (src: string): boolean => {
176
178
  return (whilteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
177
179
  };
178
- return super.runScripts(false, whitelistFunc);
180
+ return super.runScripts(sticky, whitelistFunc);
179
181
  }
180
182
 
183
+ /**
184
+ * adds the elements in this ExtDomQuery to the head
185
+ *
186
+ * @param newElements the elements which need addition
187
+ */
188
+ runHeadInserts(suppressDoubleIncludes = true): void {
189
+ let head = ExtDomquery.byId(document.head);
190
+ //automated nonce handling
191
+ let processedScripts = [];
192
+
193
+ // the idea is only to run head inserts on resources
194
+ // which do not exist already, that way
195
+ // we can avoid double includes on subsequent resource
196
+ // requests.
197
+ function resourceIsNew(element: DomQuery) {
198
+ if(!suppressDoubleIncludes) {
199
+ return true;
200
+ }
201
+ const tagName = element.tagName.value;
202
+ if(!tagName) {
203
+ // textnode
204
+ return true;
205
+ }
206
+ let href = element.attr("href").orElse(element.attr("src").value);
207
+
208
+ if (!href.isPresent()) {
209
+ return true;
210
+ }
211
+ return !head.querySelectorAll(`${tagName}[href='${href.value}']`).length &&
212
+ !head.querySelectorAll(`${tagName}[src='${href.value}']`).length;
213
+ }
214
+
215
+ this
216
+ .filter(resourceIsNew)
217
+ .each(element => {
218
+ if(element.tagName.value != "SCRIPT") {
219
+ //we need to run runScripts properly to deal with the rest
220
+ new ExtDomquery(...processedScripts).runScripts(true);
221
+ processedScripts = [];
222
+ head.append(element);
223
+ } else {
224
+ processedScripts.push(element);
225
+ }
226
+ });
227
+ new ExtDomquery(...processedScripts).runScripts(true);
228
+ }
181
229
 
182
230
 
183
231
  /**
@@ -192,6 +240,7 @@ export class ExtDomquery extends DQ {
192
240
  return new ExtDomquery(ret);
193
241
  }
194
242
 
243
+
195
244
  }
196
245
 
197
246
  export const ExtDQ = ExtDomquery;
@@ -315,7 +315,7 @@ export class ResponseProcessor implements IResponseProcessor {
315
315
  globalEval() {
316
316
  // phase one, if we have head inserts, we build up those before going into the script eval phase
317
317
  let insertHeadElems = new ExtDomquery(...this.internalContext.getIf(DEFERRED_HEAD_INSERTS).value);
318
- this.runHeadInserts(insertHeadElems);
318
+ insertHeadElems.runHeadInserts(true);
319
319
 
320
320
  // phase 2 we run a script eval on all updated elements in the body
321
321
  let updateElems = new ExtDomquery(...this.internalContext.getIf(UPDATE_ELEMS).value);
@@ -485,26 +485,4 @@ export class ResponseProcessor implements IResponseProcessor {
485
485
  }
486
486
 
487
487
 
488
- /**
489
- * adds new elements to the head as per spec, we use it in a deferred way
490
- * to have the html buildup first then the head inserts which run the head evals
491
- * and then the body and css evals from the markup
492
- *
493
- * This is only performed upon a head replacement or resource insert
494
- *
495
- * @param newElements the elements which need addition
496
- */
497
- private runHeadInserts(newElements: ExtDomquery): void {
498
- let head = ExtDomquery.byId(document.head);
499
- //automated nonce handling
500
- newElements.each(element => {
501
- if(element.tagName.value != "SCRIPT" || element.attr("src").isPresent()) {
502
- head.append(element);
503
- return;
504
- }
505
- // special corner case
506
- // embedded script code,
507
- element.globalEvalSticky(element.innerHTML);
508
- });
509
- }
510
488
  }