@fluid-topics/ft-wc-utils 1.2.39 → 1.2.40
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/build/globals.min.js +11 -11
- package/build/helpers.d.ts +1 -0
- package/build/helpers.js +7 -0
- package/build/redux/FtReduxStore.js +2 -2
- package/package.json +2 -2
package/build/helpers.d.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -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.
|
|
3
|
+
"version": "1.2.40",
|
|
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": "
|
|
27
|
+
"gitHead": "497ff25b92883ae04f9f7080aa78ff605596a06d"
|
|
28
28
|
}
|