@stencil/store 2.2.1-dev.1763340412.50ef6ed → 2.2.2
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/index.cjs +27 -10
- package/dist/index.js +27 -10
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,12 +22,13 @@ function _interopNamespaceDefault(e) {
|
|
|
22
22
|
var StencilCore__namespace = /*#__PURE__*/_interopNamespaceDefault(StencilCore);
|
|
23
23
|
|
|
24
24
|
const appendToMap = (map, propName, value) => {
|
|
25
|
-
|
|
26
|
-
if (!
|
|
27
|
-
|
|
25
|
+
let refs = map.get(propName);
|
|
26
|
+
if (!refs) {
|
|
27
|
+
refs = [];
|
|
28
|
+
map.set(propName, refs);
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
if (!refs.some((ref) => ref.deref() === value)) {
|
|
31
|
+
refs.push(new WeakRef(value));
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
const debounce = (fn, ms) => {
|
|
@@ -55,7 +56,11 @@ const debounce = (fn, ms) => {
|
|
|
55
56
|
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
56
57
|
const cleanupElements = debounce((map) => {
|
|
57
58
|
for (let key of map.keys()) {
|
|
58
|
-
|
|
59
|
+
const refs = map.get(key).filter((ref) => {
|
|
60
|
+
const elm = ref.deref();
|
|
61
|
+
return elm && isConnected(elm);
|
|
62
|
+
});
|
|
63
|
+
map.set(key, refs);
|
|
59
64
|
}
|
|
60
65
|
}, 2_000);
|
|
61
66
|
const core = StencilCore__namespace;
|
|
@@ -79,14 +84,26 @@ const stencilSubscription = () => {
|
|
|
79
84
|
}
|
|
80
85
|
},
|
|
81
86
|
set: (propName) => {
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
|
|
87
|
+
const refs = elmsToUpdate.get(propName);
|
|
88
|
+
if (refs) {
|
|
89
|
+
const nextRefs = refs.filter((ref) => {
|
|
90
|
+
const elm = ref.deref();
|
|
91
|
+
if (!elm)
|
|
92
|
+
return false;
|
|
93
|
+
return ensureForceUpdate(elm);
|
|
94
|
+
});
|
|
95
|
+
elmsToUpdate.set(propName, nextRefs);
|
|
85
96
|
}
|
|
86
97
|
cleanupElements(elmsToUpdate);
|
|
87
98
|
},
|
|
88
99
|
reset: () => {
|
|
89
|
-
elmsToUpdate.forEach((
|
|
100
|
+
elmsToUpdate.forEach((refs) => {
|
|
101
|
+
refs.forEach((ref) => {
|
|
102
|
+
const elm = ref.deref();
|
|
103
|
+
if (elm)
|
|
104
|
+
ensureForceUpdate(elm);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
90
107
|
cleanupElements(elmsToUpdate);
|
|
91
108
|
},
|
|
92
109
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as StencilCore from '@stencil/core';
|
|
2
2
|
|
|
3
3
|
const appendToMap = (map, propName, value) => {
|
|
4
|
-
|
|
5
|
-
if (!
|
|
6
|
-
|
|
4
|
+
let refs = map.get(propName);
|
|
5
|
+
if (!refs) {
|
|
6
|
+
refs = [];
|
|
7
|
+
map.set(propName, refs);
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
if (!refs.some((ref) => ref.deref() === value)) {
|
|
10
|
+
refs.push(new WeakRef(value));
|
|
10
11
|
}
|
|
11
12
|
};
|
|
12
13
|
const debounce = (fn, ms) => {
|
|
@@ -34,7 +35,11 @@ const debounce = (fn, ms) => {
|
|
|
34
35
|
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
35
36
|
const cleanupElements = debounce((map) => {
|
|
36
37
|
for (let key of map.keys()) {
|
|
37
|
-
|
|
38
|
+
const refs = map.get(key).filter((ref) => {
|
|
39
|
+
const elm = ref.deref();
|
|
40
|
+
return elm && isConnected(elm);
|
|
41
|
+
});
|
|
42
|
+
map.set(key, refs);
|
|
38
43
|
}
|
|
39
44
|
}, 2_000);
|
|
40
45
|
const core = StencilCore;
|
|
@@ -58,14 +63,26 @@ const stencilSubscription = () => {
|
|
|
58
63
|
}
|
|
59
64
|
},
|
|
60
65
|
set: (propName) => {
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
66
|
+
const refs = elmsToUpdate.get(propName);
|
|
67
|
+
if (refs) {
|
|
68
|
+
const nextRefs = refs.filter((ref) => {
|
|
69
|
+
const elm = ref.deref();
|
|
70
|
+
if (!elm)
|
|
71
|
+
return false;
|
|
72
|
+
return ensureForceUpdate(elm);
|
|
73
|
+
});
|
|
74
|
+
elmsToUpdate.set(propName, nextRefs);
|
|
64
75
|
}
|
|
65
76
|
cleanupElements(elmsToUpdate);
|
|
66
77
|
},
|
|
67
78
|
reset: () => {
|
|
68
|
-
elmsToUpdate.forEach((
|
|
79
|
+
elmsToUpdate.forEach((refs) => {
|
|
80
|
+
refs.forEach((ref) => {
|
|
81
|
+
const elm = ref.deref();
|
|
82
|
+
if (elm)
|
|
83
|
+
ensureForceUpdate(elm);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
69
86
|
cleanupElements(elmsToUpdate);
|
|
70
87
|
},
|
|
71
88
|
};
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const appendToMap: <K, V>(map: Map<K, V[]>, propName: K, value: V) => void;
|
|
1
|
+
export declare const appendToMap: <K, V extends Object>(map: Map<K, WeakRef<V>[]>, propName: K, value: V) => void;
|
|
2
2
|
export declare const debounce: <T extends (...args: any[]) => any>(fn: T, ms: number) => ((...args: Parameters<T>) => void);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/store",
|
|
3
3
|
"author": "StencilJS Team",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.2",
|
|
5
5
|
"description": "Store is a lightweight shared state library by the StencilJS core team. Implements a simple key/value map that efficiently re-renders components when necessary.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://stenciljs.com/docs/stencil-store",
|