@configura/web-api 2.0.0-alpha.6 → 2.0.0-alpha.7

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.
@@ -598,13 +598,12 @@ prodParams, settings, optional, loadingObservable, parent, root, additionalProdu
598
598
  const productResponse = yield productLoaderForGroupedLoad.getProduct(correctDefaultsOnCatalogueParams(prodParams));
599
599
  const { productData, rootFeatureRefs, features: allRawFeatures, uuid, unit, } = productResponse;
600
600
  const product = yield new Promise((initSuccess, initFail) => {
601
- var _a;
602
601
  const p = new _CfgProductInternal(() => {
603
602
  // We absolutely do not want anyone to assign to this._configuration. So we want that field private.
604
603
  // But we can not set the api selection synchronously. And the product configuration needs "this". So we use this callback.
605
604
  // Feel free to find a nicer more readable solution :)
606
605
  initSuccess(p);
607
- }, initFail, productLoaderRaw, prodParams, settings, optional, !optional, rootFeatureRefs, allRawFeatures, uuid, unit, productData, (_a = productData.partsData.selOptions) !== null && _a !== void 0 ? _a : [], loadingObservable, parent, root, additionalProductRef, syncGroupHandler);
606
+ }, initFail, productLoaderRaw, prodParams, settings, optional, !optional, rootFeatureRefs, allRawFeatures, uuid, unit, productData, productData.partsData.selOptions || [], loadingObservable, parent, root, additionalProductRef, syncGroupHandler);
608
607
  });
609
608
  yield product._syncAndLoadAdditionalProducts(productLoaderForGroupedLoad);
610
609
  // Product is guaranteed to be root
