@open-pioneer/map 0.6.1 → 0.8.0-dev.20241120115147

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +127 -12
  3. package/api/MapModel.d.ts +50 -17
  4. package/api/index.d.ts +2 -1
  5. package/api/layers/GroupLayer.d.ts +50 -0
  6. package/api/layers/GroupLayer.js +6 -0
  7. package/api/layers/GroupLayer.js.map +1 -0
  8. package/api/layers/SimpleLayer.d.ts +5 -2
  9. package/api/layers/SimpleLayer.js.map +1 -1
  10. package/api/layers/WMSLayer.d.ts +6 -3
  11. package/api/layers/WMSLayer.js.map +1 -1
  12. package/api/layers/WMTSLayer.d.ts +4 -2
  13. package/api/layers/WMTSLayer.js.map +1 -1
  14. package/api/layers/base.d.ts +77 -18
  15. package/api/layers/base.js +9 -0
  16. package/api/layers/base.js.map +1 -0
  17. package/api/layers/index.d.ts +1 -0
  18. package/index.js +3 -0
  19. package/index.js.map +1 -1
  20. package/model/AbstractLayer.d.ts +4 -3
  21. package/model/AbstractLayer.js +16 -23
  22. package/model/AbstractLayer.js.map +1 -1
  23. package/model/AbstractLayerBase.d.ts +21 -5
  24. package/model/AbstractLayerBase.js +48 -35
  25. package/model/AbstractLayerBase.js.map +1 -1
  26. package/model/Highlights.d.ts +11 -4
  27. package/model/Highlights.js +5 -1
  28. package/model/Highlights.js.map +1 -1
  29. package/model/LayerCollectionImpl.d.ts +10 -10
  30. package/model/LayerCollectionImpl.js +39 -37
  31. package/model/LayerCollectionImpl.js.map +1 -1
  32. package/model/MapModelImpl.d.ts +16 -3
  33. package/model/MapModelImpl.js +94 -25
  34. package/model/MapModelImpl.js.map +1 -1
  35. package/model/SublayersCollectionImpl.d.ts +6 -3
  36. package/model/SublayersCollectionImpl.js +6 -4
  37. package/model/SublayersCollectionImpl.js.map +1 -1
  38. package/model/layers/GroupLayerImpl.d.ts +39 -0
  39. package/model/layers/GroupLayerImpl.js +88 -0
  40. package/model/layers/GroupLayerImpl.js.map +1 -0
  41. package/model/layers/SimpleLayerImpl.d.ts +4 -1
  42. package/model/layers/SimpleLayerImpl.js +6 -0
  43. package/model/layers/SimpleLayerImpl.js.map +1 -1
  44. package/model/layers/WMSLayerImpl.d.ts +11 -7
  45. package/model/layers/WMSLayerImpl.js +64 -51
  46. package/model/layers/WMSLayerImpl.js.map +1 -1
  47. package/model/layers/WMTSLayerImpl.d.ts +4 -5
  48. package/model/layers/WMTSLayerImpl.js +16 -13
  49. package/model/layers/WMTSLayerImpl.js.map +1 -1
  50. package/package.json +11 -12
  51. package/ui/CssProps.d.ts +9 -0
  52. package/ui/CssProps.js +13 -0
  53. package/ui/CssProps.js.map +1 -0
  54. package/ui/DefaultMapProvider.d.ts +39 -0
  55. package/ui/DefaultMapProvider.js +24 -0
  56. package/ui/DefaultMapProvider.js.map +1 -0
  57. package/ui/MapAnchor.d.ts +0 -3
  58. package/ui/MapAnchor.js +5 -49
  59. package/ui/MapAnchor.js.map +1 -1
  60. package/ui/MapContainer.d.ts +3 -3
  61. package/ui/MapContainer.js +30 -25
  62. package/ui/MapContainer.js.map +1 -1
  63. package/ui/MapContainerContext.d.ts +7 -0
  64. package/ui/MapContainerContext.js +17 -0
  65. package/ui/MapContainerContext.js.map +1 -0
  66. package/ui/computeMapAnchorStyles.d.ts +3 -0
  67. package/ui/computeMapAnchorStyles.js +51 -0
  68. package/ui/computeMapAnchorStyles.js.map +1 -0
  69. package/ui/hooks.d.ts +10 -0
  70. package/ui/hooks.js.map +1 -1
  71. package/ui/styles.css +7 -0
  72. package/ui/styles.css.map +1 -1
  73. package/ui/useMapModel.d.ts +33 -6
  74. package/ui/useMapModel.js +40 -2
  75. package/ui/useMapModel.js.map +1 -1
  76. package/ui/MapContext.d.ts +0 -11
  77. package/ui/MapContext.js +0 -17
  78. package/ui/MapContext.js.map +0 -1
  79. package/util/defer.d.ts +0 -18
  80. package/util/defer.js +0 -21
  81. package/util/defer.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapModel, MapRegistry } from \"../api\";\n\n/** Return value of {@link useMapModel}. */\nexport type UseMapModelResult =\n | {\n kind: \"loading\" | \"resolved\" | \"rejected\";\n map?: MapModel | undefined;\n error?: Error | undefined;\n }\n | UseMapModelLoading\n | UseMapModelResolved\n | UseMapModelRejected;\n\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * React hooks that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(mapId: string): UseMapModelResult {\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n const state = useAsync(() => mapRegistry.getMapModel(mapId), [mapRegistry, mapId]);\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n return { kind: \"resolved\", map: state.value };\n }, [state]);\n return result;\n}\n"],"names":[],"mappings":";;;;AA4CO,SAAS,YAAY,KAAkC,EAAA;AAC1D,EAAM,MAAA,WAAA,GAAc,WAAwB,iBAAiB,CAAA,CAAA;AAC7D,EAAM,MAAA,KAAA,GAAQ,QAAS,CAAA,MAAM,WAAY,CAAA,WAAA,CAAY,KAAK,CAAG,EAAA,CAAC,WAAa,EAAA,KAAK,CAAC,CAAA,CAAA;AACjF,EAAM,MAAA,MAAA,GAAS,QAAQ,MAAyB;AAC5C,IAAA,IAAI,MAAM,OAAS,EAAA;AACf,MAAO,OAAA,EAAE,MAAM,SAAU,EAAA,CAAA;AAAA,KAC7B;AACA,IAAA,IAAI,MAAM,KAAO,EAAA;AACb,MAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,KAAA,EAAO,MAAM,KAAM,EAAA,CAAA;AAAA,KAClD;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,GAAA,EAAK,MAAM,KAAM,EAAA,CAAA;AAAA,GAChD,EAAG,CAAC,KAAK,CAAC,CAAA,CAAA;AACV,EAAO,OAAA,MAAA,CAAA;AACX;;;;"}
