jsf.js_next_gen 1.0.0-beta-18 → 1.0.0-beta-20

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 (92) hide show
  1. package/README.md +5 -2
  2. package/dist/docs/assets/search.js +1 -1
  3. package/dist/docs/functions/myfaces.ab.html +1 -0
  4. package/dist/docs/index.html +5 -2
  5. package/dist/docs/modules/myfaces.html +5 -0
  6. package/dist/docs/variables/myfaces.oam.html +50 -0
  7. package/dist/window/jsf-development.js +204 -13
  8. package/dist/window/jsf-development.js.map +1 -1
  9. package/dist/window/jsf.js +2 -2
  10. package/dist/window/jsf.js.br +0 -0
  11. package/dist/window/jsf.js.gz +0 -0
  12. package/dist/window/jsf.js.map +1 -1
  13. package/package.json +1 -1
  14. package/remap.js +1 -1
  15. package/remap.js.map +1 -1
  16. package/remap.ts +1 -1
  17. package/src/main/typescript/api/Jsf.ts +8 -10
  18. package/src/main/typescript/impl/AjaxImpl.ts +1 -1
  19. package/src/main/typescript/impl/PushImpl.ts +16 -0
  20. package/src/main/typescript/impl/util/Assertions.ts +15 -0
  21. package/src/main/typescript/impl/util/AsyncQueue.ts +15 -0
  22. package/src/main/typescript/impl/util/ExtDomQuery.ts +15 -0
  23. package/src/main/typescript/impl/util/IListener.ts +18 -0
  24. package/src/main/typescript/impl/xhrCore/ErrorData.ts +15 -0
  25. package/src/main/typescript/impl/xhrCore/EventData.ts +15 -0
  26. package/src/main/typescript/impl/xhrCore/IResponseProcessor.ts +15 -0
  27. package/src/main/typescript/impl/xhrCore/Response.ts +5 -6
  28. package/src/main/typescript/myfaces/OamSubmit.ts +119 -0
  29. package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +0 -5
  30. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +8 -4
  31. package/src/main/typescript/test/impl/SeparatorCharsTest.spec.ts +0 -1
  32. package/src/main/typescript/test/myfaces/OamSubmit.spec.ts +141 -0
  33. package/src/main/typescript/test/xhrCore/FakeWebsocket.ts +15 -0
  34. package/src/main/typescript/test/xhrCore/FileUploadTest.spec.ts +15 -0
  35. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +15 -0
  36. package/src/main/typescript/test/xhrCore/WebsocketTest.ts +15 -0
  37. package/src/main/typescript/tsconfig.json +1 -0
  38. package/target/api/Jsf.js +6 -5
  39. package/target/api/Jsf.js.map +1 -1
  40. package/target/impl/PushImpl.js +17 -2
  41. package/target/impl/PushImpl.js.map +1 -1
  42. package/target/impl/util/Assertions.js +15 -0
  43. package/target/impl/util/Assertions.js.map +1 -1
  44. package/target/impl/util/AsyncQueue.js.map +1 -1
  45. package/target/impl/util/ExtDomQuery.js +15 -0
  46. package/target/impl/util/ExtDomQuery.js.map +1 -1
  47. package/target/impl/util/IListener.js +3 -0
  48. package/target/impl/util/IListener.js.map +1 -0
  49. package/target/impl/xhrCore/ErrorData.js +15 -0
  50. package/target/impl/xhrCore/ErrorData.js.map +1 -1
  51. package/target/impl/xhrCore/EventData.js +15 -0
  52. package/target/impl/xhrCore/EventData.js.map +1 -1
  53. package/target/impl/xhrCore/Response.js +5 -5
  54. package/target/impl/xhrCore/Response.js.map +1 -1
  55. package/target/myfaces/OamSubmit.js +105 -0
  56. package/target/myfaces/OamSubmit.js.map +1 -0
  57. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +24 -1
  58. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
  59. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +0 -5
  60. package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
  61. package/target/test/frameworkBase/_ext/shared/StandardInits.js +35 -6
  62. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  63. package/target/test/impl/ImplTest.spec.js +24 -1
  64. package/target/test/impl/ImplTest.spec.js.map +1 -1
  65. package/target/test/impl/SeparatorCharsTest.spec.js +24 -2
  66. package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
  67. package/target/test/myfaces/OamSubmit.spec.js +125 -0
  68. package/target/test/myfaces/OamSubmit.spec.js.map +1 -0
  69. package/target/test/queue/AsynchronousQueueTest.spec.js +24 -1
  70. package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
  71. package/target/test/xhrCore/EventTests.spec.js +24 -1
  72. package/target/test/xhrCore/EventTests.spec.js.map +1 -1
  73. package/target/test/xhrCore/FakeWebsocket.js +15 -0
  74. package/target/test/xhrCore/FakeWebsocket.js.map +1 -1
  75. package/target/test/xhrCore/FileUploadTest.spec.js +39 -1
  76. package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
  77. package/target/test/xhrCore/RequestParamsTest.spec.js +39 -1
  78. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  79. package/target/test/xhrCore/RequestTest.spec.js +24 -1
  80. package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
  81. package/target/test/xhrCore/ResponseTest.spec.js +24 -1
  82. package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
  83. package/target/test/xhrCore/ShadowDomTest.spec.js +24 -1
  84. package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
  85. package/target/test/xhrCore/WebsocketTest.js +39 -1
  86. package/target/test/xhrCore/WebsocketTest.js.map +1 -1
  87. package/target/test/xhrCore/XhrFormDataTest.spec.js +24 -1
  88. package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
  89. package/webpack.config.js +0 -7
  90. package/webpack.config.js.map +1 -1
  91. package/webpack.config.ts +0 -7
  92. package/src/main/typescript/impl/util/ListenerQueue.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsf.js_next_gen",
