@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
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Licensing
|
|
2
|
+
|
|
3
|
+
COPYRIGHT © 2023 Esri
|
|
4
|
+
|
|
5
|
+
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
|
|
6
|
+
|
|
7
|
+
This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
|
|
8
|
+
|
|
9
|
+
See use restrictions at http://www.esri.com/legal/pdfs/mla_e204_e300/english
|
|
10
|
+
|
|
11
|
+
For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
|
|
12
|
+
|
|
13
|
+
email: contracts@esri.com
|
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @arcgis/common-components (beta)
|
|
2
|
+
|
|
3
|
+
This Web Component package is part of the [ArcGIS Maps SDK for JavaScript](https://developers.arcgis.com/javascript) and is under active development. At this time, customer support is **not** provided. More news to come.
|
|
4
|
+
|
|
5
|
+
## License
|
|
6
|
+
|
|
7
|
+
COPYRIGHT © 2023 Esri
|
|
8
|
+
|
|
9
|
+
All rights reserved under the copyright laws of the United States and applicable international laws, treaties, and conventions.
|
|
10
|
+
|
|
11
|
+
This material is licensed for use under the Esri Master License Agreement (MLA), and is bound by the terms of that agreement. You may redistribute and use this code without modification, provided you adhere to the terms of the MLA and include this copyright notice.
|
|
12
|
+
|
|
13
|
+
See use restrictions at <http://www.esri.com/legal/pdfs/mla_e204_e300/english>
|
|
14
|
+
|
|
15
|
+
For additional information, contact: Environmental Systems Research Institute, Inc. Attn: Contracts and Legal Services Department 380 New York Street Redlands, California, USA 92373 USA
|
|
16
|
+
|
|
17
|
+
email: contracts@esri.com
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{p,b as a}from"./p-b0c98bba.js";export{s as setNonce}from"./p-b0c98bba.js";(()=>{const a=import.meta.url,e={};return""!==a&&(e.resourcesUrl=new URL(".",a).href),p(e)})().then((p=>a([["p-9fc4e265",[[0,"arcgis-api-key",{apiKey:[1,"api-key"]}]]],["p-adc54f17",[[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]}]]]],p)));
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,c as a,g as t}from"./p-b0c98bba.js";import{i}from"./p-e8b62824.js";const e=class{constructor(t){s(this,t),this.apiKeyReady=a(this,"apiKeyReady",7),this.apiKey=void 0}apiKeyWatcher(s){this._setApiKey(s)}async connectedCallback(){this.apiKey&&await this._setApiKey(this.apiKey)}async _setApiKey(s){(await i()).apiKey=s,this.apiKeyReady.emit(!0)}get el(){return t(this)}static get watchers(){return{apiKey:["apiKeyWatcher"]}}};e.style=":host{display:none}arcgis-api-key{display:none}";export{e as arcgis_api_key}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,g as s}from"./p-b0c98bba.js";import{a as h,n as a,b as e}from"./p-e8b62824.js";const r=class{constructor(s){t(this,s),this.identityReady=i(this,"identityReady",7),this.credentialCreate=i(this,"credentialCreate",7),this.dialogCreate=i(this,"dialogCreate",7),this.identity=void 0,this.appId=void 0,this.credential=void 0,this.expiration=void 0,this.locale=void 0,this.usePopup=!1,this.popupCallbackUrl=void 0,this.portalUrl=void 0,this.preserveUrlHash=!1}appIdWatcher(t,i){i!==t&&this._registerOAuth()}async signIn(){if(!this.credential)try{this.credential=await this._checkCurrentStatus()}catch(t){this.credential=await this._fetchCredential()}return this.credential}async signOut(){if(!this.credential)try{this.identity.destroyCredentials()}catch(t){this.credential=void 0}this.credential=void 0}async connectedCallback(){this.appId&&await this._registerOAuth(),this._proxyEvents(),await this._addWatchers(),this.identityReady.emit({identity:this.identity,ready:!0})}async _addWatchers(){const{watch:t}=await h();t((()=>this._info.expiration),(t=>this.expiration=t),{initial:!0})}_checkCurrentStatus(){return this.identity.checkSignInStatus(`${this._info.portalUrl}/sharing`)}async _createOAuthInfo(){const t={};void 0!==this.appId&&(t.appId=this.appId),void 0!==this.locale&&(t.locale=this.locale),void 0!==this.popupCallbackUrl&&(t.popupCallbackUrl=this.popupCallbackUrl),void 0!==this.preserveUrlHash&&(t.preserveUrlHash=this.preserveUrlHash),void 0!==this.usePopup&&(t.popup=this.usePopup),void 0!==this.portalUrl&&(t.portalUrl=this.portalUrl);const i=await a(t);return this._info=i,i}async _fetchCredential(){return await this.identity.getCredential(`${this._info?.portalUrl}/sharing`,{error:null,oAuthPopupConfirmation:!1,token:null})}async _registerOAuth(){this.identity=await e();const t=await this._createOAuthInfo();this.identity.registerOAuthInfos([t])}_proxyEvents(){this.identity.on("credential-create",(t=>this.credentialCreate.emit(t))),this.identity.on("dialog-create",(t=>this.dialogCreate.emit(t)))}get el(){return s(this)}static get watchers(){return{appId:["appIdWatcher"]}}};r.style=":host{display:none}arcgis-identity{display:none}";export{r as arcgis_identity}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
let e=!1;function t(e){var t,n,s;return null!==(s=null===(n=null===(t=e.head)||void 0===t?void 0:t.querySelector('meta[name="csp-nonce"]'))||void 0===n?void 0:n.getAttribute("content"))&&void 0!==s?s:void 0}const n=e=>S(e).t,s=(e,t,s)=>{const c=n(e);return{emit:e=>o(c,t,{bubbles:!!(4&s),composed:!!(2&s),cancelable:!!(1&s),detail:e})}},o=(e,t,n)=>{const s=N.ce(t,n);return e.dispatchEvent(s),s},c=new WeakMap,i=e=>"sc-"+e.o,r=(e,t)=>{t&&!e.i&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.i=t)))},a=(e,t)=>{if(e.l|=16,!(4&e.l))return r(e,e.u),A((()=>l(e,t)));e.l|=512},l=(e,t)=>{const n=e.m;return h(void 0,(()=>u(e,n,t)))},u=async(e,n,s)=>{const o=e.t,r=o["s-rc"];s&&(e=>{const n=e.h;((e,n)=>{var s;let o=i(n);const r=O.get(o);if(e=11===e.nodeType?e:E,r)if("string"==typeof r){let n,i=c.get(e=e.head||e);if(i||c.set(e,i=new Set),!i.has(o)){{n=E.createElement("style"),n.innerHTML=r;const o=null!==(s=N.p)&&void 0!==s?s:t(E);null!=o&&n.setAttribute("nonce",o),e.insertBefore(n,e.querySelector("link"))}i&&i.add(o)}}else e.adoptedStyleSheets.includes(r)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,r])})(e.t.getRootNode(),n)})(e);f(e,n),r&&(r.map((e=>e())),o["s-rc"]=void 0);{const t=o["s-p"],n=()=>d(e);0===t.length?n():(Promise.all(t).then(n),e.l|=4,t.length=0)}},f=(e,t)=>{try{t=t.render&&t.render(),e.l&=-17,e.l|=2}catch(t){M(t,e.t)}return null},d=e=>{const t=e.t,n=e.u;64&e.l||(e.l|=64,p(t),e.$(t),n||m()),e.v(t),e.i&&(e.i(),e.i=void 0),512&e.l&&q((()=>a(e,!1))),e.l&=-517},m=()=>{p(E.documentElement),q((()=>o(P,"appload",{detail:{namespace:"arcgis-common-components"}})))},h=(e,t)=>e&&e.then?e.then(t):t(),p=e=>e.setAttribute("hydrated",""),y=(e,t,n)=>{if(t.S){e.watchers&&(t.g=e.watchers);const s=Object.entries(t.S),o=e.prototype;if(s.map((([e,[s]])=>{31&s||2&n&&32&s?Object.defineProperty(o,e,{get(){return((e,t)=>S(this).j.get(t))(0,e)},set(n){((e,t,n,s)=>{const o=S(e),c=o.t,i=o.j.get(t),r=o.l,l=o.m;if(n=((e,t)=>null==e||(e=>"object"==(e=typeof e)||"function"===e)(e)?e:4&t?"false"!==e&&(""===e||!!e):2&t?parseFloat(e):1&t?e+"":e)(n,s.S[t][0]),(!(8&r)||void 0===i)&&n!==i&&(!Number.isNaN(i)||!Number.isNaN(n))&&(o.j.set(t,n),l)){if(s.g&&128&r){const e=s.g[t];e&&e.map((e=>{try{l[e](n,i,t)}catch(e){M(e,c)}}))}2==(18&r)&&a(o,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0}):1&n&&64&s&&Object.defineProperty(o,e,{value(...t){const n=S(this);return n.M.then((()=>n.m[e](...t)))}})})),1&n){const t=new Map;o.attributeChangedCallback=function(e,n,s){N.jmp((()=>{const n=t.get(e);if(this.hasOwnProperty(n))s=this[n],delete this[n];else if(o.hasOwnProperty(n)&&"number"==typeof this[n]&&this[n]==s)return;this[n]=(null!==s||"boolean"!=typeof this[n])&&s}))},e.observedAttributes=s.filter((([e,t])=>15&t[0])).map((([e,n])=>{const s=n[1]||e;return t.set(s,e),s}))}}return e},b=e=>{((e,t)=>{if(e&&e[t])try{e[t](void 0)}catch(e){M(e)}})(e,"connectedCallback")},w=(e,n={})=>{var s;const o=[],c=n.exclude||[],l=P.customElements,u=E.head,f=u.querySelector("meta[charset]"),d=E.createElement("style"),h=[];let p,w=!0;Object.assign(N,n),N.k=new URL(n.resourcesUrl||"./",E.baseURI).href,e.map((e=>{e[1].map((t=>{const n={l:t[0],o:t[1],S:t[2],C:t[3]};n.S=t[2],n.g={};const s=n.o,u=class extends HTMLElement{constructor(e){super(e),j(e=this,n)}connectedCallback(){p&&(clearTimeout(p),p=null),w?h.push(this):N.jmp((()=>(e=>{if(0==(1&N.l)){const t=S(e),n=t.h,s=()=>{};if(1&t.l)b(t.m);else{t.l|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){r(t,t.u=n);break}}n.S&&Object.entries(n.S).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,s,o)=>{if(0==(32&t.l)){{if(t.l|=32,(o=C(n)).then){const e=()=>{};o=await o,e()}o.isProxied||(n.g=o.watchers,y(o,n,2),o.isProxied=!0);const e=()=>{};t.l|=8;try{new o(t)}catch(e){M(e)}t.l&=-9,t.l|=128,e(),b(t.m)}if(o.style){let e=o.style;const t=i(n);if(!O.has(t)){const s=()=>{};((e,t,n)=>{let s=O.get(e);x&&n?(s=s||new CSSStyleSheet,"string"==typeof s?s=t:s.replaceSync(t)):s=t,O.set(e,s)})(t,e,!!(1&n.l)),s()}}}const c=t.u,r=()=>a(t,!0);c&&c["s-rc"]?c["s-rc"].push(r):r()})(0,t,n)}s()}})(this)))}disconnectedCallback(){N.jmp((()=>{}))}componentOnReady(){return S(this).O}};n.P=e[0],c.includes(s)||l.get(s)||(o.push(s),l.define(s,y(u,n,1)))}))}));{d.innerHTML=o+"{visibility:hidden}[hydrated]{visibility:inherit}",d.setAttribute("data-styles","");const e=null!==(s=N.p)&&void 0!==s?s:t(E);null!=e&&d.setAttribute("nonce",e),u.insertBefore(d,f?f.nextSibling:u.firstChild)}w=!1,h.length?h.map((e=>e.connectedCallback())):N.jmp((()=>p=setTimeout(m,30)))},$=e=>N.p=e,v=new WeakMap,S=e=>v.get(e),g=(e,t)=>v.set(t.m=e,t),j=(e,t)=>{const n={l:0,t:e,h:t,j:new Map};return n.M=new Promise((e=>n.v=e)),n.O=new Promise((e=>n.$=e)),e["s-p"]=[],e["s-rc"]=[],v.set(e,n)},M=(e,t)=>(0,console.error)(e,t),k=new Map,C=e=>{const t=e.o.replace(/-/g,"_"),n=e.P,s=k.get(n);return s?s[t]:import(`./${n}.entry.js`).then((e=>(k.set(n,e),e[t])),M)
|
|
2
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/},O=new Map,P="undefined"!=typeof window?window:{},E=P.document||{head:{}},N={l:0,k:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,s)=>e.addEventListener(t,n,s),rel:(e,t,n,s)=>e.removeEventListener(t,n,s),ce:(e,t)=>new CustomEvent(e,t)},T=e=>Promise.resolve(e),x=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),F=[],L=[],R=(t,n)=>s=>{t.push(s),e||(e=!0,n&&4&N.l?q(W):N.raf(W))},U=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){M(e)}e.length=0},W=()=>{U(F),U(L),(e=F.length>0)&&N.raf(W)},q=e=>T().then(e),A=R(L,!0);export{w as b,s as c,n as g,T as p,g as r,$ as s}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const i="define"in window&&"function"==typeof window.define&&"amd"in window.define;function n(i){return new Promise((n=>window.require([i],(i=>{n(i)}))))}async function t(){return i?n("esri/identity/IdentityManager"):(await import("@arcgis/core/identity/IdentityManager.js")).default}async function r(t){return new(await async function(){return i?n("esri/identity/OAuthInfo"):(await import("@arcgis/core/identity/OAuthInfo.js")).default}())(t)}async function e(){return i?n("esri/config"):(await import("@arcgis/core/config.js")).default}async function a(){return i?n("esri/core/reactiveUtils"):await import("@arcgis/core/core/reactiveUtils.js")}export{a,t as b,e as i,r as n}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-e8c59179.js');
|
|
6
|
+
const index$1 = require('./index-33f2dbd2.js');
|
|
7
|
+
|
|
8
|
+
const arcgisApiKeyCss = ":host{display:none}arcgis-api-key{display:none}";
|
|
9
|
+
|
|
10
|
+
const ArcgisApiKey = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
this.apiKeyReady = index.createEvent(this, "apiKeyReady", 7);
|
|
14
|
+
this.apiKey = undefined;
|
|
15
|
+
}
|
|
16
|
+
//--------------------------------------------------------------------------
|
|
17
|
+
//
|
|
18
|
+
// Watchers
|
|
19
|
+
//
|
|
20
|
+
//--------------------------------------------------------------------------
|
|
21
|
+
apiKeyWatcher(value) {
|
|
22
|
+
this._setApiKey(value);
|
|
23
|
+
}
|
|
24
|
+
//--------------------------------------------------------------------------
|
|
25
|
+
//
|
|
26
|
+
// Lifecycle
|
|
27
|
+
//
|
|
28
|
+
//--------------------------------------------------------------------------
|
|
29
|
+
async connectedCallback() {
|
|
30
|
+
if (this.apiKey) {
|
|
31
|
+
await this._setApiKey(this.apiKey);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//--------------------------------------------------------------------------
|
|
35
|
+
//
|
|
36
|
+
// Private Methods
|
|
37
|
+
//
|
|
38
|
+
//--------------------------------------------------------------------------
|
|
39
|
+
async _setApiKey(value) {
|
|
40
|
+
const config = await index$1.importConfig();
|
|
41
|
+
config.apiKey = value;
|
|
42
|
+
this.apiKeyReady.emit(true);
|
|
43
|
+
}
|
|
44
|
+
get el() { return index.getElement(this); }
|
|
45
|
+
static get watchers() { return {
|
|
46
|
+
"apiKey": ["apiKeyWatcher"]
|
|
47
|
+
}; }
|
|
48
|
+
};
|
|
49
|
+
ArcgisApiKey.style = arcgisApiKeyCss;
|
|
50
|
+
|
|
51
|
+
exports.arcgis_api_key = ArcgisApiKey;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 Browser v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
9
|
+
*/
|
|
10
|
+
const patchBrowser = () => {
|
|
11
|
+
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('arcgis-common-components.cjs.js', document.baseURI).href));
|
|
12
|
+
const opts = {};
|
|
13
|
+
if (importMeta !== '') {
|
|
14
|
+
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
15
|
+
}
|
|
16
|
+
return index.promiseResolve(opts);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
patchBrowser().then(options => {
|
|
20
|
+
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);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
exports.setNonce = index.setNonce;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-e8c59179.js');
|
|
6
|
+
const index$1 = require('./index-33f2dbd2.js');
|
|
7
|
+
|
|
8
|
+
const arcgisIdentityCss = ":host{display:none}arcgis-identity{display:none}";
|
|
9
|
+
|
|
10
|
+
const ArcgisIdentity = class {
|
|
11
|
+
constructor(hostRef) {
|
|
12
|
+
index.registerInstance(this, hostRef);
|
|
13
|
+
this.identityReady = index.createEvent(this, "identityReady", 7);
|
|
14
|
+
this.credentialCreate = index.createEvent(this, "credentialCreate", 7);
|
|
15
|
+
this.dialogCreate = index.createEvent(this, "dialogCreate", 7);
|
|
16
|
+
this.identity = undefined;
|
|
17
|
+
this.appId = undefined;
|
|
18
|
+
this.credential = undefined;
|
|
19
|
+
this.expiration = undefined;
|
|
20
|
+
this.locale = undefined;
|
|
21
|
+
this.usePopup = false;
|
|
22
|
+
this.popupCallbackUrl = undefined;
|
|
23
|
+
this.portalUrl = undefined;
|
|
24
|
+
this.preserveUrlHash = false;
|
|
25
|
+
}
|
|
26
|
+
//--------------------------------------------------------------------------
|
|
27
|
+
//
|
|
28
|
+
// Watchers
|
|
29
|
+
//
|
|
30
|
+
//--------------------------------------------------------------------------
|
|
31
|
+
appIdWatcher(value, oldValue) {
|
|
32
|
+
if (oldValue !== value) {
|
|
33
|
+
this._registerOAuth();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//--------------------------------------------------------------------------
|
|
37
|
+
//
|
|
38
|
+
// Methods
|
|
39
|
+
//
|
|
40
|
+
//--------------------------------------------------------------------------
|
|
41
|
+
async signIn() {
|
|
42
|
+
if (!this.credential) {
|
|
43
|
+
try {
|
|
44
|
+
this.credential = await this._checkCurrentStatus();
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.credential = await this._fetchCredential();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return this.credential;
|
|
51
|
+
}
|
|
52
|
+
async signOut() {
|
|
53
|
+
if (!this.credential) {
|
|
54
|
+
try {
|
|
55
|
+
this.identity.destroyCredentials();
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.credential = undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
this.credential = undefined;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
//--------------------------------------------------------------------------
|
|
65
|
+
//
|
|
66
|
+
// Lifecycle
|
|
67
|
+
//
|
|
68
|
+
//--------------------------------------------------------------------------
|
|
69
|
+
async connectedCallback() {
|
|
70
|
+
if (this.appId) {
|
|
71
|
+
await this._registerOAuth();
|
|
72
|
+
}
|
|
73
|
+
this._proxyEvents();
|
|
74
|
+
await this._addWatchers();
|
|
75
|
+
this.identityReady.emit({ identity: this.identity, ready: true });
|
|
76
|
+
}
|
|
77
|
+
//--------------------------------------------------------------------------
|
|
78
|
+
//
|
|
79
|
+
// Private Methods
|
|
80
|
+
//
|
|
81
|
+
//--------------------------------------------------------------------------
|
|
82
|
+
async _addWatchers() {
|
|
83
|
+
const { watch } = await index$1.importCoreReactiveUtils();
|
|
84
|
+
watch(() => this._info.expiration, (value) => (this.expiration = value), {
|
|
85
|
+
initial: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
_checkCurrentStatus() {
|
|
89
|
+
return this.identity.checkSignInStatus(`${this._info.portalUrl}/sharing`);
|
|
90
|
+
}
|
|
91
|
+
async _createOAuthInfo() {
|
|
92
|
+
const params = {};
|
|
93
|
+
if (this.appId !== undefined) {
|
|
94
|
+
params.appId = this.appId;
|
|
95
|
+
}
|
|
96
|
+
if (this.locale !== undefined) {
|
|
97
|
+
params.locale = this.locale;
|
|
98
|
+
}
|
|
99
|
+
if (this.popupCallbackUrl !== undefined) {
|
|
100
|
+
params.popupCallbackUrl = this.popupCallbackUrl;
|
|
101
|
+
}
|
|
102
|
+
if (this.preserveUrlHash !== undefined) {
|
|
103
|
+
params.preserveUrlHash = this.preserveUrlHash;
|
|
104
|
+
}
|
|
105
|
+
if (this.usePopup !== undefined) {
|
|
106
|
+
params.popup = this.usePopup;
|
|
107
|
+
}
|
|
108
|
+
if (this.portalUrl !== undefined) {
|
|
109
|
+
params.portalUrl = this.portalUrl;
|
|
110
|
+
}
|
|
111
|
+
const info = await index$1.newIdentityOAuthInfo(params);
|
|
112
|
+
this._info = info;
|
|
113
|
+
return info;
|
|
114
|
+
}
|
|
115
|
+
async _fetchCredential() {
|
|
116
|
+
const credential = await this.identity.getCredential(`${this._info?.portalUrl}/sharing`, {
|
|
117
|
+
error: null,
|
|
118
|
+
oAuthPopupConfirmation: false,
|
|
119
|
+
token: null
|
|
120
|
+
});
|
|
121
|
+
return credential;
|
|
122
|
+
}
|
|
123
|
+
async _registerOAuth() {
|
|
124
|
+
this.identity = await index$1.importIdentityIdentityManager();
|
|
125
|
+
const info = await this._createOAuthInfo();
|
|
126
|
+
this.identity.registerOAuthInfos([info]);
|
|
127
|
+
}
|
|
128
|
+
_proxyEvents() {
|
|
129
|
+
this.identity.on("credential-create", (e) => this.credentialCreate.emit(e));
|
|
130
|
+
this.identity.on("dialog-create", (e) => this.dialogCreate.emit(e));
|
|
131
|
+
}
|
|
132
|
+
get el() { return index.getElement(this); }
|
|
133
|
+
static get watchers() { return {
|
|
134
|
+
"appId": ["appIdWatcher"]
|
|
135
|
+
}; }
|
|
136
|
+
};
|
|
137
|
+
ArcgisIdentity.style = arcgisIdentityCss;
|
|
138
|
+
|
|
139
|
+
exports.arcgis_identity = ArcgisIdentity;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _interopNamespace(e) {
|
|
4
|
+
if (e && e.__esModule) return e;
|
|
5
|
+
var n = Object.create(null);
|
|
6
|
+
if (e) {
|
|
7
|
+
Object.keys(e).forEach(function (k) {
|
|
8
|
+
if (k !== 'default') {
|
|
9
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
10
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return e[k];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
n['default'] = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const amd = "define" in window && typeof window.define === "function" && "amd" in window.define;
|
|
24
|
+
function requireModule(modulePath) {
|
|
25
|
+
return new Promise((resolve) => window.require([modulePath], (moduleDefault) => {
|
|
26
|
+
resolve(moduleDefault);
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
async function importIdentityIdentityManager() {
|
|
30
|
+
if (amd) {
|
|
31
|
+
return requireModule("esri/identity/IdentityManager");
|
|
32
|
+
}
|
|
33
|
+
const module = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@arcgis/core/identity/IdentityManager.js')); });
|
|
34
|
+
return module.default;
|
|
35
|
+
}
|
|
36
|
+
async function importIdentityOAuthInfo() {
|
|
37
|
+
if (amd) {
|
|
38
|
+
return requireModule("esri/identity/OAuthInfo");
|
|
39
|
+
}
|
|
40
|
+
const module = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@arcgis/core/identity/OAuthInfo.js')); });
|
|
41
|
+
return module.default;
|
|
42
|
+
}
|
|
43
|
+
async function newIdentityOAuthInfo(properties) {
|
|
44
|
+
const ModConstructor = await importIdentityOAuthInfo();
|
|
45
|
+
return new ModConstructor(properties);
|
|
46
|
+
}
|
|
47
|
+
async function importConfig() {
|
|
48
|
+
if (amd) {
|
|
49
|
+
return requireModule("esri/config");
|
|
50
|
+
}
|
|
51
|
+
const module = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@arcgis/core/config.js')); });
|
|
52
|
+
return module.default;
|
|
53
|
+
}
|
|
54
|
+
async function importCoreReactiveUtils() {
|
|
55
|
+
if (amd) {
|
|
56
|
+
return requireModule("esri/core/reactiveUtils");
|
|
57
|
+
}
|
|
58
|
+
const module = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@arcgis/core/core/reactiveUtils.js')); });
|
|
59
|
+
return module;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.importConfig = importConfig;
|
|
63
|
+
exports.importCoreReactiveUtils = importCoreReactiveUtils;
|
|
64
|
+
exports.importIdentityIdentityManager = importIdentityIdentityManager;
|
|
65
|
+
exports.newIdentityOAuthInfo = newIdentityOAuthInfo;
|