@configura/web-api 1.6.0-iotest.2 → 1.6.0-iotest.3
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/dist/CfgProduct.d.ts +0 -4
- package/dist/CfgProduct.js +0 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/io/CfgHistoryManager.d.ts +2 -6
- package/dist/io/CfgHistoryManager.js +6 -10
- package/dist/io/CfgHistoryToCameraConfConnector.d.ts +15 -0
- package/dist/io/CfgHistoryToCameraConfConnector.js +58 -0
- package/dist/io/CfgHistoryToProdConfConnector.d.ts +7 -3
- package/dist/io/CfgHistoryToProdConfConnector.js +11 -7
- package/dist/io/CfgIOCameraConfConnector.d.ts +32 -0
- package/dist/io/CfgIOCameraConfConnector.js +67 -0
- package/dist/io/CfgIOProdConfConnector.d.ts +12 -9
- package/dist/io/CfgIOProdConfConnector.js +15 -13
- package/dist/io/CfgWindowMessageToCameraConfConnector.d.ts +6 -0
- package/dist/io/CfgWindowMessageToCameraConfConnector.js +6 -0
- package/dist/io/CfgWindowMessageToProdConfConnector.d.ts +2 -1
- package/dist/io/CfgWindowMessageToProdConfConnector.js +2 -2
- package/package.json +3 -3
package/dist/CfgProduct.d.ts
CHANGED
|
@@ -122,8 +122,6 @@ export declare class _CfgProductInternal {
|
|
|
122
122
|
_configurationHasChanged: (freshRef: CfgProductConfiguration, bubbleMode: ProductConfigurationBubbleMode, committed: boolean) => Promise<void>;
|
|
123
123
|
getApiSelection: () => AdditionalProductConfiguration;
|
|
124
124
|
setApiSelection: (s: AdditionalProductConfiguration, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
125
|
-
getApiSelectionAsString: () => string;
|
|
126
|
-
setFromApiSelectionString: (str: string, doValidate: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
127
125
|
structureCompare: (other: _CfgProductInternal, strictOrder?: boolean, descriptionMatch?: boolean) => boolean;
|
|
128
126
|
tryMatchSelection: (other: _CfgProductInternal, descriptionMatch?: boolean, productLoaderForGroupedLoad?: ProductLoader | undefined) => Promise<boolean>;
|
|
129
127
|
/** Only features in selected options and selected additional products. */
|
|
@@ -233,8 +231,6 @@ export declare class CfgProduct {
|
|
|
233
231
|
*/
|
|
234
232
|
getApiSelection: () => AdditionalProductConfiguration;
|
|
235
233
|
setApiSelection: (s: AdditionalProductConfiguration, doValidate?: boolean) => Promise<boolean>;
|
|
236
|
-
getApiSelectionAsString: () => string;
|
|
237
|
-
setFromApiSelectionString: (str: string, doValidate?: boolean) => Promise<boolean>;
|
|
238
234
|
listenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
|
239
235
|
stopListenForChange: (l: SingleArgCallback<CfgProductChangeNotification>) => void;
|
|
240
236
|
stopAllListenForChange: () => void;
|
package/dist/CfgProduct.js
CHANGED
|
@@ -190,10 +190,6 @@ export class _CfgProductInternal {
|
|
|
190
190
|
}
|
|
191
191
|
return change;
|
|
192
192
|
});
|
|
193
|
-
this.getApiSelectionAsString = () => JSON.stringify(this.getApiSelection(), undefined, "");
|
|
194
|
-
this.setFromApiSelectionString = (str, doValidate, productLoaderForGroupedLoad) => __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
return this.setApiSelection(JSON.parse(decodeURIComponent(str)), doValidate, productLoaderForGroupedLoad);
|
|
196
|
-
});
|
|
197
193
|
this.structureCompare = (other, strictOrder = true, descriptionMatch = false) => {
|
|
198
194
|
if (!this.configuration.structureCompare(other.configuration, strictOrder, descriptionMatch)) {
|
|
199
195
|
return false;
|
|
@@ -558,8 +554,6 @@ export class CfgProduct {
|
|
|
558
554
|
*/
|
|
559
555
|
this.getApiSelection = () => this._internal.getApiSelection();
|
|
560
556
|
this.setApiSelection = (s, doValidate = false) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setApiSelection(s, doValidate); });
|
|
561
|
-
this.getApiSelectionAsString = () => this._internal.getApiSelectionAsString();
|
|
562
|
-
this.setFromApiSelectionString = (str, doValidate = false) => __awaiter(this, void 0, void 0, function* () { return yield this._internal.setFromApiSelectionString(str, doValidate); });
|
|
563
557
|
this.listenForChange = (l) => this._internal.changeObservable.listen(l);
|
|
564
558
|
this.stopListenForChange = (l) => this._internal.changeObservable.stopListen(l);
|
|
565
559
|
this.stopAllListenForChange = () => this._internal.changeObservable.stopAllListen();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./CatalogueAPI.js";
|
|
2
2
|
export * from "./CfgProduct.js";
|
|
3
3
|
export * from "./io/CfgHistoryManager.js";
|
|
4
|
+
export * from "./io/CfgHistoryToCameraConfConnector.js";
|
|
4
5
|
export * from "./io/CfgHistoryToProdConfConnector.js";
|
|
5
6
|
export * from "./io/CfgWindowMessageManager.js";
|
|
7
|
+
export * from "./io/CfgWindowMessageToCameraConfConnector.js";
|
|
6
8
|
export * from "./io/CfgWindowMessageToProdConfConnector.js";
|
|
7
9
|
export * from "./material/CfgMaterialMapping.js";
|
|
8
10
|
export * from "./material/CfgMtrlApplication.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * from "./CatalogueAPI.js";
|
|
2
2
|
export * from "./CfgProduct.js";
|
|
3
3
|
export * from "./io/CfgHistoryManager.js";
|
|
4
|
+
export * from "./io/CfgHistoryToCameraConfConnector.js";
|
|
4
5
|
export * from "./io/CfgHistoryToProdConfConnector.js";
|
|
5
6
|
export * from "./io/CfgWindowMessageManager.js";
|
|
7
|
+
export * from "./io/CfgWindowMessageToCameraConfConnector.js";
|
|
6
8
|
export * from "./io/CfgWindowMessageToProdConfConnector.js";
|
|
7
9
|
export * from "./material/CfgMaterialMapping.js";
|
|
8
10
|
export * from "./material/CfgMtrlApplication.js";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
2
2
|
export declare type CfgHistoryManagerSendData<D> = {
|
|
3
3
|
message: D;
|
|
4
|
+
useHistoryPush: boolean;
|
|
4
5
|
qsKeyValues: Map<string, string | undefined> | undefined;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
@@ -11,18 +12,13 @@ export declare type CfgHistoryManagerSendData<D> = {
|
|
|
11
12
|
export declare class CfgHistoryManager<D extends {
|
|
12
13
|
initial: boolean;
|
|
13
14
|
}> extends CfgIOManager<"popstate", CfgHistoryManagerSendData<D>> {
|
|
14
|
-
private readonly _useHistoryPush;
|
|
15
|
-
/**
|
|
16
|
-
* @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
|
|
17
|
-
*/
|
|
18
|
-
constructor(_useHistoryPush: boolean);
|
|
19
15
|
protected doSend(messageKey: string, data: CfgHistoryManagerSendData<D>): void;
|
|
20
16
|
private static _makeUpdatedUrl;
|
|
21
17
|
private static _makeUpdatedQueryString;
|
|
22
18
|
/**
|
|
23
19
|
* @returns The current query string as a Map
|
|
24
20
|
*/
|
|
25
|
-
static
|
|
21
|
+
static currentQsKeyValues(): Map<string, string>;
|
|
26
22
|
private static _makeUpdatedState;
|
|
27
23
|
protected readonly eventType = "popstate";
|
|
28
24
|
protected getDataFromEvent(event: PopStateEvent): unknown;
|
|
@@ -6,19 +6,15 @@ import { CfgIOManager } from "./CfgIOManager.js";
|
|
|
6
6
|
* Only handles configuration, not product
|
|
7
7
|
*/
|
|
8
8
|
export class CfgHistoryManager extends CfgIOManager {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
constructor(_useHistoryPush) {
|
|
13
|
-
super();
|
|
14
|
-
this._useHistoryPush = _useHistoryPush;
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
15
11
|
this.eventType = "popstate";
|
|
16
12
|
}
|
|
17
13
|
doSend(messageKey, data) {
|
|
18
|
-
const { qsKeyValues, message } = data;
|
|
14
|
+
const { qsKeyValues, message, useHistoryPush } = data;
|
|
19
15
|
const newUrl = qsKeyValues === undefined ? null : CfgHistoryManager._makeUpdatedUrl(qsKeyValues);
|
|
20
16
|
const newState = CfgHistoryManager._makeUpdatedState(message, messageKey);
|
|
21
|
-
if (!message.initial &&
|
|
17
|
+
if (!message.initial && useHistoryPush) {
|
|
22
18
|
window.history.pushState(newState, "", newUrl);
|
|
23
19
|
}
|
|
24
20
|
else {
|
|
@@ -30,7 +26,7 @@ export class CfgHistoryManager extends CfgIOManager {
|
|
|
30
26
|
return `${window.location.origin}${window.location.pathname}${qs ? "?" : ""}${qs}${window.location.hash}`;
|
|
31
27
|
}
|
|
32
28
|
static _makeUpdatedQueryString(qsKeyValues) {
|
|
33
|
-
const currentKeyValues = this.
|
|
29
|
+
const currentKeyValues = this.currentQsKeyValues();
|
|
34
30
|
for (const [key, value] of qsKeyValues) {
|
|
35
31
|
if (value === undefined) {
|
|
36
32
|
currentKeyValues.delete(key);
|
|
@@ -44,7 +40,7 @@ export class CfgHistoryManager extends CfgIOManager {
|
|
|
44
40
|
/**
|
|
45
41
|
* @returns The current query string as a Map
|
|
46
42
|
*/
|
|
47
|
-
static
|
|
43
|
+
static currentQsKeyValues() {
|
|
48
44
|
return mapQueryString(window.location.search);
|
|
49
45
|
}
|
|
50
46
|
static _makeUpdatedState(message, messageKey) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Observable } from "@configura/web-utilities";
|
|
2
|
+
import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
|
|
3
|
+
import { CfgCameraConf, CfgCameraConfMessage, CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
4
|
+
export declare class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector<"popstate", CfgHistoryManagerSendData<CfgCameraConfMessage>, CfgHistoryManager<CfgCameraConfMessage>> {
|
|
5
|
+
private readonly defaults;
|
|
6
|
+
private readonly _qsKeyYaw;
|
|
7
|
+
private readonly _qsKeyPitch;
|
|
8
|
+
static make(manager: CfgHistoryManager<CfgCameraConfMessage>, defaults: CfgCameraConf, cameraControl: Observable<CfgCameraConf>, qsKeyYaw?: string, qsKeyPitch?: string): {
|
|
9
|
+
instance: CfgHistoryToCameraConfConnector;
|
|
10
|
+
initial: CfgCameraConf;
|
|
11
|
+
};
|
|
12
|
+
private constructor();
|
|
13
|
+
protected makeSendData(cameraConf: CfgCameraConf, initial: boolean): CfgHistoryManagerSendData<CfgCameraConfMessage>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=CfgHistoryToCameraConfConnector.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { degToRad, radToDeg } from "@configura/web-utilities";
|
|
2
|
+
import { CfgHistoryManager } from "./CfgHistoryManager.js";
|
|
3
|
+
import { CfgIOCameraConfConnector, } from "./CfgIOCameraConfConnector.js";
|
|
4
|
+
const YAW_QS_KEY = "stageyaw";
|
|
5
|
+
const PITCH_QS_KEY = "stagepitch";
|
|
6
|
+
function qsAsNumber(qsMap, key) {
|
|
7
|
+
const asString = qsMap.get(key);
|
|
8
|
+
if (asString === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const asNumber = parseFloat(asString);
|
|
12
|
+
if (!isFinite(asNumber)) {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return degToRad(asNumber);
|
|
16
|
+
}
|
|
17
|
+
function addToMap(map, key, value) {
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
map.delete(key);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const timesHundredString = `${Math.round(100 * radToDeg(value))}`;
|
|
23
|
+
const decimalPlace = timesHundredString.length - 2;
|
|
24
|
+
map.set(key, `${timesHundredString.substring(0, decimalPlace)}.${timesHundredString.substring(decimalPlace)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
28
|
+
constructor(manager, defaults, initial, cameraControl, _qsKeyYaw, _qsKeyPitch) {
|
|
29
|
+
super(manager, initial, cameraControl);
|
|
30
|
+
this.defaults = defaults;
|
|
31
|
+
this._qsKeyYaw = _qsKeyYaw;
|
|
32
|
+
this._qsKeyPitch = _qsKeyPitch;
|
|
33
|
+
}
|
|
34
|
+
static make(manager, defaults, cameraControl, qsKeyYaw = YAW_QS_KEY, qsKeyPitch = PITCH_QS_KEY) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const qsKeyValues = CfgHistoryManager.currentQsKeyValues();
|
|
37
|
+
const initial = {
|
|
38
|
+
yaw: (_a = qsAsNumber(qsKeyValues, qsKeyYaw)) !== null && _a !== void 0 ? _a : defaults.yaw,
|
|
39
|
+
pitch: (_b = qsAsNumber(qsKeyValues, qsKeyPitch)) !== null && _b !== void 0 ? _b : defaults.pitch,
|
|
40
|
+
};
|
|
41
|
+
const instance = new CfgHistoryToCameraConfConnector(manager, defaults, initial, cameraControl, qsKeyYaw, qsKeyPitch);
|
|
42
|
+
return { instance, initial };
|
|
43
|
+
}
|
|
44
|
+
makeSendData(cameraConf, initial) {
|
|
45
|
+
let qsKeyValues = undefined;
|
|
46
|
+
if (!initial &&
|
|
47
|
+
!(this.defaults.pitch === cameraConf.pitch && this.defaults.yaw === cameraConf.yaw)) {
|
|
48
|
+
qsKeyValues = new Map();
|
|
49
|
+
addToMap(qsKeyValues, this._qsKeyYaw, cameraConf.yaw);
|
|
50
|
+
addToMap(qsKeyValues, this._qsKeyPitch, cameraConf.pitch);
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
message: this.makeMessage(cameraConf, initial),
|
|
54
|
+
qsKeyValues,
|
|
55
|
+
useHistoryPush: false,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
|
|
1
2
|
import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
|
|
2
3
|
import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
4
4
|
export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector<"popstate", CfgHistoryManagerSendData<CfgProdConfMessage>, CfgHistoryManager<CfgProdConfMessage>> {
|
|
5
|
+
private readonly _useHistoryPush;
|
|
5
6
|
private readonly _qsKey;
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
|
|
9
|
+
*/
|
|
10
|
+
constructor(manager: CfgHistoryManager<CfgProdConfMessage>, _useHistoryPush: boolean, _qsKey?: string, doValidate?: boolean);
|
|
7
11
|
protected getInitialProdConf(): string | undefined;
|
|
8
|
-
protected makeSendData(
|
|
12
|
+
protected makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=CfgHistoryToProdConfConnector.d.ts.map
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
import { CfgHistoryManager } from "./CfgHistoryManager.js";
|
|
2
|
-
import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
|
|
3
|
-
export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
2
|
+
import { CfgIOProdConfConnector, prodConfToString, STAGE_PROD_CONF_MESSAGE_KEY, } from "./CfgIOProdConfConnector.js";
|
|
4
3
|
export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
|
|
5
|
-
|
|
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) {
|
|
6
8
|
super(manager, doValidate);
|
|
9
|
+
this._useHistoryPush = _useHistoryPush;
|
|
7
10
|
this._qsKey = _qsKey;
|
|
8
11
|
}
|
|
9
12
|
getInitialProdConf() {
|
|
10
|
-
return CfgHistoryManager.
|
|
13
|
+
return CfgHistoryManager.currentQsKeyValues().get(this._qsKey);
|
|
11
14
|
}
|
|
12
|
-
makeSendData(
|
|
15
|
+
makeSendData(prodConf, initial) {
|
|
13
16
|
return {
|
|
14
|
-
message: this.makeMessage(
|
|
17
|
+
message: this.makeMessage(prodConf, initial),
|
|
15
18
|
qsKeyValues: initial
|
|
16
19
|
? undefined
|
|
17
|
-
: new Map([[STAGE_PROD_CONF_MESSAGE_KEY,
|
|
20
|
+
: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, prodConfToString(prodConf)]]),
|
|
21
|
+
useHistoryPush: this._useHistoryPush,
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
24
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
distance?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare type CfgCameraConfMessage = {
|
|
9
|
+
version: string;
|
|
10
|
+
initial: boolean;
|
|
11
|
+
} & CfgCameraConf;
|
|
12
|
+
export declare const STAGE_CAMERA_CONF_MESSAGE_KEY = "stagecameraconf";
|
|
13
|
+
export declare const STAGE_CAMERA_MESSAGE_VERSION = "1.0";
|
|
14
|
+
declare type CameraConfMessageCallback = (message: CfgCameraConfMessage) => Promise<void>;
|
|
15
|
+
declare type CameraConfCallback = (conf: CfgCameraConf) => Promise<void>;
|
|
16
|
+
export declare abstract class CfgIOCameraConfConnector<K extends keyof WindowEventMap, S, M extends CfgIOManager<K, S>> {
|
|
17
|
+
private readonly _ioManager;
|
|
18
|
+
private readonly _cameraControl;
|
|
19
|
+
constructor(_ioManager: M, initial: CfgCameraConf, _cameraControl: Observable<CfgCameraConf>);
|
|
20
|
+
private _delayId;
|
|
21
|
+
protected abstract makeSendData(cameraConf: CfgCameraConf, initial: boolean): S;
|
|
22
|
+
makeMessage(cameraConf: CfgCameraConf, initial: boolean): CfgCameraConfMessage;
|
|
23
|
+
makeMessageListener(callback: CameraConfMessageCallback): (message: unknown) => Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Register the callback to listen for Product Configuration messages
|
|
26
|
+
* @returns A function which when called will cancel listening
|
|
27
|
+
*/
|
|
28
|
+
listenForMessage(callback: CameraConfMessageCallback): () => void;
|
|
29
|
+
listenForCamera(callback: CameraConfCallback): () => void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=CfgIOCameraConfConnector.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
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, initial, _cameraControl) {
|
|
17
|
+
this._ioManager = _ioManager;
|
|
18
|
+
this._cameraControl = _cameraControl;
|
|
19
|
+
_ioManager.send(STAGE_CAMERA_CONF_MESSAGE_KEY, this.makeSendData(initial, 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 Object.assign({ version: STAGE_CAMERA_MESSAGE_VERSION, initial }, cameraConf);
|
|
36
|
+
}
|
|
37
|
+
makeMessageListener(callback) {
|
|
38
|
+
return (message) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const cameraConfMessage = message;
|
|
40
|
+
const version = cameraConfMessage.version;
|
|
41
|
+
if (version !== "1.0") {
|
|
42
|
+
console.error(`The a message was passed with an unsupported version "${version}". Currently only ${STAGE_CAMERA_MESSAGE_VERSION} is supported.`);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
yield callback(cameraConfMessage);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Register the callback to listen for Product Configuration messages
|
|
50
|
+
* @returns A function which when called will cancel listening
|
|
51
|
+
*/
|
|
52
|
+
listenForMessage(callback) {
|
|
53
|
+
const ioManager = this._ioManager;
|
|
54
|
+
const listener = this.makeMessageListener(callback);
|
|
55
|
+
ioManager.listen(listener, STAGE_CAMERA_CONF_MESSAGE_KEY);
|
|
56
|
+
return () => {
|
|
57
|
+
ioManager.stopListen(listener);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
listenForCamera(callback) {
|
|
61
|
+
const cameraControl = this._cameraControl;
|
|
62
|
+
cameraControl.listen(callback, this);
|
|
63
|
+
return () => {
|
|
64
|
+
cameraControl.stopListen(callback);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,33 +1,36 @@
|
|
|
1
|
+
import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
|
|
1
2
|
import { CfgProduct, CfgProductChangeNotification } from "../CfgProduct.js";
|
|
2
3
|
import { CfgIOManager } from "./CfgIOManager.js";
|
|
3
4
|
export declare type CfgProdConfMessage = {
|
|
4
5
|
version: string;
|
|
5
6
|
initial: boolean;
|
|
6
|
-
|
|
7
|
+
prodConf: AdditionalProductConfiguration;
|
|
7
8
|
};
|
|
8
|
-
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "
|
|
9
|
+
export declare const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
9
10
|
export declare const STAGE_PROD_CONF_MESSAGE_VERSION = "1.0";
|
|
10
11
|
declare type ProdConfMessageCallback = (message: CfgProdConfMessage) => Promise<void>;
|
|
11
|
-
declare type
|
|
12
|
+
declare type ProdConfCallback = (prodConf: AdditionalProductConfiguration) => Promise<void>;
|
|
13
|
+
export declare function prodConfToString(conf: AdditionalProductConfiguration): string;
|
|
14
|
+
export declare function stringToProdConf(conf: string): AdditionalProductConfiguration;
|
|
12
15
|
export declare abstract class CfgIOProdConfConnector<K extends keyof WindowEventMap, S, M extends CfgIOManager<K, S>> {
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
private readonly _ioManager;
|
|
17
|
+
private readonly _doValidate;
|
|
15
18
|
protected _product: CfgProduct | undefined;
|
|
16
19
|
private _stopListenToMessage;
|
|
17
20
|
private _stopListenToProdConf;
|
|
18
21
|
constructor(_ioManager: M, _doValidate: boolean);
|
|
19
22
|
setProduct: (product: CfgProduct | undefined) => Promise<void>;
|
|
20
23
|
protected abstract getInitialProdConf(): string | undefined;
|
|
21
|
-
protected abstract makeSendData(
|
|
22
|
-
makeMessage(
|
|
24
|
+
protected abstract makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): S;
|
|
25
|
+
makeMessage(prodConf: AdditionalProductConfiguration, initial: boolean): CfgProdConfMessage;
|
|
23
26
|
makeMessageListener(callback: ProdConfMessageCallback): (message: unknown) => Promise<void>;
|
|
24
27
|
/**
|
|
25
28
|
* Register the callback to listen for Product Configuration messages
|
|
26
29
|
* @returns A function which when called will cancel listening
|
|
27
30
|
*/
|
|
28
31
|
listenForMessage(callback: ProdConfMessageCallback): () => void;
|
|
29
|
-
makeProdConfListener(callback:
|
|
30
|
-
listenForProdConf(product: CfgProduct, callback:
|
|
32
|
+
makeProdConfListener(callback: ProdConfCallback): (n: CfgProductChangeNotification) => void;
|
|
33
|
+
listenForProdConf(product: CfgProduct, callback: ProdConfCallback): () => void;
|
|
31
34
|
}
|
|
32
35
|
export {};
|
|
33
36
|
//# sourceMappingURL=CfgIOProdConfConnector.d.ts.map
|
|
@@ -7,8 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
export const STAGE_PROD_CONF_MESSAGE_KEY = "
|
|
10
|
+
export const STAGE_PROD_CONF_MESSAGE_KEY = "stageprodconf";
|
|
11
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
|
+
}
|
|
12
18
|
export class CfgIOProdConfConnector {
|
|
13
19
|
constructor(_ioManager, _doValidate) {
|
|
14
20
|
this._ioManager = _ioManager;
|
|
@@ -36,27 +42,23 @@ export class CfgIOProdConfConnector {
|
|
|
36
42
|
if (currentProduct === undefined) {
|
|
37
43
|
const initialProdConf = this.getInitialProdConf();
|
|
38
44
|
if (initialProdConf !== undefined) {
|
|
39
|
-
yield newProduct.
|
|
45
|
+
yield newProduct.setApiSelection(stringToProdConf(initialProdConf), this._doValidate);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
|
-
this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(newProduct.
|
|
48
|
+
this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(newProduct.getApiSelection(), true));
|
|
43
49
|
this._stopListenToMessage = this.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
|
|
45
|
-
if (prodConfAsString === newProduct.getApiSelectionAsString()) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
yield newProduct.setFromApiSelectionString(prodConfAsString, this._doValidate);
|
|
50
|
+
yield newProduct.setApiSelection(message.prodConf, this._doValidate);
|
|
49
51
|
}));
|
|
50
|
-
this._stopListenToProdConf = this.listenForProdConf(newProduct, (
|
|
51
|
-
this._ioManager.send(STAGE_PROD_CONF_MESSAGE_KEY, this.makeSendData(
|
|
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));
|
|
52
54
|
}));
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
|
-
makeMessage(
|
|
57
|
+
makeMessage(prodConf, initial) {
|
|
56
58
|
return {
|
|
57
59
|
version: STAGE_PROD_CONF_MESSAGE_VERSION,
|
|
58
60
|
initial,
|
|
59
|
-
|
|
61
|
+
prodConf,
|
|
60
62
|
};
|
|
61
63
|
}
|
|
62
64
|
makeMessageListener(callback) {
|
|
@@ -87,7 +89,7 @@ export class CfgIOProdConfConnector {
|
|
|
87
89
|
if (!n.committed) {
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
|
-
callback(n.freshRef.
|
|
92
|
+
callback(n.freshRef.getApiSelection());
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
listenForProdConf(product, callback) {
|
|
@@ -0,0 +1,6 @@
|
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { AdditionalProductConfiguration } from "../CatalogueAPI.js";
|
|
1
2
|
import { CfgIOProdConfConnector } from "./CfgIOProdConfConnector.js";
|
|
2
3
|
import { CfgWindowMessageManager, CfgWindowMessageManagerSendData } from "./CfgWindowMessageManager.js";
|
|
3
4
|
/**
|
|
@@ -8,6 +9,6 @@ import { CfgWindowMessageManager, CfgWindowMessageManagerSendData } from "./CfgW
|
|
|
8
9
|
export declare class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector<"message", CfgWindowMessageManagerSendData, CfgWindowMessageManager> {
|
|
9
10
|
constructor(manager: CfgWindowMessageManager, doValidate?: boolean);
|
|
10
11
|
protected getInitialProdConf(): string | undefined;
|
|
11
|
-
protected makeSendData(
|
|
12
|
+
protected makeSendData(prodConf: AdditionalProductConfiguration, initial: boolean): CfgWindowMessageManagerSendData;
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=CfgWindowMessageToProdConfConnector.d.ts.map
|
|
@@ -11,7 +11,7 @@ export class CfgWindowMessageToProdConfConnector extends CfgIOProdConfConnector
|
|
|
11
11
|
getInitialProdConf() {
|
|
12
12
|
return undefined;
|
|
13
13
|
}
|
|
14
|
-
makeSendData(
|
|
15
|
-
return this.makeMessage(
|
|
14
|
+
makeSendData(prodConf, initial) {
|
|
15
|
+
return this.makeMessage(prodConf, initial);
|
|
16
16
|
}
|
|
17
17
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/web-api",
|
|
3
|
-
"version": "1.6.0-iotest.
|
|
3
|
+
"version": "1.6.0-iotest.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@configura/web-utilities": "1.6.0-iotest.
|
|
26
|
+
"@configura/web-utilities": "1.6.0-iotest.3"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "7f913509770f510cef840f5821fc0068887900ca"
|
|
29
29
|
}
|