3
- "version": "1.0.0-beta-18",
3
+ "version": "1.0.0-beta-20",
4
4
  "description": "A next generation typescript reimplementation of jsf.js",
5
5
  "main": "dist/window/jsf.js",
6
6
  "scripts": {
package/remap.js CHANGED
@@ -31,7 +31,7 @@ var option = {
31
31
  //development
32
32
  files: 'dist/**/*.js',
33
33
  from: (buildStage == "-development") ? /jsf-development.js\.map/g : /jsf.js\.map/g,
34
- to: "jsf".concat(buildStage, ".js.map\n//# sourceMappingURL=jsf").concat(buildStage, ".js.map.jsf?ln=scripts")
34
+ to: "jsf".concat(buildStage, ".js.map\n//# sourceMappingURL=jsf").concat(buildStage, ".js.map.jsf?ln=javax.faces")
35
35
  };
36
36
  try {
37
37
  var result = replace.sync(option);
package/remap.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"remap.js","sourceRoot":"","sources":["remap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH,2EAA2E;AAC3E,uDAAuD;AACvD,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE3C,sCAAsC;AACtC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,sCAAsC;AACtC,IAAM,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAEtD,IAAI,MAAM,GAAG;IACT,aAAa;IACb,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,CAAC,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,cAAc;IAClF,EAAE,EAAE,aAAM,UAAU,8CAAoC,UAAU,2BAAwB;CAC7F,CAAA;AAED,IAAI;IACA,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CAC/C;AAAC,OAAO,KAAK,EAAE;IACZ,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;CAC3C"}
1
+ {"version":3,"file":"remap.js","sourceRoot":"","sources":["remap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;GAKG;AAEH,2EAA2E;AAC3E,uDAAuD;AACvD,IAAM,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE3C,sCAAsC;AACtC,IAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,sCAAsC;AACtC,IAAM,UAAU,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AAEtD,IAAI,MAAM,GAAG;IACT,aAAa;IACb,KAAK,EAAE,cAAc;IACrB,IAAI,EAAE,CAAC,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,cAAc;IAClF,EAAE,EAAE,aAAM,UAAU,8CAAoC,UAAU,+BAA4B;CACjG,CAAA;AAED,IAAI;IACA,IAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;CAC/C;AAAC,OAAO,KAAK,EAAE;IACZ,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;CAC3C"}
package/remap.ts CHANGED
@@ -35,7 +35,7 @@ let option = {
35
35
  //development
36
36
  files: 'dist/**/*.js',
37
37
  from: (buildStage == "-development") ? /jsf-development.js\.map/g : /jsf.js\.map/g,
38
- to: `jsf${buildStage}.js.map\n//# sourceMappingURL=jsf${buildStage}.js.map.jsf?ln=scripts`
38
+ to: `jsf${buildStage}.js.map\n//# sourceMappingURL=jsf${buildStage}.js.map.jsf?ln=javax.faces`
39
39
  }
40
40
 
41
41
  try {
@@ -18,6 +18,8 @@
18
18
 
19
19
  import {Implementation} from "../impl/AjaxImpl";
20
20
  import {PushImpl} from "../impl/PushImpl";
21
+ import {oam as _oam} from "../myfaces/OamSubmit";
22
+
21
23
 
22
24
  //declare const Implementation: any;
23
25
 
@@ -219,18 +221,9 @@ export module jsf {
219
221
  }
220
222
 
221
223
  }
222
-
223
- //We hook the old namespace system into our npm system
224
- //if ("undefined" == window.jsf) {
225
- // window.jsf = jsf;
226
- //}
227
-
228
-
229
224
  }
230
225
 
231
-
232
-
233
- //fullfill the window contract
226
+ //fullfill the window contract for the myfaces namespace
234
227
  export module myfaces {
235
228
 
236
229
  /**
@@ -258,6 +251,11 @@ export module myfaces {
258
251
 
259
252
  jsf.ajax.request(source, event, options);
260
253
  }
254
+
255
+ /**
256
+ * legacy oam functions
257
+ */
258
+ export const oam = _oam;
261
259
  }
262
260
 
263
261
 
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- import {IListener} from "./util/ListenerQueue";
17
+ import {IListener} from "./util/IListener";
18
18
  import {Response} from "./xhrCore/Response";
19
19
  import {XhrRequest} from "./xhrCore/XhrRequest";
20
20
  import {AsynchronousQueue} from "./util/AsyncQueue";
@@ -1,3 +1,19 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
1
17
  /**
2
18
  * Typescript port of the jsf.push part in the myfaces implementation
3
19
  */
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {Config, Lang, XMLQuery} from "mona-dish";
2
17
 
3
18
  import {DQ} from "mona-dish";
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {AsyncRunnable} from "./AsyncRunnable";
2
17
 
3
18
  /**
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {Config, IValueHolder, Optional, DomQuery, DQ} from "mona-dish";
2
17
  import {P_WINDOW_ID} from "../core/Const";
3
18
 
@@ -0,0 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export interface IListener<T> {
17
+ (data: T): void;
18
+ }
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {
2
17
  EMPTY_STR,
3
18
  ERROR_MESSAGE,
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {Config, DQ} from "mona-dish";
2
17
  import {BEGIN, CTX_PARAM_PASS_THR, EVENT, P_PARTIAL_SOURCE, SOURCE} from "../core/Const";
3
18
 
@@ -1,3 +1,18 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
1
16
  import {XMLQuery} from "mona-dish";
2
17
  // noinspection TypeScriptPreferShortImport
3
18
  import {DQ} from "mona-dish";
@@ -52,7 +52,7 @@ export module Response {
52
52
  * and processing its tags
53
53
  *
54
54
  * @param {XMLHttpRequest} request (xhrRequest) - xhr request object
55
- * @param ASSOC_ARR<any> context (Map) - AJAX context
55
+ * @param context {Context} context (Map) - AJAX context
56
56
  *
57
57
  */
58
58
  export function processResponse(request: XMLHttpRequest, context: Context) {
@@ -90,7 +90,7 @@ export module Response {
90
90
  const SEL_SUB_TAGS = [CMD_ERROR, CMD_REDIRECT, CMD_CHANGES].join(",");
91
91
 
92
92
  //now we can process the main operations
93
- node.getIf(SEL_SUB_TAGS).each((node: XMLQuery) => {
93
+ node.querySelectorAll(SEL_SUB_TAGS).each((node: XMLQuery) => {
94
94
  switch (node.tagName.value) {
95
95
  case CMD_ERROR:
96
96
  responseProcessor.error(node);
@@ -123,8 +123,8 @@ export module Response {
123
123
  * @param responseProcessor
124
124
  */
125
125
  function processChangesTag(node: XMLQuery, responseProcessor: IResponseProcessor): boolean {
126
- const ALLOWED_TAGS = [CMD_UPDATE, CMD_EVAL, CMD_INSERT, CMD_DELETE, CMD_ATTRIBUTES, CMD_EXTENSION].join(",");
127
- node.getIf(ALLOWED_TAGS).each(
126
+ const ALLOWED_TAGS = [CMD_UPDATE, CMD_EVAL, CMD_INSERT, CMD_DELETE, CMD_ATTRIBUTES, CMD_EXTENSION].join(", ");
127
+ node.querySelectorAll(ALLOWED_TAGS).each(
128
128
  (node: XMLQuery) => {
129
129
  switch (node.tagName.value) {
130
130
  case CMD_UPDATE:
@@ -168,7 +168,7 @@ export module Response {
168
168
  }
169
169
 
170
170
  /**
171
- * branch tag update.. drill further down into the updates
171
+ * branch tag update. drill further down into the updates
172
172
  * special case viewstate in that case it is a leaf
173
173
  * and the viewstate must be processed
174
174
  *
@@ -206,7 +206,6 @@ export module Response {
206
206
  default://htmlItem replacement
207
207
  responseProcessor.update(node, cdataBlock);
208
208
  break;
209
-
210
209
  }
211
210
  }
212
211
  }
@@ -0,0 +1,119 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {DQ, Stream} from "mona-dish";
18
+
19
+ /**
20
+ * legacy code to enable various aspects
21
+ * of myfaces, used to be rendered inline
22
+ * for jsf 2.0 we can externalize it into its own custom resource
23
+ *
24
+ * note this is a straight 1:1 port from the existing codebase
25
+ * (not too much work has been spent here, the important thing is, that
26
+ * the namespace and functions need to be kept intact for legacy code)
27
+ *
28
+ * we might move the code over in the future, but for now a straight 1:1 port suffices
29
+ */
30
+ declare const window: any;
31
+ declare const myfaces: any;
32
+
33
+ //TODO add unit tests to check all this here that it works just as before
34
+ export module oam {
35
+ /**
36
+ * sets a hidden input field
37
+ * @param formName the formName
38
+ * @param name the hidden field
39
+ * @param value the value to be rendered
40
+ */
41
+ export const setHiddenInput = function (formName: string, name: string, value: string) {
42
+ DQ.byId(document.forms[formName])
43
+ .each(form => {
44
+ const input = form.querySelectorAll(`input[type='hidden'][name='${name}']`);
45
+ if (input.isPresent()) {
46
+ input.inputValue.value = value;
47
+ } else {
48
+ const newInput = DQ.fromMarkup(`<input type='hidden' id='${name}' name='${name}'>`);
49
+ newInput.inputValue.value = value;
50
+ newInput.appendTo(form);
51
+ }
52
+ });
53
+ };
54
+
55
+ /**
56
+ * clears a hidden input field
57
+ *
58
+ * @param formName formName for the input
59
+ * @param name the name of the input field
60
+ */
61
+ export const clearHiddenInput = function (formName: string, name: string) {
62
+ let element = document.forms?.[formName]?.elements?.[name];
63
+ if(!element) {
64
+ return;
65
+ }
66
+ DQ.byId(element).delete();
67
+ };
68
+
69
+ // noinspection JSUnusedGlobalSymbols
70
+ /**
71
+ * does special form submit remapping
72
+ * re-maps the issuing command link into something,
73
+ * a decode of the command link on the server can understand
74
+ *
75
+ * @param formName
76
+ * @param linkId
77
+ * @param target
78
+ * @param params
79
+ */
80
+ export const submitForm = function (formName: string, linkId: string, target: string, params: { [key: string]: any }) {
81
+ let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
82
+ window?.[clearFn]?.(formName);
83
+
84
+ //autoscroll code
85
+ if (window?.myfaces?.core?.config?.autoScroll && window?.getScrolling) {
86
+ myfaces.oam.setHiddenInput(formName, 'autoScroll', window?.getScrolling());
87
+ }
88
+ Stream.ofAssoc(params).each((param: [string, any]) => {
89
+ myfaces.oam.setHiddenInput(formName, param[0], param[1]);
90
+ });
91
+
92
+ //we call the namespaced function, to allow decoration, via a direct call we would
93
+ myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
94
+
95
+ DQ.byId(document.forms[formName]).each(form => {
96
+ const ATTR_TARGET = "target";
97
+ const formElement = form.getAsElem(0).value as HTMLFormElement;
98
+ const oldTarget = form.attr(ATTR_TARGET).value;
99
+ form.attr(ATTR_TARGET).value = target;
100
+
101
+ const result = formElement?.onsubmit?.(null);
102
+
103
+ try {
104
+ if ((!!result) || 'undefined' == typeof result) {
105
+ formElement.submit();
106
+ }
107
+ } catch (e) {
108
+ window?.console.error(e);
109
+ }
110
+
111
+ form.attr(ATTR_TARGET).value = oldTarget;
112
+ Stream.ofAssoc(params).each((param: [string, any]) => {
113
+ myfaces.oam.clearHiddenInput(formName, param[0]);
114
+ });
115
+ myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
116
+ });
117
+ return false;
118
+ };
119
+ }
@@ -119,7 +119,6 @@ describe('Config tests', () => {
119
119
  it('array config', () => {
120
120
  let config = setup();
121
121
  config.assign("hello[5]", "world[3]", "from[5]").value = "me";
122
- console.debug(JSON.stringify(config.toJson()));
123
122
  expect(config.getIf("hello[5]", "world[3]", "from[5]").value).to.be.eq("me");
124
123
  expect(config.value.hello[5].world[3].from[5]).to.be.eq("me");
125
124
  structure(config.value);
@@ -129,7 +128,6 @@ describe('Config tests', () => {
129
128
  let config = setup();
130
129
  config.assign("[5]", "world[3]", "from").value = "me";
131
130
  expect(config.getIf("[5]", "world[3]", "from").value).to.be.eq("me");
132
- console.debug(JSON.stringify(config.toJson()));
133
131
  expect(config.value[5].world[3].from).to.be.eq("me");
134
132
  structureBroken(config.value);
135
133
  });
@@ -138,7 +136,6 @@ describe('Config tests', () => {
138
136
  let config = setup();
139
137
  config.assign("[5]", "[3]", "from").value = "me";
140
138
  expect(config.getIf("[5]", "[3]", "from").value).to.be.eq("me");
141
- console.debug(JSON.stringify(config.toJson()));
142
139
  expect(config.value[5][3].from).to.be.eq("me");
143
140
  structureBroken(config.value);
144
141
  });
@@ -147,7 +144,6 @@ describe('Config tests', () => {
147
144
  let config = setup();
148
145
  config.assign("[5]", "[3]", "[2]").value = "me";
149
146
  expect(config.getIf("[5]", "[3]", "[2]").value).to.be.eq("me");
150
- console.debug(JSON.stringify(config.toJson()));
151
147
  expect(config.value[5][3][2]).to.be.eq("me");
152
148
  structureBroken(config.value);
153
149
  });
@@ -156,7 +152,6 @@ describe('Config tests', () => {
156
152
  let config = setup();
157
153
  config.assign("[5]", "world[3]", "from[2]").value = "me";
158
154
  expect(config.getIf("[5]", "world[3]", "from[2]").value).to.be.eq("me");
159
- console.debug(JSON.stringify(config.toJson()));
160
155
  expect(config.value[5].world[3].from[2]).to.be.eq("me");
161
156
  structureBroken(config.value);
162
157
  });
@@ -19,6 +19,7 @@ import {DomQuery} from "mona-dish";
19
19
 
20
20
  declare let global;
21
21
  declare let jsf: any;
22
+ declare let myfaces: any;
22
23
 
23
24
  /**
24
25
  * helpers with various init and html patterns
@@ -222,8 +223,6 @@ export module StandardInits {
222
223
  var target = "./test.mockup";
223
224
 
224
225
  function emitPPR(source, event, action, useIframe, formName) {
225
- debugger;
226
- console.debug("emitting;");
227
226
  document.getElementById(formName || "form1").action = target;
228
227
 
229
228
  jsf.ajax.request(/*String|Dom Node*/ source, /*|EVENT|*/ (window.event) ? window.event : event, /*{|OPTIONS|}*/ {op: action});
@@ -298,7 +297,9 @@ export module StandardInits {
298
297
  */
299
298
  let applyJsfToGlobals = function (data, Implementation, PushImpl) {
300
299
  (<any>global).jsf = data.jsf;
300
+ (<any>global).myfaces = data.myfaces;
301
301
  (<any>global).window.jsf = data.jsf;
302
+ (<any>global).window.myfaces = data.myfaces;
302
303
  (<any>global).Implementation = Implementation.Implementation;
303
304
  (<any>global).PushImpl = PushImpl.PushImpl;
304
305
  //bypass a bug on windows jsdom, domparser not an auto global but on window only
@@ -314,10 +315,12 @@ export module StandardInits {
314
315
  let initJSDOM = async function (template: string) {
315
316
  // @ts-ignore
316
317
  return import('jsdom-global').then((domIt) => {
317
- return domIt(template, {
318
+ let params = {
318
319
  contentType: "text/html",
319
320
  runScripts: "dangerously"
320
- });
321
+ };
322
+ //we have two different apis depending whether we allow module interop with sinon or not
323
+ return domIt?.default?.(template, params) ?? domIt?.(template, params);
321
324
  });
322
325
  };
323
326
 
@@ -343,6 +346,7 @@ export module StandardInits {
343
346
  (<any>global)?.PushImpl?.reset();
344
347
 
345
348
  delete (<any>global).jsf;
349
+ delete (<any>global).myfaces;
346
350
  delete (<any>global).Implementation;
347
351
  delete (<any>global).PushImpl;
348
352
  };
@@ -51,7 +51,6 @@ describe('various tests for get separator char', () => {
51
51
  waitForResult.then((close) => {
52
52
  try {
53
53
  let separator = Implementation.getSeparatorChar();
54
- console.debug("sep:", separator);
55
54
  expect(separator).to.eq("$");
56
55
  done();
57
56
  } finally {
@@ -0,0 +1,141 @@
1
+ /* Licensed to the Apache Software Foundation (ASF) under one or more
2
+ * contributor license agreements. See the NOTICE file distributed with
3
+ * this work for additional information regarding copyright ownership.
4
+ * The ASF licenses this file to you under the Apache License, Version 2.0
5
+ * (the "License"); you may not use this file except in compliance with
6
+ * the License. You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {describe, it} from "mocha";
18
+
19
+ import {expect} from "chai";
20
+ import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
21
+ import defaultMyFaces = StandardInits.defaultMyFaces;
22
+ import {oam} from "../../myfaces/OamSubmit";
23
+ import setHiddenInput = oam.setHiddenInput;
24
+ import {DomQuery} from "mona-dish";
25
+ import clearHiddenInput = oam.clearHiddenInput;
26
+ import submitForm = oam.submitForm;
27
+ import Sinon from "sinon";
28
+
29
+
30
+ declare var myfaces: any;
31
+
32
+ /**
33
+ * specialized tests testing the xhr core behavior when it hits the xmlHttpRequest object
34
+ */
35
+ describe('Tests on the xhr core when it starts to call the request', function () {
36
+
37
+ beforeEach(() => {
38
+ return defaultMyFaces();
39
+ })
40
+
41
+ it('namespace must exist', function() {
42
+ expect(!!myfaces?.oam).to.eq(true);
43
+ expect(!!myfaces?.oam?.setHiddenInput).to.eq(true);
44
+ expect(!!myfaces?.oam?.clearHiddenInput).to.eq(true);
45
+ expect(!!myfaces?.oam?.submitForm).to.eq(true);
46
+ });
47
+
48
+ it('hidden input setting must work', function() {
49
+ let FORM_ID = "blarg";
50
+ setHiddenInput(FORM_ID, "new_hidden", "hiddenvalue");
51
+ expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").isPresent());
52
+ expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").inputValue.value).to.eq("hiddenvalue");
53
+ })
54
+
55
+ it('resetting the hidden input must work', function() {
56
+ let FORM_ID = "blarg";
57
+ setHiddenInput(FORM_ID, "new_hidden", "hiddenvalue");
58
+ clearHiddenInput(FORM_ID, "new_hidden");
59
+ expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").isAbsent()).to.eq(true);
60
+ })
61
+
62
+ it('submit form must work', function() {
63
+ let FORM_ID = "blarg";
64
+ let form = DomQuery.byId(FORM_ID);
65
+ let submitCalled;
66
+ (form.value.value as any).submit = () => {
67
+ submitCalled = true;
68
+ expect(form.querySelectorAll('input[name=\'booga1\']').isPresent()).to.eq(true);
69
+ expect(form.querySelectorAll('input[name=\'booga1\']').length == 1).to.eq(true);
70
+ expect(form.querySelectorAll('input[name=\'booga1\']').inputValue.value == 'val_booga1').to.eq(true);
71
+ expect(form.querySelectorAll('input[name=\'booga2\']').isPresent()).to.eq(true);
72
+ expect(form.querySelectorAll('input[name=\'booga2\']').length == 1).to.eq(true);
73
+ expect(form.querySelectorAll('input[name=\'booga2\']').inputValue.value == 'val_booga2').to.eq(true);
74
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isPresent()).to.eq(true);
75
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).length == 1).to.eq(true);
76
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).inputValue.value == 'mylink').to.eq(true);
77
+ expect(form.attr("target").value).to.eq('target1');
78
+ }
79
+
80
+
81
+ submitForm(FORM_ID, 'mylink', 'target1', {
82
+ booga1: "val_booga1",
83
+ booga2: "val_booga2"
84
+ });
85
+
86
+ expect(submitCalled).to.eq(true);
87
+ form = DomQuery.byId(FORM_ID);
88
+ expect(form.querySelectorAll('input[name=\'booga1\']').isAbsent()).to.eq(true);
89
+ expect(form.querySelectorAll('input[name=\'booga2\']').isAbsent()).to.eq(true);
90
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isAbsent()).to.eq(true);
91
+
92
+ //const os_spy = Sinon.spy(form.getAsElem(0).value, 'onsubmit' as keyof Element);
93
+ const submit_spy = Sinon.spy(form.getAsElem(0).value, 'submit' as keyof Element);
94
+ expect
95
+
96
+ //we also have to interceot onsbumit
97
+ // expect(os_spy.called).to.eq(true);
98
+ // expect(submit_spy.called).to.eq(true);
99
+ })
100
+
101
+ it('onsubmit form must work', function() {
102
+ let FORM_ID = "blarg";
103
+ let form = DomQuery.byId(FORM_ID);
104
+ let onSubmitCalled;
105
+ (form.value.value as any).onsubmit = () => {
106
+ onSubmitCalled = true;
107
+ expect(form.querySelectorAll('input[name=\'booga1\']').isPresent()).to.eq(true);
108
+ expect(form.querySelectorAll('input[name=\'booga1\']').length == 1).to.eq(true);
109
+ expect(form.querySelectorAll('input[name=\'booga1\']').inputValue.value == 'val_booga1').to.eq(true);
110
+ expect(form.querySelectorAll('input[name=\'booga2\']').isPresent()).to.eq(true);
111
+ expect(form.querySelectorAll('input[name=\'booga2\']').length == 1).to.eq(true);
112
+ expect(form.querySelectorAll('input[name=\'booga2\']').inputValue.value == 'val_booga2').to.eq(true);
113
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isPresent()).to.eq(true);
114
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).length == 1).to.eq(true);
115
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).inputValue.value == 'mylink').to.eq(true);
116
+ expect(form.attr("target").value).to.eq('target1');
117
+ }
118
+
119
+
120
+ submitForm(FORM_ID, 'mylink', 'target1', {
121
+ booga1: "val_booga1",
122
+ booga2: "val_booga2"
123
+ });
124
+
125
+ expect(onSubmitCalled).to.eq(true);
126
+ form = DomQuery.byId(FORM_ID);
127
+ expect(form.querySelectorAll('input[name=\'booga1\']').isAbsent()).to.eq(true);
128
+ expect(form.querySelectorAll('input[name=\'booga2\']').isAbsent()).to.eq(true);
129
+ expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isAbsent()).to.eq(true);
130
+
131
+ //const os_spy = Sinon.spy(form.getAsElem(0).value, 'onsubmit' as keyof Element);
132
+ const submit_spy = Sinon.spy(form.getAsElem(0).value, 'submit' as keyof Element);
133
+ expect
134
+
135
+ //we also have to interceot onsbumit
136
+ // expect(os_spy.called).to.eq(true);
137
+ // expect(submit_spy.called).to.eq(true);
138
+ })
139
+
140
+ // further tests will follow if needed, for now the namespace must be restored
141
+ });