esri-gl 1.0.6 → 2.0.0
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/README.md +52 -2
- package/dist/{index-DczUYC4z.d.ts → index-Doq93o-G.d.ts} +252 -75
- package/dist/{IdentifyImage-DmyKcbAv.js → index-DsY1_0df.js} +825 -678
- package/dist/index-DsY1_0df.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +7181 -1017
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +5 -1
- package/dist/react-map-gl.d.ts +42 -13
- package/dist/react-map-gl.js +292 -304
- package/dist/react-map-gl.js.map +1 -1
- package/dist/react.d.ts +23 -28
- package/dist/react.js +202 -178
- package/dist/react.js.map +1 -1
- package/dist/{useFeatureService-E9PiUOLP.js → useFeatureService-BRY6PHUs.js} +50 -12
- package/dist/useFeatureService-BRY6PHUs.js.map +1 -0
- package/dist/{useFeatureService-QUqwJcet.d.ts → useFeatureService-CG70gjQy.d.ts} +29 -41
- package/package.json +8 -5
- package/dist/IdentifyImage-DmyKcbAv.js.map +0 -1
- package/dist/useFeatureService-E9PiUOLP.js.map +0 -1
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
-
import { D as DynamicMapService, d as TiledMapService, c as ImageService, e as VectorTileService, F as FeatureService } from './
|
|
2
|
+
import { D as DynamicMapService, d as TiledMapService, c as ImageService, e as VectorTileService, F as FeatureService } from './index-DsY1_0df.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Base hook for managing Esri services lifecycle
|
|
6
6
|
*/
|
|
7
|
-
function useEsriService(createService, map
|
|
7
|
+
function useEsriService(createService, map,
|
|
8
|
+
/**
|
|
9
|
+
* Values that, when changed, rebuild the service (and its source). Pass the
|
|
10
|
+
* service-defining options (e.g. `url`, `token`) so option changes are
|
|
11
|
+
* reflected; the base hook otherwise only rebuilds when `map` changes.
|
|
12
|
+
*/
|
|
13
|
+
deps = []) {
|
|
8
14
|
const [service, setService] = useState(null);
|
|
9
15
|
const [loading, setLoading] = useState(false);
|
|
10
16
|
const [error, setError] = useState(null);
|
|
@@ -81,7 +87,8 @@ function useEsriService(createService, map) {
|
|
|
81
87
|
clearTimeout(timeoutId);
|
|
82
88
|
if (retryTimeoutId) clearTimeout(retryTimeoutId);
|
|
83
89
|
};
|
|
84
|
-
|
|
90
|
+
// deps trigger a rebuild when service-defining options change.
|
|
91
|
+
}, [map, reload, ...deps]);
|
|
85
92
|
// Cleanup on unmount only
|
|
86
93
|
useEffect(() => {
|
|
87
94
|
return () => {
|
|
@@ -116,9 +123,12 @@ function useDynamicMapService({
|
|
|
116
123
|
sourceOptions
|
|
117
124
|
}) {
|
|
118
125
|
const optionsRef = useRef(options);
|
|
119
|
-
const createService = useCallback(mapInstance => new DynamicMapService(sourceId, mapInstance, options, sourceOptions),
|
|
120
|
-
);
|
|
121
|
-
|
|
126
|
+
const createService = useCallback(mapInstance => new DynamicMapService(sourceId, mapInstance, options, sourceOptions),
|
|
127
|
+
// url/token/apiKey changes need a fresh closure + rebuild (below); layers /
|
|
128
|
+
// layerDefs are applied in place by the effect, so they stay out of here.
|
|
129
|
+
[sourceId, sourceOptions, options.url, options.token, options.apiKey]);
|
|
130
|
+
// Rebuild the service when the url / auth changes.
|
|
131
|
+
const result = useEsriService(createService, map, [sourceId, options.url, options.token, options.apiKey]);
|
|
122
132
|
// Update service options when they change
|
|
123
133
|
useEffect(() => {
|
|
124
134
|
if (result.service && options !== optionsRef.current && map) {
|
|
@@ -162,11 +172,16 @@ function useTiledMapService({
|
|
|
162
172
|
options,
|
|
163
173
|
sourceOptions
|
|
164
174
|
}) {
|
|
165
|
-
return useEsriService(mapInstance => new TiledMapService(sourceId, mapInstance, options, sourceOptions), map);
|
|
175
|
+
return useEsriService(mapInstance => new TiledMapService(sourceId, mapInstance, options, sourceOptions), map, [sourceId, options.url, options.token, options.apiKey]);
|
|
166
176
|
}
|
|
167
177
|
|
|
168
178
|
/**
|
|
169
|
-
* Hook for managing ImageService lifecycle
|
|
179
|
+
* Hook for managing ImageService lifecycle.
|
|
180
|
+
*
|
|
181
|
+
* `useEsriService` only rebuilds when the `map` changes, so this hook reacts to
|
|
182
|
+
* service-defining option changes itself: a different `url`/`format` rebuilds
|
|
183
|
+
* the service (and its source), while `renderingRule`/`mosaicRule` changes are
|
|
184
|
+
* applied in place. (Pass a memoized `options` object.)
|
|
170
185
|
*/
|
|
171
186
|
function useImageService({
|
|
172
187
|
sourceId,
|
|
@@ -174,7 +189,30 @@ function useImageService({
|
|
|
174
189
|
options,
|
|
175
190
|
sourceOptions
|
|
176
191
|
}) {
|
|
177
|
-
|
|
192
|
+
const result = useEsriService(mapInstance => new ImageService(sourceId, mapInstance, options, sourceOptions), map);
|
|
193
|
+
const {
|
|
194
|
+
service,
|
|
195
|
+
reload
|
|
196
|
+
} = result;
|
|
197
|
+
const optionsRef = useRef(options);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
const prev = optionsRef.current;
|
|
200
|
+
if (prev === options) return;
|
|
201
|
+
optionsRef.current = options;
|
|
202
|
+
if (options.url !== prev.url || options.format !== prev.format) {
|
|
203
|
+
// A different service / format needs a fresh source.
|
|
204
|
+
reload();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!service) return;
|
|
208
|
+
if (options.renderingRule !== prev.renderingRule) {
|
|
209
|
+
service.setRenderingRule(options.renderingRule || {});
|
|
210
|
+
}
|
|
211
|
+
if (options.mosaicRule !== prev.mosaicRule) {
|
|
212
|
+
service.setMosaicRule(options.mosaicRule || {});
|
|
213
|
+
}
|
|
214
|
+
}, [options, service, reload]);
|
|
215
|
+
return result;
|
|
178
216
|
}
|
|
179
217
|
|
|
180
218
|
/**
|
|
@@ -186,7 +224,7 @@ function useVectorTileService({
|
|
|
186
224
|
options,
|
|
187
225
|
sourceOptions
|
|
188
226
|
}) {
|
|
189
|
-
return useEsriService(mapInstance => new VectorTileService(sourceId, mapInstance, options, sourceOptions), map);
|
|
227
|
+
return useEsriService(mapInstance => new VectorTileService(sourceId, mapInstance, options, sourceOptions), map, [sourceId, options.url, options.token, options.apiKey]);
|
|
190
228
|
}
|
|
191
229
|
|
|
192
230
|
/**
|
|
@@ -198,8 +236,8 @@ function useFeatureService({
|
|
|
198
236
|
options,
|
|
199
237
|
sourceOptions
|
|
200
238
|
}) {
|
|
201
|
-
return useEsriService(mapInstance => new FeatureService(sourceId, mapInstance, options, sourceOptions), map);
|
|
239
|
+
return useEsriService(mapInstance => new FeatureService(sourceId, mapInstance, options, sourceOptions), map, [sourceId, options.url, options.where, options.outFields, options.token, options.apiKey]);
|
|
202
240
|
}
|
|
203
241
|
|
|
204
242
|
export { useEsriService as a, useFeatureService as b, useImageService as c, useTiledMapService as d, useVectorTileService as e, useDynamicMapService as u };
|
|
205
|
-
//# sourceMappingURL=useFeatureService-
|
|
243
|
+
//# sourceMappingURL=useFeatureService-BRY6PHUs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFeatureService-BRY6PHUs.js","sources":["../src/react/hooks/useEsriService.ts","../src/react/hooks/useDynamicMapService.ts","../src/react/hooks/useTiledMapService.ts","../src/react/hooks/useImageService.ts","../src/react/hooks/useVectorTileService.ts","../src/react/hooks/useFeatureService.ts"],"sourcesContent":["import { useState, useEffect, useRef, useCallback } from 'react';\nimport type { UseEsriServiceResult } from '../types';\nimport type { Map } from '@/types';\n\n// Interface for services that can be removed\ninterface RemovableService {\n remove(): void;\n}\n\n/**\n * Base hook for managing Esri services lifecycle\n */\nexport function useEsriService<T extends RemovableService>(\n createService: (map: Map) => T,\n map: Map | null,\n /**\n * Values that, when changed, rebuild the service (and its source). Pass the\n * service-defining options (e.g. `url`, `token`) so option changes are\n * reflected; the base hook otherwise only rebuilds when `map` changes.\n */\n deps: ReadonlyArray<unknown> = []\n): UseEsriServiceResult<T> {\n const [service, setService] = useState<T | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n // Track if a service creation is in progress to prevent race conditions\n const isCreatingService = useRef(false);\n // Store the current service in a ref to avoid stale closure issues in cleanup\n const serviceRef = useRef<T | null>(null);\n // Track the createService function to detect changes\n const createServiceRef = useRef(createService);\n createServiceRef.current = createService;\n\n // Memoized reload function\n const reload = useCallback(() => {\n if (!map || isCreatingService.current) return;\n\n isCreatingService.current = true;\n setLoading(true);\n setError(null);\n\n try {\n // Clean up existing service using ref to avoid stale closure\n if (serviceRef.current) {\n try {\n serviceRef.current.remove();\n } catch (err) {\n // Log error but don't fail the reload\n if (process.env?.NODE_ENV !== 'test') {\n console.warn('Error removing existing service:', err);\n }\n }\n }\n\n // Create new service using the ref to get the latest createService\n const newService = createServiceRef.current(map);\n serviceRef.current = newService;\n setService(newService);\n } catch (err) {\n setError(err instanceof Error ? err : new Error('Failed to create service'));\n serviceRef.current = null;\n } finally {\n setLoading(false);\n isCreatingService.current = false;\n }\n }, [map]);\n\n // Initialize service when map becomes available\n useEffect(() => {\n if (!map) {\n // Clean up service when map is removed\n if (serviceRef.current) {\n try {\n serviceRef.current.remove();\n } catch (err) {\n if (process.env?.NODE_ENV !== 'test') {\n console.warn('Error removing service during cleanup:', err);\n }\n }\n serviceRef.current = null;\n }\n setService(null);\n return;\n }\n\n // Add a small delay to ensure map is fully initialized\n let retryTimeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeoutId = setTimeout(() => {\n // Check if map is still valid\n if (map && typeof map.addSource === 'function') {\n reload();\n } else {\n // If map is not ready, try again after a short delay\n retryTimeoutId = setTimeout(() => {\n if (map && typeof map.addSource === 'function') {\n reload();\n }\n }, 100);\n }\n }, 10);\n\n return () => {\n clearTimeout(timeoutId);\n if (retryTimeoutId) clearTimeout(retryTimeoutId);\n };\n // deps trigger a rebuild when service-defining options change.\n }, [map, reload, ...deps]);\n\n // Cleanup on unmount only\n useEffect(() => {\n return () => {\n // This cleanup function runs on unmount\n if (serviceRef.current) {\n try {\n serviceRef.current.remove();\n } catch (err) {\n if (process.env?.NODE_ENV !== 'test') {\n console.warn('Error removing service during cleanup:', err);\n }\n }\n serviceRef.current = null;\n }\n };\n }, []); // Empty dependency array - only run cleanup on unmount\n\n return {\n service,\n loading,\n error,\n reload,\n };\n}\n","import { useCallback, useEffect, useRef } from 'react';\nimport { useEsriService } from './useEsriService';\nimport { DynamicMapService } from '@/Services/DynamicMapService';\nimport type { UseDynamicMapServiceOptions, UseEsriServiceResult } from '../types';\nimport type { Map } from '@/types';\n\n/**\n * Hook for managing DynamicMapService lifecycle\n */\nexport function useDynamicMapService({\n sourceId,\n map,\n options,\n sourceOptions,\n}: UseDynamicMapServiceOptions): UseEsriServiceResult<DynamicMapService> {\n const optionsRef = useRef(options);\n\n const createService = useCallback(\n (mapInstance: Map) => new DynamicMapService(sourceId, mapInstance, options, sourceOptions),\n // url/token/apiKey changes need a fresh closure + rebuild (below); layers /\n // layerDefs are applied in place by the effect, so they stay out of here.\n [sourceId, sourceOptions, options.url, options.token, options.apiKey]\n );\n\n // Rebuild the service when the url / auth changes.\n const result = useEsriService(createService, map, [\n sourceId,\n options.url,\n options.token,\n options.apiKey,\n ]);\n\n // Update service options when they change\n useEffect(() => {\n if (result.service && options !== optionsRef.current && map) {\n // Add a small delay to ensure the service is fully initialized\n const timeoutId = setTimeout(() => {\n if (!result.service || !map) return;\n\n // Check for specific option changes that we can handle without recreation\n if (options.layers !== optionsRef.current.layers) {\n const layers = options.layers || [];\n if (Array.isArray(layers) || typeof layers === 'number') {\n try {\n result.service.setLayers(layers);\n } catch (error) {\n console.warn('useDynamicMapService: Error setting layers:', error);\n }\n }\n }\n\n if (options.layerDefs !== optionsRef.current.layerDefs) {\n const layerDefs = options.layerDefs || {};\n try {\n result.service.setLayerDefs(layerDefs);\n } catch (error) {\n console.warn('useDynamicMapService: Error setting layer definitions:', error);\n }\n }\n\n // Update the ref to track current options\n optionsRef.current = options;\n }, 50);\n\n return () => clearTimeout(timeoutId);\n }\n }, [result.service, options, map]);\n\n return result;\n}\n","import { useEsriService } from './useEsriService';\nimport { TiledMapService } from '@/Services/TiledMapService';\nimport type { UseTiledMapServiceOptions, UseEsriServiceResult } from '../types';\n\n/**\n * Hook for managing TiledMapService lifecycle\n */\nexport function useTiledMapService({\n sourceId,\n map,\n options,\n sourceOptions,\n}: UseTiledMapServiceOptions): UseEsriServiceResult<TiledMapService> {\n return useEsriService(\n mapInstance => new TiledMapService(sourceId, mapInstance, options, sourceOptions),\n map,\n [sourceId, options.url, options.token, options.apiKey]\n );\n}\n","import { useEffect, useRef } from 'react';\nimport { useEsriService } from './useEsriService';\nimport { ImageService } from '@/Services/ImageService';\nimport type { UseImageServiceOptions, UseEsriServiceResult } from '../types';\n\n/**\n * Hook for managing ImageService lifecycle.\n *\n * `useEsriService` only rebuilds when the `map` changes, so this hook reacts to\n * service-defining option changes itself: a different `url`/`format` rebuilds\n * the service (and its source), while `renderingRule`/`mosaicRule` changes are\n * applied in place. (Pass a memoized `options` object.)\n */\nexport function useImageService({\n sourceId,\n map,\n options,\n sourceOptions,\n}: UseImageServiceOptions): UseEsriServiceResult<ImageService> {\n const result = useEsriService(\n mapInstance => new ImageService(sourceId, mapInstance, options, sourceOptions),\n map\n );\n\n const { service, reload } = result;\n const optionsRef = useRef(options);\n\n useEffect(() => {\n const prev = optionsRef.current;\n if (prev === options) return;\n optionsRef.current = options;\n\n if (options.url !== prev.url || options.format !== prev.format) {\n // A different service / format needs a fresh source.\n reload();\n return;\n }\n\n if (!service) return;\n if (options.renderingRule !== prev.renderingRule) {\n service.setRenderingRule((options.renderingRule || {}) as Record<string, unknown>);\n }\n if (options.mosaicRule !== prev.mosaicRule) {\n service.setMosaicRule((options.mosaicRule || {}) as Record<string, unknown>);\n }\n }, [options, service, reload]);\n\n return result;\n}\n","import { useEsriService } from './useEsriService';\nimport { VectorTileService } from '@/Services/VectorTileService';\nimport type { UseVectorTileServiceOptions, UseEsriServiceResult } from '../types';\n\n/**\n * Hook for managing VectorTileService lifecycle\n */\nexport function useVectorTileService({\n sourceId,\n map,\n options,\n sourceOptions,\n}: UseVectorTileServiceOptions): UseEsriServiceResult<VectorTileService> {\n return useEsriService(\n mapInstance => new VectorTileService(sourceId, mapInstance, options, sourceOptions),\n map,\n [sourceId, options.url, options.token, options.apiKey]\n );\n}\n","import { useEsriService } from './useEsriService';\nimport { FeatureService } from '@/Services/FeatureService';\nimport type { UseFeatureServiceOptions, UseEsriServiceResult } from '../types';\n\n/**\n * Hook for managing FeatureService lifecycle\n */\nexport function useFeatureService({\n sourceId,\n map,\n options,\n sourceOptions,\n}: UseFeatureServiceOptions): UseEsriServiceResult<FeatureService> {\n return useEsriService(\n mapInstance => new FeatureService(sourceId, mapInstance, options, sourceOptions),\n map,\n [sourceId, options.url, options.where, options.outFields, options.token, options.apiKey]\n );\n}\n"],"names":["useEsriService","createService","map","deps","service","setService","useState","loading","setLoading","error","setError","isCreatingService","useRef","serviceRef","createServiceRef","current","reload","useCallback","remove","err","process","env","NODE_ENV","console","warn","newService","Error","useEffect","retryTimeoutId","timeoutId","setTimeout","addSource","clearTimeout","useDynamicMapService","sourceId","options","sourceOptions","optionsRef","mapInstance","DynamicMapService","url","token","apiKey","result","layers","Array","isArray","setLayers","layerDefs","setLayerDefs","useTiledMapService","TiledMapService","useImageService","ImageService","prev","format","renderingRule","setRenderingRule","mosaicRule","setMosaicRule","useVectorTileService","VectorTileService","useFeatureService","FeatureService","where","outFields"],"mappings":";;;AASA;;AAEG;AACG,SAAUA,cAAcA,CAC5BC,aAA8B,EAC9BC,GAAe;AACf;;;;AAIG;AACHC,IAAA,GAA+B,EAAE,EAAA;EAEjC,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,QAAQ,CAAW,IAAI,CAAC;EACtD,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGF,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM,CAACG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Aa,IAAI,EAA8B,CAAC;AACpF,IAAA;AACA,IAAA,IAAIrB,OAAO,CAACuB,UAAU,KAAKJ,IAAI,CAACI,UAAU,EAAE;MAC1CtD,OAAO,CAACuD,aAAa,CAAExB,OAAO,CAACuB,UAAU,IAAI,EAA8B,CAAC;AAC9E,IAAA;EACF,CAAC,EAAE,CAACvB,OAAO,EAAE/B,OAAO,EAAEY,MAAM,CAAC,CAAC;AAE9B,EAAA,OAAO2B,MAAM;AACf;;AC5CA;;AAEG;AACG,SAAUiB,oBAAoBA,CAAC;EACnC1B,QAAQ;EACRhC,GAAG;EACHiC,OAAO;AACPC,EAAAA;AAAa,CACe,EAAA;AAC5B,EAAA,OAAOpC,cAAc,CACnBsC,WAAW,IAAI,IAAIuB,iBAAiB,CAAC3B,QAAQ,EAAEI,WAAW,EAAEH,OAAO,EAAEC,aAAa,CAAC,EACnFlC,GAAG,EACH,CAACgC,QAAQ,EAAEC,OAAO,CAACK,GAAG,EAAEL,OAAO,CAACM,KAAK,EAAEN,OAAO,CAACO,MAAM,CAAC,CACvD;AACH;;ACdA;;AAEG;AACG,SAAUoB,iBAAiBA,CAAC;EAChC5B,QAAQ;EACRhC,GAAG;EACHiC,OAAO;AACPC,EAAAA;AAAa,CACY,EAAA;AACzB,EAAA,OAAOpC,cAAc,CACnBsC,WAAW,IAAI,IAAIyB,cAAc,CAAC7B,QAAQ,EAAEI,WAAW,EAAEH,OAAO,EAAEC,aAAa,CAAC,EAChFlC,GAAG,EACH,CAACgC,QAAQ,EAAEC,OAAO,CAACK,GAAG,EAAEL,OAAO,CAAC6B,KAAK,EAAE7B,OAAO,CAAC8B,SAAS,EAAE9B,OAAO,CAACM,KAAK,EAAEN,OAAO,CAACO,MAAM,CAAC,CACzF;AACH;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EsriServiceOptions, a as EditResult, A as ApplyEditsResult, F as FeatureServiceOptions, b as FindOptions, I as IdentifyImageOptions, c as ImageServiceOptions, V as VectorBasemapStyleOptions,
|
|
1
|
+
import { E as EsriServiceOptions, a as EditResult, A as ApplyEditsResult, F as FeatureServiceOptions, b as FindOptions, I as IdentifyImageOptions, c as ImageServiceOptions, P as PortalItemServiceOptions, d as PortalResolvedService, e as PortalServiceKind, V as VectorBasemapStyleOptions, f as VectorTileServiceOptions, D as DynamicMapService, T as TiledMapService, g as ImageService, h as VectorTileService, i as FeatureService } from './index-Doq93o-G.js';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { Map } from 'maplibre-gl';
|
|
4
4
|
|
|
@@ -14,6 +14,26 @@ interface UseEsriServiceResult<T> {
|
|
|
14
14
|
error: Error | null;
|
|
15
15
|
reload: () => void;
|
|
16
16
|
}
|
|
17
|
+
interface UsePortalItemOptions {
|
|
18
|
+
sourceId: string;
|
|
19
|
+
map: Map | null;
|
|
20
|
+
/** ArcGIS portal item id to resolve. */
|
|
21
|
+
itemId: string;
|
|
22
|
+
options?: PortalItemServiceOptions;
|
|
23
|
+
}
|
|
24
|
+
interface UsePortalItemResult {
|
|
25
|
+
/** The resolved esri-gl service (source already added to the map), or null. */
|
|
26
|
+
service: PortalResolvedService | null;
|
|
27
|
+
/** Which service kind the item resolved to. */
|
|
28
|
+
kind: PortalServiceKind | null;
|
|
29
|
+
/** The service URL the item resolved to. */
|
|
30
|
+
url: string | null;
|
|
31
|
+
/** The portal item title. */
|
|
32
|
+
title: string | null;
|
|
33
|
+
loading: boolean;
|
|
34
|
+
error: Error | null;
|
|
35
|
+
reload: () => void;
|
|
36
|
+
}
|
|
17
37
|
interface UseDynamicMapServiceOptions extends UseEsriServiceOptions<EsriServiceOptions> {
|
|
18
38
|
}
|
|
19
39
|
interface UseTiledMapServiceOptions extends UseEsriServiceOptions<EsriServiceOptions> {
|
|
@@ -73,43 +93,6 @@ interface EsriLayerProps {
|
|
|
73
93
|
layout?: Record<string, unknown>;
|
|
74
94
|
beforeId?: string;
|
|
75
95
|
}
|
|
76
|
-
interface EsriLayerBaseProps {
|
|
77
|
-
id: string;
|
|
78
|
-
sourceId?: string;
|
|
79
|
-
beforeId?: string;
|
|
80
|
-
visible?: boolean;
|
|
81
|
-
}
|
|
82
|
-
interface EsriDynamicLayerProps extends EsriLayerBaseProps {
|
|
83
|
-
url: string;
|
|
84
|
-
layers?: number[] | number | false;
|
|
85
|
-
layerDefs?: Record<string, string> | false;
|
|
86
|
-
format?: string;
|
|
87
|
-
dpi?: number;
|
|
88
|
-
transparent?: boolean;
|
|
89
|
-
}
|
|
90
|
-
interface EsriTiledLayerProps extends EsriLayerBaseProps {
|
|
91
|
-
url: string;
|
|
92
|
-
}
|
|
93
|
-
interface EsriImageLayerProps extends EsriLayerBaseProps {
|
|
94
|
-
url: string;
|
|
95
|
-
renderingRule?: Record<string, unknown> | false;
|
|
96
|
-
mosaicRule?: Record<string, unknown> | false;
|
|
97
|
-
format?: string;
|
|
98
|
-
}
|
|
99
|
-
interface EsriVectorTileLayerProps extends EsriLayerBaseProps {
|
|
100
|
-
url: string;
|
|
101
|
-
}
|
|
102
|
-
interface EsriVectorBasemapLayerProps extends EsriLayerBaseProps {
|
|
103
|
-
basemapEnum: string;
|
|
104
|
-
token: string;
|
|
105
|
-
}
|
|
106
|
-
interface EsriFeatureLayerProps extends EsriLayerBaseProps {
|
|
107
|
-
url: string;
|
|
108
|
-
where?: string;
|
|
109
|
-
outFields?: string | string[];
|
|
110
|
-
paint?: Record<string, unknown>;
|
|
111
|
-
layout?: Record<string, unknown>;
|
|
112
|
-
}
|
|
113
96
|
|
|
114
97
|
/**
|
|
115
98
|
* Hook for managing DynamicMapService lifecycle
|
|
@@ -122,7 +105,12 @@ declare function useDynamicMapService({ sourceId, map, options, sourceOptions, }
|
|
|
122
105
|
declare function useTiledMapService({ sourceId, map, options, sourceOptions, }: UseTiledMapServiceOptions): UseEsriServiceResult<TiledMapService>;
|
|
123
106
|
|
|
124
107
|
/**
|
|
125
|
-
* Hook for managing ImageService lifecycle
|
|
108
|
+
* Hook for managing ImageService lifecycle.
|
|
109
|
+
*
|
|
110
|
+
* `useEsriService` only rebuilds when the `map` changes, so this hook reacts to
|
|
111
|
+
* service-defining option changes itself: a different `url`/`format` rebuilds
|
|
112
|
+
* the service (and its source), while `renderingRule`/`mosaicRule` changes are
|
|
113
|
+
* applied in place. (Pass a memoized `options` object.)
|
|
126
114
|
*/
|
|
127
115
|
declare function useImageService({ sourceId, map, options, sourceOptions, }: UseImageServiceOptions): UseEsriServiceResult<ImageService>;
|
|
128
116
|
|
|
@@ -136,5 +124,5 @@ declare function useVectorTileService({ sourceId, map, options, sourceOptions, }
|
|
|
136
124
|
*/
|
|
137
125
|
declare function useFeatureService({ sourceId, map, options, sourceOptions, }: UseFeatureServiceOptions): UseEsriServiceResult<FeatureService>;
|
|
138
126
|
|
|
139
|
-
export {
|
|
140
|
-
export type { EsriServiceProviderProps as E, UseEsriServiceResult as U, UseVectorBasemapStyleOptions as a, UseIdentifyFeaturesOptions as b, UseIdentifyImageOptions as c, UseQueryOptions as d, UseFindOptions as e,
|
|
127
|
+
export { useFeatureService as p, useImageService as q, useTiledMapService as r, useVectorTileService as s, useDynamicMapService as u };
|
|
128
|
+
export type { EsriServiceProviderProps as E, UseEsriServiceResult as U, UseVectorBasemapStyleOptions as a, UseIdentifyFeaturesOptions as b, UseIdentifyImageOptions as c, UseQueryOptions as d, UseFindOptions as e, UseFeatureEditingResult as f, UsePortalItemOptions as g, UsePortalItemResult as h, EsriLayerProps as i, UseDynamicMapServiceOptions as j, UseEsriServiceOptions as k, UseFeatureServiceOptions as l, UseImageServiceOptions as m, UseTiledMapServiceOptions as n, UseVectorTileServiceOptions as o };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esri-gl",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A module for making it easier to use Esri services in mapbox-gl or maplibre-gl.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dev:docs": "cd docs && npm start",
|
|
39
39
|
"serve:docs": "cd docs && npm run serve",
|
|
40
40
|
"clean": "rimraf dist",
|
|
41
|
-
"type-check": "tsc --noEmit",
|
|
42
|
-
"type-check:watch": "tsc --noEmit --watch",
|
|
41
|
+
"type-check": "tsc -p tsconfig.app.json --noEmit && tsc -p tsconfig.test.json --noEmit && tsc -p tsconfig.node.json --noEmit",
|
|
42
|
+
"type-check:watch": "tsc -p tsconfig.app.json --noEmit --watch",
|
|
43
43
|
"lint": "eslint 'src/**/*.{ts,tsx,js,jsx}'",
|
|
44
44
|
"lint:fix": "eslint 'src/**/*.{ts,tsx,js,jsx}' --fix",
|
|
45
45
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,css,md}\"",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"test:watch": "jest --watch",
|
|
49
49
|
"test:coverage": "jest --coverage",
|
|
50
50
|
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
51
|
+
"test:portal": "node scripts/portal-live-test.mjs",
|
|
51
52
|
"validate": "npm run type-check && npm run lint && npm run format:check && npm run test:ci",
|
|
52
53
|
"publish:redirects": "./scripts/publish-redirects.sh",
|
|
53
54
|
"publish:mapbox-redirect": "cd packages/esri-mapbox-gl && npm publish --access=public",
|
|
@@ -86,10 +87,8 @@
|
|
|
86
87
|
"@rollup/plugin-babel": "^6.1.0",
|
|
87
88
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
88
89
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
89
|
-
"@rollup/plugin-terser": "^1.0.0",
|
|
90
90
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
91
91
|
"@testing-library/dom": "^10.4.1",
|
|
92
|
-
"@testing-library/jest-dom": "^6.9.1",
|
|
93
92
|
"@testing-library/react": "^16.3.2",
|
|
94
93
|
"@types/jest": "^30.0.0",
|
|
95
94
|
"@types/react": "^19.2.9",
|
|
@@ -157,6 +156,10 @@
|
|
|
157
156
|
}
|
|
158
157
|
},
|
|
159
158
|
"dependencies": {
|
|
159
|
+
"@esri/arcgis-rest-basemap-sessions": "^4.10.2",
|
|
160
|
+
"@esri/arcgis-rest-feature-service": "^4.10.2",
|
|
161
|
+
"@esri/arcgis-rest-portal": "^4.10.2",
|
|
162
|
+
"@esri/arcgis-rest-request": "^4.10.2",
|
|
160
163
|
"@mapbox/tilebelt": "^2.0.3",
|
|
161
164
|
"arcgis-pbf-parser": "^0.0.4"
|
|
162
165
|
}
|