jsf.js_next_gen 4.0.0-beta-9 → 4.0.0-beta-10

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.
package/README.md CHANGED
@@ -3,42 +3,42 @@
3
3
  ## What is this?
4
4
 
5
5
  This project is a work in progress for a next gen typescript based
6
- reimplementation of jsf.js
6
+ reimplementation of jsf.js/faces.js
7
7
 
8
8
  The main goal is maintainability. It omits legacy browsers
9
- with IE11 being the future the baseline for the moment.
9
+ with Edge 14 and Ecmascript 2015 being the browser and ES baseline for the moment.
10
10
 
11
11
  It uses functional constructs on micro scale
12
12
  to keep the maintainability and uses
13
13
  my own [mona-dish](https://github.com/werpu/mona-dish/) project as core framework base, to avoid
14
14
  unnecessary colliding dependencies.
15
15
 
16
- I might roll in MonaDish in the future
17
- via npm, but for now simply having it in the codebase suffices
18
- and prevents collisions with other frameworks.
19
-
20
16
  But it still uses classes modules and inheritance
21
17
  for code structuring.
22
18
  The reason for this is, I do not like the one function for all
23
- approach, Webpack can take care of the packaging.
19
+ approach, especially given we have Typescript now as implementation language
20
+ which allows a proper code structuring and modularization.
21
+
22
+ Webpack can take care of the packaging.
24
23
 
25
- Having smaller code parts makes it easier to test certain
24
+ Having smaller code parts, makes it easier to test certain
26
25
  aspects of the implementation.
27
26
 
28
- Also one additional aspect of the new implementation it has a proper
29
- test coverage via unit tests.
27
+ Also one additional aspect of the new implementation: it has a proper
28
+ test coverage via Mocha based unit tests.
30
29
 
31
30
  This was also severely lacking in my old implementation
32
31
  where I just ran a set of 20 integration tests on macro scale.
33
32
 
34
33
  ## Status
35
34
 
36
- ATM I am function complete, and the code
35
+ ATM I am function in beta bugfixing stage, and the code
37
36
  can be tested (final beta stages)
38
- I probably will make a release before 2022.
37
+ I probably will make a release at the same time MyFaces 4.0
38
+ final hits the scene.
39
39
  It has been testing in MyFaces Tobago now for a year
40
40
  and atm is being integrated into MyFaces as new
41
- JS codebase.
41
+ JS/TS codebase.
42
42
 
43
43
  Addition, for the integration in MyFaces, the api level has been
44
44
  uplifted to Jakarta Faces 4.0
@@ -51,11 +51,31 @@ you simply just need to load the generated. jsf.js file which goes down to 2.3 c
51
51
  while loading faces.js will provide 4.0 compatibility
52
52
 
53
53
  For this reason the version now also in the npm package is 4.0.x
54
+ (the pre changes code can still be reached in the 2.3 branch although
55
+ this branch is basically legacy, given we have the SHIM layer doing both)
56
+
57
+ ### Special info
58
+ Due to a small api change, if you want to embed the 4.0 version (faces.js)
59
+ in your code, a new attribute specified by the Faces 4.0 spec is not set
60
+ at its proper value, *contextpath*. This attribute atm is a value expression
61
+ which needs to be set by the loading implementation.
62
+
63
+ Now if you want to provide your own embedded solution and you will have
64
+ to set this value yourself. While my code does not use the attribute in the faces
65
+ namespace, other libraries or the users might.
66
+
67
+ If you serve the code from MyFaces 4 instead of embedding it, the value will be preset
68
+ by the internal resource loader.
69
+
70
+ The JSF 2.3 version (jsf.js) is not affected by this change, so nothing needs to be done.
71
+ In fact the *contextpath* attribute is not present there.
72
+ All other attributes behave the same in both versions as in the original legacy codebase.
73
+
54
74
 
55
75
 
56
76
  ## Usage
57
77
 
58
- It still is a work in progress, but for testing purposes
78
+ It still is code complete and in bugfixing phase, for testing purposes
59
79
  it can be used (check the dist directory for builds, I consider
60
80
  stable enough for testing, or your own builds)
61
81
 
@@ -103,7 +123,7 @@ so it is gone now
103
123
 
104
124
  * pps disabled for the moment
105
125
 
106
- we had a special pps handling introduced in myfaces, a feature
126
+ We had a special pps handling introduced in myfaces, a feature
107
127
  probably never used (you basically could reduce the parameters
108
128
  sent down by sending a list of pps ids). I have disabled it for the time being.
109
129
  The code still is in there for the moment, but will be dropped
@@ -114,30 +134,28 @@ if no demand arises to enable it again.
114
134
  In order to improve the maintainability I have dropped a lot
115
135
  of shim and legacy code which was needed to support old browsers.
116
136
  Since our main aim is long term maintainability there is a clear cut.
117
- The lowest supported browser for the moment is Internet Explorer 11
118
- older browsers are now cut off. This should suffice for most if
137
+ The lowest supported browser for the moment is Edge 14.
138
+ Older browsers are now cut off. This should suffice for most, if
119
139
  not all important environments. If you still use an older browser than
120
- IE11 you still can revert to the old codebase for the time being
140
+ Edge 14 you still can revert to the old codebase for the time being
121
141
  (final cutoff point probably will come within the next few years)
122
142
 
123
- IE11 might be cut off in the future, depending on the business requirements
124
- by the myfaces users
125
143
 
126
144
  * performance
127
145
 
128
146
  Given that we now have faster browsers and end user devices in the mobile
129
- area than 10 years ago, my main focus was maintainability.
147
+ area than 10 years ago and the spec conformity has improved a lot, my main focus was maintainability.
130
148
  Maintainability and readability now comes before performance. So I sacrificed some
131
149
  of the performance to achieve it.
132
150
  Given that the most critical performance hits do not happen in the ajax area
133
- this is a sacrifice I can live with for the time being.
151
+ this is a sacrifice I can live with, for the time being.
134
152
 
135
153
  * Client side i18n
136
154
 
137
155
  The client side i18n error message translations have become more
138
156
  of a liability than a feature.
139
157
  For the time being all client side errors are reported in english.
140
- I can reintroduce them, if there is a real demand.
141
- But the size and maintainability tradeoff compared to what they
158
+ I can reintroduce them, if there is real demand.
159
+ But the size and maintainability tradeoff, compared to what they
142
160
  bring was not worth it to keep them anymore.
143
161
 
@@ -19,36 +19,36 @@
19
19
  <h2>What is this?</h2>
20
20
  </a>
21
21
  <p>This project is a work in progress for a next gen typescript based
22
- reimplementation of jsf.js</p>
22
+ reimplementation of jsf.js/faces.js</p>
23
23
  <p>The main goal is maintainability. It omits legacy browsers
24
- with IE11 being the future the baseline for the moment.</p>
24
+ with Edge 14 and Ecmascript 2015 being the browser and ES baseline for the moment.</p>
25
25
  <p>It uses functional constructs on micro scale
26
26
  to keep the maintainability and uses
27
27
  my own <a href="https://github.com/werpu/mona-dish/">mona-dish</a> project as core framework base, to avoid
28
28
  unnecessary colliding dependencies.</p>
29
- <p>I might roll in MonaDish in the future
30
- via npm, but for now simply having it in the codebase suffices
31
- and prevents collisions with other frameworks.</p>
32
29
  <p>But it still uses classes modules and inheritance
33
30
  for code structuring.
34
31
  The reason for this is, I do not like the one function for all
35
- approach, Webpack can take care of the packaging.</p>
36
- <p>Having smaller code parts makes it easier to test certain
32
+ approach, especially given we have Typescript now as implementation language
33
+ which allows a proper code structuring and modularization.</p>
34
+ <p>Webpack can take care of the packaging.</p>
35
+ <p>Having smaller code parts, makes it easier to test certain
37
36
  aspects of the implementation.</p>
38
- <p>Also one additional aspect of the new implementation it has a proper
39
- test coverage via unit tests.</p>
37
+ <p>Also one additional aspect of the new implementation: it has a proper
38
+ test coverage via Mocha based unit tests.</p>
40
39
  <p>This was also severely lacking in my old implementation
41
40
  where I just ran a set of 20 integration tests on macro scale.</p>
42
41
 
43
42
  <a href="#status" id="status" style="color: inherit; text-decoration: none;">
44
43
  <h2>Status</h2>
45
44
  </a>
46
- <p>ATM I am function complete, and the code
45
+ <p>ATM I am function in beta bugfixing stage, and the code
47
46
  can be tested (final beta stages)
48
- I probably will make a release before 2022.
47
+ I probably will make a release at the same time MyFaces 4.0
48
+ final hits the scene.
49
49
  It has been testing in MyFaces Tobago now for a year
50
50
  and atm is being integrated into MyFaces as new
51
- JS codebase.</p>
51
+ JS/TS codebase.</p>
52
52
  <p>Addition, for the integration in MyFaces, the api level has been
53
53
  uplifted to Jakarta Faces 4.0
54
54
  Note, this introduces some breaking changes, jsf jas been replaced with jakarta
@@ -57,12 +57,30 @@ so javax.faces.request becomes jakarta.faces.request</p>
57
57
  <p>Note, a shim layer for backwards compatibility has been provided
58
58
  you simply just need to load the generated. jsf.js file which goes down to 2.3 compatibility level
59
59
  while loading faces.js will provide 4.0 compatibility</p>
60
- <p>For this reason the version now also in the npm package is 4.0.x</p>
60
+ <p>For this reason the version now also in the npm package is 4.0.x
61
+ (the pre changes code can still be reached in the 2.3 branch although
62
+ this branch is basically legacy, given we have the SHIM layer doing both)</p>
63
+
64
+ <a href="#special-info" id="special-info" style="color: inherit; text-decoration: none;">
65
+ <h3>Special info</h3>
66
+ </a>
67
+ <p>Due to a small api change, if you want to embed the 4.0 version (faces.js)
68
+ in your code, a new attribute specified by the Faces 4.0 spec is not set
69
+ at its proper value, <em>contextpath</em>. This attribute atm is a value expression
70
+ which needs to be set by the loading implementation.</p>
71
+ <p>Now if you want to provide your own embedded solution and you will have
72
+ to set this value yourself. While my code does not use the attribute in the faces
73
+ namespace, other libraries or the users might.</p>
74
+ <p>If you serve the code from MyFaces 4 instead of embedding it, the value will be preset
75
+ by the internal resource loader.</p>
76
+ <p>The JSF 2.3 version (jsf.js) is not affected by this change, so nothing needs to be done.
77
+ In fact the <em>contextpath</em> attribute is not present there.
78
+ All other attributes behave the same in both versions as in the original legacy codebase.</p>
61
79
 
62
80
  <a href="#usage" id="usage" style="color: inherit; text-decoration: none;">
63
81
  <h2>Usage</h2>
64
82
  </a>
65
- <p>It still is a work in progress, but for testing purposes
83
+ <p>It still is code complete and in bugfixing phase, for testing purposes
66
84
  it can be used (check the dist directory for builds, I consider
67
85
  stable enough for testing, or your own builds)</p>
68
86
 
@@ -118,7 +136,7 @@ so it is gone now</p>
118
136
  <li><p>pps disabled for the moment</p>
119
137
  </li>
120
138
  </ul>
121
- <p>we had a special pps handling introduced in myfaces, a feature
139
+ <p>We had a special pps handling introduced in myfaces, a feature
122
140
  probably never used (you basically could reduce the parameters
123
141
  sent down by sending a list of pps ids). I have disabled it for the time being.
124
142
  The code still is in there for the moment, but will be dropped
@@ -129,30 +147,28 @@ if no demand arises to enable it again.</p>
129
147
  <p>In order to improve the maintainability I have dropped a lot
130
148
  of shim and legacy code which was needed to support old browsers.
131
149
  Since our main aim is long term maintainability there is a clear cut.
132
- The lowest supported browser for the moment is Internet Explorer 11
133
- older browsers are now cut off. This should suffice for most if
150
+ The lowest supported browser for the moment is Edge 14.
151
+ Older browsers are now cut off. This should suffice for most, if
134
152
  not all important environments. If you still use an older browser than
135
- IE11 you still can revert to the old codebase for the time being
153
+ Edge 14 you still can revert to the old codebase for the time being
136
154
  (final cutoff point probably will come within the next few years)</p>
137
- <p>IE11 might be cut off in the future, depending on the business requirements
138
- by the myfaces users</p>
139
155
  <ul>
140
156
  <li>performance</li>
141
157
  </ul>
142
158
  <p>Given that we now have faster browsers and end user devices in the mobile
143
- area than 10 years ago, my main focus was maintainability.
159
+ area than 10 years ago and the spec conformity has improved a lot, my main focus was maintainability.
144
160
  Maintainability and readability now comes before performance. So I sacrificed some
145
161
  of the performance to achieve it.
146
162
  Given that the most critical performance hits do not happen in the ajax area
147
- this is a sacrifice I can live with for the time being.</p>
163
+ this is a sacrifice I can live with, for the time being.</p>
148
164
  <ul>
149
165
  <li>Client side i18n</li>
150
166
  </ul>
151
167
  <p>The client side i18n error message translations have become more
152
168
  of a liability than a feature.
153
169
  For the time being all client side errors are reported in english.
154
- I can reintroduce them, if there is a real demand.
155
- But the size and maintainability tradeoff compared to what they
170
+ I can reintroduce them, if there is real demand.
171
+ But the size and maintainability tradeoff, compared to what they
156
172
  bring was not worth it to keep them anymore.</p>
157
173
  </div></div>
158
174
  <div class="col-4 col-menu menu-sticky-wrap menu-highlight">
@@ -35,7 +35,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
35
35
  });
