@open-pioneer/map-test-utils 0.9.0-dev.20250217152428 → 0.9.0-dev.20250224083536

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/CHANGELOG.md CHANGED
@@ -1,168 +1,179 @@
1
1
  # @open-pioneer/map-test-utils
2
2
 
3
- ## 0.9.0-dev.20250217152428
3
+ ## 0.9.0-dev.20250224083536
4
+
5
+ ### Minor Changes
6
+
7
+ - cb94c75: update dependencies
4
8
 
5
9
  ### Patch Changes
6
10
 
7
- - Updated dependencies [209eb8e]
8
- - @open-pioneer/map@0.9.0-dev.20250217152428
11
+ - d72e42c: Removed BKGTopPlusOpen layer source. The BKGTopPlusOpen was an internal layer source only needed for tests. Please use own test sources instead.
12
+ - Updated dependencies [cb94c75]
13
+ - Updated dependencies [37cd707]
14
+ - Updated dependencies [32ed2cd]
15
+ - Updated dependencies [f327eec]
16
+ - Updated dependencies [f327eec]
17
+ - Updated dependencies [209eb8e]
18
+ - Updated dependencies [d72e42c]
19
+ - @open-pioneer/map@0.9.0-dev.20250224083536
9
20
 
10
21
  ## 0.8.0
11
22
 
12
23
  ### Minor Changes
13
24
 
14
- - 2fa8020: Update trails core package dependencies.
25
+ - 2fa8020: Update trails core package dependencies.
15
26
 
16
- - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
17
- - Removes any obsolete references to `@chakra-ui/system`.
18
- This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
27
+ - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
28
+ - Removes any obsolete references to `@chakra-ui/system`.
29
+ This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
19
30
 
20
31
  ### Patch Changes
21
32
 
22
- - 49f0207: Update trails core packages to version 2.4.0
23
- - 224102d: Use reactive map model API to watch for changes of initialExtent.
24
- - Updated dependencies [b717121]
25
- - Updated dependencies [e7978a8]
26
- - Updated dependencies [7a5f1e1]
27
- - Updated dependencies [7ae9f90]
28
- - Updated dependencies [d8337a6]
29
- - Updated dependencies [49f0207]
30
- - Updated dependencies [b2127df]
31
- - Updated dependencies [2fa8020]
32
- - Updated dependencies [7ae9f90]
33
- - Updated dependencies [d8337a6]
34
- - @open-pioneer/map@0.8.0
33
+ - 49f0207: Update trails core packages to version 2.4.0
34
+ - 224102d: Use reactive map model API to watch for changes of initialExtent.
35
+ - Updated dependencies [b717121]
36
+ - Updated dependencies [e7978a8]
37
+ - Updated dependencies [7a5f1e1]
38
+ - Updated dependencies [7ae9f90]
39
+ - Updated dependencies [d8337a6]
40
+ - Updated dependencies [49f0207]
41
+ - Updated dependencies [b2127df]
42
+ - Updated dependencies [2fa8020]
43
+ - Updated dependencies [7ae9f90]
44
+ - Updated dependencies [d8337a6]
45
+ - @open-pioneer/map@0.8.0
35
46
 
36
47
  ## 0.7.0
37
48
 
38
49
  ### Minor Changes
39
50
 
40
- - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
51
+ - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
41
52
 
42
53
  ### Patch Changes
43
54
 
44
- - 310800c: Update core packages version.
45
- - a8b3449: Switch to a new versioning strategy.
46
- From now on, packages released by this repository share a common version number.
47
- - 900eb11: Update dependencies.
48
- - Updated dependencies [310800c]
49
- - Updated dependencies [2502050]
50
- - Updated dependencies [583f1d6]
51
- - Updated dependencies [583f1d6]
52
- - Updated dependencies [397d617]
53
- - Updated dependencies [a8b3449]
54
- - Updated dependencies [310800c]
55
- - Updated dependencies [900eb11]
56
- - Updated dependencies [583f1d6]
57
- - Updated dependencies [397d617]
58
- - @open-pioneer/map@0.7.0
55
+ - 310800c: Update core packages version.
56
+ - a8b3449: Switch to a new versioning strategy.
57
+ From now on, packages released by this repository share a common version number.
58
+ - 900eb11: Update dependencies.
59
+ - Updated dependencies [310800c]
60
+ - Updated dependencies [2502050]
61
+ - Updated dependencies [583f1d6]
62
+ - Updated dependencies [583f1d6]
63
+ - Updated dependencies [397d617]
64
+ - Updated dependencies [a8b3449]
65
+ - Updated dependencies [310800c]
66
+ - Updated dependencies [900eb11]
67
+ - Updated dependencies [583f1d6]
68
+ - Updated dependencies [397d617]
69
+ - @open-pioneer/map@0.7.0
59
70
 
