x4js 1.5.17 → 1.5.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 (242) hide show
  1. package/lib/{README.md → README.txt} +0 -0
  2. package/lib/cjs/index.js +39 -103
  3. package/lib/cjs/index.js.map +7 -0
  4. package/lib/esm/index.mjs +39 -87
  5. package/lib/esm/index.mjs.map +7 -0
  6. package/lib/{license.md → licence.md} +0 -0
  7. package/lib/src/MIT-license.md +14 -0
  8. package/lib/{types/action.d.ts → src/action.ts} +64 -33
  9. package/lib/src/alpha.jpg +0 -0
  10. package/lib/src/app_sockets.ts +81 -0
  11. package/lib/src/application.ts +251 -0
  12. package/lib/src/autocomplete.ts +197 -0
  13. package/lib/src/base64.ts +166 -0
  14. package/lib/src/base_component.ts +152 -0
  15. package/lib/src/button.ts +355 -0
  16. package/lib/src/calendar.ts +328 -0
  17. package/lib/src/canvas.ts +505 -0
  18. package/lib/src/cardview.ts +227 -0
  19. package/lib/src/checkbox.ts +188 -0
  20. package/lib/src/color.ts +752 -0
  21. package/lib/src/colorpicker.ts +1639 -0
  22. package/lib/src/combobox.ts +465 -0
  23. package/lib/src/component.ts +2329 -0
  24. package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
  25. package/lib/src/datastore.ts +1322 -0
  26. package/lib/src/dialog.ts +656 -0
  27. package/lib/src/dom_events.ts +315 -0
  28. package/lib/src/drag_manager.ts +199 -0
  29. package/lib/src/drawtext.ts +355 -0
  30. package/lib/src/fileupload.ts +213 -0
  31. package/lib/src/form.ts +375 -0
  32. package/lib/src/formatters.ts +105 -0
  33. package/lib/src/gridview.ts +1185 -0
  34. package/lib/src/i18n.ts +346 -0
  35. package/lib/src/icon.ts +335 -0
  36. package/lib/src/image.ts +204 -0
  37. package/lib/src/index.ts +89 -0
  38. package/lib/src/input.ts +249 -0
  39. package/lib/src/label.ts +128 -0
  40. package/lib/src/layout.ts +430 -0
  41. package/lib/src/link.ts +86 -0
  42. package/lib/src/listview.ts +765 -0
  43. package/lib/{esm/md5.js → src/md5.ts} +438 -403
  44. package/lib/src/menu.ts +425 -0
  45. package/lib/src/messagebox.ts +224 -0
  46. package/lib/src/panel.ts +86 -0
  47. package/lib/src/popup.ts +494 -0
  48. package/lib/src/property_editor.ts +337 -0
  49. package/lib/src/radiobtn.ts +197 -0
  50. package/lib/src/rating.ts +135 -0
  51. package/lib/src/request.ts +300 -0
  52. package/lib/src/router.ts +185 -0
  53. package/lib/src/settings.ts +77 -0
  54. package/lib/src/sidebarview.ts +103 -0
  55. package/lib/src/spreadsheet.ts +1449 -0
  56. package/lib/src/styles.ts +343 -0
  57. package/lib/src/svgcomponent.ts +577 -0
  58. package/lib/src/tabbar.ts +151 -0
  59. package/lib/src/tabview.ts +110 -0
  60. package/lib/src/textarea.ts +235 -0
  61. package/lib/src/textedit.ts +544 -0
  62. package/lib/src/toaster.ts +80 -0
  63. package/lib/src/tools.ts +1473 -0
  64. package/lib/src/tooltips.ts +191 -0
  65. package/lib/src/treeview.ts +716 -0
  66. package/lib/{esm/version.js → src/version.ts} +30 -29
  67. package/lib/{styles → src}/x4.less +0 -0
  68. package/lib/src/x4dom.ts +57 -0
  69. package/lib/src/x4events.ts +585 -0
  70. package/lib/src/x4react.ts +90 -0
  71. package/package.json +52 -49
  72. package/lib/cjs/action.js +0 -58
  73. package/lib/cjs/app_sockets.js +0 -74
  74. package/lib/cjs/application.js +0 -182
  75. package/lib/cjs/autocomplete.js +0 -155
  76. package/lib/cjs/base_component.js +0 -124
  77. package/lib/cjs/button.js +0 -263
  78. package/lib/cjs/calendar.js +0 -254
  79. package/lib/cjs/canvas.js +0 -361
  80. package/lib/cjs/cardview.js +0 -161
  81. package/lib/cjs/checkbox.js +0 -139
  82. package/lib/cjs/color.js +0 -591
  83. package/lib/cjs/colorpicker.js +0 -1468
  84. package/lib/cjs/combobox.js +0 -349
  85. package/lib/cjs/component.js +0 -1719
  86. package/lib/cjs/datastore.js +0 -985
  87. package/lib/cjs/dialog.js +0 -478
  88. package/lib/cjs/dom_events.js +0 -30
  89. package/lib/cjs/drag_manager.js +0 -145
  90. package/lib/cjs/drawtext.js +0 -276
  91. package/lib/cjs/fileupload.js +0 -167
  92. package/lib/cjs/form.js +0 -304
  93. package/lib/cjs/formatters.js +0 -90
  94. package/lib/cjs/gridview.js +0 -881
  95. package/lib/cjs/i18n.js +0 -266
  96. package/lib/cjs/icon.js +0 -272
  97. package/lib/cjs/image.js +0 -157
  98. package/lib/cjs/input.js +0 -174
  99. package/lib/cjs/label.js +0 -95
  100. package/lib/cjs/layout.js +0 -322
  101. package/lib/cjs/link.js +0 -64
  102. package/lib/cjs/listview.js +0 -546
  103. package/lib/cjs/md5.js +0 -403
  104. package/lib/cjs/menu.js +0 -301
  105. package/lib/cjs/messagebox.js +0 -177
  106. package/lib/cjs/panel.js +0 -68
  107. package/lib/cjs/popup.js +0 -383
  108. package/lib/cjs/property_editor.js +0 -252
  109. package/lib/cjs/radiobtn.js +0 -140
  110. package/lib/cjs/rating.js +0 -102
  111. package/lib/cjs/request.js +0 -246
  112. package/lib/cjs/router.js +0 -139
  113. package/lib/cjs/settings.js +0 -69
  114. package/lib/cjs/sidebarview.js +0 -82
  115. package/lib/cjs/spreadsheet.js +0 -1084
  116. package/lib/cjs/styles.js +0 -275
  117. package/lib/cjs/svgcomponent.js +0 -447
  118. package/lib/cjs/tabbar.js +0 -111
  119. package/lib/cjs/tabview.js +0 -85
  120. package/lib/cjs/textarea.js +0 -165
  121. package/lib/cjs/textedit.js +0 -415
  122. package/lib/cjs/toaster.js +0 -64
  123. package/lib/cjs/tools.js +0 -1197
  124. package/lib/cjs/tooltips.js +0 -157
  125. package/lib/cjs/treeview.js +0 -535
  126. package/lib/cjs/version.js +0 -32
  127. package/lib/cjs/x4dom.js +0 -32
  128. package/lib/cjs/x4events.js +0 -384
  129. package/lib/cjs/x4react.js +0 -72
  130. package/lib/esm/action.js +0 -53
  131. package/lib/esm/app_sockets.js +0 -70
  132. package/lib/esm/application.js +0 -184
  133. package/lib/esm/autocomplete.js +0 -155
  134. package/lib/esm/base_component.js +0 -107
  135. package/lib/esm/button.js +0 -257
  136. package/lib/esm/calendar.js +0 -249
  137. package/lib/esm/canvas.js +0 -358
  138. package/lib/esm/cardview.js +0 -159
  139. package/lib/esm/checkbox.js +0 -134
  140. package/lib/esm/color.js +0 -588
  141. package/lib/esm/colorpicker.js +0 -1475
  142. package/lib/esm/combobox.js +0 -351
  143. package/lib/esm/component.js +0 -1711
  144. package/lib/esm/datastore.js +0 -990
  145. package/lib/esm/dialog.js +0 -490
  146. package/lib/esm/drag_manager.js +0 -147
  147. package/lib/esm/drawtext.js +0 -271
  148. package/lib/esm/fileupload.js +0 -163
  149. package/lib/esm/form.js +0 -304
  150. package/lib/esm/formatters.js +0 -81
  151. package/lib/esm/gridview.js +0 -889
  152. package/lib/esm/i18n.js +0 -257
  153. package/lib/esm/icon.js +0 -261
  154. package/lib/esm/image.js +0 -154
  155. package/lib/esm/input.js +0 -182
  156. package/lib/esm/label.js +0 -90
  157. package/lib/esm/layout.js +0 -310
  158. package/lib/esm/link.js +0 -59
  159. package/lib/esm/listview.js +0 -534
  160. package/lib/esm/menu.js +0 -300
  161. package/lib/esm/messagebox.js +0 -161
  162. package/lib/esm/panel.js +0 -65
  163. package/lib/esm/popup.js +0 -379
  164. package/lib/esm/property_editor.js +0 -251
  165. package/lib/esm/radiobtn.js +0 -136
  166. package/lib/esm/rating.js +0 -97
  167. package/lib/esm/request.js +0 -224
  168. package/lib/esm/router.js +0 -136
  169. package/lib/esm/settings.js +0 -66
  170. package/lib/esm/sidebarview.js +0 -79
  171. package/lib/esm/spreadsheet.js +0 -1097
  172. package/lib/esm/styles.js +0 -270
  173. package/lib/esm/svgcomponent.js +0 -450
  174. package/lib/esm/tabbar.js +0 -107
  175. package/lib/esm/tabview.js +0 -83
  176. package/lib/esm/textarea.js +0 -160
  177. package/lib/esm/textedit.js +0 -412
  178. package/lib/esm/toaster.js +0 -62
  179. package/lib/esm/tools.js +0 -1158
  180. package/lib/esm/tooltips.js +0 -153
  181. package/lib/esm/treeview.js +0 -527
  182. package/lib/esm/x4dom.js +0 -29
  183. package/lib/esm/x4events.js +0 -376
  184. package/lib/esm/x4react.js +0 -71
  185. package/lib/types/app_sockets.d.ts +0 -29
  186. package/lib/types/application.d.ts +0 -104
  187. package/lib/types/autocomplete.d.ts +0 -58
  188. package/lib/types/base_component.d.ts +0 -88
  189. package/lib/types/button.d.ts +0 -151
  190. package/lib/types/calendar.d.ts +0 -82
  191. package/lib/types/canvas.d.ts +0 -92
  192. package/lib/types/cardview.d.ts +0 -87
  193. package/lib/types/checkbox.d.ts +0 -77
  194. package/lib/types/color.d.ts +0 -148
  195. package/lib/types/colorpicker.d.ts +0 -107
  196. package/lib/types/combobox.d.ts +0 -107
  197. package/lib/types/component.d.ts +0 -601
  198. package/lib/types/datastore.d.ts +0 -396
  199. package/lib/types/dialog.d.ts +0 -175
  200. package/lib/types/dom_events.d.ts +0 -302
  201. package/lib/types/drag_manager.d.ts +0 -54
  202. package/lib/types/drawtext.d.ts +0 -48
  203. package/lib/types/fileupload.d.ts +0 -64
  204. package/lib/types/form.d.ts +0 -133
  205. package/lib/types/formatters.d.ts +0 -35
  206. package/lib/types/gridview.d.ts +0 -175
  207. package/lib/types/i18n.d.ts +0 -73
  208. package/lib/types/icon.d.ts +0 -64
  209. package/lib/types/image.d.ts +0 -55
  210. package/lib/types/index.d.ts +0 -84
  211. package/lib/types/input.d.ts +0 -91
  212. package/lib/types/label.d.ts +0 -58
  213. package/lib/types/layout.d.ts +0 -87
  214. package/lib/types/link.d.ts +0 -50
  215. package/lib/types/listview.d.ts +0 -178
  216. package/lib/types/md5.d.ts +0 -61
  217. package/lib/types/menu.d.ts +0 -130
  218. package/lib/types/messagebox.d.ts +0 -69
  219. package/lib/types/panel.d.ts +0 -47
  220. package/lib/types/popup.d.ts +0 -75
  221. package/lib/types/property_editor.d.ts +0 -71
  222. package/lib/types/radiobtn.d.ts +0 -73
  223. package/lib/types/rating.d.ts +0 -53
  224. package/lib/types/request.d.ts +0 -52
  225. package/lib/types/router.d.ts +0 -42
  226. package/lib/types/settings.d.ts +0 -37
  227. package/lib/types/sidebarview.d.ts +0 -49
  228. package/lib/types/spreadsheet.d.ts +0 -222
  229. package/lib/types/styles.d.ts +0 -85
  230. package/lib/types/svgcomponent.d.ts +0 -215
  231. package/lib/types/tabbar.d.ts +0 -58
  232. package/lib/types/tabview.d.ts +0 -49
  233. package/lib/types/textarea.d.ts +0 -77
  234. package/lib/types/textedit.d.ts +0 -123
  235. package/lib/types/toaster.d.ts +0 -42
  236. package/lib/types/tools.d.ts +0 -394
  237. package/lib/types/tooltips.d.ts +0 -46
  238. package/lib/types/treeview.d.ts +0 -144
  239. package/lib/types/version.d.ts +0 -29
  240. package/lib/types/x4dom.d.ts +0 -49
  241. package/lib/types/x4events.d.ts +0 -269
  242. package/lib/types/x4react.d.ts +0 -41
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file version.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.x4js_version = void 0;
32
- exports.x4js_version = "1.5.17";
package/lib/cjs/x4dom.js DELETED
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file x4events.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.x4document = void 0;
32
- exports.x4document = document;
@@ -1,384 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file x4events.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.EventSource = exports.EvError = exports.EvDrag = exports.EvMessage = exports.EvTimer = exports.EvContextMenu = exports.EvSelectionChange = exports.EvChange = exports.EvClick = exports.BasicEvent = void 0;
32
- // default stopPropagation implementation for Events
33
- const stopPropagation = function () {
34
- this.propagationStopped = true;
35
- };
36
- // default preventDefault implementation for Events
37
- const preventDefault = function () {
38
- this.defaultPrevented = true;
39
- };
40
- ;
41
- /**
42
- * BasicEvent Builder
43
- * this function is responsable of BasicEvent creation
44
- * ie. is equivalent of new BasicEvent( xxx );
45
- * @param params
46
- * @returns BasicEvent
47
- */
48
- function BasicEvent(params) {
49
- return Object.assign({ stopPropagation,
50
- preventDefault }, params);
51
- }
52
- exports.BasicEvent = BasicEvent;
53
- function EvClick(context = null) {
54
- return BasicEvent({ context });
55
- }
56
- exports.EvClick = EvClick;
57
- function EvChange(value, context = null) {
58
- return BasicEvent({ value, context });
59
- }
60
- exports.EvChange = EvChange;
61
- function EvSelectionChange(selection, context = null) {
62
- return BasicEvent({ selection, context });
63
- }
64
- exports.EvSelectionChange = EvSelectionChange;
65
- function EvContextMenu(uievent, context = null) {
66
- return BasicEvent({ uievent, context });
67
- }
68
- exports.EvContextMenu = EvContextMenu;
69
- function EvTimer(timer, time = 0, context = null) {
70
- return BasicEvent({ timer, time, context });
71
- }
72
- exports.EvTimer = EvTimer;
73
- function EvMessage(msg, params, source) {
74
- return BasicEvent({ msg, params, source });
75
- }
76
- exports.EvMessage = EvMessage;
77
- function EvDrag(element, data, ctx) {
78
- return BasicEvent({ element, data, context: ctx });
79
- }
80
- exports.EvDrag = EvDrag;
81
- function EvError(code, message) {
82
- return BasicEvent({ code, message });
83
- }
84
- exports.EvError = EvError;
85
- /**
86
- * Event emitter class
87
- * this class allow you to emit and handle events
88
- *
89
- * @example:
90
- * ```ts
91
- *
92
- * interface EvDoIt extends BasicEvent {
93
- * param: unknown;
94
- * }
95
- *
96
- * function EvDoIt( e: EvDoIt ) : EvDoIt {
97
- * return BasicEvent<EvDoIt>( e );
98
- * }
99
- *
100
- * interface TestEventMap extends EventMap {
101
- * doit: EvDoIt;
102
- * }
103
- *
104
- * let ee = new EventSource<TestEventMap>(null);
105
- * ee.listen({
106
- * doit: (e) => {
107
- * console.log(e);
108
- * e.preventDefault();
109
- * },
110
- * });
111
- *
112
- * ee.defaults({
113
- * doit: (e) => {
114
- * console.log('default handler for ', e.type, e.selection);
115
- * },
116
- * })
117
- *
118
- * ee.on('doit', (e) => {
119
- * debugger;
120
- * })
121
- *
122
- * const ev = EvDoIt({ param: 10 });
123
- * ee.emit('change', ev);
124
- * if (ev.defaultPrevented) {
125
- * console.log('prevented');
126
- * }
127
- * ```
128
- */
129
- class EventSource {
130
- constructor(source = null) {
131
- this.m_source = source !== null && source !== void 0 ? source : this;
132
- }
133
- /**
134
- * emit an event
135
- * you can stop propagation of event or prevent default
136
- * @param eventName - name of event to emit
137
- * @param event - event data
138
- */
139
- emit(type, event) {
140
- this._emit(type, event);
141
- }
142
- _emit(eventName, e) {
143
- var _a, _b;
144
- let listeners = (_a = this.m_eventRegistry) === null || _a === void 0 ? void 0 : _a.get(eventName);
145
- const defaultHandler = (_b = this.m_defaultHandlers) === null || _b === void 0 ? void 0 : _b.get(eventName);
146
- if (!e) {
147
- e = {};
148
- }
149
- if (!e.source) {
150
- e.source = this.m_source;
151
- }
152
- if (!e.type) {
153
- e.type = eventName;
154
- }
155
- if (listeners && listeners.length) {
156
- if (!e.preventDefault) {
157
- e.preventDefault = preventDefault;
158
- }
159
- if (!e.stopPropagation) {
160
- e.stopPropagation = stopPropagation;
161
- }
162
- // small optimisation
163
- if (listeners.length == 1) {
164
- listeners[0](e);
165
- }
166
- else {
167
- const temp = listeners.slice();
168
- for (let i = 0, n = temp.length; i < n; i++) {
169
- temp[i](e);
170
- if (e.propagationStopped) {
171
- break;
172
- }
173
- }
174
- }
175
- }
176
- if (defaultHandler && defaultHandler.length && !e.defaultPrevented) {
177
- return defaultHandler[0](e);
178
- }
179
- }
180
- /**
181
- * signal en event
182
- * signaled event are notification : no way to prevent default not stop propagation
183
- * @param eventName name of event to signal
184
- * @param event event data
185
- */
186
- signal(type, event, delay = -1) {
187
- this._signal(type, event, delay);
188
- }
189
- _signal(eventName, e, delay = -1) {
190
- if (!this.m_eventRegistry) {
191
- return;
192
- }
193
- const listeners = this.m_eventRegistry.get(eventName);
194
- if (!listeners || !listeners.length) {
195
- return;
196
- }
197
- if (!e) {
198
- e = {};
199
- }
200
- if (!e.type) {
201
- e.type = eventName;
202
- }
203
- if (!e.source) {
204
- e.source = this.m_source;
205
- }
206
- e.preventDefault = e.stopPropagation = () => {
207
- console.error('this event cannot be stopped not default prevented');
208
- };
209
- // small optimisation
210
- if (listeners.length == 1 && delay == -1) {
211
- listeners[0](e);
212
- }
213
- else {
214
- const temp = listeners.slice();
215
- const call = () => {
216
- for (let i = 0, n = temp.length; i < n; i++) {
217
- temp[i](e);
218
- }
219
- };
220
- if (delay == -1) {
221
- call();
222
- }
223
- else {
224
- setTimeout(call, delay);
225
- }
226
- }
227
- }
228
- /**
229
- * handle an event one time
230
- * @param eventName - event name to handle
231
- * @param callback - callback to call when event is signaled
232
- * @returns Promise if callback is null
233
- *
234
- * take care with that because if the event is never fired and you await it,
235
- * the system may overflow
236
- */
237
- once(type, callback) {
238
- //@ts-ignore
239
- this._once(type, callback);
240
- }
241
- _once(eventName, callback) {
242
- const newCallback = (ev) => {
243
- this._off(eventName, newCallback);
244
- callback(ev);
245
- };
246
- this._on(eventName, newCallback);
247
- if (!callback) {
248
- return new Promise(function (resolve) {
249
- callback = resolve;
250
- });
251
- }
252
- }
253
- /**
254
- * set the event default handler
255
- * @param eventName - name of the event
256
- * @param callback - callback to call when the event is not handled (and preventDeault has not been called)
257
- */
258
- setDefaultHandler(eventName, callback) {
259
- let handlers = this.m_defaultHandlers;
260
- if (!handlers) {
261
- handlers = this.m_defaultHandlers = new Map();
262
- }
263
- let stack = handlers.get(eventName);
264
- if (stack) {
265
- // if already in the stack, remove it
266
- const idx = stack.indexOf(callback);
267
- if (idx != -1) {
268
- stack.splice(idx, 1);
269
- }
270
- // then make it first
271
- stack.unshift(callback);
272
- }
273
- else {
274
- handlers.set(eventName, [callback]);
275
- }
276
- }
277
- /**
278
- * remove the previous default handler installed for an event
279
- * @param eventName - event name
280
- * @param callback - callback handler to remove (must be the same as in setDefaultHandler)
281
- */
282
- removeDefaultHandler(eventName, callback) {
283
- const handlers = this.m_defaultHandlers;
284
- if (!handlers) {
285
- return;
286
- }
287
- const stack = handlers.get(eventName);
288
- if (stack) {
289
- const idx = stack.indexOf(callback);
290
- if (idx != -1) {
291
- stack.splice(idx, 1);
292
- }
293
- }
294
- }
295
- /**
296
- * define a set of listeners in one call
297
- * @param events
298
- */
299
- listen(events) {
300
- for (let n in events) {
301
- this._on(n, events[n]);
302
- }
303
- }
304
- /**
305
- * define a set of default handlers in one call
306
- * @param events
307
- */
308
- defaults(events) {
309
- for (let n in events) {
310
- this.setDefaultHandler(n, events[n]);
311
- }
312
- }
313
- /**
314
- * listen for an event
315
- * @param eventName - event name to listen on
316
- * @param callback - callback to call
317
- * @param capturing - if true, capture event before other registred event handlers
318
- */
319
- on(type, callback) {
320
- //@ts-ignore
321
- return this._on(type, callback);
322
- }
323
- _on(eventName, callback, capturing = false) {
324
- if (!this.m_eventRegistry) {
325
- this.m_eventRegistry = new Map();
326
- }
327
- let listeners = this.m_eventRegistry.get(eventName);
328
- if (!listeners) {
329
- listeners = [];
330
- this.m_eventRegistry.set(eventName, listeners);
331
- }
332
- if (listeners.indexOf(callback) == -1) {
333
- if (capturing) {
334
- listeners.unshift(callback);
335
- }
336
- else {
337
- listeners.push(callback);
338
- }
339
- }
340
- return {
341
- dispose: () => { this._off(eventName, callback); }
342
- };
343
- }
344
- /**
345
- * stop listening to an event
346
- * @param eventName - event name
347
- * @param callback - callback to remove (must be the same as in on )
348
- */
349
- off(type, callback) {
350
- //@ts-ignore
351
- return this._off(type, callback);
352
- }
353
- _off(eventName, callback) {
354
- if (!this.m_eventRegistry) {
355
- return;
356
- }
357
- let listeners = this.m_eventRegistry.get(eventName);
358
- if (!listeners) {
359
- return;
360
- }
361
- const idx = listeners.indexOf(callback);
362
- if (idx !== -1) {
363
- listeners.splice(idx, 1);
364
- }
365
- }
366
- /**
367
- * remove all listeners for an event
368
- * @param eventName - event name
369
- */
370
- removeAllListeners(eventName) {
371
- if (!eventName) {
372
- this.m_eventRegistry = this.m_defaultHandlers = undefined;
373
- }
374
- else {
375
- if (this.m_eventRegistry) {
376
- this.m_eventRegistry[eventName] = undefined;
377
- }
378
- if (this.m_defaultHandlers) {
379
- this.m_defaultHandlers[eventName] = undefined;
380
- }
381
- }
382
- }
383
- }
384
- exports.EventSource = EventSource;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- /**
3
- * ___ ___ __
4
- * \ \_/ / / _
5
- * \ / /_| |_
6
- * / _ \____ _|
7
- * /__/ \__\ |_|
8
- *
9
- * @file x4react.ts
10
- * @author Etienne Cochard
11
- *
12
- * Copyright (c) 2019-2022 R-libre ingenierie
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
18
- * of the Software, and to permit persons to whom the Software is furnished to do so,
19
- * subject to the following conditions:
20
- * The above copyright notice and this permission notice shall be included in all copies
21
- * or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
24
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
25
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
28
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
- **/
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.TSXComponent = exports.React = void 0;
32
- const component_1 = require("./component");
33
- const createElement = (clsOrTag, attrs, ...children) => {
34
- let comp;
35
- // fragment
36
- if (clsOrTag == createFragment || clsOrTag == Fragment) {
37
- return children;
38
- }
39
- // class constructor, yes : dirty
40
- else if (clsOrTag instanceof Function) {
41
- comp = new clsOrTag(attrs);
42
- }
43
- // basic tag
44
- else {
45
- comp = new component_1.Component(Object.assign({ tag: clsOrTag }, attrs));
46
- }
47
- if (children && children.length) {
48
- comp.setContent(children);
49
- }
50
- return comp;
51
- };
52
- const Fragment = Symbol("fragment");
53
- const createFragment = () => {
54
- return null;
55
- };
56
- exports.React = {
57
- createElement,
58
- createFragment,
59
- Fragment,
60
- };
61
- /**
62
- *
63
- */
64
- class TSXComponent extends component_1.Component {
65
- render(props) {
66
- const tsx = this.renderTSX(props);
67
- if (tsx) {
68
- this.setContent(tsx);
69
- }
70
- }
71
- }
72
- exports.TSXComponent = TSXComponent;
package/lib/esm/action.js DELETED
@@ -1,53 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file action.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { BasicEvent, EvChange } from './x4events';
30
- import { BaseComponent } from './base_component';
31
- export function EvAction(source) {
32
- return BasicEvent({ source });
33
- }
34
- export class Action extends BaseComponent {
35
- constructor(props) {
36
- super(props);
37
- this.mapPropEvents(props, "run");
38
- }
39
- get props() {
40
- return this.m_props;
41
- }
42
- set text(t) {
43
- this.m_props.text = t;
44
- this.emit("change", EvChange(this));
45
- }
46
- set icon(i) {
47
- this.m_props.icon = i;
48
- this.emit("change", EvChange(this));
49
- }
50
- fire() {
51
- this.emit("run", EvAction(this));
52
- }
53
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file app_sockets.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Application } from "./application";
30
- /**
31
- * WEB SOCKETS
32
- *
33
- * les messages reçus par l'application sont retransmis au websocket.
34
- * comme ça, tous les clients connectés sur le serveur recevront une copie du message.
35
- * ca permet de mettre a jour les clients dynamiquement
36
- *
37
- */
38
- const msg_sent = Symbol('msg_sent');
39
- export function setupWSMessaging(closeCB) {
40
- const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
41
- const sockets = new WebSocket(`${protocol}${window.location.hostname}:${window.location.port}`, 'messaging');
42
- const app = Application.instance();
43
- // pour tous les messages recus par l'application
44
- // on transmet aux autres
45
- app.on('global', (e) => {
46
- if (e[msg_sent]) {
47
- return;
48
- }
49
- sockets.send(JSON.stringify({
50
- msg: e.msg,
51
- params: e.params,
52
- }));
53
- });
54
- // reception d'un message
55
- sockets.onmessage = (e) => {
56
- if (e.data != 'ping') {
57
- const message = JSON.parse(e.data);
58
- message[msg_sent] = true;
59
- app.signal('global', message);
60
- }
61
- };
62
- // perte du socket
63
- sockets.onclose = (ev) => {
64
- console.log('websocket closed:', ev);
65
- closeCB();
66
- };
67
- sockets.onerror = (ev) => {
68
- console.log('websocket error:', ev);
69
- };
70
- }