@learncard/react 2.3.0 → 2.3.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.
@@ -90199,979 +90199,6 @@ class Crypto extends Crypto$1 {
90199
90199
 
90200
90200
  var crypto2 = new Crypto();
90201
90201
 
90202
- /**
90203
- * @author Toru Nagashima <https://github.com/mysticatea>
90204
- * @copyright 2015 Toru Nagashima. All rights reserved.
90205
- * See LICENSE file in root directory for full license.
90206
- */
90207
- /**
90208
- * @typedef {object} PrivateData
90209
- * @property {EventTarget} eventTarget The event target.
90210
- * @property {{type:string}} event The original event object.
90211
- * @property {number} eventPhase The current event phase.
90212
- * @property {EventTarget|null} currentTarget The current event target.
90213
- * @property {boolean} canceled The flag to prevent default.
90214
- * @property {boolean} stopped The flag to stop propagation.
90215
- * @property {boolean} immediateStopped The flag to stop propagation immediately.
90216
- * @property {Function|null} passiveListener The listener if the current listener is passive. Otherwise this is null.
90217
- * @property {number} timeStamp The unix time.
90218
- * @private
90219
- */
90220
-
90221
- /**
90222
- * Private data for event wrappers.
90223
- * @type {WeakMap<Event, PrivateData>}
90224
- * @private
90225
- */
90226
- const privateData = new WeakMap();
90227
-
90228
- /**
90229
- * Cache for wrapper classes.
90230
- * @type {WeakMap<Object, Function>}
90231
- * @private
90232
- */
90233
- const wrappers = new WeakMap();
90234
-
90235
- /**
90236
- * Get private data.
90237
- * @param {Event} event The event object to get private data.
90238
- * @returns {PrivateData} The private data of the event.
90239
- * @private
90240
- */
90241
- function pd(event) {
90242
- const retv = privateData.get(event);
90243
- console.assert(
90244
- retv != null,
90245
- "'this' is expected an Event object, but got",
90246
- event
90247
- );
90248
- return retv
90249
- }
90250
-
90251
- /**
90252
- * https://dom.spec.whatwg.org/#set-the-canceled-flag
90253
- * @param data {PrivateData} private data.
90254
- */
90255
- function setCancelFlag(data) {
90256
- if (data.passiveListener != null) {
90257
- if (
90258
- typeof console !== "undefined" &&
90259
- typeof console.error === "function"
90260
- ) {
90261
- console.error(
90262
- "Unable to preventDefault inside passive event listener invocation.",
90263
- data.passiveListener
90264
- );
90265
- }
90266
- return
90267
- }
90268
- if (!data.event.cancelable) {
90269
- return
90270
- }
90271
-
90272
- data.canceled = true;
90273
- if (typeof data.event.preventDefault === "function") {
90274
- data.event.preventDefault();
90275
- }
90276
- }
90277
-
90278
- /**
90279
- * @see https://dom.spec.whatwg.org/#interface-event
90280
- * @private
90281
- */
90282
- /**
90283
- * The event wrapper.
90284
- * @constructor
90285
- * @param {EventTarget} eventTarget The event target of this dispatching.
90286
- * @param {Event|{type:string}} event The original event to wrap.
90287
- */
90288
- function Event(eventTarget, event) {
90289
- privateData.set(this, {
90290
- eventTarget,
90291
- event,
90292
- eventPhase: 2,
90293
- currentTarget: eventTarget,
90294
- canceled: false,
90295
- stopped: false,
90296
- immediateStopped: false,
90297
- passiveListener: null,
90298
- timeStamp: event.timeStamp || Date.now(),
90299
- });
90300
-
90301
- // https://heycam.github.io/webidl/#Unforgeable
90302
- Object.defineProperty(this, "isTrusted", { value: false, enumerable: true });
90303
-
90304
- // Define accessors
90305
- const keys = Object.keys(event);
90306
- for (let i = 0; i < keys.length; ++i) {
90307
- const key = keys[i];
90308
- if (!(key in this)) {
90309
- Object.defineProperty(this, key, defineRedirectDescriptor(key));
90310
- }
90311
- }
90312
- }
90313
-
90314
- // Should be enumerable, but class methods are not enumerable.
90315
- Event.prototype = {
90316
- /**
90317
- * The type of this event.
90318
- * @type {string}
90319
- */
90320
- get type() {
90321
- return pd(this).event.type
90322
- },
90323
-
90324
- /**
90325
- * The target of this event.
90326
- * @type {EventTarget}
90327
- */
90328
- get target() {
90329
- return pd(this).eventTarget
90330
- },
90331
-
90332
- /**
90333
- * The target of this event.
90334
- * @type {EventTarget}
90335
- */
90336
- get currentTarget() {
90337
- return pd(this).currentTarget
90338
- },
90339
-
90340
- /**
90341
- * @returns {EventTarget[]} The composed path of this event.
90342
- */
90343
- composedPath() {
90344
- const currentTarget = pd(this).currentTarget;
90345
- if (currentTarget == null) {
90346
- return []
90347
- }
90348
- return [currentTarget]
90349
- },
90350
-
90351
- /**
90352
- * Constant of NONE.
90353
- * @type {number}
90354
- */
90355
- get NONE() {
90356
- return 0
90357
- },
90358
-
90359
- /**
90360
- * Constant of CAPTURING_PHASE.
90361
- * @type {number}
90362
- */
90363
- get CAPTURING_PHASE() {
90364
- return 1
90365
- },
90366
-
90367
- /**
90368
- * Constant of AT_TARGET.
90369
- * @type {number}
90370
- */
90371
- get AT_TARGET() {
90372
- return 2
90373
- },
90374
-
90375
- /**
90376
- * Constant of BUBBLING_PHASE.
90377
- * @type {number}
90378
- */
90379
- get BUBBLING_PHASE() {
90380
- return 3
90381
- },
90382
-
90383
- /**
90384
- * The target of this event.
90385
- * @type {number}
90386
- */
90387
- get eventPhase() {
90388
- return pd(this).eventPhase
90389
- },
90390
-
90391
- /**
90392
- * Stop event bubbling.
90393
- * @returns {void}
90394
- */
90395
- stopPropagation() {
90396
- const data = pd(this);
90397
-
90398
- data.stopped = true;
90399
- if (typeof data.event.stopPropagation === "function") {
90400
- data.event.stopPropagation();
90401
- }
90402
- },
90403
-
90404
- /**
90405
- * Stop event bubbling.
90406
- * @returns {void}
90407
- */
90408
- stopImmediatePropagation() {
90409
- const data = pd(this);
90410
-
90411
- data.stopped = true;
90412
- data.immediateStopped = true;
90413
- if (typeof data.event.stopImmediatePropagation === "function") {
90414
- data.event.stopImmediatePropagation();
90415
- }
90416
- },
90417
-
90418
- /**
90419
- * The flag to be bubbling.
90420
- * @type {boolean}
90421
- */
90422
- get bubbles() {
90423
- return Boolean(pd(this).event.bubbles)
90424
- },
90425
-
90426
- /**
90427
- * The flag to be cancelable.
90428
- * @type {boolean}
90429
- */
90430
- get cancelable() {
90431
- return Boolean(pd(this).event.cancelable)
90432
- },
90433
-
90434
- /**
90435
- * Cancel this event.
90436
- * @returns {void}
90437
- */
90438
- preventDefault() {
90439
- setCancelFlag(pd(this));
90440
- },
90441
-
90442
- /**
90443
- * The flag to indicate cancellation state.
90444
- * @type {boolean}
90445
- */
90446
- get defaultPrevented() {
90447
- return pd(this).canceled
90448
- },
90449
-
90450
- /**
90451
- * The flag to be composed.
90452
- * @type {boolean}
90453
- */
90454
- get composed() {
90455
- return Boolean(pd(this).event.composed)
90456
- },
90457
-
90458
- /**
90459
- * The unix time of this event.
90460
- * @type {number}
90461
- */
90462
- get timeStamp() {
90463
- return pd(this).timeStamp
90464
- },
90465
-
90466
- /**
90467
- * The target of this event.
90468
- * @type {EventTarget}
90469
- * @deprecated
90470
- */
90471
- get srcElement() {
90472
- return pd(this).eventTarget
90473
- },
90474
-
90475
- /**
90476
- * The flag to stop event bubbling.
90477
- * @type {boolean}
90478
- * @deprecated
90479
- */
90480
- get cancelBubble() {
90481
- return pd(this).stopped
90482
- },
90483
- set cancelBubble(value) {
90484
- if (!value) {
90485
- return
90486
- }
90487
- const data = pd(this);
90488
-
90489
- data.stopped = true;
90490
- if (typeof data.event.cancelBubble === "boolean") {
90491
- data.event.cancelBubble = true;
90492
- }
90493
- },
90494
-
90495
- /**
90496
- * The flag to indicate cancellation state.
90497
- * @type {boolean}
90498
- * @deprecated
90499
- */
90500
- get returnValue() {
90501
- return !pd(this).canceled
90502
- },
90503
- set returnValue(value) {
90504
- if (!value) {
90505
- setCancelFlag(pd(this));
90506
- }
90507
- },
90508
-
90509
- /**
90510
- * Initialize this event object. But do nothing under event dispatching.
90511
- * @param {string} type The event type.
90512
- * @param {boolean} [bubbles=false] The flag to be possible to bubble up.
90513
- * @param {boolean} [cancelable=false] The flag to be possible to cancel.
90514
- * @deprecated
90515
- */
90516
- initEvent() {
90517
- // Do nothing.
90518
- },
90519
- };
90520
-
90521
- // `constructor` is not enumerable.
90522
- Object.defineProperty(Event.prototype, "constructor", {
90523
- value: Event,
90524
- configurable: true,
90525
- writable: true,
90526
- });
90527
-
90528
- // Ensure `event instanceof window.Event` is `true`.
90529
- if (typeof window !== "undefined" && typeof window.Event !== "undefined") {
90530
- Object.setPrototypeOf(Event.prototype, window.Event.prototype);
90531
-
90532
- // Make association for wrappers.
90533
- wrappers.set(window.Event.prototype, Event);
90534
- }
90535
-
90536
- /**
90537
- * Get the property descriptor to redirect a given property.
90538
- * @param {string} key Property name to define property descriptor.
90539
- * @returns {PropertyDescriptor} The property descriptor to redirect the property.
90540
- * @private
90541
- */
90542
- function defineRedirectDescriptor(key) {
90543
- return {
90544
- get() {
90545
- return pd(this).event[key]
90546
- },
90547
- set(value) {
90548
- pd(this).event[key] = value;
90549
- },
90550
- configurable: true,
90551
- enumerable: true,
90552
- }
90553
- }
90554
-
90555
- /**
90556
- * Get the property descriptor to call a given method property.
90557
- * @param {string} key Property name to define property descriptor.
90558
- * @returns {PropertyDescriptor} The property descriptor to call the method property.
90559
- * @private
90560
- */
90561
- function defineCallDescriptor(key) {
90562
- return {
90563
- value() {
90564
- const event = pd(this).event;
90565
- return event[key].apply(event, arguments)
90566
- },
90567
- configurable: true,
90568
- enumerable: true,
90569
- }
90570
- }
90571
-
90572
- /**
90573
- * Define new wrapper class.
90574
- * @param {Function} BaseEvent The base wrapper class.
90575
- * @param {Object} proto The prototype of the original event.
90576
- * @returns {Function} The defined wrapper class.
90577
- * @private
90578
- */
90579
- function defineWrapper(BaseEvent, proto) {
90580
- const keys = Object.keys(proto);
90581
- if (keys.length === 0) {
90582
- return BaseEvent
90583
- }
90584
-
90585
- /** CustomEvent */
90586
- function CustomEvent(eventTarget, event) {
90587
- BaseEvent.call(this, eventTarget, event);
90588
- }
90589
-
90590
- CustomEvent.prototype = Object.create(BaseEvent.prototype, {
90591
- constructor: { value: CustomEvent, configurable: true, writable: true },
90592
- });
90593
-
90594
- // Define accessors.
90595
- for (let i = 0; i < keys.length; ++i) {
90596
- const key = keys[i];
90597
- if (!(key in BaseEvent.prototype)) {
90598
- const descriptor = Object.getOwnPropertyDescriptor(proto, key);
90599
- const isFunc = typeof descriptor.value === "function";
90600
- Object.defineProperty(
90601
- CustomEvent.prototype,
90602
- key,
90603
- isFunc
90604
- ? defineCallDescriptor(key)
90605
- : defineRedirectDescriptor(key)
90606
- );
90607
- }
90608
- }
90609
-
90610
- return CustomEvent
90611
- }
90612
-
90613
- /**
90614
- * Get the wrapper class of a given prototype.
90615
- * @param {Object} proto The prototype of the original event to get its wrapper.
90616
- * @returns {Function} The wrapper class.
90617
- * @private
90618
- */
90619
- function getWrapper(proto) {
90620
- if (proto == null || proto === Object.prototype) {
90621
- return Event
90622
- }
90623
-
90624
- let wrapper = wrappers.get(proto);
90625
- if (wrapper == null) {
90626
- wrapper = defineWrapper(getWrapper(Object.getPrototypeOf(proto)), proto);
90627
- wrappers.set(proto, wrapper);
90628
- }
90629
- return wrapper
90630
- }
90631
-
90632
- /**
90633
- * Wrap a given event to management a dispatching.
90634
- * @param {EventTarget} eventTarget The event target of this dispatching.
90635
- * @param {Object} event The event to wrap.
90636
- * @returns {Event} The wrapper instance.
90637
- * @private
90638
- */
90639
- function wrapEvent(eventTarget, event) {
90640
- const Wrapper = getWrapper(Object.getPrototypeOf(event));
90641
- return new Wrapper(eventTarget, event)
90642
- }
90643
-
90644
- /**
90645
- * Get the immediateStopped flag of a given event.
90646
- * @param {Event} event The event to get.
90647
- * @returns {boolean} The flag to stop propagation immediately.
90648
- * @private
90649
- */
90650
- function isStopped(event) {
90651
- return pd(event).immediateStopped
90652
- }
90653
-
90654
- /**
90655
- * Set the current event phase of a given event.
90656
- * @param {Event} event The event to set current target.
90657
- * @param {number} eventPhase New event phase.
90658
- * @returns {void}
90659
- * @private
90660
- */
90661
- function setEventPhase(event, eventPhase) {
90662
- pd(event).eventPhase = eventPhase;
90663
- }
90664
-
90665
- /**
90666
- * Set the current target of a given event.
90667
- * @param {Event} event The event to set current target.
90668
- * @param {EventTarget|null} currentTarget New current target.
90669
- * @returns {void}
90670
- * @private
90671
- */
90672
- function setCurrentTarget(event, currentTarget) {
90673
- pd(event).currentTarget = currentTarget;
90674
- }
90675
-
90676
- /**
90677
- * Set a passive listener of a given event.
90678
- * @param {Event} event The event to set current target.
90679
- * @param {Function|null} passiveListener New passive listener.
90680
- * @returns {void}
90681
- * @private
90682
- */
90683
- function setPassiveListener(event, passiveListener) {
90684
- pd(event).passiveListener = passiveListener;
90685
- }
90686
-
90687
- /**
90688
- * @typedef {object} ListenerNode
90689
- * @property {Function} listener
90690
- * @property {1|2|3} listenerType
90691
- * @property {boolean} passive
90692
- * @property {boolean} once
90693
- * @property {ListenerNode|null} next
90694
- * @private
90695
- */
90696
-
90697
- /**
90698
- * @type {WeakMap<object, Map<string, ListenerNode>>}
90699
- * @private
90700
- */
90701
- const listenersMap = new WeakMap();
90702
-
90703
- // Listener types
90704
- const CAPTURE = 1;
90705
- const BUBBLE = 2;
90706
- const ATTRIBUTE = 3;
90707
-
90708
- /**
90709
- * Check whether a given value is an object or not.
90710
- * @param {any} x The value to check.
90711
- * @returns {boolean} `true` if the value is an object.
90712
- */
90713
- function isObject(x) {
90714
- return x !== null && typeof x === "object" //eslint-disable-line no-restricted-syntax
90715
- }
90716
-
90717
- /**
90718
- * Get listeners.
90719
- * @param {EventTarget} eventTarget The event target to get.
90720
- * @returns {Map<string, ListenerNode>} The listeners.
90721
- * @private
90722
- */
90723
- function getListeners(eventTarget) {
90724
- const listeners = listenersMap.get(eventTarget);
90725
- if (listeners == null) {
90726
- throw new TypeError(
90727
- "'this' is expected an EventTarget object, but got another value."
90728
- )
90729
- }
90730
- return listeners
90731
- }
90732
-
90733
- /**
90734
- * Get the property descriptor for the event attribute of a given event.
90735
- * @param {string} eventName The event name to get property descriptor.
90736
- * @returns {PropertyDescriptor} The property descriptor.
90737
- * @private
90738
- */
90739
- function defineEventAttributeDescriptor(eventName) {
90740
- return {
90741
- get() {
90742
- const listeners = getListeners(this);
90743
- let node = listeners.get(eventName);
90744
- while (node != null) {
90745
- if (node.listenerType === ATTRIBUTE) {
90746
- return node.listener
90747
- }
90748
- node = node.next;
90749
- }
90750
- return null
90751
- },
90752
-
90753
- set(listener) {
90754
- if (typeof listener !== "function" && !isObject(listener)) {
90755
- listener = null; // eslint-disable-line no-param-reassign
90756
- }
90757
- const listeners = getListeners(this);
90758
-
90759
- // Traverse to the tail while removing old value.
90760
- let prev = null;
90761
- let node = listeners.get(eventName);
90762
- while (node != null) {
90763
- if (node.listenerType === ATTRIBUTE) {
90764
- // Remove old value.
90765
- if (prev !== null) {
90766
- prev.next = node.next;
90767
- } else if (node.next !== null) {
90768
- listeners.set(eventName, node.next);
90769
- } else {
90770
- listeners.delete(eventName);
90771
- }
90772
- } else {
90773
- prev = node;
90774
- }
90775
-
90776
- node = node.next;
90777
- }
90778
-
90779
- // Add new value.
90780
- if (listener !== null) {
90781
- const newNode = {
90782
- listener,
90783
- listenerType: ATTRIBUTE,
90784
- passive: false,
90785
- once: false,
90786
- next: null,
90787
- };
90788
- if (prev === null) {
90789
- listeners.set(eventName, newNode);
90790
- } else {
90791
- prev.next = newNode;
90792
- }
90793
- }
90794
- },
90795
- configurable: true,
90796
- enumerable: true,
90797
- }
90798
- }
90799
-
90800
- /**
90801
- * Define an event attribute (e.g. `eventTarget.onclick`).
90802
- * @param {Object} eventTargetPrototype The event target prototype to define an event attrbite.
90803
- * @param {string} eventName The event name to define.
90804
- * @returns {void}
90805
- */
90806
- function defineEventAttribute(eventTargetPrototype, eventName) {
90807
- Object.defineProperty(
90808
- eventTargetPrototype,
90809
- `on${eventName}`,
90810
- defineEventAttributeDescriptor(eventName)
90811
- );
90812
- }
90813
-
90814
- /**
90815
- * Define a custom EventTarget with event attributes.
90816
- * @param {string[]} eventNames Event names for event attributes.
90817
- * @returns {EventTarget} The custom EventTarget.
90818
- * @private
90819
- */
90820
- function defineCustomEventTarget(eventNames) {
90821
- /** CustomEventTarget */
90822
- function CustomEventTarget() {
90823
- EventTarget.call(this);
90824
- }
90825
-
90826
- CustomEventTarget.prototype = Object.create(EventTarget.prototype, {
90827
- constructor: {
90828
- value: CustomEventTarget,
90829
- configurable: true,
90830
- writable: true,
90831
- },
90832
- });
90833
-
90834
- for (let i = 0; i < eventNames.length; ++i) {
90835
- defineEventAttribute(CustomEventTarget.prototype, eventNames[i]);
90836
- }
90837
-
90838
- return CustomEventTarget
90839
- }
90840
-
90841
- /**
90842
- * EventTarget.
90843
- *
90844
- * - This is constructor if no arguments.
90845
- * - This is a function which returns a CustomEventTarget constructor if there are arguments.
90846
- *
90847
- * For example:
90848
- *
90849
- * class A extends EventTarget {}
90850
- * class B extends EventTarget("message") {}
90851
- * class C extends EventTarget("message", "error") {}
90852
- * class D extends EventTarget(["message", "error"]) {}
90853
- */
90854
- function EventTarget() {
90855
- /*eslint-disable consistent-return */
90856
- if (this instanceof EventTarget) {
90857
- listenersMap.set(this, new Map());
90858
- return
90859
- }
90860
- if (arguments.length === 1 && Array.isArray(arguments[0])) {
90861
- return defineCustomEventTarget(arguments[0])
90862
- }
90863
- if (arguments.length > 0) {
90864
- const types = new Array(arguments.length);
90865
- for (let i = 0; i < arguments.length; ++i) {
90866
- types[i] = arguments[i];
90867
- }
90868
- return defineCustomEventTarget(types)
90869
- }
90870
- throw new TypeError("Cannot call a class as a function")
90871
- /*eslint-enable consistent-return */
90872
- }
90873
-
90874
- // Should be enumerable, but class methods are not enumerable.
90875
- EventTarget.prototype = {
90876
- /**
90877
- * Add a given listener to this event target.
90878
- * @param {string} eventName The event name to add.
90879
- * @param {Function} listener The listener to add.
90880
- * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
90881
- * @returns {void}
90882
- */
90883
- addEventListener(eventName, listener, options) {
90884
- if (listener == null) {
90885
- return
90886
- }
90887
- if (typeof listener !== "function" && !isObject(listener)) {
90888
- throw new TypeError("'listener' should be a function or an object.")
90889
- }
90890
-
90891
- const listeners = getListeners(this);
90892
- const optionsIsObj = isObject(options);
90893
- const capture = optionsIsObj
90894
- ? Boolean(options.capture)
90895
- : Boolean(options);
90896
- const listenerType = capture ? CAPTURE : BUBBLE;
90897
- const newNode = {
90898
- listener,
90899
- listenerType,
90900
- passive: optionsIsObj && Boolean(options.passive),
90901
- once: optionsIsObj && Boolean(options.once),
90902
- next: null,
90903
- };
90904
-
90905
- // Set it as the first node if the first node is null.
90906
- let node = listeners.get(eventName);
90907
- if (node === undefined) {
90908
- listeners.set(eventName, newNode);
90909
- return
90910
- }
90911
-
90912
- // Traverse to the tail while checking duplication..
90913
- let prev = null;
90914
- while (node != null) {
90915
- if (
90916
- node.listener === listener &&
90917
- node.listenerType === listenerType
90918
- ) {
90919
- // Should ignore duplication.
90920
- return
90921
- }
90922
- prev = node;
90923
- node = node.next;
90924
- }
90925
-
90926
- // Add it.
90927
- prev.next = newNode;
90928
- },
90929
-
90930
- /**
90931
- * Remove a given listener from this event target.
90932
- * @param {string} eventName The event name to remove.
90933
- * @param {Function} listener The listener to remove.
90934
- * @param {boolean|{capture?:boolean,passive?:boolean,once?:boolean}} [options] The options for this listener.
90935
- * @returns {void}
90936
- */
90937
- removeEventListener(eventName, listener, options) {
90938
- if (listener == null) {
90939
- return
90940
- }
90941
-
90942
- const listeners = getListeners(this);
90943
- const capture = isObject(options)
90944
- ? Boolean(options.capture)
90945
- : Boolean(options);
90946
- const listenerType = capture ? CAPTURE : BUBBLE;
90947
-
90948
- let prev = null;
90949
- let node = listeners.get(eventName);
90950
- while (node != null) {
90951
- if (
90952
- node.listener === listener &&
90953
- node.listenerType === listenerType
90954
- ) {
90955
- if (prev !== null) {
90956
- prev.next = node.next;
90957
- } else if (node.next !== null) {
90958
- listeners.set(eventName, node.next);
90959
- } else {
90960
- listeners.delete(eventName);
90961
- }
90962
- return
90963
- }
90964
-
90965
- prev = node;
90966
- node = node.next;
90967
- }
90968
- },
90969
-
90970
- /**
90971
- * Dispatch a given event.
90972
- * @param {Event|{type:string}} event The event to dispatch.
90973
- * @returns {boolean} `false` if canceled.
90974
- */
90975
- dispatchEvent(event) {
90976
- if (event == null || typeof event.type !== "string") {
90977
- throw new TypeError('"event.type" should be a string.')
90978
- }
90979
-
90980
- // If listeners aren't registered, terminate.
90981
- const listeners = getListeners(this);
90982
- const eventName = event.type;
90983
- let node = listeners.get(eventName);
90984
- if (node == null) {
90985
- return true
90986
- }
90987
-
90988
- // Since we cannot rewrite several properties, so wrap object.
90989
- const wrappedEvent = wrapEvent(this, event);
90990
-
90991
- // This doesn't process capturing phase and bubbling phase.
90992
- // This isn't participating in a tree.
90993
- let prev = null;
90994
- while (node != null) {
90995
- // Remove this listener if it's once
90996
- if (node.once) {
90997
- if (prev !== null) {
90998
- prev.next = node.next;
90999
- } else if (node.next !== null) {
91000
- listeners.set(eventName, node.next);
91001
- } else {
91002
- listeners.delete(eventName);
91003
- }
91004
- } else {
91005
- prev = node;
91006
- }
91007
-
91008
- // Call this listener
91009
- setPassiveListener(
91010
- wrappedEvent,
91011
- node.passive ? node.listener : null
91012
- );
91013
- if (typeof node.listener === "function") {
91014
- try {
91015
- node.listener.call(this, wrappedEvent);
91016
- } catch (err) {
91017
- if (
91018
- typeof console !== "undefined" &&
91019
- typeof console.error === "function"
91020
- ) {
91021
- console.error(err);
91022
- }
91023
- }
91024
- } else if (
91025
- node.listenerType !== ATTRIBUTE &&
91026
- typeof node.listener.handleEvent === "function"
91027
- ) {
91028
- node.listener.handleEvent(wrappedEvent);
91029
- }
91030
-
91031
- // Break if `event.stopImmediatePropagation` was called.
91032
- if (isStopped(wrappedEvent)) {
91033
- break
91034
- }
91035
-
91036
- node = node.next;
91037
- }
91038
- setPassiveListener(wrappedEvent, null);
91039
- setEventPhase(wrappedEvent, 0);
91040
- setCurrentTarget(wrappedEvent, null);
91041
-
91042
- return !wrappedEvent.defaultPrevented
91043
- },
91044
- };
91045
-
91046
- // `constructor` is not enumerable.
91047
- Object.defineProperty(EventTarget.prototype, "constructor", {
91048
- value: EventTarget,
91049
- configurable: true,
91050
- writable: true,
91051
- });
91052
-
91053
- // Ensure `eventTarget instanceof window.EventTarget` is `true`.
91054
- if (
91055
- typeof window !== "undefined" &&
91056
- typeof window.EventTarget !== "undefined"
91057
- ) {
91058
- Object.setPrototypeOf(EventTarget.prototype, window.EventTarget.prototype);
91059
- }
91060
-
91061
- /**
91062
- * @author Toru Nagashima <https://github.com/mysticatea>
91063
- * See LICENSE file in root directory for full license.
91064
- */
91065
-
91066
- /**
91067
- * The signal class.
91068
- * @see https://dom.spec.whatwg.org/#abortsignal
91069
- */
91070
- class AbortSignal extends EventTarget {
91071
- /**
91072
- * AbortSignal cannot be constructed directly.
91073
- */
91074
- constructor() {
91075
- super();
91076
- throw new TypeError("AbortSignal cannot be constructed directly");
91077
- }
91078
- /**
91079
- * Returns `true` if this `AbortSignal`'s `AbortController` has signaled to abort, and `false` otherwise.
91080
- */
91081
- get aborted() {
91082
- const aborted = abortedFlags.get(this);
91083
- if (typeof aborted !== "boolean") {
91084
- throw new TypeError(`Expected 'this' to be an 'AbortSignal' object, but got ${this === null ? "null" : typeof this}`);
91085
- }
91086
- return aborted;
91087
- }
91088
- }
91089
- defineEventAttribute(AbortSignal.prototype, "abort");
91090
- /**
91091
- * Create an AbortSignal object.
91092
- */
91093
- function createAbortSignal() {
91094
- const signal = Object.create(AbortSignal.prototype);
91095
- EventTarget.call(signal);
91096
- abortedFlags.set(signal, false);
91097
- return signal;
91098
- }
91099
- /**
91100
- * Abort a given signal.
91101
- */
91102
- function abortSignal(signal) {
91103
- if (abortedFlags.get(signal) !== false) {
91104
- return;
91105
- }
91106
- abortedFlags.set(signal, true);
91107
- signal.dispatchEvent({ type: "abort" });
91108
- }
91109
- /**
91110
- * Aborted flag for each instances.
91111
- */
91112
- const abortedFlags = new WeakMap();
91113
- // Properties should be enumerable.
91114
- Object.defineProperties(AbortSignal.prototype, {
91115
- aborted: { enumerable: true },
91116
- });
91117
- // `toString()` should return `"[object AbortSignal]"`
91118
- if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
91119
- Object.defineProperty(AbortSignal.prototype, Symbol.toStringTag, {
91120
- configurable: true,
91121
- value: "AbortSignal",
91122
- });
91123
- }
91124
-
91125
- /**
91126
- * The AbortController.
91127
- * @see https://dom.spec.whatwg.org/#abortcontroller
91128
- */
91129
- class AbortController$1 {
91130
- /**
91131
- * Initialize this controller.
91132
- */
91133
- constructor() {
91134
- signals.set(this, createAbortSignal());
91135
- }
91136
- /**
91137
- * Returns the `AbortSignal` object associated with this object.
91138
- */
91139
- get signal() {
91140
- return getSignal(this);
91141
- }
91142
- /**
91143
- * Abort and signal to any observers that the associated activity is to be aborted.
91144
- */
91145
- abort() {
91146
- abortSignal(getSignal(this));
91147
- }
91148
- }
91149
- /**
91150
- * Associated signals.
91151
- */
91152
- const signals = new WeakMap();
91153
- /**
91154
- * Get the associated signal of a given controller.
91155
- */
91156
- function getSignal(controller) {
91157
- const signal = signals.get(controller);
91158
- if (signal == null) {
91159
- throw new TypeError(`Expected 'this' to be an 'AbortController' object, but got ${controller === null ? "null" : typeof controller}`);
91160
- }
91161
- return signal;
91162
- }
91163
- // Properties should be enumerable.
91164
- Object.defineProperties(AbortController$1.prototype, {
91165
- signal: { enumerable: true },
91166
- abort: { enumerable: true },
91167
- });
91168
- if (typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol") {
91169
- Object.defineProperty(AbortController$1.prototype, Symbol.toStringTag, {
91170
- configurable: true,
91171
- value: "AbortController",
91172
- });
91173
- }
91174
-
91175
90202
  var __create = Object.create;
