@aws-amplify/analytics 7.0.1-console-preview.f63250a.0 → 7.0.1-console-preview.e8aa063.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.
- package/lib/errors/AnalyticsError.d.ts +7 -0
- package/lib/errors/AnalyticsError.js +23 -0
- package/lib/errors/assertValidationError.d.ts +5 -0
- package/lib/errors/assertValidationError.js +17 -0
- package/lib/errors/index.d.ts +3 -0
- package/lib/errors/index.js +12 -0
- package/lib/errors/validation.d.ts +9 -0
- package/lib/errors/validation.js +31 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -15
- package/lib/providers/pinpoint/apis/identifyUser.d.ts +10 -0
- package/lib/providers/pinpoint/apis/identifyUser.js +44 -0
- package/lib/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/providers/pinpoint/apis/index.js +9 -0
- package/lib/providers/pinpoint/apis/record.d.ts +11 -0
- package/lib/providers/pinpoint/apis/record.js +44 -0
- package/lib/providers/pinpoint/index.d.ts +1 -1
- package/lib/providers/pinpoint/index.js +1 -7
- package/lib/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib/providers/pinpoint/types/errors.js +15 -0
- package/lib/providers/pinpoint/types/index.d.ts +2 -0
- package/lib/providers/pinpoint/types/index.js +7 -0
- package/lib/providers/pinpoint/types/parameters.d.ts +18 -0
- package/lib/providers/pinpoint/utils/index.d.ts +2 -0
- package/lib/providers/pinpoint/utils/index.js +9 -0
- package/lib/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib/providers/pinpoint/utils/resolveConfig.js +18 -0
- package/lib/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib/providers/pinpoint/utils/resolveCredentials.js +24 -0
- package/lib/setupTests.js +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/{lib-esm/types/Analytics.d.ts → lib/types/analytics.d.ts} +0 -8
- package/lib/types/index.d.ts +1 -3
- package/lib/types/index.js +1 -3
- package/lib/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
- package/lib/utils/{UserAgent.js → userAgent.js} +5 -5
- package/lib-esm/errors/AnalyticsError.d.ts +7 -0
- package/lib-esm/errors/AnalyticsError.js +20 -0
- package/lib-esm/errors/assertValidationError.d.ts +5 -0
- package/lib-esm/errors/assertValidationError.js +13 -0
- package/lib-esm/errors/index.d.ts +3 -0
- package/lib-esm/errors/index.js +5 -0
- package/lib-esm/errors/validation.d.ts +9 -0
- package/lib-esm/errors/validation.js +28 -0
- package/lib-esm/index.d.ts +0 -3
- package/lib-esm/index.js +0 -12
- package/lib-esm/providers/pinpoint/apis/identifyUser.d.ts +10 -0
- package/lib-esm/providers/pinpoint/apis/identifyUser.js +40 -0
- package/lib-esm/providers/pinpoint/apis/index.d.ts +2 -0
- package/{src/types/providers/index.ts → lib-esm/providers/pinpoint/apis/index.js} +2 -1
- package/lib-esm/providers/pinpoint/apis/record.d.ts +11 -0
- package/lib-esm/providers/pinpoint/apis/record.js +40 -0
- package/lib-esm/providers/pinpoint/index.d.ts +1 -1
- package/lib-esm/providers/pinpoint/index.js +1 -6
- package/lib-esm/providers/pinpoint/types/errors.d.ts +9 -0
- package/lib-esm/providers/pinpoint/types/errors.js +12 -0
- package/lib-esm/providers/pinpoint/types/index.d.ts +2 -0
- package/lib-esm/{types/providers → providers/pinpoint/types}/index.js +1 -1
- package/lib-esm/providers/pinpoint/types/parameters.d.ts +18 -0
- package/lib-esm/providers/pinpoint/utils/index.d.ts +2 -0
- package/lib-esm/{utils/AppUtils.js → providers/pinpoint/utils/index.js} +2 -4
- package/lib-esm/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/providers/pinpoint/utils/resolveConfig.js +14 -0
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib-esm/providers/pinpoint/utils/resolveCredentials.js +20 -0
- package/lib-esm/setupTests.js +1 -0
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/{lib/types/Analytics.d.ts → lib-esm/types/analytics.d.ts} +0 -8
- package/lib-esm/types/index.d.ts +1 -3
- package/lib-esm/types/index.js +1 -3
- package/lib-esm/utils/{UserAgent.d.ts → userAgent.d.ts} +1 -1
- package/lib-esm/utils/{UserAgent.js → userAgent.js} +1 -1
- package/package.json +11 -29
- package/src/errors/AnalyticsError.ts +18 -0
- package/src/errors/assertValidationError.ts +19 -0
- package/src/errors/index.ts +6 -0
- package/src/errors/validation.ts +31 -0
- package/src/index.ts +0 -15
- package/src/providers/pinpoint/apis/identifyUser.ts +35 -0
- package/src/{utils/AppUtils.ts → providers/pinpoint/apis/index.ts} +2 -4
- package/src/providers/pinpoint/apis/record.ts +50 -0
- package/src/providers/pinpoint/index.ts +1 -3
- package/src/providers/pinpoint/types/errors.ts +12 -0
- package/src/providers/pinpoint/types/index.ts +5 -0
- package/src/providers/pinpoint/types/parameters.ts +24 -0
- package/src/providers/pinpoint/utils/index.ts +5 -0
- package/src/providers/pinpoint/utils/resolveConfig.ts +18 -0
- package/src/providers/pinpoint/utils/resolveCredentials.ts +20 -0
- package/src/types/{Analytics.ts → analytics.ts} +1 -10
- package/src/types/index.ts +1 -3
- package/src/utils/{UserAgent.ts → userAgent.ts} +1 -1
- package/lib/Analytics.d.ts +0 -87
- package/lib/Analytics.js +0 -354
- package/lib/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
- package/lib/providers/AWSKinesisFirehoseProvider.js +0 -82
- package/lib/providers/AWSKinesisProvider.d.ts +0 -43
- package/lib/providers/AWSKinesisProvider.js +0 -240
- package/lib/providers/AWSPinpointProvider.d.ts +0 -67
- package/lib/providers/AWSPinpointProvider.js +0 -576
- package/lib/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
- package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
- package/lib/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -156
- package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
- package/lib/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -96
- package/lib/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
- package/lib/providers/AmazonPersonalizeHelper/index.js +0 -7
- package/lib/providers/AmazonPersonalizeProvider.d.ts +0 -76
- package/lib/providers/AmazonPersonalizeProvider.js +0 -331
- package/lib/providers/EventBuffer.d.ts +0 -28
- package/lib/providers/EventBuffer.js +0 -209
- package/lib/providers/index.d.ts +0 -4
- package/lib/providers/index.js +0 -14
- package/lib/trackers/EventTracker.d.ts +0 -9
- package/lib/trackers/EventTracker.js +0 -99
- package/lib/trackers/PageViewTracker.d.ts +0 -12
- package/lib/trackers/PageViewTracker.js +0 -158
- package/lib/trackers/SessionTracker-rn.d.ts +0 -12
- package/lib/trackers/SessionTracker-rn.js +0 -134
- package/lib/trackers/SessionTracker.d.ts +0 -14
- package/lib/trackers/SessionTracker.js +0 -163
- package/lib/trackers/index.d.ts +0 -3
- package/lib/trackers/index.js +0 -11
- package/lib/trackers/reactnative.d.ts +0 -8
- package/lib/trackers/reactnative.js +0 -19
- package/lib/types/Analytics.js +0 -2
- package/lib/types/Provider.d.ts +0 -10
- package/lib/types/providers/AWSKinesisProvider.d.ts +0 -6
- package/lib/types/providers/AWSKinesisProvider.js +0 -2
- package/lib/types/providers/AWSPinpointProvider.d.ts +0 -50
- package/lib/types/providers/AWSPinpointProvider.js +0 -2
- package/lib/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
- package/lib/types/providers/AmazonPersonalizeProvider.js +0 -2
- package/lib/types/providers/index.d.ts +0 -1
- package/lib/types/providers/index.js +0 -6
- package/lib/utils/AppUtils.d.ts +0 -2
- package/lib/utils/AppUtils.js +0 -9
- package/lib/utils/AppUtils.native.d.ts +0 -2
- package/lib/utils/AppUtils.native.js +0 -10
- package/lib/utils/MethodEmbed.d.ts +0 -11
- package/lib/utils/MethodEmbed.js +0 -43
- package/lib/vendor/dom-utils/closest.d.ts +0 -12
- package/lib/vendor/dom-utils/closest.js +0 -27
- package/lib/vendor/dom-utils/delegate.d.ts +0 -18
- package/lib/vendor/dom-utils/delegate.js +0 -51
- package/lib/vendor/dom-utils/dispatch.d.ts +0 -17
- package/lib/vendor/dom-utils/dispatch.js +0 -51
- package/lib/vendor/dom-utils/get-attributes.d.ts +0 -11
- package/lib/vendor/dom-utils/get-attributes.js +0 -28
- package/lib/vendor/dom-utils/index.d.ts +0 -7
- package/lib/vendor/dom-utils/index.js +0 -17
- package/lib/vendor/dom-utils/matches.d.ts +0 -11
- package/lib/vendor/dom-utils/matches.js +0 -69
- package/lib/vendor/dom-utils/parents.d.ts +0 -10
- package/lib/vendor/dom-utils/parents.js +0 -22
- package/lib/vendor/dom-utils/parse-url.d.ts +0 -9
- package/lib/vendor/dom-utils/parse-url.js +0 -59
- package/lib-esm/Analytics.d.ts +0 -87
- package/lib-esm/Analytics.js +0 -351
- package/lib-esm/providers/AWSKinesisFirehoseProvider.d.ts +0 -12
- package/lib-esm/providers/AWSKinesisFirehoseProvider.js +0 -79
- package/lib-esm/providers/AWSKinesisProvider.d.ts +0 -43
- package/lib-esm/providers/AWSKinesisProvider.js +0 -237
- package/lib-esm/providers/AWSPinpointProvider.d.ts +0 -67
- package/lib-esm/providers/AWSPinpointProvider.js +0 -573
- package/lib-esm/providers/AmazonPersonalizeHelper/DataType.d.ts +0 -40
- package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.d.ts +0 -20
- package/lib-esm/providers/AmazonPersonalizeHelper/MediaAutoTrack.js +0 -153
- package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.d.ts +0 -17
- package/lib-esm/providers/AmazonPersonalizeHelper/SessionInfoManager.js +0 -92
- package/lib-esm/providers/AmazonPersonalizeHelper/index.d.ts +0 -3
- package/lib-esm/providers/AmazonPersonalizeHelper/index.js +0 -2
- package/lib-esm/providers/AmazonPersonalizeProvider.d.ts +0 -76
- package/lib-esm/providers/AmazonPersonalizeProvider.js +0 -328
- package/lib-esm/providers/EventBuffer.d.ts +0 -28
- package/lib-esm/providers/EventBuffer.js +0 -207
- package/lib-esm/providers/index.d.ts +0 -4
- package/lib-esm/providers/index.js +0 -7
- package/lib-esm/trackers/EventTracker.d.ts +0 -9
- package/lib-esm/trackers/EventTracker.js +0 -96
- package/lib-esm/trackers/PageViewTracker.d.ts +0 -12
- package/lib-esm/trackers/PageViewTracker.js +0 -155
- package/lib-esm/trackers/SessionTracker-rn.d.ts +0 -12
- package/lib-esm/trackers/SessionTracker-rn.js +0 -131
- package/lib-esm/trackers/SessionTracker.d.ts +0 -14
- package/lib-esm/trackers/SessionTracker.js +0 -160
- package/lib-esm/trackers/index.d.ts +0 -3
- package/lib-esm/trackers/index.js +0 -5
- package/lib-esm/trackers/reactnative.d.ts +0 -8
- package/lib-esm/trackers/reactnative.js +0 -14
- package/lib-esm/types/Analytics.js +0 -1
- package/lib-esm/types/Provider.d.ts +0 -10
- package/lib-esm/types/providers/AWSKinesisProvider.d.ts +0 -6
- package/lib-esm/types/providers/AWSKinesisProvider.js +0 -1
- package/lib-esm/types/providers/AWSPinpointProvider.d.ts +0 -50
- package/lib-esm/types/providers/AWSPinpointProvider.js +0 -1
- package/lib-esm/types/providers/AmazonPersonalizeProvider.d.ts +0 -7
- package/lib-esm/types/providers/AmazonPersonalizeProvider.js +0 -1
- package/lib-esm/types/providers/index.d.ts +0 -1
- package/lib-esm/utils/AppUtils.d.ts +0 -2
- package/lib-esm/utils/AppUtils.native.d.ts +0 -2
- package/lib-esm/utils/AppUtils.native.js +0 -7
- package/lib-esm/utils/MethodEmbed.d.ts +0 -11
- package/lib-esm/utils/MethodEmbed.js +0 -40
- package/lib-esm/vendor/dom-utils/closest.d.ts +0 -12
- package/lib-esm/vendor/dom-utils/closest.js +0 -23
- package/lib-esm/vendor/dom-utils/delegate.d.ts +0 -18
- package/lib-esm/vendor/dom-utils/delegate.js +0 -47
- package/lib-esm/vendor/dom-utils/dispatch.d.ts +0 -17
- package/lib-esm/vendor/dom-utils/dispatch.js +0 -47
- package/lib-esm/vendor/dom-utils/get-attributes.d.ts +0 -11
- package/lib-esm/vendor/dom-utils/get-attributes.js +0 -24
- package/lib-esm/vendor/dom-utils/index.d.ts +0 -7
- package/lib-esm/vendor/dom-utils/index.js +0 -7
- package/lib-esm/vendor/dom-utils/matches.d.ts +0 -11
- package/lib-esm/vendor/dom-utils/matches.js +0 -65
- package/lib-esm/vendor/dom-utils/parents.d.ts +0 -10
- package/lib-esm/vendor/dom-utils/parents.js +0 -18
- package/lib-esm/vendor/dom-utils/parse-url.d.ts +0 -9
- package/lib-esm/vendor/dom-utils/parse-url.js +0 -55
- package/src/Analytics.ts +0 -446
- package/src/providers/AWSKinesisFirehoseProvider.ts +0 -105
- package/src/providers/AWSKinesisProvider.ts +0 -250
- package/src/providers/AWSPinpointProvider.ts +0 -685
- package/src/providers/AmazonPersonalizeHelper/DataType.ts +0 -49
- package/src/providers/AmazonPersonalizeHelper/MediaAutoTrack.ts +0 -196
- package/src/providers/AmazonPersonalizeHelper/SessionInfoManager.ts +0 -121
- package/src/providers/AmazonPersonalizeHelper/index.ts +0 -11
- package/src/providers/AmazonPersonalizeProvider.ts +0 -398
- package/src/providers/EventBuffer.ts +0 -257
- package/src/providers/index.ts +0 -8
- package/src/trackers/EventTracker.ts +0 -115
- package/src/trackers/PageViewTracker.ts +0 -157
- package/src/trackers/SessionTracker-rn.ts +0 -134
- package/src/trackers/SessionTracker.ts +0 -179
- package/src/trackers/index.ts +0 -5
- package/src/trackers/reactnative.ts +0 -13
- package/src/types/Provider.ts +0 -26
- package/src/types/providers/AWSKinesisProvider.ts +0 -8
- package/src/types/providers/AWSPinpointProvider.ts +0 -60
- package/src/types/providers/AmazonPersonalizeProvider.ts +0 -9
- package/src/utils/AppUtils.native.ts +0 -9
- package/src/utils/MethodEmbed.ts +0 -49
- package/src/vendor/dom-utils/closest.ts +0 -25
- package/src/vendor/dom-utils/delegate.ts +0 -51
- package/src/vendor/dom-utils/dispatch.ts +0 -59
- package/src/vendor/dom-utils/get-attributes.ts +0 -26
- package/src/vendor/dom-utils/index.ts +0 -7
- package/src/vendor/dom-utils/matches.ts +0 -68
- package/src/vendor/dom-utils/parents.ts +0 -19
- package/src/vendor/dom-utils/parse-url.ts +0 -66
- /package/lib/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
- /package/lib/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
- /package/lib-esm/{types/Provider.js → providers/pinpoint/types/parameters.js} +0 -0
- /package/lib-esm/{providers/AmazonPersonalizeHelper/DataType.js → types/analytics.js} +0 -0
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { AppState } from 'react-native';
|
|
4
|
-
|
|
5
|
-
const isAppInForeground = () => {
|
|
6
|
-
return AppState.currentState === 'active';
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { isAppInForeground };
|
package/src/utils/MethodEmbed.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
const lists: MethodEmbed[] = [];
|
|
5
|
-
|
|
6
|
-
export class MethodEmbed {
|
|
7
|
-
public context;
|
|
8
|
-
public methodName;
|
|
9
|
-
private _originalMethod;
|
|
10
|
-
private _bindedMethod;
|
|
11
|
-
|
|
12
|
-
static add(context, methodName, methodOverride) {
|
|
13
|
-
getInstance(context, methodName).set(methodOverride);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
static remove(context, methodName) {
|
|
17
|
-
getInstance(context, methodName).remove();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
constructor(context, methodName) {
|
|
21
|
-
this.context = context;
|
|
22
|
-
this.methodName = methodName;
|
|
23
|
-
|
|
24
|
-
this._originalMethod = context[methodName].bind(context);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public set(methodOverride) {
|
|
28
|
-
this.context[this.methodName] = (...args) => {
|
|
29
|
-
return methodOverride(this._originalMethod(...args));
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public remove() {
|
|
34
|
-
this.context[this.methodName] = this._originalMethod;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getInstance(context, methodName): MethodEmbed {
|
|
39
|
-
let instance = lists.filter(
|
|
40
|
-
h => h.context === context && h.methodName === methodName
|
|
41
|
-
)[0];
|
|
42
|
-
|
|
43
|
-
if (!instance) {
|
|
44
|
-
instance = new MethodEmbed(context, methodName);
|
|
45
|
-
lists.push(instance);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return instance;
|
|
49
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { matches } from './matches';
|
|
6
|
-
import { parents } from './parents';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Gets the closest parent element that matches the passed selector.
|
|
10
|
-
* @param {Element} element The element whose parents to check.
|
|
11
|
-
* @param {string} selector The CSS selector to match against.
|
|
12
|
-
* @param {boolean=} shouldCheckSelf True if the selector should test against
|
|
13
|
-
* the passed element itself.
|
|
14
|
-
* @return {Element|undefined} The matching element or undefined.
|
|
15
|
-
*/
|
|
16
|
-
export function closest(element, selector, shouldCheckSelf = false) {
|
|
17
|
-
if (!(element && element.nodeType === 1 && selector)) return;
|
|
18
|
-
const parentElements = (shouldCheckSelf ? [element] : []).concat(
|
|
19
|
-
parents(element)
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
for (let i = 0, parent; (parent = parentElements[i]); i++) {
|
|
23
|
-
if (matches(parent, selector)) return parent;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { closest } from './closest';
|
|
6
|
-
import { matches } from './matches';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Delegates the handling of events for an element matching a selector to an
|
|
10
|
-
* ancestor of the matching element.
|
|
11
|
-
* @param {!Node} ancestor The ancestor element to add the listener to.
|
|
12
|
-
* @param {string} eventType The event type to listen to.
|
|
13
|
-
* @param {string} selector A CSS selector to match against child elements.
|
|
14
|
-
* @param {!Function} callback A function to run any time the event happens.
|
|
15
|
-
* @param {Object=} opts A configuration options object. The available options:
|
|
16
|
-
* - useCapture<boolean>: If true, bind to the event capture phase.
|
|
17
|
-
* - deep<boolean>: If true, delegate into shadow trees.
|
|
18
|
-
* @return {Object} The delegate object. It contains a destroy method.
|
|
19
|
-
*/
|
|
20
|
-
export function delegate(ancestor, eventType, selector, callback, opts = {}) {
|
|
21
|
-
// Defines the event listener.
|
|
22
|
-
const listener = function(event) {
|
|
23
|
-
let delegateTarget;
|
|
24
|
-
|
|
25
|
-
// If opts.composed is true and the event originated from inside a Shadow
|
|
26
|
-
// tree, check the composed path nodes.
|
|
27
|
-
if (opts['composed'] && typeof event['composedPath'] === 'function') {
|
|
28
|
-
const composedPath = event.composedPath();
|
|
29
|
-
for (let i = 0, node; (node = composedPath[i]); i++) {
|
|
30
|
-
if (node.nodeType === 1 && matches(node, selector)) {
|
|
31
|
-
delegateTarget = node;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
// Otherwise check the parents.
|
|
36
|
-
delegateTarget = closest(event.target, selector, true);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (delegateTarget) {
|
|
40
|
-
callback.call(delegateTarget, event, delegateTarget);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
ancestor.addEventListener(eventType, listener, opts['useCapture']);
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
destroy: () => {
|
|
48
|
-
ancestor.removeEventListener(eventType, listener, opts['useCapture']);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Dispatches an event on the passed element.
|
|
7
|
-
* @param {!Element} element The DOM element to dispatch the event on.
|
|
8
|
-
* @param {string} eventType The type of event to dispatch.
|
|
9
|
-
* @param {Object|string=} eventName A string name of the event constructor
|
|
10
|
-
* to use. Defaults to 'Event' if nothing is passed or 'CustomEvent' if
|
|
11
|
-
* a value is set on `initDict.detail`. If eventName is given an object
|
|
12
|
-
* it is assumed to be initDict and thus reassigned.
|
|
13
|
-
* @param {Object=} initDict The initialization attributes for the
|
|
14
|
-
* event. A `detail` property can be used here to pass custom data.
|
|
15
|
-
* @return {boolean} The return value of `element.dispatchEvent`, which will
|
|
16
|
-
* be false if any of the event listeners called `preventDefault`.
|
|
17
|
-
*/
|
|
18
|
-
export function dispatch(
|
|
19
|
-
element,
|
|
20
|
-
eventType,
|
|
21
|
-
evtName = 'Event',
|
|
22
|
-
init_dict = {}
|
|
23
|
-
) {
|
|
24
|
-
let event;
|
|
25
|
-
let isCustom;
|
|
26
|
-
let initDict = init_dict;
|
|
27
|
-
let eventName = evtName;
|
|
28
|
-
|
|
29
|
-
// eventName is optional
|
|
30
|
-
if (typeof eventName === 'object') {
|
|
31
|
-
initDict = eventName;
|
|
32
|
-
eventName = 'Event';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
initDict['bubbles'] = initDict['bubbles'] || false;
|
|
36
|
-
initDict['cancelable'] = initDict['cancelable'] || false;
|
|
37
|
-
initDict['composed'] = initDict['composed'] || false;
|
|
38
|
-
|
|
39
|
-
// If a detail property is passed, this is a custom event.
|
|
40
|
-
if ('detail' in initDict) isCustom = true;
|
|
41
|
-
eventName = isCustom ? 'CustomEvent' : eventName;
|
|
42
|
-
|
|
43
|
-
// Tries to create the event using constructors, if that doesn't work,
|
|
44
|
-
// fallback to `document.createEvent()`.
|
|
45
|
-
try {
|
|
46
|
-
event = new window[eventName](eventType, initDict);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
event = document.createEvent(eventName);
|
|
49
|
-
const initMethod = 'init' + (isCustom ? 'Custom' : '') + 'Event';
|
|
50
|
-
event[initMethod](
|
|
51
|
-
eventType,
|
|
52
|
-
initDict['bubbles'],
|
|
53
|
-
initDict['cancelable'],
|
|
54
|
-
initDict['detail']
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return element.dispatchEvent(event);
|
|
59
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Gets all attributes of an element as a plain JavaScriot object.
|
|
7
|
-
* @param {Element} element The element whose attributes to get.
|
|
8
|
-
* @return {!Object} An object whose keys are the attribute keys and whose
|
|
9
|
-
* values are the attribute values. If no attributes exist, an empty
|
|
10
|
-
* object is returned.
|
|
11
|
-
*/
|
|
12
|
-
export function getAttributes(element) {
|
|
13
|
-
const attrs = {};
|
|
14
|
-
|
|
15
|
-
// Validate input.
|
|
16
|
-
if (!(element && element.nodeType === 1)) return attrs;
|
|
17
|
-
|
|
18
|
-
// Return an empty object if there are no attributes.
|
|
19
|
-
const map = element.attributes;
|
|
20
|
-
if (map.length === 0) return {};
|
|
21
|
-
|
|
22
|
-
for (let i = 0, attr; (attr = map[i]); i++) {
|
|
23
|
-
attrs[attr.name] = attr.value;
|
|
24
|
-
}
|
|
25
|
-
return attrs;
|
|
26
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { closest } from './closest';
|
|
2
|
-
export { delegate } from './delegate';
|
|
3
|
-
export { dispatch } from './dispatch';
|
|
4
|
-
export { getAttributes } from './get-attributes';
|
|
5
|
-
export { matches } from './matches';
|
|
6
|
-
export { parents } from './parents';
|
|
7
|
-
export { parseUrl } from './parse-url';
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { browserOrNode } from '@aws-amplify/core';
|
|
6
|
-
|
|
7
|
-
const proto =
|
|
8
|
-
browserOrNode().isBrowser && window['Element']
|
|
9
|
-
? window['Element'].prototype
|
|
10
|
-
: null;
|
|
11
|
-
|
|
12
|
-
const nativeMatches = proto
|
|
13
|
-
? proto.matches ||
|
|
14
|
-
// @ts-ignore
|
|
15
|
-
proto.matchesSelector ||
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
proto.webkitMatchesSelector ||
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
proto.mozMatchesSelector ||
|
|
20
|
-
// @ts-ignore
|
|
21
|
-
proto.msMatchesSelector ||
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
proto.oMatchesSelector
|
|
24
|
-
: null;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Tests if a DOM elements matches any of the test DOM elements or selectors.
|
|
28
|
-
* @param {Element} element The DOM element to test.
|
|
29
|
-
* @param {Element|string|Array<Element|string>} test A DOM element, a CSS
|
|
30
|
-
* selector, or an array of DOM elements or CSS selectors to match against.
|
|
31
|
-
* @return {boolean} True of any part of the test matches.
|
|
32
|
-
*/
|
|
33
|
-
export function matches(element, test) {
|
|
34
|
-
// Validate input.
|
|
35
|
-
if (element && element.nodeType === 1 && test) {
|
|
36
|
-
// if test is a string or DOM element test it.
|
|
37
|
-
if (typeof test === 'string' || test.nodeType === 1) {
|
|
38
|
-
return (
|
|
39
|
-
element === test || matchesSelector(element, /** @type {string} */ test)
|
|
40
|
-
);
|
|
41
|
-
} else if ('length' in test) {
|
|
42
|
-
// if it has a length property iterate over the items
|
|
43
|
-
// and return true if any match.
|
|
44
|
-
for (let i = 0, item; (item = test[i]); i++) {
|
|
45
|
-
if (element === item || matchesSelector(element, item)) return true;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// Still here? Return false
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Tests whether a DOM element matches a selector. This polyfills the native
|
|
55
|
-
* Element.prototype.matches method across browsers.
|
|
56
|
-
* @param {!Element} element The DOM element to test.
|
|
57
|
-
* @param {string} selector The CSS selector to test element against.
|
|
58
|
-
* @return {boolean} True if the selector matches.
|
|
59
|
-
*/
|
|
60
|
-
function matchesSelector(element, selector) {
|
|
61
|
-
if (typeof selector !== 'string') return false;
|
|
62
|
-
if (nativeMatches) return nativeMatches.call(element, selector);
|
|
63
|
-
const nodes = element.parentNode.querySelectorAll(selector);
|
|
64
|
-
for (let i = 0, node; (node = nodes[i]); i++) {
|
|
65
|
-
if (node === element) return true;
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns an array of a DOM element's parent elements.
|
|
7
|
-
* @param {!Element} element The DOM element whose parents to get.
|
|
8
|
-
* @return {!Array} An array of all parent elemets, or an empty array if no
|
|
9
|
-
* parent elements are found.
|
|
10
|
-
*/
|
|
11
|
-
export function parents(ele) {
|
|
12
|
-
const list = [];
|
|
13
|
-
let element = ele;
|
|
14
|
-
while (element && element.parentNode && element.parentNode.nodeType === 1) {
|
|
15
|
-
element = /** @type {!Element} */ element.parentNode;
|
|
16
|
-
list.push(element);
|
|
17
|
-
}
|
|
18
|
-
return list;
|
|
19
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { browserOrNode } from '@aws-amplify/core';
|
|
6
|
-
|
|
7
|
-
const HTTP_PORT = '80';
|
|
8
|
-
const HTTPS_PORT = '443';
|
|
9
|
-
const DEFAULT_PORT = RegExp(':(' + HTTP_PORT + '|' + HTTPS_PORT + ')$');
|
|
10
|
-
|
|
11
|
-
const a = browserOrNode().isBrowser ? document.createElement('a') : null;
|
|
12
|
-
const cache = {};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Parses the given url and returns an object mimicing a `Location` object.
|
|
16
|
-
* @param {string} url The url to parse.
|
|
17
|
-
* @return {!Object} An object with the same properties as a `Location`.
|
|
18
|
-
*/
|
|
19
|
-
export function parseUrl(u) {
|
|
20
|
-
let url = u;
|
|
21
|
-
// All falsy values (as well as ".") should map to the current URL.
|
|
22
|
-
url = !url || url === '.' ? location.href : url;
|
|
23
|
-
|
|
24
|
-
if (cache[url]) return cache[url];
|
|
25
|
-
|
|
26
|
-
a.href = url;
|
|
27
|
-
|
|
28
|
-
// When parsing file relative paths (e.g. `../index.html`), IE will correctly
|
|
29
|
-
// resolve the `href` property but will keep the `..` in the `path` property.
|
|
30
|
-
// It will also not include the `host` or `hostname` properties. Furthermore,
|
|
31
|
-
// IE will sometimes return no protocol or just a colon, especially for things
|
|
32
|
-
// like relative protocol URLs (e.g. "//google.com").
|
|
33
|
-
// To workaround all of these issues, we reparse with the full URL from the
|
|
34
|
-
// `href` property.
|
|
35
|
-
if (url.charAt(0) === '.' || url.charAt(0) === '/') return parseUrl(a.href);
|
|
36
|
-
|
|
37
|
-
// Don't include default ports.
|
|
38
|
-
let port = a.port === HTTP_PORT || a.port === HTTPS_PORT ? '' : a.port;
|
|
39
|
-
|
|
40
|
-
// PhantomJS sets the port to "0" when using the file: protocol.
|
|
41
|
-
port = port === '0' ? '' : port;
|
|
42
|
-
|
|
43
|
-
// Sometimes IE incorrectly includes a port for default ports
|
|
44
|
-
// (e.g. `:80` or `:443`) even when no port is specified in the URL.
|
|
45
|
-
// http://bit.ly/1rQNoMg
|
|
46
|
-
const host = a.host.replace(DEFAULT_PORT, '');
|
|
47
|
-
|
|
48
|
-
// Not all browser support `origin` so we have to build it.
|
|
49
|
-
const origin = a['origin'] ? a['origin'] : a.protocol + '//' + host;
|
|
50
|
-
|
|
51
|
-
// Sometimes IE doesn't include the leading slash for pathname.
|
|
52
|
-
// http://bit.ly/1rQNoMg
|
|
53
|
-
const pathname = a.pathname.charAt(0) === '/' ? a.pathname : '/' + a.pathname;
|
|
54
|
-
|
|
55
|
-
return (cache[url] = {
|
|
56
|
-
hash: a.hash,
|
|
57
|
-
host,
|
|
58
|
-
hostname: a.hostname,
|
|
59
|
-
href: a.href,
|
|
60
|
-
origin,
|
|
61
|
-
pathname,
|
|
62
|
-
port,
|
|
63
|
-
protocol: a.protocol,
|
|
64
|
-
search: a.search,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|