@@ -10,19 +10,9 @@ declare type CfgHistoryManagerMessageData = {
10
10
  */
11
11
  export declare type CfgHistoryManagerSendData<D> = {
12
12
  message: D;
13
- historyWriteMode: CfgHistoryWriteMode;
13
+ useHistoryPush: boolean;
14
14
  qsKeyValues: Map<string, string | undefined>;
15
15
  };
16
- /**
17
- * @param Replace Just updates the URL
18
- * @param Push Push makes the web browser navigation buttons navigate configuration changes.
19
- * @param DoNotWrite Do not update the history at all.
20
- */
21
- export declare enum CfgHistoryWriteMode {
22
- Replace = "Replace",
23
- Push = "Push",
24
- DoNotWrite = "DoNotWrite"
25
- }
26
16
  /**
27
17
  * This class does nothing on it's own. It is used to coordinate writing to the history, that
28
18
  * is, updating the browsing history.
@@ -1,17 +1,6 @@
1
1
  import { mapQueryString, unmapQueryString } from "@configura/web-utilities";
2
2
  import { CfgIOManager } from "./CfgIOManager.js";
3
3
  import { CfgWindowEventManager } from "./CfgWindowEventManager.js";
4
- /**
5
- * @param Replace Just updates the URL
6
- * @param Push Push makes the web browser navigation buttons navigate configuration changes.
7
- * @param DoNotWrite Do not update the history at all.
8
- */
9
- export var CfgHistoryWriteMode;
10
- (function (CfgHistoryWriteMode) {
11
- CfgHistoryWriteMode["Replace"] = "Replace";
12
- CfgHistoryWriteMode["Push"] = "Push";
13
- CfgHistoryWriteMode["DoNotWrite"] = "DoNotWrite";
14
- })(CfgHistoryWriteMode || (CfgHistoryWriteMode = {}));
15
4
  /**
16
5
  * This class does nothing on it's own. It is used to coordinate writing to the history, that
17
6
  * is, updating the browsing history.
@@ -31,17 +20,14 @@ export class CfgHistoryManager extends CfgWindowEventManager {
31
20
  * Write to the history
32
21
  */
33
22
  send(messageKey, data) {
34
- const { qsKeyValues, message, historyWriteMode } = data;
35
- if (historyWriteMode === CfgHistoryWriteMode.DoNotWrite) {
36
- return;
37
- }
23
+ const { qsKeyValues, message, useHistoryPush } = data;
38
24
  // Initial data is before user interaction has happened
39
25
  const initial = message.initial;
40
26
  // At initial we do not replace the URL as we presumable have the defaults
41
27
  const newUrl = initial ? null : CfgHistoryManager._makeUpdatedUrl(qsKeyValues);
42
28
  // ...but we do replace the state so that we can in the future browse back to here
43
29
  const newState = CfgHistoryManager._makeUpdatedState(window.history.state, message, messageKey);
44
- if (initial || historyWriteMode === CfgHistoryWriteMode.Replace || this.receiveInProgress) {
30
+ if (initial || !useHistoryPush || this.receiveInProgress) {
45
31
  window.history.replaceState(newState, "", newUrl);
46
32
  }
47
33
  else {
@@ -1,5 +1,5 @@
1
1
  import { DtoConfProd } from "../CatalogueAPI.js";
2
- import { CfgHistoryManager, CfgHistoryManagerSendData, CfgHistoryWriteMode } from "./CfgHistoryManager.js";
2
+ import { CfgHistoryManager, CfgHistoryManagerSendData } from "./CfgHistoryManager.js";
3
3
  import { CfgIOProdConfConnector, CfgProdConfMessage } from "./CfgIOProdConfConnector.js";
4
4
  export declare function dtoConfToString(conf: DtoConfProd): string;
5
5
  export declare function stringToDtoConf(conf: string): DtoConfProd;
@@ -7,14 +7,14 @@ export declare function stringToDtoConf(conf: string): DtoConfProd;
7
7
  * Instantiating this will make the browser history (and URL) update with the product configuration.
8
8
  */
9
9
  export declare class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector<CfgHistoryManagerSendData<CfgProdConfMessage>> {
10
- private readonly _historyWriteMode;
10
+ private readonly _useHistoryPush;
11
11
  private readonly _qsKey;
12
12
  /**
13
- * @param _historyWriteMode What way to update history.
13
+ * @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
14
14
  * @param _qsKey The Query String key for product configuration.
15
15
  * @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
16
16
  */
17
- constructor(manager: CfgHistoryManager, _historyWriteMode: CfgHistoryWriteMode, _qsKey?: string, doValidate?: boolean);
17
+ constructor(manager: CfgHistoryManager, _useHistoryPush: boolean, _qsKey?: string, doValidate?: boolean);
18
18
  protected getInitialProdConf(): DtoConfProd | undefined;
19
19
  protected makeSendData(conf: DtoConfProd, initial: boolean): CfgHistoryManagerSendData<CfgProdConfMessage>;
20
20
  }
@@ -1,4 +1,4 @@
1
- import { CfgHistoryManager, } from "./CfgHistoryManager.js";
1
+ import { CfgHistoryManager } from "./CfgHistoryManager.js";
2
2
  import { CfgIOProdConfConnector, CfgProdConfMessageVersions, STAGE_PROD_CONF_MESSAGE_KEY, } from "./CfgIOProdConfConnector.js";
3
3
  const jsonKeyRegex = /"([^"]+)":/g;
4
4
  const keyMap = [
@@ -30,13 +30,13 @@ export function stringToDtoConf(conf) {
30
30
  */
31
31
  export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
32
32
  /**
33
- * @param _historyWriteMode What way to update history.
33
+ * @param _useHistoryPush As opposed to replace. Push makes the web browser navigation buttons navigate configuration changes. Replace just updates the URL.
34
34
  * @param _qsKey The Query String key for product configuration.
35
35
  * @param doValidate When popping from the history stack (navigating in the browser), should a navigate call be sent to the server to verify that the product configuration is still valid?
36
36
  */
37
- constructor(manager, _historyWriteMode, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
37
+ constructor(manager, _useHistoryPush, _qsKey = STAGE_PROD_CONF_MESSAGE_KEY, doValidate = true) {
38
38
  super(manager, doValidate, CfgProdConfMessageVersions.V2dot0, false, false);
39
- this._historyWriteMode = _historyWriteMode;
39
+ this._useHistoryPush = _useHistoryPush;
40
40
  this._qsKey = _qsKey;
41
41
  }
42
42
  getInitialProdConf() {
@@ -50,7 +50,7 @@ export class CfgHistoryToProdConfConnector extends CfgIOProdConfConnector {
50
50
  return {
51
51
  message: this.makeMessage(conf, initial),
52
52
  qsKeyValues: new Map([[STAGE_PROD_CONF_MESSAGE_KEY, dtoConfToString(conf)]]),
53
- historyWriteMode: this._historyWriteMode,
53
+ useHistoryPush: this._useHistoryPush,
54
54
  };
55
55
  }
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/web-api",
3
- "version": "2.0.0-alpha.6",
3
+ "version": "2.0.0-alpha.7",
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": "2.0.0-alpha.6"
26
+ "@configura/web-utilities": "2.0.0-alpha.7"
27
27
  },
28
- "gitHead": "91edc6834460f70904b9914292a5869ad6e8b245"
28
+ "gitHead": "bab414b6e4a9ed5f0f5abd9b872c516b22655298"
29
29
  }