@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.84 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{_ as t}from"../chunks/tslib.es6.js";import{deprecatedFunction as e}from"../core/deprecate.js";import o from"../core/Error.js";import r from"../core/Logger.js";import{throwIfAborted as s}from"../core/promiseUtils.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{enumeration as i}from"../core/accessorSupport/decorators/enumeration.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import p from"../portal/Portal.js";import{w as a,r as c}from"../chunks/persistableUrlUtils.js";import y from"./Symbol.js";import{Thumbnail as n}from"./support/Thumbnail.js";var h;let u=h=class extends y{constructor(t){super(t),this.color=null,this.styleName=null,this.portal=null,this.styleUrl=null,this.thumbnail=null,this.name=null,this.type="web-style"}get _fetchCacheKey(){const t=null!=this.portal?this.portal:p.getDefault(),e=t.user?t.user.username:null;return`${this.styleName}:${this.styleUrl}:${this.name}:${e}:${t.url}`}read(t,e){this.portal=e?.portal,super.read(t,e)}clone(){return new h({name:this.name,styleUrl:this.styleUrl,styleName:this.styleName,portal:this.portal})}fetchSymbol(t){return this._fetchSymbol(t)}async fetchCIMSymbol(t){e(r.getLogger(this),"WebStyleSymbol.fetchCIMSymbol is deprecated in favour of WebStyleSymbol.fetchSymbol which now supports both web and cim symbology",{version:"4.33",replacement:"WebStyleSymbol.fetchSymbol",see:"https://arcg.is/0CXPTr#fetchSymbol",warnOnce:!0});const s=await this._fetchSymbol({...t,acceptedFormats:["cim"]});if("cim"!==s?.type)throw new o("webstylesymbol:fetchCIMSymbol","Resolved web style symbol is not of type 'cim'");return s}async _fetchSymbol(t){const e=null!=t?t.cache:null,o=e?this._fetchCacheKey:null;if(null!=e){const t=o&&e.get(o);if(t)return t.clone()}const{resolveWebStyleSymbol:l}=await import("./support/webStyleSymbolUtils.js");s(t);const i=l(this,{portal:this.portal},t);i.catch((t=>{r.getLogger(this).error("#fetchSymbol()","Failed to create symbol from style",t)}));const m=await i;return null!=e&&e.set(o,m.clone()),m}};t([l({json:{write:!1}})],u.prototype,"color",void 0),t([l({type:String,json:{write:!0}})],u.prototype,"styleName",void 0),t([l({type:p,json:{write:!1}})],u.prototype,"portal",void 0),t([l({type:String,json:{read:c,write:a}})],u.prototype,"styleUrl",void 0),t([l({type:n,json:{read:!1}})],u.prototype,"thumbnail",void 0),t([l({type:String,json:{write:!0}})],u.prototype,"name",void 0),t([i({styleSymbolReference:"web-style"},{readOnly:!0})],u.prototype,"type",void 0),t([l()],u.prototype,"_fetchCacheKey",null),u=h=t([m("esri.symbols.WebStyleSymbol")],u);export{u as default};