reslib 1.0.0

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 (200) hide show
  1. package/README.md +298 -0
  2. package/build/auth/index.d.ts +2034 -0
  3. package/build/auth/index.js +5 -0
  4. package/build/auth/types.d.ts +465 -0
  5. package/build/auth/types.js +1 -0
  6. package/build/countries/countries.d.ts +1454 -0
  7. package/build/countries/countries.js +1 -0
  8. package/build/countries/index.d.ts +159 -0
  9. package/build/countries/index.js +5 -0
  10. package/build/countries/types.d.ts +65 -0
  11. package/build/countries/types.js +1 -0
  12. package/build/currency/currencies.d.ts +8 -0
  13. package/build/currency/currencies.js +1 -0
  14. package/build/currency/index.d.ts +51 -0
  15. package/build/currency/index.js +5 -0
  16. package/build/currency/session.d.ts +23 -0
  17. package/build/currency/session.js +5 -0
  18. package/build/currency/types.d.ts +1039 -0
  19. package/build/currency/types.js +1 -0
  20. package/build/currency/utils.d.ts +25 -0
  21. package/build/currency/utils.js +1 -0
  22. package/build/i18n/index.d.ts +640 -0
  23. package/build/i18n/index.js +5 -0
  24. package/build/inputFormatter/index.d.ts +396 -0
  25. package/build/inputFormatter/index.js +5 -0
  26. package/build/inputFormatter/types.d.ts +544 -0
  27. package/build/inputFormatter/types.js +1 -0
  28. package/build/logger/index.d.ts +235 -0
  29. package/build/logger/index.js +5 -0
  30. package/build/observable/index.d.ts +329 -0
  31. package/build/observable/index.js +1 -0
  32. package/build/platform/index.d.ts +32 -0
  33. package/build/platform/index.js +1 -0
  34. package/build/resources/ResourcePaginationHelper.d.ts +537 -0
  35. package/build/resources/ResourcePaginationHelper.js +2 -0
  36. package/build/resources/decorators/create.decorator.d.ts +20 -0
  37. package/build/resources/decorators/create.decorator.js +1 -0
  38. package/build/resources/decorators/index.d.ts +41 -0
  39. package/build/resources/decorators/index.js +1 -0
  40. package/build/resources/fields/index.d.ts +33 -0
  41. package/build/resources/fields/index.js +1 -0
  42. package/build/resources/filters.d.ts +62 -0
  43. package/build/resources/filters.js +1 -0
  44. package/build/resources/index.d.ts +854 -0
  45. package/build/resources/index.js +6 -0
  46. package/build/resources/types/filters.d.ts +508 -0
  47. package/build/resources/types/filters.js +1 -0
  48. package/build/resources/types/index.d.ts +4138 -0
  49. package/build/resources/types/index.js +1 -0
  50. package/build/session/index.d.ts +1474 -0
  51. package/build/session/index.js +1 -0
  52. package/build/translations/auth.en.d.ts +3 -0
  53. package/build/translations/auth.en.js +1 -0
  54. package/build/translations/countries.en.d.ts +6 -0
  55. package/build/translations/countries.en.js +1 -0
  56. package/build/translations/currencies.en.d.ts +5 -0
  57. package/build/translations/currencies.en.js +1 -0
  58. package/build/translations/date.en.d.ts +19 -0
  59. package/build/translations/date.en.js +1 -0
  60. package/build/translations/index.d.ts +1583 -0
  61. package/build/translations/index.js +5 -0
  62. package/build/translations/resources.en.d.ts +6 -0
  63. package/build/translations/resources.en.js +1 -0
  64. package/build/translations/validator.en.d.ts +104 -0
  65. package/build/translations/validator.en.js +5 -0
  66. package/build/types/date.d.ts +44 -0
  67. package/build/types/date.js +1 -0
  68. package/build/types/dictionary.d.ts +29 -0
  69. package/build/types/dictionary.js +1 -0
  70. package/build/types/i18n.d.ts +121 -0
  71. package/build/types/i18n.js +1 -0
  72. package/build/types/index.d.ts +145 -0
  73. package/build/types/index.js +1 -0
  74. package/build/utils/areEquals.d.ts +19 -0
  75. package/build/utils/areEquals.js +1 -0
  76. package/build/utils/date/dateHelper.d.ts +371 -0
  77. package/build/utils/date/dateHelper.js +5 -0
  78. package/build/utils/date/index.d.ts +212 -0
  79. package/build/utils/date/index.js +5 -0
  80. package/build/utils/date/isDateObj.d.ts +14 -0
  81. package/build/utils/date/isDateObj.js +1 -0
  82. package/build/utils/debounce.d.ts +52 -0
  83. package/build/utils/debounce.js +1 -0
  84. package/build/utils/defaultArray.d.ts +18 -0
  85. package/build/utils/defaultArray.js +1 -0
  86. package/build/utils/defaultBool.d.ts +14 -0
  87. package/build/utils/defaultBool.js +1 -0
  88. package/build/utils/defaultStr.d.ts +17 -0
  89. package/build/utils/defaultStr.js +1 -0
  90. package/build/utils/defaultVal.d.ts +18 -0
  91. package/build/utils/defaultVal.js +1 -0
  92. package/build/utils/dom/index.d.ts +65 -0
  93. package/build/utils/dom/index.js +1 -0
  94. package/build/utils/dom/isDOMElement.d.ts +11 -0
  95. package/build/utils/dom/isDOMElement.js +1 -0
  96. package/build/utils/file/index.d.ts +26 -0
  97. package/build/utils/file/index.js +1 -0
  98. package/build/utils/global.d.ts +53 -0
  99. package/build/utils/global.js +1 -0
  100. package/build/utils/image.d.ts +56 -0
  101. package/build/utils/image.js +1 -0
  102. package/build/utils/index.d.ts +39 -0
  103. package/build/utils/index.js +6 -0
  104. package/build/utils/interpolate.d.ts +105 -0
  105. package/build/utils/interpolate.js +1 -0
  106. package/build/utils/isEmail.d.ts +57 -0
  107. package/build/utils/isEmail.js +1 -0
  108. package/build/utils/isEmpty.d.ts +18 -0
  109. package/build/utils/isEmpty.js +1 -0
  110. package/build/utils/isNonNullString.d.ts +17 -0
  111. package/build/utils/isNonNullString.js +1 -0
  112. package/build/utils/isNullable.d.ts +7 -0
  113. package/build/utils/isNullable.js +1 -0
  114. package/build/utils/isNumber.d.ts +36 -0
  115. package/build/utils/isNumber.js +1 -0
  116. package/build/utils/isPrimitive.d.ts +16 -0
  117. package/build/utils/isPrimitive.js +1 -0
  118. package/build/utils/isPromise.d.ts +14 -0
  119. package/build/utils/isPromise.js +1 -0
  120. package/build/utils/isRegex.d.ts +15 -0
  121. package/build/utils/isRegex.js +1 -0
  122. package/build/utils/isTime.d.ts +18 -0
  123. package/build/utils/isTime.js +1 -0
  124. package/build/utils/json.d.ts +224 -0
  125. package/build/utils/json.js +1 -0
  126. package/build/utils/numbers.d.ts +148 -0
  127. package/build/utils/numbers.js +5 -0
  128. package/build/utils/object.d.ts +567 -0
  129. package/build/utils/object.js +1 -0
  130. package/build/utils/sort.d.ts +67 -0
  131. package/build/utils/sort.js +1 -0
  132. package/build/utils/string.d.ts +165 -0
  133. package/build/utils/string.js +1 -0
  134. package/build/utils/stringify.d.ts +23 -0
  135. package/build/utils/stringify.js +1 -0
  136. package/build/utils/uniqid.d.ts +18 -0
  137. package/build/utils/uniqid.js +1 -0
  138. package/build/utils/uri/index.d.ts +333 -0
  139. package/build/utils/uri/index.js +2 -0
  140. package/build/validator/index.d.ts +4 -0
  141. package/build/validator/index.js +6 -0
  142. package/build/validator/rules/array.d.ts +848 -0
  143. package/build/validator/rules/array.js +5 -0
  144. package/build/validator/rules/boolean.d.ts +87 -0
  145. package/build/validator/rules/boolean.js +5 -0
  146. package/build/validator/rules/date.d.ts +551 -0
  147. package/build/validator/rules/date.js +5 -0
  148. package/build/validator/rules/default.d.ts +367 -0
  149. package/build/validator/rules/default.js +5 -0
  150. package/build/validator/rules/enum.d.ts +155 -0
  151. package/build/validator/rules/enum.js +5 -0
  152. package/build/validator/rules/file.d.ts +356 -0
  153. package/build/validator/rules/file.js +5 -0
  154. package/build/validator/rules/format.d.ts +2825 -0
  155. package/build/validator/rules/format.js +6 -0
  156. package/build/validator/rules/index.d.ts +16 -0
  157. package/build/validator/rules/index.js +6 -0
  158. package/build/validator/rules/multiRules.d.ts +475 -0
  159. package/build/validator/rules/multiRules.js +5 -0
  160. package/build/validator/rules/numeric.d.ts +1135 -0
  161. package/build/validator/rules/numeric.js +5 -0
  162. package/build/validator/rules/string.d.ts +504 -0
  163. package/build/validator/rules/string.js +5 -0
  164. package/build/validator/rules/target.d.ts +137 -0
  165. package/build/validator/rules/target.js +5 -0
  166. package/build/validator/rules/utils.d.ts +1 -0
  167. package/build/validator/rules/utils.js +1 -0
  168. package/build/validator/rulesMarkers.d.ts +11 -0
  169. package/build/validator/rulesMarkers.js +1 -0
  170. package/build/validator/types.d.ts +2906 -0
  171. package/build/validator/types.js +1 -0
  172. package/build/validator/validator.d.ts +3692 -0
  173. package/build/validator/validator.js +5 -0
  174. package/lib/cjs/auth.js +1 -0
  175. package/lib/cjs/countries.js +1 -0
  176. package/lib/cjs/currency.js +1 -0
  177. package/lib/cjs/i18n.js +1 -0
  178. package/lib/cjs/inputFormatter.js +1 -0
  179. package/lib/cjs/logger.js +1 -0
  180. package/lib/cjs/observable.js +1 -0
  181. package/lib/cjs/platform.js +1 -0
  182. package/lib/cjs/resources.js +1 -0
  183. package/lib/cjs/session.js +1 -0
  184. package/lib/cjs/types.js +1 -0
  185. package/lib/cjs/utils.js +1 -0
  186. package/lib/cjs/validator.js +1 -0
  187. package/lib/esm/auth.mjs +1 -0
  188. package/lib/esm/countries.mjs +1 -0
  189. package/lib/esm/currency.mjs +1 -0
  190. package/lib/esm/i18n.mjs +1 -0
  191. package/lib/esm/inputFormatter.mjs +1 -0
  192. package/lib/esm/logger.mjs +1 -0
  193. package/lib/esm/observable.mjs +1 -0
  194. package/lib/esm/platform.mjs +1 -0
  195. package/lib/esm/resources.mjs +1 -0
  196. package/lib/esm/session.mjs +1 -0
  197. package/lib/esm/types.mjs +1 -0
  198. package/lib/esm/utils.mjs +1 -0
  199. package/lib/esm/validator.mjs +1 -0
  200. package/package.json +244 -0
