UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 1.35 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{makeData as e,isDataProtocol as r,dataComponents as t,isAbsolute as a,join as n}from"../../core/urlUtils.js";import{w as i,f as u}from"../../chunks/persistableUrlUtils.js";function l(r,t,a){return t.imageData?e({mediaType:t.contentType||"image/png",isBase64:!0,data:t.imageData}):o(t.url,a)}function o(e,r){if(!a(e)){const t=p(r);if(t)return n(t,"images",e)}return u(e,r)}function s(e,a,n,u){if(r(e)){const r=t(e);if(!r)return;a.contentType=r.mediaType,a.imageData=r.data,n&&n.imageData===a.imageData&&n.url&&i(n.url,a,"url",u)}else i(e,a,"url",u)}const m={json:{read:{source:["imageData","url"],reader:l},write:{writer(e,r,t,a){s(e,r,this.source,a)}}}},c={readOnly:!0,json:{read:{source:["imageData","url"],reader(e,r,t){const a={};return r.imageData&&(a.imageData=r.imageData),r.contentType&&(a.contentType=r.contentType),r.url&&(a.url=o(r.url,t)),a}}}};function p(e){if(!e)return null;const{origin:r,layer:t}=e;if("service"!==r&&"portal-item"!==r)return null;const a=t?.type;return"feature"===a||"stream"===a?t.parsedUrl?.path:"map-image"===a||"tile"===a?e.url?.path:null}export{o as read,l as readImageDataOrUrl,c as sourcePropertyDefinition,m as urlPropertyDefinition,s as writeImageDataAndUrl};