@disy/cadenza.js 10.2.9 → 10.2.10

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 (60) hide show
  1. package/CHANGELOG.md +6 -3
  2. package/apidoc/assets/hierarchy.js +1 -0
  3. package/apidoc/assets/icons.js +17 -14
  4. package/apidoc/assets/icons.svg +1 -1
  5. package/apidoc/assets/main.js +5 -4
  6. package/apidoc/assets/navigation.js +1 -1
  7. package/apidoc/assets/search.js +1 -1
  8. package/apidoc/assets/style.css +1423 -1224
  9. package/apidoc/classes/AbortError.html +60 -60
  10. package/apidoc/classes/CadenzaClient.html +163 -188
  11. package/apidoc/classes/CadenzaError.html +15 -16
  12. package/apidoc/functions/cadenza.html +10 -10
  13. package/apidoc/index.html +146 -118
  14. package/apidoc/interfaces/CadenzaClientOptions.html +14 -14
  15. package/apidoc/interfaces/CadenzaEvent.html +6 -6
  16. package/apidoc/interfaces/Distance.html +3 -3
  17. package/apidoc/interfaces/ExternalLinkKey.html +8 -7
  18. package/apidoc/interfaces/Feature.html +16 -16
  19. package/apidoc/interfaces/FeatureCollection.html +6 -6
  20. package/apidoc/interfaces/Geometry.html +6 -6
  21. package/apidoc/interfaces/GeometryExtentStrategy.html +6 -6
  22. package/apidoc/interfaces/LayerDataExtentStrategy.html +7 -7
  23. package/apidoc/interfaces/LayerDefinition.html +7 -7
  24. package/apidoc/interfaces/LocationFinderExtentStrategy.html +6 -6
  25. package/apidoc/interfaces/PageSource.html +4 -4
  26. package/apidoc/interfaces/SnappingOptions.html +5 -0
  27. package/apidoc/interfaces/StaticExtentStrategy.html +6 -6
  28. package/apidoc/modules.html +1 -46
  29. package/apidoc/types/CadenzaActionEvent.html +2 -2
  30. package/apidoc/types/CadenzaChangeSelectionEvent.html +2 -2
  31. package/apidoc/types/CadenzaDrillThroughEvent.html +2 -2
  32. package/apidoc/types/CadenzaEditGeometryCancelEvent.html +2 -2
  33. package/apidoc/types/CadenzaEditGeometryOkEvent.html +2 -2
  34. package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +2 -2
  35. package/apidoc/types/CadenzaErrorEvent.html +2 -2
  36. package/apidoc/types/CadenzaEventByType.html +1 -1
  37. package/apidoc/types/CadenzaEventType.html +2 -2
  38. package/apidoc/types/CadenzaObjectInfoEvent.html +2 -2
  39. package/apidoc/types/CadenzaReloadEvent.html +2 -2
  40. package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +2 -2
  41. package/apidoc/types/CadenzaSelectObjectsOkEvent.html +2 -2
  42. package/apidoc/types/Coordinate.html +2 -2
  43. package/apidoc/types/CustomValidityType.html +2 -2
  44. package/apidoc/types/DataType.html +2 -2
  45. package/apidoc/types/EmbeddingTargetId.html +3 -3
  46. package/apidoc/types/Extent.html +2 -2
  47. package/apidoc/types/ExtentStrategy.html +5 -5
  48. package/apidoc/types/FilterVariables.html +2 -2
  49. package/apidoc/types/GeometryType.html +2 -2
  50. package/apidoc/types/GlobalId.html +2 -2
  51. package/apidoc/types/LengthUnit.html +1 -1
  52. package/apidoc/types/OpaqueString.html +4 -4
  53. package/apidoc/types/OperationMode.html +2 -2
  54. package/apidoc/types/TablePart.html +2 -2
  55. package/apidoc/types/UiFeature.html +3 -3
  56. package/apidoc/types/WorkbookLayerPath.html +3 -3
  57. package/cadenza.d.ts +36 -22
  58. package/cadenza.js +38 -29
  59. package/package.json +8 -8
  60. package/sandbox.html +63 -21
