@stencil/store 2.2.2 → 2.2.3-dev.1785970285.b07d6c8
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 +21 -15
- package/dist/index.js +21 -15
- package/dist/{utils.d.ts → src/utils.d.ts} +1 -1
- package/package.json +5 -5
- /package/dist/{index.d.ts → src/index.d.ts} +0 -0
- /package/dist/{observable-map.d.ts → src/observable-map.d.ts} +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{subscriptions → src/subscriptions}/stencil.d.ts +0 -0
- /package/dist/{types.d.ts → src/types.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -21,15 +21,18 @@ function _interopNamespaceDefault(e) {
|
|
|
21
21
|
|
|
22
22
|
var StencilCore__namespace = /*#__PURE__*/_interopNamespaceDefault(StencilCore);
|
|
23
23
|
|
|
24
|
-
const appendToMap = (map, propName, value) => {
|
|
24
|
+
const appendToMap = (map, refsByValue, propName, value) => {
|
|
25
|
+
let ref = refsByValue.get(value);
|
|
26
|
+
if (!ref) {
|
|
27
|
+
ref = new WeakRef(value);
|
|
28
|
+
refsByValue.set(value, ref);
|
|
29
|
+
}
|
|
25
30
|
let refs = map.get(propName);
|
|
26
31
|
if (!refs) {
|
|
27
|
-
refs =
|
|
32
|
+
refs = new Set();
|
|
28
33
|
map.set(propName, refs);
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
refs.push(new WeakRef(value));
|
|
32
|
-
}
|
|
35
|
+
refs.add(ref);
|
|
33
36
|
};
|
|
34
37
|
const debounce = (fn, ms) => {
|
|
35
38
|
let timeoutId;
|
|
@@ -55,13 +58,15 @@ const debounce = (fn, ms) => {
|
|
|
55
58
|
*/
|
|
56
59
|
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
57
60
|
const cleanupElements = debounce((map) => {
|
|
58
|
-
|
|
59
|
-
const
|
|
61
|
+
map.forEach((refs, key) => {
|
|
62
|
+
const nextRefs = new Set();
|
|
63
|
+
refs.forEach((ref) => {
|
|
60
64
|
const elm = ref.deref();
|
|
61
|
-
|
|
65
|
+
if (elm && isConnected(elm))
|
|
66
|
+
nextRefs.add(ref);
|
|
62
67
|
});
|
|
63
|
-
map.set(key,
|
|
64
|
-
}
|
|
68
|
+
map.set(key, nextRefs);
|
|
69
|
+
});
|
|
65
70
|
}, 2_000);
|
|
66
71
|
const core = StencilCore__namespace;
|
|
67
72
|
const forceUpdate = core.forceUpdate;
|
|
@@ -74,23 +79,24 @@ const stencilSubscription = () => {
|
|
|
74
79
|
}
|
|
75
80
|
const ensureForceUpdate = forceUpdate;
|
|
76
81
|
const ensureGetRenderingRef = getRenderingRef;
|
|
82
|
+
const refsByElement = new WeakMap();
|
|
77
83
|
const elmsToUpdate = new Map();
|
|
78
84
|
return {
|
|
79
85
|
dispose: () => elmsToUpdate.clear(),
|
|
80
86
|
get: (propName) => {
|
|
81
87
|
const elm = ensureGetRenderingRef();
|
|
82
88
|
if (elm) {
|
|
83
|
-
appendToMap(elmsToUpdate, propName, elm);
|
|
89
|
+
appendToMap(elmsToUpdate, refsByElement, propName, elm);
|
|
84
90
|
}
|
|
85
91
|
},
|
|
86
92
|
set: (propName) => {
|
|
87
93
|
const refs = elmsToUpdate.get(propName);
|
|
88
94
|
if (refs) {
|
|
89
|
-
const nextRefs =
|
|
95
|
+
const nextRefs = new Set();
|
|
96
|
+
refs.forEach((ref) => {
|
|
90
97
|
const elm = ref.deref();
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
return ensureForceUpdate(elm);
|
|
98
|
+
if (elm && ensureForceUpdate(elm))
|
|
99
|
+
nextRefs.add(ref);
|
|
94
100
|
});
|
|
95
101
|
elmsToUpdate.set(propName, nextRefs);
|
|
96
102
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import * as StencilCore from '@stencil/core';
|
|
2
2
|
|
|
3
|
-
const appendToMap = (map, propName, value) => {
|
|
3
|
+
const appendToMap = (map, refsByValue, propName, value) => {
|
|
4
|
+
let ref = refsByValue.get(value);
|
|
5
|
+
if (!ref) {
|
|
6
|
+
ref = new WeakRef(value);
|
|
7
|
+
refsByValue.set(value, ref);
|
|
8
|
+
}
|
|
4
9
|
let refs = map.get(propName);
|
|
5
10
|
if (!refs) {
|
|
6
|
-
refs =
|
|
11
|
+
refs = new Set();
|
|
7
12
|
map.set(propName, refs);
|
|
8
13
|
}
|
|
9
|
-
|
|
10
|
-
refs.push(new WeakRef(value));
|
|
11
|
-
}
|
|
14
|
+
refs.add(ref);
|
|
12
15
|
};
|
|
13
16
|
const debounce = (fn, ms) => {
|
|
14
17
|
let timeoutId;
|
|
@@ -34,13 +37,15 @@ const debounce = (fn, ms) => {
|
|
|
34
37
|
*/
|
|
35
38
|
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
|
|
36
39
|
const cleanupElements = debounce((map) => {
|
|
37
|
-
|
|
38
|
-
const
|
|
40
|
+
map.forEach((refs, key) => {
|
|
41
|
+
const nextRefs = new Set();
|
|
42
|
+
refs.forEach((ref) => {
|
|
39
43
|
const elm = ref.deref();
|
|
40
|
-
|
|
44
|
+
if (elm && isConnected(elm))
|
|
45
|
+
nextRefs.add(ref);
|
|
41
46
|
});
|
|
42
|
-
map.set(key,
|
|
43
|
-
}
|
|
47
|
+
map.set(key, nextRefs);
|
|
48
|
+
});
|
|
44
49
|
}, 2_000);
|
|
45
50
|
const core = StencilCore;
|
|
46
51
|
const forceUpdate = core.forceUpdate;
|
|
@@ -53,23 +58,24 @@ const stencilSubscription = () => {
|
|
|
53
58
|
}
|
|
54
59
|
const ensureForceUpdate = forceUpdate;
|
|
55
60
|
const ensureGetRenderingRef = getRenderingRef;
|
|
61
|
+
const refsByElement = new WeakMap();
|
|
56
62
|
const elmsToUpdate = new Map();
|
|
57
63
|
return {
|
|
58
64
|
dispose: () => elmsToUpdate.clear(),
|
|
59
65
|
get: (propName) => {
|
|
60
66
|
const elm = ensureGetRenderingRef();
|
|
61
67
|
if (elm) {
|
|
62
|
-
appendToMap(elmsToUpdate, propName, elm);
|
|
68
|
+
appendToMap(elmsToUpdate, refsByElement, propName, elm);
|
|
63
69
|
}
|
|
64
70
|
},
|
|
65
71
|
set: (propName) => {
|
|
66
72
|
const refs = elmsToUpdate.get(propName);
|
|
67
73
|
if (refs) {
|
|
68
|
-
const nextRefs =
|
|
74
|
+
const nextRefs = new Set();
|
|
75
|
+
refs.forEach((ref) => {
|
|
69
76
|
const elm = ref.deref();
|
|
70
|
-
if (
|
|
71
|
-
|
|
72
|
-
return ensureForceUpdate(elm);
|
|
77
|
+
if (elm && ensureForceUpdate(elm))
|
|
78
|
+
nextRefs.add(ref);
|
|
73
79
|
});
|
|
74
80
|
elmsToUpdate.set(propName, nextRefs);
|
|
75
81
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const appendToMap: <K, V extends Object>(map: Map<K, WeakRef<V
|
|
1
|
+
export declare const appendToMap: <K, V extends Object>(map: Map<K, Set<WeakRef<V>>>, refsByValue: WeakMap<V, 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.3-dev.1785970285.b07d6c8",
|
|
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",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"@ionic/prettier-config": "^4.0.0",
|
|
56
56
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
57
57
|
"@stencil/core": "^4.38.2",
|
|
58
|
-
"@types/node": "^
|
|
58
|
+
"@types/node": "^26.0.0",
|
|
59
59
|
"@vitest/coverage-v8": "^4.0.5",
|
|
60
|
-
"np": "^
|
|
61
|
-
"npm-run-all2": "^
|
|
60
|
+
"np": "^11.0.1",
|
|
61
|
+
"npm-run-all2": "^9.0.1",
|
|
62
62
|
"prettier": "^3.6.2",
|
|
63
63
|
"rimraf": "^6.0.1",
|
|
64
64
|
"rollup": "^4.52.5",
|
|
65
|
-
"typescript": "~
|
|
65
|
+
"typescript": "~6.0.2",
|
|
66
66
|
"vitest": "^4.0.5"
|
|
67
67
|
},
|
|
68
68
|
"prettier": "@ionic/prettier-config"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|