ctx-core 7.0.1 → 7.1.0

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.
@@ -1,13 +1,15 @@
1
1
  /// <reference types="ctx-core" />
2
- import { be_sig_triple_ } from '../be_sig_triple/index.js'
2
+ import { id_be_sig_triple_ } from '../be_sig_triple/index.js'
3
3
  import { import_meta_env_ } from '../import_meta_env/index.js'
4
4
  export const [
5
5
  CACHE_VERSION$_,
6
6
  CACHE_VERSION_,
7
7
  CACHE_VERSION__set,
8
- ] = /** @type {be_sig_triple_T<false|string>} */ be_sig_triple_(()=>
9
- typeof process === 'object' && import_meta_env_().CACHE_VERSION,
10
- { id: 'CACHE_VERSION' })
8
+ ] = /** @type {be_sig_triple_T<false|string>} */
9
+ id_be_sig_triple_(
10
+ 'CACHE_VERSION',
11
+ ()=>
12
+ typeof process === 'object' && import_meta_env_().CACHE_VERSION)
11
13
  export {
12
14
  CACHE_VERSION$_ as CACHE_VERSION__,
13
15
  CACHE_VERSION$_ as b__CACHE_VERSION,
@@ -1,13 +1,14 @@
1
1
  /// <reference types="ctx-core" />
2
- import { be_sig_triple_ } from '../be_sig_triple/index.js'
2
+ import { id_be_sig_triple_ } from '../be_sig_triple/index.js'
3
3
  import { import_meta_env_ } from '../import_meta_env/index.js'
4
4
  export const [
5
5
  NODE_ENV$_,
6
6
  NODE_ENV_,
7
7
  NODE_ENV__set,
8
- ] = be_sig_triple_(()=>
9
- import_meta_env_().NODE_ENV,
10
- { id: 'NODE_ENV' })
8
+ ] = id_be_sig_triple_(
9
+ 'NODE_ENV',
10
+ ()=>
11
+ import_meta_env_().NODE_ENV)
11
12
  export {
12
13
  NODE_ENV$_ as NODE_ENV__,
13
14
  NODE_ENV$_ as b__NODE_ENV,
@@ -1,12 +1,13 @@
1
- import { be_sig_triple_ } from '../be_sig_triple/index.js'
1
+ import { id_be_sig_triple_ } from '../be_sig_triple/index.js'
2
2
  import { import_meta_env_ } from '../import_meta_env/index.js'
3
3
  export const [
4
4
  VERSION$_,
5
5
  VERSION_,
6
6
  VERSION__set,
7
- ] = be_sig_triple_(()=>
8
- typeof process === 'object'
7
+ ] = id_be_sig_triple_(
8
+ 'VERSION',
9
+ ()=>
10
+ typeof process === 'object'
9
11
  && (import_meta_env_().VERSION || import_meta_env_().HEROKU_SLUG_COMMIT)
10
- || Math.random().toString(),
11
- { id: 'VERSION' })
12
+ || Math.random().toString())
12
13
  export { VERSION$_ as VERSION__ }
package/all/be/index.d.ts CHANGED
@@ -9,3 +9,30 @@ export declare function be<
9
9
  config:be_config_T<ns_T>
10
10
  ):val_T
11
11
  export { be as b, }
12
+ export declare function id_be<
13
+ val_T extends NonNullable<unknown>,
14
+ ctx_T extends wide_ctx_T<''> = wide_ctx_T<''>,
15
+ >(
16
+ ctx:ctx_T,
17
+ id:string,
18
+ val_:be__val__new_T<val_T, '', ctx_T>,
19
+ ):val_T
20
+ export declare function ns_be<
21
+ val_T extends NonNullable<unknown>,
22
+ ns_T extends string = '',
23
+ ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
24
+ >(
25
+ ctx:ctx_T,
26
+ ns:ns_T,
27
+ val_:be__val__new_T<val_T, ns_T, ctx_T>,
28
+ ):val_T
29
+ export declare function ns_id_be<
30
+ val_T extends NonNullable<unknown>,
31
+ ns_T extends string = '',
32
+ ctx_T extends wide_ctx_T<ns_T> = wide_ctx_T<ns_T>,
33
+ >(
34
+ ctx:ctx_T,
35
+ ns:ns_T,
36
+ id:string,
37
+ val_:be__val__new_T<val_T, ns_T, ctx_T>,
38
+ ):val_T
package/all/be/index.js CHANGED
@@ -10,3 +10,28 @@ export function be(ctx, val_, config) {
10
10
  return be_(val_, config)(ctx)
11
11
  }
12
12
  export { be as b, }
13
+ /**
14
+ * @param {ctx_T}ctx
15
+ * @param {string}id
16
+ * @param {be__val__new_T}val_
17
+ */
18
+ export function id_be(ctx, id, val_) {
19
+ return be(ctx, val_, { id })
20
+ }
21
+ /**
22
+ * @param {ctx_T}ctx
23
+ * @param {string}ns
24
+ * @param {be__val__new_T}val_
25
+ */
26
+ export function ns_be(ctx, ns, val_) {
27
+ return be(ctx, val_, { ns })
28
+ }
29
+ /**
30
+ * @param {ctx_T}ctx
31
+ * @param {string}ns
32
+ * @param {string}id
33
+ * @param {be__val__new_T}val_
34
+ */
35
+ export function ns_id_be(ctx, ns, id, val_) {
36
+ return be(ctx, val_, { ns, id })
37
+ }
@@ -1,8 +1,8 @@
1
1
  import { test } from 'uvu'
2
2
  import { equal } from 'uvu/assert'
