@disy/cadenza.js 10.2.9 → 10.2.11

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 +9 -2
  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 +4 -3
  56. package/apidoc/types/WorkbookLayerPath.html +3 -3
  57. package/cadenza.d.ts +38 -23
  58. package/cadenza.js +41 -30
  59. package/package.json +8 -8
  60. package/sandbox.html +64 -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
  */
@@ -620,11 +624,12 @@ export type OperationMode = 'normal' | 'simplified';
620
624
  * - The name of a Cadenza UI feature
621
625
  *
622
626
  * _Note:_ Supported features are:
627
+ * * `"geometry-edit-translate"` - Enables translation interactions when editing geometries
623
628
  * * `"workbook-design"` - The workbook designer
624
629
  * * `"workbook-map-add-layer"`- Add layers to the map
625
630
  * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
626
631
  */
627
- export type UiFeature = 'workbook-design' | 'workbook-map-add-layer' | 'workbook-view-management';
632
+ export type UiFeature = 'geometry-edit-translate' | 'workbook-design' | 'workbook-map-add-layer' | 'workbook-view-management';
628
633
  export type LayerDefinition = {
629
634
  /**
630
635
  * - The layer's name.
@@ -800,11 +805,21 @@ export type FeatureCollection = {
800
805
  * - The type of custom validity used for disclose on visual presentation and form submission behavior
801
806
  */
802
807
  export type CustomValidityType = 'error' | 'warning' | 'info' | 'success';
808
+ export type SnappingOptions = {
809
+ /**
810
+ * - The layer to snap to
811
+ */
812
+ layer: WorkbookLayerPath | string;
813
+ /**
814
+ * - Snapping types; Without this option, the Cadenza default snapping types are used.
815
+ */
816
+ types?: ("toVertices" | "toEdges" | "lineTracing")[] | undefined;
817
+ };
803
818
  /**
804
819
  * - An event type to subscribe to using {@link CadenzaClienton }
805
820
  */
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;
821
+ export type CadenzaEventType = 'action' | 'change:selection' | 'drillThrough' | 'editGeometry:ok' | 'editGeometry:update' | 'editGeometry:cancel' | 'objectInfo' | 'reload' | 'selectObjects:ok' | 'selectObjects:cancel';
822
+ 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
823
  /**
809
824
  * - A Cadenza `postMessage()` event
810
825
  */
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.11';
16
16
  /**
17
17
  * Creates an instance of the Cadenza JS client.
18
18
  *
@@ -95,9 +95,10 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
95
95
  */
96
96
  /** @typedef {'normal'|'simplified'} OperationMode - The mode in which a workbook should be operated */
97
97
  /**
98
- * @typedef {'workbook-design'|'workbook-map-add-layer'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
98
+ * @typedef {'geometry-edit-translate'|'workbook-design'|'workbook-map-add-layer'|'workbook-view-management'} UiFeature - The name of a Cadenza UI feature
99
99
  *
100
100
  * _Note:_ Supported features are:
101
+ * * `"geometry-edit-translate"` - Enables translation interactions when editing geometries
101
102
  * * `"workbook-design"` - The workbook designer
102
103
  * * `"workbook-map-add-layer"`- Add layers to the map
103
104
  * * `"workbook-view-management"` - Add/Edit/Remove workbook views (Is included in 'workbook-design'.)
@@ -188,6 +189,11 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
188
189
  * @property {Feature[]} features - The features within this collection
189
190
  */
190
191
  /** @typedef {'error'|'warning'|'info'|'success'} CustomValidityType - The type of custom validity used for disclose on visual presentation and form submission behavior */
192
+ /**
193
+ * @typedef SnappingOptions
194
+ * @property {WorkbookLayerPath | string} layer - The layer to snap to
195
+ * @property {('toVertices' | 'toEdges' | 'lineTracing')[]} [types] - Snapping types; Without this option, the Cadenza default snapping types are used.
196
+ */
191
197
  let hasCadenzaSession = false;
192
198
  /** @type {Promise<void> | undefined} */
193
199
  let firstEmbeddingTargetShown;
@@ -267,7 +273,7 @@ export class CadenzaClient {
267
273
  const targetWindow = this.#iframe
268
274
  ? this.iframe?.contentWindow
269
275
  : // 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);
276
+ (window.opener ?? (window.parent !== window ? window.parent : null));
271
277
  return /** @type {WindowProxy | null} */ targetWindow;
272
278
  }
273
279
  get #requiredIframe() {
@@ -312,6 +318,7 @@ export class CadenzaClient {
312
318
  source.page === 'welcome', 'labelSet is only supported on the welcome page');
313
319
  }
