aontu 0.28.0 → 0.29.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.
Files changed (45) hide show
  1. package/aontu.ts +40 -29
  2. package/dist/aontu.d.ts +9 -6
  3. package/dist/aontu.js +29 -22
  4. package/dist/aontu.js.map +1 -1
  5. package/dist/lib/err.d.ts +2 -1
  6. package/dist/lib/err.js +9 -39
  7. package/dist/lib/err.js.map +1 -1
  8. package/dist/lib/lang.d.ts +1 -1
  9. package/dist/lib/lang.js +1 -1
  10. package/dist/lib/lang.js.map +1 -1
  11. package/dist/lib/op/disjunct.js.map +1 -1
  12. package/dist/lib/op/op.js.map +1 -1
  13. package/dist/lib/type.d.ts +10 -1
  14. package/dist/lib/type.js.map +1 -1
  15. package/dist/lib/unify.d.ts +3 -0
  16. package/dist/lib/unify.js +0 -5
  17. package/dist/lib/unify.js.map +1 -1
  18. package/dist/lib/utility.js.map +1 -1
  19. package/dist/lib/val/ConjunctVal.js +0 -25
  20. package/dist/lib/val/ConjunctVal.js.map +1 -1
  21. package/dist/lib/val/DisjunctVal.js +0 -5
  22. package/dist/lib/val/DisjunctVal.js.map +1 -1
  23. package/dist/lib/val/MapVal.js +0 -27
  24. package/dist/lib/val/MapVal.js.map +1 -1
  25. package/dist/lib/val/NullVal.js +0 -1
  26. package/dist/lib/val/NullVal.js.map +1 -1
  27. package/dist/lib/val/RefVal.js +0 -9
  28. package/dist/lib/val/RefVal.js.map +1 -1
  29. package/dist/lib/val/VarVal.js.map +1 -1
  30. package/dist/lib/val.js.map +1 -1
  31. package/lib/err.ts +12 -40
  32. package/lib/lang.ts +2 -3
  33. package/lib/op/disjunct.ts +0 -1
  34. package/lib/op/op.ts +0 -1
  35. package/lib/type.ts +13 -1
  36. package/lib/unify.ts +3 -19
  37. package/lib/utility.ts +1 -0
  38. package/lib/val/ConjunctVal.ts +0 -35
  39. package/lib/val/DisjunctVal.ts +0 -10
  40. package/lib/val/MapVal.ts +0 -36
  41. package/lib/val/NullVal.ts +0 -2
  42. package/lib/val/RefVal.ts +0 -18
  43. package/lib/val/VarVal.ts +1 -0
  44. package/lib/val.ts +1 -0
  45. package/package.json +8 -8
@@ -58,29 +58,18 @@ class ConjunctVal extends ValBase {
58
58
  }
59
59
 
