@disy/cadenza.js 2.3.0 → 2.3.2
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 +8 -0
- package/apidoc/classes/AbortError.html +2 -2
- package/apidoc/classes/CadenzaClient.html +19 -22
- 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 +2 -2
- 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 +11 -80
- package/cadenza.js +37 -9
- package/package.json +1 -1
- package/sandbox.html +15 -12
package/cadenza.js
CHANGED
|
@@ -96,6 +96,9 @@ globalThis.cadenza = Object.assign((/** @type Parameters<cadenza> */ ...args) =>
|
|
|
96
96
|
* _Note:_ Since numbers in JavaScript are Double values ([more info on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_encoding)),
|
|
97
97
|
* for Long variables, the API is currently limited to the Double value range.
|
|
98
98
|
*/
|
|
99
|
+
let hasCadenzaSession = false;
|
|
100
|
+
/** @type {Promise<void> | undefined} */
|
|
101
|
+
let firstEmbeddingTargetShown;
|
|
99
102
|
/**
|
|
100
103
|
* _Notes:_
|
|
101
104
|
* * Most public methods can be aborted using an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
|
|
@@ -442,10 +445,24 @@ export class CadenzaClient {
|
|
|
442
445
|
});
|
|
443
446
|
return this.#show(resolvePath(backgroundMapView), params, signal);
|
|
444
447
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
448
|
+
/**
|
|
449
|
+
* @param {string} path
|
|
450
|
+
* @param {URLSearchParams} params
|
|
451
|
+
* @param {AbortSignal} [signal]
|
|
452
|
+
* @return {Promise<void>}
|
|
453
|
+
*/
|
|
454
|
+
#show(path, params, signal) {
|
|
455
|
+
const waitForFirstEmbeddingTargetShown = !(hasCadenzaSession || isTest());
|
|
456
|
+
/*
|
|
457
|
+
* If we show multiple embedding targets at the same time,
|
|
458
|
+
* there's a race condition in the session creation for guest users.
|
|
459
|
+
* To work around that, we wait for the first embedding target to be shown
|
|
460
|
+
* (which implicitly creates the session for all embedding targets).
|
|
461
|
+
* Note: We do not wait in tests to keep them simple.
|
|
462
|
+
*/
|
|
463
|
+
if (waitForFirstEmbeddingTargetShown && firstEmbeddingTargetShown != null) {
|
|
464
|
+
return firstEmbeddingTargetShown.finally(() => this.#show(path, params, signal));
|
|
465
|
+
}
|
|
449
466
|
const webApplication = this.#webApplication;
|
|
450
467
|
if (webApplication) {
|
|
451
468
|
params.set('webApplicationLink', webApplication.externalLinkId);
|
|
@@ -454,7 +471,15 @@ export class CadenzaClient {
|
|
|
454
471
|
const url = this.#createUrl(path, params);
|
|
455
472
|
this.#log('Load iframe', url.toString());
|
|
456
473
|
this.#requiredIframe.src = url.toString();
|
|
457
|
-
|
|
474
|
+
const promise = this.#getIframePromise(signal);
|
|
475
|
+
if (waitForFirstEmbeddingTargetShown) {
|
|
476
|
+
// Use Promise.allSettled() to handle Promise rejections.
|
|
477
|
+
firstEmbeddingTargetShown ??= Promise.allSettled([promise]).then(([{ status }]) => {
|
|
478
|
+
firstEmbeddingTargetShown = undefined;
|
|
479
|
+
hasCadenzaSession = status === 'fulfilled';
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
return promise;
|
|
458
483
|
}
|
|
459
484
|
#getIframePromise(/** @type AbortSignal | undefined */ signal) {
|
|
460
485
|
const iframe = this.#requiredIframe;
|
|
@@ -594,7 +619,7 @@ export class CadenzaClient {
|
|
|
594
619
|
* Currently only table and indicator views are supported.
|
|
595
620
|
* @param {DataType} dataType - The data type you want to get back from the server.
|
|
596
621
|
* Currently, `"csv"`, `"excel"` and `"json"` are supported.
|
|
597
|
-
* @param {object} options - Options
|
|
622
|
+
* @param {object} [options] - Options
|
|
598
623
|
* @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
|
|
599
624
|
* @param {AbortSignal} [options.signal] - A signal to abort the data fetching
|
|
600
625
|
* @return {Promise<Response>} A `Promise` for the fetch response
|
|
@@ -632,12 +657,12 @@ export class CadenzaClient {
|
|
|
632
657
|
* Currently only table and indicator views are supported.
|
|
633
658
|
* @param {DataType} dataType - The data type you want to get back from the server.
|
|
634
659
|
* Currently, `"csv"`, `"excel"` and `"json"` are supported.
|
|
635
|
-
* @param {object} options - Options
|
|
660
|
+
* @param {object} [options] - Options
|
|
636
661
|
* @param {string} [options.fileName] - The file name to use; The file extension is appended by Cadenza.
|
|
637
662
|
* @param {TablePart[]} [options.parts] - Table parts to export; If not specified, all parts are exported.
|
|
638
663
|
* @throws For invalid arguments
|
|
639
664
|
*/
|
|
640
|
-
downloadData(source, dataType, { fileName, parts }) {
|
|
665
|
+
downloadData(source, dataType, { fileName, parts } = {}) {
|
|
641
666
|
this.#log('CadenzaClient#downloadData', ...arguments);
|
|
642
667
|
assertSupportedDataType(dataType, ['csv', 'excel', 'json']);
|
|
643
668
|
const params = createParams({ dataType, fileName, parts });
|
|
@@ -882,7 +907,7 @@ function array(/** @type unknown */ value) {
|
|
|
882
907
|
/** @typedef {CadenzaEvent<'editGeometry:ok', {geometry: Geometry}>} CadenzaEditGeometryOkEvent - When the user submitted the geometry. */
|
|
883
908
|
/** @typedef {CadenzaEvent<'editGeometry:cancel'>} CadenzaEditGeometryCancelEvent - When the user cancelled the geometry editing. */
|
|
884
909
|
/** @typedef {CadenzaEvent<'error', {type: string, message?: string}>} CadenzaErrorEvent - An error event that is mapped to a {@link CadenzaError} */
|
|
885
|
-
/** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number,
|
|
910
|
+
/** @typedef {CadenzaEvent<'objectInfo', {layer: WorkbookLayerPath, objectInfos: {selectionIndex: number, elements: {attributePrintName: string, formattedValue: string}[]}}>} CadenzaObjectInfoEvent - When the user opened the object info flyout. */
|
|
886
911
|
/** @typedef {CadenzaEvent<'selectObjects:ok', {layer: WorkbookLayerPath, values: unknown[][]}>} CadenzaSelectObjectsOkEvent - When the user submitted the selection. */
|
|
887
912
|
/** @typedef {CadenzaEvent<'selectObjects:cancel'>} CadenzaSelectObjectsCancelEvent - When the user cancelled the selection. */
|
|
888
913
|
export class AbortError extends DOMException {
|
|
@@ -909,3 +934,6 @@ export class CadenzaError extends Error {
|
|
|
909
934
|
return this.#type;
|
|
910
935
|
}
|
|
911
936
|
}
|
|
937
|
+
function isTest() {
|
|
938
|
+
return location.href === 'test';
|
|
939
|
+
}
|
package/package.json
CHANGED
package/sandbox.html
CHANGED
|
@@ -291,18 +291,19 @@
|
|
|
291
291
|
</footer>
|
|
292
292
|
|
|
293
293
|
<template id="common-show">
|
|
294
|
-
<div>
|
|
295
|
-
<label>
|
|
296
|
-
<input type="checkbox" name="expandNavigator">
|
|
297
|
-
Expand navigator tree
|
|
298
|
-
</label>
|
|
299
|
-
</div>
|
|
300
294
|
<div>
|
|
301
295
|
<label>
|
|
302
296
|
<input type="checkbox" name="hideMainHeaderAndFooter">
|
|
303
297
|
Hide main header and footer
|
|
304
298
|
</label>
|
|
305
299
|
</div>
|
|
300
|
+
<div>
|
|
301
|
+
<label for="highlightGlobalId">Highlighted Global ID</label>
|
|
302
|
+
<input name="highlightGlobalId" id="highlightGlobalId">
|
|
303
|
+
</div>
|
|
304
|
+
</template>
|
|
305
|
+
|
|
306
|
+
<template id="common-showWorkbook">
|
|
306
307
|
<div>
|
|
307
308
|
<label>
|
|
308
309
|
<input type="checkbox" name="hideWorkbookToolBar">
|
|
@@ -315,10 +316,6 @@
|
|
|
315
316
|
Simplified operation mode
|
|
316
317
|
</label>
|
|
317
318
|
</div>
|
|
318
|
-
<div>
|
|
319
|
-
<label for="highlightGlobalId">Highlighted Global ID</label>
|
|
320
|
-
<input name="highlightGlobalId" id="highlightGlobalId">
|
|
321
|
-
</div>
|
|
322
319
|
<div>
|
|
323
320
|
<label for="disabledUiFeatures">Disabled UI features</label>
|
|
324
321
|
<input name="disabledUiFeatures" id="disabledUiFeatures" placeholder="feature1,feature2,...">
|
|
@@ -343,6 +340,12 @@
|
|
|
343
340
|
<p>Pass <code>null</code> to unset a variable.</p>
|
|
344
341
|
</small>
|
|
345
342
|
</div>
|
|
343
|
+
<div>
|
|
344
|
+
<label>
|
|
345
|
+
<input type="checkbox" name="expandNavigator">
|
|
346
|
+
Expand navigator tree
|
|
347
|
+
</label>
|
|
348
|
+
</div>
|
|
346
349
|
</template>
|
|
347
350
|
|
|
348
351
|
<template id="common-map">
|
|
@@ -385,7 +388,7 @@
|
|
|
385
388
|
</div>
|
|
386
389
|
</template>
|
|
387
390
|
|
|
388
|
-
<template data-action="show" data-common="show">
|
|
391
|
+
<template data-action="show" data-common="showWorkbook,show">
|
|
389
392
|
<div>
|
|
390
393
|
<label for="embeddingTargetId">Embedding target ID *</label>
|
|
391
394
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|
|
@@ -421,7 +424,7 @@
|
|
|
421
424
|
</div>
|
|
422
425
|
</template>
|
|
423
426
|
|
|
424
|
-
<template data-action="showMap" data-common="map,show">
|
|
427
|
+
<template data-action="showMap" data-common="map,showWorkbook,show">
|
|
425
428
|
<div>
|
|
426
429
|
<label for="embeddingTargetId">Embedding target ID of the map view *</label>
|
|
427
430
|
<input name="embeddingTargetId" id="embeddingTargetId" required>
|