60
71
  ## 0.3.4
61
72
 
62
73
  ### Patch Changes
63
74
 
64
- - b152428: Update trails dependencies
65
- - Updated dependencies [b152428]
66
- - Updated dependencies [291ccb6]
67
- - @open-pioneer/map@0.6.1
75
+ - b152428: Update trails dependencies
76
+ - Updated dependencies [b152428]
77
+ - Updated dependencies [291ccb6]
78
+ - @open-pioneer/map@0.6.1
68
79
 
69
80
  ## 0.3.3
70
81
 
71
82
  ### Patch Changes
72
83
 
73
- - 28e092a: Update dependencies
74
- - 76f8863: Don't import map package internals using the services module.
75
- - Updated dependencies [28e092a]
76
- - Updated dependencies [0d51d2f]
77
- - Updated dependencies [76f8863]
78
- - @open-pioneer/map@0.6.0
84
+ - 28e092a: Update dependencies
85
+ - 76f8863: Don't import map package internals using the services module.
86
+ - Updated dependencies [28e092a]
87
+ - Updated dependencies [0d51d2f]
88
+ - Updated dependencies [76f8863]
89
+ - @open-pioneer/map@0.6.0
79
90
 
80
91
  ## 0.3.2
81
92
 
82
93
  ### Patch Changes
83
94
 
84
- - 4140646: Update trails dependencies
85
- - 4140646: Update to react 18.3.1
86
- - 81bc7da: Update trails dependencies
87
- - 2c092dc: Update dependencies
88
- - Updated dependencies [4140646]
89
- - Updated dependencies [4140646]
90
- - Updated dependencies [b5bb7a1]
91
- - Updated dependencies [81bc7da]
92
- - Updated dependencies [2c092dc]
93
- - @open-pioneer/map@0.5.1
95
+ - 4140646: Update trails dependencies
96
+ - 4140646: Update to react 18.3.1
97
+ - 81bc7da: Update trails dependencies
98
+ - 2c092dc: Update dependencies
99
+ - Updated dependencies [4140646]
100
+ - Updated dependencies [4140646]
101
+ - Updated dependencies [b5bb7a1]
102
+ - Updated dependencies [81bc7da]
103
+ - Updated dependencies [2c092dc]
104
+ - @open-pioneer/map@0.5.1
94
105
 
95
106
  ## 0.3.1
96
107
 
97
108
  ### Patch Changes
98
109
 
99
- - Updated dependencies [520a97b]
100
- - @open-pioneer/map@0.5.0
110
+ - Updated dependencies [520a97b]
111
+ - @open-pioneer/map@0.5.0
101
112
 
102
113
  ## 0.3.0
103
114
 
104
115
  ### Minor Changes
105
116
 
106
- - a11bf72: mock vector layer rendering during tests
107
- - 9334e81: Update to OpenLayers 9
117
+ - a11bf72: mock vector layer rendering during tests
118
+ - 9334e81: Update to OpenLayers 9
108
119
 
109
120
  ### Patch Changes
110
121
 
111
- - 1a8ad89: Update package.json metadata
112
- - Updated dependencies [1a8ad89]
113
- - Updated dependencies [a11bf72]
114
- - Updated dependencies [fc6bf82]
115
- - Updated dependencies [a0d8882]
116
- - Updated dependencies [6162979]
117
- - Updated dependencies [9334e81]
118
- - Updated dependencies [ac7fdd1]
119
- - Updated dependencies [13ea342]
120
- - @open-pioneer/map@0.4.0
122
+ - 1a8ad89: Update package.json metadata
123
+ - Updated dependencies [1a8ad89]
124
+ - Updated dependencies [a11bf72]
125
+ - Updated dependencies [fc6bf82]
126
+ - Updated dependencies [a0d8882]
127
+ - Updated dependencies [6162979]
128
+ - Updated dependencies [9334e81]
129
+ - Updated dependencies [ac7fdd1]
130
+ - Updated dependencies [13ea342]
131
+ - @open-pioneer/map@0.4.0
121
132
 
