@waku/core 0.0.1

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 (235) hide show
  1. package/CHANGELOG.md +614 -0
  2. package/README.md +56 -0
  3. package/bundle/browser-1e1a2f27.js +722 -0
  4. package/bundle/crypto-8551d579.js +2585 -0
  5. package/bundle/crypto-b00764b7.js +1772 -0
  6. package/bundle/enr-564d4a51.js +20785 -0
  7. package/bundle/enr-9fc5eed8.js +20786 -0
  8. package/bundle/enr-f6e82a53.js +20785 -0
  9. package/bundle/events-158407bb.js +1929 -0
  10. package/bundle/events-fcbda4dc.js +76 -0
  11. package/bundle/index-02d21809.js +20 -0
  12. package/bundle/index-0a4bdddc.js +2976 -0
  13. package/bundle/index-2ae915be.js +1854 -0
  14. package/bundle/index-64ce43f0.js +69 -0
  15. package/bundle/index-691c0be6.js +4059 -0
  16. package/bundle/index-a013a259.js +20 -0
  17. package/bundle/index-ba42b4fc.js +862 -0
  18. package/bundle/index.js +13428 -0
  19. package/bundle/lib/enr.js +8 -0
  20. package/bundle/lib/peer_discovery_dns.js +5018 -0
  21. package/bundle/lib/peer_discovery_static_list.js +75 -0
  22. package/bundle/lib/predefined_bootstrap_nodes.js +59 -0
  23. package/bundle/lib/utils.js +1 -0
  24. package/bundle/lib/wait_for_remote_peer.js +327 -0
  25. package/bundle/lib/waku_message/topic_only_message.js +4 -0
  26. package/bundle/lib/waku_message/version_0.js +4 -0
  27. package/bundle/lib/waku_message/version_1.js +463 -0
  28. package/bundle/message-e2db79d7.js +8393 -0
  29. package/bundle/multiaddr_to_peer_info-c406b1e1.js +19 -0
  30. package/bundle/multiaddr_to_peer_info-fd1de516.js +19 -0
  31. package/bundle/random_subset-75d1c511.js +26 -0
  32. package/bundle/topic_only_message-34f36fa6.js +82 -0
  33. package/bundle/utils-9a3221f2.js +815 -0
  34. package/bundle/version_0-e6fe440c.js +317 -0
  35. package/dist/index.d.ts +16 -0
  36. package/dist/index.js +17 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/lib/constants.d.ts +4 -0
  39. package/dist/lib/constants.js +5 -0
  40. package/dist/lib/constants.js.map +1 -0
  41. package/dist/lib/crypto.d.ts +34 -0
  42. package/dist/lib/crypto.js +79 -0
  43. package/dist/lib/crypto.js.map +1 -0
  44. package/dist/lib/enr/constants.d.ts +4 -0
  45. package/dist/lib/enr/constants.js +8 -0
  46. package/dist/lib/enr/constants.js.map +1 -0
  47. package/dist/lib/enr/enr.d.ts +90 -0
  48. package/dist/lib/enr/enr.js +432 -0
  49. package/dist/lib/enr/enr.js.map +1 -0
  50. package/dist/lib/enr/index.d.ts +5 -0
  51. package/dist/lib/enr/index.js +6 -0
  52. package/dist/lib/enr/index.js.map +1 -0
  53. package/dist/lib/enr/keypair/index.d.ts +8 -0
  54. package/dist/lib/enr/keypair/index.js +53 -0
  55. package/dist/lib/enr/keypair/index.js.map +1 -0
  56. package/dist/lib/enr/keypair/secp256k1.d.ts +13 -0
  57. package/dist/lib/enr/keypair/secp256k1.js +57 -0
  58. package/dist/lib/enr/keypair/secp256k1.js.map +1 -0
  59. package/dist/lib/enr/keypair/types.d.ts +13 -0
  60. package/dist/lib/enr/keypair/types.js +7 -0
  61. package/dist/lib/enr/keypair/types.js.map +1 -0
  62. package/dist/lib/enr/multiaddr_from_fields.d.ts +2 -0
  63. package/dist/lib/enr/multiaddr_from_fields.js +8 -0
  64. package/dist/lib/enr/multiaddr_from_fields.js.map +1 -0
  65. package/dist/lib/enr/multiaddrs_codec.d.ts +3 -0
  66. package/dist/lib/enr/multiaddrs_codec.js +32 -0
  67. package/dist/lib/enr/multiaddrs_codec.js.map +1 -0
  68. package/dist/lib/enr/types.d.ts +8 -0
  69. package/dist/lib/enr/types.js +3 -0
  70. package/dist/lib/enr/types.js.map +1 -0
  71. package/dist/lib/enr/v4.d.ts +3 -0
  72. package/dist/lib/enr/v4.js +14 -0
  73. package/dist/lib/enr/v4.js.map +1 -0
  74. package/dist/lib/enr/waku2_codec.d.ts +8 -0
  75. package/dist/lib/enr/waku2_codec.js +36 -0
  76. package/dist/lib/enr/waku2_codec.js.map +1 -0
  77. package/dist/lib/group_by.d.ts +3 -0
  78. package/dist/lib/group_by.js +13 -0
  79. package/dist/lib/group_by.js.map +1 -0
  80. package/dist/lib/multiaddr_to_peer_info.d.ts +3 -0
  81. package/dist/lib/multiaddr_to_peer_info.js +15 -0
  82. package/dist/lib/multiaddr_to_peer_info.js.map +1 -0
  83. package/dist/lib/peer_discovery_dns/dns.d.ts +48 -0
  84. package/dist/lib/peer_discovery_dns/dns.js +158 -0
  85. package/dist/lib/peer_discovery_dns/dns.js.map +1 -0
  86. package/dist/lib/peer_discovery_dns/dns_over_https.d.ts +32 -0
  87. package/dist/lib/peer_discovery_dns/dns_over_https.js +87 -0
  88. package/dist/lib/peer_discovery_dns/dns_over_https.js.map +1 -0
  89. package/dist/lib/peer_discovery_dns/enrtree.d.ts +33 -0
  90. package/dist/lib/peer_discovery_dns/enrtree.js +76 -0
  91. package/dist/lib/peer_discovery_dns/enrtree.js.map +1 -0
  92. package/dist/lib/peer_discovery_dns/fetch_nodes.d.ts +14 -0
  93. package/dist/lib/peer_discovery_dns/fetch_nodes.js +133 -0
  94. package/dist/lib/peer_discovery_dns/fetch_nodes.js.map +1 -0
  95. package/dist/lib/peer_discovery_dns/index.d.ts +30 -0
  96. package/dist/lib/peer_discovery_dns/index.js +54 -0
  97. package/dist/lib/peer_discovery_dns/index.js.map +1 -0
  98. package/dist/lib/peer_discovery_static_list.d.ts +44 -0
  99. package/dist/lib/peer_discovery_static_list.js +72 -0
  100. package/dist/lib/peer_discovery_static_list.js.map +1 -0
  101. package/dist/lib/predefined_bootstrap_nodes.d.ts +35 -0
  102. package/dist/lib/predefined_bootstrap_nodes.js +56 -0
  103. package/dist/lib/predefined_bootstrap_nodes.js.map +1 -0
  104. package/dist/lib/push_or_init_map.d.ts +1 -0
  105. package/dist/lib/push_or_init_map.js +9 -0
  106. package/dist/lib/push_or_init_map.js.map +1 -0
  107. package/dist/lib/random_subset.d.ts +4 -0
  108. package/dist/lib/random_subset.js +25 -0
  109. package/dist/lib/random_subset.js.map +1 -0
  110. package/dist/lib/select_connection.d.ts +2 -0
  111. package/dist/lib/select_connection.js +19 -0
  112. package/dist/lib/select_connection.js.map +1 -0
  113. package/dist/lib/select_peer.d.ts +15 -0
  114. package/dist/lib/select_peer.js +59 -0
  115. package/dist/lib/select_peer.js.map +1 -0
  116. package/dist/lib/to_proto_message.d.ts +3 -0
  117. package/dist/lib/to_proto_message.js +11 -0
  118. package/dist/lib/to_proto_message.js.map +1 -0
  119. package/dist/lib/utils.d.ts +22 -0
  120. package/dist/lib/utils.js +40 -0
  121. package/dist/lib/utils.js.map +1 -0
  122. package/dist/lib/wait_for_remote_peer.d.ts +22 -0
  123. package/dist/lib/wait_for_remote_peer.js +113 -0
  124. package/dist/lib/wait_for_remote_peer.js.map +1 -0
  125. package/dist/lib/waku.d.ts +61 -0
  126. package/dist/lib/waku.js +174 -0
  127. package/dist/lib/waku.js.map +1 -0
  128. package/dist/lib/waku_filter/filter_rpc.d.ts +25 -0
  129. package/dist/lib/waku_filter/filter_rpc.js +44 -0
  130. package/dist/lib/waku_filter/filter_rpc.js.map +1 -0
  131. package/dist/lib/waku_filter/index.d.ts +50 -0
  132. package/dist/lib/waku_filter/index.js +181 -0
  133. package/dist/lib/waku_filter/index.js.map +1 -0
  134. package/dist/lib/waku_light_push/index.d.ts +38 -0
  135. package/dist/lib/waku_light_push/index.js +83 -0
  136. package/dist/lib/waku_light_push/index.js.map +1 -0
  137. package/dist/lib/waku_light_push/push_rpc.d.ts +11 -0
  138. package/dist/lib/waku_light_push/push_rpc.js +31 -0
  139. package/dist/lib/waku_light_push/push_rpc.js.map +1 -0
  140. package/dist/lib/waku_message/constants.d.ts +12 -0
  141. package/dist/lib/waku_message/constants.js +10 -0
  142. package/dist/lib/waku_message/constants.js.map +1 -0
  143. package/dist/lib/waku_message/ecies.d.ts +17 -0
  144. package/dist/lib/waku_message/ecies.js +126 -0
  145. package/dist/lib/waku_message/ecies.js.map +1 -0
  146. package/dist/lib/waku_message/symmetric.d.ts +3 -0
  147. package/dist/lib/waku_message/symmetric.js +18 -0
  148. package/dist/lib/waku_message/symmetric.js.map +1 -0
  149. package/dist/lib/waku_message/topic_only_message.d.ts +15 -0
  150. package/dist/lib/waku_message/topic_only_message.js +31 -0
  151. package/dist/lib/waku_message/topic_only_message.js.map +1 -0
  152. package/dist/lib/waku_message/version_0.d.ts +26 -0
  153. package/dist/lib/waku_message/version_0.js +96 -0
  154. package/dist/lib/waku_message/version_0.js.map +1 -0
  155. package/dist/lib/waku_message/version_1.d.ts +93 -0
  156. package/dist/lib/waku_message/version_1.js +325 -0
  157. package/dist/lib/waku_message/version_1.js.map +1 -0
  158. package/dist/lib/waku_relay/constants.d.ts +63 -0
  159. package/dist/lib/waku_relay/constants.js +67 -0
  160. package/dist/lib/waku_relay/constants.js.map +1 -0
  161. package/dist/lib/waku_relay/index.d.ts +65 -0
  162. package/dist/lib/waku_relay/index.js +111 -0
  163. package/dist/lib/waku_relay/index.js.map +1 -0
  164. package/dist/lib/waku_store/history_rpc.d.ts +27 -0
  165. package/dist/lib/waku_store/history_rpc.js +71 -0
  166. package/dist/lib/waku_store/history_rpc.js.map +1 -0
  167. package/dist/lib/waku_store/index.d.ts +126 -0
  168. package/dist/lib/waku_store/index.js +218 -0
  169. package/dist/lib/waku_store/index.js.map +1 -0
  170. package/dist/proto/filter.d.ts +65 -0
  171. package/dist/proto/filter.js +425 -0
  172. package/dist/proto/filter.js.map +1 -0
  173. package/dist/proto/light_push.d.ts +57 -0
  174. package/dist/proto/light_push.js +369 -0
  175. package/dist/proto/light_push.js.map +1 -0
  176. package/dist/proto/message.d.ts +29 -0
  177. package/dist/proto/message.js +215 -0
  178. package/dist/proto/message.js.map +1 -0
  179. package/dist/proto/store.d.ts +104 -0
  180. package/dist/proto/store.js +602 -0
  181. package/dist/proto/store.js.map +1 -0
  182. package/dist/proto/topic_only_message.d.ts +10 -0
  183. package/dist/proto/topic_only_message.js +46 -0
  184. package/dist/proto/topic_only_message.js.map +1 -0
  185. package/package.json +292 -0
  186. package/src/index.ts +33 -0
  187. package/src/lib/constants.ts +4 -0
  188. package/src/lib/crypto.ts +100 -0
  189. package/src/lib/enr/constants.ts +10 -0
  190. package/src/lib/enr/enr.ts +516 -0
  191. package/src/lib/enr/index.ts +5 -0
  192. package/src/lib/enr/keypair/index.ts +76 -0
  193. package/src/lib/enr/keypair/secp256k1.ts +69 -0
  194. package/src/lib/enr/keypair/types.ts +14 -0
  195. package/src/lib/enr/multiaddr_from_fields.ts +18 -0
  196. package/src/lib/enr/multiaddrs_codec.ts +50 -0
  197. package/src/lib/enr/types.ts +11 -0
  198. package/src/lib/enr/v4.ts +22 -0
  199. package/src/lib/enr/waku2_codec.ts +39 -0
  200. package/src/lib/group_by.ts +14 -0
  201. package/src/lib/multiaddr_to_peer_info.ts +17 -0
  202. package/src/lib/peer_discovery_dns/dns.ts +223 -0
  203. package/src/lib/peer_discovery_dns/dns_over_https.ts +98 -0
  204. package/src/lib/peer_discovery_dns/enrtree.ts +123 -0
  205. package/src/lib/peer_discovery_dns/fetch_nodes.ts +180 -0
  206. package/src/lib/peer_discovery_dns/index.ts +84 -0
  207. package/src/lib/peer_discovery_static_list.ts +118 -0
  208. package/src/lib/predefined_bootstrap_nodes.ts +72 -0
  209. package/src/lib/push_or_init_map.ts +13 -0
  210. package/src/lib/random_subset.ts +30 -0
  211. package/src/lib/select_connection.ts +24 -0
  212. package/src/lib/select_peer.ts +77 -0
  213. package/src/lib/to_proto_message.ts +15 -0
  214. package/src/lib/utils.ts +50 -0
  215. package/src/lib/wait_for_remote_peer.ts +151 -0
  216. package/src/lib/waku.ts +258 -0
  217. package/src/lib/waku_filter/filter_rpc.ts +57 -0
  218. package/src/lib/waku_filter/index.ts +291 -0
  219. package/src/lib/waku_light_push/index.ts +137 -0
  220. package/src/lib/waku_light_push/push_rpc.ts +39 -0
  221. package/src/lib/waku_message/constants.ts +10 -0
  222. package/src/lib/waku_message/ecies.ts +194 -0
  223. package/src/lib/waku_message/symmetric.ts +33 -0
  224. package/src/lib/waku_message/topic_only_message.ts +40 -0
  225. package/src/lib/waku_message/version_0.ts +121 -0
  226. package/src/lib/waku_message/version_1.ts +457 -0
  227. package/src/lib/waku_relay/constants.ts +77 -0
  228. package/src/lib/waku_relay/index.ts +189 -0
  229. package/src/lib/waku_store/history_rpc.ts +94 -0
  230. package/src/lib/waku_store/index.ts +372 -0
  231. package/src/proto/filter.ts +602 -0
  232. package/src/proto/light_push.ts +526 -0
  233. package/src/proto/message.ts +304 -0
  234. package/src/proto/store.ts +844 -0
  235. package/src/proto/topic_only_message.ts +67 -0
