@arcgis/core 4.33.0-next.20250227 → 4.33.0-next.20250228
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/WebLinkChart.js +1 -1
- package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +2 -0
- package/applications/KnowledgeStudio/generalSharedKgUtils.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{3170552a6310725d7730.js → 05b7c739115be0490583.js} +1 -1
- package/assets/esri/core/workers/chunks/2c227d97d00b3849f441.js +1 -0
- package/assets/esri/core/workers/chunks/2ce80c764cca9e6a20cd.js +1 -0
- package/assets/esri/core/workers/chunks/6f9bfa6ed34ef6efcc6f.js +1 -0
- package/assets/esri/core/workers/chunks/8abd2235aa702d8b239f.js +1 -0
- package/assets/esri/core/workers/chunks/a288c2474ef193f9fbd3.js +1 -0
- package/assets/esri/core/workers/chunks/{e118245566be994a53da.js → a901c445d36f1a9e7df8.js} +1 -1
- package/assets/esri/core/workers/chunks/a91f2d1deb950f46ad09.js +1 -0
- package/assets/esri/core/workers/chunks/b8416f2560710258c239.js +1 -0
- package/assets/esri/core/workers/chunks/f45ef721d21388846101.js +1 -0
- package/assets/esri/core/workers/chunks/{2d4bfd747580ed3b6f4d.js → fdab6921d007929ab288.js} +1 -1
- package/assets/esri/themes/base/widgets/_Sketch.scss +4 -4
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/interfaces.d.ts +17 -15
- package/intl/duration.js +1 -1
- package/intl/locale.js +1 -1
- package/intl/messages.js +1 -1
- package/layers/BingMapsLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/SublayersOwner.js +1 -1
- package/layers/support/rasterDatasets/covJSONParser.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/previewSymbol2D.js +1 -1
- package/views/3d/environment/CloudsRenderer.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +11 -11
- package/views/3d/webgl-engine/core/shaderLibrary/util/LookupCubemapFromTextureArray.glsl.js +39 -0
- package/views/3d/webgl-engine/core/shaderModules/Texture2DArrayBindUniform.js +5 -0
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/webdoc/support/webdocSaveUtils.js +1 -1
- package/webdoc/support/writeUtils.js +1 -1
- package/widgets/Print/PrintViewModel.js +1 -1
- package/widgets/ScaleRangeSlider/scalePreviewUtils.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
- package/widgets/support/SelectionToolbar.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/widgets/support/chartUtilsAm5.js +1 -1
- package/assets/esri/core/workers/chunks/22e7db720724f2426d74.js +0 -1
- package/assets/esri/core/workers/chunks/2515ace848cf078c6263.js +0 -1
- package/assets/esri/core/workers/chunks/2c348d0e8131f08391cb.js +0 -1
- package/assets/esri/core/workers/chunks/380128e2cb74798478c1.js +0 -1
- package/assets/esri/core/workers/chunks/68ac336f7384bbca85ab.js +0 -1
- package/assets/esri/core/workers/chunks/823bf95f42cc42f20e22.js +0 -1
- package/assets/esri/core/workers/chunks/84e50d3ff298b7b66070.js +0 -1
- package/assets/esri/core/workers/chunks/aa98a6c38e82d384403c.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{neverReached as s}from"../../../core/compilerUtils.js";import{lerp as i}from"../../../core/mathUtils.js";import{destroyMaybe as r,disposeMaybe as o}from"../../../core/maybe.js";import{watch as a,initial as n}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as m,equals as f,copy as _}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as g,ZEROS as x,zeros as y}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{CubeMapState as C,CloudsTextureChannels as w}from"./Clouds.js";import{C as S,c as j}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as z}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import{neverReached as s}from"../../../core/compilerUtils.js";import{lerp as i}from"../../../core/mathUtils.js";import{destroyMaybe as r,disposeMaybe as o}from"../../../core/maybe.js";import{watch as a,initial as n}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as d}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as m,equals as f,copy as _}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as g,ZEROS as x,zeros as y}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{CubeMapState as C,CloudsTextureChannels as w}from"./Clouds.js";import{C as S,c as j}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as z}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as R,RayMarchingSteps as M}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as I}from"./NoiseTextureAtlas.js";import{TaskPriority as H}from"../../support/Scheduler.js";import{Yield as U}from"../../support/Yield.js";import{TextureType as q,TextureWrapMode as A,ColorAttachment as D}from"../../webgl/enums.js";import{FramebufferObject as E}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as F}from"../../webgl/TextureDescriptor.js";let O=class extends e{constructor(t){super(t),this._state=h(C.Idle),this._passParameters=new S,this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this._tilesPerFace=1,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=p(),this._dirty=!0,this.running=!0,this._configuration=new R}initialize(){const t=v(this.view.spatialReference);this._passParameters.cloudRadius=.5*t.radius;const e=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(H.CLOUDS_GENERATOR,this),a((()=>this.coverage),e,n),a((()=>this.density),e,n),a((()=>this.absorption),e,n),a((()=>this.cloudSize),e,n),a((()=>this.detailSize),e,n),a((()=>this.smoothness),e,n),a((()=>this.cloudHeight),e,n),a((()=>this.raymarchingSteps),e,n)]);const s=g(this._computeWeatherTile());let i=0;this.addHandles(a((()=>{const t=this._computeWeatherTile();return f(s,t)||(++i,_(s,t)),i}),e))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=r(this._passParameters.noiseTexture)}_precompileTechniques(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=w.RG,this.context.techniques.precompile(z,this._configuration),this._configuration.writeTextureChannels=w.BA,this.context.techniques.precompile(z,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case M.SIXTEEN:this._tilesPerFace=1;break;case M.HUNDRED:this._tilesPerFace=4;break;case M.COUNT:case M.TWOHUNDRED:this._tilesPerFace=8;break;default:s(this.raymarchingSteps)}return this._configuration.writeTextureChannels=1-this.parameters.readChannels,this._configuration.steps=this.raymarchingSteps,this.context.techniques.get(z,this._configuration)}_computeWeatherTile(){const{camera:t,environment:e}=this.view,{latitude:s,longitude:i}=t.position;if(null==s||null==i)return x;m(L,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*L[0]-1));L[0]=Math.floor(2*this._weatherTileCount*L[0]),L[1]=Math.floor(4*(this._weatherTileCount-r)*L[1]);let o=0,a=0;if("virtual"!==e?.lighting?.type&&null!=e?.lighting?.date){const t=new Date(e.lighting.date);t.setUTCHours(e.lighting.date.getUTCHours()+(e.lighting.displayUTCOffset??0)),o=31*t.getUTCMonth()+t.getUTCDate(),a=t.getUTCFullYear()}return L[0]=(L[0]+o)%(2*this._weatherTileCount),L[1]=(L[1]+a%100)%(4*this._weatherTileCount),L}get state(){return this._state.value}set state(t){this._state.value=t}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new I({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(t){const e=this.context.renderContext.rctx;if(null==this._fbo){const s=new F(t);s.target=q.TEXTURE_2D_ARRAY,s.depth=5,s.wrapMode=A.CLAMP_TO_EDGE,this._fbo=new E(e,s),this.parameters.data=this}return e.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=o(this._fbo),this.parameters.data=null}applyPreset(t,e){const s=t.median,r=t=>{const r=i(t[0],t[1],s);return e<.5?i(t[0],r,2*e):i(r,t[1],2*(e-.5))};this.coverage=r(t.coverage),this.density=r(t.density),this.absorption=r(t.absorption),this.cloudSize=r(t.cloudSize),this.detailSize=r(t.detailSize),this.smoothness=r(t.smoothness),this.cloudHeight=r(t.cloudHeight),this.raymarchingSteps=t.raymarchingSteps,this._precompileTechniques()}setDirty(){this._dirty=this.running=!0}runTask(t){if(this.state===C.Fading)return U;this._dirty&&(this._faceIndex=this._tileIndex=0,this.state=C.Rendering,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const e=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!e.compiled)return U;const s=N[this._faceIndex],i=k[this._faceIndex];d(this._viewMatrix,W,s,i),u(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=j/this._tilesPerFace,n=this._tileIndex*a;r.setViewport(0,n,j,a);const h=this._ensureFrameBufferCube(j);r.bindFramebuffer(h),r.bindTechnique(e,this.context.renderContext.bind,this._passParameters);const c=q.TEXTURE_2D_ARRAY;return h.setColorTextureTarget(c,D.COLOR_ATTACHMENT0,this._faceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this._faceIndex=this._tileIndex=0,this.state=C.Ready,this.running=!1):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),t.madeProgress(),U}};t([c({constructOnly:!0})],O.prototype,"context",void 0),t([c({constructOnly:!0})],O.prototype,"view",void 0),t([c({constructOnly:!0})],O.prototype,"requestRender",void 0),t([c()],O.prototype,"coverage",void 0),t([c()],O.prototype,"density",void 0),t([c()],O.prototype,"absorption",void 0),t([c()],O.prototype,"cloudSize",void 0),t([c()],O.prototype,"detailSize",void 0),t([c()],O.prototype,"smoothness",void 0),t([c()],O.prototype,"cloudHeight",void 0),t([c()],O.prototype,"raymarchingSteps",void 0),t([c()],O.prototype,"running",void 0),O=t([l("esri.views.3d.environment.CloudsRenderer")],O);const N=[T(1,0,0),T(-1,0,0),T(0,1,0),T(0,-1,0),T(0,0,1)],k=[T(0,1,0),T(0,1,0),T(0,0,-1),T(0,0,1),T(0,1,0)],W=b(),L=y();export{O as CloudsRenderer};
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{fromValues as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{earth as t}from"../../../../../../geometry/support/Ellipsoid.js";import{CloudsTextureChannels as e}from"../../../../environment/Clouds.js";import{FadeState as
|
|
5
|
+
import{fromValues as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{earth as t}from"../../../../../../geometry/support/Ellipsoid.js";import{CloudsTextureChannels as e}from"../../../../environment/Clouds.js";import{FadeState as r}from"../../../../environment/CloudsParameters.js";import{cloudsHeight as a}from"../../../../environment/weather.js";import{addMainLightDirection as i,addMainLightIntensity as c}from"../shading/MainLighting.glsl.js";import{LookupCubemapFromTextureArray as d}from"./LookupCubemapFromTextureArray.glsl.js";import{BooleanBindUniform as n}from"../../shaderModules/BooleanBindUniform.js";import{Float3BindUniform as l}from"../../shaderModules/Float3BindUniform.js";import{FloatBindUniform as s}from"../../shaderModules/FloatBindUniform.js";import{glsl as u}from"../../shaderModules/glsl.js";import{Matrix4BindUniform as m}from"../../shaderModules/Matrix4BindUniform.js";import{Texture2DArrayBindUniform as h}from"../../shaderModules/Texture2DArrayBindUniform.js";function C(t){const a=t.fragment;a.constants.add("radiusCloudsSquared","float",p).code.add(u`vec3 intersectWithCloudLayer(vec3 dir, vec3 cameraPosition, vec3 spherePos) {
|
|
6
6
|
float B = 2.0 * dot(cameraPosition, dir);
|
|
7
7
|
float C = dot(cameraPosition, cameraPosition) - radiusCloudsSquared;
|
|
8
8
|
float det = B * B - 4.0 * C;
|
|
9
9
|
float pointIntDist = max(0.0, 0.5 *(-B + sqrt(det)));
|
|
10
10
|
return (cameraPosition + dir * pointIntDist) - spherePos;
|
|
11
|
-
}`),
|
|
11
|
+
}`),a.uniforms.add(new s("radiusCurvatureCorrection",(({clouds:o})=>o.parallax.radiusCurvatureCorrection))).code.add(u`vec3 correctForPlanetCurvature(vec3 dir) {
|
|
12
12
|
dir.z = dir.z * (1.0 - radiusCurvatureCorrection) + radiusCurvatureCorrection;
|
|
13
13
|
return dir;
|
|
14
|
-
}`),
|
|
14
|
+
}`),a.code.add(u`vec3 rotateDirectionToAnchorPoint(mat4 rotMat, vec3 inVec) {
|
|
15
15
|
return (rotMat * vec4(inVec, 0.0)).xyz;
|
|
16
|
-
}`),i(
|
|
16
|
+
}`),i(a),c(a);const C=o(.28,.175,.035);a.constants.add("RIM_COLOR","vec3",C);const v=.3,f=140,g=.2,w=10,P=.3;a.code.add(u`
|
|
17
17
|
vec3 calculateCloudColor(vec3 cameraPosition, vec3 worldSpaceRay, vec4 clouds) {
|
|
18
18
|
float upDotLight = dot(cameraPosition, mainLightDirection);
|
|
19
19
|
float dirDotLight = max(dot(worldSpaceRay, mainLightDirection), 0.0);
|
|
20
|
-
float sunsetTransition = clamp(pow(max(upDotLight, 0.0), ${
|
|
20
|
+
float sunsetTransition = clamp(pow(max(upDotLight, 0.0), ${u.float(v)}), 0.0, 1.0);
|
|
21
21
|
|
|
22
22
|
// Base color of the clouds that depends on lighting of the sun and sky
|
|
23
23
|
vec3 ambientLight = calculateAmbientIrradiance(cameraPosition, 0.0);
|
|
@@ -27,19 +27,19 @@ return (rotMat * vec4(inVec, 0.0)).xyz;
|
|
|
27
27
|
// Rim light around the edge of the clouds simulating scattering of the direct lun light
|
|
28
28
|
float scatteringMod = max(clouds.a < 0.5 ? clouds.a / 0.5 : - clouds.a / 0.5 + 2.0, 0.0);
|
|
29
29
|
float rimLightIntensity = 0.5 + 0.5 * pow(max(upDotLight, 0.0), 0.35);
|
|
30
|
-
vec3 directSunScattering = RIM_COLOR * rimLightIntensity * (pow(dirDotLight, ${
|
|
30
|
+
vec3 directSunScattering = RIM_COLOR * rimLightIntensity * (pow(dirDotLight, ${u.float(f)})) * scatteringMod;
|
|
31
31
|
|
|
32
32
|
// Brighten the clouds around the sun at the sunsets
|
|
33
|
-
float additionalLight = ${
|
|
33
|
+
float additionalLight = ${u.float(g)} * pow(dirDotLight, ${u.float(w)}) * (1. - pow(sunsetTransition, ${u.float(P)})) ;
|
|
34
34
|
|
|
35
35
|
return vec3(baseCloudColor * (1.0 + additionalLight) + directSunScattering);
|
|
36
36
|
}
|
|
37
|
-
`),
|
|
38
|
-
vec4 s =
|
|
37
|
+
`),t.include(d),a.uniforms.add(new n("readChannelsRG",(o=>o.clouds.readChannels===e.RG)),new h("cubeMap",(o=>o.clouds.data?.cubeMap?.colorTexture??null))).code.add(u`vec4 sampleCloud(vec3 rayDir, bool readOtherChannel) {
|
|
38
|
+
vec4 s = lookupCubemapFromTextureArray(cubeMap, rayDir);
|
|
39
39
|
bool readRG = readChannelsRG ^^ readOtherChannel;
|
|
40
40
|
s = readRG ? vec4(vec3(s.r), s.g) : vec4(vec3(s.b), s.a);
|
|
41
41
|
return length(s) == 0.0 ? vec4(s.rgb, 1.0) : s;
|
|
42
|
-
}`),
|
|
42
|
+
}`),a.uniforms.add(new l("anchorPoint",(o=>o.clouds.parallax.anchorPoint)),new l("anchorPointNew",(o=>o.clouds.parallaxNew.anchorPoint)),new m("rotationClouds",(o=>o.clouds.parallax.transform)),new m("rotationCloudsNew",(o=>o.clouds.parallaxNew.transform)),new s("cloudsOpacity",(o=>o.clouds.opacity)),new s("fadeFactor",(o=>o.clouds.fadeFactor)),new n("crossFade",(o=>o.clouds.fadeState===r.CROSS_FADE))).code.add(u`vec4 renderClouds(vec3 worldRay, vec3 cameraPosition) {
|
|
43
43
|
vec3 intersectionPoint = intersectWithCloudLayer(worldRay, cameraPosition, anchorPoint);
|
|
44
44
|
vec3 worldRayRotated = rotateDirectionToAnchorPoint(rotationClouds, normalize(intersectionPoint));
|
|
45
45
|
vec3 worldRayRotatedCorrected = correctForPlanetCurvature(worldRayRotated);
|
|
@@ -58,4 +58,4 @@ float totalTransmittance = length(cloudColor.rgb) == 0.0 ?
|
|
|
58
58
|
1.0 :
|
|
59
59
|
clamp(cloudColor.a * cloudsOpacity + (1.0 - cloudsOpacity), 0.0 , 1.0);
|
|
60
60
|
return vec4(cloudColor.rgb, totalTransmittance);
|
|
61
|
-
}`)}const
|
|
61
|
+
}`)}const p=(t.radius+a)**2;export{C as CloudsParallaxShading};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{glsl as r}from"../../shaderModules/glsl.js";function e(e){e.fragment.code.add(r`vec4 lookupCubemapFromTextureArray(sampler2DArray cubeMap, vec3 rayDir) {
|
|
6
|
+
int faceIndex;
|
|
7
|
+
vec2 uv;
|
|
8
|
+
if (abs(rayDir.x) >= abs(rayDir.y) && abs(rayDir.x) >= abs(rayDir.z)) {
|
|
9
|
+
if(rayDir.x > 0.0) {
|
|
10
|
+
faceIndex = 0;
|
|
11
|
+
uv = rayDir.yz / rayDir.x;
|
|
12
|
+
uv = vec2(-uv.y, -uv.x);
|
|
13
|
+
} else {
|
|
14
|
+
faceIndex = 1;
|
|
15
|
+
uv = rayDir.yz / rayDir.x;
|
|
16
|
+
uv = vec2(-uv.y, uv.x);
|
|
17
|
+
}
|
|
18
|
+
} else if (abs(rayDir.y) >= abs(rayDir.x) && abs(rayDir.y) >= abs(rayDir.z)) {
|
|
19
|
+
if(rayDir.y > 0.0) {
|
|
20
|
+
faceIndex = 2;
|
|
21
|
+
uv = rayDir.xz / rayDir.y;
|
|
22
|
+
} else {
|
|
23
|
+
faceIndex = 3;
|
|
24
|
+
uv = rayDir.xz / rayDir.y;
|
|
25
|
+
uv = vec2(-uv.x, uv.y);
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
if(rayDir.z > 0.0) {
|
|
29
|
+
faceIndex = 4;
|
|
30
|
+
uv = rayDir.xy / rayDir.z;
|
|
31
|
+
uv = vec2(uv.x, -uv.y);
|
|
32
|
+
} else {
|
|
33
|
+
return vec4(0.0, 0.0, 0.0, 1.0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
uv = 0.5 * (uv + 1.0);
|
|
37
|
+
vec4 s = texture(cubeMap, vec3(uv, float(faceIndex)));
|
|
38
|
+
return s;
|
|
39
|
+
}`)}export{e as LookupCubemapFromTextureArray};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{BindType as r}from"../../../../webgl/BindType.js";import{Uniform as e}from"../../../../webgl/Uniform.js";class o extends e{constructor(e,o){super(e,"sampler2DArray",r.Bind,((r,s)=>r.bindTexture(e,o(s))))}}export{o as Texture2DArrayBindUniform};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment as n,PixelFormat as h,PixelType as o,DepthStencilAttachment as c,FramebufferTarget as a,TextureType as u,Usage as _,BufferType as f,RenderbufferFormat as l}from"./enums.js";import{GLObjectType as T}from"./GLObjectType.js";import{Renderbuffer as d}from"./Renderbuffer.js";import{Texture as m}from"./Texture.js";const p=()=>t.getLogger("esri.views.webgl.FramebufferObject");class x{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this);const r=E(e)?e:new m(this._context,e);if(this._colorAttachments.set(n.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(n.COLOR_ATTACHMENT0),null!=i)if(b(i))this._depthStencilTexture=E(i)?i:new m(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=g(i)?i:new d(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(n.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(n.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.usedMemory),this.depthStencil?.usedMemory??0)}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&E(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=n.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=n.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=n.COLOR_ATTACHMENT0){const i=this._colorAttachments.get(e);i&&this._framebufferTexture2D(i.glName,e,t)}attachDepthStencil(t){if(t)switch(t.type){case T.Texture:return this._attachDepthStencilTexture(t);case T.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==h.DEPTH_STENCIL&&e.pixelFormat!==h.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==o.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,c)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,c),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);i.framebufferRenderbuffer(a.FRAMEBUFFER,r,i.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,n,h){(t<0||e<0||s<0||n<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const o=h.descriptor;h.descriptor.target!==u.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==o?.width||null==o?.height||t+i>this.width||e+r>this.height||s+i>o.width||n+r>o.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const c=this._context,a=c.bindTexture(h,m.TEXTURE_UNIT_FOR_UPDATES);c.setActiveTexture(m.TEXTURE_UNIT_FOR_UPDATES),c.bindFramebuffer(this),c.gl.copyTexSubImage2D(u.TEXTURE_2D,0,s,n,t,e,i,r),c.bindTexture(a,m.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,n,h){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),h||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,n,h)}async readPixelsAsync(t,e,r,s,n,h,o){const{gl:c}=this._context,a=i.createPixelPack(this._context,_.STREAM_READ,o.byteLength);this._context.bindBuffer(a);const u=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),c.readPixels(t,e,r,s,n,h,0),this._context.unbindBuffer(f.PIXEL_PACK_BUFFER),this._context.bindFramebuffer(u),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};A(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(A(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=a.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,S(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,S(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=n.COLOR_ATTACHMENT0,i=u.TEXTURE_2D,r=a.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(a.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==u.TEXTURE_2D&&t.target!==u.TEXTURE_CUBE_MAP&&console.error("Texture type must be TEXTURE_2D or TEXTURE_CUBE_MAP!"),A(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){A(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case l.DEPTH24_STENCIL8:case l.DEPTH32F_STENCIL8:case l.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case l.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===x._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;x._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const i=e-n.COLOR_ATTACHMENT0;i+1>x._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${x._MAX_COLOR_ATTACHMENTS} color attachments`)}}function E(t){return null!=t&&"type"in t&&t.type===T.Texture}function g(t){return null!=t&&"type"in t&&t.type===T.RenderBuffer}function b(t){return E(t)||null!=t&&"pixelFormat"in t}function A(t,e){const i=Math.max(t.width,t.height);if(i>e){p().warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function S(t){return t.descriptor.target===u.TEXTURE_CUBE_MAP?u.TEXTURE_CUBE_MAP_POSITIVE_X:u.TEXTURE_2D}export{x as FramebufferObject,A as ensureAttachmentMaxSize};
|
|
5
|
+
import"../../core/has.js";import t from"../../core/Logger.js";import{disposeMaybe as e}from"../../core/maybe.js";import{BufferObject as i}from"./BufferObject.js";import{webglDebugEnabled as r}from"./checkWebGLError.js";import{ResourceType as s,ColorAttachment as h,TextureType as n,FramebufferTarget as o,PixelFormat as c,PixelType as a,DepthStencilAttachment as _,Usage as f,BufferType as u,RenderbufferFormat as l}from"./enums.js";import{GLObjectType as T}from"./GLObjectType.js";import{Renderbuffer as d}from"./Renderbuffer.js";import{Texture as m}from"./Texture.js";const E=()=>t.getLogger("esri.views.webgl.FramebufferObject");class x{constructor(t,e,i=null){this._context=t,this._glName=null,this._colorAttachments=new Map,this._depthStencilBuffer=null,this._depthStencilTexture=null,this._initialized=!1,t.instanceCounter.increment(s.FramebufferObject,this);const r=p(e)?e:new m(this._context,e);if(this._colorAttachments.set(h.COLOR_ATTACHMENT0,r),this._validateTextureDescriptor(r.descriptor),this._validateColorAttachmentPoint(h.COLOR_ATTACHMENT0),null!=i)if(g(i))this._depthStencilTexture=p(i)?i:new m(this._context,i),this._validateTextureDescriptor(this._depthStencilTexture.descriptor);else{const t=A(i)?i:new d(this._context,i);this._depthStencilBuffer=t,this._validateRenderBufferDescriptor(t.descriptor)}}dispose(){if(0===this._colorAttachments.size&&!this._glName)return;const t=this._context.getBoundFramebufferObject();if(this._colorAttachments.forEach(((t,e)=>this.detachColorTexture(e)?.dispose())),this.detachDepthStencilBuffer()?.dispose(),this.detachDepthStencilTexture()?.dispose(),this._glName){this._context.gl.deleteFramebuffer(this._glName),this._glName=null}this._context.bindFramebuffer(t),this._context.instanceCounter.decrement(s.FramebufferObject,this)}get glName(){return this._glName}get colorTexture(){return this._colorAttachments.get(h.COLOR_ATTACHMENT0)}get depthStencil(){return this._depthStencilTexture||this._depthStencilBuffer}get depthStencilTexture(){return this._depthStencilTexture}get width(){const t=this._colorAttachments.get(h.COLOR_ATTACHMENT0);return t?.descriptor?.width??0}get height(){const t=this._colorAttachments.get(h.COLOR_ATTACHMENT0);return t?.descriptor?.height??0}get usedMemory(){return[...this._colorAttachments].reduce(((t,[e,i])=>t+i.usedMemory),this.depthStencil?.usedMemory??0)}static{this._MAX_COLOR_ATTACHMENTS=-1}getColorTexture(t){const e=this._colorAttachments.get(t);return e&&p(e)?e:null}get colorAttachments(){return[...this._colorAttachments.keys()]}attachColorTexture(t,e=h.COLOR_ATTACHMENT0){if(!t)return;this._validateColorAttachmentPoint(e);const i=t.descriptor;this._validateTextureDescriptor(i),this.detachColorTexture(e)?.dispose(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,e)),this._colorAttachments.set(e,t)}detachColorTexture(t=h.COLOR_ATTACHMENT0){const e=this._colorAttachments.get(t);if(e){if(this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t),this._context.bindFramebuffer(e)}return this._colorAttachments.delete(t),e}}setColorTextureTarget(t,e=h.COLOR_ATTACHMENT0,i=0){const r=this._colorAttachments.get(e);r&&(t===n.TEXTURE_2D_ARRAY?this._framebufferTextureLayer(r.glName,e,o.FRAMEBUFFER,0,i):this._framebufferTexture2D(r.glName,e,t,o.FRAMEBUFFER,0))}attachDepthStencil(t){if(t)switch(t.type){case T.Texture:return this._attachDepthStencilTexture(t);case T.RenderBuffer:return this._attachDepthStencilBuffer(t)}}_attachDepthStencilTexture(t){if(null==t)return;const e=t.descriptor;e.pixelFormat!==c.DEPTH_STENCIL&&e.pixelFormat!==c.DEPTH24_STENCIL8&&console.error("Depth/Stencil texture must have a pixel type of DEPTH_STENCIL!"),e.dataType!==a.UNSIGNED_INT_24_8&&console.error("Depth/Stencil texture must have data type of UNSIGNED_INT_24_8!"),this._validateTextureDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(t.glName,_)),this._depthStencilTexture?.dispose(),this._depthStencilTexture=t}detachDepthStencilTexture(){const t=this._depthStencilTexture;if(t&&this._initialized){const t=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),this._framebufferTexture2D(null,_),this._context.bindFramebuffer(t)}return this._depthStencilTexture=null,t}_attachDepthStencilBuffer(t){if(null==t)return;const e=t.descriptor;if(this._validateRenderBufferDescriptor(e),this._disposeDepthStencilAttachments(),this._initialized){this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(e);i.framebufferRenderbuffer(o.FRAMEBUFFER,r,i.RENDERBUFFER,t.glName)}this._depthStencilBuffer=t}detachDepthStencilBuffer(){const t=this._depthStencilBuffer;if(t&&this._initialized){const e=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this);const i=this._context.gl,r=this._getGLAttachmentPoint(t.descriptor);i.framebufferRenderbuffer(o.FRAMEBUFFER,r,i.RENDERBUFFER,null),this._context.bindFramebuffer(e)}return this._depthStencilBuffer=null,t}copyToTexture(t,e,i,r,s,h,o){(t<0||e<0||s<0||h<0)&&console.error("Offsets cannot be negative!"),(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!");const c=o.descriptor;o.descriptor.target!==n.TEXTURE_2D&&console.error("Texture target must be TEXTURE_2D!"),(null==c?.width||null==c?.height||t+i>this.width||e+r>this.height||s+i>c.width||h+r>c.height)&&console.error("Bad dimensions, the current input values will attempt to read or copy out of bounds!");const a=this._context,_=a.bindTexture(o,m.TEXTURE_UNIT_FOR_UPDATES);a.setActiveTexture(m.TEXTURE_UNIT_FOR_UPDATES),a.bindFramebuffer(this),a.gl.copyTexSubImage2D(n.TEXTURE_2D,0,s,h,t,e,i,r),a.bindTexture(_,m.TEXTURE_UNIT_FOR_UPDATES)}readPixels(t,e,i,r,s,h,n){(i<=0||r<=0)&&console.error("Copy width and height must be greater than zero!"),n||console.error("Target memory is not initialized!"),this._context.bindFramebuffer(this),this._context.gl.readPixels(t,e,i,r,s,h,n)}async readPixelsAsync(t,e,r,s,h,n,o){const{gl:c}=this._context,a=i.createPixelPack(this._context,f.STREAM_READ,o.byteLength);this._context.bindBuffer(a);const _=this._context.getBoundFramebufferObject();this._context.bindFramebuffer(this),c.readPixels(t,e,r,s,h,n,0),this._context.unbindBuffer(u.PIXEL_PACK_BUFFER),this._context.bindFramebuffer(_),await a.getSubDataAsync(o),a.dispose()}resize(t,e){if(this.width===t&&this.height===e)return;const i={width:t,height:e};b(i,this._context.parameters.maxTextureSize),this._colorAttachments.forEach((t=>t.resize(i.width,i.height))),this._depthStencilTexture?.resize(i.width,i.height),this._initialized&&(b(i,this._context.parameters.maxRenderbufferSize),this._depthStencilBuffer?.resize(i.width,i.height),this._context.getBoundFramebufferObject()===this&&this._context.bindFramebuffer(null),this._initialized=!1)}initializeAndBind(t=o.FRAMEBUFFER){const e=this._context.gl;if(this._initialized)return void e.bindFramebuffer(t,this.glName);this._glName&&e.deleteFramebuffer(this._glName);const i=e.createFramebuffer();if(e.bindFramebuffer(t,i),this._colorAttachments.forEach(((e,i)=>this._framebufferTexture2D(e.glName,i,R(e),t))),this._depthStencilBuffer){const i=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);e.framebufferRenderbuffer(t,i,e.RENDERBUFFER,this._depthStencilBuffer.glName)}else this._depthStencilTexture&&this._framebufferTexture2D(this._depthStencilTexture.glName,e.DEPTH_STENCIL_ATTACHMENT,R(this._depthStencilTexture),t);if(r()){e.checkFramebufferStatus(t)!==e.FRAMEBUFFER_COMPLETE&&console.error("Framebuffer is incomplete!")}this._glName=i,this._initialized=!0}_framebufferTexture2D(t,e=h.COLOR_ATTACHMENT0,i=n.TEXTURE_2D,r=o.FRAMEBUFFER,s=0){this._context.gl.framebufferTexture2D(r,e,i,t,s)}_framebufferTextureLayer(t,e=h.COLOR_ATTACHMENT0,i=o.FRAMEBUFFER,r=0,s=0){this._context.gl.framebufferTextureLayer(i,e,t,r,s)}_disposeDepthStencilAttachments(){const t=this._context.gl;if(this._depthStencilBuffer){if(this._initialized){this._context.bindFramebuffer(this);const e=this._getGLAttachmentPoint(this._depthStencilBuffer.descriptor);t.framebufferRenderbuffer(o.FRAMEBUFFER,e,t.RENDERBUFFER,null)}this._depthStencilBuffer=e(this._depthStencilBuffer)}this._depthStencilTexture&&(this._initialized&&(this._context.bindFramebuffer(this),this._framebufferTexture2D(null,t.DEPTH_STENCIL_ATTACHMENT)),this._depthStencilTexture=e(this._depthStencilTexture))}_validateTextureDescriptor(t){t.target!==n.TEXTURE_2D&&t.target!==n.TEXTURE_CUBE_MAP&&t.target!==n.TEXTURE_2D_ARRAY&&console.error("Texture type must be TEXTURE_2D, TEXTURE_2D_ARRAY or TEXTURE_CUBE_MAP!"),b(t,this._context.parameters.maxTextureSize),this._validateBufferDimensions(t)}_validateRenderBufferDescriptor(t){b(t,this._context.parameters.maxRenderbufferSize),this._validateBufferDimensions(t)}_validateBufferDimensions(t){t.width<=0&&(t.width=this.width),t.height<=0&&(t.height=this.height),this.width>0&&this.height>0&&(this.width===t.width&&this.height===t.height||console.error("Attachment size must match framebuffer size!"))}_getGLAttachmentPoint(t){switch(t.internalFormat){case l.DEPTH_COMPONENT16:case l.DEPTH_COMPONENT24:case l.DEPTH_COMPONENT32F:return this._context.gl.DEPTH_ATTACHMENT;case l.DEPTH24_STENCIL8:case l.DEPTH32F_STENCIL8:case l.DEPTH_STENCIL:return this._context.gl.DEPTH_STENCIL_ATTACHMENT;case l.STENCIL_INDEX8:return this._context.gl.STENCIL_ATTACHMENT}}_validateColorAttachmentPoint(e){if(-1===x._MAX_COLOR_ATTACHMENTS){const{gl:t}=this._context;x._MAX_COLOR_ATTACHMENTS=t.getParameter(t.MAX_COLOR_ATTACHMENTS)}const i=e-h.COLOR_ATTACHMENT0;i+1>x._MAX_COLOR_ATTACHMENTS&&t.getLogger("esri.views.webgl.FrameBufferObject").error("esri.FrameBufferObject",`illegal attachment point for color attachment: ${i+1}. Implementation supports up to ${x._MAX_COLOR_ATTACHMENTS} color attachments`)}}function p(t){return null!=t&&"type"in t&&t.type===T.Texture}function A(t){return null!=t&&"type"in t&&t.type===T.RenderBuffer}function g(t){return p(t)||null!=t&&"pixelFormat"in t}function b(t,e){const i=Math.max(t.width,t.height);if(i>e){E().warn(`Resizing FBO attachment size ${t.width}x${t.height} to device limit ${e}`);const r=e/i;return t.width=Math.round(t.width*r),t.height=Math.round(t.height*r),!1}return!0}function R(t){return t.descriptor.target===n.TEXTURE_CUBE_MAP?n.TEXTURE_CUBE_MAP_POSITIVE_X:t.descriptor.target===n.TEXTURE_2D_ARRAY?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}export{x as FramebufferObject,b as ensureAttachmentMaxSize};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,
|
|
5
|
+
import e from"../../core/Error.js";import"../../core/has.js";import t from"../../core/Logger.js";import{BindType as r}from"./BindType.js";const n=()=>t.getLogger("esri.views.3d.webgl-engine.core.shaderModules.shaderBuilder");class s{constructor(){this._includedModules=new Map}include(e,t){this._includedModules.has(e)?this._includedModules.get(e):(this._includedModules.set(e,t),e(this.builder,t))}}class i extends s{constructor(){super(...arguments),this.vertex=new u,this.fragment=new u,this.attributes=new h,this.varyings=new m,this.extensions=new _,this.outputs=new d}get fragmentUniforms(){return this.fragment.uniforms.entries}get builder(){return this}generate(e,t=!1){const r=this.extensions.generateSource(e),n=this.attributes.generateSource(e),s=this.varyings.generateSource(e),i="vertex"===e?this.vertex:this.fragment,a=i.uniforms.generateSource(),o=i.code.generateSource(),c=i.main.generateSource(t),u="vertex"===e?p:g,h=i.constants.generateSource(),m=this.outputs.generateSource(e);return`#version 300 es\n${r.join("\n")}\n${u}\n${h.join("\n")}\n${a.join("\n")}\n${n.join("\n")}\n${s.join("\n")}\n${m.join("\n")}\n${o.join("\n")}\n${c.join("\n")}`}generateBind(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Bind];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return t=>{for(let r=0;r<s;++r)n[r](e,t)}}generateBindPass(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Pass];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r)=>{for(let i=0;i<s;++i)n[i](e,t,r)}}generateBindDraw(e){const t=new Map;this.vertex.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)})),this.fragment.uniforms.entries.forEach((e=>{const n=e.bind[r.Draw];n&&t.set(e.name,n)}));const n=Array.from(t.values()),s=n.length;return(t,r,i)=>{for(let a=0;a<s;++a)n[a](e,i,t,r)}}}class a{constructor(e){this._stage=e,this._entries=new Map}add(...e){for(const t of e)this._add(t);return this._stage}get(e){return this._entries.get(e)}_add(t){if(null!=t){if(this._entries.has(t.name)&&!this._entries.get(t.name).equals(t))throw new e(`Duplicate uniform name ${t.name} for different uniform type`);this._entries.set(t.name,t)}else n().error(`Trying to add null Uniform from ${(new Error).stack}.`)}generateSource(){return Array.from(this._entries.values()).map((e=>null!=e.arraySize?`uniform ${e.type} ${e.name}[${e.arraySize}];`:`uniform ${e.type} ${e.name};`))}get entries(){return Array.from(this._entries.values())}}class o{constructor(e){this._stage=e,this._bodies=new Array}add(e){return this._bodies.push(e),this._stage}generateSource(t){if(this._bodies.length>0)return[`void main() {\n ${this._bodies.join("\n")||""} \n}`];if(t)throw new e("Shader does not contain main function body.");return[]}}class c{constructor(e){this._stage=e,this._entries=new Array}add(e){return this._entries.push(e),this._stage}generateSource(){return this._entries}}class u extends s{constructor(){super(...arguments),this.uniforms=new a(this),this.main=new o(this),this.code=new c(this),this.constants=new l(this)}get builder(){return this}}class h{constructor(){this._entries=new Array}add(e,t){this._entries.push([e,t])}generateSource(e){return"fragment"===e?[]:this._entries.map((e=>`in ${e[1]} ${e[0]};`))}}class m{constructor(){this._entries=new Map}add(e,t,r){this._entries.has(e)?n().warn(`Ignoring duplicate varying ${t} ${e}`):this._entries.set(e,{type:t,invariant:r?.invariant??!1})}generateSource(e){const t=new Array;return this._entries.forEach(((r,n)=>t.push((r.invariant&&"vertex"===e?"invariant ":"")+("vertex"===e?"out":"in")+` ${r.type} ${n};`))),t}}class _{constructor(){this._entries=new Set}add(e){this._entries.add(e)}generateSource(e){const t="vertex"===e?_.ALLOWLIST_VERTEX:_.ALLOWLIST_FRAGMENT;return Array.from(this._entries).filter((e=>t.includes(e))).map((e=>`#extension ${e} : enable`))}static{this.ALLOWLIST_FRAGMENT=["GL_EXT_shader_texture_lod","GL_OES_standard_derivatives"]}static{this.ALLOWLIST_VERTEX=[]}}class d{constructor(){this._entries=new Map}add(e,t,r=0){const s=this._entries.get(r);s?.name!==e||s?.type!==t?this._entries.set(r,{name:e,type:t}):n().warn(`Fragment shader output location ${r} occupied`)}static{this.DEFAULT_TYPE="vec4"}static{this.DEFAULT_NAME="fragColor"}generateSource(e){if("vertex"===e)return[];0===this._entries.size&&this._entries.set(0,{name:d.DEFAULT_NAME,type:d.DEFAULT_TYPE});const t=new Array;return this._entries.forEach(((e,r)=>t.push(`layout(location = ${r}) out ${e.type} ${e.name};`))),t}}class l{constructor(e){this._stage=e,this._entries=new Set}add(e,t,r){let n="ERROR_CONSTRUCTOR_STRING";switch(t){case"float":n=l._numberToFloatStr(r);break;case"int":n=l._numberToIntStr(r);break;case"bool":n=r.toString();break;case"vec2":n=`vec2(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])})`;break;case"vec3":n=`vec3(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])})`;break;case"vec4":n=`vec4(${l._numberToFloatStr(r[0])}, ${l._numberToFloatStr(r[1])}, ${l._numberToFloatStr(r[2])}, ${l._numberToFloatStr(r[3])})`;break;case"ivec2":n=`ivec2(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])})`;break;case"ivec3":n=`ivec3(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])})`;break;case"ivec4":n=`ivec4(${l._numberToIntStr(r[0])}, ${l._numberToIntStr(r[1])}, ${l._numberToIntStr(r[2])}, ${l._numberToIntStr(r[3])})`;break;case"mat2":case"mat3":case"mat4":n=`${t}(${Array.prototype.map.call(r,(e=>l._numberToFloatStr(e))).join(", ")})`}return this._entries.add(`const ${t} ${e} = ${n};`),this._stage}static _numberToIntStr(e){return e.toFixed(0)}static _numberToFloatStr(e){return Number.isInteger(e)?e.toFixed(1):e.toString()}generateSource(){return Array.from(this._entries)}}const g="#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n precision highp sampler2DArray;\n#else\n precision mediump float;\n precision mediump int;\n precision mediump sampler2D;\n precision mediump sampler2DArray;\n#endif",p="precision highp float;\n precision highp sampler2D;\n precision highp sampler2DArray;\n \n invariant gl_Position;\n ";export{c as Code,s as Includes,o as Main,i as ShaderBuilder,u as Stage,a as Uniforms};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as u}from"../../layers/support/layerUtils.js";import m from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,findSpatialReference as R,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as W}from"./resourceUtils.js";import{beforeSave as P,evaluateWriteErrors as S}from"./saveUtils.js";const I=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function A(e,t,r){r??={},U(e,t),await o((()=>!t.updatingFromView)),await t.load(),await E(t),await P(t),await M(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a);return S(n,{errorName:`${e.name}:save`},r),await V(t,a),await ye(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),W(t.resourceReferences,n)]),a}async function O(e,t){const
|
|
5
|
+
import e from"../../core/Error.js";import{MultiOriginJSONSupport as t}from"../../core/MultiOriginJSONSupport.js";import{whenOnce as o}from"../../core/reactiveUtils.js";import{hasSameCanonicalPortal as r,urlToObject as a}from"../../core/urlUtils.js";import{updateOrigins as i}from"../../core/accessorSupport/originUtils.js";import n from"../../geometry/SpatialReference.js";import{equals as s}from"../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as u}from"../../layers/support/layerUtils.js";import m from"../../portal/Portal.js";import f from"../../portal/PortalItem.js";import{createForItemWrite as d}from"../../portal/support/jsonContext.js";import{typeKeyword as w,removeTypeKeyword as y,addTypeKeyword as h,hasTypeKeyword as g}from"../../portal/support/portalItemUtils.js";import{project as _}from"../../rest/geometryService/project.js";import b from"../../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as j,findSpatialReference as R,isDeveloperBasemapLayer as v}from"../../support/basemapUtils.js";import{saveResources as W}from"./resourceUtils.js";import{beforeSave as P,evaluateWriteErrors as S}from"./saveUtils.js";const I=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function A(e,t,r){r??={},U(e,t),await o((()=>!t.updatingFromView)),await t.load(),await E(t),await P(t),await M(e,t);const a=t.portalItem,{json:i,jsonContext:n}=await O(t,a,e.origin);return S(n,{errorName:`${e.name}:save`},r),await V(t,a),await ye(e,t,a,i,n),await Promise.all([t.updateItemThumbnail(),W(t.resourceReferences,n)]),a}async function O(e,t,o){const r=d(t,o,!0),a=e.write({},r);return await Promise.all(r.resources.pendingOperations),{json:a,jsonContext:r}}async function T(e,t,r,a){a??={};const i=D(e,r);await o((()=>!t.updatingFromView)),await t.load(),await E(t),await P(t),await M(e,t);const{json:n,jsonContext:s}=await O(t,i,e.origin);S(s,{errorName:`${e.name}:save`},a),await X(t,i);const l=t.getThumbnailState();return await he(e,t,i,n,s,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),W(t.resourceReferences,s)]),i}function U(t,o){if(!o.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");C(t,o.portalItem)}function C(t,o){if(o.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function M(t,r){if("linkchart"===t.name)return;if(!r.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await o((()=>{const e=R(r.initialViewProperties,r.basemap);return a=e.spatialReference,!e.updating})),!s(a,r.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:r.initialViewProperties.spatialReference,actual:a})}function D(e,t){let o=f.from(t);return o.id&&(o=o.clone(),o.id=null),o.type||(o.type=e.itemType),o.portal||(o.portal=m.getDefault()),C(e,o),o}function E(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function V(e,t){t.extent=await pe(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Y(e,t)}const k=w.JSAPI,x="CollectorDisabled",G="Collector",L="Data Editing",N="OfflineDisabled",$="Offline",B="Workforce Project",F="Workforce Worker",K="Workforce Dispatcher",H="Offline Map Areas",J="FieldMapsDisabled",q=w.DEVELOPER_BASEMAP,z="UtilityNetwork",Q="IPS";async function X(e,t){y(t,x),y(t,J),y(t,w.METADATA),y(t,N),y(t,H),y(t,K),y(t,B),y(t,F),await V(e,t)}async function Y(e,t){h(t,k),await Z(e),re(e,t),ae(e,t),ie(e,t),ne(e,t),se(e,t),le(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,o)=>o.indexOf(e)===t)))}function Z(e){const t=ee(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function ee(e){return e.allLayers.concat(e.allTables)}function te(e){return ee(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function oe(e){return ee(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&me(e,t)))}function re(e,t){g(t,x)||g(t,B)||g(t,F)||g(t,K)||!te(e)?y(t,G):h(t,G)}function ae(e,t){te(e)?h(t,L):y(t,L)}function ie(e,t){!g(t,N)&&oe(e)?h(t,$):y(t,$)}function ne(e,t){j(e.basemap)?h(t,q):y(t,q)}function se(e,t){e.utilityNetworks?.length?h(t,z):y(t,z)}function le(e,t){e.ipsInfo?h(t,Q):y(t,Q)}async function pe(e,t){const o=t.clone().normalize();let r;if(o.length>1)for(const a of o)r?a.width>r.width&&(r=a):r=a;else r=o[0];return ce(e,r)}async function ce(e,t){const o=t.spatialReference;if(o.isWGS84)return t.clone();if(o.isWebMercator)return l(t);const{getGeometryServiceURL:r}=await import("../../portal/support/geometryServiceUtils.js"),a=await r(e),i=new b({geometries:[t],outSpatialReference:n.WGS84});return(await _(a,i))[0]}function ue(e){return u(e)||"map-notes"===e.type||"route"===e.type}function me(e,t){return c(t)&&t.capabilities.operations.supportsSync||ue(t)&&!t.portalItem||fe(t)&&!de(t)&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function fe(e){return("tile"===e.type||"vector-tile"===e.type)&&(e.capabilities.operations.supportsExportTiles||we(e)||v(e))}function de(e){return"vector-tile"===e.type&&Object.keys(e.sourceNameToSource).length>1}function we(e){return"tile"===e.type&&(p(e.url)&&I.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function ye(e,t,o,r,a){await o.update({data:r}),be(e,t,o,r,a)}async function he(t,o,r,a,i,n){const s=o.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=r.portal;await p.signIn();const{copyAllowed:c,itemReloaded:u}=await ge(l,p);if(l.authenticated||=u,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m=await _e(r,l,a,n);return o.portalItem=r,be(t,o,r,a,i),m}async function ge(e,t){const{item:o,authenticated:r}=e;return o?.id&&o.typeKeywords?.includes("useOnly")?o.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(r||await o.reload(),{copyAllowed:"admin"===o.itemControl||"update"===o.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function _e(e,t,o,a){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=a;let p=!1;if(l&&n?.id&&r(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const r=e.toJSON();await e.load(),e.read(r),await e.update({data:o})}else await i.user.addItem({item:e,folder:s,data:o});return p}function be(e,o,r,n,s){t.prototype.read.call(o,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:r.itemUrl?a(r.itemUrl):void 0}),i(s),o.resourceInfo=n}export{O as createJSON,_e as initializeNewItem,ge as isCopyAllowed,A as save,T as saveAs};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import{clone as t}from"../../core/lang.js";import{getDeepValue as n}from"../../core/object.js";import{numberToJSON as r}from"../../core/accessorSupport/extensions/serializableProperty/writer.js";import{isFeatureCollectionLayer as i}from"../../layers/support/layerUtils.js";const o=new Set(["bing-maps","imagery","imagery-tile","map-image","open-street-map","tile","unknown","unsupported","vector-tile","web-tile","wcs","wms","wmts"]),l=new Set(["catalog","csv","feature","geo-rss","geojson","group","imagery","imagery-tile","kml","knowledge-graph","map-image","map-notes","media","ogc-feature","oriented-imagery","route","stream","subtype-group","tile","unknown","unsupported","vector-tile","web-tile","wcs","wfs","wms","wmts"]);function
|
|
5
|
+
import e from"../../core/Error.js";import{clone as t}from"../../core/lang.js";import{getDeepValue as n}from"../../core/object.js";import{numberToJSON as r}from"../../core/accessorSupport/extensions/serializableProperty/writer.js";import{isFeatureCollectionLayer as i}from"../../layers/support/layerUtils.js";const o=new Set(["bing-maps","imagery","imagery-tile","map-image","open-street-map","tile","unknown","unsupported","vector-tile","web-tile","wcs","wms","wmts"]),l=new Set(["catalog","csv","feature","geo-rss","geojson","group","imagery","imagery-tile","kml","knowledge-graph","map-image","map-notes","media","ogc-feature","oriented-imagery","route","stream","subtype-group","tile","unknown","unsupported","vector-tile","web-tile","wcs","wfs","wms","wmts"]),a=new Set([...l,"link-chart"]);function s(e){o.delete(e),l.delete(e)}function c(e){o.add(e),l.add(e)}function u(e){switch(e.layerContainerType){case"basemap":return o;case"operational-layers":return"link-chart"===e.origin?a:l;default:return null}}function d(e,t){if(t.restrictedWebMapWriting){const n=u(t);return null==n||n.has(e.type)&&!i(e)}return!0}function p(e,t){if(t)if(i(e)){const r=n("featureCollection.layers",t),i=r?.[0]?.layerDefinition;i&&m(e,i)}else"group"!==e.type&&m(e,t)}function m(e,t){"maxScale"in e&&(t.maxScale=r(e.maxScale)??void 0),"minScale"in e&&(t.minScale=r(e.minScale)??void 0)}function f(e,t){if(p(e,t),t&&(t.id=e.id,"blendMode"in e&&(t.blendMode=e.blendMode,"normal"===t.blendMode&&delete t.blendMode),t.opacity=r(e.opacity)??void 0,t.title=e.title||"Layer",t.visibility=e.visible,"legendEnabled"in e&&"wmts"!==e.type))if(i(e)){const n=t.featureCollection;n&&(n.showLegend=e.legendEnabled)}else t.showLegend=e.legendEnabled}function g(n,r,o){if(!n.persistenceEnabled)return null;if(!("write"in n)||!n.write)return o?.messages&&o.messages.push(new e("layer:unsupported",`Layers (${n.title}, ${n.id}) of type '${n.declaredClass}' cannot be persisted`,{layer:n})),null;if(i(n)&&!n.isTable)r=n.resourceInfo;else if(d(n,o)){const e={};return n.write(e,o)?e:null}return null!=r&&f(n,r=t(r)),r}export{c as disableRestrictedWriting,s as enableRestrictedWriting,g as getLayerJSON};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/Extent.js";import _ from"../../geometry/SpatialReference.js";import{formatDate as I,convertDateFormatToIntlOptions as g}from"../../intl/date.js";import{getLanguage as O}from"../../intl/locale.js";import b from"../../portal/Portal.js";import x from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as P}from"../../portal/support/urlUtils.js";import{execute as S,getTasks as U}from"../../rest/print.js";import{formatJsonMap as E}from"../../rest/support/fileFormat.js";import{fromJSON as L}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as H}from"../../views/input/InputManager.js";import F from"../../views/overlay/BoxOverlayItem.js";import D from"./CustomTemplate.js";import A from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as R}from"./utils.js";const W=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(D);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=I(Date.now(),g("short-date"));"ar"===O()&&(i=""+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let $=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._customLayoutOptions=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=b.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new A}initialize(){this.addHandles([m((()=>[this.showPrintAreaEnabled,this.view]),(()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:C(new w,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await S(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleBarEnabled:f,scaleEnabled:v,title:T,width:w}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const _=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:T||""},outScale:y??0,scalePreserved:v});if(w&&(_.exportOptions.width=w),n&&(_.exportOptions.height=n),a&&(_.exportOptions.dpi=a),_.layoutOptions){d||(_.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)N(_,t,c);const i=t.scaleBar;for(const t of i)N(_,t,f);const s=t.legend;for(const t of s)N(_,t,d)}}return _}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new D({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:void 0;await this.templateOptions.applyTemplate(t,e,this._customLayoutOptions)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new D({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await U(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter((t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(L(t.layout)))))?.map((e=>{const i=D.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=P.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new x({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new x({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new D({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach(((t,e)=>{if(!o||o.includes(e)){const i=new D({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e))??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=await R(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=L(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some((e=>new RegExp(`\\b${e}\\b`,"i").test(t))))),s=(e.length?e:t.choiceList).map((t=>E.fromJSON(t))).filter(i),o=E.fromJSON(t.defaultValue),a=s.some((t=>new RegExp(`\\b${o}\\b`,"i").test(t)))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(L(t)))),o=(s.length?s:e).map(L).filter(i),a=L(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new F({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),H.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),H.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=W;break;case"error":e.strokeColor=V}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([v()],$.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],$.prototype,"_templateIdToCustomTemplate",void 0),t([v()],$.prototype,"allowedFormats",void 0),t([v()],$.prototype,"allowedLayouts",void 0),t([v({type:B})],$.prototype,"browseTemplates",void 0),t([v({type:B})],$.prototype,"defaultTemplates",void 0),t([v()],$.prototype,"error",void 0),t([v()],$.prototype,"extraParameters",void 0),t([v()],$.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],$.prototype,"effectivePrintServiceUrl",null),t([v()],$.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:_})],$.prototype,"outSpatialReference",void 0),t([v({type:b})],$.prototype,"portal",void 0),t([v()],$.prototype,"portalTemplateIds",void 0),t([v({type:B})],$.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],$.prototype,"defaultTemplate",void 0),t([v()],$.prototype,"showPrintAreaEnabled",void 0),t([v()],$.prototype,"printServiceUrl",void 0),t([v()],$.prototype,"printTimeout",void 0),t([v({readOnly:!0})],$.prototype,"state",null),t([v({readOnly:!0})],$.prototype,"templatesInfo",void 0),t([v()],$.prototype,"updateDelay",void 0),t([v()],$.prototype,"view",void 0),t([v()],$.prototype,"templateCustomTextElements",void 0),t([v({type:A})],$.prototype,"templateOptions",void 0),$=t([T("esri.widgets.Print.PrintViewModel")],$);const Q=$;export{Q as default};
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../request.js";import{isSome as i}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import l from"../../core/Loadable.js";import{isAbortError as n}from"../../core/promiseUtils.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as d,convertUnit as c,getMetersPerUnitForSR as y,inchesPerMeter as f}from"../../core/unitUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as T}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/Extent.js";import _ from"../../geometry/SpatialReference.js";import{formatDate as I,convertDateFormatToIntlOptions as g}from"../../intl/date.js";import{getLocaleParts as O}from"../../intl/locale.js";import b from"../../portal/Portal.js";import x from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as P}from"../../portal/support/urlUtils.js";import{execute as S,getTasks as U}from"../../rest/print.js";import{formatJsonMap as E}from"../../rest/support/fileFormat.js";import{fromJSON as L}from"../../rest/support/layoutTemplate.js";import j from"../../rest/support/PrintParameters.js";import k from"../../rest/support/PrintTemplate.js";import{getExtent as C}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as H}from"../../views/input/InputManager.js";import F from"../../views/overlay/BoxOverlayItem.js";import D from"./CustomTemplate.js";import A from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as R}from"./utils.js";const W=[30,144,255,255],M=[237,211,23,255],V=[216,48,32,255],q=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),z=/(\/GPServer\/).+/i,G=new a({inch:"inches",foot:"feet",yard:"yards",mile:"miles","nautical-mile":"nautical-miles",millimeter:"millimeters",centimeter:"centimeters",decimeter:"decimeters",meter:"meters",kilometer:"kilometers"}),B=s.ofType(D);function J(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find((t=>e in t))){const{customTextElements:e}=t.layoutOptions;let i=I(Date.now(),g("short-date"));"ar"===O()?.language&&(i=""+i),e.push({date:i})}}function N(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let $=class extends l{constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._customLayoutOptions=null,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new B,this.defaultTemplates=new B,this.error=null,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=b.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new B,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new A}initialize(){this.addHandles([m((()=>[this.showPrintAreaEnabled,this.view]),(()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))})),m((()=>[this.templateOptions.layout,this.templateOptions.layoutItem]),(()=>{this.loaded&&this._processTemplateOptions()}))])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach((e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach((e=>{const[i]=Object.entries(e)[0];t?.forEach((t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)}))}))}})),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async load(t){return this.addResolvingPromise(this._loadResources(t).catch((t=>this.error=t))),this}async print(t){const{view:e,extraParameters:i,updateDelay:s,outSpatialReference:a}=this;if(!e)throw new o("print:view-required","view is not set");J(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:C(new w,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:s,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.portalTemplateIds.includes(t.layoutItem.id)||this.browseTemplates.some((e=>e.layoutItem?.id===t.layoutItem?.id)));return await S(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new o("print:export-error","An error occurred while exporting the web map.",{error:p})}}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:s,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:u,legendEnabled:d,northArrowEnabled:c,scale:y,scaleBarEnabled:f,scaleEnabled:v,title:T,width:w}){if(!h&&!u)throw new o("print:layout-required","layout is not set");const _=new k({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:u,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:s,titleText:T||""},outScale:y??0,scalePreserved:v});if(w&&(_.exportOptions.width=w),n&&(_.exportOptions.height=n),a&&(_.exportOptions.dpi=a),_.layoutOptions){d||(_.layoutOptions.legendLayers=[]);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)N(_,t,c);const i=t.scaleBar;for(const t of i)N(_,t,f);const s=t.legend;for(const t of s)N(_,t,d)}}return _}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new D({type:"browse-template",layoutInfoTaskUrl:this._layoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(!t)return void this.templateOptions.reset();!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout?this.effectiveTemplateCustomTextElements[t.layout]:void 0;await this.templateOptions.applyTemplate(t,e,this._customLayoutOptions)}async _loadResources(t){if(this.destroyed)return;await this._loadUrls(t);const[e,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(e,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions(),this._updateOverLayItem()}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t&&!this.templateOptions.id)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new D({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find((t=>t.layout===this.templateOptions.layout))??this.printServiceTemplates.find((t=>t.layout===this.templateOptions.layout));await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new o("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),await this._updateLayoutInfoTaskUrl(this.effectivePrintServiceUrl);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,await this._updateLayoutInfoTaskUrl(s?.url||this.effectivePrintServiceUrl)}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new o("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _updateLayoutInfoTaskUrl(t,e){if(!t)return;const i=(await U(t,e)).find((t=>t.includes("Get Layout Templates Info")));i&&(this._layoutInfoTaskUrl=t.replace(z,`$1${encodeURI(i)}`))}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter((t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(L(t.layout)))))?.map((e=>{const i=D.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i}))??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=P.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&q.has(o);if(!e||s&&!a)return[];const r=new x({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new x({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map((t=>(this.portalTemplateIds.push(t.id),new D({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._layoutInfoTaskUrl}))))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach(((t,e)=>{if(!o||o.includes(e)){const i=new D({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}}))}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find((t=>t.layout===e))??this.printServiceTemplates.find((t=>t.layout===e))??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=await R(this._layoutInfoTaskUrl,void 0,t),i=new Map,s={};for(const o of e){const t=L(o.layoutTemplate);i.set(t,o),s[t]=o.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(s),i}async _getPrintServiceTemplatesInfo(t){let i;try{({data:i}=await e(this.effectivePrintServiceUrl,{...t,query:{f:"json"},timeout:this.printTimeout}))}catch(l){throw n(l)?l:new o("print:unavailable-service-info","Can't fetch templates info from service",{error:l})}const{parameters:s}=i,a=s.find((({name:t})=>"Format"===t)),r=s.find((({name:t})=>"Layout_Template"===t));return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const e="all"===this.allowedFormats?t.choiceList:t.choiceList.filter((t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some((e=>new RegExp(`\\b${e}\\b`,"i").test(t))))),s=(e.length?e:t.choiceList).map((t=>E.fromJSON(t))).filter(i),o=E.fromJSON(t.defaultValue),a=s.some((t=>new RegExp(`\\b${o}\\b`,"i").test(t)))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const e=t.choiceList.filter((t=>"map_only"!==t.toLowerCase())),s="all"===this.allowedLayouts?e:e.filter((t=>this.allowedLayouts.includes(L(t)))),o=(s.length?s:e).map(L).filter(i),a=L(t.defaultValue),r=o.includes(a)?a:o.find((t=>/(?=.*letter)(?=.*landscape)/i.test(t)))??o.find((t=>/(?=.*a4)(?=.*landscape)/i.test(t)))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new F({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m((()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded]),(()=>this._updateOverLayItem()),h),this.view?.on("drag",["Shift"],(t=>this._handleDrag(t)),H.WIDGET),this.view?.on("key-down",["Escape"],(()=>this._resetDrag()),H.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=G.fromJSON(s.toLowerCase()),e=o.unit;d(t)===d(e)?(n=c(i[0],t,e),p=c(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const e=l?Math.min(a/n,r/p):y(o)*f*t.dpi;n*=e,p*=e}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,u=m&&h?h/this.view.scale:1;if(e.boxWidth=n*u||a,e.boxHeight=p*u||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=M;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=M;break;case"ready":e.strokeColor=W;break;case"error":e.strokeColor=V}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([v()],$.prototype,"_serviceTemplateCustomTextElements",void 0),t([v()],$.prototype,"_templateIdToCustomTemplate",void 0),t([v()],$.prototype,"allowedFormats",void 0),t([v()],$.prototype,"allowedLayouts",void 0),t([v({type:B})],$.prototype,"browseTemplates",void 0),t([v({type:B})],$.prototype,"defaultTemplates",void 0),t([v()],$.prototype,"error",void 0),t([v()],$.prototype,"extraParameters",void 0),t([v()],$.prototype,"includeDefaultTemplates",void 0),t([v({readOnly:!0})],$.prototype,"effectivePrintServiceUrl",null),t([v()],$.prototype,"effectiveTemplateCustomTextElements",null),t([v({type:_})],$.prototype,"outSpatialReference",void 0),t([v({type:b})],$.prototype,"portal",void 0),t([v()],$.prototype,"portalTemplateIds",void 0),t([v({type:B})],$.prototype,"printServiceTemplates",void 0),t([v({readOnly:!0})],$.prototype,"defaultTemplate",void 0),t([v()],$.prototype,"showPrintAreaEnabled",void 0),t([v()],$.prototype,"printServiceUrl",void 0),t([v()],$.prototype,"printTimeout",void 0),t([v({readOnly:!0})],$.prototype,"state",null),t([v({readOnly:!0})],$.prototype,"templatesInfo",void 0),t([v()],$.prototype,"updateDelay",void 0),t([v()],$.prototype,"view",void 0),t([v()],$.prototype,"templateCustomTextElements",void 0),t([v({type:A})],$.prototype,"templateOptions",void 0),$=t([T("esri.widgets.Print.PrintViewModel")],$);const Q=$;export{Q as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{getAssetUrl as e}from"../../assets.js";import
|
|
5
|
+
import{getAssetUrl as e}from"../../assets.js";import{getLocaleParts as n}from"../../intl/locale.js";const s="en-wo";var r;!function(e){e.ar="ar",e.bg="bg",e.cs="cs",e.da="da",e.de="de",e.el="el",e.en="en",e.es="es",e.et="et",e.fi="fi",e.fr="fr",e.is="is",e.it="it",e.ja="ja",e.ko="ko",e.lt="lt",e.lv="lv",e.nl="nl",e.nn="nn",e.pl="pl",e.pt="pt",e.ro="ro",e.ru="ru",e.sk="sk",e.sv="sv",e.th="th",e.zh="zh"}(r||(r={}));const t={ae:r.en,ar:r.es,at:r.de,au:r.en,be:r.nl,bg:r.bg,bo:r.es,br:r.pt,ca:r.en,ch:r.de,ci:r.fr,cl:r.es,cn:r.zh,co:r.es,cr:r.es,cz:r.cs,de:r.de,dk:r.da,ee:r.et,eg:r.en,es:r.es,fi:r.fi,fr:r.fr,gb:r.en,gl:r.da,gr:r.el,gt:r.es,hk:r.en,id:r.en,ie:r.en,il:r.en,in:r.en,iq:r.ar,is:r.is,it:r.it,jp:r.ja,ke:r.en,kr:r.ko,kw:r.ar,li:r.de,lt:r.lt,lu:r.en,lv:r.lv,ma:r.fr,mg:r.fr,ml:r.fr,mo:r.en,mx:r.es,my:r.en,ni:r.es,nl:r.nl,no:r.nn,nz:r.en,pe:r.es,pl:r.pl,pr:r.es,pt:r.pt,ro:r.ro,ru:r.ru,rw:r.en,se:r.sv,sg:r.en,sk:r.sk,sr:r.nl,sv:r.es,th:r.th,tn:r.fr,tw:r.zh,us:r.en,ve:r.es,vi:r.en,wo:r.en,za:r.en},l=new Set(["ar-iq","ar-kw","bg-bg","cs-cz","da-dk","da-gl","de-at","de-ch","de-de","de-li","el-gr","en-ae","en-au","en-ca","en-eg","en-gb","en-hk","en-id","en-ie","en-il","en-in","en-iq","en-ke","en-lu","en-mo","en-my","en-nz","en-rw","en-sg","en-us","en-vi","en-wo","en-za","es-ar","es-bo","es-cl","es-co","es-cr","es-es","es-gt","es-mx","es-ni","es-pe","es-pr","es-sv","es-ve","et-ee","fi-fi","fr-ci","fr-fr","fr-ma","fr-mg","fr-ml","fr-tn","is-is","it-it","ja-jp","ko-kr","lt-lt","lv-lv","nl-be","nl-nl","nl-sr","nn-no","pl-pl","pt-br","pt-pt","ro-ro","ru-ru","sk-sk","sv-se","th-th","zh-cn","zh-tw"]);function i(e){return e.toLowerCase()}function a(n){return`url(${e(`esri/widgets/ScaleRangeSlider/images/scalePreview/${n}.jpg`)})`}function o(e){e=i(e);const r=`${n()?.language??"en"}-${e}`,o=`${t[e]}-${e}`;return a(l.has(r)?r:l.has(o)?o:s)}function c(e){const n=5,s=5;if(e<0||e>=n*s)return;return`-${128*(e%n)}px -${128*Math.floor(e/s)}px`}export{s as fallbackSpriteSheetFileName,o as getScalePreviewSource,c as getScalePreviewSpriteBackgroundPosition};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{deprecatedProperty as t}from"../../../core/deprecate.js";import
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{deprecatedProperty as t}from"../../../core/deprecate.js";import r from"../../../core/Evented.js";import{handlesGroup as o}from"../../../core/handleUtils.js";import s from"../../../core/Logger.js";import{removeMaybe as i}from"../../../core/maybe.js";import{watch as a}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{isKnowledgeGraphLayer as l,isLinkChartLayer as p}from"../../../layers/support/layerUtils.js";import{findLayerView as u}from"../../../views/draw/support/layerUtils.js";import{isSelectableLayerView2D as h}from"../../../views/support/layerViewUtils.js";import d from"../Selector2D/SelectionOperation.js";let m=class extends r.EventedAccessor{constructor(e){super(e),this._operationHandlesGroup=null,this.activeOperation=null,this.layerViewPreferenceEnabled=!0,this.sources=null}initialize(){this.addHandles([a((()=>this._sources),(e=>{this.activeOperation&&(this.activeOperation.sources=e)}))])}destroy(){this._operationHandlesGroup=i(this._operationHandlesGroup)}get _sources(){const{layerViewPreferenceEnabled:e,sources:t,view:r}=this;return r&&t?.length?t.flatMap((t=>{if(h(t))return t;if(l(t)||p(t)){const o=t.layers||[],s=o.map((t=>{const o=u(r,t)||void 0;return e&&h(o)?o:t}));return s.length?s.toArray():o.length?o.toArray():t}if(!e)return t;const o=u(r,t)||void 0;return h(o)?o:t})):[]}get layers(){return t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources}set layers(e){t(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.sources=e}get state(){const{_sources:e,view:t}=this,r=!e?.length&&!t?.selectionManager.sources.length;return this.activeOperation?"active":t?.ready&&!r?"ready":"disabled"}cancel(){"active"===this.state&&(this.activeOperation?.cancel(),this._set("activeOperation",null))}activate(e){const{_sources:t,state:r,view:s}=this,i=!t?.length&&!s?.selectionManager.sources.length;if("disabled"===r||i||!this.view)return;"active"===r&&this.cancel();const a=new d({view:this.view,sources:t,options:e});return this._operationHandlesGroup=o([a.selection.on("change",(e=>this.emit("selection-change",e))),a.once("complete",(e=>this._onOperationComplete(e)))]),this._set("activeOperation",a),a}_onOperationComplete(e){this._operationHandlesGroup=i(this._operationHandlesGroup),this._set("activeOperation",null),this.emit("complete",e)}};e([n()],m.prototype,"_sources",null),e([n({readOnly:!0})],m.prototype,"activeOperation",void 0),e([n()],m.prototype,"layers",null),e([n()],m.prototype,"layerViewPreferenceEnabled",void 0),e([n()],m.prototype,"sources",void 0),e([n({readOnly:!0})],m.prototype,"state",null),e([n()],m.prototype,"view",void 0),m=e([c("esri.widgets.support.SelectionToolbar.SelectionToolbarViewModel")],m);const v=m;export{v as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import{handlesGroup as t}from"../../core/handleUtils.js";import s from"../../core/Logger.js";import{removeMaybe as l}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import{cast as r}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import n from"../Widget.js";import{loadCalciteComponents as c}from"./componentsUtils.js";import{globalCss as d}from"./globalCss.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as h}from"./jsxFactory.js";import
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import{handlesGroup as t}from"../../core/handleUtils.js";import s from"../../core/Logger.js";import{removeMaybe as l}from"../../core/maybe.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import{cast as r}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import n from"../Widget.js";import{loadCalciteComponents as c}from"./componentsUtils.js";import{globalCss as d}from"./globalCss.js";import"./widgetUtils.js";import{messageBundle as p}from"./decorators/messageBundle.js";import{tsx as h}from"./jsxFactory.js";import u from"./SelectionToolbar/SelectionToolbarViewModel.js";const m={lassoTool:!0,rectangleTool:!0},v="esri-selection-toolbar",g={base:v,container:`${v}__container`,toolButton:`${v}__tool-button`};let T=class extends n{constructor(e,o){super(e,o),this._viewModelHandlesGroup=null,this.activeToolInfo=null,this.defaultLassoToolOptions={createTool:"polygon",mode:"freehand"},this.defaultRectangleToolOptions={createTool:"rectangle"},this.messages=null,this.toolConfigs=[],this.viewModel=new u,this.visibleElements={...m},this.scale="s",this.layout="horizontal",this._viewModelHandlesGroup=t([this.viewModel.on("complete",(e=>{this._set("activeToolInfo",null),this.emit("complete",e)}))])}destroy(){this._viewModelHandlesGroup=l(this._viewModelHandlesGroup)}loadDependencies(){return c({action:()=>import("@esri/calcite-components/dist/components/calcite-action")})}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layers(){return o(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources}set layers(e){o(s.getLogger(this),"layers",{replacement:"Use SelectionToolbar.sources instead."}),this.viewModel.sources=e}get layerViewPreferenceEnabled(){return this.viewModel.layerViewPreferenceEnabled}set layerViewPreferenceEnabled(e){this.viewModel.layerViewPreferenceEnabled=e}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...m,...e}}get state(){return this.viewModel.state}get visibleToolCount(){const{view:e,toolConfigs:o,visibleElements:t}=this;return(o?.length??0)+("2d"===e?.type?(t.lassoTool?1:0)+(t.rectangleTool?1:0):0)}activate(e){if(this.cancel(),"disabled"!==this.state)switch(e){case"lasso":this._activateTool("lasso");break;case"rectangle":this._activateTool("rectangle");break;default:this._activateTool(e)}}cancel(){this.viewModel.cancel(),this._set("activeToolInfo",null)}render(){return h("div",{"aria-label":this.label,class:this.classes(g.base,d.widget)},h("div",{class:g.container},this._renderDefaultTools(),this._renderCustomTools()))}_renderDefaultTools(){if("2d"===this.view?.type)return[this._renderRectangleTool(),this._renderLassoTool()]}_renderCustomTools(){if(this.toolConfigs?.length)return this.toolConfigs.map((({toolName:e,icon:o,toolKey:t})=>this._renderToolWithTooltip(e,t,o)))}_renderLassoTool(){const{messages:e,visibleElements:o}=this;if(!o.lassoTool)return;const t=e.selectByLasso;return this._renderToolWithTooltip("lasso","lasso","lasso-select",t)}_renderRectangleTool(){const{messages:e,visibleElements:o}=this;if(!o.rectangleTool)return;const t=e.selectByRectangle;return this._renderToolWithTooltip("rectangle","rectangle","cursor-marquee",t)}_renderToolWithTooltip(e,o,t,s=e){const l=`${this.id}-tool-${o}`;return h("calcite-action",{active:this.activeToolInfo?.toolName===e,bind:this,class:g.toolButton,disabled:"disabled"===this.state,icon:t||"selection",id:l,key:l,onclick:()=>this._toggleTool(e),scale:this.scale,text:s,title:s})}_activateTool(e){const o=this._getToolOptions(e);if(!o)return;const t=this.viewModel.activate(o);t&&this._set("activeToolInfo",{toolName:e,operation:t})}_toggleTool(e){if(this.activeToolInfo){const o=this.activeToolInfo.toolName;if(this.cancel(),o===e)return}this._activateTool(e)}_getToolOptions(e){return"lasso"===e?this.defaultLassoToolOptions:"rectangle"===e?this.defaultRectangleToolOptions:this.toolConfigs.find((o=>o.toolName===e))}};e([i({readOnly:!0})],T.prototype,"activeToolInfo",void 0),e([i()],T.prototype,"defaultLassoToolOptions",void 0),e([i()],T.prototype,"defaultRectangleToolOptions",void 0),e([i()],T.prototype,"label",null),e([i()],T.prototype,"layers",null),e([i()],T.prototype,"layerViewPreferenceEnabled",null),e([i(),p("esri/widgets/support/SelectionToolbar/t9n/SelectionToolbar")],T.prototype,"messages",void 0),e([i()],T.prototype,"sources",null),e([i()],T.prototype,"toolConfigs",void 0),e([i()],T.prototype,"view",null),e([i()],T.prototype,"viewModel",void 0),e([i()],T.prototype,"visibleElements",void 0),e([r("visibleElements")],T.prototype,"castVisibleElements",null),e([i()],T.prototype,"scale",void 0),e([i()],T.prototype,"state",null),e([i()],T.prototype,"layout",void 0),e([i()],T.prototype,"visibleToolCount",null),T=e([a("esri.widgets.support.SelectionToolbar")],T);const f=T;export{f as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import{createTask as o}from"../../../core/asyncUtils.js";import t from"../../../core/Collection.js";import s from"../../../core/Evented.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{debounce as i,ignoreAbortErrors as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{createTask as o}from"../../../core/asyncUtils.js";import t from"../../../core/Collection.js";import s from"../../../core/Evented.js";import{makeHandle as r}from"../../../core/handleUtils.js";import{debounce as i,ignoreAbortErrors as n,onAbort as c}from"../../../core/promiseUtils.js";import{createScreenPoint as l}from"../../../core/screenUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import m from"../../../geometry/Point.js";import d from"../../../geometry/Polygon.js";import{isClockwise as h}from"../../../geometry/support/coordsUtils.js";import{DrawScreenTool as u}from"../../../views/draw/DrawScreenTool.js";import{sketchKeys as y}from"../../../views/interactive/keybindings.js";import{getSelectionFromGeometry as g}from"./selectorUtils.js";const f=100;let v=class extends s.EventedAccessor{constructor(e){super(e),this._processTask=null,this.options=null,this.selection=new t,this.sources=null,this._process=i((async(e,t)=>{const{callback:s,selector:r,completed:i}=e,n=o((async e=>{const{options:o,sources:t,selection:n,view:c}=this;if(!(!t?.length&&!c?.selectionManager.sources.length)&&c){if(r&&null!=t){const s=await g({currentSelection:n,selector:r,signal:e,sources:t,view:c});i&&!1!==o?.persistSelection&&c.selectionManager?.updateSelection({current:n.toArray(),...s})}s&&s()}else n.removeAll()}));return c(t,(()=>n.abort())),this._processTask=n,n.promise}),f)}initialize(){this._setup()}cancel(){this.removeAllHandles(),this._processTask?.abort()}async _setup(){const{view:e}=this;if(await e.whenReady(),this.destroyed)return;const o=this.options,t=o?.createTool??"rectangle",s=o?.mode??("polygon"===t?"click":"hybrid"),i=Symbol();this._tool=new u({view:e,mode:s,geometryType:t}),o?.selectOnComplete||this.addHandles(this._tool.on(["cursor-update","vertex-add","vertex-remove"],(()=>n(this._process({selector:this._selectionArea})))),i),this.addHandles([e.on("key-down",(e=>{if(!e.repeat)switch(e.key){case y.constraint:this._tool.uniformSizeToggled=!0,e.stopPropagation();break;case y.center:this._tool.centeredToggled=!0,e.stopPropagation()}})),e.on("key-up",(e=>{switch(e.key){case y.constraint:this._tool.uniformSizeToggled=!1,e.stopPropagation();break;case y.center:this._tool.centeredToggled=!1,e.stopPropagation()}})),this._tool.on("complete",(async e=>{this.removeHandles(i);const o=()=>{this.removeAllHandles(),this.emit("complete",{aborted:e.aborted,selection:this.selection.toArray()})};e.aborted?(this.cancel(),this.selection.removeAll(),o()):await this._process({selector:this._selectionArea,callback:o,completed:!0})}))],i),this.addHandles(r((()=>e.tools.remove(this._tool)))),e.addAndActivateTool(this._tool)}get _selectionArea(){const e=l(),o=this._tool.coordinates,t=this.view.spatialReference,s=o=>{e.x=o[0],e.y=o[1];const{x:t,y:s}=this.view.toMap(e);return[t,s]};if(0===o.length)return;if(1===o.length||o.every((([e,t])=>e===o[0][0]&&t===o[0][1]))){const[e,r]=s(o[0]);return new m({x:e,y:r,spatialReference:t})}const r=o.map(s);if(0===r.length)return;h(r)||r.reverse();return new d({spatialReference:t,rings:[r]})}};e([a()],v.prototype,"options",void 0),e([a({readOnly:!0})],v.prototype,"selection",void 0),e([a()],v.prototype,"sources",void 0),e([a({constructOnly:!0})],v.prototype,"view",void 0),v=e([p("esri.widgets.support.Selector2D.SelectionOperation")],v);const w=v;export{w as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{whenOrAbort as e,ignoreAbortErrors as
|
|
5
|
+
import{whenOrAbort as e,ignoreAbortErrors as t}from"../../../core/promiseUtils.js";import{getDisplayFieldName as r}from"../../../layers/support/fieldUtils.js";import{isFeatureLayer as s,isKnowledgeGraphLayer as n,isLinkChartLayer as i,isMapNotesLayer as l,isGraphicsLayer as a,isSubtypeGroupLayer as o}from"../../../layers/support/layerUtils.js";import{calculateTolerance as u}from"../../../renderers/support/clickToleranceUtils.js";import{createQueryGeometry as c}from"../../../views/support/drapedUtils.js";import{isSelectableLayerView2D as d}from"../../../views/support/layerViewUtils.js";async function y(){return import("../../../geometry/geometryEngineJSON.js")}async function p(){return y().then((({contains:e,intersects:t,overlaps:r,simplify:s})=>({contains:e,intersects:t,overlaps:r,simplify:s})))}async function f(t){const{currentSelection:r,selector:s,signal:n,sources:i,view:l}=t;if(!i?.length)return{added:[],removed:[]};const{layers:a,layerViews:o,graphicsLayers:u}=F(i),c=(await e(Promise.all([g(s,a,l,n),h(s,o,l,n),m(s,u,l)]),n)).flat();if(!r)return{added:c,removed:[]};const d=r.toArray(),y=c.filter((e=>!v(d,e))),p=d.filter((e=>!v(c,e)));return r.removeMany(p),r.addMany(y),{added:y,removed:p}}const m=async(e,t,r)=>S({candidates:t.flatMap((e=>e.graphics.toArray()))??[],selector:e,view:r}),g=async(e,r,s,n)=>{const i=await t(b({selector:e,signal:n,layers:r,view:s}));return i?w(i):[]},h=async(e,r,s,n)=>{const i=await t(I({selector:e,signal:n,layerViews:r,view:s}));return i?w(i):[]};function w(e){const t=[];for(let r=0;r<e.length;r++){const s=e[r];"fulfilled"===s.status&&t.push(...s.value)}return t}function F(e){const t=[],r=[],o=[];return e.forEach((e=>{s(e)?t.push(e):(n(e)||i(e))&&e.layers?.length?t.push(...e.layers.toArray()):l(e)&&e.sublayers?.length?o.push(...e.sublayers.toArray()):a(e)?o.push(e):d(e)&&r.push(e)})),{layers:t,layerViews:r,graphicsLayers:o}}function v(e,t){if(e.includes(t))return!0;const r=t.getObjectId(),s=null!=r,{layer:n,uid:i}=t;return s?e.some((e=>{if(n===e.layer)return r===e.getObjectId()})):e.some((e=>{if(n===e.layer)return i===e.uid}))}async function I(t){const{layerViews:r,selector:s,signal:n,view:i}=t;return e(Promise.allSettled(r.map((async e=>{const t=e.createQuery(),{geometry:r}=j(s,e.layer,i);return t.outFields=["*"],t.geometry=r,t.returnGeometry=!0,t.outSpatialReference=i.spatialReference,e.queryFeatures(t,{signal:n}).then((({features:e})=>e))}))),n)}async function b(t){const{layers:r,selector:s,signal:n,view:i}=t;return e(Promise.allSettled(r.map((async e=>e.queryFeatures(x(e.createQuery(),s,e,i),{signal:n}).then((({features:e})=>e))))),n)}function j(e,t,s){const n="renderer"in t?u({renderer:t.renderer}):0,i="point"===e.type?c(e,n,s):e,l="displayField"in t?t.displayField:null,a=r({displayField:l,fields:t.fields}),d=[t.objectIdField];null!=a&&t.fieldsIndex.has(a)&&d.push(a),"globalIdField"in t&&null!=t.globalIdField&&t.fieldsIndex.has(t.globalIdField)&&d.push(t.fieldsIndex.get(t.globalIdField).name),o(t)&&null!=t.subtypeField&&t.fieldsIndex.has(t.subtypeField)&&d.push(t.fieldsIndex.get(t.subtypeField).name);if("utilityNetworks"in s.map&&s.map.utilityNetworks?.length&&(o(t)||"feature"===t.type)){const e=t.fieldsIndex.get("assetgroup"),r=t.fieldsIndex.get("assettype");e?.name&&d.push(e.name),r?.name&&d.push(r.name)}return{geometry:i,outFields:d}}function x(e,t,r,s){const{outFields:n,geometry:i}=j(t,r,s);return e.outFields=n,e.geometry=i,e.returnGeometry=!0,e.outSpatialReference=s.spatialReference,e}async function S(e){const{selector:t,candidates:r,view:s}=e;if(!r?.length||!t)return[];const{spatialReference:n}=s,i=t,l=await p();return r.filter((e=>e.geometry&&"mesh"!==e.geometry.type&&l.intersects(n,i,e.geometry)))}export{p as getGeometryEngineOperations,j as getQueryOptionsFromLayer,I as getSelectionFromFeatureLayerViews,b as getSelectionFromFeatureLayers,f as getSelectionFromGeometry,S as getSelectionFromGeometryEngine,y as importGeometryEngine};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import"../../chunks/Theme.js";export{c as createRoot}from"../../chunks/chartUtilsAm5.js";
|
|
5
|
+
import"../../intl.js";import"../../intl/locale.js";import"../../chunks/Theme.js";export{c as createRoot}from"../../chunks/chartUtilsAm5.js";
|