91176
90203
  var __defProp = Object.defineProperty;
91177
90204
  var __defProps = Object.defineProperties;
@@ -118772,10 +117799,10 @@ var require_lodash = __commonJS({
118772
117799
  return "";
118773
117800
  }
118774
117801
  __name(toSource, "toSource");
118775
- function cloneDeep3(value) {
117802
+ function cloneDeep5(value) {
118776
117803
  return baseClone(value, true, true);
118777
117804
  }
118778
- __name(cloneDeep3, "cloneDeep");
117805
+ __name(cloneDeep5, "cloneDeep");
118779
117806
  function eq4(value, other) {
118780
117807
  return value === other || value !== value && other !== other;
118781
117808
  }
@@ -118824,7 +117851,7 @@ var require_lodash = __commonJS({
118824
117851
  return false;
118825
117852
  }
118826
117853
  __name(stubFalse, "stubFalse");
118827
- module.exports = cloneDeep3;
117854
+ module.exports = cloneDeep5;
118828
117855
  }
118829
117856
  });
118830
117857
  var require_tslib = __commonJS({
@@ -121209,9 +120236,8 @@ var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/jXEx
121209
120236
  return didkit_wasm_default(arg);
121210
120237
  }), "init");
121211
120238
  var didkit_default = init2;
