UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 2.07 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{collectClassPaths as e}from"./utils.js";function t(e){const t=s(e),n=[],r=a(t),i=new Map;p("api","",e.api,t,r.api,i);const c=new Map;p("spec","",e.spec,t,r.spec,c);const u=o(t);for(const[p,a]of i){const e=c.get(p),t=u.get(a.container.id),o=`${a.container.name} (${e.container.name})${a.container.typeValue?` <${a.container.typeValue}>`:""}`;n.push({name:o,api:a,spec:e,indent:t})}return n}function n(e,t,a,o,s,i,c,u,f){if(c.has(o))return f;for(const d of o.properties){const l=t?`${t}.${d.name}`:d.name,m=a?`${a}.${d.name}`:d.name,y=s.get(m);if(y){const t=i.get(y[e].id);f.push({name:l,type:"ref",ref:y,refName:t,required:d.required}),p(e,m,y[e],s,i,u)}else"string"==typeof d.type?f.push(r(l,d)):(c.add(o),n(e,l,m,d.type,s,i,c,u,f))}return c.delete(o),f}function p(e,t,p,a,o,s){if(s.has(p.id))return s;const r={container:p,text:null,props:[]};return o.get(p.id).forEach((e=>s.set(e,r))),n(e,"",t,p,a,o,new Set,s,r.props),r.props.sort(i),s}function a(e){const t={api:new Map,spec:new Map};for(const n of e.values()){const e=`${n.api.name} (${n.spec.name})${n.api.typeValue?` <${n.api.typeValue}>`:""}`;let p=t.api.get(n.api.id);p||(p=new Set,t.api.set(n.api.id,p)),p.add(e);let a=t.spec.get(n.spec.id);a||(a=new Set,t.spec.set(n.spec.id,a)),a.add(e)}return t}function o(e){const t=new Map;for(const n of e.keys()){const p=n?n.split(".").length:0,a=e.get(n).api.id;t.has("id")?t.set(a,Math.min(p,t.get(a))):t.set(a,p)}return t}function s(t){const n=e(t.api),p=e(t.spec),a=new Map;a.set("",{api:t.api,spec:t.spec});for(const[e,o]of n){const t=p.get(e);t&&a.set(e,{api:o,spec:t})}return a}function r(e,t){return{name:e,type:t.enum||("string"==typeof t.type?t.type:""),default:JSON.stringify(t.default),required:t.required}}function i(e,t){const n=e.name.localeCompare(t.name);if(0!==n)return n;const p=(e.type||"").localeCompare(t.type||"");return 0!==p?p:(e.default||"").localeCompare(t.default||"")}export{t as collect};