@disy/cadenza.js 2.5.0 → 2.6.1
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 +12 -1
- package/apidoc/assets/search.js +1 -1
- package/apidoc/classes/AbortError.html +2 -2
- package/apidoc/classes/CadenzaClient.html +24 -20
- package/apidoc/classes/CadenzaError.html +3 -3
- package/apidoc/functions/cadenza.html +1 -1
- package/apidoc/interfaces/CadenzaEvent.html +3 -3
- package/apidoc/interfaces/ExternalLinkKey.html +3 -3
- package/apidoc/interfaces/Geometry.html +2 -2
- package/apidoc/interfaces/PageSource.html +2 -2
- package/apidoc/types/CadenzaChangeSelectionEvent.html +1 -1
- package/apidoc/types/CadenzaDrillThroughEvent.html +1 -1
- package/apidoc/types/CadenzaEditGeometryCancelEvent.html +1 -1
- package/apidoc/types/CadenzaEditGeometryOkEvent.html +1 -1
- package/apidoc/types/CadenzaEditGeometryUpdateEvent.html +1 -1
- package/apidoc/types/CadenzaErrorEvent.html +1 -1
- package/apidoc/types/CadenzaEventByType.html +1 -1
- package/apidoc/types/CadenzaEventType.html +1 -1
- package/apidoc/types/CadenzaObjectInfoEvent.html +1 -1
- package/apidoc/types/CadenzaSelectObjectsCancelEvent.html +1 -1
- package/apidoc/types/CadenzaSelectObjectsOkEvent.html +1 -1
- package/apidoc/types/DataType.html +1 -1
- package/apidoc/types/EmbeddingTargetId.html +1 -1
- package/apidoc/types/Extent.html +1 -1
- package/apidoc/types/FilterVariables.html +1 -1
- package/apidoc/types/GeometryType.html +1 -1
- package/apidoc/types/GlobalId.html +1 -1
- package/apidoc/types/OpaqueString.html +1 -1
- package/apidoc/types/OperationMode.html +1 -1
- package/apidoc/types/TablePart.html +1 -1
- package/apidoc/types/UiFeature.html +1 -1
- package/apidoc/types/WorkbookLayerPath.html +1 -1
- package/cadenza.d.ts +15 -3
- package/cadenza.js +25 -7
- package/package.json +1 -1
- package/sandbox.html +3 -3
package/cadenza.js
CHANGED
|
@@ -162,6 +162,9 @@ export class CadenzaClient {
|
|
|
162
162
|
}
|
|
163
163
|
return this.#iframeElement;
|
|
164
164
|
}
|
|
165
|
+
get #targetWindow() {
|
|
166
|
+
return /** @type {WindowProxy | null} */ this.iframe?.contentWindow;
|
|
167
|
+
}
|
|
165
168
|
get #requiredIframe() {
|
|
166
169
|
const iframe = /** @type {HTMLIFrameElement} */ (this.iframe);
|
|
167
170
|
assert(iframe instanceof HTMLIFrameElement, 'Required iframe is not present.');
|
|
@@ -358,6 +361,7 @@ export class CadenzaClient {
|
|
|
358
361
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
359
362
|
* @param {GeometryType} geometryType - The geometry type
|
|
360
363
|
* @param {object} [options] - Options
|
|
364
|
+
* @param {FilterVariables} [options.filter] - Filter variables
|
|
361
365
|
* @param {string} [options.locationFinder] - A search query for the location finder
|
|
362
366
|
* @param {Extent} [options.mapExtent] - A map extent to set
|
|
363
367
|
* @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
|
|
@@ -370,10 +374,11 @@ export class CadenzaClient {
|
|
|
370
374
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
371
375
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
372
376
|
*/
|
|
373
|
-
createGeometry(backgroundMapView, geometryType, { locationFinder, mapExtent, minScale, useMapSrs, signal } = {}) {
|
|
377
|
+
createGeometry(backgroundMapView, geometryType, { filter, locationFinder, mapExtent, minScale, useMapSrs, signal } = {}) {
|
|
374
378
|
this.#log('CadenzaClient#createGeometry', ...arguments);
|
|
375
379
|
const params = createParams({
|
|
376
380
|
action: 'editGeometry',
|
|
381
|
+
filter,
|
|
377
382
|
geometryType,
|
|
378
383
|
locationFinder,
|
|
379
384
|
mapExtent,
|
|
@@ -388,6 +393,7 @@ export class CadenzaClient {
|
|
|
388
393
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view in the background
|
|
389
394
|
* @param {Geometry} geometry - The geometry
|
|
390
395
|
* @param {object} [options] - Options
|
|
396
|
+
* @param {FilterVariables} [options.filter] - Filter variables
|
|
391
397
|
* @param {string} [options.locationFinder] - A search query for the location finder
|
|
392
398
|
* @param {Extent} [options.mapExtent] - A map extent to set
|
|
393
399
|
* @param {number} [options.minScale] - The minimum scale where the user should work on. A warning is shown when the map is zoomed out above the threshold.
|
|
@@ -400,11 +406,12 @@ export class CadenzaClient {
|
|
|
400
406
|
* - {@link CadenzaEditGeometryOkEvent}
|
|
401
407
|
* - {@link CadenzaEditGeometryCancelEvent}
|
|
402
408
|
*/
|
|
403
|
-
async editGeometry(backgroundMapView, geometry, { locationFinder, mapExtent, minScale, useMapSrs, signal } = {}) {
|
|
409
|
+
async editGeometry(backgroundMapView, geometry, { filter, locationFinder, mapExtent, minScale, useMapSrs, signal } = {}) {
|
|
404
410
|
this.#log('CadenzaClient#editGeometry', ...arguments);
|
|
405
411
|
assertValidGeometryType(geometry.type);
|
|
406
412
|
const params = createParams({
|
|
407
413
|
action: 'editGeometry',
|
|
414
|
+
filter,
|
|
408
415
|
locationFinder,
|
|
409
416
|
mapExtent,
|
|
410
417
|
minScale,
|
|
@@ -420,6 +427,7 @@ export class CadenzaClient {
|
|
|
420
427
|
*
|
|
421
428
|
* @param {EmbeddingTargetId} backgroundMapView - The workbook map view
|
|
422
429
|
* @param {object} [options] - Options
|
|
430
|
+
* @param {FilterVariables} [options.filter] - Filter variables
|
|
423
431
|
* @param {(WorkbookLayerPath | string)[]} [options.layers] - Layers to restrict the selection to
|
|
424
432
|
* (identified using layer paths or print names)
|
|
425
433
|
* @param {string} [options.locationFinder] - A search query for the location finder
|
|
@@ -434,10 +442,11 @@ export class CadenzaClient {
|
|
|
434
442
|
* - {@link CadenzaSelectObjectsOkEvent}
|
|
435
443
|
* - {@link CadenzaSelectObjectsCancelEvent}
|
|
436
444
|
*/
|
|
437
|
-
selectObjects(backgroundMapView, { layers, locationFinder, mapExtent, useMapSrs, signal } = {}) {
|
|
445
|
+
selectObjects(backgroundMapView, { filter, layers, locationFinder, mapExtent, useMapSrs, signal } = {}) {
|
|
438
446
|
this.#log('CadenzaClient#selectObjects', ...arguments);
|
|
439
447
|
const params = createParams({
|
|
440
448
|
action: 'selectObjects',
|
|
449
|
+
filter,
|
|
441
450
|
layers: layers?.map(array),
|
|
442
451
|
locationFinder,
|
|
443
452
|
mapExtent,
|
|
@@ -559,8 +568,7 @@ export class CadenzaClient {
|
|
|
559
568
|
// Use arrow function so that it's bound to this.
|
|
560
569
|
#onMessage = (
|
|
561
570
|
/** @type MessageEvent<CadenzaEvent<never, never>> */ event) => {
|
|
562
|
-
if (event.origin !== this.#origin ||
|
|
563
|
-
event.source !== this.#requiredIframe.contentWindow) {
|
|
571
|
+
if (event.origin !== this.#origin || event.source !== this.#targetWindow) {
|
|
564
572
|
return;
|
|
565
573
|
}
|
|
566
574
|
const cadenzaEvent = event.data;
|
|
@@ -571,6 +579,15 @@ export class CadenzaClient {
|
|
|
571
579
|
}
|
|
572
580
|
});
|
|
573
581
|
};
|
|
582
|
+
/**
|
|
583
|
+
* Remove all subscriptions.
|
|
584
|
+
*
|
|
585
|
+
* @see {@link CadenzaClient#on}
|
|
586
|
+
*/
|
|
587
|
+
destroy() {
|
|
588
|
+
this.#subscriptions = [];
|
|
589
|
+
window.removeEventListener('message', this.#onMessage);
|
|
590
|
+
}
|
|
574
591
|
/**
|
|
575
592
|
* Posts an event to Cadenza and returns a `Promise` for the response.
|
|
576
593
|
*
|
|
@@ -606,8 +623,9 @@ export class CadenzaClient {
|
|
|
606
623
|
#postEvent(type, detail, transfer) {
|
|
607
624
|
const cadenzaEvent = { type, detail };
|
|
608
625
|
this.#log('postMessage', cadenzaEvent);
|
|
609
|
-
const
|
|
610
|
-
|
|
626
|
+
const targetWindow = this.#targetWindow;
|
|
627
|
+
assert(targetWindow != null, 'Cannot find target window');
|
|
628
|
+
/** @type {WindowProxy} */ (targetWindow).postMessage(cadenzaEvent, {
|
|
611
629
|
targetOrigin: this.#origin,
|
|
612
630
|
transfer,
|
|
613
631
|
});
|
package/package.json
CHANGED
package/sandbox.html
CHANGED
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
|
|
441
441
|
<template data-action="setFilter" data-common="filter"></template>
|
|
442
442
|
|
|
443
|
-
<template data-action="createGeometry" data-common="map">
|
|
443
|
+
<template data-action="createGeometry" data-common="map,filter">
|
|
444
444
|
<div>
|
|
445
445
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
446
446
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|
|
@@ -462,7 +462,7 @@
|
|
|
462
462
|
</div>
|
|
463
463
|
</template>
|
|
464
464
|
|
|
465
|
-
<template data-action="editGeometry" data-common="map">
|
|
465
|
+
<template data-action="editGeometry" data-common="map,filter">
|
|
466
466
|
<div>
|
|
467
467
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
468
468
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|
|
@@ -477,7 +477,7 @@
|
|
|
477
477
|
</div>
|
|
478
478
|
</template>
|
|
479
479
|
|
|
480
|
-
<template data-action="selectObjects" data-common="map">
|
|
480
|
+
<template data-action="selectObjects" data-common="map,filter">
|
|
481
481
|
<div>
|
|
482
482
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
483
483
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|