@fluid-topics/ft-wc-utils 1.2.39 → 1.2.41

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.
@@ -12,3 +12,4 @@ export declare function minmax(min: number, value: number, max: number): number;
12
12
  export declare function last<T = any>(arr: T[]): T | undefined;
13
13
  export declare function unslotText(node: any): string;
14
14
  export declare function getComposedPathTo(element: EventTarget): EventTarget[];
15
+ export declare function deepCopy<T = any>(value: T): T;
package/build/helpers.js CHANGED
@@ -162,3 +162,10 @@ export function getComposedPathTo(element) {
162
162
  element.removeEventListener("get-composed-path", findScrollableParent);
163
163
  return path;
164
164
  }
165
+ export function deepCopy(value) {
166
+ // @ts-ignore
167
+ if (window.structuredClone) {
168
+ return structuredClone(value);
169
+ }
170
+ return value != null ? JSON.parse(JSON.stringify(value)) : value;
171
+ }
package/build/index.d.ts CHANGED
@@ -34,3 +34,4 @@ export * from "./shadowQuerySelector";
34
34
  export * from "./SearchPlaceConverter";
35
35
  export * from "./FtFormComponent";
36
36
  export { setVariable } from "@fluid-topics/design-system-variables";
37
+ export * from "./SameWindowStorageEvent";
package/build/index.js CHANGED
@@ -31,6 +31,7 @@ import * as SearchPlaceConverter from "./SearchPlaceConverter";
31
31
  import * as FtFormComponent from "./FtFormComponent";
32
32
  import * as DateFormatter from "./DateFormatter";
33
33
  import { setVariable } from "@fluid-topics/design-system-variables";
34
+ import * as SameWindowStorageEvent from "./SameWindowStorageEvent";
34
35
  export const isSafari = (navigator.vendor && !!navigator.vendor.match(/apple/i))
35
36
  || ((_c = (_b = (_a = window.safari) === null || _a === void 0 ? void 0 : _a.pushNotification) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "") === "[object SafariRemoteNotification]";
36
37
  export const isTouchScreen = (("ontouchstart" in window)
@@ -69,6 +70,7 @@ window.ftGlobals = (_d = window.ftGlobals) !== null && _d !== void 0 ? _d : {
69
70
  ...shadowQuerySelector,
70
71
  ...SearchPlaceConverter,
71
72
  ...FtFormComponent,
73
+ ...SameWindowStorageEvent,
72
74
  isSafari,
73
75
  isTouchScreen,
74
76
  setVariable,
@@ -99,3 +101,4 @@ export * from "./shadowQuerySelector";
99
101
  export * from "./SearchPlaceConverter";
100
102
  export * from "./FtFormComponent";
101
103
  export { setVariable } from "@fluid-topics/design-system-variables";
104
+ export * from "./SameWindowStorageEvent";
@@ -2,6 +2,7 @@ import { configureStore, createSlice } from "@reduxjs/toolkit";
2
2
  import { isFtReduxStore } from "./models";
3
3
  import { FtCommandQueue } from "./FtCommandQueue";
4
4
  import { WithEventBus } from "../events";
5
+ import { deepCopy } from "../helpers";
5
6
  if (!window.ftReduxStores) {
6
7
  window.ftReduxStores = {};
7
8
  }
@@ -40,7 +41,6 @@ export class FtReduxStore extends WithEventBus {
40
41
  this.reduxStore = reduxStore;
41
42
  this.isFtReduxStore = true;
42
43
  this.commands = new FtCommandQueue();
43
- const deepCopy = (value) => value != null ? JSON.parse(JSON.stringify(value)) : value;
44
44
  // Add proxy to automatically dispatch changes
45
45
  this.actions = new Proxy(this.reduxSlice.actions, {
46
46
  get: (actions, p, receiver) => {
@@ -79,7 +79,7 @@ export class FtReduxStore extends WithEventBus {
79
79
  return this.reduxStore[Symbol.observable]();
80
80
  }
81
81
  getState() {
82
- return this.reduxStore.getState();
82
+ return deepCopy(this.reduxStore.getState());
83
83
  }
84
84
  replaceReducer(nextReducer) {
85
85
  throw new Error("Not implemented yet.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-wc-utils",
3
- "version": "1.2.39",
3
+ "version": "1.2.41",
4
4
  "description": "Internal web components tools",
5
5
  "author": "Fluid Topics <devtopics@antidot.net>",
6
6
  "license": "ISC",
@@ -24,5 +24,5 @@
24
24
  "mark.js": "8.11.1",
25
25
  "moment": "2.29.4"
26
26
  },
27
- "gitHead": "b5772ed3ef0ed0ffc2465cfb8307593eacb6ad27"
27
+ "gitHead": "2f51fbafc6693cb23bd5207ea7f9a7534bd8cb25"
28
28
  }