dcp-client 5.8.2 → 5.8.3

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.
@@ -273,6 +273,198 @@ self.wrapScriptLoading({ scriptName: 'polyfills' }, function accessLists$$fn(pro
273
273
  );
274
274
  }
275
275
  },
276
+ // Polyfill for Event and EventTarget
277
+ // copied from https://github.com/Distributive-Network/PythonMonkey/blob/v1.3.2/python/pythonmonkey/builtin_modules/event-target.js
278
+ // Copyright (c) 2023 Distributive Corp., MIT License, author: Tom Tang <xmader@distributive.network>
279
+ Event: class Event {
280
+ /**
281
+ * Indicates whether the event bubbles up through the DOM tree or not.
282
+ * @type {Boolean}
283
+ */
284
+ bubbles = false;
285
+
286
+ /**
287
+ * Indicates whether the event is cancelable.
288
+ * @type {Boolean}
289
+ */
290
+ cancelable = true;
291
+
292
+ /**
293
+ * Indicates whether the event can bubble across the boundary between the shadow DOM and the regular DOM.
294
+ * @type {Boolean}
295
+ */
296
+ composed = false;
297
+
298
+ /**
299
+ * The element to which the event handler has been attached.
300
+ * @type {EventTarget}
301
+ */
302
+ currentTarget = null;
303
+
304
+ /**
305
+ * Indicates whether the call to event.preventDefault() canceled the event.
306
+ * @type {Boolean}
307
+ */
308
+ devaultPrevented = false;
309
+
310
+ /**
311
+ * Indicates which phase of the event flow is currently being evaluated.
312
+ * @type {Number}
313
+ */
314
+ eventPhase = Event.NONE;
315
+ static NONE = 0; // The event is not being processed
316
+ static CAPTURING_PHASE = 1; // The event is being propagated through the target's ancestor objects
317
+ static AT_TARGET = 2; // The event has arrived at the event's target
318
+ static BUBBLING_PHASE = 3; // The event is propagating back up through the target's ancestors in reverse order, starting with the parent
319
+
320
+ /**
321
+ * Indicates whether the event was initiated by the browser or by a script.
322
+ * @type {Boolean}
323
+ */
324
+ isTrusted = false;
325
+
326
+ /**
327
+ * A reference to the object to which the event was originally dispatched.
328
+ * @type {EventTarget}
329
+ */
330
+ target = null;
331
+
332
+ /**
333
+ * The time at which the event was created (in milliseconds). By specification, this value is time since epoch.
334
+ * @type {Number}
335
+ */
336
+ timeStamp = null;
337
+
338
+ /**
339
+ * The name identifying the type of the event.
340
+ * @type {String}
341
+ */
342
+ type = '';
343
+
344
+ /**
345
+ * @param {string} type A string with the name of the event.
346
+ */
347
+ constructor(type)
348
+ {
349
+ this.type = type;
350
+ }
351
+ },
352
+ EventTarget: class EventTarget {
353
+ /**
354
+ * @readonly
355
+ * @type {{ [type: string]: Set<EventListener> }}
356
+ */
357
+ #listeners = Object.create(null);
358
+
359
+ /**
360
+ * Add an event listener that will be called whenever the specified event is delivered to the target
361
+ * @param {string} type A case-sensitive string representing the event type to listen for
362
+ * @param {EventListener | null} listener The object that receives a notification when an event of the specified type occurs
363
+ */
364
+ addEventListener(type, listener)
365
+ {
366
+ if (!listener)
367
+ return;
368
+
369
+ if (!Object.hasOwn(this.#listeners, type))
370
+ this.#listeners[type] = new Set();
371
+
372
+ this.#listeners[type].add(listener);
373
+ }
374
+
375
+ /**
376
+ * Remove an event listener previously registered with EventTarget.addEventListener() from the target.
377
+ * @param {string} type A string which specifies the type of event for which to remove an event listener.
378
+ * @param {EventListener} listener The event listener function of the event handler to remove from the event target.
379
+ */
380
+ removeEventListener(type, listener)
381
+ {
382
+ if (Object.hasOwn(this.#listeners, type))
383
+ this.#listeners[type].delete(listener);
384
+ }
385
+
386
+ /**
387
+ * Send an Event to the target, (synchronously) invoking the affected event listeners in the appropriate order.
388
+ * @param {Event} event The Event object to dispatch
389
+ */
390
+ dispatchEvent(event)
391
+ {
392
+ // Set the Event.target property to the current EventTarget
393
+ event.target = this;
394
+
395
+ const type = event.type;
396
+ if (!type)
397
+ return;
398
+
399
+ // Call "on" methods
400
+ if (typeof this['on' + type] === 'function')
401
+ this['on' + type].call(this, event);
402
+
403
+ // Call listeners registered with addEventListener()
404
+ if (!Object.hasOwn(this.#listeners, type))
405
+ return;
406
+ for (const listener of this.#listeners[type].values())
407
+ if (typeof listener === 'function')
408
+ listener.call(this, event);
409
+ else
410
+ listener.handleEvent.call(this, event);
411
+ }
412
+
413
+ /**
414
+ * Determine whether the target has any kind of event listeners
415
+ */
416
+ _hasAnyListeners()
417
+ {
418
+ return Object.values(this.#listeners).some(t => t.size > 0);
419
+ }
420
+
421
+ /**
422
+ * Determine whether the target has listeners of the given event type
423
+ * @param {string} [type]
424
+ */
425
+ _hasListeners(type)
426
+ {
427
+ return this.#listeners[type] && this.#listeners[type].size > 0;
428
+ }
429
+ },
430
+ };
431
+
432
+ // Polyfill for DOMException
433
+ // copied from core-js, MIT License
434
+ {
435
+ const domExceptionConstants = {
436
+ IndexSizeError: 1,
437
+ HierarchyRequestError: 3,
438
+ WrongDocumentError: 4,
439
+ InvalidCharacterError: 5,
440
+ NoModificationAllowedError: 7,
441
+ NotFoundError: 8,
442
+ NotSupportedError: 9,
443
+ InUseAttributeError: 10,
444
+ InvalidStateError: 11,
445
+ SyntaxError: 12,
446
+ InvalidModificationError: 13,
447
+ NamespaceError: 14,
448
+ InvalidAccessError: 15,
449
+ TypeMismatchError: 17,
450
+ SecurityError: 18,
451
+ NetworkError: 19,
452
+ AbortError: 20,
453
+ URLMismatchError: 21,
454
+ QuotaExceededError: 22,
455
+ TimeoutError: 23,
456
+ InvalidNodeTypeError: 24,
457
+ DataCloneError: 25
458
+ };
459
+
460
+ polyfills.DOMException = class DOMException extends Error {
461
+ code = 0;
462
+ constructor(message, name) {
463
+ super(message);
464
+ this.name = name || `Error`;
465
+ this.code = Object.hasOwn(domExceptionConstants, this.name) ? domExceptionConstants[this.name] : 0;
466
+ }
467
+ };
276
468
  };
277
469
 
278
470
  /** @param {(Blob | Uint8Array)[]} parts */
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dcp-client",
3
- "version": "5.8.2",
3
+ "version": "5.8.3",
4
4
  "dcp": {
5
- "version": "6a4f4a2cfba2b9b7a54f541f48051f2443557250",
5
+ "version": "ae7034a0048b46974785ac47d61bbdfced45ad07",
6
6
  "repository": "git@gitlab.com:Distributed-Compute-Protocol/dcp.git"
7
7
  },
8
8
  "description": "Core libraries for accessing DCP network",