@@ -0,0 +1,329 @@
1
+ import 'reflect-metadata';
2
+ /**
3
+ * @interface ObservableCallback
4
+ * Represents the callback options for observable events.
5
+ *
6
+ * This type defines a function that can be used as a callback for observable events.
7
+ * It accepts a variable number of arguments of any type and returns a value of any type.
8
+ *
9
+ * Callbacks of this type can be utilized in various event-driven scenarios, allowing
10
+ * flexibility in the number and types of parameters passed to the callback.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const callback: ObservableCallback = (arg1: string, arg2: number) => {
15
+ * console.log(arg1, arg2); // Outputs the string and number passed to the callback
16
+ * };
17
+ *
18
+ * // Invoking the callback with different types of arguments
19
+ * callback("Event triggered", 42); // Outputs: Event triggered 42
20
+ * callback("Another event", 100); // Outputs: Another event 100
21
+ * ```
22
+ */
23
+ export type ObservableCallback = (...args: any[]) => any;
24
+ /**
25
+ * Represents a collection of observable callbacks mapped to their respective event types,
26
+ * allowing for optional event handling.
27
+ *
28
+ * This type defines a record structure where each key corresponds to a specific event type,
29
+ * and the value is an array of callback functions associated with that event. The use of
30
+ * `Partial` allows for flexibility, meaning that not all event types need to have registered
31
+ * callbacks, making it suitable for scenarios where some events may not be utilized.
32
+ *
33
+ * @template TEventType - A generic type parameter that extends from `string`, representing
34
+ * the event types. By default, it is set to `string`, allowing for
35
+ * any string-based event name.
36
+ *
37
+ * @example
38
+ * // Defining specific event types
39
+ * type MyEvent = 'click' | 'hover' | 'scroll';
40
+ *
41
+ * // Creating a record of callbacks for the defined events
42
+ * const callbacks: ObservableCallbacks<MyEvent> = {
43
+ * click: [
44
+ * (event) => console.log('Click event handler 1', event),
45
+ * (event) => console.log('Click event handler 2', event),
46
+ * ],
47
+ * hover: [
48
+ * (event) => console.log('Hover event handler', event),
49
+ * ],
50
+ * // 'scroll' event has no callbacks registered
51
+ * };
52
+ *
53
+ * // Accessing the callbacks for a specific event
54
+ * const clickHandlers = callbacks.click;
55
+ * if (clickHandlers) {
56
+ * clickHandlers.forEach(handler => handler('click')); // Logs: Click event handler 1 click
57
+ * // Logs: Click event handler 2 click
58
+ * }
59
+ *
60
+ * @remarks
61
+ * This type is particularly useful in event-driven architectures where multiple callbacks
62
+ * need to be associated with different events. The use of `Partial` allows for a more
63
+ * flexible design, enabling developers to define only the events they are interested in
64
+ * without requiring all possible events to be present.
65
+ */
66
+ export type ObservableCallbacks<TEventType extends string = string> = Partial<Record<TEventType | ObservableAllEventType, ObservableCallback[]>>;
67
+ /**
68
+ * Represents a wildcard event type for observable systems.
69
+ *
70
+ * This type is used to signify that a callback should be triggered for all events within
71
+ * an observable system. It acts as a catch-all for any event, allowing developers to
72
+ * register handlers that respond to every event emitted by the observable.
73
+ *
74
+ * @example
75
+ * // Using the wildcard event type to listen for all events
76
+ * observable.on('*', (event, ...args) => {
77
+ * console.log(`An event occurred: ${event}`, 'Arguments:', args);
78
+ * });
79
+ *
80
+ * @remarks
81
+ * The use of a wildcard event type can be useful for logging, debugging, or handling
82
+ * global events that are not specific to a single event type. However, it should be used
83
+ * judiciously, as it may lead to performance concerns if many events are emitted frequently.
84
+ */
85
+ export type ObservableAllEventType = '*';
86
+ export type Observable<TEventType extends string = string, Context = unknown> = {
87
+ _____isObservable?: boolean;
88
+ on: (event: TEventType, fn: ObservableCallback) => {
89
+ remove: () => any;
90
+ };
91
+ finally: (event: TEventType, fn: ObservableCallback) => Observable<TEventType>;
92
+ off: (event: TEventType, fn: ObservableCallback) => Observable<TEventType>;
93
+ trigger: (event: TEventType | ObservableAllEventType, ...args: any[]) => Observable<TEventType>;
94
+ offAll: () => Observable<TEventType>;
95
+ once: (event: TEventType, fn: ObservableCallback) => {
96
+ remove: () => any;
97
+ };
98
+ getEventCallBacks: () => ObservableCallbacks<TEventType>;
99
+ } & Context;
100
+ /**
101
+ * Returns an instance of the Observable interface.
102
+ * The `observableFactory` function creates a new observable object with methods to manage
103
+ * event listeners and trigger events. The returned observable object allows for adding,
104
+ * removing, and triggering event callbacks, as well as managing final callbacks that execute
105
+ * after all other callbacks for an event.
106
+ *
107
+ * @returns {Observable<TEventType>} A new instance of the observable object.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const observable = observableFactory();
112
+ * observable.on("event", (arg1, arg2) => {
113
+ * console.log(arg1, arg2);
114
+ * });
115
+ * observable.trigger("event", "Hello", "World"); // Outputs: Hello World
116
+ * observable.on("event",function(){
117
+ * console.log("event triggered");
118
+ * })
119
+ * ```
120
+ * @see {@link Observable} for more information on the observable interface.
121
+ * @see {@link ObservableCallbacks} for more information on the observable callbacks interface.
122
+ * @see {@link ObservableAllEventType} for more information on the observable all event type.
123
+ * @see {@link isObservable} for more information on the observable check function.
124
+ */
125
+ export declare const observableFactory: <TEventType extends string = string, Context = unknown>(context?: Context) => Observable<TEventType, Context>;
126
+ /**
127
+ * Creates an observable object based on the provided element.
128
+ *
129
+ * The `observable` function checks if the given element is already observable. If it is,
130
+ * the function returns the existing observable instance. If not, it creates a new observable
131
+ * instance and extends the provided element with observable methods. This allows the element
132
+ * to listen for events, trigger callbacks, and manage event listeners.
133
+ *
134
+ * @template TEventType - The type of the event. This can be any string or a custom type.
135
+ * @param {any} element - The element to make observable. This can be any object or value.
136
+ * @returns {Observable<TEventType>} The observable object, which includes methods for event handling.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const context = observable({});
141
+ * const testCb = (e) => console.log("test");
142
+ * context.on("test", testCb);
143
+ * context.trigger("test");
144
+ * context.off("test", testCb);
145
+ * context.offAll();
146
+ * ```
147
+ * @see {@link Observable} for more information on the observable interface.
148
+ * @see {@link ObservableCallbacks} for more information on the observable callbacks interface.
149
+ * @see {@link ObservableAllEventType} for more information on the observable all event type.
150
+ * @see {@link isObservable} for more information on the observable check function.
151
+ */
152
+ export declare const observable: <TEventType extends string = string>(element: any) => Observable<TEventType>;
153
+ /**
154
+ * Exports the ObservableClass that implements the Observable interface.
155
+ *
156
+ * This class provides a way to create observable objects that can emit events and have
157
+ * listeners attached to them. It encapsulates the observable functionality, allowing
158
+ * users to manage events and their corresponding callbacks in a structured manner.
159
+ *
160
+ * The ObservableClass is particularly useful in scenarios where you need to implement
161
+ * an event-driven architecture, enabling decoupled communication between different parts
162
+ * of an application.
163
+ * @template TEventType - The type of the event. This can be any string or a custom type.
164
+ */
165
+ export declare class ObservableClass<TEventType extends string = string> implements Observable<TEventType> {
166
+ /**
167
+ * Flag indicating whether the object is observable.
168
+ *
169
+ * This property is used internally to identify instances of observable objects.
170
+ * It is set to true for all instances of this class.
171
+ */
172
+ readonly _____isObservable?: boolean | undefined;
173
+ /**
174
+ * The internal observable object that provides the observable functionality.
175
+ *
176
+ * This object is created using the observableFactory function and contains
177
+ * the core methods for managing event listeners and triggering events.
178
+ */
179
+ readonly _observable: {
180
+ _____isObservable?: boolean;
181
+ on: (event: TEventType, fn: ObservableCallback) => {
182
+ remove: () => any;
183
+ };
184
+ finally: (event: TEventType, fn: ObservableCallback) => /*elided*/ any;
185
+ off: (event: TEventType, fn: ObservableCallback) => /*elided*/ any;
186
+ trigger: (event: "*" | TEventType, ...args: any[]) => /*elided*/ any;
187
+ offAll: () => /*elided*/ any;
188
+ once: (event: TEventType, fn: ObservableCallback) => {
189
+ remove: () => any;
190
+ };
191
+ getEventCallBacks: () => Partial<Record<"*" | TEventType, ObservableCallback[]>>;
192
+ };
193
+ /**
194
+ * Listen to the given `event` and execute the `callback` each time an event is triggered.
195
+ *
196
+ * @param {TEventType} event - The event to listen to.
197
+ * @param {ObservableCallback} fn - The callback function to execute.
198
+ * @returns {{ remove: () => any }} An object with a `remove` method to remove the callback.
199
+ *
200
+ * @example
201
+ * ```typescript
202
+ * const observable = new ObservableClass();
203
+ * const subscription = observable.on("dataReceived", (data) => {
204
+ * console.log("Data received:", data);
205
+ * });
206
+ * ```
207
+ */
208
+ on(event: TEventType, fn: ObservableCallback): {
209
+ remove: () => any;
210
+ };
211
+ /**
212
+ * Add a callback function to an event that will be triggered once.
213
+ *
214
+ * This method ensures that the callback is executed only the first time the event is triggered.
215
+ *
216
+ * @param {TEventType} event - The event to listen to.
217
+ * @param {ObservableCallback} fn - The callback function to execute.
218
+ * @returns {Observable<TEventType>} The observable object.
219
+ *
220
+ * @example
221
+ * ```typescript
222
+ * observable.finally("dataProcessed", () => {
223
+ * console.log("Data has been processed.");
224
+ * });
225
+ * ```
226
+ */
227
+ finally(event: TEventType, fn: ObservableCallback): Observable<TEventType>;
228
+ /**
229
+ * Removes the given `event` listener.
230
+ *
231
+ * If `fn` is provided, this method removes the specific callback function from the event.
232
+ * If `fn` is not provided, it removes all callback functions associated with the event.
233
+ *
234
+ * @param {TEventType} event - The event to remove the listener from.
235
+ * @param {ObservableCallback} [fn] - The callback function to remove.
236
+ * @returns {Observable<TEventType>} The observable object.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * observable.off("dataReceived", subscription.remove);
241
+ * ```
242
+ */
243
+ off(event: TEventType, fn: ObservableCallback): Observable<TEventType>;
244
+ /**
245
+ * Execute all callback functions that listen to the given `event`.
246
+ *
247
+ * If the last argument is a function, it will be treated as the final callback function
248
+ * to be executed after all other callbacks.
249
+ *
250
+ * @param {TEventType} event - The event to trigger.
251
+ * @param {...any[]} args - The arguments to pass to the callback functions.
252
+ * @returns {Observable<TEventType>} The observable object.
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * observable.trigger("dataReceived", { id: 1, value: "Hello" });
257
+ * ```
258
+ */
259
+ trigger(event: TEventType | ObservableAllEventType, ...args: any[]): Observable<TEventType>;
260
+ /**
261
+ * Remove all event bindings.
262
+ *
263
+ * This method clears all event listeners for the observable object.
264
+ *
265
+ * @returns {Observable<TEventType>} The observable object.
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * observable.offAll();
270
+ * ```
271
+ */
272
+ offAll(): Observable<TEventType>;
273
+ /**
274
+ * Listen to the given `event` and execute the `callback` at most once.
275
+ *
276
+ * This method ensures that the callback is executed only once, even if the event is triggered multiple times.
277
+ *
278
+ * @param {TEventType} event - The event to listen to.
279
+ * @param {ObservableCallback} fn - The callback function to execute.
280
+ * @returns {{ remove: () => any }} An object with a `remove` method to remove the callback.
281
+ *
282
+ * @example
283
+ * ```typescript
284
+ * const subscription = observable.once("dataLoaded", () => {
285
+ * console.log("Data has been loaded.");
286
+ * });
287
+ * ```
288
+ */
289
+ once(event: TEventType, fn: ObservableCallback): {
290
+ remove: () => any;
291
+ };
292
+ /**
293
+ * Get all event callbacks.
294
+ *
295
+ * This method returns an object with event names as keys and arrays of callback functions as values.
296
+ *
297
+ * @returns {ObservableCallbacks<TEventType>} An object with event names as keys and arrays of callback functions as values.
298
+ *
299
+ * @example
300
+ * ```typescript
301
+ * const callbacks = observable.getEventCallBacks();
302
+ * console.log(callbacks);
303
+ * ```
304
+ */
305
+ getEventCallBacks(): ObservableCallbacks<TEventType>;
306
+ }
307
+ /**
308
+ * Checks if the given object is an observable element.
309
+ *
310
+ * An object is considered observable if it implements the Observable interface and has
311
+ * the following properties and methods:
312
+ * - `_____isObservable` set to `true`
313
+ * - `on` method
314
+ * - `trigger` method
315
+ * - `off` method
316
+ *
317
+ * @param {any} obj - The object to check.
318
+ * @returns {boolean} `true` if the object is observable, `false` otherwise.
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * const observable = new ObservableClass();
323
+ * console.log(isObservable(observable)); // true
324
+ *
325
+ * const nonObservable = {};
326
+ * console.log(isObservable(nonObservable)); // false
327
+ * ```
328
+ */
329
+ export declare function isObservable(obj: any): boolean;
@@ -0,0 +1 @@
1
+ 'use strict';require('reflect-metadata');var O=Object.defineProperty,h=Object.defineProperties;var g=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var y=(t,e,l)=>e in t?O(t,e,{enumerable:true,configurable:true,writable:true,value:l}):t[e]=l,f=(t,e)=>{for(var l in e||(e={}))C.call(e,l)&&y(t,l,e[l]);if(T)for(var l of T(e))k.call(e,l)&&y(t,l,e[l]);return t},p=(t,e)=>h(t,g(e));var u=function(t){let e={},l={},o=Array.prototype.slice;return p(f({},Object.assign({},t)),{on:function(n,a){return a&&n&&(e[n]=e[n]||[]).push(a),{remove:()=>{this.off(n,a);}}},finally:function(n,a){return a&&n?((l[n]=l[n]||[]).push(a),this):this},off:function(n,a){if(!n)return this;if(n=="*"&&!a)e={};else if(a)for(var s=e[n],r=0,b;b=s&&s[r];++r)b==a&&s.splice(r--,1);return this},once:function(n,a){let s=(...r)=>{this.off(n,s),a.apply(this,r);};return this.on(n,s)},trigger:function(n,...a){if(!n)return this;let s,r,b,v=null;typeof a[a.length-1]=="function"&&(v=a.pop()),s=o.call(e[n]||[],0);let i=[];for(b=0;r=s[b];++b)typeof r=="function"&&i.push(r.apply(this,a));typeof e["*"]=="function"&&n!="*"&&(this.trigger(n,...a),this.trigger("*",...a));var E=o.call(l[n]||[],0);for(b=0;r=E[b];++b)r.call(this,i,a);return v&&v.call(this,i,a),this},offAll:function(){return e={},l={},this},getEventCallBacks:function(){return e}})},A=function(t){if(_(t))return t;let e=t||{},l=u();return Object.defineProperties(e,{_____isObservable:{value:true},on:{value:l.on.bind(e)},finally:{value:l.finally.bind(e)},off:{value:l.off.bind(e)},offAll:{value:l.offAll.bind(e)},once:{value:l.once.bind(e)},getEventCallBacks:{value:l.getEventCallBacks.bind(e)},trigger:{value:l.trigger.bind(e)}}),e},c=class{constructor(){this._____isObservable=true;this._observable=u();}on(e,l){return this._observable.on.call(this,e,l)}finally(e,l){return this._observable.finally.call(this,e,l)}off(e,l){return this._observable.off.call(this,e,l)}trigger(e,...l){return this._observable.trigger.call(this,e,...l)}offAll(){return this._observable.offAll.call(this)}once(e,l){return this._observable.once.call(this,e,l)}getEventCallBacks(){return this._observable.getEventCallBacks.call(this)}};function _(t){if(!t||["string","boolean","number"].includes(typeof t))return false;try{return (t==null?void 0:t._____isObservable)===!0&&typeof(t==null?void 0:t.on)=="function"&&typeof(t==null?void 0:t.trigger)=="function"&&typeof(t==null?void 0:t.off)=="function"}catch(e){}return false}exports.ObservableClass=c;exports.isObservable=_;exports.observable=A;exports.observableFactory=u;
@@ -0,0 +1,32 @@
1
+ import 'reflect-metadata';
2
+ /**
3
+ @group Platform
4
+ * Checks if the current environment is a web environment.
5
+ * This function checks for the presence of the `window` object and its `document` property,
6
+ * as well as the `document` object itself, to determine if the environment is a web environment.
7
+ * @returns {boolean} True if the environment is a web environment, false otherwise.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * if (isWeb()) {
12
+ * console.log("We're in a web environment!");
13
+ * } else {
14
+ * console.log("We're not in a web environment.");
15
+ * }
16
+ * ```
17
+ */
18
+ declare function isWeb(): boolean;
19
+ export declare const Platform: {
20
+ isWeb: typeof isWeb;
21
+ isLinux: () => boolean;
22
+ isDarwin: () => boolean;
23
+ isWin32: () => boolean;
24
+ isNode: () => boolean;
25
+ isElectron: () => boolean;
26
+ isTouchDevice: () => boolean;
27
+ isServerSide: () => boolean;
28
+ isClientSide: () => boolean;
29
+ isAndroidMobileBrowser: () => boolean;
30
+ isReactNativeWebview: () => boolean;
31
+ };
32
+ export {};
@@ -0,0 +1 @@
1
+ 'use strict';require('reflect-metadata');function t(){return typeof window!="undefined"&&(window==null?void 0:window.document)!==void 0&&typeof document!="undefined"&&typeof navigator!="undefined"}var n=()=>{var e;try{if(typeof process!="undefined"&&(process!=null&&process.versions)&&((e=process==null?void 0:process.versions)!=null&&e.node)||typeof global=="object"&&(global==null?void 0:global.toString.call(global))==="[object global]")return !0}catch(o){}return false},i=()=>{var e,o;return !!(typeof window!="undefined"&&window&&typeof(window==null?void 0:window.process)=="object"&&((e=window==null?void 0:window.process)==null?void 0:e.type)==="renderer"||typeof process!="undefined"&&typeof(process==null?void 0:process.versions)=="object"&&((o=process.versions)!=null&&o.electron)||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&String(navigator==null?void 0:navigator.userAgent).toLowerCase().indexOf("electron")>=0)},s=()=>{if(typeof document!="undefined"&&document)try{return document.createEvent("TouchEvent"),!0}catch(e){try{return "ontouchstart"in window||"onmsgesturechange"in window}catch(o){}}return false},a=()=>typeof window=="undefined"&&typeof process!="undefined",r=()=>!!(typeof window!="undefined"&&typeof window=="object"&&window),c=()=>{if(!t()||typeof navigator!="object"||!navigator||typeof navigator.userAgent!="string")return false;let e=navigator.userAgent.toLowerCase();return /android/i.test(e)},u=()=>{var e;return !r()||!(window!=null&&window.ReactNativeWebView)?false:typeof((e=window==null?void 0:window.ReactNativeWebView)==null?void 0:e.postMessage)=="function"},f=()=>n()&&process.platform==="darwin",d=()=>n()&&process.platform==="win32",l=()=>n()&&process.platform==="linux",b={isWeb:t,isLinux:l,isDarwin:f,isWin32:d,isNode:n,isElectron:i,isTouchDevice:s,isServerSide:a,isClientSide:r,isAndroidMobileBrowser:c,isReactNativeWebview:u};exports.Platform=b;