3
- import { be_ } from '../be_/index.js'
4
- import { ctx__new } from '../ctx/index.js'
5
- import { be } from './index.js'
3
+ import { be_, id_be_, ns_be_, ns_id_be_ } from '../be_/index.js'
4
+ import { ctx__new, ns_ctx__new } from '../ctx/index.js'
5
+ import { be, id_be, ns_be, ns_id_be } from './index.js'
6
6
  test('be|s|BeMap', ()=>{
7
7
  const ctx = ctx__new()
8
8
  let incrementer_num = 0
@@ -12,10 +12,54 @@ test('be|s|BeMap', ()=>{
12
12
  { id: 'root_' })
13
13
  const child = be(ctx, ctx=>
14
14
  root_(ctx) + incrementer(),
15
- { id: 'child_' })
15
+ { id: 'child' })
16
16
  equal(root_(ctx), 1)
17
17
  equal(ctx.s[''].get('root_')![0], 1)
18
18
  equal(child, 3)
19
- equal(ctx.s[''].get('child_')![0], 3)
19
+ equal(ctx.s[''].get('child')![0], 3)
20
+ })
21
+ test('id_be|s|BeMap', ()=>{
22
+ const ctx = ctx__new()
23
+ let incrementer_num = 0
24
+ const incrementer = ()=>++incrementer_num
25
+ const root_ = id_be_(
26
+ 'root_',
27
+ ()=>incrementer())
28
+ const child = id_be(ctx, 'child', ctx=>
29
+ root_(ctx) + incrementer())
30
+ equal(root_(ctx), 1)
31
+ equal(ctx.s[''].get('root_')![0], 1)
32
+ equal(child, 3)
33
+ equal(ctx.s[''].get('child')![0], 3)
34
+ })
35
+ test('ns_be|s|BeMap', ()=>{
36
+ const ctx = ns_ctx__new('test_ns')
37
+ let incrementer_num = 0
38
+ const incrementer = ()=>++incrementer_num
39
+ const root_ = ns_be_(
40
+ 'test_ns',
41
+ ()=>incrementer())
42
+ const child = ns_be(ctx, 'test_ns', ctx=>
43
+ root_(ctx) + incrementer())
44
+ equal(root_(ctx), 1)
45
+ equal(ctx.s.test_ns.get(root_)![0], 1)
46
+ equal(child, 3)
47
+ const child_id = Array.from(ctx.s.test_ns.keys()).find(id=>id!==root_)!
48
+ equal(ctx.s.test_ns.get(child_id)![0], 3)
49
+ })
50
+ test('ns_id_be|s|BeMap', ()=>{
51
+ const ctx = ns_ctx__new('test_ns')
52
+ let incrementer_num = 0
53
+ const incrementer = ()=>++incrementer_num
54
+ const root_ = ns_id_be_(
55
+ 'test_ns',
56
+ 'root_',
57
+ ()=>incrementer())
58
+ const child = ns_id_be(ctx, 'test_ns', 'child', ctx=>
59
+ root_(ctx) + incrementer())
60
+ equal(root_(ctx), 1)
61
+ equal(ctx.s.test_ns.get('root_')![0], 1)
62
+ equal(child, 3)
63
+ equal(ctx.s.test_ns.get('child')![0], 3)
20
64
  })
21
65
  test.run()
@@ -44,13 +44,13 @@ export type memo_T<val_T, E = unknown> = (()=>val_T)&{
44
44
  add_def_a1?:rmemo_add_def_T<val_T, E>[]
45
45
  ):memo_T<_val_T, E>
46
46
  val:val_T
47
- readonly a?:rmemo_a_T
48
- readonly b:rmemo_add_def_T<val_T, E>[]
49
- readonly d:()=>val_T
50
- readonly l:number
51
- readonly r:rmemo_r_T[]
52
- readonly u:rmemo_T<unknown>[]
53
- readonly t:rmemo_T<unknown>[]
47
+ readonly a:unknown
48
+ readonly b:unknown
49
+ readonly d:unknown
50
+ readonly l:unknown
51
+ readonly r:unknown
52
+ readonly u:unknown
53
+ readonly t:unknown
54
54
  }&E
55
55
  interface _circular_memo_T extends memo_T<_circular_memo_T> {
56
56
  }
@@ -199,9 +199,9 @@ test('rmemo|add|has strong reference to the return value', ()=>{
199
199
  equal(num$.a, undefined)
200
200
  equal(add_arg_aa, [])
201
201
  equal(num$(), undefined)
202
- equal(num$.a![0], memo)
202
+ equal((<any>num$.a)![0], memo)
203
203
  equal(memo!.val, 99)
204
- equal((num$.a![0] as memo_T<number>).val, 99)
204
+ equal((<memo_T<number>>(<any>num$.a)![0]).val, 99)
205
205
  equal(add_arg_aa, [[num$, undefined]])
206
206
  })
207
207
  test('rmemo|add|notified if sig is set before read', ()=>{
@@ -1,7 +1,7 @@
1
1
  import type { nullish } from '../nullish/index.js'
2
- import type { sig_T } from '../rmemo/index.js'
2
+ import type { memo_T } from '../rmemo/index.js'
3
3
  export declare function wanimato__new<E extends Element>(
4
- $:sig_T<wanimato_T|nullish>,
4
+ $:memo_T<wanimato_T>|memo_T<wanimato_T|nullish>,
5
5
  el:E,
6
6
  animation_:(el:E)=>Animation
7
7
  ):wanimato_T
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ctx-core",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
4
4
  "description": "ctx-core core library",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -430,7 +430,7 @@
430
430
  "import": {
431
431
  "./web_animation": "{ memo_, wanimato__new }"
432
432
  },
433
- "limit": "707 B"
433
+ "limit": "706 B"
434
434
  }
435
435
  ],
436
436
  "scripts": {