jsf.js_next_gen 4.0.0-beta-19 → 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 (79) hide show
  1. package/dist/docs/functions/faces.ajax.addOnError.html +1 -1
  2. package/dist/docs/functions/faces.ajax.addOnEvent.html +1 -1
  3. package/dist/docs/functions/faces.ajax.request.html +1 -1
  4. package/dist/docs/functions/faces.ajax.response.html +1 -1
  5. package/dist/docs/functions/faces.getClientWindow.html +1 -1
  6. package/dist/docs/functions/faces.getProjectStage.html +1 -1
  7. package/dist/docs/functions/faces.getViewState.html +1 -1
  8. package/dist/docs/functions/faces.push.close.html +1 -1
  9. package/dist/docs/functions/faces.push.init.html +1 -1
  10. package/dist/docs/functions/faces.push.open.html +1 -1
  11. package/dist/docs/functions/faces.util.chain.html +1 -1
  12. package/dist/docs/functions/myfaces.ab.html +1 -1
  13. package/dist/docs/index.html +1 -1
  14. package/dist/docs/modules/faces.ajax.html +1 -1
  15. package/dist/docs/modules/faces.html +1 -1
  16. package/dist/docs/modules/faces.push.html +1 -1
  17. package/dist/docs/modules/faces.util.html +1 -1
  18. package/dist/docs/modules/myfaces.html +1 -1
  19. package/dist/docs/modules.html +1 -1
  20. package/dist/docs/variables/faces.contextpath.html +1 -1
  21. package/dist/docs/variables/faces.implversion.html +1 -1
  22. package/dist/docs/variables/faces.separatorchar.html +1 -1
  23. package/dist/docs/variables/faces.specversion.html +1 -1
  24. package/dist/docs/variables/myfaces.oam.html +1 -1
  25. package/dist/window/faces-development.js +282 -47
  26. package/dist/window/faces-development.js.br +0 -0
  27. package/dist/window/faces-development.js.gz +0 -0
  28. package/dist/window/faces-development.js.map +1 -1
  29. package/dist/window/faces.js +1 -1
  30. package/dist/window/faces.js.br +0 -0
  31. package/dist/window/faces.js.gz +0 -0
  32. package/dist/window/faces.js.map +1 -1
  33. package/dist/window/jsf-development.js +282 -47
  34. package/dist/window/jsf-development.js.br +0 -0
  35. package/dist/window/jsf-development.js.gz +0 -0
  36. package/dist/window/jsf-development.js.map +1 -1
  37. package/dist/window/jsf.js +1 -1
  38. package/dist/window/jsf.js.br +0 -0
  39. package/dist/window/jsf.js.gz +0 -0
  40. package/dist/window/jsf.js.map +1 -1
  41. package/package.json +6 -6
  42. package/src/main/typescript/impl/core/Const.ts +6 -0
  43. package/src/main/typescript/impl/util/ExtDomQuery.ts +61 -3
  44. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +8 -0
  45. package/src/main/typescript/impl/xhrCore/ResonseDataResolver.ts +3 -1
  46. package/src/main/typescript/impl/xhrCore/Response.ts +6 -2
  47. package/src/main/typescript/impl/xhrCore/ResponseProcessor.ts +26 -4
  48. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +283 -68
  49. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test.js +1 -0
  50. package/src/main/typescript/test/frameworkBase/_ext/monadish/fixtures/test2.js +1 -0
  51. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +15 -2
  52. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +34 -0
  53. package/src/main/typescript/test/xhrCore/ResponseTest.spec.ts +47 -2
  54. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +1 -1
  55. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead1.js +1 -0
  56. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.css +3 -0
  57. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead2.js +1 -0
  58. package/src/main/typescript/test/xhrCore/fixtures/addedViewHead3.js +3 -0
  59. package/src/test.html +75 -0
  60. package/target/impl/core/Const.js +7 -3
  61. package/target/impl/core/Const.js.map +1 -1
  62. package/target/impl/util/ExtDomQuery.js +49 -2
  63. package/target/impl/util/ExtDomQuery.js.map +1 -1
  64. package/target/impl/xhrCore/ResonseDataResolver.js +1 -0
  65. package/target/impl/xhrCore/ResonseDataResolver.js.map +1 -1
  66. package/target/impl/xhrCore/Response.js +3 -0
  67. package/target/impl/xhrCore/Response.js.map +1 -1
  68. package/target/impl/xhrCore/ResponseProcessor.js +18 -3
  69. package/target/impl/xhrCore/ResponseProcessor.js.map +1 -1
  70. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +243 -83
  71. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  72. package/target/test/frameworkBase/_ext/shared/StandardInits.js +15 -2
  73. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  74. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +32 -0
  75. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  76. package/target/test/xhrCore/ResponseTest.spec.js +38 -2
  77. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  78. package/target/test/xhrCore/ResponseTest23.spec.js +0 -1
  79. package/target/test/xhrCore/ResponseTest23.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-19",
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": {
@@ -23,17 +23,17 @@
23
23
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
24
24
  "@types/chai": "^4.3.3",
