@configura/web-api 1.6.0-iotest.4 → 1.6.0-rc.0
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/.eslintrc.json +18 -0
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/CatalogueAPI.d.ts +507 -511
- package/dist/CatalogueAPI.js +280 -273
- package/dist/CfgMeasure.d.ts +32 -32
- package/dist/CfgMeasure.js +30 -30
- package/dist/CfgProduct.d.ts +253 -240
- package/dist/CfgProduct.js +733 -668
- package/dist/index.d.ts +20 -24
- package/dist/index.js +20 -24
- package/dist/material/CfgMaterialMapping.d.ts +7 -7
- package/dist/material/CfgMaterialMapping.js +181 -181
- package/dist/material/CfgMtrlApplication.d.ts +18 -18
- package/dist/material/CfgMtrlApplication.js +43 -43
- package/dist/material/CfgMtrlApplicationSource.d.ts +7 -7
- package/dist/material/CfgMtrlApplicationSource.js +8 -8
- package/dist/material/CfgMtrlSource.d.ts +19 -19
- package/dist/material/CfgMtrlSource.js +40 -40
- package/dist/material/CfgMtrlSourceWithMetaData.d.ts +7 -7
- package/dist/material/CfgMtrlSourceWithMetaData.js +1 -1
- package/dist/productConfiguration/CfgFeature.d.ts +188 -178
- package/dist/productConfiguration/CfgFeature.js +636 -611
- package/dist/productConfiguration/CfgOption.d.ts +150 -128
- package/dist/productConfiguration/CfgOption.js +426 -394
- package/dist/productConfiguration/CfgProductConfiguration.d.ts +120 -121
- package/dist/productConfiguration/CfgProductConfiguration.js +309 -306
- package/dist/productConfiguration/filters.d.ts +15 -15
- package/dist/productConfiguration/filters.js +70 -67
- package/dist/productConfiguration/productParamsGenerator.d.ts +15 -15
- package/dist/productConfiguration/productParamsGenerator.js +51 -51
- package/dist/productConfiguration/utilitiesProductConfiguration.d.ts +17 -17
- package/dist/productConfiguration/utilitiesProductConfiguration.js +80 -80
- package/dist/productLoader.d.ts +33 -33
- package/dist/productLoader.js +49 -49
- package/dist/syncGroups/SyncGroupsApplyMode.d.ts +21 -0
- package/dist/syncGroups/SyncGroupsApplyMode.js +21 -0
- package/dist/syncGroups/SyncGroupsHandler.d.ts +36 -0
- package/dist/syncGroups/SyncGroupsHandler.js +349 -0
- package/dist/syncGroups/SyncGroupsPathHelper.d.ts +27 -0
- package/dist/syncGroups/SyncGroupsPathHelper.js +90 -0
- package/dist/syncGroups/SyncGroupsState.d.ts +26 -0
- package/dist/syncGroups/SyncGroupsState.js +113 -0
- package/dist/syncGroups/SyncGroupsTransaction.d.ts +155 -0
- package/dist/syncGroups/SyncGroupsTransaction.js +576 -0
- package/dist/tasks/TaskHandler.d.ts +78 -78
- package/dist/tasks/TaskHandler.js +276 -265
- package/dist/tasks/formats.d.ts +4 -4
- package/dist/tasks/formats.js +7 -7
- package/dist/tests/testData/collectorForTest.d.ts +73 -73
- package/dist/tests/testData/collectorForTest.js +194 -195
- package/dist/tests/testData/dummyProductForTest.d.ts +4 -4
- package/dist/tests/testData/dummyProductForTest.js +36 -36
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.d.ts +11 -32
- package/dist/tests/testData/testDataAdditionalProductInAdditionalProductInProductForTest.js +277 -348
- package/dist/tests/testData/testDataCachedGetProduct.d.ts +5 -5
- package/dist/tests/testData/testDataCachedGetProduct.js +185 -196
- package/dist/tests/testData/testDataCachedPostValidate.d.ts +7 -7
- package/dist/tests/testData/testDataCachedPostValidate.js +183 -183
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.d.ts +3 -3
- package/dist/tests/testData/testDataNoAdditionalProductNoPropagateForTest.js +1099 -1099
- package/dist/tests/testData/testDataOptions.d.ts +13 -0
- package/dist/tests/testData/testDataOptions.js +60 -0
- package/dist/tests/testData/testDataProductAggregatedPrice.d.ts +6 -6
- package/dist/tests/testData/testDataProductAggregatedPrice.js +187 -198
- package/dist/tests/testData/testDataUpcharge.d.ts +8 -29
- package/dist/tests/testData/testDataUpcharge.js +119 -151
- package/dist/utilitiesCatalogueData.d.ts +31 -25
- package/dist/utilitiesCatalogueData.js +162 -65
- package/dist/utilitiesCataloguePermission.d.ts +37 -39
- package/dist/utilitiesCataloguePermission.js +80 -84
- package/dist/utilitiesNumericValues.d.ts +24 -24
- package/dist/utilitiesNumericValues.js +109 -109
- package/package.json +3 -3
- package/dist/io/CfgHistoryManager.d.ts +0 -26
- package/dist/io/CfgHistoryManager.js +0 -58
- package/dist/io/CfgHistoryToCameraConfConnector.d.ts +0 -15
- package/dist/io/CfgHistoryToCameraConfConnector.js +0 -58
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +0 -14
- package/dist/io/CfgHistoryToProdConfConnector.js +0 -24
- package/dist/io/CfgIOCameraConfConnector.d.ts +0 -31
- package/dist/io/CfgIOCameraConfConnector.js +0 -72
- package/dist/io/CfgIOManager.d.ts +0 -29
- package/dist/io/CfgIOManager.js +0 -89
- package/dist/io/CfgIOProdConfConnector.d.ts +0 -36
- package/dist/io/CfgIOProdConfConnector.js +0 -102
- package/dist/io/CfgWindowMessageManager.d.ts +0 -13
- package/dist/io/CfgWindowMessageManager.js +0 -33
- package/dist/io/CfgWindowMessageToCameraConfConnector.d.ts +0 -6
- package/dist/io/CfgWindowMessageToCameraConfConnector.js +0 -6
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +0 -14
- package/dist/io/CfgWindowMessageToProdConfConnector.js +0 -17
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { CfgHistoryManager } from "./CfgHistoryManager.js";
|
|
2
|
-
import { CfgIOProdConfConnector, prodConfToString, STAGE_PROD_CONF_MESSAGE_KEY, } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
|
|
4
|
-
/**
|
|
5
|
-
* @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
|
|
6
|
-
*/
|
|
7
|
-
constructor(manager, _useHistoryPush, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
|
|
8
|
-
super(manager, doValidate);
|
|
9
|
-
this._useHistoryPush = _useHistoryPush;
|
|
10
|
-
this._qsKey = _qsKey;
|
|
11
|
-
}
|
|
12
|
-
getInitialProdConf() {
|
|
13
|
-
return CfgHistoryManager.currentQsKeyValues().get(this._qsKey);
|
|
14
|
-
}
|
|
15
|
-
makeSendData(prodConf, initial) {
|
|
16
|
-
return {
|
|
17
|
-
message: this.makeMessage(prodConf, initial),
|
|
18
|
-
qsKeyValues: initial
|
|
19
|
-
? undefined
|
|
20
|
-
: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, prodConfToString(prodConf)]]),
|
|
21
|
-
useHistoryPush: this._useHistoryPush,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Observable } from "@configura/web-utilities";
|
|
2
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
3
|
-
export declare type CfgCameraConf = {
|
|
4
|
-
yaw?: number;
|
|
5
|
-
pitch?: number;
|
|
6
|
-
};
|
|
7
|
-
export declare type CfgCameraConfMessage = {
|
|
8
|
-
version: string;
|
|
9
|
-
initial: boolean;
|
|
10
|
-
} & CfgCameraConf;
|
|
11
|
-
export declare const STAGE_CAMERA_CONF_MESSAGE_KEY = "stagecameraconf";
|
|
12
|
-
export declare const STAGE_CAMERA_MESSAGE_VERSION = "1.0";
|
|
13
|
-
declare type CameraConfMessageCallback = (message: CfgCameraConfMessage) => Promise<void>;
|
|
14
|
-
declare type CameraConfCallback = (conf: CfgCameraConf) => Promise<void>;
|
|
15
|
-
export declare abstract class CfgIOCameraConfConnector<K extends keyof WindowEventMap, S, M extends CfgIOManager<K, S>> {
|
|
16
|
-
private readonly _ioManager;
|
|
17
|
-
private readonly _cameraControl;
|
|
18
|
-
constructor(_ioManager: M, initialCameraConf: CfgCameraConf, _cameraControl: Observable<CfgCameraConf>);
|
|
19
|
-
private _delayId;
|
|
20
|
-
protected abstract makeSendData(cameraConf: CfgCameraConf, initial: boolean): S;
|
|
21
|
-
makeMessage(cameraConf: CfgCameraConf, initial: boolean): CfgCameraConfMessage;
|
|
22
|
-
makeMessageListener(callback: CameraConfMessageCallback): (message: unknown) => Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Register the callback to listen for Product Configuration messages
|
|
25
|
-
* @returns A function which when called will cancel listening
|
|
26
|
-
*/
|
|
27
|
-
listenForMessage(callback: CameraConfMessageCallback): () => void;
|
|
28
|
-
listenForCamera(callback: CameraConfCallback): () => void;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=CfgIOCameraConfConnector.d.ts.map
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
// Chrome is not happy if history updates are sent to rapidly.
|
|
11
|
-
// And message receivers probably don't want to get flooded either.
|
|
12
|
-
const THROTTLING_DELAY = 100;
|
|
13
|
-
export const STAGE_CAMERA_CONF_MESSAGE_KEY = "stagecameraconf";
|
|
14
|
-
export const STAGE_CAMERA_MESSAGE_VERSION = "1.0";
|
|
15
|
-
export class CfgIOCameraConfConnector {
|
|
16
|
-
constructor(_ioManager, initialCameraConf, _cameraControl) {
|
|
17
|
-
this._ioManager = _ioManager;
|
|
18
|
-
this._cameraControl = _cameraControl;
|
|
19
|
-
_ioManager.send(STAGE_CAMERA_CONF_MESSAGE_KEY, this.makeSendData(initialCameraConf, true));
|
|
20
|
-
this.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
if (this._delayId !== undefined) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
_cameraControl.notifyAll(message, this);
|
|
25
|
-
}));
|
|
26
|
-
this.listenForCamera((cameraConf) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
window.clearTimeout(this._delayId);
|
|
28
|
-
this._delayId = window.setTimeout(() => {
|
|
29
|
-
_ioManager.send(STAGE_CAMERA_CONF_MESSAGE_KEY, this.makeSendData(cameraConf, false));
|
|
30
|
-
this._delayId = undefined;
|
|
31
|
-
}, THROTTLING_DELAY);
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
makeMessage(cameraConf, initial) {
|
|
35
|
-
return {
|
|
36
|
-
version: STAGE_CAMERA_MESSAGE_VERSION,
|
|
37
|
-
initial,
|
|
38
|
-
yaw: cameraConf.yaw,
|
|
39
|
-
pitch: cameraConf.pitch,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
makeMessageListener(callback) {
|
|
43
|
-
return (message) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const cameraConfMessage = message;
|
|
45
|
-
const version = cameraConfMessage.version;
|
|
46
|
-
if (version !== "1.0") {
|
|
47
|
-
console.error(`The a message was passed with an unsupported version "${version}". Currently only ${STAGE_CAMERA_MESSAGE_VERSION} is supported.`);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
yield callback(cameraConfMessage);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Register the callback to listen for Product Configuration messages
|
|
55
|
-
* @returns A function which when called will cancel listening
|
|
56
|
-
*/
|
|
57
|
-
listenForMessage(callback) {
|
|
58
|
-
const ioManager = this._ioManager;
|
|
59
|
-
const listener = this.makeMessageListener(callback);
|
|
60
|
-
ioManager.listen(listener, STAGE_CAMERA_CONF_MESSAGE_KEY);
|
|
61
|
-
return () => {
|
|
62
|
-
ioManager.stopListen(listener);
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
listenForCamera(callback) {
|
|
66
|
-
const cameraControl = this._cameraControl;
|
|
67
|
-
cameraControl.listen(callback, this);
|
|
68
|
-
return () => {
|
|
69
|
-
cameraControl.stopListen(callback);
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare type ConfiguraShebang = "c0nf1guraarug1fn0c";
|
|
2
|
-
declare type Listener = (m: unknown) => Promise<void>;
|
|
3
|
-
export declare type CfgIOContainer = {
|
|
4
|
-
shebang: ConfiguraShebang;
|
|
5
|
-
messages: {
|
|
6
|
-
[index: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
9
|
-
export declare abstract class CfgIOManager<K extends keyof WindowEventMap, S> {
|
|
10
|
-
static isIOContainer: (data: any) => data is CfgIOContainer;
|
|
11
|
-
static hasIOContainerMessageKey: (container: CfgIOContainer, messageKey: string) => boolean;
|
|
12
|
-
static getMessageFromIOContainer: (container: any, messageKey: string) => unknown;
|
|
13
|
-
static makeContainer: (messages: {
|
|
14
|
-
[index: string]: unknown;
|
|
15
|
-
}) => CfgIOContainer;
|
|
16
|
-
private _inhibitSend;
|
|
17
|
-
private _listeners;
|
|
18
|
-
private _getIndexOfListener;
|
|
19
|
-
listen: (l: Listener, messageKey: string) => void;
|
|
20
|
-
stopListen: (l: Listener) => void;
|
|
21
|
-
private _containerListenerBound;
|
|
22
|
-
protected _containerListener(event: WindowEventMap[K]): void;
|
|
23
|
-
send: (messageKey: string, data: S) => void;
|
|
24
|
-
protected abstract doSend(messageKey: string, data: S): void;
|
|
25
|
-
protected abstract readonly eventType: K;
|
|
26
|
-
protected abstract getDataFromEvent(event: WindowEventMap[K]): unknown;
|
|
27
|
-
}
|
|
28
|
-
export {};
|
|
29
|
-
//# sourceMappingURL=CfgIOManager.d.ts.map
|
package/dist/io/CfgIOManager.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const CONFIGURA_SHEBANG = "c0nf1guraarug1fn0c";
|
|
2
|
-
export class CfgIOManager {
|
|
3
|
-
constructor() {
|
|
4
|
-
// A lock to avoid circular write
|
|
5
|
-
this._inhibitSend = false;
|
|
6
|
-
this._listeners = [];
|
|
7
|
-
this._getIndexOfListener = (l) => this._listeners.findIndex((item) => l === item.l);
|
|
8
|
-
this.listen = (l, messageKey) => {
|
|
9
|
-
if (this._getIndexOfListener(l) !== -1) {
|
|
10
|
-
console.warn("Tried to add listener twice");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const startListenToWindow = this._listeners.length === 0;
|
|
14
|
-
this._listeners.push({ l, messageKey });
|
|
15
|
-
if (startListenToWindow) {
|
|
16
|
-
window.addEventListener(this.eventType, this._containerListenerBound);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
this.stopListen = (l) => {
|
|
20
|
-
const i = this._getIndexOfListener(l);
|
|
21
|
-
if (i === -1) {
|
|
22
|
-
console.warn("Tried to stopListen on unknown listener");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
this._listeners.splice(i, 1);
|
|
26
|
-
if (this._listeners.length === 0) {
|
|
27
|
-
window.removeEventListener(this.eventType, this._containerListenerBound);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this._containerListenerBound = this._containerListener.bind(this);
|
|
31
|
-
this.send = (messageKey, data) => {
|
|
32
|
-
if (this._inhibitSend) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
this.doSend(messageKey, data);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
_containerListener(event) {
|
|
39
|
-
const data = this.getDataFromEvent(event);
|
|
40
|
-
if (!CfgIOManager.isIOContainer(data)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// The 15 or so rows below is one of the cases where I believe building a clever
|
|
44
|
-
// data structure of so would probably be worse for performance than just looping
|
|
45
|
-
// as the subscribers are expected to be very few
|
|
46
|
-
const listeners = this._listeners;
|
|
47
|
-
const allMessageKeys = listeners.reduce((a, c) => {
|
|
48
|
-
a.add(c.messageKey);
|
|
49
|
-
return a;
|
|
50
|
-
}, new Set());
|
|
51
|
-
this._inhibitSend = true;
|
|
52
|
-
const promises = [];
|
|
53
|
-
for (const messageKey of allMessageKeys) {
|
|
54
|
-
if (!CfgIOManager.hasIOContainerMessageKey(data, messageKey)) {
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
const message = CfgIOManager.getMessageFromIOContainer(data, messageKey);
|
|
58
|
-
for (const item of listeners) {
|
|
59
|
-
if (item.messageKey !== messageKey) {
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
promises.push(item.l(message));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
Promise.all(promises)
|
|
66
|
-
.then(() => {
|
|
67
|
-
this._inhibitSend = false;
|
|
68
|
-
})
|
|
69
|
-
.catch(() => {
|
|
70
|
-
this._inhibitSend = false;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
CfgIOManager.isIOContainer = (data) => data && data.shebang === CONFIGURA_SHEBANG;
|
|
75
|
-
CfgIOManager.hasIOContainerMessageKey = (container, messageKey) => messageKey in container.messages;
|
|
76
|
-
CfgIOManager.getMessageFromIOContainer = (container, messageKey) => {
|
|
77
|
-
if (!CfgIOManager.isIOContainer(container)) {
|
|
78
|
-
throw new Error("The passed data was not a CfgIOContainer. It is to be expected that such data messages can arrive, so please use isIOContainer function to filter them out before calling this.");
|
|
79
|
-
}
|
|
80
|
-
if (!CfgIOManager.hasIOContainerMessageKey(container, messageKey)) {
|
|
81
|
-
throw new Error(`The passed data did not have the messageKey "${messageKey}". You can test for this using hasIOContainerMessageKey function.`);
|
|
82
|
-
}
|
|
83
|
-
// It is assumed that if a message arrives with the right subMessageKey it can cast to T
|
|
84
|
-
return container.messages[messageKey];
|
|
85
|
-
};
|
|
86
|
-
CfgIOManager.makeContainer = (messages) => ({
|
|
87
|
-
shebang: CONFIGURA_SHEBANG,
|
|
88
|
-
messages,
|
|
89
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
|
|
2
|
-
import { CfgProduct, CfgProductChangeNotification } from "../CfgProduct.js";
|
|
3
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
4
|
-
export declare type CfgProdConfMessage = {
|
|
5
|
-
version: string;
|
|
6
|
-
initial: boolean;
|
|
7
|
-
prodConf: AdditionalProductConfiguration;
|
|
8
|
-
};
|
|
9
|
-
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
10
|
-
export declare const STAGE_PROD_CONF_MESSAGE_VERSION = "1.0";
|
|
11
|
-
declare type ProdConfMessageCallback = (message: CfgProdConfMessage) => Promise<void>;
|
|
12
|
-
declare type ProdConfCallback = (prodConf: AdditionalProductConfiguration) => Promise<void>;
|
|
13
|
-
export declare function prodConfToString(conf: AdditionalProductConfiguration): string;
|
|
14
|
-
export declare function stringToProdConf(conf: string): AdditionalProductConfiguration;
|
|
15
|
-
export declare abstract class CfgIOProdConfConnector<K extends keyof WindowEventMap, S, M extends CfgIOManager<K, S>> {
|
|
16
|
-
private readonly _ioManager;
|
|
17
|
-
private readonly _doValidate;
|
|
18
|
-
protected _product: CfgProduct | undefined;
|
|
19
|
-
private _stopListenToMessage;
|
|
20
|
-
private _stopListenToProdConf;
|
|
21
|
-
constructor(_ioManager: M, _doValidate: boolean);
|
|
22
|
-
setProduct: (product: CfgProduct | undefined) => Promise<void>;
|
|
23
|
-
protected abstract getInitialProdConf(): string | undefined;
|
|
24
|
-
protected abstract makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): S;
|
|
25
|
-
makeMessage(prodConf: AdditionalProductConfiguration, initial: boolean): CfgProdConfMessage;
|
|
26
|
-
makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Register the callback to listen for Product Configuration messages
|
|
29
|
-
* @returns A function which when called will cancel listening
|
|
30
|
-
*/
|
|
31
|
-
listenForMessage(callback: ProdConfMessageCallback): () => void;
|
|
32
|
-
makeProdConfListener(callback: ProdConfCallback): (n: CfgProductChangeNotification) => void;
|
|
33
|
-
listenForProdConf(product: CfgProduct, callback: ProdConfCallback): () => void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=CfgIOProdConfConnector.d.ts.map
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
11
|
-
export const STAGE_PROD_CONF_MESSAGE_VERSION = "1.0";
|
|
12
|
-
export function prodConfToString(conf) {
|
|
13
|
-
return JSON.stringify(conf, undefined, "");
|
|
14
|
-
}
|
|
15
|
-
export function stringToProdConf(conf) {
|
|
16
|
-
return JSON.parse(conf);
|
|
17
|
-
}
|
|
18
|
-
export class CfgIOProdConfConnector {
|
|
19
|
-
constructor(_ioManager, _doValidate) {
|
|
20
|
-
this._ioManager = _ioManager;
|
|
21
|
-
this._doValidate = _doValidate;
|
|
22
|
-
this._stopListenToMessage = undefined;
|
|
23
|
-
this._stopListenToProdConf = undefined;
|
|
24
|
-
this.setProduct = (product) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
const currentProduct = this._product;
|
|
27
|
-
const newProduct = product;
|
|
28
|
-
this._product = newProduct;
|
|
29
|
-
// If same product don't do anything at all
|
|
30
|
-
if (currentProduct !== undefined &&
|
|
31
|
-
newProduct !== undefined &&
|
|
32
|
-
currentProduct.isBackedBySame(newProduct)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (currentProduct !== undefined) {
|
|
36
|
-
(_a = this._stopListenToMessage) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
37
|
-
(_b = this._stopListenToProdConf) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
38
|
-
}
|
|
39
|
-
if (newProduct === undefined) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (currentProduct === undefined) {
|
|
43
|
-
const initialProdConf = this.getInitialProdConf();
|
|
44
|
-
if (initialProdConf !== undefined) {
|
|
45
|
-
yield newProduct.setApiSelection(stringToProdConf(initialProdConf), this._doValidate);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(newProduct.getApiSelection(), true));
|
|
49
|
-
this._stopListenToMessage = this.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
yield newProduct.setApiSelection(message.prodConf, this._doValidate);
|
|
51
|
-
}));
|
|
52
|
-
this._stopListenToProdConf = this.listenForProdConf(newProduct, (prodConf) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(prodConf, false));
|
|
54
|
-
}));
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
makeMessage(prodConf, initial) {
|
|
58
|
-
return {
|
|
59
|
-
version: STAGE_PROD_CONF_MESSAGE_VERSION,
|
|
60
|
-
initial,
|
|
61
|
-
prodConf,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
makeMessageListener(callback) {
|
|
65
|
-
return (message) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const prodConfMessage = message;
|
|
67
|
-
const version = prodConfMessage.version;
|
|
68
|
-
if (version !== "1.0") {
|
|
69
|
-
console.error(`The a message was passed with an unsupported version "${version}". Currently only ${STAGE_PROD_CONF_MESSAGE_VERSION} is supported.`);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
yield callback(prodConfMessage);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Register the callback to listen for Product Configuration messages
|
|
77
|
-
* @returns A function which when called will cancel listening
|
|
78
|
-
*/
|
|
79
|
-
listenForMessage(callback) {
|
|
80
|
-
const ioManager = this._ioManager;
|
|
81
|
-
const listener = this.makeMessageListener(callback);
|
|
82
|
-
ioManager.listen(listener, STAGE_PROD_CONF_MESSAGE_KEY);
|
|
83
|
-
return () => {
|
|
84
|
-
ioManager.stopListen(listener);
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
makeProdConfListener(callback) {
|
|
88
|
-
return (n) => {
|
|
89
|
-
if (!n.committed) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
callback(n.freshRef.getApiSelection());
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
listenForProdConf(product, callback) {
|
|
96
|
-
const listener = this.makeProdConfListener(callback);
|
|
97
|
-
product.listenForChange(listener);
|
|
98
|
-
return () => {
|
|
99
|
-
product.stopListenForChange(listener);
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
2
|
-
export declare type CfgWindowMessageManagerSendData = unknown;
|
|
3
|
-
export declare class CfgWindowMessageManager extends CfgIOManager<"message", CfgWindowMessageManagerSendData> {
|
|
4
|
-
private readonly _remoteEnds;
|
|
5
|
-
private readonly _targetOrigin;
|
|
6
|
-
private readonly _acceptableMessageOrigin?;
|
|
7
|
-
constructor(_remoteEnds: Window[], _targetOrigin?: string, _acceptableMessageOrigin?: string | undefined);
|
|
8
|
-
protected doSend(messageKey: string, data: unknown): void;
|
|
9
|
-
protected _containerListener(event: MessageEvent<any>): void;
|
|
10
|
-
protected readonly eventType = "message";
|
|
11
|
-
protected getDataFromEvent(event: MessageEvent<any>): unknown;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=CfgWindowMessageManager.d.ts.map
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { CfgIOManager } from "./CfgIOManager.js";
|
|
2
|
-
export class CfgWindowMessageManager extends CfgIOManager {
|
|
3
|
-
constructor(_remoteEnds, _targetOrigin = "*", _acceptableMessageOrigin) {
|
|
4
|
-
super();
|
|
5
|
-
this._remoteEnds = _remoteEnds;
|
|
6
|
-
this._targetOrigin = _targetOrigin;
|
|
7
|
-
this._acceptableMessageOrigin = _acceptableMessageOrigin;
|
|
8
|
-
this.eventType = "message";
|
|
9
|
-
for (const remote of _remoteEnds) {
|
|
10
|
-
if (remote === window) {
|
|
11
|
-
console.warn("You are providing your own window as a remote end.");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
doSend(messageKey, data) {
|
|
16
|
-
const container = CfgIOManager.makeContainer({
|
|
17
|
-
[messageKey]: data,
|
|
18
|
-
});
|
|
19
|
-
for (const remoteEnd of this._remoteEnds) {
|
|
20
|
-
remoteEnd.postMessage(container, this._targetOrigin);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
_containerListener(event) {
|
|
24
|
-
if (this._acceptableMessageOrigin !== undefined &&
|
|
25
|
-
event.origin !== this._acceptableMessageOrigin) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
super._containerListener(event);
|
|
29
|
-
}
|
|
30
|
-
getDataFromEvent(event) {
|
|
31
|
-
return event.data;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CfgCameraConf, CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
2
|
-
import { CfgWindowMessageManager, CfgWindowMessageManagerSendData } from "./CfgWindowMessageManager.js";
|
|
3
|
-
export declare class CfgWindowMessageToCameraConfConnector extends CfgIOCameraConfConnector<"message", CfgWindowMessageManagerSendData, CfgWindowMessageManager> {
|
|
4
|
-
protected makeSendData(cameraConf: CfgCameraConf, initial: boolean): CfgWindowMessageManagerSendData;
|
|
5
|
-
}
|
|
6
|
-
//# sourceMappingURL=CfgWindowMessageToCameraConfConnector.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
|
|
2
|
-
import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
import { CfgWindowMessageManager, CfgWindowMessageManagerSendData } from "./CfgWindowMessageManager.js";
|
|
4
|
-
/**
|
|
5
|
-
* Instantiating the class will expose your product to:
|
|
6
|
-
* - Listen for configuration changes posted to this window
|
|
7
|
-
* - Send configuration changes using sendMessage
|
|
8
|
-
*/
|
|
9
|
-
export declare class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector<"message", CfgWindowMessageManagerSendData, CfgWindowMessageManager> {
|
|
10
|
-
constructor(manager: CfgWindowMessageManager, doValidate?: boolean);
|
|
11
|
-
protected getInitialProdConf(): string | undefined;
|
|
12
|
-
protected makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): CfgWindowMessageManagerSendData;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=CfgWindowMessageToProdConfConnector.d.ts.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
|
|
2
|
-
/**
|
|
3
|
-
* Instantiating the class will expose your product to:
|
|
4
|
-
* - Listen for configuration changes posted to this window
|
|
5
|
-
* - Send configuration changes using sendMessage
|
|
6
|
-
*/
|
|
7
|
-
export class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector {
|
|
8
|
-
constructor(manager, doValidate = true) {
|
|
9
|
-
super(manager, doValidate);
|
|
10
|
-
}
|
|
11
|
-
getInitialProdConf() {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
makeSendData(prodConf, initial) {
|
|
15
|
-
return this.makeMessage(prodConf, initial);
|
|
16
|
-
}
|
|
17
|
-
}
|