package/cadenza.d.ts CHANGED
@@ -107,6 +107,7 @@ export class CadenzaClient {
107
107
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
108
108
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
109
109
  * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
110
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
110
111
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
111
112
  * @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map
112
113
  * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
@@ -117,7 +118,6 @@ export class CadenzaClient {
117
118
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
118
119
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
119
120
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
120
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
121
121
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
122
122
  * @throws For invalid arguments
123
123
  * @fires
@@ -125,10 +125,11 @@ export class CadenzaClient {
125
125
  * - {@link CadenzaActionEvent}
126
126
  * @embed
127
127
  */
128
- showMap(mapView: EmbeddingTargetId, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, extentStrategy, signal, additionalLayers, }?: {
128
+ showMap(mapView: EmbeddingTargetId, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, }?: {
129
129
  additionalLayers?: LayerDefinition[] | undefined;
130
130
  disabledUiFeatures?: UiFeature[] | undefined;
131
131
  expandNavigator?: boolean | undefined;
132
+ extentStrategy?: ExtentStrategy | undefined;
132
133
  filter?: FilterVariables | undefined;
133
134
  geometry?: Geometry | undefined;
134
135
  hideMainHeaderAndFooter?: boolean | undefined;
@@ -139,7 +140,6 @@ export class CadenzaClient {
139
140
  operationMode?: OperationMode | undefined;
140
141
  signal?: AbortSignal | undefined;
141
142
  useMapSrs?: boolean | undefined;
142
- extentStrategy?: ExtentStrategy | undefined;
143
143
  } | undefined, ...args: any[]): Promise<void>;
144
144
  /**
145
145
  * Expand/collapse the navigator.
@@ -236,14 +236,15 @@ export class CadenzaClient {
236
236
  * @param {object} [__namedParameters] - Options
237
237
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
238
238
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
239
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
239
240
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
240
241
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
241
242
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
242
243
  * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
243
244
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
244
245
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
246
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
245
247
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS and the created geometry should use the map's SRS (otherwise EPSG:4326 is assumed)
246
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
247
248
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
248
249
  * @throws For invalid arguments
249
250
  * @fires
@@ -252,17 +253,18 @@ export class CadenzaClient {
252
253
  * - {@link CadenzaEditGeometryCancelEvent}
253
254
  * @embed
254
255
  */
255
- createGeometry(backgroundMapView: EmbeddingTargetId, geometryType: GeometryType, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, extentStrategy, }?: {
256
+ createGeometry(backgroundMapView: EmbeddingTargetId, geometryType: GeometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, snapping, }?: {
256
257
  additionalLayers?: LayerDefinition[] | undefined;
257
258
  disabledUiFeatures?: UiFeature[] | undefined;
259
+ extentStrategy?: ExtentStrategy | undefined;
258
260
  filter?: FilterVariables | undefined;
259
261
  locationFinder?: string | undefined;
260
262
  mapExtent?: Extent | undefined;
261
263
  minScale?: number | undefined;
262
264
  operationMode?: OperationMode | undefined;
263
265
  signal?: AbortSignal | undefined;
266
+ snapping?: SnappingOptions | undefined;
264
267
  useMapSrs?: boolean | undefined;
265
- extentStrategy?: ExtentStrategy | undefined;
266
268
  } | undefined, ...args: any[]): Promise<void>;
267
269
  /**
268
270
  * Edit a geometry.
@@ -272,14 +274,15 @@ export class CadenzaClient {
272
274
  * @param {object} [__namedParameters] - Options
273
275
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
274
276
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
277
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
275
278
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
276
279
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
277
280
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
278
281
  * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
279
282
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
280
283
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
284
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
281
285
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
282
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
283
286
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
284
287
  * @throws For invalid arguments
285
288
  * @fires
@@ -288,17 +291,18 @@ export class CadenzaClient {
288
291
  * - {@link CadenzaEditGeometryCancelEvent}
289
292
  * @embed
290
293
  */
291
- editGeometry(backgroundMapView: EmbeddingTargetId, geometry: Geometry, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, operationMode, signal, useMapSrs, extentStrategy, }?: {
294
+ editGeometry(backgroundMapView: EmbeddingTargetId, geometry: Geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, operationMode, signal, snapping, useMapSrs, }?: {
292
295
  additionalLayers?: LayerDefinition[] | undefined;
293
296
  disabledUiFeatures?: UiFeature[] | undefined;
297
+ extentStrategy?: ExtentStrategy | undefined;
294
298
  filter?: FilterVariables | undefined;
295
299
  locationFinder?: string | undefined;
296
300
  mapExtent?: Extent | undefined;
297
301
  minScale?: number | undefined;
298
302
  operationMode?: OperationMode | undefined;
299
303
  signal?: AbortSignal | undefined;
304
+ snapping?: SnappingOptions | undefined;
300
305
  useMapSrs?: boolean | undefined;
301
- extentStrategy?: ExtentStrategy | undefined;
302
306
  } | undefined, ...args: any[]): Promise<void>;
303
307
  /**
304
308
  * Set custom validity state of the geometry editor in addition to the default validation state (including errors and
@@ -315,6 +319,7 @@ export class CadenzaClient {
315
319
  *
316
320
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
317
321
  * @param {object} [__namedParameters] - Options
322
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
318
323
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
319
324
  * @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
320
325
  * (identified using layer paths or print names)
@@ -323,7 +328,6 @@ export class CadenzaClient {
323
328
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
324
329
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
325
330
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
326
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
327
331
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
328
332
  * @throws For invalid arguments
329
333
  * @fires
@@ -333,7 +337,8 @@ export class CadenzaClient {
333
337
  * - {@link CadenzaSelectObjectsCancelEvent}
334
338
  * @embed
335
339
  */
336
- selectObjects(backgroundMapView: EmbeddingTargetId, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, extentStrategy, }?: {
340
+ selectObjects(backgroundMapView: EmbeddingTargetId, { extentStrategy, filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, }?: {
341
+ extentStrategy?: ExtentStrategy | undefined;
337
342
  filter?: FilterVariables | undefined;
338
343
  layers?: (string | WorkbookLayerPath)[] | undefined;
339
344
  locationFinder?: string | undefined;
@@ -341,7 +346,6 @@ export class CadenzaClient {
341
346
  useMapSrs?: boolean | undefined;
342
347
  operationMode?: OperationMode | undefined;
343
348
  signal?: AbortSignal | undefined;
344
- extentStrategy?: ExtentStrategy | undefined;
345
349
  } | undefined, ...args: any[]): Promise<void>;
346
350
  /**
347
351
  * Subscribe to a `postMessage()` event.
@@ -388,17 +392,17 @@ export class CadenzaClient {
388
392
  * @param {unknown[][]} objectIds - The IDs of the objects to select
389
393
  * @param {object} [__namedParameters] - Options
390
394
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
395
+ * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
391
396
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
392
397
  * @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84
393
- * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
394
398
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
395
399
  * @throws For invalid arguments
396
400
  */
397
- fetchObjectInfo(source: EmbeddingTargetId, layerPath: (WorkbookLayerPath | string)[], objectIds: unknown[][], { filter, signal, useMapSrs, fullGeometries }?: {
401
+ fetchObjectInfo(source: EmbeddingTargetId, layerPath: (WorkbookLayerPath | string)[], objectIds: unknown[][], { filter, signal, fullGeometries, useMapSrs }?: {
398
402
  filter?: FilterVariables | undefined;
403
+ fullGeometries?: boolean | undefined;
399
404
  signal?: AbortSignal | undefined;
400
405
  useMapSrs?: boolean | undefined;
401
- fullGeometries?: boolean | undefined;
402
406
  } | undefined, ...args: any[]): Promise<FeatureCollection>;
403
407
  /**
404
408
  * Fetch the intersection areas from a workbook map view layer in JSON format for a given area.
@@ -408,16 +412,16 @@ export class CadenzaClient {
408
412
  * (identified using layer paths or print names)
409
413
  * @param {Geometry} geometry - The intersection geometry
410
414
  * @param {object} [__namedParameters] - Options
411
- * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
412
415
  * @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition
413
416
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
417
+ * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
414
418
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
415
419
  * @server
416
420
  */
417
- fetchAreaIntersections(source: EmbeddingTargetId, layerPath: (WorkbookLayerPath | string)[], geometry: Geometry, { useMapSrs, buffer, signal }?: {
418
- useMapSrs?: boolean | undefined;
421
+ fetchAreaIntersections(source: EmbeddingTargetId, layerPath: (WorkbookLayerPath | string)[], geometry: Geometry, { buffer, signal, useMapSrs }?: {
419
422
  buffer?: Distance | undefined;
420
423
  signal?: AbortSignal | undefined;
424
+ useMapSrs?: boolean | undefined;
421
425
  } | undefined, ...args: any[]): Promise<FeatureCollection>;
422
426
  /**
423
427
  * Download data from a workbook view.
@@ -451,9 +455,9 @@ export class CadenzaClient {
451
455
  * | 'editGeometry:update'
452
456
  * | 'editGeometry:cancel'
453
457
  * | 'objectInfo'
458
+ * | 'reload'
454
459
  * | 'selectObjects:ok'
455
460
  * | 'selectObjects:cancel'
456
- * | 'reload'
457
461
  * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
458
462
  */
459
463
  /**
@@ -465,9 +469,9 @@ export class CadenzaClient {
465
469
  * : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent
466
470
  * : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent
467
471
  * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
472
+ * : T extends 'reload' ? CadenzaReloadEvent
468
473
  * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
469
474
  * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
470
- * : T extends 'reload' ? CadenzaReloadEvent
471
475
  * : never
472
476
  * } CadenzaEventByType
473
477
  */
@@ -800,11 +804,21 @@ export type FeatureCollection = {
800
804
  * - The type of custom validity used for disclose on visual presentation and form submission behavior
801
805
  */
802
806
  export type CustomValidityType = 'error' | 'warning' | 'info' | 'success';
807
+ export type SnappingOptions = {
808
+ /**
809
+ * - The layer to snap to
810
+ */
811
+ layer: WorkbookLayerPath | string;
812
+ /**
813
+ * - Snapping types; Without this option, the Cadenza default snapping types are used.
814
+ */
815
+ types?: ("toVertices" | "toEdges" | "lineTracing")[] | undefined;
816
+ };
803
817
  /**
804
818
  * - An event type to subscribe to using {@link CadenzaClienton }
805
819
  */
806
- export type CadenzaEventType = 'action' | 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'selectObjects:ok' | 'selectObjects:cancel' | 'reload';
807
- export type CadenzaEventByType<T extends CadenzaEventType> = T extends 'action' ? CadenzaActionEvent : T extends 'change:selection' ? CadenzaChangeSelectionEvent : T extends 'drillThrough' ? CadenzaDrillThroughEvent : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent : T extends 'objectInfo' ? CadenzaObjectInfoEvent : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent : T extends 'reload' ? CadenzaReloadEvent : never;
820
+ export type CadenzaEventType = 'action' | 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'reload' | 'selectObjects:ok' | 'selectObjects:cancel';
821
+ export type CadenzaEventByType<T extends CadenzaEventType> = T extends 'action' ? CadenzaActionEvent : T extends 'change:selection' ? CadenzaChangeSelectionEvent : T extends 'drillThrough' ? CadenzaDrillThroughEvent : T extends 'editGeometry:update' ? CadenzaEditGeometryUpdateEvent : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent : T extends 'objectInfo' ? CadenzaObjectInfoEvent : T extends 'reload' ? CadenzaReloadEvent : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent : never;
808
822
  /**
809
823
  * - A Cadenza `postMessage()` event
810
824
  */
package/cadenza.js CHANGED
@@ -12,7 +12,7 @@
12
12
  */
13
13
  // This placeholder is replaced when Cadenza JS is released,
14
14
  // i.e. during development, the version is not available.
15
- const CADENZAJS_VERSION = '10.2.9';
15
+ const CADENZAJS_VERSION = '10.2.10';
16
16
  /**
17
17
  * Creates an instance of the Cadenza JS client.
18
18
  *
@@ -188,6 +188,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
188
188
  * @property {Feature[]} features - The features within this collection
189
189
  */
190
190
  /** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */
191
+ /**
192
+ * @typedef SnappingOptions
193
+ * @property {WorkbookLayerPath | string} layer - The layer to snap to
194
+ * @property {('toVertices' | 'toEdges' | 'lineTracing')[]} [types] - Snapping types; Without this option, the Cadenza default snapping types are used.
195
+ */
191
196
  let hasCadenzaSession = false;
192
197
  /** @type {Promise<void> | undefined} */
193
198
  let firstEmbeddingTargetShown;
@@ -267,7 +272,7 @@ export class CadenzaClient {
267
272
  const targetWindow = this.#iframe
268
273
  ? this.iframe?.contentWindow
269
274
  : // If a window does not have a parent, its parent property is a reference to itself.
270
- window.opener ?? (window.parent !== window ? window.parent : null);
275
+ (window.opener ?? (window.parent !== window ? window.parent : null));
271
276
  return /** @type {WindowProxy | null} */ targetWindow;
272
277
  }
273
278
  get #requiredIframe() {
@@ -312,6 +317,7 @@ export class CadenzaClient {
312
317
  source.page === 'welcome', 'labelSet is only supported on the welcome page');
313
318
  }
314
319
  const params = createParams({
320
+ dataType,
315
321
  disabledUiFeatures,
316
322
  expandNavigator,
317
323
  filter,
@@ -319,7 +325,6 @@ export class CadenzaClient {
319
325
  hideWorkbookToolBar,
320
326
  highlightGlobalId,
321
327
  labelSet,
322
- dataType,
323
328
  operationMode,
324
329
  });
325
330
  return this.#show(resolvePath(source), params, signal);
@@ -353,6 +358,7 @@ export class CadenzaClient {
353
358
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
354
359
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
355
360
  * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
361
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
356
362
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
357
363
  * @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map
358
364
  * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
@@ -363,7 +369,6 @@ export class CadenzaClient {
363
369
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
364
370
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
365
371
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
366
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
367
372
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
368
373
  * @throws For invalid arguments
369
374
  * @fires
@@ -371,16 +376,16 @@ export class CadenzaClient {
371
376
  * - {@link CadenzaActionEvent}
372
377
  * @embed
373
378
  */
374
- async showMap(mapView, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, extentStrategy, signal, additionalLayers, } = {}) {
379
+ async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
375
380
  this.#log('CadenzaClient#showMap', ...arguments);
376
381
  if (geometry) {
377
382
  assertValidGeometryType(geometry.type);
378
383
  }
379
384
  const validExtentStrategy = sanitizeExtentStrategy({
385
+ extentStrategy,
380
386
  geometry,
381
387
  locationFinder,
382
388
  mapExtent,
383
- extentStrategy,
384
389
  });
385
390
  const params = createParams({
386
391
  disabledUiFeatures,
@@ -536,14 +541,15 @@ export class CadenzaClient {
536
541
  * @param {object} [__namedParameters] - Options
537
542
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
538
543
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
544
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
539
545
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
540
546
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
541
547
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
542
548
  * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
543
549
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
544
550
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
551
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
545
552
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS and the created geometry should use the map's SRS (otherwise EPSG:4326 is assumed)
546
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
547
553
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
548
554
  * @throws For invalid arguments
549
555
  * @fires
@@ -552,12 +558,12 @@ export class CadenzaClient {
552
558
  * - {@link CadenzaEditGeometryCancelEvent}
553
559
  * @embed
554
560
  */
555
- async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
561
+ async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
556
562
  this.#log('CadenzaClient#createGeometry', ...arguments);
557
563
  const validExtentStrategy = sanitizeExtentStrategy({
564
+ extentStrategy,
558
565
  locationFinder,
559
566
  mapExtent,
560
- extentStrategy,
561
567
  });
562
568
  const params = createParams({
563
569
  action: 'editGeometry',
@@ -566,6 +572,7 @@ export class CadenzaClient {
566
572
  geometryType,
567
573
  minScale,
568
574
  operationMode,
575
+ snapping,
569
576
  useMapSrs,
570
577
  validExtentStrategy,
571
578
  });
@@ -585,14 +592,15 @@ export class CadenzaClient {
585
592
  * @param {object} [__namedParameters] - Options
586
593
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing. Each is a layer definition, with name, type and content (a Geojson featureCollection).
587
594
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
595
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
588
596
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
589
597
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
590
598
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
591
599
  * @param {number} [__namedParameters.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
592
600
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
593
601
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
602
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
594
603
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
595
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
596
604
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
597
605
  * @throws For invalid arguments
598
606
  * @fires
@@ -601,14 +609,14 @@ export class CadenzaClient {
601
609
  * - {@link CadenzaEditGeometryCancelEvent}
602
610
  * @embed
603
611
  */
604
- async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, operationMode, signal, useMapSrs, extentStrategy, } = {}) {
612
+ async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
605
613
  this.#log('CadenzaClient#editGeometry', ...arguments);
606
614
  assertValidGeometryType(geometry.type);
607
615
  const validExtentStrategy = sanitizeExtentStrategy({
616
+ extentStrategy,
608
617
  geometry,
609
618
  locationFinder,
610
619
  mapExtent,
611
- extentStrategy,
612
620
  });
613
621
  const params = createParams({
614
622
  action: 'editGeometry',
@@ -616,6 +624,7 @@ export class CadenzaClient {
616
624
  filter,
617
625
  minScale,
618
626
  operationMode,
627
+ snapping,
619
628
  useMapSrs,
620
629
  validExtentStrategy,
621
630
  });
@@ -650,6 +659,7 @@ export class CadenzaClient {
650
659
  *
651
660
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
652
661
  * @param {object} [__namedParameters] - Options
662
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
653
663
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
654
664
  * @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
655
665
  * (identified using layer paths or print names)
@@ -658,7 +668,6 @@ export class CadenzaClient {
658
668
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
659
669
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
660
670
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
661
- * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
662
671
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
663
672
  * @throws For invalid arguments
664
673
  * @fires
@@ -668,7 +677,7 @@ export class CadenzaClient {
668
677
  * - {@link CadenzaSelectObjectsCancelEvent}
669
678
  * @embed
670
679
  */
671
- async selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
680
+ async selectObjects(backgroundMapView, { extentStrategy, filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, } = {}) {
672
681
  this.#log('CadenzaClient#selectObjects', ...arguments);
673
682
  const validExtentStrategy = sanitizeExtentStrategy({
674
683
  geometry: undefined,
@@ -901,22 +910,22 @@ export class CadenzaClient {
901
910
  * @param {unknown[][]} objectIds - The IDs of the objects to select
902
911
  * @param {object} [__namedParameters] - Options
903
912
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
913
+ * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
904
914
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
905
915
  * @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84
906
- * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
907
916
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
908
917
  * @throws For invalid arguments
909
918
  */
910
- fetchObjectInfo(source, layerPath, objectIds, { filter, signal, useMapSrs, fullGeometries } = {}) {
919
+ fetchObjectInfo(source, layerPath, objectIds, { filter, signal, fullGeometries, useMapSrs } = {}) {
911
920
  this.#log('CadenzaClient#fetchObjectInfo', ...arguments);
912
921
  const params = createParams({
913
922
  filter,
914
923
  });
915
924
  return this.#fetch(resolvePath(source) + '/objectinfo', params, signal, JSON.stringify({
925
+ fullGeometries,
916
926
  objectIds,
917
927
  layerPath: array(layerPath),
918
928
  useMapSrs,
919
- fullGeometries,
920
929
  })).then((response) => response.json());
921
930
  }
922
931
  /**
@@ -927,20 +936,20 @@ export class CadenzaClient {
927
936
  * (identified using layer paths or print names)
928
937
  * @param {Geometry} geometry - The intersection geometry
929
938
  * @param {object} [__namedParameters] - Options
930
- * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
931
939
  * @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition
932
940
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
941
+ * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
933
942
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
934
943
  * @server
935
944
  */
936
- fetchAreaIntersections(source, layerPath, geometry, { useMapSrs, buffer, signal } = {}) {
945
+ fetchAreaIntersections(source, layerPath, geometry, { buffer, signal, useMapSrs } = {}) {
937
946
  this.#log('CadenzaClient#areaIntersections', ...arguments);
938
947
  const params = createParams({});
939
948
  return this.#fetch(resolvePath(source) + '/area-intersections', params, signal, JSON.stringify({
949
+ buffer,
940
950
  layerPath: array(layerPath),
941
- geometry: geometry,
942
- useMapSrs: useMapSrs,
943
- buffer: buffer,
951
+ geometry,
952
+ useMapSrs,
944
953
  })).then((response) => response.json());
945
954
  }
946
955
  async #fetch(
@@ -1133,11 +1142,12 @@ function assertSupportedDataType(
1133
1142
  * @param {OperationMode} [params.operationMode]
1134
1143
  * @param {TablePart[]} [params.parts]
1135
1144
  * @param {'MAP'} [params.targetType]
1145
+ * @param {SnappingOptions} [params.snapping]
1136
1146
  * @param {boolean} [params.useMapSrs]
1137
1147
  * @param {ExtentStrategy | undefined} [params.validExtentStrategy]
1138
1148
  * @return {URLSearchParams}
1139
1149
  */
1140
- function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, useMapSrs, validExtentStrategy, }) {
1150
+ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, }) {
1141
1151
  if (disabledUiFeatures) {
1142
1152
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
1143
1153
  }
@@ -1181,15 +1191,14 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1181
1191
  ...(hideWorkbookToolBar && { hideWorkbookToolBar: 'true' }),
1182
1192
  ...(highlightGlobalId && { highlightGlobalId }),
1183
1193
  ...(labelSet && { labelSet }),
1184
- ...(layers &&
1185
- layers.length && {
1186
- layers: JSON.stringify(layers),
1187
- }),
1194
+ ...(layers?.length && { layers: JSON.stringify(layers) }),
1188
1195
  ...(locationFinder && { locationFinder }),
1189
1196
  ...(mapExtent && { mapExtent: mapExtent.join() }),
1190
1197
  ...(minScale && { minScale: String(minScale) }),
1191
1198
  ...(operationMode && { operationMode }),
1192
1199
  ...(parts && { parts: parts.join() }),
1200
+ ...(snapping && { snappingLayer: JSON.stringify(array(snapping.layer)) }),
1201
+ ...(snapping?.types?.length && { snappingTypes: snapping.types.join() }),
1193
1202
  ...(targetType && { targetType }),
1194
1203
  ...(useMapSrs && { useMapSrs: 'true' }),
1195
1204
  });
@@ -1257,9 +1266,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
1257
1266
  * | 'editGeometry:update'
1258
1267
  * | 'editGeometry:cancel'
1259
1268
  * | 'objectInfo'
1269
+ * | 'reload'
1260
1270
  * | 'selectObjects:ok'
1261
1271
  * | 'selectObjects:cancel'
1262
- * | 'reload'
1263
1272
  * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
1264
1273
  */
1265
1274
  /**
@@ -1271,9 +1280,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
1271
1280
  * : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent
1272
1281
  * : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent
1273
1282
  * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
1283
+ * : T extends 'reload' ? CadenzaReloadEvent
1274
1284
  * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
1275
1285
  * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
1276
- * : T extends 'reload' ? CadenzaReloadEvent
1277
1286
  * : never
1278
1287
  * } CadenzaEventByType
1279
1288
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disy/cadenza.js",
3
- "version": "10.2.9",
3
+ "version": "10.2.10",
4
4
  "license": "Apache-2.0",
5
5
  "repository": "github:DisyInformationssysteme/cadenza.js",
6
6
  "type": "module",
@@ -30,20 +30,20 @@
30
30
  "sandbox": "node ./sandbox.cjs"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/jest": "29.5.12",
33
+ "@types/jest": "29.5.14",
34
34
  "cross-env": "7.0.3",
35
- "gh-pages": "6.1.1",
35
+ "gh-pages": "6.3.0",
36
36
  "http-server": "14.1.1",
37
37
  "jest": "29.7.0",
38
38
  "jest-environment-jsdom": "29.7.0",
39
- "keep-a-changelog": "2.5.3",
39
+ "keep-a-changelog": "2.6.1",
40
40
  "npm-run-all": "4.1.5",
41
41
  "onchange": "7.1.0",
42
- "prettier": "3.2.5",
43
- "ts-jest": "29.1.2",
44
- "typedoc": "0.25.13"
42
+ "prettier": "3.5.3",
43
+ "ts-jest": "29.2.6",
44
+ "typedoc": "0.27.9"
45
45
  },
46
46
  "volta": {
47
- "node": "16.13.1"
47
+ "node": "20.18.3"
48
48
  }
49
49
  }