25
25
  "@types/mocha": "^10.0.0",
26
- "@types/node": "^18.11.0",
26
+ "@types/node": "^18.11.9",
27
27
  "@types/sinon": "^10.0.13",
28
28
  "babel-plugin-syntax-dynamic-import": "^6.18.0",
29
29
  "chai": "^4.3.6",
30
30
  "compression-webpack-plugin": "^10.0.0",
31
31
  "html-webpack-plugin": "^5.5.0",
32
32
  "http-server": "^14.1.1",
33
- "jsdom": "^20.0.1",
33
+ "jsdom": "^20.0.2",
34
34
  "jsdom-global": "^3.0.2",
35
35
  "mocha": "^10.1.0",
36
- "npm-check-updates": "^16.3.13",
36
+ "npm-check-updates": "^16.3.16",
37
37
  "nyc": "^15.1.0",
38
38
  "replace-in-file": "^6.3.5",
39
39
  "rxjs": "^7.5.7",
@@ -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.17",
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.19"
51
+ "mona-dish": "0.23.2"
52
52
  }
53
53
  }
@@ -24,6 +24,8 @@ export const P_VIEWROOT = "jakarta.faces.ViewRoot";
24
24
  export const P_VIEWHEAD = "jakarta.faces.ViewHead";
25
25
  export const P_VIEWBODY = "jakarta.faces.ViewBody";
26
26
 
27
+ export const P_RESOURCE = "jakarta.faces.Resource";
28
+
27
29
  /*some useful definitions*/
28
30
 
