@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,50 +0,0 @@
|
|
|
1
|
-
import { PromiseHandlers } from '../Provider';
|
|
2
|
-
export type Event = {
|
|
3
|
-
eventId: string;
|
|
4
|
-
name: string;
|
|
5
|
-
attributes: string;
|
|
6
|
-
metrics: string;
|
|
7
|
-
session: object;
|
|
8
|
-
immediate: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type EventConfig = {
|
|
11
|
-
appId: string;
|
|
12
|
-
endpointId: string;
|
|
13
|
-
region: string;
|
|
14
|
-
resendLimit: number;
|
|
15
|
-
};
|
|
16
|
-
export type EventParams = {
|
|
17
|
-
event: Event;
|
|
18
|
-
timestamp: string;
|
|
19
|
-
config: EventConfig;
|
|
20
|
-
credentials: object;
|
|
21
|
-
resendLimit: number;
|
|
22
|
-
};
|
|
23
|
-
export type EventObject = {
|
|
24
|
-
params: EventParams;
|
|
25
|
-
handlers: PromiseHandlers;
|
|
26
|
-
};
|
|
27
|
-
export type EventMap = {
|
|
28
|
-
[key: string]: EventObject;
|
|
29
|
-
};
|
|
30
|
-
export type EventBuffer = Array<EventMap>;
|
|
31
|
-
export type EndpointBuffer = Array<EventObject>;
|
|
32
|
-
export type PutEventsResponse = {
|
|
33
|
-
EventsResponse: {
|
|
34
|
-
Results?: {
|
|
35
|
-
[endpointId: string]: {
|
|
36
|
-
EventsItemResponse?: {
|
|
37
|
-
[eventId: string]: {
|
|
38
|
-
StatusCode?: number;
|
|
39
|
-
Message?: string;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export type EndpointFailureData = {
|
|
47
|
-
err: any;
|
|
48
|
-
update_params: any;
|
|
49
|
-
endpointObject: EventObject;
|
|
50
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './AWSPinpointProvider';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var tslib_1 = require("tslib");
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
tslib_1.__exportStar(require("./AWSPinpointProvider"), exports);
|
package/lib/utils/AppUtils.d.ts
DELETED
package/lib/utils/AppUtils.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAppInForeground = void 0;
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
var isAppInForeground = function () {
|
|
7
|
-
return true;
|
|
8
|
-
};
|
|
9
|
-
exports.isAppInForeground = isAppInForeground;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isAppInForeground = void 0;
|
|
4
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
var react_native_1 = require("react-native");
|
|
7
|
-
var isAppInForeground = function () {
|
|
8
|
-
return react_native_1.AppState.currentState === 'active';
|
|
9
|
-
};
|
|
10
|
-
exports.isAppInForeground = isAppInForeground;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class MethodEmbed {
|
|
2
|
-
context: any;
|
|
3
|
-
methodName: any;
|
|
4
|
-
private _originalMethod;
|
|
5
|
-
private _bindedMethod;
|
|
6
|
-
static add(context: any, methodName: any, methodOverride: any): void;
|
|
7
|
-
static remove(context: any, methodName: any): void;
|
|
8
|
-
constructor(context: any, methodName: any);
|
|
9
|
-
set(methodOverride: any): void;
|
|
10
|
-
remove(): void;
|
|
11
|
-
}
|
package/lib/utils/MethodEmbed.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.MethodEmbed = void 0;
|
|
6
|
-
var tslib_1 = require("tslib");
|
|
7
|
-
var lists = [];
|
|
8
|
-
var MethodEmbed = /** @class */ (function () {
|
|
9
|
-
function MethodEmbed(context, methodName) {
|
|
10
|
-
this.context = context;
|
|
11
|
-
this.methodName = methodName;
|
|
12
|
-
this._originalMethod = context[methodName].bind(context);
|
|
13
|
-
}
|
|
14
|
-
MethodEmbed.add = function (context, methodName, methodOverride) {
|
|
15
|
-
getInstance(context, methodName).set(methodOverride);
|
|
16
|
-
};
|
|
17
|
-
MethodEmbed.remove = function (context, methodName) {
|
|
18
|
-
getInstance(context, methodName).remove();
|
|
19
|
-
};
|
|
20
|
-
MethodEmbed.prototype.set = function (methodOverride) {
|
|
21
|
-
var _this = this;
|
|
22
|
-
this.context[this.methodName] = function () {
|
|
23
|
-
var args = [];
|
|
24
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
25
|
-
args[_i] = arguments[_i];
|
|
26
|
-
}
|
|
27
|
-
return methodOverride(_this._originalMethod.apply(_this, tslib_1.__spreadArray([], tslib_1.__read(args), false)));
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
MethodEmbed.prototype.remove = function () {
|
|
31
|
-
this.context[this.methodName] = this._originalMethod;
|
|
32
|
-
};
|
|
33
|
-
return MethodEmbed;
|
|
34
|
-
}());
|
|
35
|
-
exports.MethodEmbed = MethodEmbed;
|
|
36
|
-
function getInstance(context, methodName) {
|
|
37
|
-
var instance = lists.filter(function (h) { return h.context === context && h.methodName === methodName; })[0];
|
|
38
|
-
if (!instance) {
|
|
39
|
-
instance = new MethodEmbed(context, methodName);
|
|
40
|
-
lists.push(instance);
|
|
41
|
-
}
|
|
42
|
-
return instance;
|
|
43
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Gets the closest parent element that matches the passed selector.
|
|
6
|
-
* @param {Element} element The element whose parents to check.
|
|
7
|
-
* @param {string} selector The CSS selector to match against.
|
|
8
|
-
* @param {boolean=} shouldCheckSelf True if the selector should test against
|
|
9
|
-
* the passed element itself.
|
|
10
|
-
* @return {Element|undefined} The matching element or undefined.
|
|
11
|
-
*/
|
|
12
|
-
export declare function closest(element: any, selector: any, shouldCheckSelf?: boolean): any;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.closest = void 0;
|
|
7
|
-
var matches_1 = require("./matches");
|
|
8
|
-
var parents_1 = require("./parents");
|
|
9
|
-
/**
|
|
10
|
-
* Gets the closest parent element that matches the passed selector.
|
|
11
|
-
* @param {Element} element The element whose parents to check.
|
|
12
|
-
* @param {string} selector The CSS selector to match against.
|
|
13
|
-
* @param {boolean=} shouldCheckSelf True if the selector should test against
|
|
14
|
-
* the passed element itself.
|
|
15
|
-
* @return {Element|undefined} The matching element or undefined.
|
|
16
|
-
*/
|
|
17
|
-
function closest(element, selector, shouldCheckSelf) {
|
|
18
|
-
if (shouldCheckSelf === void 0) { shouldCheckSelf = false; }
|
|
19
|
-
if (!(element && element.nodeType === 1 && selector))
|
|
20
|
-
return;
|
|
21
|
-
var parentElements = (shouldCheckSelf ? [element] : []).concat((0, parents_1.parents)(element));
|
|
22
|
-
for (var i = 0, parent_1; (parent_1 = parentElements[i]); i++) {
|
|
23
|
-
if ((0, matches_1.matches)(parent_1, selector))
|
|
24
|
-
return parent_1;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.closest = closest;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Delegates the handling of events for an element matching a selector to an
|
|
6
|
-
* ancestor of the matching element.
|
|
7
|
-
* @param {!Node} ancestor The ancestor element to add the listener to.
|
|
8
|
-
* @param {string} eventType The event type to listen to.
|
|
9
|
-
* @param {string} selector A CSS selector to match against child elements.
|
|
10
|
-
* @param {!Function} callback A function to run any time the event happens.
|
|
11
|
-
* @param {Object=} opts A configuration options object. The available options:
|
|
12
|
-
* - useCapture<boolean>: If true, bind to the event capture phase.
|
|
13
|
-
* - deep<boolean>: If true, delegate into shadow trees.
|
|
14
|
-
* @return {Object} The delegate object. It contains a destroy method.
|
|
15
|
-
*/
|
|
16
|
-
export declare function delegate(ancestor: any, eventType: any, selector: any, callback: any, opts?: {}): {
|
|
17
|
-
destroy: () => void;
|
|
18
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.delegate = void 0;
|
|
7
|
-
var closest_1 = require("./closest");
|
|
8
|
-
var matches_1 = require("./matches");
|
|
9
|
-
/**
|
|
10
|
-
* Delegates the handling of events for an element matching a selector to an
|
|
11
|
-
* ancestor of the matching element.
|
|
12
|
-
* @param {!Node} ancestor The ancestor element to add the listener to.
|
|
13
|
-
* @param {string} eventType The event type to listen to.
|
|
14
|
-
* @param {string} selector A CSS selector to match against child elements.
|
|
15
|
-
* @param {!Function} callback A function to run any time the event happens.
|
|
16
|
-
* @param {Object=} opts A configuration options object. The available options:
|
|
17
|
-
* - useCapture<boolean>: If true, bind to the event capture phase.
|
|
18
|
-
* - deep<boolean>: If true, delegate into shadow trees.
|
|
19
|
-
* @return {Object} The delegate object. It contains a destroy method.
|
|
20
|
-
*/
|
|
21
|
-
function delegate(ancestor, eventType, selector, callback, opts) {
|
|
22
|
-
if (opts === void 0) { opts = {}; }
|
|
23
|
-
// Defines the event listener.
|
|
24
|
-
var listener = function (event) {
|
|
25
|
-
var delegateTarget;
|
|
26
|
-
// If opts.composed is true and the event originated from inside a Shadow
|
|
27
|
-
// tree, check the composed path nodes.
|
|
28
|
-
if (opts['composed'] && typeof event['composedPath'] === 'function') {
|
|
29
|
-
var composedPath = event.composedPath();
|
|
30
|
-
for (var i = 0, node = void 0; (node = composedPath[i]); i++) {
|
|
31
|
-
if (node.nodeType === 1 && (0, matches_1.matches)(node, selector)) {
|
|
32
|
-
delegateTarget = node;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
// Otherwise check the parents.
|
|
38
|
-
delegateTarget = (0, closest_1.closest)(event.target, selector, true);
|
|
39
|
-
}
|
|
40
|
-
if (delegateTarget) {
|
|
41
|
-
callback.call(delegateTarget, event, delegateTarget);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
ancestor.addEventListener(eventType, listener, opts['useCapture']);
|
|
45
|
-
return {
|
|
46
|
-
destroy: function () {
|
|
47
|
-
ancestor.removeEventListener(eventType, listener, opts['useCapture']);
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
exports.delegate = delegate;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Dispatches an event on the passed element.
|
|
6
|
-
* @param {!Element} element The DOM element to dispatch the event on.
|
|
7
|
-
* @param {string} eventType The type of event to dispatch.
|
|
8
|
-
* @param {Object|string=} eventName A string name of the event constructor
|
|
9
|
-
* to use. Defaults to 'Event' if nothing is passed or 'CustomEvent' if
|
|
10
|
-
* a value is set on `initDict.detail`. If eventName is given an object
|
|
11
|
-
* it is assumed to be initDict and thus reassigned.
|
|
12
|
-
* @param {Object=} initDict The initialization attributes for the
|
|
13
|
-
* event. A `detail` property can be used here to pass custom data.
|
|
14
|
-
* @return {boolean} The return value of `element.dispatchEvent`, which will
|
|
15
|
-
* be false if any of the event listeners called `preventDefault`.
|
|
16
|
-
*/
|
|
17
|
-
export declare function dispatch(element: any, eventType: any, evtName?: string, init_dict?: {}): any;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.dispatch = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Dispatches an event on the passed element.
|
|
9
|
-
* @param {!Element} element The DOM element to dispatch the event on.
|
|
10
|
-
* @param {string} eventType The type of event to dispatch.
|
|
11
|
-
* @param {Object|string=} eventName A string name of the event constructor
|
|
12
|
-
* to use. Defaults to 'Event' if nothing is passed or 'CustomEvent' if
|
|
13
|
-
* a value is set on `initDict.detail`. If eventName is given an object
|
|
14
|
-
* it is assumed to be initDict and thus reassigned.
|
|
15
|
-
* @param {Object=} initDict The initialization attributes for the
|
|
16
|
-
* event. A `detail` property can be used here to pass custom data.
|
|
17
|
-
* @return {boolean} The return value of `element.dispatchEvent`, which will
|
|
18
|
-
* be false if any of the event listeners called `preventDefault`.
|
|
19
|
-
*/
|
|
20
|
-
function dispatch(element, eventType, evtName, init_dict) {
|
|
21
|
-
if (evtName === void 0) { evtName = 'Event'; }
|
|
22
|
-
if (init_dict === void 0) { init_dict = {}; }
|
|
23
|
-
var event;
|
|
24
|
-
var isCustom;
|
|
25
|
-
var initDict = init_dict;
|
|
26
|
-
var eventName = evtName;
|
|
27
|
-
// eventName is optional
|
|
28
|
-
if (typeof eventName === 'object') {
|
|
29
|
-
initDict = eventName;
|
|
30
|
-
eventName = 'Event';
|
|
31
|
-
}
|
|
32
|
-
initDict['bubbles'] = initDict['bubbles'] || false;
|
|
33
|
-
initDict['cancelable'] = initDict['cancelable'] || false;
|
|
34
|
-
initDict['composed'] = initDict['composed'] || false;
|
|
35
|
-
// If a detail property is passed, this is a custom event.
|
|
36
|
-
if ('detail' in initDict)
|
|
37
|
-
isCustom = true;
|
|
38
|
-
eventName = isCustom ? 'CustomEvent' : eventName;
|
|
39
|
-
// Tries to create the event using constructors, if that doesn't work,
|
|
40
|
-
// fallback to `document.createEvent()`.
|
|
41
|
-
try {
|
|
42
|
-
event = new window[eventName](eventType, initDict);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
event = document.createEvent(eventName);
|
|
46
|
-
var initMethod = 'init' + (isCustom ? 'Custom' : '') + 'Event';
|
|
47
|
-
event[initMethod](eventType, initDict['bubbles'], initDict['cancelable'], initDict['detail']);
|
|
48
|
-
}
|
|
49
|
-
return element.dispatchEvent(event);
|
|
50
|
-
}
|
|
51
|
-
exports.dispatch = dispatch;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Gets all attributes of an element as a plain JavaScriot object.
|
|
6
|
-
* @param {Element} element The element whose attributes to get.
|
|
7
|
-
* @return {!Object} An object whose keys are the attribute keys and whose
|
|
8
|
-
* values are the attribute values. If no attributes exist, an empty
|
|
9
|
-
* object is returned.
|
|
10
|
-
*/
|
|
11
|
-
export declare function getAttributes(element: any): {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getAttributes = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Gets all attributes of an element as a plain JavaScriot object.
|
|
9
|
-
* @param {Element} element The element whose attributes to get.
|
|
10
|
-
* @return {!Object} An object whose keys are the attribute keys and whose
|
|
11
|
-
* values are the attribute values. If no attributes exist, an empty
|
|
12
|
-
* object is returned.
|
|
13
|
-
*/
|
|
14
|
-
function getAttributes(element) {
|
|
15
|
-
var attrs = {};
|
|
16
|
-
// Validate input.
|
|
17
|
-
if (!(element && element.nodeType === 1))
|
|
18
|
-
return attrs;
|
|
19
|
-
// Return an empty object if there are no attributes.
|
|
20
|
-
var map = element.attributes;
|
|
21
|
-
if (map.length === 0)
|
|
22
|
-
return {};
|
|
23
|
-
for (var i = 0, attr = void 0; (attr = map[i]); i++) {
|
|
24
|
-
attrs[attr.name] = attr.value;
|
|
25
|
-
}
|
|
26
|
-
return attrs;
|
|
27
|
-
}
|
|
28
|
-
exports.getAttributes = getAttributes;
|
|
@@ -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,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseUrl = exports.parents = exports.matches = exports.getAttributes = exports.dispatch = exports.delegate = exports.closest = void 0;
|
|
4
|
-
var closest_1 = require("./closest");
|
|
5
|
-
Object.defineProperty(exports, "closest", { enumerable: true, get: function () { return closest_1.closest; } });
|
|
6
|
-
var delegate_1 = require("./delegate");
|
|
7
|
-
Object.defineProperty(exports, "delegate", { enumerable: true, get: function () { return delegate_1.delegate; } });
|
|
8
|
-
var dispatch_1 = require("./dispatch");
|
|
9
|
-
Object.defineProperty(exports, "dispatch", { enumerable: true, get: function () { return dispatch_1.dispatch; } });
|
|
10
|
-
var get_attributes_1 = require("./get-attributes");
|
|
11
|
-
Object.defineProperty(exports, "getAttributes", { enumerable: true, get: function () { return get_attributes_1.getAttributes; } });
|
|
12
|
-
var matches_1 = require("./matches");
|
|
13
|
-
Object.defineProperty(exports, "matches", { enumerable: true, get: function () { return matches_1.matches; } });
|
|
14
|
-
var parents_1 = require("./parents");
|
|
15
|
-
Object.defineProperty(exports, "parents", { enumerable: true, get: function () { return parents_1.parents; } });
|
|
16
|
-
var parse_url_1 = require("./parse-url");
|
|
17
|
-
Object.defineProperty(exports, "parseUrl", { enumerable: true, get: function () { return parse_url_1.parseUrl; } });
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Tests if a DOM elements matches any of the test DOM elements or selectors.
|
|
6
|
-
* @param {Element} element The DOM element to test.
|
|
7
|
-
* @param {Element|string|Array<Element|string>} test A DOM element, a CSS
|
|
8
|
-
* selector, or an array of DOM elements or CSS selectors to match against.
|
|
9
|
-
* @return {boolean} True of any part of the test matches.
|
|
10
|
-
*/
|
|
11
|
-
export declare function matches(element: any, test: any): any;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.matches = void 0;
|
|
7
|
-
var core_1 = require("@aws-amplify/core");
|
|
8
|
-
var proto = (0, core_1.browserOrNode)().isBrowser && window['Element']
|
|
9
|
-
? window['Element'].prototype
|
|
10
|
-
: null;
|
|
11
|
-
var nativeMatches = proto
|
|
12
|
-
? proto.matches ||
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
proto.matchesSelector ||
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
proto.webkitMatchesSelector ||
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
proto.mozMatchesSelector ||
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
proto.msMatchesSelector ||
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
proto.oMatchesSelector
|
|
23
|
-
: null;
|
|
24
|
-
/**
|
|
25
|
-
* Tests if a DOM elements matches any of the test DOM elements or selectors.
|
|
26
|
-
* @param {Element} element The DOM element to test.
|
|
27
|
-
* @param {Element|string|Array<Element|string>} test A DOM element, a CSS
|
|
28
|
-
* selector, or an array of DOM elements or CSS selectors to match against.
|
|
29
|
-
* @return {boolean} True of any part of the test matches.
|
|
30
|
-
*/
|
|
31
|
-
function matches(element, test) {
|
|
32
|
-
// Validate input.
|
|
33
|
-
if (element && element.nodeType === 1 && test) {
|
|
34
|
-
// if test is a string or DOM element test it.
|
|
35
|
-
if (typeof test === 'string' || test.nodeType === 1) {
|
|
36
|
-
return (element === test || matchesSelector(element, /** @type {string} */ test));
|
|
37
|
-
}
|
|
38
|
-
else if ('length' in test) {
|
|
39
|
-
// if it has a length property iterate over the items
|
|
40
|
-
// and return true if any match.
|
|
41
|
-
for (var i = 0, item = void 0; (item = test[i]); i++) {
|
|
42
|
-
if (element === item || matchesSelector(element, item))
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Still here? Return false
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
exports.matches = matches;
|
|
51
|
-
/**
|
|
52
|
-
* Tests whether a DOM element matches a selector. This polyfills the native
|
|
53
|
-
* Element.prototype.matches method across browsers.
|
|
54
|
-
* @param {!Element} element The DOM element to test.
|
|
55
|
-
* @param {string} selector The CSS selector to test element against.
|
|
56
|
-
* @return {boolean} True if the selector matches.
|
|
57
|
-
*/
|
|
58
|
-
function matchesSelector(element, selector) {
|
|
59
|
-
if (typeof selector !== 'string')
|
|
60
|
-
return false;
|
|
61
|
-
if (nativeMatches)
|
|
62
|
-
return nativeMatches.call(element, selector);
|
|
63
|
-
var nodes = element.parentNode.querySelectorAll(selector);
|
|
64
|
-
for (var i = 0, node = void 0; (node = nodes[i]); i++) {
|
|
65
|
-
if (node === element)
|
|
66
|
-
return true;
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Returns an array of a DOM element's parent elements.
|
|
6
|
-
* @param {!Element} element The DOM element whose parents to get.
|
|
7
|
-
* @return {!Array} An array of all parent elemets, or an empty array if no
|
|
8
|
-
* parent elements are found.
|
|
9
|
-
*/
|
|
10
|
-
export declare function parents(ele: any): any[];
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parents = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Returns an array of a DOM element's parent elements.
|
|
9
|
-
* @param {!Element} element The DOM element whose parents to get.
|
|
10
|
-
* @return {!Array} An array of all parent elemets, or an empty array if no
|
|
11
|
-
* parent elements are found.
|
|
12
|
-
*/
|
|
13
|
-
function parents(ele) {
|
|
14
|
-
var list = [];
|
|
15
|
-
var element = ele;
|
|
16
|
-
while (element && element.parentNode && element.parentNode.nodeType === 1) {
|
|
17
|
-
element = /** @type {!Element} */ element.parentNode;
|
|
18
|
-
list.push(element);
|
|
19
|
-
}
|
|
20
|
-
return list;
|
|
21
|
-
}
|
|
22
|
-
exports.parents = parents;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Parses the given url and returns an object mimicing a `Location` object.
|
|
6
|
-
* @param {string} url The url to parse.
|
|
7
|
-
* @return {!Object} An object with the same properties as a `Location`.
|
|
8
|
-
*/
|
|
9
|
-
export declare function parseUrl(u: any): any;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2017, Philip Walton <philip@philipwalton.com>
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parseUrl = void 0;
|
|
7
|
-
var core_1 = require("@aws-amplify/core");
|
|
8
|
-
var HTTP_PORT = '80';
|
|
9
|
-
var HTTPS_PORT = '443';
|
|
10
|
-
var DEFAULT_PORT = RegExp(':(' + HTTP_PORT + '|' + HTTPS_PORT + ')$');
|
|
11
|
-
var a = (0, core_1.browserOrNode)().isBrowser ? document.createElement('a') : null;
|
|
12
|
-
var cache = {};
|
|
13
|
-
/**
|
|
14
|
-
* Parses the given url and returns an object mimicing a `Location` object.
|
|
15
|
-
* @param {string} url The url to parse.
|
|
16
|
-
* @return {!Object} An object with the same properties as a `Location`.
|
|
17
|
-
*/
|
|
18
|
-
function parseUrl(u) {
|
|
19
|
-
var url = u;
|
|
20
|
-
// All falsy values (as well as ".") should map to the current URL.
|
|
21
|
-
url = !url || url === '.' ? location.href : url;
|
|
22
|
-
if (cache[url])
|
|
23
|
-
return cache[url];
|
|
24
|
-
a.href = url;
|
|
25
|
-
// When parsing file relative paths (e.g. `../index.html`), IE will correctly
|
|
26
|
-
// resolve the `href` property but will keep the `..` in the `path` property.
|
|
27
|
-
// It will also not include the `host` or `hostname` properties. Furthermore,
|
|
28
|
-
// IE will sometimes return no protocol or just a colon, especially for things
|
|
29
|
-
// like relative protocol URLs (e.g. "//google.com").
|
|
30
|
-
// To workaround all of these issues, we reparse with the full URL from the
|
|
31
|
-
// `href` property.
|
|
32
|
-
if (url.charAt(0) === '.' || url.charAt(0) === '/')
|
|
33
|
-
return parseUrl(a.href);
|
|
34
|
-
// Don't include default ports.
|
|
35
|
-
var port = a.port === HTTP_PORT || a.port === HTTPS_PORT ? '' : a.port;
|
|
36
|
-
// PhantomJS sets the port to "0" when using the file: protocol.
|
|
37
|
-
port = port === '0' ? '' : port;
|
|
38
|
-
// Sometimes IE incorrectly includes a port for default ports
|
|
39
|
-
// (e.g. `:80` or `:443`) even when no port is specified in the URL.
|
|
40
|
-
// http://bit.ly/1rQNoMg
|
|
41
|
-
var host = a.host.replace(DEFAULT_PORT, '');
|
|
42
|
-
// Not all browser support `origin` so we have to build it.
|
|
43
|
-
var origin = a['origin'] ? a['origin'] : a.protocol + '//' + host;
|
|
44
|
-
// Sometimes IE doesn't include the leading slash for pathname.
|
|
45
|
-
// http://bit.ly/1rQNoMg
|
|
46
|
-
var pathname = a.pathname.charAt(0) === '/' ? a.pathname : '/' + a.pathname;
|
|
47
|
-
return (cache[url] = {
|
|
48
|
-
hash: a.hash,
|
|
49
|
-
host: host,
|
|
50
|
-
hostname: a.hostname,
|
|
51
|
-
href: a.href,
|
|
52
|
-
origin: origin,
|
|
53
|
-
pathname: pathname,
|
|
54
|
-
port: port,
|
|
55
|
-
protocol: a.protocol,
|
|
56
|
-
search: a.search,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
exports.parseUrl = parseUrl;
|