@open-pioneer/map-test-utils 0.9.0-dev.20250220091855 → 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,170 +1,179 @@
1
1
  # @open-pioneer/map-test-utils
2
2
 
3
- ## 0.9.0-dev.20250220091855
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 [f327eec]
8
- - Updated dependencies [f327eec]
9
- - Updated dependencies [209eb8e]
10
- - @open-pioneer/map@0.9.0-dev.20250220091855
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
11
20
 
12
21
  ## 0.8.0
13
22
 
14
23
  ### Minor Changes
15
24
 
16
- - 2fa8020: Update trails core package dependencies.
25
+ - 2fa8020: Update trails core package dependencies.
17
26
 
18
- - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
19
- - Removes any obsolete references to `@chakra-ui/system`.
20
- 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.
21
30
 
22
31
  ### Patch Changes
23
32
 
24
- - 49f0207: Update trails core packages to version 2.4.0
25
- - 224102d: Use reactive map model API to watch for changes of initialExtent.
26
- - Updated dependencies [b717121]
27
- - Updated dependencies [e7978a8]
28
- - Updated dependencies [7a5f1e1]
29
- - Updated dependencies [7ae9f90]
30
- - Updated dependencies [d8337a6]
31
- - Updated dependencies [49f0207]
32
- - Updated dependencies [b2127df]
33
- - Updated dependencies [2fa8020]
34
- - Updated dependencies [7ae9f90]
35
- - Updated dependencies [d8337a6]
36
- - @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
37
46
 
38
47
  ## 0.7.0
39
48
 
40
49
  ### Minor Changes
41
50
 
42
- - 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.
43
52
 
44
53
  ### Patch Changes
45
54
 
46
- - 310800c: Update core packages version.
47
- - a8b3449: Switch to a new versioning strategy.
48
- From now on, packages released by this repository share a common version number.
49
- - 900eb11: Update dependencies.
50
- - Updated dependencies [310800c]
51
- - Updated dependencies [2502050]
52
- - Updated dependencies [583f1d6]
53
- - Updated dependencies [583f1d6]
54
- - Updated dependencies [397d617]
55
- - Updated dependencies [a8b3449]
56
- - Updated dependencies [310800c]
57
- - Updated dependencies [900eb11]
58
- - Updated dependencies [583f1d6]
59
- - Updated dependencies [397d617]
60
- - @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
61
70
 
62
71
  ## 0.3.4
63
72
 
64
73
  ### Patch Changes
65
74
 
66
- - b152428: Update trails dependencies
67
- - Updated dependencies [b152428]
68
- - Updated dependencies [291ccb6]
69
- - @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
70
79
 
71
80
  ## 0.3.3
72
81
 
73
82
  ### Patch Changes
74
83
 
75
- - 28e092a: Update dependencies
76
- - 76f8863: Don't import map package internals using the services module.
77
- - Updated dependencies [28e092a]
78
- - Updated dependencies [0d51d2f]
79
- - Updated dependencies [76f8863]
80
- - @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
81
90
 
82
91
  ## 0.3.2
83
92
 
84
93
  ### Patch Changes
85
94
 
86
- - 4140646: Update trails dependencies
87
- - 4140646: Update to react 18.3.1
88
- - 81bc7da: Update trails dependencies
89
- - 2c092dc: Update dependencies
90
- - Updated dependencies [4140646]
91
- - Updated dependencies [4140646]
92
- - Updated dependencies [b5bb7a1]
93
- - Updated dependencies [81bc7da]
94
- - Updated dependencies [2c092dc]
95
- - @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
96
105
 
97
106
  ## 0.3.1
98
107
 
99
108
  ### Patch Changes
100
109
 
101
- - Updated dependencies [520a97b]
102
- - @open-pioneer/map@0.5.0
110
+ - Updated dependencies [520a97b]
111
+ - @open-pioneer/map@0.5.0
103
112
 
104
113
  ## 0.3.0
105
114
 
106
115
  ### Minor Changes
107
116
 
108
- - a11bf72: mock vector layer rendering during tests
109
- - 9334e81: Update to OpenLayers 9
117
+ - a11bf72: mock vector layer rendering during tests
118
+ - 9334e81: Update to OpenLayers 9
110
119
 
111
120
  ### Patch Changes
112
121
 
113
- - 1a8ad89: Update package.json metadata
114
- - Updated dependencies [1a8ad89]
115
- - Updated dependencies [a11bf72]
116
- - Updated dependencies [fc6bf82]
117
- - Updated dependencies [a0d8882]
118
- - Updated dependencies [6162979]
119
- - Updated dependencies [9334e81]
120
- - Updated dependencies [ac7fdd1]
121
- - Updated dependencies [13ea342]
122
- - @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
123
132
 
124
133
  ## 0.2.2
125
134
 
126
135
  ### Patch Changes
127
136
 
128
- - Updated dependencies [611ddb9]
129
- - @open-pioneer/map@0.3.1
137
+ - Updated dependencies [611ddb9]
138
+ - @open-pioneer/map@0.3.1
130
139
 
131
140
  ## 0.2.1
132
141
 
133
142
  ### Patch Changes
134
143
 
135
- - Updated dependencies [ee7c2d4]
136
- - Updated dependencies [a582e5e]
137
- - Updated dependencies [0456500]
138
- - @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
139
148
 
140
149
  ## 0.2.0
141
150
 
142
151
  ### Minor Changes
143
152
 
144
- - 70349a8: Update to new core packages major versions
153
+ - 70349a8: Update to new core packages major versions
145
154
 
146
155
  ### Patch Changes
147
156
 
148
- - Updated dependencies [70349a8]
149
- - @open-pioneer/map@0.2.0
157
+ - Updated dependencies [70349a8]
158
+ - @open-pioneer/map@0.2.0
150
159
 
151
160
  ## 0.1.1
152
161
 
153
162
  ### Patch Changes
154
163
 
155
- - Updated dependencies [08bffbc]
156
- - Updated dependencies [a58546b]
157
- - Updated dependencies [a58546b]
158
- - Updated dependencies [0c4ce04]
159
- - @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
160
169
 
161
170
  ## 0.1.0
162
171
 
163
172
  ### Minor Changes
164
173
 
165
- - 90103b9: Initial release.
174
+ - 90103b9: Initial release.
166
175
 
167
176
  ### Patch Changes
168
177
 
169
- - Updated dependencies [bb2f27a]
170
- - @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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,GACH,CAAA,CAAA;AAED,EAAO,OAAA,EAAE,OAAO,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,Y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EAAA;AAC1D,IAAA,IAAA,CAAK,KAAQ,GAAA,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.20250220091855",
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.20250220091855"
21
+ "@open-pioneer/map": "^0.9.0-dev.20250224083536"
22
22
  },
23
23
  "exports": {
24
24
  "./package.json": "./package.json",