29
31
  export const EMPTY_FUNC = Object.freeze(() => {
@@ -156,6 +158,10 @@ export const CMD_REDIRECT = "redirect";
156
158
  export const UPDATE_FORMS = "_updateForms";
157
159
  export const UPDATE_ELEMS = "_updateElems";
158
160
 
161
+ //we want the head elements to be processed before we process the body
162
+ //but after the inner html is done
163
+ export const DEFERRED_HEAD_INSERTS = "_headElems";
164
+
159
165
  export const MYFACES = "myfaces";
160
166
 
161
167
  export const SEL_SCRIPTS_STYLES = "script, style, link";
@@ -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
 
@@ -132,6 +134,8 @@ export class ExtDomquery extends DQ {
132
134
  return null;
133
135
  }
134
136
 
137
+
138
+
135
139
  private extractNonce(curScript: DomQuery) {
136
140
  return (curScript.getAsElem(0).value as HTMLElement)?.nonce ?? curScript.attr("nonce").value;
137
141
  }
@@ -160,18 +164,70 @@ export class ExtDomquery extends DQ {
160
164
  return new ExtDomquery(super.globalEval(code, nonce ?? this.nonce));
161
165
  }
162
166
 
167
+ globalEvalSticky(code: string, nonce ?: string): DQ {
168
+ return new ExtDomquery(super.globalEvalSticky(code, nonce ?? this.nonce));
169
+ }
170
+
163
171
  /**
164
172
  * decorated run scripts which takes our jsf extensions into consideration
165
173
  * (standard DomQuery will let you pass anything)
166
174
  * @param whilteListed
167
175
  */
168
- runScripts(whilteListed?: (src: string) => boolean): DomQuery {
176
+ runScripts(sticky = false, whilteListed?: (src: string) => boolean): DomQuery {
169
177
  const whitelistFunc = (src: string): boolean => {
170
178
  return (whilteListed?.(src) ?? true) && !IS_FACES_SOURCE(src) && !IS_INTERNAL_SOURCE(src);
171
179
  };
172
- return super.runScripts(whitelistFunc);
180
+ return super.runScripts(sticky, whitelistFunc);
181
+ }
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);
173
228
  }
174
229
 
230
+
175
231
  /**
176
232
  * byId producer
177
233
  *
@@ -183,6 +239,8 @@ export class ExtDomquery extends DQ {
183
239
  const ret = DomQuery.byId(selector, deep);
184
240
  return new ExtDomquery(ret);
185
241
  }
242
+
243
+
186
244
  }
187
245
 
188
246
  export const ExtDQ = ExtDomquery;
@@ -32,6 +32,14 @@ export interface IResponseProcessor {
32
32
  */
33
33
  replaceHead(shadowHead: XMLQuery | DQ): void;
34
34
 
35
+
36
+ /**
37
+ * adds new elements to the head
38
+ *
39
+ * @param newElements the elements which need addition
40
+ */
41
+ addToHead(newElements: XMLQuery | DQ): void;
42
+
35
43
  /**
36
44
  * replace the body
37
45
  *
@@ -27,7 +27,8 @@ import {
27
27
  SOURCE,
28
28
  TAG_FORM,
29
29
  UPDATE_ELEMS,
30
- UPDATE_FORMS
30
+ UPDATE_FORMS,
31
+ DEFERRED_HEAD_INSERTS
31
32
  } from "../core/Const";
32
33
  import {ExtConfig} from "../util/ExtDomQuery";
33
34
 
@@ -75,6 +76,7 @@ export function resolveContexts(context: { [p: string]: any }): any {
75
76
  /**
76
77
  * prepare storage for some deferred operations
77
78
  */
79
+ internalContext.assign(DEFERRED_HEAD_INSERTS).value = [];
78
80
  internalContext.assign(UPDATE_FORMS).value = [];
79
81
  internalContext.assign(UPDATE_ELEMS).value = [];
80
82
  return {externalContext, internalContext};
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {Config, DQ, XMLQuery} from "mona-dish";
17
+ import {DQ, XMLQuery} from "mona-dish";
18
18
  import {ResponseProcessor} from "./ResponseProcessor";
19
19
 
20
20
  import {IResponseProcessor} from "./IResponseProcessor";
@@ -28,7 +28,7 @@ import {
28
28
  CMD_EXTENSION,
29
29
  CMD_INSERT,
30
30
  CMD_REDIRECT,
31
- CMD_UPDATE,
31
+ CMD_UPDATE, P_RESOURCE,
32
32
  P_VIEWBODY,
33
33
  P_VIEWHEAD,
34
34
  P_VIEWROOT,
@@ -205,6 +205,10 @@ export module Response {
205
205
  responseProcessor.replaceBody(DQ.fromMarkup(cdataBlock));
206
206
  break;
207
207
 
208
+ case $nsp(P_RESOURCE):
209
+ responseProcessor.addToHead(DQ.fromMarkup(cdataBlock))
210
+ break;
211
+
208
212
  default://htmlItem replacement
209
213
  responseProcessor.update(node, cdataBlock);
210
214
  break;
@@ -51,7 +51,8 @@ import {
51
51
  TAG_FORM,
52
52
  TAG_HEAD,
53
53
  UPDATE_ELEMS,
54
- UPDATE_FORMS
54
+ UPDATE_FORMS,
55
+ DEFERRED_HEAD_INSERTS
55
56
  } from "../core/Const";
56
57
  import trim = Lang.trim;
57
58
  import {ExtConfig, ExtDomquery} from "../util/ExtDomQuery";
@@ -86,7 +87,7 @@ export class ResponseProcessor implements IResponseProcessor {
86
87
  return;
87
88
  }
88
89
 
89
- let oldHead = DQ.querySelectorAll(TAG_HEAD);
90
+ let oldHead = ExtDomquery.querySelectorAll(TAG_HEAD);
90
91
 
91
92
  //delete all to avoid script and style overlays
92
93
  oldHead.querySelectorAll(SEL_SCRIPTS_STYLES).delete();
@@ -95,8 +96,17 @@ export class ResponseProcessor implements IResponseProcessor {
95
96
  // eval means the scripts will get attached (eval script attach method)
96
97
  // but this is done by DomQuery not in this code
97
98
  this.storeForEval(shadowHead);
99
+ //incoming either the outer head tag or its childs
100
+ //shadowHead = (shadowHead.tagName.value === "HEAD") ? shadowHead.childNodes : shadowHead;
101
+ //this.addToHead(shadowHead);
98
102
  }
99
103
 
104
+ addToHead(newElements: XMLQuery | DQ) {
105
+ this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(newElements);
106
+ }
107
+
108
+
109
+
100
110
  /**
101
111
  * replaces the body in the expected manner
102
112
  * which means the entire body content is refreshed
@@ -114,7 +124,7 @@ export class ResponseProcessor implements IResponseProcessor {
114
124
 
115
125
  let shadowInnerHTML: string = <string>shadowBody.html().value;
116
126
 
117
- let resultingBody = <DQ>DQ.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
127
+ let resultingBody = <DQ>ExtDomquery.querySelectorAll(TAG_BODY).html(shadowInnerHTML);
118
128
  let updateForms = resultingBody.querySelectorAll(TAG_FORM);
119
129
 
120
130
  // main difference, we cannot replace the body itself, but only its content
@@ -130,7 +140,7 @@ export class ResponseProcessor implements IResponseProcessor {
130
140
  * @param node the node to eval
131
141
  */
132
142
  eval(node: XMLQuery) {
133
- DQ.globalEval(node.cDATAAsString);
143
+ ExtDomquery.globalEval(node.cDATAAsString);
134
144
  }
135
145
 
136
146
  /**
@@ -303,8 +313,14 @@ export class ResponseProcessor implements IResponseProcessor {
303
313
  * generic global eval which runs the embedded css and scripts
304
314
  */
305
315
  globalEval() {
316
+ // phase one, if we have head inserts, we build up those before going into the script eval phase
317
+ let insertHeadElems = new ExtDomquery(...this.internalContext.getIf(DEFERRED_HEAD_INSERTS).value);
318
+ insertHeadElems.runHeadInserts(true);
319
+
320
+ // phase 2 we run a script eval on all updated elements in the body
306
321
  let updateElems = new ExtDomquery(...this.internalContext.getIf(UPDATE_ELEMS).value);
307
322
  updateElems.runCss();
323
+ // phase 3, we do the same for the css
308
324
  updateElems.runScripts();
309
325
  }
310
326
 
@@ -433,6 +449,11 @@ export class ResponseProcessor implements IResponseProcessor {
433
449
  this.internalContext.assign(UPDATE_ELEMS).value.push(toBeEvaled);
434
450
  }
435
451
 
452
+ // head eval is always sticky
453
+ private storeForHeadEval(toBeEvaled: DQ, sticky) {
454
+ this.internalContext.assign(DEFERRED_HEAD_INSERTS).value.push(toBeEvaled);
455
+ }
456
+
436
457
  /**
437
458
  * check whether a given XMLQuery node is an explicit viewstate node
438
459
  *
@@ -463,4 +484,5 @@ export class ResponseProcessor implements IResponseProcessor {
463
484
  this.externalContext.getIf(ON_ERROR).orElse(this.internalContext.getIf(ON_ERROR).value).orElse(EMPTY_FUNC).value(errorData);
464
485
  }
465
486
 
487
+
466
488
  }