36
36
  };
37
37
  Object.defineProperty(exports, "__esModule", ({ value: true }));
38
- exports.DQ = exports.DomQueryCollector = exports.DomQuery = exports.ElementAttribute = void 0;
38
+ exports.DQ = exports.DomQueryCollector = exports.DomQuery = exports.Style = exports.ElementAttribute = void 0;
39
39
  const Monad_1 = __webpack_require__(/*! ./Monad */ "./node_modules/mona-dish/src/main/typescript/Monad.ts");
40
40
  const Stream_1 = __webpack_require__(/*! ./Stream */ "./node_modules/mona-dish/src/main/typescript/Stream.ts");
41
41
  const SourcesCollectors_1 = __webpack_require__(/*! ./SourcesCollectors */ "./node_modules/mona-dish/src/main/typescript/SourcesCollectors.ts");
@@ -69,13 +69,36 @@ var Submittables;
69
69
  function waitUntilDom(root, condition, options = { attributes: true, childList: true, subtree: true, timeout: 500, interval: 100 }) {
70
70
  const ret = new Promise((success, error) => {
71
71
  const MUT_ERROR = new Error("Mutation observer timeout");
72
- if ('undefined' != typeof window.MutationObserver) {
72
+ //we do the same but for now ignore the options on the dom query
73
+ //we cannot use absent here, because the condition might search for an absent element
74
+ function findElement(root, condition) {
75
+ let found = null;
76
+ if (condition(root)) {
77
+ return root;
78
+ }
79
+ if (options.childList) {
80
+ found = (condition(root)) ? root : root.childNodes.first(condition).value.value;
81
+ }
82
+ else if (options.subtree) {
83
+ found = (condition(root)) ? root : root.querySelectorAll(" * ").first(condition).value;
84
+ }
85
+ else {
86
+ found = (condition(root)) ? root : null;
87
+ }
88
+ return found;
89
+ }
90
+ let foundElement = root;
91
+ if (foundElement = findElement(foundElement, condition)) {
92
+ success(new DomQuery(foundElement));
93
+ return;
94
+ }
95
+ if ('undefined' != typeof MutationObserver) {
73
96
  const mutTimeout = setTimeout(() => {
74
97
  return error(MUT_ERROR);
75
98
  }, options.timeout);
76
99
  const callback = (mutationList, observer) => {
77
100
  const found = new DomQuery(mutationList.map((mut) => mut.target)).first(condition);
78
- if (found.isPresent()) {
101
+ if (found) {
79
102
  clearTimeout(mutTimeout);
80
103
  success(found);
81
104
  }
@@ -90,19 +113,9 @@ function waitUntilDom(root, condition, options = { attributes: true, childList:
90
113
  });
91
114
  }
92
115
  else { //fallback for legacy browsers without mutation observer
93
- //we do the same but for now ignore the options on the dom query
94
116
  let interval = setInterval(() => {
95
- let found = null;
96
- if (options.childList) {
97
- found = (condition(root)) ? root : root.childNodes.first(condition);
98
- }
99
- else if (options.subtree) {
100
- found = (condition(root)) ? root : root.querySelectorAll(" * ").first(condition);
101
- }
102
- else {
103
- found = (condition(root)) ? root : DomQuery.absent;
104
- }
105
- if (found.isPresent()) {
117
+ let found = findElement(root, condition);
118
+ if (found) {
106
119
  if (timeout) {
107
120
  clearTimeout(timeout);
108
121
  clearInterval(interval);
@@ -150,6 +163,34 @@ class ElementAttribute extends Monad_1.ValueEmbedder {
150
163
  }
151
164
  }
152
165
  exports.ElementAttribute = ElementAttribute;
166
+ class Style extends Monad_1.ValueEmbedder {
167
+ constructor(element, name, defaultVal = null) {
168
+ super(element, name);
169
+ this.element = element;
170
+ this.name = name;
171
+ this.defaultVal = defaultVal;
172
+ }
173
+ get value() {
174
+ let val = this.element.values;
175
+ if (!val.length) {
176
+ return this.defaultVal;
177
+ }
178
+ return val[0].style[this.name];
179
+ }
180
+ set value(value) {
181
+ let val = this.element.values;
182
+ for (let cnt = 0; cnt < val.length; cnt++) {
183
+ val[cnt].style[this.name] = value;
184
+ }
185
+ }
186
+ getClass() {
187
+ return ElementAttribute;
188
+ }
189
+ static fromNullable(value, valueKey = "value") {
190
+ return new ElementAttribute(value, valueKey);
191
+ }
192
+ }
193
+ exports.Style = Style;
153
194
  /**
154
195
  * small helper for the specialized jsf case
155
196
  * @param src
@@ -648,6 +689,9 @@ class DomQuery {
648
689
  attr(attr, defaultValue = null) {
649
690
  return new ElementAttribute(this, attr, defaultValue);
650
691
  }
692
+ style(cssProperty, defaultValue = null) {
693
+ return new Style(this, cssProperty, defaultValue);
694
+ }
651
695
  /**
652
696
  * hasclass, checks for an existing class in the class attributes
653
697
  *
@@ -896,7 +940,6 @@ class DomQuery {
896
940
  if (charSet) {
897
941
  xhr.setRequestHeader("Content-Type", "application/x-javascript; charset:" + charSet);
898
942
  }
899
- xhr.send(null);
900
943
  xhr.onload = (responseData) => {
901
944
  //defer also means we have to process after the ajax response
902
945
  //has been processed
@@ -917,6 +960,7 @@ class DomQuery {
917
960
  throw Error(data);
918
961
  };
919
962
  //since we are synchronous we do it after not with onReadyStateChange
963
+ xhr.send(null);
920
964
  return this;
921
965
  }
922
966
  insertAfter(...toInsertParams) {
@@ -1146,7 +1190,7 @@ class DomQuery {
1146
1190
  }
1147
1191
  }
1148
1192
  catch (e) {
1149
- if (window.console && window.console.error) {
1193
+ if (console && console.error) {
1150
1194
  //not sure if we
1151
1195
  //should use our standard
1152
1196
  //error mechanisms here
Binary file
Binary file