122
133
  ## 0.2.2
123
134
 
124
135
  ### Patch Changes
125
136
 
126
- - Updated dependencies [611ddb9]
127
- - @open-pioneer/map@0.3.1
137
+ - Updated dependencies [611ddb9]
138
+ - @open-pioneer/map@0.3.1
128
139
 
129
140
  ## 0.2.1
130
141
 
131
142
  ### Patch Changes
132
143
 
133
- - Updated dependencies [ee7c2d4]
134
- - Updated dependencies [a582e5e]
135
- - Updated dependencies [0456500]
136
- - @open-pioneer/map@0.3.0
144
+ - Updated dependencies [ee7c2d4]
145
+ - Updated dependencies [a582e5e]
146
+ - Updated dependencies [0456500]
147
+ - @open-pioneer/map@0.3.0
137
148
 
138
149
  ## 0.2.0
139
150
 
140
151
  ### Minor Changes
141
152
 
142
- - 70349a8: Update to new core packages major versions
153
+ - 70349a8: Update to new core packages major versions
143
154
 
144
155
  ### Patch Changes
145
156
 
146
- - Updated dependencies [70349a8]
147
- - @open-pioneer/map@0.2.0
157
+ - Updated dependencies [70349a8]
158
+ - @open-pioneer/map@0.2.0
148
159
 
149
160
  ## 0.1.1
150
161
 
151
162
  ### Patch Changes
152
163
 
153
- - Updated dependencies [08bffbc]
154
- - Updated dependencies [a58546b]
155
- - Updated dependencies [a58546b]
156
- - Updated dependencies [0c4ce04]
157
- - @open-pioneer/map@0.1.1
164
+ - Updated dependencies [08bffbc]
165
+ - Updated dependencies [a58546b]
166
+ - Updated dependencies [a58546b]
167
+ - Updated dependencies [0c4ce04]
168
+ - @open-pioneer/map@0.1.1
158
169
 
159
170
  ## 0.1.0
160
171
 
161
172
  ### Minor Changes
162
173
 
163
- - 90103b9: Initial release.
174
+ - 90103b9: Initial release.
164
175
 
165
176
  ### Patch Changes
166
177
 
