ctx-core 6.8.1 → 6.8.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.
@@ -44,7 +44,6 @@ export type sig_T<val_T, E = unknown> = (()=>val_T)&{
44
44
  readonly f?:rmemo_f_T
45
45
  readonly l:number
46
46
  readonly t:rmemo_T<unknown>[]
47
- readonly i:rmemo_T<unknown>[]
48
47
  readonly val:val_T
49
48
  add<add_val_T>(fn:rmemo_add_def_T<val_T, add_val_T>):sig_T<val_T, E>
50
49
  memo_<_val_T, E = unknown>(def:memo_def_T<_val_T>):memo_T<_val_T, E>
@@ -64,5 +63,9 @@ export type rmemo_val_T<sig_T> = sig_T extends { ():infer val_T }
64
63
  export type memo_def_T<val_T, E = unknown> = (sig:sig_T<val_T, E>)=>val_T
65
64
  export type rmemo_a_T = unknown[]
66
65
  export type rmemo_add_def_T<val_T, add_val_T, E = unknown> = (sig:sig_T<val_T, E>)=>add_val_T
67
- export type rmemo_f_T = (()=>void)
66
+ export type rmemo_f_T = (()=>void)&{
67
+ readonly l:number
68
+ readonly s:rmemo_T<unknown>[]
69
+ readonly t:rmemo_T<unknown>[]
70
+ }
68
71
  export type rmemo_r_T = WeakRef<rmemo_f_T>&{ readonly d?: ()=>rmemo_f_T }
@@ -12,19 +12,18 @@ let $ = globalThis.__rmemo__ ??= { q: new Set }
12
12
  * @private
13
13
  */
14
14
  export function memo_(memo_def, ...add_def_a) {
15
- let t = []
16
15
  /** @type {memo_T} */
17
16
  let memo = ()=>{
18
17
  'val' in memo || memo.f()
19
18
  if ($.c) {
20
- if (!t.includes($.c.r ??= new WeakRef($.c))) {
21
- t.push($.c.r)
19
+ if (!memo.t.includes($.c.s ??= new WeakRef($.c.f))) {
20
+ memo.t.push($.c.s)
22
21
  }
23
- if ($.c.l < memo.l + 1) $.c.l = memo.l + 1
22
+ if ($.c.f.l < memo.f.l + 1) $.c.f.l = memo.f.l + 1
24
23
  // memo is called by $.c's conditional execution...next change to memo will notify $.c
25
- $.c.t.push(memo)
24
+ $.c.f.s.push(memo)
26
25
  // prevent memo from GC while $.c still has a strong reference
27
- if (!$.c.i.includes(memo)) $.c.i.push(memo)
26
+ if (!$.c.f.t.includes(memo)) $.c.f.t.push(memo)
28
27
  }
29
28
  return memo.val
30
29
  }
@@ -32,9 +31,9 @@ export function memo_(memo_def, ...add_def_a) {
32
31
  get: memo,
33
32
  set: val=>{
34
33
  if (memo.val !== val) {
35
- t = t.filter(r=>{
34
+ memo.t = memo.t.filter(r=>{
36
35
  r = r.deref()
37
- if (r?.t.includes(memo)) { // if added by $.c.t.push(memo), add to $.q
36
+ if (r?.s.includes(memo)) { // if added by $.c.f.s.push(memo), add to $.q
38
37
  $.q.add(r)
39
38
  }
40
39
  return r
@@ -53,7 +52,7 @@ export function memo_(memo_def, ...add_def_a) {
53
52
  continue cur_refresh_loop
54
53
  }
55
54
  }
56
- cur_refresh.f()
55
+ cur_refresh()
57
56
  }
58
57
  },
59
58
  })
@@ -77,7 +76,7 @@ export function memo_(memo_def, ...add_def_a) {
77
76
  memo.f = ()=>{
78
77
  let prev_memo = $.c
79
78
  $.c = memo
80
- memo.t = [] // reset references in memo_def conditional execution path...see $.c.t.push(memo)
79
+ memo.f.s = [] // reset references in memo_def conditional execution path...see $.c.f.s.push(memo)
81
80
  try {
82
81
  memo._ = memo_def(memo)
83
82
  } catch (err) {
@@ -85,9 +84,10 @@ export function memo_(memo_def, ...add_def_a) {
85
84
  }
86
85
  $.c = prev_memo // catch does not throw
87
86
  }
88
- memo.l = 0
87
+ memo.f.l = 0
88
+ memo.f.s = []
89
+ memo.f.t = []
89
90
  memo.t = []
90
- memo.i = []
91
91
  return memo
92
92
  }
93
93
  export { memo_ as memosig_ }
@@ -153,8 +153,8 @@ export function memo__bind(fn) {
153
153
  */
154
154
  export function rmemo__on(rmemo, off_fn) {
155
155
  if (off_fn) rmemo__off__add(rmemo, off_fn)
156
- if (rmemo.r?.d) {
157
- rmemo.r.deref = rmemo.r.d
156
+ if (rmemo.s?.d) {
157
+ rmemo.s.deref = rmemo.s.d
158
158
  }
159
159
  rmemo.f()
160
160
  return rmemo
@@ -165,9 +165,9 @@ export function rmemo__on(rmemo, off_fn) {
165
165
  * @returns {rmemo_T}
166
166
  */
167
167
  export function rmemo__off(rmemo) {
168
- if (rmemo.r) {
169
- rmemo.r.d ??= rmemo.r.deref
170
- rmemo.r.deref = ()=>{
168
+ if (rmemo.s) {
169
+ rmemo.s.d ??= rmemo.s.deref
170
+ rmemo.s.deref = ()=>{
171
171
  }
172
172
  }
173
173
  for (let a_o of rmemo.a ?? []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-core",
3
- "version": "6.8.1",
3
+ "version": "6.8.2",
4
4
  "description": "ctx-core core library",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -374,28 +374,28 @@
374
374
  "import": {
375
375
  "./rmemo": "{ memo_ }"
376
376
  },
377
- "limit": "377 B"
377
+ "limit": "376 B"
378
378
  },
379
379
  {
380
380
  "name": "memo_ sig_",
381
381
  "import": {
382
382
  "./rmemo": "{ sig_, memo_ }"
383
383
  },
384
- "limit": "393 B"
384
+ "limit": "394 B"
385
385
  },
386
386
  {
387
387
  "name": "memo_ sig_ be_ ctx_",
388
388
  "import": {
389
389
  "./rmemo": "{ sig_, memo_, be_, ctx_ }"
390
390
  },
391
- "limit": "499 B"
391
+ "limit": "498 B"
392
392
  },
393
393
  {
394
394
  "name": "memo_ sig_ be_ ctx_ be_memo_pair_ be_sig_triple_",
395
395
  "import": {
396
396
  "./rmemo": "{ sig_, memo_, be_, ctx_, be_memo_pair_, be_sig_triple_ }"
397
397
  },
398
- "limit": "587 B"
398
+ "limit": "591 B"
399
399
  },
400
400
  {
401
401
  "name": "class_",
@@ -430,7 +430,7 @@
430
430
  "import": {
431
431
  "./web_animation": "{ memo_, wanimato__new }"
432
432
  },
433
- "limit": "728 B"
433
+ "limit": "730 B"
434
434
  }
435
435
  ],
436
436
  "scripts": {