sprae 13.3.7 → 13.3.8
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/directive/each.js +29 -13
- package/dist/sprae-csp.js +9 -9
- package/dist/sprae-csp.js.map +3 -3
- package/dist/sprae-csp.umd.js +9 -9
- package/dist/sprae-csp.umd.js.map +3 -3
- package/dist/sprae-preact.js +4 -4
- package/dist/sprae-preact.js.map +3 -3
- package/dist/sprae-preact.umd.js +4 -4
- package/dist/sprae-preact.umd.js.map +3 -3
- package/dist/sprae.js +4 -4
- package/dist/sprae.js.map +3 -3
- package/dist/sprae.umd.js +4 -4
- package/dist/sprae.umd.js.map +3 -3
- package/package.json +1 -1
- package/store.js +20 -4
- package/types/directive/each.d.ts.map +1 -1
- package/types/store.d.ts +2 -0
- package/types/store.d.ts.map +1 -1
package/store.js
CHANGED
|
@@ -11,6 +11,9 @@ export const _signals = Symbol('signals')
|
|
|
11
11
|
/** Symbol for the change signal that tracks object keys or array length */
|
|
12
12
|
export const _change = Symbol('change')
|
|
13
13
|
|
|
14
|
+
/** Symbol for list index/content bumps (swap, splice, index writes) */
|
|
15
|
+
export const _touch = Symbol('touch')
|
|
16
|
+
|
|
14
17
|
/** Symbol for stashed setter on computed values */
|
|
15
18
|
export const _set = Symbol('set')
|
|
16
19
|
|
|
@@ -154,17 +157,26 @@ const list = (values, parent = globalThis) => {
|
|
|
154
157
|
|
|
155
158
|
length = signal(values.length),
|
|
156
159
|
|
|
160
|
+
// _touch bumps notify keyed :each of index/content changes (swap, splice) in O(1)
|
|
161
|
+
// instead of forcing :each to subscribe to all N index signals
|
|
162
|
+
touch = signal(0),
|
|
163
|
+
bump = () => { touch.value++ },
|
|
164
|
+
|
|
165
|
+
// capture native array mutators before they're shadowed on signals[]
|
|
166
|
+
asplice = signals.splice,
|
|
167
|
+
|
|
157
168
|
// proxy passes prop access to signals
|
|
158
169
|
state = new Proxy(
|
|
159
170
|
Object.assign(signals, {
|
|
160
171
|
[_change]: length,
|
|
172
|
+
[_touch]: touch,
|
|
161
173
|
[_signals]: signals,
|
|
162
|
-
// patch mutators
|
|
174
|
+
// patch mutators — `this` must be the list proxy so set traps fire reactively
|
|
163
175
|
push: mut(signals.push),
|
|
164
176
|
pop: mut(signals.pop),
|
|
165
177
|
shift: mut(signals.shift),
|
|
166
178
|
unshift: mut(signals.unshift),
|
|
167
|
-
splice: mut(
|
|
179
|
+
splice: mut(function () { let r = asplice.apply(this, arguments); bump(); return r }),
|
|
168
180
|
}),
|
|
169
181
|
{
|
|
170
182
|
get(_, k) {
|
|
@@ -195,8 +207,12 @@ const list = (values, parent = globalThis) => {
|
|
|
195
207
|
// force changing length, if eg. a=[]; a[1]=1 - need to come after setting the item
|
|
196
208
|
else if (k >= signals.length) create(signals, k, v, shallow), state.length = +k + 1
|
|
197
209
|
|
|
198
|
-
// existing signal
|
|
199
|
-
else signals[k]
|
|
210
|
+
// existing signal — bump for :each index tracking (swap)
|
|
211
|
+
else if (signals[k]) {
|
|
212
|
+
let s = signals[k], prev = s.peek?.() ?? s.valueOf()
|
|
213
|
+
set(signals, k, v, shallow)
|
|
214
|
+
if ((s.peek?.() ?? s.valueOf()) !== prev) bump()
|
|
215
|
+
} else create(signals, k, v, shallow)
|
|
200
216
|
|
|
201
217
|
return 1
|
|
202
218
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../directive/each.js"],"names":[],"mappings":"AAuBe;;;;
|
|
1
|
+
{"version":3,"file":"each.d.ts","sourceRoot":"","sources":["../../directive/each.js"],"names":[],"mappings":"AAuBe;;;;EAqId;;qBA5JqG,YAAY"}
|
package/types/store.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export const _signals: unique symbol;
|
|
3
3
|
/** Symbol for the change signal that tracks object keys or array length */
|
|
4
4
|
export const _change: unique symbol;
|
|
5
|
+
/** Symbol for list index/content bumps (swap, splice, index writes) */
|
|
6
|
+
export const _touch: unique symbol;
|
|
5
7
|
/** Symbol for stashed setter on computed values */
|
|
6
8
|
export const _set: unique symbol;
|
|
7
9
|
export function store<T extends unknown>(values: T, parent?: any): ReactiveStore<T>;
|
package/types/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../store.js"],"names":[],"mappings":"AAOA,oDAAoD;AACpD,qCAAyC;AAEzC,2EAA2E;AAC3E,oCAAuC;AAEvC,mDAAmD;AACnD,iCAAiC;AA6B1B,sBAVe,CAAC,0BACZ,CAAC,iBAEC,aAAa,CAAC,CAAC,CAAC,CAkG5B;;;;;0BA9GY,CAAC,IACD,CAAC,GAAG;IAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;CAAE"}
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../store.js"],"names":[],"mappings":"AAOA,oDAAoD;AACpD,qCAAyC;AAEzC,2EAA2E;AAC3E,oCAAuC;AAEvC,uEAAuE;AACvE,mCAAqC;AAErC,mDAAmD;AACnD,iCAAiC;AA6B1B,sBAVe,CAAC,0BACZ,CAAC,iBAEC,aAAa,CAAC,CAAC,CAAC,CAkG5B;;;;;0BA9GY,CAAC,IACD,CAAC,GAAG;IAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;CAAE"}
|