167
- - Updated dependencies [bb2f27a]
168
- - @open-pioneer/map@0.1.0
178
+ - Updated dependencies [bb2f27a]
179
+ - @open-pioneer/map@0.1.0
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { watch } from \"@conterra/reactivity-core\";\nimport { HttpService, HttpServiceRequestInit } from \"@open-pioneer/http\";\nimport {\n ExtentConfig,\n InitialViewConfig,\n Layer,\n MapConfig,\n MapConfigProvider,\n MapModel,\n MapRegistry,\n OlMapOptions,\n SimpleLayer,\n SimpleLayerConfig\n} from \"@open-pioneer/map\";\nimport { MapRegistryImpl } from \"@open-pioneer/map/internalTestSupport\";\nimport { createService } from \"@open-pioneer/test-utils/services\";\nimport { screen, waitFor } from \"@testing-library/react\";\nimport VectorLayer from \"ol/layer/Vector\";\n\nexport interface SimpleMapOptions {\n /** Center coordinates for the map. */\n center?: { x: number; y: number };\n\n /** Zoom level of the map. */\n zoom?: number;\n\n /**\n * Initial extent (don't mix with center / zoom).\n */\n extent?: ExtentConfig;\n\n /**\n * The map's projection.\n */\n projection?: string;\n\n /**\n * Layers used by the map.\n */\n layers?: (SimpleLayerConfig | Layer)[];\n\n /**\n * Overrides fetching of network resources (such as service capabilities).\n */\n fetch?: (resource: URL, init: HttpServiceRequestInit | undefined) => Promise<Response>;\n\n /**\n * Passed to the open layers map constructor.\n */\n advanced?: OlMapOptions;\n\n /**\n * Disables the initial view when set to true.\n */\n noInitialView?: boolean;\n\n /**\n * Disables the default projection when set to true.\n */\n noProjection?: boolean;\n}\n\n/**\n * Waits until the OpenLayers map has been mounted in the parent with the given id.\n */\nexport async function waitForMapMount(parentTestId = \"base\") {\n return await waitFor(async () => {\n const domElement = await screen.findByTestId(parentTestId);\n const container = domElement.querySelector(\".ol-viewport\");\n if (!container) {\n throw new Error(\"map not mounted\");\n }\n return domElement;\n });\n}\n\n/**\n * Waits until the model has an initial extent.\n */\nexport async function waitForInitialExtent(model: MapModel) {\n if (model.initialExtent) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n const resource = watch(\n () => [model.initialExtent],\n ([extent]) => {\n resource.destroy();\n if (extent) {\n resolve();\n } else {\n reject(new Error(\"Expected a valid initial extent\"));\n }\n }\n );\n });\n}\n\n/**\n * Creates a simple map registry service with exactly one map configuration.\n *\n * The map is configured by using the `options` parameter.\n *\n * Returns the map registry and the id of the configured map.\n */\nexport async function setupMap(options?: SimpleMapOptions) {\n // Always use \"test\" as mapId for unit tests\n const mapId = \"test\";\n\n const getInitialView = (): InitialViewConfig => {\n if (options?.extent) {\n return {\n kind: \"extent\",\n extent: options.extent\n };\n }\n return {\n kind: \"position\",\n center: options?.center ?? { x: 847541, y: 6793584 },\n zoom: options?.zoom ?? 10\n };\n };\n\n const mapConfig: MapConfig = {\n initialView: options?.noInitialView ? undefined : getInitialView(),\n projection: options?.noProjection ? undefined : (options?.projection ?? \"EPSG:3857\"),\n layers: options?.layers?.map(\n (config) => (\"map\" in config ? config : new SimpleLayer(config))\n // using map as discriminator (no prototype for Layer)\n ) ?? [\n new SimpleLayer({\n title: \"OSM\",\n olLayer: new VectorLayer()\n })\n ],\n advanced: options?.advanced\n };\n\n const httpService = {\n async fetch(resource, init) {\n if (options?.fetch) {\n const url = new URL(resource, \"http://localhost:1234\");\n return options.fetch(url, init);\n }\n throw new Error(\n \"Network requests are not implemented (override fetch via map test utils if your test requires network access).\"\n );\n }\n } satisfies Partial<HttpService> as HttpService;\n\n const registry = await createService(MapRegistryImpl, {\n references: {\n providers: [new MapConfigProviderImpl(mapId, mapConfig)],\n httpService: httpService\n }\n });\n\n return { mapId, registry };\n}\n\n/**\n * Creates (service name, service implementation)-pairs suitable for the `services`\n * option of the `PackageContextProvider`.\n *\n * This helper method can be used to avoid hard-coding service names used in the implementation.\n */\nexport function createServiceOptions(services: { registry: MapRegistry }): Record<string, unknown> {\n return {\n \"map.MapRegistry\": services.registry\n };\n}\n\nclass MapConfigProviderImpl implements MapConfigProvider {\n mapId = \"default\";\n mapConfig: MapConfig;\n\n constructor(mapId: string, mapConfig?: MapConfig | undefined) {\n this.mapId = mapId;\n this.mapConfig = mapConfig ?? {};\n }\n\n getMapConfig(): Promise<MapConfig> {\n return Promise.resolve(this.mapConfig);\n }\n}\n\nfunction mockVectorLayer() {\n // Overwrite render so it doesn't actually do anything during tests.\n // Would otherwise error because <canvas /> is not fully implemented in happy dom.\n const div = document.createElement(\"div\");\n VectorLayer.prototype.render = () => {\n return div;\n };\n}\n\nmockVectorLayer();\n"],"names":[],"mappings":";;;;;;;AAmEsB,eAAA,eAAA,CAAgB,eAAe,MAAQ,EAAA;AACzD,EAAO,OAAA,MAAM,QAAQ,YAAY;AAC7B,IAAA,MAAM,UAAa,GAAA,MAAM,MAAO,CAAA,YAAA,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AO,QAAS,EAAA,CAAA;AAC7B,CAAA;AAQO,SAAS,qBAAqB,QAA8D,EAAA;AAC/F,EAAO,OAAA;AAAA,IACH,mBAAmB,QAAS,CAAA,QAAA;AAAA,GAChC,CAAA;AACJ,CAAA;AAEA,MAAM,qBAAmD,CAAA;AAAA,EACrD,KAAQ,GAAA,SAAA,CAAA;AAAA,EACR,SAAA,CAAA;AAAA,EAEA,WAAA,CAAY,OAAe,SAAmC,EAAA;AAC1D,IAAA,IAAA,CAAK,KAAQ,GAAA,KAAA,CAAA;AACb,IAAK,IAAA,CAAA,SAAA,GAAY,aAAa,EAAC,CAAA;AAAA,GACnC;AAAA,EAEA,YAAmC,GAAA;AAC/B,IAAO,OAAA,OAAA,CAAQ,OAAQ,CAAA,IAAA,CAAK,SAAS,CAAA,CAAA;AAAA,GACzC;AACJ,CAAA;AAEA,SAAS,eAAkB,GAAA;AAGvB,EAAM,MAAA,GAAA,GAAM,QAAS,CAAA,aAAA,CAAc,KAAK,CAAA,CAAA;AACxC,EAAY,WAAA,CAAA,SAAA,CAAU,SAAS,MAAM;AACjC,IAAO,OAAA,GAAA,CAAA;AAAA,GACX,CAAA;AACJ,CAAA;AAEA,eAAgB,EAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { watch } from \"@conterra/reactivity-core\";\nimport { HttpService, HttpServiceRequestInit } from \"@open-pioneer/http\";\nimport {\n ExtentConfig,\n InitialViewConfig,\n Layer,\n MapConfig,\n MapConfigProvider,\n MapModel,\n MapRegistry,\n OlMapOptions,\n SimpleLayer,\n SimpleLayerConfig\n} from \"@open-pioneer/map\";\nimport { MapRegistryImpl } from \"@open-pioneer/map/internalTestSupport\";\nimport { createService } from \"@open-pioneer/test-utils/services\";\nimport { screen, waitFor } from \"@testing-library/react\";\nimport VectorLayer from \"ol/layer/Vector\";\n\nexport interface SimpleMapOptions {\n /** Center coordinates for the map. */\n center?: { x: number; y: number };\n\n /** Zoom level of the map. */\n zoom?: number;\n\n /**\n * Initial extent (don't mix with center / zoom).\n */\n extent?: ExtentConfig;\n\n /**\n * The map's projection.\n */\n projection?: string;\n\n /**\n * Layers used by the map.\n */\n layers?: (SimpleLayerConfig | Layer)[];\n\n /**\n * Overrides fetching of network resources (such as service capabilities).\n */\n fetch?: (resource: URL, init: HttpServiceRequestInit | undefined) => Promise<Response>;\n\n /**\n * Passed to the open layers map constructor.\n */\n advanced?: OlMapOptions;\n\n /**\n * Disables the initial view when set to true.\n */\n noInitialView?: boolean;\n\n /**\n * Disables the default projection when set to true.\n */\n noProjection?: boolean;\n}\n\n/**\n * Waits until the OpenLayers map has been mounted in the parent with the given id.\n */\nexport async function waitForMapMount(parentTestId = \"base\") {\n return await waitFor(async () => {\n const domElement = await screen.findByTestId(parentTestId);\n const container = domElement.querySelector(\".ol-viewport\");\n if (!container) {\n throw new Error(\"map not mounted\");\n }\n return domElement;\n });\n}\n\n/**\n * Waits until the model has an initial extent.\n */\nexport async function waitForInitialExtent(model: MapModel) {\n if (model.initialExtent) {\n return;\n }\n\n await new Promise<void>((resolve, reject) => {\n const resource = watch(\n () => [model.initialExtent],\n ([extent]) => {\n resource.destroy();\n if (extent) {\n resolve();\n } else {\n reject(new Error(\"Expected a valid initial extent\"));\n }\n }\n );\n });\n}\n\n/**\n * Creates a simple map registry service with exactly one map configuration.\n *\n * The map is configured by using the `options` parameter.\n *\n * Returns the map registry and the id of the configured map.\n */\nexport async function setupMap(options?: SimpleMapOptions) {\n // Always use \"test\" as mapId for unit tests\n const mapId = \"test\";\n\n const getInitialView = (): InitialViewConfig => {\n if (options?.extent) {\n return {\n kind: \"extent\",\n extent: options.extent\n };\n }\n return {\n kind: \"position\",\n center: options?.center ?? { x: 847541, y: 6793584 },\n zoom: options?.zoom ?? 10\n };\n };\n\n const mapConfig: MapConfig = {\n initialView: options?.noInitialView ? undefined : getInitialView(),\n projection: options?.noProjection ? undefined : (options?.projection ?? \"EPSG:3857\"),\n layers: options?.layers?.map(\n (config) => (\"map\" in config ? config : new SimpleLayer(config))\n // using map as discriminator (no prototype for Layer)\n ) ?? [\n new SimpleLayer({\n title: \"OSM\",\n olLayer: new VectorLayer()\n })\n ],\n advanced: options?.advanced\n };\n\n const httpService = {\n async fetch(resource, init) {\n if (options?.fetch) {\n const url = new URL(resource, \"http://localhost:1234\");\n return options.fetch(url, init);\n }\n throw new Error(\n \"Network requests are not implemented (override fetch via map test utils if your test requires network access).\"\n );\n }\n } satisfies Partial<HttpService> as HttpService;\n\n const registry = await createService(MapRegistryImpl, {\n references: {\n providers: [new MapConfigProviderImpl(mapId, mapConfig)],\n httpService: httpService\n }\n });\n\n return { mapId, registry };\n}\n\n/**\n * Creates (service name, service implementation)-pairs suitable for the `services`\n * option of the `PackageContextProvider`.\n *\n * This helper method can be used to avoid hard-coding service names used in the implementation.\n */\nexport function createServiceOptions(services: { registry: MapRegistry }): Record<string, unknown> {\n return {\n \"map.MapRegistry\": services.registry\n };\n}\n\nclass MapConfigProviderImpl implements MapConfigProvider {\n mapId = \"default\";\n mapConfig: MapConfig;\n\n constructor(mapId: string, mapConfig?: MapConfig | undefined) {\n this.mapId = mapId;\n this.mapConfig = mapConfig ?? {};\n }\n\n getMapConfig(): Promise<MapConfig> {\n return Promise.resolve(this.mapConfig);\n }\n}\n\nfunction mockVectorLayer() {\n // Overwrite render so it doesn't actually do anything during tests.\n // Would otherwise error because <canvas /> is not fully implemented in happy dom.\n const div = document.createElement(\"div\");\n VectorLayer.prototype.render = () => {\n return div;\n };\n}\n\nmockVectorLayer();\n"],"names":[],"mappings":";;;;;;;AAmEsB,eAAA,eAAA,CAAgB,eAAe,MAAQ,EAAA;AACzD,EAAO,OAAA,MAAM,QAAQ,YAAY;AAC7B,IAAA,MAAM,UAAa,GAAA,MAAM,MAAO,CAAA,YAAA,CAAa,YAAY,CAAA;AACzD,IAAM,MAAA,SA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,KAAA;AACb,IAAK,IAAA,CAAA,SAAA,GAAY,aAAa,EAAC;AAAA;AACnC,EAEA,YAAmC,GAAA;AAC/B,IAAO,OAAA,OAAA,CAAQ,OAAQ,CAAA,IAAA,CAAK,SAAS,CAAA;AAAA;AAE7C;AAEA,SAAS,eAAkB,GAAA;AAGvB,EAAM,MAAA,GAAA,GAAM,QAAS,CAAA,aAAA,CAAc,KAAK,CAAA;AACxC,EAAY,WAAA,CAAA,SAAA,CAAU,SAAS,MAAM;AACjC,IAAO,OAAA,GAAA;AAAA,GACX;AACJ;AAEA,eAAgB,EAAA;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/map-test-utils",
4
- "version": "0.9.0-dev.20250217152428",
4
+ "version": "0.9.0-dev.20250224083536",
5
5
  "description": "This package is an internal support package for testing map-related UI components.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,11 +14,11 @@
14
14
  "directory": "src/packages/map-test-utils"
15
15
  },
16
16
  "dependencies": {
17
- "@open-pioneer/test-utils": "^2.4.0",
18
- "@testing-library/react": "^16.0.0",
19
- "ol": "^10.3.0",
17
+ "@open-pioneer/test-utils": "3.0.0-dev.20250221111321",
18
+ "@testing-library/react": "^16.2.0",
19
+ "ol": "^10.4.0",
20
20
  "@conterra/reactivity-core": "^0.4.3",
21
- "@open-pioneer/map": "^0.9.0-dev.20250217152428"
21
+ "@open-pioneer/map": "^0.9.0-dev.20250224083536"
22
22
  },
23
23
  "exports": {
24
24
  "./package.json": "./package.json",