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

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 (43) hide show
  1. package/dist/window/faces-development.js +147 -79
  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 +147 -79
  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 -4
  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 +11 -3
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +14 -6
  25. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +36 -11
  26. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +16 -0
  27. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +18 -0
  28. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +16 -0
  29. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +16 -0
  30. package/src/main/typescript/test/xhrCore/fixtures/nonce_script.js +16 -0
  31. package/src/tmp/test.html +92 -0
  32. package/target/impl/util/ExtDomQuery.js +47 -2
  33. package/target/impl/util/ExtDomQuery.js.map +1 -1
  34. package/target/impl/xhrCore/ResponseProcessor.js +1 -23
  35. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  36. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +243 -83
  37. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  38. package/target/test/frameworkBase/_ext/shared/StandardInits.js +11 -3
  39. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  40. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +13 -6
  41. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  42. package/target/test/xhrCore/ResponseTest.spec.js +25 -10
  43. 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-22",
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.4"
52
52
  }
53
53
  }
@@ -17,8 +17,6 @@ import {Config, IValueHolder, Optional, DomQuery, DQ, Stream, ArrayCollector} fr
17
17
  import {$nsp, P_WINDOW_ID} from "../core/Const";
18
18
 
19
19
 
20
-
21
-
22
20
  /**
23
21
  * detects whether a source is a faces.js request
24
22
  *
@@ -42,7 +40,7 @@ const IS_FACES_SOURCE = (source?: string): boolean => {
42
40
 
43
41
  /**
44
42
  * namespace myfaces.testscripts can be used as extension point for internal
45
- * tests, those will be handled similarly to faces.js regarding
43
+ * tests, those will be handled similarly to faces.js - regarding
46
44
  * reload blocking on ajax requests
47
45
  *
48
46
  * @param source the source to check
@@ -169,15 +167,62 @@ export class ExtDomquery extends DQ {
169
167
  /**
170
168
  * decorated run scripts which takes our jsf extensions into consideration
171
169
  * (standard DomQuery will let you pass anything)
170
+ * @param sticky if set to true the internally generated element for the script is left in the dom
172
171
  * @param whilteListed
173
172
  */
174
173
  runScripts(sticky = false, whilteListed?: (src: string) => boolean): DomQuery {
175
174
  const whitelistFunc = (src: string): boolean => {
176
175
  return (whilteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
177
176
  };
178
- return super.runScripts(false, whitelistFunc);
177
+ return super.runScripts(sticky, whitelistFunc);
179
178
  }
180
179
 
180
+ /**
181
+ * adds the elements in this ExtDomQuery to the head
182
+ *
183
+ * @param suppressDoubleIncludes checks for existing elements in the head before running the insert
184
+ */
185
+ runHeadInserts(suppressDoubleIncludes = true): void {
186
+ let head = ExtDomquery.byId(document.head);
187
+ //automated nonce handling
188
+ let processedScripts = [];
189
+
190
+ // the idea is only to run head inserts on resources
191
+ // which do not exist already, that way
192
+ // we can avoid double includes on subsequent resource
193
+ // requests.
194
+ function resourceIsNew(element: DomQuery) {
195
+ if(!suppressDoubleIncludes) {
196
+ return true;
197
+ }
198
+ const tagName = element.tagName.value;
199
+ if(!tagName) {
200
+ // textnode
201
+ return true;
202
+ }
203
+ let href = element.attr("href").orElse(element.attr("src").value);
204
+
205
+ if (!href.isPresent()) {
206
+ return true;
207
+ }
208
+ return !head.querySelectorAll(`${tagName}[href='${href.value}']`).length &&
209
+ !head.querySelectorAll(`${tagName}[src='${href.value}']`).length;
210
+ }
211
+
212
+ this
213
+ .filter(resourceIsNew)
214
+ .each(element => {
215
+ if(element.tagName.value != "SCRIPT") {
216
+ //we need to run runScripts properly to deal with the rest
217
+ new ExtDomquery(...processedScripts).runScripts(true);
218
+ processedScripts = [];
219
+ head.append(element);
220
+ } else {
221
+ processedScripts.push(element);
222
+ }
223
+ });
224
+ new ExtDomquery(...processedScripts).runScripts(true);
225
+ }
181
226
 
182
227
 
183
228
  /**
@@ -192,6 +237,7 @@ export class ExtDomquery extends DQ {
192
237
  return new ExtDomquery(ret);
193
238
  }
194
239
 
240
+
195
241
  }
196
242
 
197
243
  export const ExtDQ = ExtDomquery;
@@ -271,4 +317,5 @@ export class ExtConfig extends Config {
271
317
  return Stream.of(...accessPath).map(key => $nsp(key)).collect(new ArrayCollector());
272
318
  }
273
319
 
320
+
274
321
  }
@@ -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
  }