60
60
  unify(peer: Val, ctx: Context): Val {
61
- // console.log('CONJUNCT UNIFY', this.done, this.path.join('.'), this.canon,
62
- // 'P', peer.top || peer.constructor.name,
63
- // peer.done, peer.path.join('.'), peer.canon)
64
-
65
-
66
61
  const mark = (Math.random() * 1e7) % 1e6 | 0
67
- // console.log('CONJUNCT unify', mark, this.done, this.canon, 'peer=', peer.canon)
68
-
69
62
  let done = true
70
63
 
71
64
  // Unify each term of conjunct against peer
72
65
  let upeer: Val[] = []
73
66
 
74
-
75
- // console.log('CJa' + mark, this.peg.map((p: Val) => p.canon), 'p=', peer.canon)
76
67
  for (let vI = 0; vI < this.peg.length; vI++) {
77
68
  upeer[vI] = unite(ctx, this.peg[vI], peer, 'cj-own' + mark)
78
69
 
79
70
  // let prevdone = done
80
71
  done = done && (DONE === upeer[vI].done)
81
72
 
82
- // console.log('CONJUNCT pud', mark, vI, done, prevdone, '|', upeer[vI].done, upeer[vI].canon)
83
-
84
73
  if (upeer[vI] instanceof Nil) {
85
74
  return Nil.make(
86
75
  ctx,
@@ -93,15 +82,11 @@ class ConjunctVal extends ValBase {
93
82
 
94
83
  upeer = norm(upeer)
95
84
 
96
- // console.log('CONJUNCT upeer', this.id, mark, this.done, done, upeer.map(p => p.canon))
97
-
98
85
  upeer.sort((a: Val, b: Val) => {
99
86
  return (a.constructor.name === b.constructor.name) ? 0 :
100
87
  (a.constructor.name < b.constructor.name ? -1 : 1)
101
88
  })
102
89
 
103
- // console.log('CONJUNCT upeer sort', this.id, mark, this.done, done, upeer.map(p => p.canon))
104
-
105
90
  // Unify terms against each other
106
91
 
107
92
  let outvals: Val[] = []
@@ -119,8 +104,6 @@ class ConjunctVal extends ValBase {
119
104
  // }
120
105
 
121
106
 
122
- // console.log('CJ upeer', mark, upeer.map(v => v.canon))
123
-
124
107
  let t0 = upeer[0]
125
108
 
126
109
  next_term:
@@ -142,9 +125,7 @@ class ConjunctVal extends ValBase {
142
125
  )
143
126
  ) {
144
127
 
145
- // console.log('CONJUNCT PUSH A', u0.id, u0.canon)
146
128
  outvals.push(u0)
147
- // console.log('CJ outvals A', outvals.map(v => v.canon))
148
129
  continue next_term
149
130
  }
150
131
  else {
@@ -153,27 +134,20 @@ class ConjunctVal extends ValBase {
153
134
  }
154
135
 
155
136
  let t1 = upeer[pI + 1]
156
- // console.log('CJ TERM t1', pI + 1, t1?.done, t1?.canon)
157
137
 
158
138
  if (null == t1) {
159
- // console.log('CONJUNCT PUSH B', t0.canon)
160
139
  outvals.push(t0)
161
- // console.log('CJ outvals B', outvals.map(v => v.canon))
162
140
  }
163
141
 
164
142
  // Can't unite with a RefVal, unless also a RefVal with same path.
165
143
  else if (t0 instanceof RefVal && !(t1 instanceof RefVal)) {
166
- // console.log('CONJUNCT PUSH D', t0.canon)
167
144
  outvals.push(t0)
168
145
  t0 = t1
169
- // console.log('CJ outvals C', outvals.map(v => v.canon))
170
146
  }
171
147
 
172
148
  else if (t1 instanceof RefVal && !(t0 instanceof RefVal)) {
173
- // console.log('CONJUNCT PUSH D', t0.canon)
174
149
  outvals.push(t0)
175
150
  t0 = t1
176
- // console.log('CJ outvals C', outvals.map(v => v.canon))
177
151
  }
178
152
 
179
153
 
@@ -183,12 +157,8 @@ class ConjunctVal extends ValBase {
183
157
 
184
158
  // Unite was just a conjunt anyway, so discard.
185
159
  if (val instanceof ConjunctVal) {
186
- // if (t0.id === val.peg[0].id) {
187
- // val = t0
188
160
  outvals.push(t0)
189
161
  t0 = t1
190
- // console.log('CJ outvals D', outvals.map(v => v.canon))
191
- //}
192
162
  }
193
163
  else if (val instanceof Nil) {
194
164
  return val
@@ -197,15 +167,12 @@ class ConjunctVal extends ValBase {
197
167
  t0 = val
198
168
  }
199
169
  // TODO: t0 should become this to avoid unnecessary repasses
200
- // console.log('CONJUNCT PUSH C', val.canon)
201
170
  // outvals.push(val)
202
171
 
203
172
  // pI++
204
173
  }
205
174
  }
206
175
 
207
- // console.log('CJ outvals', mark, outvals.map(v => v.canon))
208
-
209
176
  let out: Val
210
177
 
211
178
  if (0 === outvals.length) {
@@ -224,8 +191,6 @@ class ConjunctVal extends ValBase {
224
191
 
225
192
  out.done = done ? DONE : this.done + 1
226
193
 
227
- // console.log('CJ out', out.done, out.canon)
228
-
229
194
  return out
230
195
  }
231
196
 
@@ -67,19 +67,13 @@ class DisjunctVal extends ValBase {
67
67
 
68
68
  let oval: Val[] = []
69
69
 
70
- // console.log('oval', this.canon, peer.canon)
71
-
72
70
  // Conjunction (&) distributes over disjunction (|)
73
71
  for (let vI = 0; vI < this.peg.length; vI++) {
74
72
  //oval[vI] = this.peg[vI].unify(peer, ctx)
75
73
  oval[vI] = unite(ctx, this.peg[vI], peer)
76
- // console.log('ovalA', vI, this.peg[vI].canon, peer.canon, oval[vI].canon)
77
-
78
74
  done = done && DONE === oval[vI].done
79
75
  }
80
76
 
81
- // console.log('ovalB', oval.map(v => v.canon))
82
-
83
77
  // Remove duplicates, and normalize
84
78
  if (1 < oval.length) {
85
79
  for (let vI = 0; vI < oval.length; vI++) {
@@ -88,8 +82,6 @@ class DisjunctVal extends ValBase {
88
82
  }
89
83
  }
90
84
 
91
- //console.log('ovalC', oval.map(v => v.canon))
92
-
93
85
  // TODO: not an error Nil!
94
86
  let remove = new Nil()
95
87
  for (let vI = 0; vI < oval.length; vI++) {
@@ -100,8 +92,6 @@ class DisjunctVal extends ValBase {
100
92
  }
101
93
  }
102
94
 
103
- //console.log('ovalD', oval.map(v => v.canon))
104
-
105
95
  oval = oval.filter(v => !(v instanceof Nil))
106
96
  }
107
97
 
package/lib/val/MapVal.ts CHANGED
@@ -60,8 +60,6 @@ class MapVal extends ValBase {
60
60
 
61
61
  if (spread) {
62
62
  if ('&' === spread.o) {
63
- // console.log('MapVal.ctor', this.id, this.path.join('.'),
64
- // 'SPREAD', spread.v[0] && spread.v[0].id)
65
63
  // TODO: handle existing spread!
66
64
  this.spread.cj =
67
65
  Array.isArray(spread.v) ?
@@ -79,13 +77,6 @@ class MapVal extends ValBase {
79
77
  unify(peer: Val, ctx: Context): Val {
80
78
  // let mark = Math.random()
81
79
 
82
- // console.log(
83
- // 'MapVal.unify',
84
- // this.id, '=' + this.uh, this.path.join('.'),
85
- // (this.spread.cj ?
86
- // 'spread:' + this.spread.cj.id + ':' + this.spread.cj.path.join('.') : ''),
87
- // peer.constructor.name, peer.id, peer.path.join('.'))
88
-
89
80
  let done: boolean = true
90
81
  let out: MapVal = TOP === peer ? this : new MapVal({ peg: {} }, ctx)
91
82
 
@@ -111,18 +102,6 @@ class MapVal extends ValBase {
111
102
  let keyctx = ctx.descend(key)
112
103
  let key_spread_cj = spread_cj.clone(null, keyctx)
113
104
 
114
- // console.log('M0', this.id, mark, Object.keys(this.peg).join('~'),
115
- // 'p=', this.path.join('.'),
116
- // 'k=', key, peer.top || peer.constructor.name,
117
- // 'pp=', this.peg[key].path.join('.'),
118
- // this.peg[key].canon,
119
- // 'sp=', key_spread_cj.path.join('.'),
120
- // key_spread_cj.canon)
121
-
122
- // if (1000000000 === this.id) {
123
- // console.dir(key_spread_cj, { depth: null })
124
- // }
125
-
126
105
  out.peg[key] = unite(keyctx, this.peg[key], key_spread_cj, 'map-own')
127
106
  done = (done && DONE === out.peg[key].done)
128
107
  }
@@ -143,24 +122,9 @@ class MapVal extends ValBase {
143
122
 
144
123
  if (this.spread.cj) {
145
124
  let key_ctx = ctx.descend(peerkey)
146
- // console.log('KEY_CTX', peerkey, key_ctx)
147
-
148
125
  let key_spread_cj = spread_cj.clone(null, key_ctx)
149
-
150
- // console.log('MapVal.unify.spread', this.id, '=' + this.uh, this.path.join('.'),
151
- // key_spread_cj.id, key_spread_cj.path.join('.'))
152
-
153
-
154
- // console.log('ORIG')
155
- // console.dir(out.peg[peerkey], { depth: null })
156
- // console.log('SPREAD')
157
- // console.dir(this.spread.cj, { depth: null })
158
-
159
126
  oval = out.peg[peerkey] =
160
127
  unite(key_ctx, out.peg[peerkey], key_spread_cj)
161
-
162
- // console.log('OVAL')
163
- // console.dir(oval, { depth: null })
164
128
  }
165
129
 
166
130
  done = (done && DONE === oval.done)
@@ -34,8 +34,6 @@ class NullVal extends ValBase {
34
34
  unify(peer: Val, ctx: Context): Val {
35
35
  let out: Val
36
36
 
37
- // console.log('NULLVAL-U', peer)
38
-
39
37
  if ((peer as any).isTop || (peer as NullVal).isNullVal) {
40
38
  out = this
41
39
  }
package/lib/val/RefVal.ts CHANGED
@@ -79,7 +79,6 @@ class RefVal extends ValBase {
79
79
 
80
80
 
81
81
  append(part: any) {
82
- // console.log('APPEND', part, this)
83
82
  let partval
84
83
 
85
84
  if ('string' === typeof part) {
@@ -135,8 +134,6 @@ class RefVal extends ValBase {
135
134
  // let resolved: Val | undefined = null == ctx ? this : ctx.find(this)
136
135
  let resolved: Val | undefined = null == ctx ? this : this.find(ctx)
137
136
 
138
- // console.log('UR', this.peg, resolved)
139
-
140
137
  resolved = resolved || this
141
138
 
142
139
  if (null == resolved && this.canon === peer.canon) {
@@ -174,8 +171,6 @@ class RefVal extends ValBase {
174
171
  out.done = DONE === out.done ? DONE : this.done + 1
175
172
  }
176
173
 
177
- // console.log('RV', why, this.id, this.canon, '&', peer.canon, '->', out.canon)
178
-
179
174
  return out
180
175
  }
181
176
 
@@ -191,10 +186,6 @@ class RefVal extends ValBase {
191
186
 
192
187
  let modes: string[] = []
193
188
 
194
- // console.log('REF', this.id, this.path, this.done, 'PEG', this.peg.map((p: any) => p.canon))
195
- // console.dir(this.peg, { depth: null })
196
-
197
-
198
189
  for (let pI = 0; pI < this.peg.length; pI++) {
199
190
  let part = this.peg[pI]
200
191
  if (part instanceof VarVal) {
@@ -245,9 +236,6 @@ class RefVal extends ValBase {
245
236
  }
246
237
  }
247
238
 
248
- // console.log('modes', modes)
249
-
250
-
251
239
  if (this.absolute) {
252
240
  fullpath = parts
253
241
  }
@@ -267,9 +255,6 @@ class RefVal extends ValBase {
267
255
  .reduce(((a: string[], p: string) =>
268
256
  (p === sep ? a.length = a.length - 1 : a.push(p), a)), [])
269
257
 
270
- // console.log('REF', this.id, this.path, this.done, 'FULLPATH', fullpath)
271
-
272
-
273
258
  if (modes.includes('KEY')) {
274
259
  let key = this.path[this.path.length - 2]
275
260
  let sv = new StringVal({ peg: null == key ? '' : key }, ctx)
@@ -286,7 +271,6 @@ class RefVal extends ValBase {
286
271
  let node = ctx.root
287
272
  let pI = 0
288
273
  for (; pI < fullpath.length; pI++) {
289
- // console.log('RefVal DESCEND', pI, node)
290
274
  let part = fullpath[pI]
291
275
 
292
276
  if (node instanceof MapVal) {
@@ -297,8 +281,6 @@ class RefVal extends ValBase {
297
281
  }
298
282
  }
299
283
 
300
- // console.log('RefVal KEY', modes, pI, fullpath)
301
-
302
284
  if (pI === fullpath.length) {
303
285
  // if (this.attr && 'KEY' === this.attr.kind) {
304
286
  // if (modes.includes('KEY')) {
package/lib/val/VarVal.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  /* Copyright (c) 2021-2023 Richard Rodger, MIT License */
2
2
 
3
3
 
4
+
4
5
  /* TODO
5
6
 
6
7
  $SELF.a - path starting at self
package/lib/val.ts CHANGED
@@ -41,6 +41,7 @@ import {
41
41
  } from './lang'
42
42
 
43
43
 
44
+
44
45
  import { Nil } from './val/Nil'
45
46
  import { RefVal } from './val/RefVal'
46
47
  import { ValBase } from './val/ValBase'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aontu",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "main": "dist/aontu.js",
5
5
  "type": "commonjs",
6
6
  "browser": "dist/aontu.min.js",
@@ -53,18 +53,18 @@
53
53
  "@jsonic/path": "^1.4.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@types/jest": "^29.5.14",
57
- "@types/node": "^22.10.10",
56
+ "@types/jest": "^30.0.0",
57
+ "@types/node": "^24.3.0",
58
58
  "aliasify": "^2.1.0",
59
59
  "browserify": "^17.0.1",
60
60
  "es-jest": "^2.1.0",
61
- "esbuild": "^0.24.2",
62
- "jest": "^29.7.0",
63
- "prettier": "^3.4.2",
61
+ "esbuild": "^0.25.9",
62
+ "jest": "^30.1.3",
63
+ "prettier": "^3.6.2",
64
64
  "serve": "^14.2.4",
65
65
  "tinyify": "^4.0.0",
66
- "ts-jest": "^29.2.5",
67
- "typescript": "^5.7.3"
66
+ "ts-jest": "^29.4.1",
67
+ "typescript": "^5.9.2"
68
68
  },
69
69
  "aliasify": {
70
70
  "aliases": {