jsf.js_next_gen 4.0.1-beta.5 → 4.0.1-beta.7

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 (188) hide show
  1. package/dist/docs/assets/style.css +4 -5
  2. package/dist/window/faces-development.js +111 -91
  3. package/dist/window/faces-development.js.br +0 -0
  4. package/dist/window/faces-development.js.gz +0 -0
  5. package/dist/window/faces-development.js.map +1 -1
  6. package/dist/window/faces.js +1 -1
  7. package/dist/window/faces.js.br +0 -0
  8. package/dist/window/faces.js.gz +0 -0
  9. package/dist/window/faces.js.map +1 -1
  10. package/dist/window/jsf-development.js +111 -91
  11. package/dist/window/jsf-development.js.br +0 -0
  12. package/dist/window/jsf-development.js.gz +0 -0
  13. package/dist/window/jsf-development.js.map +1 -1
  14. package/dist/window/jsf.js +1 -1
  15. package/dist/window/jsf.js.br +0 -0
  16. package/dist/window/jsf.js.gz +0 -0
  17. package/dist/window/jsf.js.map +1 -1
  18. package/package.json +10 -10
  19. package/src/main/typescript/impl/util/XhrQueueController.ts +3 -17
  20. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +94 -51
  21. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  22. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +126 -0
  23. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +60 -0
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/bootstrap-icons.css +15 -0
  25. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/tobago.css +15 -0
  26. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/js/tobago.js +15 -0
  27. package/src/main/typescript/test/myfaces/{OnLoadSpec.ts → OnLoad.spec.ts} +2 -2
  28. package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +136 -0
  29. package/src/main/typescript/test/xhrCore/NamespacesRequestTest.spec.ts +9 -12
  30. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +1 -1
  31. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +18 -0
  32. package/target/AssocArray.js +281 -0
  33. package/target/AssocArray.js.map +1 -0
  34. package/target/Config.js +235 -0
  35. package/target/Config.js.map +1 -0
  36. package/target/CryptoExtensions.js +112 -0
  37. package/target/CryptoExtensions.js.map +1 -0
  38. package/target/DomQuery.js +1963 -0
  39. package/target/DomQuery.js.map +1 -0
  40. package/target/Es2019Array.js +117 -0
  41. package/target/Es2019Array.js.map +1 -0
  42. package/target/Global.js +38 -0
  43. package/target/Global.js.map +1 -0
  44. package/target/IDomQuery.js +3 -0
  45. package/target/IDomQuery.js.map +1 -0
  46. package/target/Lang.js +183 -0
  47. package/target/Lang.js.map +1 -0
  48. package/target/Messaging.js +645 -0
  49. package/target/Messaging.js.map +1 -0
  50. package/target/Monad.js +330 -0
  51. package/target/Monad.js.map +1 -0
  52. package/target/Promise.js +296 -0
  53. package/target/Promise.js.map +1 -0
  54. package/target/PromiseShim.js +30 -0
  55. package/target/PromiseShim.js.map +1 -0
  56. package/target/SourcesCollectors.js +444 -0
  57. package/target/SourcesCollectors.js.map +1 -0
  58. package/target/Stream.js +562 -0
  59. package/target/Stream.js.map +1 -0
  60. package/target/TagBuilder.js +178 -0
  61. package/target/TagBuilder.js.map +1 -0
  62. package/target/XmlQuery.js +84 -0
  63. package/target/XmlQuery.js.map +1 -0
  64. package/target/impl/util/XhrQueueController.js +3 -18
  65. package/target/impl/util/XhrQueueController.js.map +1 -1
  66. package/target/impl/xhrCore/XhrRequest.js +89 -45
  67. package/target/impl/xhrCore/XhrRequest.js.map +1 -1
  68. package/target/index.js +80 -0
  69. package/target/index.js.map +1 -0
  70. package/target/index_core.js +76 -0
  71. package/target/index_core.js.map +1 -0
  72. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
  73. package/target/test/frameworkBase/_ext/shared/StandardInits.js +124 -0
  74. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  75. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +57 -1
  76. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  77. package/target/test/myfaces/OnLoad.spec.js +57 -0
  78. package/target/test/myfaces/OnLoad.spec.js.map +1 -0
  79. package/target/test/myfaces/OnLoadSpec.js +2 -2
  80. package/target/test/myfaces/OnLoadSpec.js.map +1 -1
  81. package/target/test/xhrCore/ErrorChainTest.spec.js +156 -0
  82. package/target/test/xhrCore/ErrorChainTest.spec.js.map +1 -0
  83. package/target/test/xhrCore/NamespacesRequestTest.spec.js +8 -5
  84. package/target/test/xhrCore/NamespacesRequestTest.spec.js.map +1 -1
  85. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  86. package/target/test/xhrCore/ResponseTest23.spec.js +13 -0
  87. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  88. package/target/types/main/typescript/AssocArray.d.ts +86 -0
  89. package/target/types/main/typescript/Config.d.ts +94 -0
  90. package/target/types/main/typescript/CryptoExtensions.d.ts +87 -0
  91. package/target/types/main/typescript/DomQuery.d.ts +587 -0
  92. package/target/types/main/typescript/Es2019Array.d.ts +30 -0
  93. package/target/types/main/typescript/Global.d.ts +23 -0
  94. package/target/types/main/typescript/IDomQuery.d.ts +480 -0
  95. package/target/types/main/typescript/Lang.d.ts +97 -0
  96. package/target/types/main/typescript/Messaging.d.ts +285 -0
  97. package/target/types/main/typescript/Monad.d.ts +161 -0
  98. package/target/types/main/typescript/Promise.d.ts +58 -0
  99. package/target/types/main/typescript/PromiseShim.d.ts +22 -0
  100. package/target/types/main/typescript/SourcesCollectors.d.ts +280 -0
  101. package/target/types/main/typescript/Stream.d.ts +284 -0
  102. package/target/types/main/typescript/TagBuilder.d.ts +50 -0
  103. package/target/types/main/typescript/XmlQuery.d.ts +31 -0
  104. package/target/types/main/typescript/api/_api.d.ts +182 -0
  105. package/target/types/main/typescript/api/faces.d.ts +17 -0
  106. package/target/types/main/typescript/api/jsf.d.ts +17 -0
  107. package/target/types/main/typescript/impl/AjaxImpl.d.ts +164 -0
  108. package/target/types/main/typescript/impl/PushImpl.d.ts +38 -0
  109. package/target/types/main/typescript/impl/core/Const.d.ts +138 -0
  110. package/target/types/main/typescript/impl/core/ImplTypes.d.ts +16 -0
  111. package/target/types/main/typescript/impl/i18n/Messages.d.ts +102 -0
  112. package/target/types/main/typescript/impl/util/Assertions.d.ts +46 -0
  113. package/target/types/main/typescript/impl/util/AsyncRunnable.d.ts +112 -0
  114. package/target/types/main/typescript/impl/util/ExtDomQuery.d.ts +100 -0
  115. package/target/types/main/typescript/impl/util/FileUtils.d.ts +25 -0
  116. package/target/types/main/typescript/impl/util/HiddenInputBuilder.d.ts +37 -0
  117. package/target/types/main/typescript/impl/util/IListener.d.ts +18 -0
  118. package/target/types/main/typescript/impl/util/Lang.d.ts +138 -0
  119. package/target/types/main/typescript/impl/util/XhrQueueController.d.ts +51 -0
  120. package/target/types/main/typescript/impl/xhrCore/ErrorData.d.ts +37 -0
  121. package/target/types/main/typescript/impl/xhrCore/EventData.d.ts +25 -0
  122. package/target/types/main/typescript/impl/xhrCore/IResponseProcessor.d.ts +136 -0
  123. package/target/types/main/typescript/impl/xhrCore/RequestDataResolver.d.ts +84 -0
  124. package/target/types/main/typescript/impl/xhrCore/ResonseDataResolver.d.ts +60 -0
  125. package/target/types/main/typescript/impl/xhrCore/Response.d.ts +29 -0
  126. package/target/types/main/typescript/impl/xhrCore/ResponseProcessor.d.ts +208 -0
  127. package/target/types/main/typescript/impl/xhrCore/XhrFormData.d.ts +83 -0
  128. package/target/types/main/typescript/impl/xhrCore/XhrRequest.d.ts +102 -0
  129. package/target/types/main/typescript/index.d.ts +34 -0
  130. package/target/types/main/typescript/index_core.d.ts +29 -0
  131. package/target/types/main/typescript/myfaces/OamSubmit.d.ts +53 -0
  132. package/target/types/main/typescript/test/frameworkBase/LangTest.spec.d.ts +1 -0
  133. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.d.ts +1 -0
  134. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/LangTest.spec.d.ts +16 -0
  135. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingProbes.d.ts +39 -0
  136. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingTest.spec.d.ts +16 -0
  137. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.d.ts +16 -0
  138. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.d.ts +0 -0
  139. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.d.ts +1 -0
  140. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.d.ts +1 -0
  141. package/target/types/main/typescript/test/frameworkBase/_ext/shared/StandardInits.d.ts +63 -0
  142. package/target/types/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.d.ts +23 -0
  143. package/target/types/main/typescript/test/impl/ImplTest.spec.d.ts +16 -0
  144. package/target/types/main/typescript/test/impl/ImplTest_23.spec.d.ts +16 -0
  145. package/target/types/main/typescript/test/impl/SeparatorCharsTest.spec.d.ts +16 -0
  146. package/target/types/main/typescript/test/myfaces/OamSubmit.spec.d.ts +16 -0
  147. package/target/types/main/typescript/test/myfaces/OnLoad.spec.d.ts +16 -0
  148. package/target/types/main/typescript/test/queue/AsynchronousProbe.d.ts +38 -0
  149. package/target/types/main/typescript/test/queue/AsynchronousQueueTest.spec.d.ts +16 -0
  150. package/target/types/main/typescript/test/xhrCore/ClientWindow.spec.d.ts +1 -0
  151. package/target/types/main/typescript/test/xhrCore/ErrorChainTest.spec.d.ts +16 -0
  152. package/target/types/main/typescript/test/xhrCore/EventTests.spec.d.ts +16 -0
  153. package/target/types/main/typescript/test/xhrCore/FakeWebsocket.d.ts +24 -0
  154. package/target/types/main/typescript/test/xhrCore/FileUploadTest.spec.d.ts +1 -0
  155. package/target/types/main/typescript/test/xhrCore/NamespacesRequestTest.spec.d.ts +16 -0
  156. package/target/types/main/typescript/test/xhrCore/OamSubmitTest.spec.d.ts +16 -0
  157. package/target/types/main/typescript/test/xhrCore/RequestParamsTest.spec.d.ts +1 -0
  158. package/target/types/main/typescript/test/xhrCore/RequestTest.spec.d.ts +16 -0
  159. package/target/types/main/typescript/test/xhrCore/RequestTest_23.spec.d.ts +16 -0
  160. package/target/types/main/typescript/test/xhrCore/ResponseTest.spec.d.ts +16 -0
  161. package/target/types/main/typescript/test/xhrCore/ResponseTest23.spec.d.ts +16 -0
  162. package/target/types/main/typescript/test/xhrCore/ShadowDomTest.spec.d.ts +16 -0
  163. package/target/types/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.d.ts +1 -0
  164. package/target/types/main/typescript/test/xhrCore/WebsocketTest.d.ts +1 -0
  165. package/target/types/main/typescript/test/xhrCore/XhrFormDataTest.spec.d.ts +16 -0
  166. package/target/types/test/typescript/AssocArrayTest.spec.d.ts +1 -0
  167. package/target/types/test/typescript/DomQueryTest.spec.d.ts +1 -0
  168. package/target/types/test/typescript/ExtendedArrayTest.spec.d.ts +1 -0
  169. package/target/types/test/typescript/LangTest.spec.d.ts +1 -0
  170. package/target/types/test/typescript/MappingProbes.d.ts +24 -0
  171. package/target/types/test/typescript/MappingTest.spec.d.ts +1 -0
  172. package/target/types/test/typescript/MessagingTest.spec.d.ts +1 -0
  173. package/target/types/test/typescript/MonadTest.spec.d.ts +16 -0
  174. package/target/types/test/typescript/PromiseTest.spec.d.ts +1 -0
  175. package/target/types/test/typescript/StreamTest.spec.d.ts +1 -0
  176. package/target/types/test/typescript/XmlQueryTest.spec.d.ts +1 -0
  177. package/target/types/test/typescript/markups/tobago-with-header.d.ts +1 -0
  178. package/target/types/test/typescript/markups/tobago-without-header.d.ts +1 -0
  179. package/webpack.config.js +1 -1
  180. package/webpack.config.js.map +1 -1
  181. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  182. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  183. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  184. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  185. package/.nyc_output/processinfo/index.json +0 -1
  186. package/src/test.html +0 -75
  187. package/src/tmp/test.html +0 -16
  188. package/tmp.xml +0 -36