1
+ {"version":3,"file":"useMapModel.js","sources":["useMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { useMemo } from \"react\";\nimport { useAsync } from \"react-use\";\nimport { MapModel, MapRegistry } from \"../api\";\nimport { MapModelImpl } from \"../model/MapModelImpl\";\n// eslint-disable-next-line unused-imports/no-unused-imports\nimport { DefaultMapProvider, useDefaultMapProps } from \"./DefaultMapProvider\";\n\n/** Return value of {@link useMapModel}. */\nexport type UseMapModelResult = UseMapModelLoading | UseMapModelResolved | UseMapModelRejected;\n\nexport interface UseMapModelLoading {\n kind: \"loading\";\n map?: undefined;\n error?: undefined;\n}\n\nexport interface UseMapModelResolved {\n kind: \"resolved\";\n map: MapModel;\n error?: undefined;\n}\n\nexport interface UseMapModelRejected {\n kind: \"rejected\";\n map?: undefined;\n error: Error;\n}\n\n/**\n * Options that specify which map to use. See {@link useMapModel}.\n *\n * When not setting any of these properties on a component, the default map (from the `DefaultMapProvider`) will be used.\n * If that is not available either, an error will be thrown.\n */\nexport interface MapModelProps {\n /**\n * The id of the map.\n * The map will be looked up in the MapRegistry service.\n */\n mapId?: string | undefined;\n\n /**\n * The direct map model reference to use.\n * This property can be used as an alternative to the {@link mapId}.\n */\n map?: MapModel | undefined;\n}\n\n/**\n * React hook that looks up the map with the given id in the `map.MapRegistry` service.\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(mapId: string): UseMapModelResult;\n\n/**\n * React hook that resolves a map model specified by the given `props` (see {@link MapModelProps}).\n *\n * Returns an object representing the progress, which will eventually represent either\n * the map model value or an initialization error.\n *\n * The map model cannot be returned directly because it may not have completed its initialization yet.\n */\nexport function useMapModel(props: MapModelProps): UseMapModelResult;\n\n/**\n * React hook that returns the default map model (if available, see {@link DefaultMapProvider}).\n */\nexport function useMapModel(): UseMapModelResult;\nexport function useMapModel(props?: undefined | string | MapModelProps): UseMapModelResult {\n const resolvedMapArg = useResolvedMapArg(props);\n const mapRegistry = useService<MapRegistry>(\"map.MapRegistry\");\n const state = useAsync(async () => {\n if (typeof resolvedMapArg === \"string\") {\n return await mapRegistry.expectMapModel(resolvedMapArg);\n }\n return Promise.resolve(resolvedMapArg);\n }, [mapRegistry, resolvedMapArg]);\n const result = useMemo((): UseMapModelResult => {\n if (state.loading) {\n return { kind: \"loading\" };\n }\n if (state.error) {\n return { kind: \"rejected\", error: state.error };\n }\n return { kind: \"resolved\", map: state.value! };\n }, [state]);\n return result;\n}\n\n/**\n * Resolves the map model (or its id) from the given props and the default map props.\n */\nfunction useResolvedMapArg(props?: undefined | string | MapModelProps): MapModel | string {\n if (typeof props === \"object\" && props.mapId != null && props.map != null) {\n throw new Error(`Cannot specify both 'mapId' and 'map' in useMapModel at the same time.`);\n }\n if (props instanceof MapModelImpl) {\n // This cannot happen in valid typescript code, but it might be a common mistake.\n throw new Error(\n `Map model instances cannot be passed directly to 'useMapModel' (see TypeScript signature).`\n );\n }\n const localProps = useMemo((): MapModelProps => {\n // Normalize local props for compatibility with old string overload.\n if (props == null) {\n return {};\n }\n if (typeof props === \"string\") {\n return { mapId: props };\n }\n return { mapId: props.mapId, map: props.map };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [...(typeof props === \"string\" || props == null ? [props] : [props.mapId, props.map])]);\n const defaultProps = useDefaultMapProps();\n\n const resolvedMapArg = resolveMap(localProps) ?? resolveMap(defaultProps);\n if (resolvedMapArg == null) {\n throw new Error(\n `No map specified. ` +\n `You must either specify the map (or its id) via a DefaultMapProvider parent or configure it explicitly.`\n );\n }\n return resolvedMapArg;\n}\n\nfunction resolveMap(props?: MapModelProps): MapModel | string | undefined {\n return props?.map ?? props?.mapId;\n}\n"],"names":[],"mappings":";;;;;;AA2EO,SAAS,YAAY,KAA+D,EAAA;AACvF,EAAM,MAAA,cAAA,GAAiB,kBAAkB,KAAK,CAAA,CAAA;AAC9C,EAAM,MAAA,WAAA,GAAc,WAAwB,iBAAiB,CAAA,CAAA;AAC7D,EAAM,MAAA,KAAA,GAAQ,SAAS,YAAY;AAC/B,IAAI,IAAA,OAAO,mBAAmB,QAAU,EAAA;AACpC,MAAO,OAAA,MAAM,WAAY,CAAA,cAAA,CAAe,cAAc,CAAA,CAAA;AAAA,KAC1D;AACA,IAAO,OAAA,OAAA,CAAQ,QAAQ,cAAc,CAAA,CAAA;AAAA,GACtC,EAAA,CAAC,WAAa,EAAA,cAAc,CAAC,CAAA,CAAA;AAChC,EAAM,MAAA,MAAA,GAAS,QAAQ,MAAyB;AAC5C,IAAA,IAAI,MAAM,OAAS,EAAA;AACf,MAAO,OAAA,EAAE,MAAM,SAAU,EAAA,CAAA;AAAA,KAC7B;AACA,IAAA,IAAI,MAAM,KAAO,EAAA;AACb,MAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,KAAA,EAAO,MAAM,KAAM,EAAA,CAAA;AAAA,KAClD;AACA,IAAA,OAAO,EAAE,IAAA,EAAM,UAAY,EAAA,GAAA,EAAK,MAAM,KAAO,EAAA,CAAA;AAAA,GACjD,EAAG,CAAC,KAAK,C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AAO,OAAO,KAAO,EAAA,KAAA,CAAA;AAChC;;;;"}
@@ -1,11 +0,0 @@
1
- import { Provider } from "react";
2
- import { type MapPadding } from "../api";
3
- import type OlMap from "ol/Map";
4
- /** Values provided to children of {@link MapContainer}. */
5
- export interface MapContextType {
6
- map: OlMap;
7
- mapAnchorsHost: HTMLElement;
8
- padding: Required<MapPadding>;
9
- }
10
- export declare const MapContextProvider: Provider<MapContextType>;
11
- export declare function useMapContext(): MapContextType;
package/ui/MapContext.js DELETED
@@ -1,17 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
-
3
- const MapContext = createContext(void 0);
4
- MapContext.displayName = "MapContext";
5
- const MapContextProvider = MapContext.Provider;
6
- function useMapContext() {
7
- const contextValue = useContext(MapContext);
8
- if (!contextValue) {
9
- throw new Error(
10
- `Map context is not available. The component must be a child of the <MapContainer /> component.`
11
- );
12
- }
13
- return contextValue;
14
- }
15
-
16
- export { MapContextProvider, useMapContext };
17
- //# sourceMappingURL=MapContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MapContext.js","sources":["MapContext.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Provider, createContext, useContext } from \"react\";\nimport { type MapPadding } from \"../api\";\nimport type OlMap from \"ol/Map\";\n\n/** Values provided to children of {@link MapContainer}. */\nexport interface MapContextType {\n map: OlMap;\n mapAnchorsHost: HTMLElement;\n padding: Required<MapPadding>;\n}\n\nconst MapContext = createContext<MapContextType | undefined>(undefined);\nMapContext.displayName = \"MapContext\";\n\nexport const MapContextProvider: Provider<MapContextType> =\n MapContext.Provider as Provider<MapContextType>;\n\nexport function useMapContext(): MapContextType {\n const contextValue = useContext(MapContext);\n if (!contextValue) {\n throw new Error(\n `Map context is not available. The component must be a child of the <MapContainer /> component.`\n );\n }\n return contextValue;\n}\n"],"names":[],"mappings":";;AAaA,MAAM,UAAA,GAAa,cAA0C,KAAS,CAAA,CAAA,CAAA;AACtE,UAAA,CAAW,WAAc,GAAA,YAAA,CAAA;AAElB,MAAM,qBACT,UAAW,CAAA,SAAA;AAER,SAAS,aAAgC,GAAA;AAC5C,EAAM,MAAA,YAAA,GAAe,WAAW,UAAU,CAAA,CAAA;AAC1C,EAAA,IAAI,CAAC,YAAc,EAAA;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,8FAAA,CAAA;AAAA,KACJ,CAAA;AAAA,GACJ;AACA,EAAO,OAAA,YAAA,CAAA;AACX;;;;"}
package/util/defer.d.ts DELETED
@@ -1,18 +0,0 @@
1
- export interface DeferredExecution {
2
- /**
3
- * Re-schedule execution of `func` (if it was not already executed).
4
- * Returns true on success, false otherwise.
5
- */
6
- reschedule(): boolean;
7
- /**
8
- * Cancels the pending execution (if it is still pending).
9
- */
10
- cancel(): void;
11
- }
12
- /**
13
- * Calls `func` at a slightly later time.
14
- *
15
- * The returned object can be used to re-schedule or cancel the execution of `func`.
16
- * However, `func` will be executed at most once.
17
- */
18
- export declare function defer(func: () => void): DeferredExecution;
package/util/defer.js DELETED
@@ -1,21 +0,0 @@
1
- function defer(func) {
2
- let executed = false;
3
- let timeout = setTimeout(() => {
4
- executed = true;
5
- timeout = void 0;
6
- func();
7
- });
8
- return {
9
- reschedule() {
10
- return !executed;
11
- },
12
- cancel() {
13
- if (timeout) {
14
- clearTimeout(timeout);
15
- }
16
- }
17
- };
18
- }
19
-
20
- export { defer };
21
- //# sourceMappingURL=defer.js.map
package/util/defer.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"defer.js","sources":["defer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nexport interface DeferredExecution {\n /**\n * Re-schedule execution of `func` (if it was not already executed).\n * Returns true on success, false otherwise.\n */\n reschedule(): boolean;\n\n /**\n * Cancels the pending execution (if it is still pending).\n */\n cancel(): void;\n}\n\n/**\n * Calls `func` at a slightly later time.\n *\n * The returned object can be used to re-schedule or cancel the execution of `func`.\n * However, `func` will be executed at most once.\n */\nexport function defer(func: () => void): DeferredExecution {\n let executed = false;\n let timeout: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n executed = true;\n timeout = undefined;\n func();\n });\n return {\n reschedule() {\n // Do nothing: if not executed, the timeout is still pending\n // and it will run in the future.\n return !executed;\n },\n cancel() {\n if (timeout) {\n clearTimeout(timeout);\n }\n }\n };\n}\n"],"names":[],"mappings":"AAqBO,SAAS,MAAM,IAAqC,EAAA;AACvD,EAAA,IAAI,QAAW,GAAA,KAAA,CAAA;AACf,EAAI,IAAA,OAAA,GAAqD,WAAW,MAAM;AACtE,IAAW,QAAA,GAAA,IAAA,CAAA;AACX,IAAU,OAAA,GAAA,KAAA,CAAA,CAAA;AACV,IAAK,IAAA,EAAA,CAAA;AAAA,GACR,CAAA,CAAA;AACD,EAAO,OAAA;AAAA,IACH,UAAa,GAAA;AAGT,MAAA,OAAO,CAAC,QAAA,CAAA;AAAA,KACZ;AAAA,IACA,MAAS,GAAA;AACL,MAAA,IAAI,OAAS,EAAA;AACT,QAAA,YAAA,CAAa,OAAO,CAAA,CAAA;AAAA,OACxB;AAAA,KACJ;AAAA,GACJ,CAAA;AACJ;;;;"}