121212
- if (!window) {
120239
+ if (typeof window === "undefined")
121213
120240
  globalThis.crypto = crypto2;
121214
- }
121215
120241
  var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async$1(void 0, null, function* () {
121216
120242
  return generateWallet(wallet.contents, {
121217
120243
  plugins: [...wallet.plugins, plugin]
@@ -129483,6 +128509,7 @@ var fast_json_patch_default = Object.assign({}, core_exports, duplex_exports, {
129483
128509
  escapePathComponent,
129484
128510
  unescapePathComponent
129485
128511
  });
128512
+ var import_lodash3 = __toESM(require_lodash(), 1);
129486
128513
  var import_random3 = __toESM(require_random(), 1);
129487
128514
  var SyncOptions;
129488
128515
  (function(SyncOptions2) {
@@ -131229,11 +130256,6 @@ var Stream = class extends Observable {
131229
130256
  get api() {
131230
130257
  return this._context.api;
131231
130258
  }
131232
- get metadata() {
131233
- var _a;
131234
- const { next, metadata } = this.state$.value;
131235
- return (0, import_lodash.default)((_a = next == null ? void 0 : next.metadata) != null ? _a : metadata);
131236
- }
131237
130259
  get content() {
131238
130260
  var _a;
131239
130261
  const { next, content } = this.state$.value;
@@ -131277,16 +130299,6 @@ function StreamStatic() {
131277
130299
  }
131278
130300
  __name(StreamStatic, "StreamStatic");
131279
130301
  var import_cross_fetch = __toESM(require_browser_ponyfill(), 1);
131280
- function polyfillAbortController() {
131281
- if (!globalThis.AbortController) {
131282
- globalThis.AbortController = AbortController$1;
131283
- }
131284
- if (!globalThis.AbortSignal) {
131285
- globalThis.AbortSignal = AbortSignal;
131286
- }
131287
- }
131288
- __name(polyfillAbortController, "polyfillAbortController");
131289
- polyfillAbortController();
131290
130302
  function mergeAbortSignals(signals) {
131291
130303
  const controller = new AbortController();
131292
130304
  if (signals.length === 0) {
@@ -131320,6 +130332,21 @@ var TimedAbortSignal = class {
131320
130332
  }
131321
130333
  };
131322
130334
  __name(TimedAbortSignal, "TimedAbortSignal");
130335
+ function abortable2(original, fn) {
130336
+ return __async$1(this, null, function* () {
130337
+ const controller = new AbortController();
130338
+ const onAbort = /* @__PURE__ */ __name(() => {
130339
+ controller.abort();
130340
+ }, "onAbort");
130341
+ original.addEventListener("abort", onAbort);
130342
+ if (original.aborted)
130343
+ controller.abort();
130344
+ return fn(controller.signal).finally(() => {
130345
+ original.removeEventListener("abort", onAbort);
130346
+ });
130347
+ });
130348
+ }
130349
+ __name(abortable2, "abortable");
131323
130350
  var DEFAULT_FETCH_TIMEOUT = 60 * 1e3 * 3;
131324
130351
  function fetchJson(_0) {
131325
130352
  return __async$1(this, arguments, function* (url, opts = {}) {
@@ -131331,8 +130358,10 @@ function fetchJson(_0) {
131331
130358
  }
131332
130359
  const timeoutLength = opts.timeout || DEFAULT_FETCH_TIMEOUT;
131333
130360
  const timedAbortSignal = new TimedAbortSignal(timeoutLength);
131334
- opts.signal = opts.signal ? mergeAbortSignals([opts.signal, timedAbortSignal.signal]) : timedAbortSignal.signal;
131335
- const res = yield (0, import_cross_fetch.default)(String(url), opts).finally(() => timedAbortSignal.clear());
130361
+ const signal = opts.signal ? mergeAbortSignals([opts.signal, timedAbortSignal.signal]) : timedAbortSignal.signal;
130362
+ const res = yield abortable2(signal, (abortSignal) => {
130363
+ return (0, import_cross_fetch.default)(String(url), __spreadProps(__spreadValues({}, opts), { signal: abortSignal }));
130364
+ }).finally(() => timedAbortSignal.clear());
131336
130365
  if (!res.ok) {
131337
130366
  const text = yield res.text();
131338
130367
  throw new Error(`HTTP request to '${url}' failed with status '${res.statusText}': ${text}`);
@@ -131496,6 +130525,16 @@ var StreamUtils = class {
131496
130525
  }
131497
130526
  return true;
131498
130527
  }
130528
+ static assertCommitLinksToState(state, commit) {
130529
+ const streamId = this.streamIdFromState(state);
130530
+ if (commit.id && !commit.id.equals(state.log[0].cid)) {
130531
+ throw new Error(`Invalid genesis CID in commit for StreamID ${streamId.toString()}. Found: ${commit.id}, expected ${state.log[0].cid}`);
130532
+ }
130533
+ const expectedPrev = state.log[state.log.length - 1].cid;
130534
+ if (!commit.prev.equals(expectedPrev)) {
130535
+ throw new Error(`Commit doesn't properly point to previous commit in log. Expected ${expectedPrev}, found 'prev' ${commit.prev}`);
130536
+ }
130537
+ }
131499
130538
  static convertCommitToSignedCommitContainer(commit, ipfs) {
131500
130539
  return __async$1(this, null, function* () {
131501
130540
  if (StreamUtils.isSignedCommit(commit)) {
@@ -131626,6 +130665,11 @@ var TileDocument = TileDocument_1 = /* @__PURE__ */ __name(class TileDocument2 e
131626
130665
  get content() {
131627
130666
  return super.content;
131628
130667
  }
130668
+ get metadata() {
130669
+ var _a;
130670
+ const { next, metadata } = this.state$.value;
130671
+ return (0, import_lodash3.default)((_a = next == null ? void 0 : next.metadata) != null ? _a : metadata);
130672
+ }
131629
130673
  static create(_0, _1, _2) {
131630
130674
  return __async$1(this, arguments, function* (ceramic, content, metadata, opts = {}) {
131631
130675
  opts = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTS), opts);
@@ -131686,7 +130730,7 @@ var TileDocument = TileDocument_1 = /* @__PURE__ */ __name(class TileDocument2 e
131686
130730
  header,
131687
130731
  data: jsonPatch,
131688
130732
  prev: this.tip,
131689
- id: this.state$.id.cid
130733
+ id: this.id.cid
131690
130734
  };
131691
130735
  const commit = yield TileDocument_1._signDagJWS(this.api, rawCommit);
131692
130736
  const updated = yield this.api.applyCommit(this.id, commit, opts);
@@ -132710,6 +131754,7 @@ var Document = class extends Observable {
132710
131754
  }
132711
131755
  };
132712
131756
  __name(Document, "Document");
131757
+ var import_lodash4 = __toESM(require_lodash(), 1);
132713
131758
  var __decorate5 = function(decorators, target, key2, desc) {
132714
131759
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key2) : desc, d;
132715
131760
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -132740,6 +131785,11 @@ var Caip10Link = Caip10Link_1 = /* @__PURE__ */ __name(class Caip10Link2 extends
132740
131785
  get did() {
132741
131786
  return this.content;
132742
131787
  }
131788
+ get metadata() {
131789
+ var _a;
131790
+ const { next, metadata } = this.state$.value;
131791
+ return (0, import_lodash4.default)((_a = next == null ? void 0 : next.metadata) != null ? _a : metadata);
131792
+ }
132743
131793
  static fromAccount(_0, _1) {
132744
131794
  return __async$1(this, arguments, function* (ceramic, accountId, opts = {}) {
132745
131795
  opts = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTS2), opts);
@@ -132804,7 +131854,7 @@ var Caip10Link = Caip10Link_1 = /* @__PURE__ */ __name(class Caip10Link2 extends
132804
131854
  };
132805
131855
  }
132806
131856
  makeCommit(proof) {
132807
- return { data: proof, prev: this.tip, id: this.state$.id.cid };
131857
+ return { data: proof, prev: this.tip, id: this.id.cid };
132808
131858
  }
132809
131859
  makeReadOnly() {
132810
131860
  this.setDidProof = throwReadOnlyError2;
@@ -132870,6 +131920,9 @@ var Model = Model_1 = /* @__PURE__ */ __name(class Model2 extends Stream {
132870
131920
  get content() {
132871
131921
  return super.content;
132872
131922
  }
131923
+ get metadata() {
131924
+ return { controller: this.state$.value.metadata.controllers[0], model: Model_1.MODEL };
131925
+ }
132873
131926
  static create(ceramic, content, metadata) {
132874
131927
  return __async$1(this, null, function* () {
132875
131928
  Model_1.assertComplete(content);
@@ -132964,6 +132017,12 @@ var Model = Model_1 = /* @__PURE__ */ __name(class Model2 extends Stream {
132964
132017
  };
132965
132018
  }
132966
132019
  static _makeGenesis(signer, content, metadata) {
132020
+ return __async$1(this, null, function* () {
132021
+ const commit = yield this._makeRawGenesis(signer, content, metadata);
132022
+ return Model_1._signDagJWS(signer, commit);
132023
+ });
132024
+ }
132025
+ static _makeRawGenesis(signer, content, metadata) {
132967
132026
  return __async$1(this, null, function* () {
132968
132027
  if (content == null) {
132969
132028
  throw new Error(`Genesis content cannot be null`);
@@ -132981,8 +132040,7 @@ var Model = Model_1 = /* @__PURE__ */ __name(class Model2 extends Stream {
132981
132040
  unique: (0, import_random4.randomBytes)(12),
132982
132041
  model: Model_1.MODEL.bytes
132983
132042
  };
132984
- const commit = { data: content, header };
132985
- return Model_1._signDagJWS(signer, commit);
132043
+ return { data: content, header };
132986
132044
  });
132987
132045
  }
132988
132046
  makeReadOnly() {
@@ -133061,6 +132119,10 @@ var ModelInstanceDocument = ModelInstanceDocument_1 = /* @__PURE__ */ __name(cla
133061
132119
  get content() {
133062
132120
  return super.content;
133063
132121
  }
132122
+ get metadata() {
132123
+ const metadata = this.state$.value.metadata;
132124
+ return { controller: metadata.controllers[0], model: metadata.model };
132125
+ }
133064
132126
  static create(_0, _1, _2) {
133065
132127
  return __async$1(this, arguments, function* (ceramic, content, metadata, opts = {}) {
133066
132128
  opts = __spreadValues(__spreadValues({}, DEFAULT_CREATE_OPTS3), opts);
@@ -133094,7 +132156,7 @@ var ModelInstanceDocument = ModelInstanceDocument_1 = /* @__PURE__ */ __name(cla
133094
132156
  const rawCommit = {
133095
132157
  data: jsonPatch,
133096
132158
  prev: this.tip,
133097
- id: this.state$.id.cid
132159
+ id: this.id.cid
133098
132160
  };
133099
132161
  const commit = yield ModelInstanceDocument_1._signDagJWS(this.api, rawCommit);
133100
132162
  const updated = yield this.api.applyCommit(this.id, commit, opts);
@@ -133123,6 +132185,12 @@ var ModelInstanceDocument = ModelInstanceDocument_1 = /* @__PURE__ */ __name(cla
133123
132185
  };
133124
132186
  }
133125
132187
  static _makeGenesis(signer, content, metadata) {
132188
+ return __async$1(this, null, function* () {
132189
+ const commit = yield this._makeRawGenesis(signer, content, metadata);
132190
+ return ModelInstanceDocument_1._signDagJWS(signer, commit);
132191
+ });
132192
+ }
132193
+ static _makeRawGenesis(signer, content, metadata) {
133126
132194
  return __async$1(this, null, function* () {
133127
132195
  if (!metadata.model) {
133128
132196
  throw new Error(`Must specify a 'model' when creating a ModelInstanceDocument`);
@@ -133140,8 +132208,7 @@ var ModelInstanceDocument = ModelInstanceDocument_1 = /* @__PURE__ */ __name(cla
133140
132208
  unique: (0, import_random5.randomBytes)(12),
133141
132209
  model: metadata.model.bytes
133142
132210
  };
133143
- const commit = { data: content, header };
133144
- return ModelInstanceDocument_1._signDagJWS(signer, commit);
132211
+ return { data: content, header };
133145
132212
  });
133146
132213
  }
133147
132214
  static _signDagJWS(signer, commit) {
@@ -133219,9 +132286,14 @@ var RemoteIndexApi = class {
133219
132286
  queryURL.searchParams.set(key2, query[key2]);
133220
132287
  }
133221
132288
  const response = yield this._fetchJson(queryURL);
133222
- const entries = response.entries.map(StreamUtils.deserializeState);
132289
+ const edges = response.edges.map((e) => {
132290
+ return {
132291
+ cursor: e.cursor,
132292
+ node: StreamUtils.deserializeState(e.node)
132293
+ };
132294
+ });
133223
132295
  return {
133224
- entries,
132296
+ edges,
133225
132297
  pageInfo: response.pageInfo
133226
132298
  };
133227
132299
  });
@@ -133269,10 +132341,10 @@ var CeramicClient = class {
133269
132341
  if (found) {
133270
132342
  if (!StreamUtils.statesEqual(stream.state, found.state))
133271
132343
  found.next(stream.state);
133272
- return this.buildStream(found);
132344
+ return this.buildStreamFromDocument(found);
133273
132345
  } else {
133274
132346
  this._streamCache.set(stream.id.toString(), stream);
133275
- return this.buildStream(stream);
132347
+ return this.buildStreamFromDocument(stream);
133276
132348
  }
133277
132349
  });
133278
132350
  }
@@ -133287,7 +132359,7 @@ var CeramicClient = class {
133287
132359
  stream = yield Document.load(streamRef, this._apiUrl, this._config.syncInterval, opts);
133288
132360
  this._streamCache.set(stream.id.toString(), stream);
133289
132361
  }
133290
- return this.buildStream(stream);
132362
+ return this.buildStreamFromDocument(stream);
133291
132363
  });
133292
132364
  }
133293
132365
  multiQuery(queries, timeout) {
@@ -133308,7 +132380,7 @@ var CeramicClient = class {
133308
132380
  const [k, v] = e;
133309
132381
  const state = StreamUtils.deserializeState(v);
133310
132382
  const stream = new Document(state, this._apiUrl, this._config.syncInterval);
133311
- acc[k] = this.buildStream(stream);
132383
+ acc[k] = this.buildStreamFromDocument(stream);
133312
132384
  return acc;
133313
132385
  }, {});
133314
132386
  });
@@ -133325,10 +132397,10 @@ var CeramicClient = class {
133325
132397
  const fromCache = this._streamCache.get(effectiveStreamId.toString());
133326
132398
  if (fromCache) {
133327
132399
  fromCache.next(document.state);
133328
- return this.buildStream(document);
132400
+ return this.buildStreamFromDocument(document);
133329
132401
  } else {
133330
132402
  this._streamCache.set(effectiveStreamId.toString(), document);
133331
- return this.buildStream(document);
132403
+ return this.buildStreamFromDocument(document);
133332
132404
  }
133333
132405
  });
133334
132406
  }
@@ -133347,16 +132419,15 @@ var CeramicClient = class {
133347
132419
  addStreamHandler(streamHandler) {
133348
132420
  this._streamConstructors[streamHandler.name] = streamHandler.stream_constructor;
133349
132421
  }
133350
- findStreamConstructor(type) {
133351
- const constructor = this._streamConstructors[type];
133352
- if (constructor) {
133353
- return constructor;
133354
- } else {
133355
- throw new Error(`Failed to find constructor for stream ${type}`);
133356
- }
132422
+ buildStreamFromState(state) {
132423
+ const stream$ = new Document(state, this._apiUrl, this._config.syncInterval);
132424
+ return this.buildStreamFromDocument(stream$);
133357
132425
  }
133358
- buildStream(stream) {
133359
- const streamConstructor = this.findStreamConstructor(stream.state.type);
132426
+ buildStreamFromDocument(stream) {
132427
+ const type = stream.state.type;
132428
+ const streamConstructor = this._streamConstructors[type];
132429
+ if (!streamConstructor)
132430
+ throw new Error(`Failed to find constructor for stream ${type}`);
133360
132431
  return new streamConstructor(stream, this.context);
133361
132432
  }
133362
132433
  setDID(did) {
@@ -138245,4 +137316,4 @@ const VCCard = ({ credential, issueeOverride, className = "" }) => {
138245
137316
  };
138246
137317
 
138247
137318
  export { VCCard as V };
138248
- //# sourceMappingURL=VCCard-3dba135e.js.map
137319
+ //# sourceMappingURL=VCCard-2b326e89.js.map