@arcgis/common-components 1.0.0-beta.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.
- package/LICENSE.md +13 -0
- package/README.md +17 -0
- package/dist/arcgis-common-components/arcgis-common-components.esm.js +1 -0
- package/dist/arcgis-common-components/index.esm.js +0 -0
- package/dist/arcgis-common-components/p-9fc4e265.entry.js +1 -0
- package/dist/arcgis-common-components/p-adc54f17.entry.js +1 -0
- package/dist/arcgis-common-components/p-b0c98bba.js +2 -0
- package/dist/arcgis-common-components/p-e8b62824.js +1 -0
- package/dist/cjs/arcgis-api-key.cjs.entry.js +51 -0
- package/dist/cjs/arcgis-common-components.cjs.js +23 -0
- package/dist/cjs/arcgis-identity.cjs.entry.js +139 -0
- package/dist/cjs/index-33f2dbd2.js +65 -0
- package/dist/cjs/index-e8c59179.js +858 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +22 -0
- package/dist/components/arcgis-api-key.d.ts +11 -0
- package/dist/components/arcgis-api-key.js +67 -0
- package/dist/components/arcgis-identity.d.ts +11 -0
- package/dist/components/arcgis-identity.js +165 -0
- package/dist/components/index.d.ts +32 -0
- package/dist/components/index.js +3 -0
- package/dist/components/index2.js +40 -0
- package/dist/esm/arcgis-api-key.entry.js +47 -0
- package/dist/esm/arcgis-common-components.js +18 -0
- package/dist/esm/arcgis-identity.entry.js +135 -0
- package/dist/esm/index-1f7e8e45.js +831 -0
- package/dist/esm/index-386f07e9.js +40 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +18 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/loader/cdn.js +3 -0
- package/dist/loader/index.cjs.js +3 -0
- package/dist/loader/index.d.ts +21 -0
- package/dist/loader/index.es2017.js +3 -0
- package/dist/loader/index.js +4 -0
- package/dist/loader/package.json +11 -0
- package/dist/types/components/arcgis-api-key/arcgis-api-key.d.ts +9 -0
- package/dist/types/components/arcgis-identity/arcgis-identity.d.ts +32 -0
- package/dist/types/components.d.ts +84 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1637 -0
- package/package.json +88 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-e8c59179.js');
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
Stencil Client Patch Esm v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchEsm = () => {
|
|
11
|
+
return index.promiseResolve();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const defineCustomElements = (win, options) => {
|
|
15
|
+
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
|
+
return patchEsm().then(() => {
|
|
17
|
+
return index.bootstrapLazy([["arcgis-api-key.cjs",[[0,"arcgis-api-key",{"apiKey":[1,"api-key"]}]]],["arcgis-identity.cjs",[[0,"arcgis-identity",{"identity":[1040],"appId":[1,"app-id"],"credential":[1040],"expiration":[1026],"locale":[1],"usePopup":[4,"use-popup"],"popupCallbackUrl":[1,"popup-callback-url"],"portalUrl":[1,"portal-url"],"preserveUrlHash":[4,"preserve-url-hash"],"signIn":[64],"signOut":[64]}]]]], options);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.setNonce = index.setNonce;
|
|
22
|
+
exports.defineCustomElements = defineCustomElements;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ArcgisApiKey extends Components.ArcgisApiKey, HTMLElement {}
|
|
4
|
+
export const ArcgisApiKey: {
|
|
5
|
+
prototype: ArcgisApiKey;
|
|
6
|
+
new (): ArcgisApiKey;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
|
|
2
|
+
import { i as importConfig } from './index2.js';
|
|
3
|
+
|
|
4
|
+
const arcgisApiKeyCss = ":host{display:none}arcgis-api-key{display:none}";
|
|
5
|
+
|
|
6
|
+
const ArcgisApiKey$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.apiKeyReady = createEvent(this, "apiKeyReady", 7);
|
|
11
|
+
this.apiKey = undefined;
|
|
12
|
+
}
|
|
13
|
+
//--------------------------------------------------------------------------
|
|
14
|
+
//
|
|
15
|
+
// Watchers
|
|
16
|
+
//
|
|
17
|
+
//--------------------------------------------------------------------------
|
|
18
|
+
apiKeyWatcher(value) {
|
|
19
|
+
this._setApiKey(value);
|
|
20
|
+
}
|
|
21
|
+
//--------------------------------------------------------------------------
|
|
22
|
+
//
|
|
23
|
+
// Lifecycle
|
|
24
|
+
//
|
|
25
|
+
//--------------------------------------------------------------------------
|
|
26
|
+
async connectedCallback() {
|
|
27
|
+
if (this.apiKey) {
|
|
28
|
+
await this._setApiKey(this.apiKey);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//--------------------------------------------------------------------------
|
|
32
|
+
//
|
|
33
|
+
// Private Methods
|
|
34
|
+
//
|
|
35
|
+
//--------------------------------------------------------------------------
|
|
36
|
+
async _setApiKey(value) {
|
|
37
|
+
const config = await importConfig();
|
|
38
|
+
config.apiKey = value;
|
|
39
|
+
this.apiKeyReady.emit(true);
|
|
40
|
+
}
|
|
41
|
+
get el() { return this; }
|
|
42
|
+
static get watchers() { return {
|
|
43
|
+
"apiKey": ["apiKeyWatcher"]
|
|
44
|
+
}; }
|
|
45
|
+
static get style() { return arcgisApiKeyCss; }
|
|
46
|
+
}, [0, "arcgis-api-key", {
|
|
47
|
+
"apiKey": [1, "api-key"]
|
|
48
|
+
}]);
|
|
49
|
+
function defineCustomElement$1() {
|
|
50
|
+
if (typeof customElements === "undefined") {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const components = ["arcgis-api-key"];
|
|
54
|
+
components.forEach(tagName => { switch (tagName) {
|
|
55
|
+
case "arcgis-api-key":
|
|
56
|
+
if (!customElements.get(tagName)) {
|
|
57
|
+
customElements.define(tagName, ArcgisApiKey$1);
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
} });
|
|
61
|
+
}
|
|
62
|
+
defineCustomElement$1();
|
|
63
|
+
|
|
64
|
+
const ArcgisApiKey = ArcgisApiKey$1;
|
|
65
|
+
const defineCustomElement = defineCustomElement$1;
|
|
66
|
+
|
|
67
|
+
export { ArcgisApiKey, defineCustomElement };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Components, JSX } from "../types/components";
|
|
2
|
+
|
|
3
|
+
interface ArcgisIdentity extends Components.ArcgisIdentity, HTMLElement {}
|
|
4
|
+
export const ArcgisIdentity: {
|
|
5
|
+
prototype: ArcgisIdentity;
|
|
6
|
+
new (): ArcgisIdentity;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Used to define this component and all nested components recursively.
|
|
10
|
+
*/
|
|
11
|
+
export const defineCustomElement: () => void;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent } from '@stencil/core/internal/client';
|
|
2
|
+
import { a as importCoreReactiveUtils, n as newIdentityOAuthInfo, b as importIdentityIdentityManager } from './index2.js';
|
|
3
|
+
|
|
4
|
+
const arcgisIdentityCss = ":host{display:none}arcgis-identity{display:none}";
|
|
5
|
+
|
|
6
|
+
const ArcgisIdentity$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.__registerHost();
|
|
10
|
+
this.identityReady = createEvent(this, "identityReady", 7);
|
|
11
|
+
this.credentialCreate = createEvent(this, "credentialCreate", 7);
|
|
12
|
+
this.dialogCreate = createEvent(this, "dialogCreate", 7);
|
|
13
|
+
this.identity = undefined;
|
|
14
|
+
this.appId = undefined;
|
|
15
|
+
this.credential = undefined;
|
|
16
|
+
this.expiration = undefined;
|
|
17
|
+
this.locale = undefined;
|
|
18
|
+
this.usePopup = false;
|
|
19
|
+
this.popupCallbackUrl = undefined;
|
|
20
|
+
this.portalUrl = undefined;
|
|
21
|
+
this.preserveUrlHash = false;
|
|
22
|
+
}
|
|
23
|
+
//--------------------------------------------------------------------------
|
|
24
|
+
//
|
|
25
|
+
// Watchers
|
|
26
|
+
//
|
|
27
|
+
//--------------------------------------------------------------------------
|
|
28
|
+
appIdWatcher(value, oldValue) {
|
|
29
|
+
if (oldValue !== value) {
|
|
30
|
+
this._registerOAuth();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//--------------------------------------------------------------------------
|
|
34
|
+
//
|
|
35
|
+
// Methods
|
|
36
|
+
//
|
|
37
|
+
//--------------------------------------------------------------------------
|
|
38
|
+
async signIn() {
|
|
39
|
+
if (!this.credential) {
|
|
40
|
+
try {
|
|
41
|
+
this.credential = await this._checkCurrentStatus();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.credential = await this._fetchCredential();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return this.credential;
|
|
48
|
+
}
|
|
49
|
+
async signOut() {
|
|
50
|
+
if (!this.credential) {
|
|
51
|
+
try {
|
|
52
|
+
this.identity.destroyCredentials();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.credential = undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.credential = undefined;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
//--------------------------------------------------------------------------
|
|
62
|
+
//
|
|
63
|
+
// Lifecycle
|
|
64
|
+
//
|
|
65
|
+
//--------------------------------------------------------------------------
|
|
66
|
+
async connectedCallback() {
|
|
67
|
+
if (this.appId) {
|
|
68
|
+
await this._registerOAuth();
|
|
69
|
+
}
|
|
70
|
+
this._proxyEvents();
|
|
71
|
+
await this._addWatchers();
|
|
72
|
+
this.identityReady.emit({ identity: this.identity, ready: true });
|
|
73
|
+
}
|
|
74
|
+
//--------------------------------------------------------------------------
|
|
75
|
+
//
|
|
76
|
+
// Private Methods
|
|
77
|
+
//
|
|
78
|
+
//--------------------------------------------------------------------------
|
|
79
|
+
async _addWatchers() {
|
|
80
|
+
const { watch } = await importCoreReactiveUtils();
|
|
81
|
+
watch(() => this._info.expiration, (value) => (this.expiration = value), {
|
|
82
|
+
initial: true
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
_checkCurrentStatus() {
|
|
86
|
+
return this.identity.checkSignInStatus(`${this._info.portalUrl}/sharing`);
|
|
87
|
+
}
|
|
88
|
+
async _createOAuthInfo() {
|
|
89
|
+
const params = {};
|
|
90
|
+
if (this.appId !== undefined) {
|
|
91
|
+
params.appId = this.appId;
|
|
92
|
+
}
|
|
93
|
+
if (this.locale !== undefined) {
|
|
94
|
+
params.locale = this.locale;
|
|
95
|
+
}
|
|
96
|
+
if (this.popupCallbackUrl !== undefined) {
|
|
97
|
+
params.popupCallbackUrl = this.popupCallbackUrl;
|
|
98
|
+
}
|
|
99
|
+
if (this.preserveUrlHash !== undefined) {
|
|
100
|
+
params.preserveUrlHash = this.preserveUrlHash;
|
|
101
|
+
}
|
|
102
|
+
if (this.usePopup !== undefined) {
|
|
103
|
+
params.popup = this.usePopup;
|
|
104
|
+
}
|
|
105
|
+
if (this.portalUrl !== undefined) {
|
|
106
|
+
params.portalUrl = this.portalUrl;
|
|
107
|
+
}
|
|
108
|
+
const info = await newIdentityOAuthInfo(params);
|
|
109
|
+
this._info = info;
|
|
110
|
+
return info;
|
|
111
|
+
}
|
|
112
|
+
async _fetchCredential() {
|
|
113
|
+
const credential = await this.identity.getCredential(`${this._info?.portalUrl}/sharing`, {
|
|
114
|
+
error: null,
|
|
115
|
+
oAuthPopupConfirmation: false,
|
|
116
|
+
token: null
|
|
117
|
+
});
|
|
118
|
+
return credential;
|
|
119
|
+
}
|
|
120
|
+
async _registerOAuth() {
|
|
121
|
+
this.identity = await importIdentityIdentityManager();
|
|
122
|
+
const info = await this._createOAuthInfo();
|
|
123
|
+
this.identity.registerOAuthInfos([info]);
|
|
124
|
+
}
|
|
125
|
+
_proxyEvents() {
|
|
126
|
+
this.identity.on("credential-create", (e) => this.credentialCreate.emit(e));
|
|
127
|
+
this.identity.on("dialog-create", (e) => this.dialogCreate.emit(e));
|
|
128
|
+
}
|
|
129
|
+
get el() { return this; }
|
|
130
|
+
static get watchers() { return {
|
|
131
|
+
"appId": ["appIdWatcher"]
|
|
132
|
+
}; }
|
|
133
|
+
static get style() { return arcgisIdentityCss; }
|
|
134
|
+
}, [0, "arcgis-identity", {
|
|
135
|
+
"identity": [1040],
|
|
136
|
+
"appId": [1, "app-id"],
|
|
137
|
+
"credential": [1040],
|
|
138
|
+
"expiration": [1026],
|
|
139
|
+
"locale": [1],
|
|
140
|
+
"usePopup": [4, "use-popup"],
|
|
141
|
+
"popupCallbackUrl": [1, "popup-callback-url"],
|
|
142
|
+
"portalUrl": [1, "portal-url"],
|
|
143
|
+
"preserveUrlHash": [4, "preserve-url-hash"],
|
|
144
|
+
"signIn": [64],
|
|
145
|
+
"signOut": [64]
|
|
146
|
+
}]);
|
|
147
|
+
function defineCustomElement$1() {
|
|
148
|
+
if (typeof customElements === "undefined") {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const components = ["arcgis-identity"];
|
|
152
|
+
components.forEach(tagName => { switch (tagName) {
|
|
153
|
+
case "arcgis-identity":
|
|
154
|
+
if (!customElements.get(tagName)) {
|
|
155
|
+
customElements.define(tagName, ArcgisIdentity$1);
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
} });
|
|
159
|
+
}
|
|
160
|
+
defineCustomElement$1();
|
|
161
|
+
|
|
162
|
+
const ArcgisIdentity = ArcgisIdentity$1;
|
|
163
|
+
const defineCustomElement = defineCustomElement$1;
|
|
164
|
+
|
|
165
|
+
export { ArcgisIdentity, defineCustomElement };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* ArcgisCommonComponents custom elements */
|
|
2
|
+
export { ArcgisApiKey as ArcgisApiKey } from '../types/components/arcgis-api-key/arcgis-api-key';
|
|
3
|
+
export { ArcgisIdentity as ArcgisIdentity } from '../types/components/arcgis-identity/arcgis-identity';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used to manually set the base path where assets can be found.
|
|
7
|
+
* If the script is used as "module", it's recommended to use "import.meta.url",
|
|
8
|
+
* such as "setAssetPath(import.meta.url)". Other options include
|
|
9
|
+
* "setAssetPath(document.currentScript.src)", or using a bundler's replace plugin to
|
|
10
|
+
* dynamically set the path at build time, such as "setAssetPath(process.env.ASSET_PATH)".
|
|
11
|
+
* But do note that this configuration depends on how your script is bundled, or lack of
|
|
12
|
+
* bundling, and where your assets can be loaded from. Additionally custom bundling
|
|
13
|
+
* will have to ensure the static assets are copied to its build directory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const setAssetPath: (path: string) => void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Used to specify a nonce value that corresponds with an application's CSP.
|
|
19
|
+
* When set, the nonce will be added to all dynamically created script and style tags at runtime.
|
|
20
|
+
* Alternatively, the nonce value can be set on a meta tag in the DOM head
|
|
21
|
+
* (<meta name="csp-nonce" content="{ nonce value here }" />) which
|
|
22
|
+
* will result in the same behavior.
|
|
23
|
+
*/
|
|
24
|
+
export declare const setNonce: (nonce: string) => void
|
|
25
|
+
|
|
26
|
+
export interface SetPlatformOptions {
|
|
27
|
+
raf?: (c: FrameRequestCallback) => number;
|
|
28
|
+
ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
29
|
+
rel?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
|
|
30
|
+
}
|
|
31
|
+
export declare const setPlatformOptions: (opts: SetPlatformOptions) => void;
|
|
32
|
+
export * from '../types';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
|
|
2
|
+
export { ArcgisApiKey, defineCustomElement as defineCustomElementArcgisApiKey } from './arcgis-api-key.js';
|
|
3
|
+
export { ArcgisIdentity, defineCustomElement as defineCustomElementArcgisIdentity } from './arcgis-identity.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const amd = "define" in window && typeof window.define === "function" && "amd" in window.define;
|
|
2
|
+
function requireModule(modulePath) {
|
|
3
|
+
return new Promise((resolve) => window.require([modulePath], (moduleDefault) => {
|
|
4
|
+
resolve(moduleDefault);
|
|
5
|
+
}));
|
|
6
|
+
}
|
|
7
|
+
async function importIdentityIdentityManager() {
|
|
8
|
+
if (amd) {
|
|
9
|
+
return requireModule("esri/identity/IdentityManager");
|
|
10
|
+
}
|
|
11
|
+
const module = await import('@arcgis/core/identity/IdentityManager.js');
|
|
12
|
+
return module.default;
|
|
13
|
+
}
|
|
14
|
+
async function importIdentityOAuthInfo() {
|
|
15
|
+
if (amd) {
|
|
16
|
+
return requireModule("esri/identity/OAuthInfo");
|
|
17
|
+
}
|
|
18
|
+
const module = await import('@arcgis/core/identity/OAuthInfo.js');
|
|
19
|
+
return module.default;
|
|
20
|
+
}
|
|
21
|
+
async function newIdentityOAuthInfo(properties) {
|
|
22
|
+
const ModConstructor = await importIdentityOAuthInfo();
|
|
23
|
+
return new ModConstructor(properties);
|
|
24
|
+
}
|
|
25
|
+
async function importConfig() {
|
|
26
|
+
if (amd) {
|
|
27
|
+
return requireModule("esri/config");
|
|
28
|
+
}
|
|
29
|
+
const module = await import('@arcgis/core/config.js');
|
|
30
|
+
return module.default;
|
|
31
|
+
}
|
|
32
|
+
async function importCoreReactiveUtils() {
|
|
33
|
+
if (amd) {
|
|
34
|
+
return requireModule("esri/core/reactiveUtils");
|
|
35
|
+
}
|
|
36
|
+
const module = await import('@arcgis/core/core/reactiveUtils.js');
|
|
37
|
+
return module;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { importCoreReactiveUtils as a, importIdentityIdentityManager as b, importConfig as i, newIdentityOAuthInfo as n };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement } from './index-1f7e8e45.js';
|
|
2
|
+
import { i as importConfig } from './index-386f07e9.js';
|
|
3
|
+
|
|
4
|
+
const arcgisApiKeyCss = ":host{display:none}arcgis-api-key{display:none}";
|
|
5
|
+
|
|
6
|
+
const ArcgisApiKey = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.apiKeyReady = createEvent(this, "apiKeyReady", 7);
|
|
10
|
+
this.apiKey = undefined;
|
|
11
|
+
}
|
|
12
|
+
//--------------------------------------------------------------------------
|
|
13
|
+
//
|
|
14
|
+
// Watchers
|
|
15
|
+
//
|
|
16
|
+
//--------------------------------------------------------------------------
|
|
17
|
+
apiKeyWatcher(value) {
|
|
18
|
+
this._setApiKey(value);
|
|
19
|
+
}
|
|
20
|
+
//--------------------------------------------------------------------------
|
|
21
|
+
//
|
|
22
|
+
// Lifecycle
|
|
23
|
+
//
|
|
24
|
+
//--------------------------------------------------------------------------
|
|
25
|
+
async connectedCallback() {
|
|
26
|
+
if (this.apiKey) {
|
|
27
|
+
await this._setApiKey(this.apiKey);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//--------------------------------------------------------------------------
|
|
31
|
+
//
|
|
32
|
+
// Private Methods
|
|
33
|
+
//
|
|
34
|
+
//--------------------------------------------------------------------------
|
|
35
|
+
async _setApiKey(value) {
|
|
36
|
+
const config = await importConfig();
|
|
37
|
+
config.apiKey = value;
|
|
38
|
+
this.apiKeyReady.emit(true);
|
|
39
|
+
}
|
|
40
|
+
get el() { return getElement(this); }
|
|
41
|
+
static get watchers() { return {
|
|
42
|
+
"apiKey": ["apiKeyWatcher"]
|
|
43
|
+
}; }
|
|
44
|
+
};
|
|
45
|
+
ArcgisApiKey.style = arcgisApiKeyCss;
|
|
46
|
+
|
|
47
|
+
export { ArcgisApiKey as arcgis_api_key };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-1f7e8e45.js';
|
|
2
|
+
export { s as setNonce } from './index-1f7e8e45.js';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Stencil Client Patch Browser v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
6
|
+
*/
|
|
7
|
+
const patchBrowser = () => {
|
|
8
|
+
const importMeta = import.meta.url;
|
|
9
|
+
const opts = {};
|
|
10
|
+
if (importMeta !== '') {
|
|
11
|
+
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
12
|
+
}
|
|
13
|
+
return promiseResolve(opts);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
patchBrowser().then(options => {
|
|
17
|
+
return bootstrapLazy([["arcgis-api-key",[[0,"arcgis-api-key",{"apiKey":[1,"api-key"]}]]],["arcgis-identity",[[0,"arcgis-identity",{"identity":[1040],"appId":[1,"app-id"],"credential":[1040],"expiration":[1026],"locale":[1],"usePopup":[4,"use-popup"],"popupCallbackUrl":[1,"popup-callback-url"],"portalUrl":[1,"portal-url"],"preserveUrlHash":[4,"preserve-url-hash"],"signIn":[64],"signOut":[64]}]]]], options);
|
|
18
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, g as getElement } from './index-1f7e8e45.js';
|
|
2
|
+
import { a as importCoreReactiveUtils, n as newIdentityOAuthInfo, b as importIdentityIdentityManager } from './index-386f07e9.js';
|
|
3
|
+
|
|
4
|
+
const arcgisIdentityCss = ":host{display:none}arcgis-identity{display:none}";
|
|
5
|
+
|
|
6
|
+
const ArcgisIdentity = class {
|
|
7
|
+
constructor(hostRef) {
|
|
8
|
+
registerInstance(this, hostRef);
|
|
9
|
+
this.identityReady = createEvent(this, "identityReady", 7);
|
|
10
|
+
this.credentialCreate = createEvent(this, "credentialCreate", 7);
|
|
11
|
+
this.dialogCreate = createEvent(this, "dialogCreate", 7);
|
|
12
|
+
this.identity = undefined;
|
|
13
|
+
this.appId = undefined;
|
|
14
|
+
this.credential = undefined;
|
|
15
|
+
this.expiration = undefined;
|
|
16
|
+
this.locale = undefined;
|
|
17
|
+
this.usePopup = false;
|
|
18
|
+
this.popupCallbackUrl = undefined;
|
|
19
|
+
this.portalUrl = undefined;
|
|
20
|
+
this.preserveUrlHash = false;
|
|
21
|
+
}
|
|
22
|
+
//--------------------------------------------------------------------------
|
|
23
|
+
//
|
|
24
|
+
// Watchers
|
|
25
|
+
//
|
|
26
|
+
//--------------------------------------------------------------------------
|
|
27
|
+
appIdWatcher(value, oldValue) {
|
|
28
|
+
if (oldValue !== value) {
|
|
29
|
+
this._registerOAuth();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//--------------------------------------------------------------------------
|
|
33
|
+
//
|
|
34
|
+
// Methods
|
|
35
|
+
//
|
|
36
|
+
//--------------------------------------------------------------------------
|
|
37
|
+
async signIn() {
|
|
38
|
+
if (!this.credential) {
|
|
39
|
+
try {
|
|
40
|
+
this.credential = await this._checkCurrentStatus();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.credential = await this._fetchCredential();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return this.credential;
|
|
47
|
+
}
|
|
48
|
+
async signOut() {
|
|
49
|
+
if (!this.credential) {
|
|
50
|
+
try {
|
|
51
|
+
this.identity.destroyCredentials();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
this.credential = undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.credential = undefined;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
//--------------------------------------------------------------------------
|
|
61
|
+
//
|
|
62
|
+
// Lifecycle
|
|
63
|
+
//
|
|
64
|
+
//--------------------------------------------------------------------------
|
|
65
|
+
async connectedCallback() {
|
|
66
|
+
if (this.appId) {
|
|
67
|
+
await this._registerOAuth();
|
|
68
|
+
}
|
|
69
|
+
this._proxyEvents();
|
|
70
|
+
await this._addWatchers();
|
|
71
|
+
this.identityReady.emit({ identity: this.identity, ready: true });
|
|
72
|
+
}
|
|
73
|
+
//--------------------------------------------------------------------------
|
|
74
|
+
//
|
|
75
|
+
// Private Methods
|
|
76
|
+
//
|
|
77
|
+
//--------------------------------------------------------------------------
|
|
78
|
+
async _addWatchers() {
|
|
79
|
+
const { watch } = await importCoreReactiveUtils();
|
|
80
|
+
watch(() => this._info.expiration, (value) => (this.expiration = value), {
|
|
81
|
+
initial: true
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
_checkCurrentStatus() {
|
|
85
|
+
return this.identity.checkSignInStatus(`${this._info.portalUrl}/sharing`);
|
|
86
|
+
}
|
|
87
|
+
async _createOAuthInfo() {
|
|
88
|
+
const params = {};
|
|
89
|
+
if (this.appId !== undefined) {
|
|
90
|
+
params.appId = this.appId;
|
|
91
|
+
}
|
|
92
|
+
if (this.locale !== undefined) {
|
|
93
|
+
params.locale = this.locale;
|
|
94
|
+
}
|
|
95
|
+
if (this.popupCallbackUrl !== undefined) {
|
|
96
|
+
params.popupCallbackUrl = this.popupCallbackUrl;
|
|
97
|
+
}
|
|
98
|
+
if (this.preserveUrlHash !== undefined) {
|
|
99
|
+
params.preserveUrlHash = this.preserveUrlHash;
|
|
100
|
+
}
|
|
101
|
+
if (this.usePopup !== undefined) {
|
|
102
|
+
params.popup = this.usePopup;
|
|
103
|
+
}
|
|
104
|
+
if (this.portalUrl !== undefined) {
|
|
105
|
+
params.portalUrl = this.portalUrl;
|
|
106
|
+
}
|
|
107
|
+
const info = await newIdentityOAuthInfo(params);
|
|
108
|
+
this._info = info;
|
|
109
|
+
return info;
|
|
110
|
+
}
|
|
111
|
+
async _fetchCredential() {
|
|
112
|
+
const credential = await this.identity.getCredential(`${this._info?.portalUrl}/sharing`, {
|
|
113
|
+
error: null,
|
|
114
|
+
oAuthPopupConfirmation: false,
|
|
115
|
+
token: null
|
|
116
|
+
});
|
|
117
|
+
return credential;
|
|
118
|
+
}
|
|
119
|
+
async _registerOAuth() {
|
|
120
|
+
this.identity = await importIdentityIdentityManager();
|
|
121
|
+
const info = await this._createOAuthInfo();
|
|
122
|
+
this.identity.registerOAuthInfos([info]);
|
|
123
|
+
}
|
|
124
|
+
_proxyEvents() {
|
|
125
|
+
this.identity.on("credential-create", (e) => this.credentialCreate.emit(e));
|
|
126
|
+
this.identity.on("dialog-create", (e) => this.dialogCreate.emit(e));
|
|
127
|
+
}
|
|
128
|
+
get el() { return getElement(this); }
|
|
129
|
+
static get watchers() { return {
|
|
130
|
+
"appId": ["appIdWatcher"]
|
|
131
|
+
}; }
|
|
132
|
+
};
|
|
133
|
+
ArcgisIdentity.style = arcgisIdentityCss;
|
|
134
|
+
|
|
135
|
+
export { ArcgisIdentity as arcgis_identity };
|