@fluid-topics/ft-app-context 2.0.32 → 2.0.34

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.
@@ -23,6 +23,7 @@ export declare class HistoryService extends WithEventBus {
23
23
  currentItem(): HistoryState;
24
24
  back(): void;
25
25
  backwardItem(): HistoryState | undefined;
26
+ backwardItemMatching(predicate: (_: HistoryState) => boolean | undefined): HistoryState | undefined;
26
27
  private previousDifferentMajorPosition;
27
28
  forward(): void;
28
29
  forwardItem(): HistoryState | undefined;
@@ -1,6 +1,6 @@
1
- import { deepCopy, deepEqual, WithEventBus } from "@fluid-topics/ft-wc-utils";
2
- import { HistoryChangeEvent } from "./HistoryService.models";
3
- import { historyStorage } from "./HistorySessionStorage";
1
+ import { deepCopy, deepEqual, WithEventBus, } from "@fluid-topics/ft-wc-utils";
2
+ import { HistoryChangeEvent, } from "./HistoryService.models";
3
+ import { historyStorage, } from "./HistorySessionStorage";
4
4
  export class HistoryService extends WithEventBus {
5
5
  static build() {
6
6
  return new HistoryService(window.history, historyStorage, () => window.location, false);
@@ -102,6 +102,13 @@ export class HistoryService extends WithEventBus {
102
102
  backwardItem() {
103
103
  return deepCopy(this.states[this.previousDifferentMajorPosition()]);
104
104
  }
105
+ backwardItemMatching(predicate) {
106
+ const backwardStates = this.states
107
+ .filter((state) => !!state)
108
+ .filter((state) => state.index < this.currentIndex)
109
+ .reverse();
110
+ return deepCopy(backwardStates.find((state) => predicate(state)));
111
+ }
105
112
  previousDifferentMajorPosition() {
106
113
  let position = this.currentIndex > 0 ? this.currentIndex - 1 : 0;
107
114
  while (position > 0 && !this.isDifferentMajorState(position)) {
@@ -8,6 +8,7 @@ declare global {
8
8
  forward: HistoryService["back"];
9
9
  backwardItem: HistoryService["backwardItem"];
10
10
  forwardItem: HistoryService["forwardItem"];
11
+ backwardItemMatching: HistoryService["backwardItemMatching"];
11
12
  addHistoryChangeListener: HistoryService["addHistoryChangeListener"];
12
13
  removeHistoryChangeListener: HistoryService["removeHistoryChangeListener"];
13
14
  };
@@ -7,7 +7,8 @@ if (window.FluidTopicsInternalHistoryService == null) {
7
7
  forward: () => window.FluidTopicsInternalHistoryService.forward(),
8
8
  backwardItem: () => window.FluidTopicsInternalHistoryService.backwardItem(),
9
9
  forwardItem: () => window.FluidTopicsInternalHistoryService.forwardItem(),
10
- addHistoryChangeListener: (callback) => window.FluidTopicsInternalHistoryService.addHistoryChangeListener(callback),
11
- removeHistoryChangeListener: (callback) => window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(callback),
10
+ backwardItemMatching: (predicate) => window.FluidTopicsInternalHistoryService.backwardItemMatching(predicate),
11
+ addHistoryChangeListener: (listener) => window.FluidTopicsInternalHistoryService.addHistoryChangeListener(listener),
12
+ removeHistoryChangeListener: (listener) => window.FluidTopicsInternalHistoryService.removeHistoryChangeListener(listener),
12
13
  };
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-app-context",
3
- "version": "2.0.32",
3
+ "version": "2.0.34",
4
4
  "description": "Global application context for Fluid Topics integrations",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,11 +19,11 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "2.0.32",
22
+ "@fluid-topics/ft-wc-utils": "2.0.34",
23
23
  "lit": "3.1.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@fluid-topics/public-api": "1.0.123"
27
27
  },
28
- "gitHead": "7b9fd05cccbb50a04b9639b26e2d958ca494c83e"
28
+ "gitHead": "4d4baba1c07ce52b8763655aaeacc33a9c4ac9b8"
29
29
  }