@@ -0,0 +1,722 @@
1
+ var browser = {exports: {}};
2
+
3
+ /**
4
+ * Helpers.
5
+ */
6
+
7
+ var ms;
8
+ var hasRequiredMs;
9
+
10
+ function requireMs () {
11
+ if (hasRequiredMs) return ms;
12
+ hasRequiredMs = 1;
13
+ var s = 1000;
14
+ var m = s * 60;
15
+ var h = m * 60;
16
+ var d = h * 24;
17
+ var w = d * 7;
18
+ var y = d * 365.25;
19
+
20
+ /**
21
+ * Parse or format the given `val`.
22
+ *
23
+ * Options:
24
+ *
25
+ * - `long` verbose formatting [false]
26
+ *
27
+ * @param {String|Number} val
28
+ * @param {Object} [options]
29
+ * @throws {Error} throw an error if val is not a non-empty string or a number
30
+ * @return {String|Number}
31
+ * @api public
32
+ */
33
+
34
+ ms = function(val, options) {
35
+ options = options || {};
36
+ var type = typeof val;
37
+ if (type === 'string' && val.length > 0) {
38
+ return parse(val);
39
+ } else if (type === 'number' && isFinite(val)) {
40
+ return options.long ? fmtLong(val) : fmtShort(val);
41
+ }
42
+ throw new Error(
43
+ 'val is not a non-empty string or a valid number. val=' +
44
+ JSON.stringify(val)
45
+ );
46
+ };
47
+
48
+ /**
49
+ * Parse the given `str` and return milliseconds.
50
+ *
51
+ * @param {String} str
52
+ * @return {Number}
53
+ * @api private
54
+ */
55
+
56
+ function parse(str) {
57
+ str = String(str);
58
+ if (str.length > 100) {
59
+ return;
60
+ }
61
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
62
+ str
63
+ );
64
+ if (!match) {
65
+ return;
66
+ }
67
+ var n = parseFloat(match[1]);
68
+ var type = (match[2] || 'ms').toLowerCase();
69
+ switch (type) {
70
+ case 'years':
71
+ case 'year':
72
+ case 'yrs':
73
+ case 'yr':
74
+ case 'y':
75
+ return n * y;
76
+ case 'weeks':
77
+ case 'week':
78
+ case 'w':
79
+ return n * w;
80
+ case 'days':
81
+ case 'day':
82
+ case 'd':
83
+ return n * d;
84
+ case 'hours':
85
+ case 'hour':
86
+ case 'hrs':
87
+ case 'hr':
88
+ case 'h':
89
+ return n * h;
90
+ case 'minutes':
91
+ case 'minute':
92
+ case 'mins':
93
+ case 'min':
94
+ case 'm':
95
+ return n * m;
96
+ case 'seconds':
97
+ case 'second':
98
+ case 'secs':
99
+ case 'sec':
100
+ case 's':
101
+ return n * s;
102
+ case 'milliseconds':
103
+ case 'millisecond':
104
+ case 'msecs':
105
+ case 'msec':
106
+ case 'ms':
107
+ return n;
108
+ default:
109
+ return undefined;
110
+ }
111
+ }
112
+
113
+ /**
114
+ * Short format for `ms`.
115
+ *
116
+ * @param {Number} ms
117
+ * @return {String}
118
+ * @api private
119
+ */
120
+
121
+ function fmtShort(ms) {
122
+ var msAbs = Math.abs(ms);
123
+ if (msAbs >= d) {
124
+ return Math.round(ms / d) + 'd';
125
+ }
126
+ if (msAbs >= h) {
127
+ return Math.round(ms / h) + 'h';
128
+ }
129
+ if (msAbs >= m) {
130
+ return Math.round(ms / m) + 'm';
131
+ }
132
+ if (msAbs >= s) {
133
+ return Math.round(ms / s) + 's';
134
+ }
135
+ return ms + 'ms';
136
+ }
137
+
138
+ /**
139
+ * Long format for `ms`.
140
+ *
141
+ * @param {Number} ms
142
+ * @return {String}
143
+ * @api private
144
+ */
145
+
146
+ function fmtLong(ms) {
147
+ var msAbs = Math.abs(ms);
148
+ if (msAbs >= d) {
149
+ return plural(ms, msAbs, d, 'day');
150
+ }
151
+ if (msAbs >= h) {
152
+ return plural(ms, msAbs, h, 'hour');
153
+ }
154
+ if (msAbs >= m) {
155
+ return plural(ms, msAbs, m, 'minute');
156
+ }
157
+ if (msAbs >= s) {
158
+ return plural(ms, msAbs, s, 'second');
159
+ }
160
+ return ms + ' ms';
161
+ }
162
+
163
+ /**
164
+ * Pluralization helper.
165
+ */
166
+
167
+ function plural(ms, msAbs, n, name) {
168
+ var isPlural = msAbs >= n * 1.5;
169
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
170
+ }
171
+ return ms;
172
+ }
173
+
174
+ /**
175
+ * This is the common logic for both the Node.js and web browser
176
+ * implementations of `debug()`.
177
+ */
178
+
179
+ function setup(env) {
180
+ createDebug.debug = createDebug;
181
+ createDebug.default = createDebug;
182
+ createDebug.coerce = coerce;
183
+ createDebug.disable = disable;
184
+ createDebug.enable = enable;
185
+ createDebug.enabled = enabled;
186
+ createDebug.humanize = requireMs();
187
+ createDebug.destroy = destroy;
188
+
189
+ Object.keys(env).forEach(key => {
190
+ createDebug[key] = env[key];
191
+ });
192
+
193
+ /**
194
+ * The currently active debug mode names, and names to skip.
195
+ */
196
+
197
+ createDebug.names = [];
198
+ createDebug.skips = [];
199
+
200
+ /**
201
+ * Map of special "%n" handling functions, for the debug "format" argument.
202
+ *
203
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
204
+ */
205
+ createDebug.formatters = {};
206
+
207
+ /**
208
+ * Selects a color for a debug namespace
209
+ * @param {String} namespace The namespace string for the debug instance to be colored
210
+ * @return {Number|String} An ANSI color code for the given namespace
211
+ * @api private
212
+ */
213
+ function selectColor(namespace) {
214
+ let hash = 0;
215
+
216
+ for (let i = 0; i < namespace.length; i++) {
217
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
218
+ hash |= 0; // Convert to 32bit integer
219
+ }
220
+
221
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
222
+ }
223
+ createDebug.selectColor = selectColor;
224
+
225
+ /**
226
+ * Create a debugger with the given `namespace`.
227
+ *
228
+ * @param {String} namespace
229
+ * @return {Function}
230
+ * @api public
231
+ */
232
+ function createDebug(namespace) {
233
+ let prevTime;
234
+ let enableOverride = null;
235
+ let namespacesCache;
236
+ let enabledCache;
237
+
238
+ function debug(...args) {
239
+ // Disabled?
240
+ if (!debug.enabled) {
241
+ return;
242
+ }
243
+
244
+ const self = debug;
245
+
246
+ // Set `diff` timestamp
247
+ const curr = Number(new Date());
248
+ const ms = curr - (prevTime || curr);
249
+ self.diff = ms;
250
+ self.prev = prevTime;
251
+ self.curr = curr;
252
+ prevTime = curr;
253
+
254
+ args[0] = createDebug.coerce(args[0]);
255
+
256
+ if (typeof args[0] !== 'string') {
257
+ // Anything else let's inspect with %O
258
+ args.unshift('%O');
259
+ }
260
+
261
+ // Apply any `formatters` transformations
262
+ let index = 0;
263
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
264
+ // If we encounter an escaped % then don't increase the array index
265
+ if (match === '%%') {
266
+ return '%';
267
+ }
268
+ index++;
269
+ const formatter = createDebug.formatters[format];
270
+ if (typeof formatter === 'function') {
271
+ const val = args[index];
272
+ match = formatter.call(self, val);
273
+
274
+ // Now we need to remove `args[index]` since it's inlined in the `format`
275
+ args.splice(index, 1);
276
+ index--;
277
+ }
278
+ return match;
279
+ });
280
+
281
+ // Apply env-specific formatting (colors, etc.)
282
+ createDebug.formatArgs.call(self, args);
283
+
284
+ const logFn = self.log || createDebug.log;
285
+ logFn.apply(self, args);
286
+ }
287
+
288
+ debug.namespace = namespace;
289
+ debug.useColors = createDebug.useColors();
290
+ debug.color = createDebug.selectColor(namespace);
291
+ debug.extend = extend;
292
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
293
+
294
+ Object.defineProperty(debug, 'enabled', {
295
+ enumerable: true,
296
+ configurable: false,
297
+ get: () => {
298
+ if (enableOverride !== null) {
299
+ return enableOverride;
300
+ }
301
+ if (namespacesCache !== createDebug.namespaces) {
302
+ namespacesCache = createDebug.namespaces;
303
+ enabledCache = createDebug.enabled(namespace);
304
+ }
305
+
306
+ return enabledCache;
307
+ },
308
+ set: v => {
309
+ enableOverride = v;
310
+ }
311
+ });
312
+
313
+ // Env-specific initialization logic for debug instances
314
+ if (typeof createDebug.init === 'function') {
315
+ createDebug.init(debug);
316
+ }
317
+
318
+ return debug;
319
+ }
320
+
321
+ function extend(namespace, delimiter) {
322
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
323
+ newDebug.log = this.log;
324
+ return newDebug;
325
+ }
326
+
327
+ /**
328
+ * Enables a debug mode by namespaces. This can include modes
329
+ * separated by a colon and wildcards.
330
+ *
331
+ * @param {String} namespaces
332
+ * @api public
333
+ */
334
+ function enable(namespaces) {
335
+ createDebug.save(namespaces);
336
+ createDebug.namespaces = namespaces;
337
+
338
+ createDebug.names = [];
339
+ createDebug.skips = [];
340
+
341
+ let i;
342
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
343
+ const len = split.length;
344
+
345
+ for (i = 0; i < len; i++) {
346
+ if (!split[i]) {
347
+ // ignore empty strings
348
+ continue;
349
+ }
350
+
351
+ namespaces = split[i].replace(/\*/g, '.*?');
352
+
353
+ if (namespaces[0] === '-') {
354
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
355
+ } else {
356
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
357
+ }
358
+ }
359
+ }
360
+
361
+ /**
362
+ * Disable debug output.
363
+ *
364
+ * @return {String} namespaces
365
+ * @api public
366
+ */
367
+ function disable() {
368
+ const namespaces = [
369
+ ...createDebug.names.map(toNamespace),
370
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
371
+ ].join(',');
372
+ createDebug.enable('');
373
+ return namespaces;
374
+ }
375
+
376
+ /**
377
+ * Returns true if the given mode name is enabled, false otherwise.
378
+ *
379
+ * @param {String} name
380
+ * @return {Boolean}
381
+ * @api public
382
+ */
383
+ function enabled(name) {
384
+ if (name[name.length - 1] === '*') {
385
+ return true;
386
+ }
387
+
388
+ let i;
389
+ let len;
390
+
391
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
392
+ if (createDebug.skips[i].test(name)) {
393
+ return false;
394
+ }
395
+ }
396
+
397
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
398
+ if (createDebug.names[i].test(name)) {
399
+ return true;
400
+ }
401
+ }
402
+
403
+ return false;
404
+ }
405
+
406
+ /**
407
+ * Convert regexp to namespace
408
+ *
409
+ * @param {RegExp} regxep
410
+ * @return {String} namespace
411
+ * @api private
412
+ */
413
+ function toNamespace(regexp) {
414
+ return regexp.toString()
415
+ .substring(2, regexp.toString().length - 2)
416
+ .replace(/\.\*\?$/, '*');
417
+ }
418
+
419
+ /**
420
+ * Coerce `val`.
421
+ *
422
+ * @param {Mixed} val
423
+ * @return {Mixed}
424
+ * @api private
425
+ */
426
+ function coerce(val) {
427
+ if (val instanceof Error) {
428
+ return val.stack || val.message;
429
+ }
430
+ return val;
431
+ }
432
+
433
+ /**
434
+ * XXX DO NOT USE. This is a temporary stub function.
435
+ * XXX It WILL be removed in the next major release.
436
+ */
437
+ function destroy() {
438
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
439
+ }
440
+
441
+ createDebug.enable(createDebug.load());
442
+
443
+ return createDebug;
444
+ }
445
+
446
+ var common = setup;
447
+
448
+ /* eslint-env browser */
449
+
450
+ (function (module, exports) {
451
+ /**
452
+ * This is the web browser implementation of `debug()`.
453
+ */
454
+
455
+ exports.formatArgs = formatArgs;
456
+ exports.save = save;
457
+ exports.load = load;
458
+ exports.useColors = useColors;
459
+ exports.storage = localstorage();
460
+ exports.destroy = (() => {
461
+ let warned = false;
462
+
463
+ return () => {
464
+ if (!warned) {
465
+ warned = true;
466
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
467
+ }
468
+ };
469
+ })();
470
+
471
+ /**
472
+ * Colors.
473
+ */
474
+
475
+ exports.colors = [
476
+ '#0000CC',
477
+ '#0000FF',
478
+ '#0033CC',
479
+ '#0033FF',
480
+ '#0066CC',
481
+ '#0066FF',
482
+ '#0099CC',
483
+ '#0099FF',
484
+ '#00CC00',
485
+ '#00CC33',
486
+ '#00CC66',
487
+ '#00CC99',
488
+ '#00CCCC',
489
+ '#00CCFF',
490
+ '#3300CC',
491
+ '#3300FF',
492
+ '#3333CC',
493
+ '#3333FF',
494
+ '#3366CC',
495
+ '#3366FF',
496
+ '#3399CC',
497
+ '#3399FF',
498
+ '#33CC00',
499
+ '#33CC33',
500
+ '#33CC66',
501
+ '#33CC99',
502
+ '#33CCCC',
503
+ '#33CCFF',
504
+ '#6600CC',
505
+ '#6600FF',
506
+ '#6633CC',
507
+ '#6633FF',
508
+ '#66CC00',
509
+ '#66CC33',
510
+ '#9900CC',
511
+ '#9900FF',
512
+ '#9933CC',
513
+ '#9933FF',
514
+ '#99CC00',
515
+ '#99CC33',
516
+ '#CC0000',
517
+ '#CC0033',
518
+ '#CC0066',
519
+ '#CC0099',
520
+ '#CC00CC',
521
+ '#CC00FF',
522
+ '#CC3300',
523
+ '#CC3333',
524
+ '#CC3366',
525
+ '#CC3399',
526
+ '#CC33CC',
527
+ '#CC33FF',
528
+ '#CC6600',
529
+ '#CC6633',
530
+ '#CC9900',
531
+ '#CC9933',
532
+ '#CCCC00',
533
+ '#CCCC33',
534
+ '#FF0000',
535
+ '#FF0033',
536
+ '#FF0066',
537
+ '#FF0099',
538
+ '#FF00CC',
539
+ '#FF00FF',
540
+ '#FF3300',
541
+ '#FF3333',
542
+ '#FF3366',
543
+ '#FF3399',
544
+ '#FF33CC',
545
+ '#FF33FF',
546
+ '#FF6600',
547
+ '#FF6633',
548
+ '#FF9900',
549
+ '#FF9933',
550
+ '#FFCC00',
551
+ '#FFCC33'
552
+ ];
553
+
554
+ /**
555
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
556
+ * and the Firebug extension (any Firefox version) are known
557
+ * to support "%c" CSS customizations.
558
+ *
559
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
560
+ */
561
+
562
+ // eslint-disable-next-line complexity
563
+ function useColors() {
564
+ // NB: In an Electron preload script, document will be defined but not fully
565
+ // initialized. Since we know we're in Chrome, we'll just detect this case
566
+ // explicitly
567
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
568
+ return true;
569
+ }
570
+
571
+ // Internet Explorer and Edge do not support colors.
572
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
573
+ return false;
574
+ }
575
+
576
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
577
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
578
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
579
+ // Is firebug? http://stackoverflow.com/a/398120/376773
580
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
581
+ // Is firefox >= v31?
582
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
583
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
584
+ // Double check webkit in userAgent just in case we are in a worker
585
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
586
+ }
587
+
588
+ /**
589
+ * Colorize log arguments if enabled.
590
+ *
591
+ * @api public
592
+ */
593
+
594
+ function formatArgs(args) {
595
+ args[0] = (this.useColors ? '%c' : '') +
596
+ this.namespace +
597
+ (this.useColors ? ' %c' : ' ') +
598
+ args[0] +
599
+ (this.useColors ? '%c ' : ' ') +
600
+ '+' + module.exports.humanize(this.diff);
601
+
602
+ if (!this.useColors) {
603
+ return;
604
+ }
605
+
606
+ const c = 'color: ' + this.color;
607
+ args.splice(1, 0, c, 'color: inherit');
608
+
609
+ // The final "%c" is somewhat tricky, because there could be other
610
+ // arguments passed either before or after the %c, so we need to
611
+ // figure out the correct index to insert the CSS into
612
+ let index = 0;
613
+ let lastC = 0;
614
+ args[0].replace(/%[a-zA-Z%]/g, match => {
615
+ if (match === '%%') {
616
+ return;
617
+ }
618
+ index++;
619
+ if (match === '%c') {
620
+ // We only are interested in the *last* %c
621
+ // (the user may have provided their own)
622
+ lastC = index;
623
+ }
624
+ });
625
+
626
+ args.splice(lastC, 0, c);
627
+ }
628
+
629
+ /**
630
+ * Invokes `console.debug()` when available.
631
+ * No-op when `console.debug` is not a "function".
632
+ * If `console.debug` is not available, falls back
633
+ * to `console.log`.
634
+ *
635
+ * @api public
636
+ */
637
+ exports.log = console.debug || console.log || (() => {});
638
+
639
+ /**
640
+ * Save `namespaces`.
641
+ *
642
+ * @param {String} namespaces
643
+ * @api private
644
+ */
645
+ function save(namespaces) {
646
+ try {
647
+ if (namespaces) {
648
+ exports.storage.setItem('debug', namespaces);
649
+ } else {
650
+ exports.storage.removeItem('debug');
651
+ }
652
+ } catch (error) {
653
+ // Swallow
654
+ // XXX (@Qix-) should we be logging these?
655
+ }
656
+ }
657
+
658
+ /**
659
+ * Load `namespaces`.
660
+ *
661
+ * @return {String} returns the previously persisted debug modes
662
+ * @api private
663
+ */
664
+ function load() {
665
+ let r;
666
+ try {
667
+ r = exports.storage.getItem('debug');
668
+ } catch (error) {
669
+ // Swallow
670
+ // XXX (@Qix-) should we be logging these?
671
+ }
672
+
673
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
674
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
675
+ r = process.env.DEBUG;
676
+ }
677
+
678
+ return r;
679
+ }
680
+
681
+ /**
682
+ * Localstorage attempts to return the localstorage.
683
+ *
684
+ * This is necessary because safari throws
685
+ * when a user disables cookies/localstorage
686
+ * and you attempt to access it.
687
+ *
688
+ * @return {LocalStorage}
689
+ * @api private
690
+ */
691
+
692
+ function localstorage() {
693
+ try {
694
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
695
+ // The Browser also has localStorage in the global context.
696
+ return localStorage;
697
+ } catch (error) {
698
+ // Swallow
699
+ // XXX (@Qix-) should we be logging these?
700
+ }
701
+ }
702
+
703
+ module.exports = common(exports);
704
+
705
+ const {formatters} = module.exports;
706
+
707
+ /**
708
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
709
+ */
710
+
711
+ formatters.j = function (v) {
712
+ try {
713
+ return JSON.stringify(v);
714
+ } catch (error) {
715
+ return '[UnexpectedJSONParseError]: ' + error.message;
716
+ }
717
+ };
718
+ } (browser, browser.exports));
719
+
720
+ var debug = browser.exports;
721
+
722
+ export { debug as d };