314
320
  const params = createParams({
321
+ dataType,
315
322
  disabledUiFeatures,
316
323
  expandNavigator,
317
324
  filter,
@@ -319,7 +326,6 @@ export class CadenzaClient {
319
326
  hideWorkbookToolBar,
320
327
  highlightGlobalId,
321
328
  labelSet,
322
- dataType,
323
329
  operationMode,
324
330
  });
325
331
  return this.#show(resolvePath(source), params, signal);
@@ -353,6 +359,7 @@ export class CadenzaClient {
353
359
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
354
360
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
355
361
  * @param {boolean} [__namedParameters.expandNavigator] - Indicates if the navigator should be expanded.
362
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
356
363
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
357
364
  * @param {Geometry} [__namedParameters.geometry] - A geometry to show on the map
358
365
  * @param {boolean} [__namedParameters.hideMainHeaderAndFooter] - Whether to hide the main Cadenza header and footer
@@ -363,7 +370,6 @@ export class CadenzaClient {
363
370
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
364
371
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
365
372
  * @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
373
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
368
374
  * @throws For invalid arguments
369
375
  * @fires
@@ -371,16 +377,16 @@ export class CadenzaClient {
371
377
  * - {@link CadenzaActionEvent}
372
378
  * @embed
373
379
  */
374
- async showMap(mapView, { disabledUiFeatures, expandNavigator, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, extentStrategy, signal, additionalLayers, } = {}) {
380
+ async showMap(mapView, { additionalLayers, disabledUiFeatures, expandNavigator, extentStrategy, filter, geometry, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, locationFinder, mapExtent, operationMode, useMapSrs, signal, } = {}) {
375
381
  this.#log('CadenzaClient#showMap', ...arguments);
376
382
  if (geometry) {
377
383
  assertValidGeometryType(geometry.type);
378
384
  }
379
385
  const validExtentStrategy = sanitizeExtentStrategy({
386
+ extentStrategy,
380
387
  geometry,
381
388
  locationFinder,
382
389
  mapExtent,
383
- extentStrategy,
384
390
  });
385
391
  const params = createParams({
386
392
  disabledUiFeatures,
@@ -536,14 +542,15 @@ export class CadenzaClient {
536
542
  * @param {object} [__namedParameters] - Options
537
543
  * @param {LayerDefinition[]} [__namedParameters.additionalLayers] - Layer definitions to be imported and shown in the background, as a basis for the drawing.
538
544
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
545
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
539
546
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
540
547
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
541
548
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
542
549
  * @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
550
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
544
551
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
552
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
545
553
  * @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
554
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
548
555
  * @throws For invalid arguments
549
556
  * @fires
@@ -552,12 +559,12 @@ export class CadenzaClient {
552
559
  * - {@link CadenzaEditGeometryCancelEvent}
553
560
  * @embed
554
561
  */
555
- async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
562
+ async createGeometry(backgroundMapView, geometryType, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, useMapSrs, operationMode, signal, snapping, } = {}) {
556
563
  this.#log('CadenzaClient#createGeometry', ...arguments);
557
564
  const validExtentStrategy = sanitizeExtentStrategy({
565
+ extentStrategy,
558
566
  locationFinder,
559
567
  mapExtent,
560
- extentStrategy,
561
568
  });
562
569
  const params = createParams({
563
570
  action: 'editGeometry',
@@ -566,6 +573,7 @@ export class CadenzaClient {
566
573
  geometryType,
567
574
  minScale,
568
575
  operationMode,
576
+ snapping,
569
577
  useMapSrs,
570
578
  validExtentStrategy,
571
579
  });
@@ -585,14 +593,15 @@ export class CadenzaClient {
585
593
  * @param {object} [__namedParameters] - Options
586
594
  * @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
595
  * @param {UiFeature[]} [__namedParameters.disabledUiFeatures] - Cadenza UI features to disable
596
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
588
597
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
589
598
  * @param {string} [__namedParameters.locationFinder] - A search query for the location finder - _Deprecated_: Use {@link LocationFinderExtentStrategy} instead.
590
599
  * @param {Extent} [__namedParameters.mapExtent] - A map extent to set - _Deprecated_: Use {@link StaticExtentStrategy} instead.
591
600
  * @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
601
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
593
602
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the iframe loading
603
+ * @param {SnappingOptions} [__namedParameters.snapping] - Passing these options enables snapping
594
604
  * @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
605
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
597
606
  * @throws For invalid arguments
598
607
  * @fires
@@ -601,14 +610,14 @@ export class CadenzaClient {
601
610
  * - {@link CadenzaEditGeometryCancelEvent}
602
611
  * @embed
603
612
  */
604
- async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, filter, locationFinder, mapExtent, minScale, operationMode, signal, useMapSrs, extentStrategy, } = {}) {
613
+ async editGeometry(backgroundMapView, geometry, { additionalLayers, disabledUiFeatures, extentStrategy, filter, locationFinder, mapExtent, minScale, operationMode, signal, snapping, useMapSrs, } = {}) {
605
614
  this.#log('CadenzaClient#editGeometry', ...arguments);
606
615
  assertValidGeometryType(geometry.type);
607
616
  const validExtentStrategy = sanitizeExtentStrategy({
617
+ extentStrategy,
608
618
  geometry,
609
619
  locationFinder,
610
620
  mapExtent,
611
- extentStrategy,
612
621
  });
613
622
  const params = createParams({
614
623
  action: 'editGeometry',
@@ -616,6 +625,7 @@ export class CadenzaClient {
616
625
  filter,
617
626
  minScale,
618
627
  operationMode,
628
+ snapping,
619
629
  useMapSrs,
620
630
  validExtentStrategy,
621
631
  });
@@ -650,6 +660,7 @@ export class CadenzaClient {
650
660
  *
651
661
  * @param {EmbeddingTargetId} backgroundMapView - The workbook map view
652
662
  * @param {object} [__namedParameters] - Options
663
+ * @param {ExtentStrategy} [__namedParameters.extentStrategy] - Defines the initial map extent; If not given, Cadenza's default logic is used.
653
664
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
654
665
  * @param {(WorkbookLayerPath | string)[]} [__namedParameters.layers] - Layers to restrict the selection to
655
666
  * (identified using layer paths or print names)
@@ -658,7 +669,6 @@ export class CadenzaClient {
658
669
  * @param {boolean} [__namedParameters.useMapSrs] - Whether the coordinates specified in other parameters are specified in the map's SRS (otherwise EPSG:4326 is assumed)
659
670
  * @param {OperationMode} [__namedParameters.operationMode] - The mode in which a workbook should be operated
660
671
  * @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
672
  * @return {Promise<void>} A `Promise` for when the iframe is loaded
663
673
  * @throws For invalid arguments
664
674
  * @fires
@@ -668,7 +678,7 @@ export class CadenzaClient {
668
678
  * - {@link CadenzaSelectObjectsCancelEvent}
669
679
  * @embed
670
680
  */
671
- async selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, extentStrategy, } = {}) {
681
+ async selectObjects(backgroundMapView, { extentStrategy, filter, layers, locationFinder, mapExtent, useMapSrs, operationMode, signal, } = {}) {
672
682
  this.#log('CadenzaClient#selectObjects', ...arguments);
673
683
  const validExtentStrategy = sanitizeExtentStrategy({
674
684
  geometry: undefined,
@@ -901,22 +911,22 @@ export class CadenzaClient {
901
911
  * @param {unknown[][]} objectIds - The IDs of the objects to select
902
912
  * @param {object} [__namedParameters] - Options
903
913
  * @param {FilterVariables} [__namedParameters.filter] - Filter variables
914
+ * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
904
915
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
905
916
  * @param {Boolean} [__namedParameters.useMapSrs] - Use the map SRS instead of WGS84
906
- * @param {Boolean} [__namedParameters.fullGeometries] - Return non-simplified geometries
907
917
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
908
918
  * @throws For invalid arguments
909
919
  */
910
- fetchObjectInfo(source, layerPath, objectIds, { filter, signal, useMapSrs, fullGeometries } = {}) {
920
+ fetchObjectInfo(source, layerPath, objectIds, { filter, signal, fullGeometries, useMapSrs } = {}) {
911
921
  this.#log('CadenzaClient#fetchObjectInfo', ...arguments);
912
922
  const params = createParams({
913
923
  filter,
914
924
  });
915
925
  return this.#fetch(resolvePath(source) + '/objectinfo', params, signal, JSON.stringify({
926
+ fullGeometries,
916
927
  objectIds,
917
928
  layerPath: array(layerPath),
918
929
  useMapSrs,
919
- fullGeometries,
920
930
  })).then((response) => response.json());
921
931
  }
922
932
  /**
@@ -927,20 +937,20 @@ export class CadenzaClient {
927
937
  * (identified using layer paths or print names)
928
938
  * @param {Geometry} geometry - The intersection geometry
929
939
  * @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
940
  * @param {Distance} [__namedParameters.buffer] - Buffer size for geometry of the transition
932
941
  * @param {AbortSignal} [__namedParameters.signal] - A signal to abort the data fetching
942
+ * @param {boolean} [__namedParameters.useMapSrs] - The intersection geometry and the result geometries are in the map's SRS (otherwise EPSG:4326 is assumed)
933
943
  * @return {Promise<FeatureCollection>} A `Promise` for the fetch response
934
944
  * @server
935
945
  */
936
- fetchAreaIntersections(source, layerPath, geometry, { useMapSrs, buffer, signal } = {}) {
946
+ fetchAreaIntersections(source, layerPath, geometry, { buffer, signal, useMapSrs } = {}) {
937
947
  this.#log('CadenzaClient#areaIntersections', ...arguments);
938
948
  const params = createParams({});
939
949
  return this.#fetch(resolvePath(source) + '/area-intersections', params, signal, JSON.stringify({
950
+ buffer,
940
951
  layerPath: array(layerPath),
941
- geometry: geometry,
942
- useMapSrs: useMapSrs,
943
- buffer: buffer,
952
+ geometry,
953
+ useMapSrs,
944
954
  })).then((response) => response.json());
945
955
  }
946
956
  async #fetch(
@@ -1105,6 +1115,7 @@ function validOperationMode(/** @type string */ value) {
1105
1115
  }
1106
1116
  function validUiFeature(/** @type string */ value) {
1107
1117
  return [
1118
+ 'geometry-edit-translate',
1108
1119
  'workbook-design',
1109
1120
  'workbook-map-add-layer',
1110
1121
  'workbook-view-management',
@@ -1133,11 +1144,12 @@ function assertSupportedDataType(
1133
1144
  * @param {OperationMode} [params.operationMode]
1134
1145
  * @param {TablePart[]} [params.parts]
1135
1146
  * @param {'MAP'} [params.targetType]
1147
+ * @param {SnappingOptions} [params.snapping]
1136
1148
  * @param {boolean} [params.useMapSrs]
1137
1149
  * @param {ExtentStrategy | undefined} [params.validExtentStrategy]
1138
1150
  * @return {URLSearchParams}
1139
1151
  */
1140
- function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, useMapSrs, validExtentStrategy, }) {
1152
+ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, fileName, filter, geometryType, hideMainHeaderAndFooter, hideWorkbookToolBar, highlightGlobalId, labelSet, layers, minScale, operationMode, parts, targetType, snapping, useMapSrs, validExtentStrategy, }) {
1141
1153
  if (disabledUiFeatures) {
1142
1154
  disabledUiFeatures.forEach((feature) => assert(validUiFeature(feature), `Invalid UI feature: ${feature}`));
1143
1155
  }
@@ -1181,15 +1193,14 @@ function createParams({ action, dataType, disabledUiFeatures, expandNavigator, f
1181
1193
  ...(hideWorkbookToolBar && { hideWorkbookToolBar: 'true' }),
1182
1194
  ...(highlightGlobalId && { highlightGlobalId }),
1183
1195
  ...(labelSet && { labelSet }),
1184
- ...(layers &&
1185
- layers.length && {
1186
- layers: JSON.stringify(layers),
1187
- }),
1196
+ ...(layers?.length && { layers: JSON.stringify(layers) }),
1188
1197
  ...(locationFinder && { locationFinder }),
1189
1198
  ...(mapExtent && { mapExtent: mapExtent.join() }),
1190
1199
  ...(minScale && { minScale: String(minScale) }),
1191
1200
  ...(operationMode && { operationMode }),
1192
1201
  ...(parts && { parts: parts.join() }),
1202
+ ...(snapping && { snappingLayer: JSON.stringify(array(snapping.layer)) }),
1203
+ ...(snapping?.types?.length && { snappingTypes: snapping.types.join() }),
1193
1204
  ...(targetType && { targetType }),
1194
1205
  ...(useMapSrs && { useMapSrs: 'true' }),
1195
1206
  });
@@ -1257,9 +1268,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
1257
1268
  * | 'editGeometry:update'
1258
1269
  * | 'editGeometry:cancel'
1259
1270
  * | 'objectInfo'
1271
+ * | 'reload'
1260
1272
  * | 'selectObjects:ok'
1261
1273
  * | 'selectObjects:cancel'
1262
- * | 'reload'
1263
1274
  * } CadenzaEventType - An event type to subscribe to using {@link CadenzaClient#on}
1264
1275
  */
1265
1276
  /**
@@ -1271,9 +1282,9 @@ function sanitizeExtentStrategy({ extentStrategy, mapExtent, locationFinder, geo
1271
1282
  * : T extends 'editGeometry:ok' ? CadenzaEditGeometryOkEvent
1272
1283
  * : T extends 'editGeometry:cancel' ? CadenzaEditGeometryCancelEvent
1273
1284
  * : T extends 'objectInfo' ? CadenzaObjectInfoEvent
1285
+ * : T extends 'reload' ? CadenzaReloadEvent
1274
1286
  * : T extends 'selectObjects:ok' ? CadenzaSelectObjectsOkEvent
1275
1287
  * : T extends 'selectObjects:cancel' ? CadenzaSelectObjectsCancelEvent
1276
- * : T extends 'reload' ? CadenzaReloadEvent
1277
1288
  * : never
1278
1289
  * } CadenzaEventByType
1279
1290
  */
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.11",
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
  }