@@ -0,0 +1,285 @@
1
+ /*!
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ /**
20
+ * a standardized message to be sent over the message bus
21
+ */
22
+ import { Observable, Subject } from "rxjs";
23
+ /**
24
+ * generic crypto interface
25
+ * to encrypt messages before they are sent
26
+ * to the message bus oder the underlying bus system
27
+ *
28
+ * The idea is to make it as easy as possible, you can use for instance crypto js to
29
+ * handle everything
30
+ */
31
+ export interface Crypto {
32
+ /**
33
+ * note anything can be passed
34
+ *
35
+ * @param data the data to be encrypted
36
+ * @returns the encrypted data in any format, important is decode must be able to handle it
37
+ */
38
+ encode(data: any): any;
39
+ /**
40
+ * @param data the encrypted data in the format you expect it to be
41
+ * @returns the unencrypted data
42
+ */
43
+ decode(data: any): any;
44
+ }
45
+ /**
46
+ * generic hash interface which provides
47
+ * exactly one method a hash encode which returns a string hash value of encoded data
48
+ */
49
+ export interface Hash {
50
+ encode(encodedData: string): string;
51
+ }
52
+ /**
53
+ * Default implementation = no encryption
54
+ */
55
+ export declare class NoCrypto implements Crypto {
56
+ decode(data: any): string;
57
+ encode(data: any): any;
58
+ }
59
+ export declare class Message {
60
+ message: any;
61
+ creationDate?: number;
62
+ identifier?: string;
63
+ targetOrigin?: string;
64
+ encoded: boolean;
65
+ constructor(message?: any, targetOrigin?: string);
66
+ }
67
+ /**
68
+ * abstract broker class
69
+ * (The broker is the central distribution unit of messages)
70
+ */
71
+ declare abstract class BaseBroker {
72
+ static readonly EVENT_TYPE = "brokerEvent";
73
+ /**
74
+ * we can split the listeners with the system
75
+ * namespace... and type (aka identifier criteria)
76
+ */
77
+ protected messageListeners: any;
78
+ protected subjects: any;
79
+ protected processedMessages: any;
80
+ protected cleanupCnt: number;
81
+ protected rootElem: any;
82
+ protected msgHandler: any;
83
+ protected readonly TIMEOUT_IN_MS = 1000;
84
+ protected readonly MSG_EVENT = "message";
85
+ crypto: NoCrypto;
86
+ abstract register(scopeElement?: any): BaseBroker;
87
+ abstract unregister(): BaseBroker;
88
+ abstract broadcast(channel: string, message: Message | string): BaseBroker;
89
+ /**
90
+ * registers a listener on a channel
91
+ * @param channel the channel to register the listeners for
92
+ * @param listener the listener to register
93
+ */
94
+ registerListener(channel: string, listener: (msg: Message) => void): BaseBroker;
95
+ /**
96
+ * binding into rxjs
97
+ * produces a subject which can be used via next calls to send messages
98
+ * on the other hand we
99
+ * @param channel
100
+ */
101
+ asSubject(channel: string): Subject<Message>;
102
+ /**
103
+ * returns an observable on the baseBroker
104
+ * @param channel
105
+ */
106
+ asObservable(channel: string): Observable<Message>;
107
+ /**
108
+ * reserves the listener namespace and wildcard namespace for the given identifier
109
+ * @param identifier
110
+ * @private
111
+ */
112
+ private reserveListenerNS;
113
+ private reserveSubjectNS;
114
+ /**
115
+ * unregisters a listener from this channel
116
+ *
117
+ * @param channel the channel to unregister from
118
+ * @param listener the listener to unregister the channel from
119
+ */
120
+ unregisterListener(channel: string, listener: (msg: Message) => void): BaseBroker;
121
+ /**
122
+ * answers a bidirectional message received
123
+ * usage, the client can use this method, to answer an incoming message in a precise manner
124
+ * so that the caller sending the bidirectional message knows how to deal with it
125
+ * this mechanism can be used for global storages where we have one answering entity per channel delivering the
126
+ * requested data, the request can be done asynchronously via promises waiting for answers
127
+ *
128
+ * @param channel the channel the originating message
129
+ * @param request the requesting message
130
+ * @param answer the answer to the request
131
+ */
132
+ answer(channel: string, request: Message | string, answer: Message): BaseBroker;
133
+ private static getAnswerId;
134
+ private static isAnswer;
135
+ /**
136
+ * idea... a bidirectional broadcast
137
+ * sends a message and waits for the first answer coming in from one of the receivers
138
+ * sending the message back with a messageIdentifier_broadCastId answer
139
+ *
140
+ * @param channel
141
+ * @param message
142
+ */
143
+ request(channel: string, message: Message | string): Promise<Message>;
144
+ /**
145
+ * garbage collects the processed messages queue
146
+ * usually after one second
147
+ */
148
+ protected gcProcessedMessages(): void;
149
+ private messageStillActive;
150
+ protected markMessageAsProcessed(message: Message): void;
151
+ }
152
+ /**
153
+ * a broker which hooks into the Broadcast Channel
154
+ * either via shim or substitute lib
155
+ *
156
+ * The broadcast channels are a standardized messaging library
157
+ * The broker mechanism sets a layer on top to make it more manageable!
158
+ *
159
+ */
160
+ export declare class BroadcastChannelBroker extends BaseBroker {
161
+ private brokerFactory;
162
+ private channelGroup;
163
+ crypto: Crypto;
164
+ private openChannels;
165
+ private readonly msgListener;
166
+ /**
167
+ * @param brokerFactory a factory generating a broker
168
+ * @param channelGroup a group to combine a set of channels
169
+ * @param crypto a crypto class
170
+ */
171
+ constructor(brokerFactory?: Function, channelGroup?: string, crypto?: Crypto);
172
+ broadcast(channel: string, message: Message | string, includeOrigin?: boolean): BaseBroker;
173
+ registerListener(channel: string, listener: (msg: Message) => void): BaseBroker;
174
+ register(): BaseBroker;
175
+ unregister(): BaseBroker;
176
+ }
177
+ /**
178
+ * Helper factory to create a broadcast channel broker
179
+ */
180
+ export declare class BroadcastChannelBrokerBuilder {
181
+ private broadCastChannelGenerator;
182
+ private channelGroup;
183
+ private crypto;
184
+ private listeners;
185
+ withGeneratorFunc(generatorFunc: Function): BroadcastChannelBrokerBuilder;
186
+ withListener(channel: string, ...listeners: Function[]): BroadcastChannelBrokerBuilder;
187
+ withChannelGroup(channelGroup: string): BroadcastChannelBrokerBuilder;
188
+ withCrypto(crypto: Crypto): BroadcastChannelBrokerBuilder;
189
+ build(): BroadcastChannelBroker;
190
+ }
191
+ /**
192
+ * implementation of a messaging based transport
193
+ */
194
+ /**
195
+ * central message broker which uses various dom constructs
196
+ * to broadcast messages into subelements
197
+ *
198
+ * we use the dom event system as transport and iframe and shadow dom mechanisms in a transparent way to
199
+ * pull this off
200
+ *
201
+ * usage
202
+ *
203
+ * broker = new Broker(optional rootElement)
204
+ *
205
+ * defines a message broker within a scope of rootElement (without it is window aka the current isolation level)
206
+ *
207
+ * broker.registerListener(channel, listener) registers a new listener to the current broker and channel
208
+ * broker.unregisterListener(channel, listener) unregisters the given listener
209
+ *
210
+ * broker.broadcast(message, optional direction, optional callBrokerListeners)
211
+ * sends a message (channel included in the message object) in a direction (up, down, both)
212
+ * and also optionally calls the listeners on the same broker (default off)
213
+ *
214
+ * the flow is like
215
+ * up messages are propagated upwards only until it reaches the outer top of the dom
216
+ * downwards, the messages are propagated downwards only
217
+ * both the message is propagated into both directions
218
+ *
219
+ * Usually messages sent from the same broker are not processed within... however by setting
220
+ * callBrokerListeners to true the listeners on the same broker also are called
221
+ * brokers on the same level will get the message and process it automatically no matter what.
222
+ * That way you can exclude the source from message processing (and it is done that way automatically)
223
+ *
224
+ * Isolation levels. Usually every isolation level needs its own broker object registering
225
+ * on the outer bounds
226
+ *
227
+ * aka documents will register on window
228
+ * iframes on the iframe windowObject
229
+ * isolated shadow doms... document
230
+ *
231
+ *
232
+ *
233
+ */
234
+ export declare class Broker extends BaseBroker {
235
+ brokerGroup: string;
236
+ /**
237
+ * constructor has an optional root element
238
+ * and an internal name
239
+ *
240
+ * @param scopeElement
241
+ * @param brokerGroup
242
+ * @param crypto
243
+ */
244
+ constructor(scopeElement?: HTMLElement | Window | ShadowRoot, brokerGroup?: string, crypto?: Crypto);
245
+ /**
246
+ * register the current broker into a scope defined by wnd
247
+ * @param scopeElement
248
+ */
249
+ register(scopeElement: HTMLElement | Window | ShadowRoot): BaseBroker;
250
+ /**
251
+ * manual unregister function, to unregister as broker from the current
252
+ * scope
253
+ */
254
+ unregister(): BaseBroker;
255
+ /**
256
+ * broadcast a message
257
+ * the message contains the channel and the data and some internal bookkeeping data
258
+ *
259
+ * @param channel the channel to broadcast to
260
+ * @param message the message dot send
261
+ * (for instance 2 iframes within the same parent broker)
262
+ */
263
+ broadcast(channel: string, message: Message | string): BaseBroker;
264
+ private dispatchUp;
265
+ private dispatchSameLevel;
266
+ private dispatchDown;
267
+ private msgCallListeners;
268
+ private transformToEvent;
269
+ private static createCustomEvent;
270
+ }
271
+ /**
272
+ * Helper factory to create a dom broker
273
+ */
274
+ export declare class BrokerBuilder {
275
+ private scopeElement;
276
+ private channelGroup;
277
+ private crypto;
278
+ private listeners;
279
+ withScopeElement(scopeElement: HTMLElement | Window | ShadowRoot): BrokerBuilder;
280
+ withListener(channel: string, ...listeners: Function[]): BrokerBuilder;
281
+ withChannelGroup(channelGroup: string): BrokerBuilder;
282
+ withCrypto(crypto: Crypto): BrokerBuilder;
283
+ build(): Broker;
284
+ }
285
+ export {};
@@ -0,0 +1,161 @@
1
+ /*!
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to you under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * IFunctor interface,
19
+ * defines an interface which allows to map a functor
20
+ * via a first order function to another functor
21
+ */
22
+ export interface IFunctor<T> {
23
+ map<R>(fn: (data: T) => R): IFunctor<R>;
24
+ }
25
+ /**
26
+ * IMonad definition, basically a functor with a flatMap implementation, flatMap reduces all nested monads after a
27
+ * function call f into a monad with the nesting level of 1
28
+ *
29
+ * flatmap flats nested Monads into a IMonad of the deepest nested implementation
30
+ */
31
+ export interface IMonad<T, M extends IMonad<any, any>> extends IFunctor<T> {
32
+ flatMap<T, M>(f: (T: any) => M): IMonad<any, any>;
33
+ }
34
+ /**
35
+ * a stateful functor which holds a value upn which a
36
+ * function can be applied
37
+ *
38
+ * as value holder of type T
39
+ */
40
+ export interface IIdentity<T> extends IFunctor<T> {
41
+ readonly value: T;
42
+ }
43
+ /**
44
+ * custom value holder definition, since we are not pure functional
45
+ * but iterative we have structures which allow the assignment of a value
46
+ * also not all structures are side - effect free
47
+ */
48
+ export interface IValueHolder<T> {
49
+ value: T | Array<T>;
50
+ }
51
+ /**
52
+ * Implementation of a monad
53
+ * (Side - effect free), no write allowed directly on the monads
54
+ * value state
55
+ */
56
+ export declare class Monad<T> implements IMonad<T, Monad<any>>, IValueHolder<T> {
57
+ constructor(value: T);
58
+ protected _value: T;
59
+ get value(): T;
60
+ map<R>(fn?: (data: T) => R): Monad<R>;
61
+ flatMap<R>(fn?: (data: T) => R): Monad<any>;
62
+ }
63
+ /**
64
+ * optional implementation, an optional is basically an implementation of a Monad with additional syntactic
65
+ * sugar on top
66
+ * (Side - effect free, since value assignment is not allowed)
67
+ * */
68
+ export declare class Optional<T> extends Monad<T> {
69
+ static absent: Optional<any>;
70
+ constructor(value: T);
71
+ get value(): T;
72
+ static fromNullable<V extends Optional<T>, T>(value?: T): Optional<T>;
73
+ isAbsent(): boolean;
74
+ /**
75
+ * any value present
76
+ */
77
+ isPresent(presentRunnable?: (val?: Monad<T>) => void): boolean;
78
+ ifPresentLazy(presentRunnable?: (val?: Monad<T>) => void): Monad<T>;
79
+ orElse(elseValue: any): Optional<any>;
80
+ /**
81
+ * lazy, passes a function which then is lazily evaluated
82
+ * instead of a direct value
83
+ * @param func
84
+ */
85
+ orElseLazy(func: () => any): Optional<any>;
86
+ flatMap<R>(fn?: (data: T) => R): Optional<any>;
87
+ getIf<R>(...key: string[]): Optional<R>;
88
+ /**
89
+ * simple match, if the first order function call returns
90
+ * true then there is a match, if the value is not present
91
+ * it never matches
92
+ *
93
+ * @param fn the first order function performing the match
94
+ */
95
+ match(fn: (item: T) => boolean): boolean;
96
+ /**
97
+ * convenience function to flatmap the internal value
98
+ * and replace it with a default in case of being absent
99
+ *
100
+ * @param defaultVal
101
+ * @returns {Optional<any>}
102
+ */
103
+ get<R>(defaultVal?: any): Optional<R>;
104
+ toJson(): string;
105
+ /**
106
+ * helper to override several implementations in a more fluent way
107
+ * by having a getClass operation we can avoid direct calls into the constructor or
108
+ * static methods and do not have to implement several methods which rely on the type
109
+ * of "this"
110
+ * @returns the type of Optional
111
+ */
112
+ protected getClass(): any;
113
+ protected arrayIndex(key: string): number;
114
+ protected keyVal(key: string): string;
115
+ /**
116
+ * additional syntactic sugar which is not part of the usual optional implementation
117
+ * but makes life easier, if you want to sacrifice typesafety and refactoring
118
+ * capabilities in typescript
119
+ */
120
+ getIfPresent<R>(key: string): Optional<R>;
121
+ /**
122
+ * elvis like typesafe functional save resolver
123
+ * a typesafe option for getIfPresent
124
+ *
125
+ * usage myOptional.resolve(value => value.subAttr.subAttr2).orElseLazy(....)
126
+ * if this is resolvable without any errors an Optional with the value is returned
127
+ * if not, then an Optional absent is returned, also if you return Optional absent
128
+ * it is flatmapped into absent
129
+ *
130
+ * @param resolver the resolver function, can throw any arbitrary errors, int the error case
131
+ * the resolution goes towards absent
132
+ */
133
+ resolve<V>(resolver: (item: T) => V): Optional<V>;
134
+ protected preprocessKeys(...keys: any[]): string[];
135
+ }
136
+ /**
137
+ * ValueEmbedder is the writeable version
138
+ * of optional, it basically is a wrapper
139
+ * around a construct which has a state
140
+ * and can be written to.
141
+ *
142
+ * For the readonly version see Optional
143
+ */
144
+ export declare class ValueEmbedder<T> extends Optional<T> implements IValueHolder<T> {
145
+ static absent: Optional<unknown>;
146
+ protected key: string;
147
+ constructor(rootElem: any, valueKey?: string);
148
+ get value(): T;
149
+ set value(newVal: T);
150
+ orElse(elseValue: any): Optional<any>;
151
+ orElseLazy(func: () => any): Optional<any>;
152
+ /**
153
+ * helper to override several implementations in a more fluent way
154
+ * by having a getClass operation we can avoid direct calls into the constructor or
155
+ * static methods and do not have to implement several methods which rely on the type
156
+ * of "this"
157
+ * @returns ValueEmbedder
158
+ */
159
+ protected getClass(): any;
160
+ static fromNullable<V extends Optional<T>, T>(value?: any, valueKey?: string): V;
161
+ }
@@ -0,0 +1,58 @@
1
+ export declare enum PromiseStatus {
2
+ PENDING = 0,
3
+ FULLFILLED = 1,
4
+ REJECTED = 2
5
+ }
6
+ export interface IPromise {
7
+ then(executorFunc: (val: any) => any): IPromise;
8
+ catch(executorFunc: (val: any) => any): IPromise;
9
+ finally(executorFunc: () => void): IPromise;
10
+ }
11
+ export declare function timeout(timeout: number): CancellablePromise;
12
+ export declare function interval(timeout: number): CancellablePromise;
13
+ /**
14
+ * a small (probably not 100% correct, although I tried to be correct as possible) Promise implementation
15
+ * for systems which do not have a promise implemented
16
+ * Note, although an internal state is kept, this is sideffect free since
17
+ * is value is a function to operate on, hence no real state is kept internally, except for the then
18
+ * and catch calling order
19
+ */
20
+ export declare class Promise implements IPromise {
21
+ status: PromiseStatus;
22
+ protected allFuncs: Array<any>;
23
+ private value;
24
+ constructor(executor: (resolve: (val?: any) => void, reject: (val?: any) => void) => void);
25
+ static all(...promises: Array<IPromise>): IPromise;
26
+ static race(...promises: Array<IPromise>): IPromise;
27
+ static reject(reason: any): Promise;
28
+ static resolve(reason: any): Promise;
29
+ then(executorFunc: (val?: any) => any, catchfunc?: (val?: any) => any): Promise;
30
+ catch(executorFunc: (val?: any) => void): Promise;
31
+ finally(executorFunc: () => void): Promise;
32
+ protected resolve(val?: any): void;
33
+ protected reject(val?: any): void;
34
+ protected appyFinally(): void;
35
+ private spliceLastFuncs;
36
+ private transferIntoNewPromise;
37
+ }
38
+ /**
39
+ * a cancellable promise
40
+ * a Promise with a cancel function, which can be cancellend any time
41
+ * this is useful for promises which use cancellable asynchronous operations
42
+ * note, even in a cancel state, the finally of the promise is executed, however
43
+ * subsequent thens are not anymore.
44
+ * The current then however is fished or a catch is called depending on how the outer
45
+ * operation reacts to a cancel order.
46
+ */
47
+ export declare class CancellablePromise extends Promise {
48
+ /**
49
+ * @param executor asynchronous callback operation which triggers the callback
50
+ * @param cancellator cancel operation, separate from the trigger operation
51
+ */
52
+ constructor(executor: (resolve: (val?: any) => void, reject: (val?: any) => void) => void, cancellator: () => void);
53
+ cancel(): void;
54
+ then(executorFunc: (val?: any) => any, catchfunc?: (val?: any) => any): CancellablePromise;
55
+ catch(executorFunc: (val?: any) => void): CancellablePromise;
56
+ finally(executorFunc: () => void): CancellablePromise;
57
+ private cancellator;
58
+ }
@@ -0,0 +1,22 @@
1
+ /*!
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ /**
20
+ * Promise shim which uses our Promise implementation in the window context
21
+ */
22
+ export {};