aontu 0.27.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.
- package/aontu.ts +40 -29
- package/dist/aontu.d.ts +9 -6
- package/dist/aontu.js +29 -22
- package/dist/aontu.js.map +1 -1
- package/dist/lib/err.d.ts +2 -1
- package/dist/lib/err.js +9 -39
- package/dist/lib/err.js.map +1 -1
- package/dist/lib/lang.d.ts +1 -1
- package/dist/lib/lang.js +27 -9
- package/dist/lib/lang.js.map +1 -1
- package/dist/lib/op/disjunct.js.map +1 -1
- package/dist/lib/op/op.js.map +1 -1
- package/dist/lib/type.d.ts +10 -1
- package/dist/lib/type.js.map +1 -1
- package/dist/lib/unify.d.ts +3 -0
- package/dist/lib/unify.js +0 -5
- package/dist/lib/unify.js.map +1 -1
- package/dist/lib/utility.js.map +1 -1
- package/dist/lib/val/ConjunctVal.d.ts +1 -0
- package/dist/lib/val/ConjunctVal.js +5 -27
- package/dist/lib/val/ConjunctVal.js.map +1 -1
- package/dist/lib/val/DisjunctVal.d.ts +1 -0
- package/dist/lib/val/DisjunctVal.js +5 -6
- package/dist/lib/val/DisjunctVal.js.map +1 -1
- package/dist/lib/val/MapVal.js +0 -27
- package/dist/lib/val/MapVal.js.map +1 -1
- package/dist/lib/val/NullVal.js +0 -1
- package/dist/lib/val/NullVal.js.map +1 -1
- package/dist/lib/val/RefVal.js +0 -9
- package/dist/lib/val/RefVal.js.map +1 -1
- package/dist/lib/val/VarVal.js.map +1 -1
- package/dist/lib/val.js.map +1 -1
- package/lib/err.ts +12 -40
- package/lib/lang.ts +33 -12
- package/lib/op/disjunct.ts +0 -1
- package/lib/op/op.ts +0 -1
- package/lib/type.ts +13 -1
- package/lib/unify.ts +3 -19
- package/lib/utility.ts +1 -0
- package/lib/val/ConjunctVal.ts +5 -37
- package/lib/val/DisjunctVal.ts +5 -11
- package/lib/val/MapVal.ts +0 -36
- package/lib/val/NullVal.ts +0 -2
- package/lib/val/RefVal.ts +0 -18
- package/lib/val/VarVal.ts +1 -0
- package/lib/val.ts +1 -0
- package/package.json +10 -10
package/lib/lang.ts
CHANGED
|
@@ -101,8 +101,6 @@ let AontuJsonic: Plugin = function aontu(jsonic: Jsonic) {
|
|
|
101
101
|
v.url = ctx.meta.multisource ? ctx.meta.multisource.path : ''
|
|
102
102
|
v.path = r.k ? [...(r.k.path || [])] : []
|
|
103
103
|
|
|
104
|
-
// console.log('ADDSITE', v)
|
|
105
|
-
|
|
106
104
|
return v
|
|
107
105
|
}
|
|
108
106
|
|
|
@@ -208,6 +206,22 @@ let AontuJsonic: Plugin = function aontu(jsonic: Jsonic) {
|
|
|
208
206
|
return addsite(new PlusVal({ peg: [terms[0], terms[1]] }), r, ctx)
|
|
209
207
|
},
|
|
210
208
|
|
|
209
|
+
'negative-prefix': (r: Rule, ctx: Context, _op: Op, terms: any) => {
|
|
210
|
+
let val = terms[0]
|
|
211
|
+
val.peg = -1 * val.peg
|
|
212
|
+
return addsite(val, r, ctx)
|
|
213
|
+
},
|
|
214
|
+
|
|
215
|
+
'positive-prefix': (r: Rule, ctx: Context, _op: Op, terms: any) => {
|
|
216
|
+
let val = terms[0]
|
|
217
|
+
return addsite(val, r, ctx)
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
'plain-paren': (r: Rule, ctx: Context, _op: Op, terms: any) => {
|
|
221
|
+
let val = terms[0]
|
|
222
|
+
return addsite(val, r, ctx)
|
|
223
|
+
},
|
|
224
|
+
|
|
211
225
|
}
|
|
212
226
|
|
|
213
227
|
|
|
@@ -253,8 +267,16 @@ let AontuJsonic: Plugin = function aontu(jsonic: Jsonic) {
|
|
|
253
267
|
prefix: true,
|
|
254
268
|
right: 24_000_000,
|
|
255
269
|
},
|
|
270
|
+
|
|
271
|
+
addition: null,
|
|
272
|
+
subtraction: null,
|
|
273
|
+
multiplication: null,
|
|
274
|
+
division: null,
|
|
275
|
+
remainder: null,
|
|
256
276
|
},
|
|
257
277
|
evaluate: (r: Rule, ctx: Context, op: Op, terms: any) => {
|
|
278
|
+
// console.log('EVAL', op.name, terms)
|
|
279
|
+
|
|
258
280
|
let val: Val = opmap[op.name](r, ctx, op, terms)
|
|
259
281
|
return val
|
|
260
282
|
}
|
|
@@ -293,18 +315,16 @@ let AontuJsonic: Plugin = function aontu(jsonic: Jsonic) {
|
|
|
293
315
|
valnode = addsite(new NullVal({ peg: r.node }), r, ctx)
|
|
294
316
|
}
|
|
295
317
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
valnode.url = ctx.meta.multisource && ctx.meta.multisource.path
|
|
318
|
+
if (null != valnode && 'object' === typeof valnode) {
|
|
319
|
+
let st = r.o0
|
|
320
|
+
valnode.row = st.rI
|
|
321
|
+
valnode.col = st.cI
|
|
322
|
+
valnode.url = ctx.meta.multisource && ctx.meta.multisource.path
|
|
323
|
+
}
|
|
324
|
+
// else { ERROR? }
|
|
304
325
|
|
|
305
326
|
r.node = valnode
|
|
306
327
|
|
|
307
|
-
// return out
|
|
308
328
|
return undefined
|
|
309
329
|
})
|
|
310
330
|
|
|
@@ -516,9 +536,10 @@ class Lang {
|
|
|
516
536
|
}
|
|
517
537
|
|
|
518
538
|
|
|
519
|
-
parse(src: string, opts?:
|
|
539
|
+
parse(src: string, opts?: Partial<Options>): Val {
|
|
520
540
|
// JSONIC-UPDATE - check meta
|
|
521
541
|
let jm: any = {
|
|
542
|
+
fs: opts?.fs,
|
|
522
543
|
fileName: this.options.path,
|
|
523
544
|
multisource: {
|
|
524
545
|
path: this.options.path,
|
package/lib/op/disjunct.ts
CHANGED
package/lib/op/op.ts
CHANGED
package/lib/type.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* Copyright (c) 2022-2023 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
|
+
import * as Fs from 'node:fs'
|
|
3
4
|
|
|
4
5
|
// TODO: refactor these out
|
|
5
6
|
|
|
@@ -13,6 +14,8 @@ import {
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
17
|
+
type FST = typeof Fs
|
|
18
|
+
|
|
16
19
|
type Options = {
|
|
17
20
|
src: string // Source text.
|
|
18
21
|
print: number // Print debug verbosity
|
|
@@ -21,11 +24,13 @@ type Options = {
|
|
|
21
24
|
path?: string // Path of entry file
|
|
22
25
|
debug?: boolean
|
|
23
26
|
trace?: boolean
|
|
27
|
+
fs?: FST
|
|
28
|
+
deps?: any
|
|
29
|
+
log?: any
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
|
|
27
33
|
|
|
28
|
-
|
|
29
34
|
interface Val {
|
|
30
35
|
isVal: boolean
|
|
31
36
|
|
|
@@ -68,12 +73,19 @@ type ValList = Val[]
|
|
|
68
73
|
const DONE = -1
|
|
69
74
|
|
|
70
75
|
|
|
76
|
+
type ErrContext = {
|
|
77
|
+
src?: string,
|
|
78
|
+
fs?: FST
|
|
79
|
+
}
|
|
80
|
+
|
|
71
81
|
export type {
|
|
72
82
|
Val,
|
|
73
83
|
ValSpec,
|
|
74
84
|
ValMap,
|
|
75
85
|
ValList,
|
|
76
86
|
Options,
|
|
87
|
+
ErrContext,
|
|
88
|
+
FST,
|
|
77
89
|
}
|
|
78
90
|
|
|
79
91
|
export {
|
package/lib/unify.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { Val } from './type'
|
|
5
5
|
|
|
6
|
-
import { DONE, } from './type'
|
|
6
|
+
import { DONE, FST } from './type'
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
import {
|
|
@@ -19,18 +19,12 @@ import {
|
|
|
19
19
|
} from './op/op'
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// import { MapVal } from '../lib/val/MapVal'
|
|
26
|
-
// import { RefVal } from '../lib/val/RefVal'
|
|
27
22
|
import { Nil } from '../lib/val/Nil'
|
|
28
23
|
|
|
29
24
|
|
|
30
25
|
type Path = string[]
|
|
31
26
|
|
|
32
27
|
|
|
33
|
-
|
|
34
28
|
class Context {
|
|
35
29
|
root: Val // Starting Val, root of paths.
|
|
36
30
|
path: Path // Path to current Val.
|
|
@@ -38,6 +32,8 @@ class Context {
|
|
|
38
32
|
vc: number // Val counter to create unique val ids.
|
|
39
33
|
cc: number = -1
|
|
40
34
|
var: Record<string, Val> = {}
|
|
35
|
+
src?: string
|
|
36
|
+
fs?: FST
|
|
41
37
|
|
|
42
38
|
constructor(cfg: {
|
|
43
39
|
root: Val,
|
|
@@ -93,15 +89,11 @@ class Unify {
|
|
|
93
89
|
lang: Lang
|
|
94
90
|
|
|
95
91
|
constructor(root: Val | string, lang?: Lang, ctx?: Context) {
|
|
96
|
-
// console.log('ROOT-A', root)
|
|
97
|
-
|
|
98
92
|
this.lang = lang || new Lang()
|
|
99
93
|
if ('string' === typeof root) {
|
|
100
94
|
root = this.lang.parse(root)
|
|
101
95
|
}
|
|
102
96
|
|
|
103
|
-
// console.log('ROOT-B', root)
|
|
104
|
-
|
|
105
97
|
this.cc = 0
|
|
106
98
|
this.root = root
|
|
107
99
|
this.res = root
|
|
@@ -116,22 +108,14 @@ class Unify {
|
|
|
116
108
|
err: this.err,
|
|
117
109
|
})
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
// TODO: derive maxdc from res deterministically
|
|
121
|
-
// perhaps parse should count intial vals, paths, etc?
|
|
122
|
-
|
|
123
|
-
|
|
124
111
|
let maxdc = 9 // 99
|
|
125
112
|
for (; this.cc < maxdc && DONE !== res.done; this.cc++) {
|
|
126
113
|
ctx.cc = this.cc
|
|
127
114
|
res = unite(ctx, res, TOP)
|
|
128
115
|
ctx = ctx.clone({ root: res })
|
|
129
|
-
|
|
130
|
-
// console.log('==============', this.cc)
|
|
131
116
|
}
|
|
132
117
|
}
|
|
133
118
|
|
|
134
|
-
|
|
135
119
|
this.res = res
|
|
136
120
|
}
|
|
137
121
|
}
|
package/lib/utility.ts
CHANGED
package/lib/val/ConjunctVal.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { ValBase } from '../val/ValBase'
|
|
|
37
37
|
|
|
38
38
|
// TODO: move main logic to op/conjunct
|
|
39
39
|
class ConjunctVal extends ValBase {
|
|
40
|
+
isBinaryOp = true
|
|
40
41
|
isConjunctVal = true
|
|
41
42
|
|
|
42
43
|
constructor(
|
|
@@ -57,29 +58,18 @@ class ConjunctVal extends ValBase {
|
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
unify(peer: Val, ctx: Context): Val {
|
|
60
|
-
// console.log('CONJUNCT UNIFY', this.done, this.path.join('.'), this.canon,
|
|
61
|
-
// 'P', peer.top || peer.constructor.name,
|
|
62
|
-
// peer.done, peer.path.join('.'), peer.canon)
|
|
63
|
-
|
|
64
|
-
|
|
65
61
|
const mark = (Math.random() * 1e7) % 1e6 | 0
|
|
66
|
-
// console.log('CONJUNCT unify', mark, this.done, this.canon, 'peer=', peer.canon)
|
|
67
|
-
|
|
68
62
|
let done = true
|
|
69
63
|
|
|
70
64
|
// Unify each term of conjunct against peer
|
|
71
65
|
let upeer: Val[] = []
|
|
72
66
|
|
|
73
|
-
|
|
74
|
-
// console.log('CJa' + mark, this.peg.map((p: Val) => p.canon), 'p=', peer.canon)
|
|
75
67
|
for (let vI = 0; vI < this.peg.length; vI++) {
|
|
76
68
|
upeer[vI] = unite(ctx, this.peg[vI], peer, 'cj-own' + mark)
|
|
77
69
|
|
|
78
70
|
// let prevdone = done
|
|
79
71
|
done = done && (DONE === upeer[vI].done)
|
|
80
72
|
|
|
81
|
-
// console.log('CONJUNCT pud', mark, vI, done, prevdone, '|', upeer[vI].done, upeer[vI].canon)
|
|
82
|
-
|
|
83
73
|
if (upeer[vI] instanceof Nil) {
|
|
84
74
|
return Nil.make(
|
|
85
75
|
ctx,
|
|
@@ -92,15 +82,11 @@ class ConjunctVal extends ValBase {
|
|
|
92
82
|
|
|
93
83
|
upeer = norm(upeer)
|
|
94
84
|
|
|
95
|
-
// console.log('CONJUNCT upeer', this.id, mark, this.done, done, upeer.map(p => p.canon))
|
|
96
|
-
|
|
97
85
|
upeer.sort((a: Val, b: Val) => {
|
|
98
86
|
return (a.constructor.name === b.constructor.name) ? 0 :
|
|
99
87
|
(a.constructor.name < b.constructor.name ? -1 : 1)
|
|
100
88
|
})
|
|
101
89
|
|
|
102
|
-
// console.log('CONJUNCT upeer sort', this.id, mark, this.done, done, upeer.map(p => p.canon))
|
|
103
|
-
|
|
104
90
|
// Unify terms against each other
|
|
105
91
|
|
|
106
92
|
let outvals: Val[] = []
|
|
@@ -118,8 +104,6 @@ class ConjunctVal extends ValBase {
|
|
|
118
104
|
// }
|
|
119
105
|
|
|
120
106
|
|
|
121
|
-
// console.log('CJ upeer', mark, upeer.map(v => v.canon))
|
|
122
|
-
|
|
123
107
|
let t0 = upeer[0]
|
|
124
108
|
|
|
125
109
|
next_term:
|
|
@@ -141,9 +125,7 @@ class ConjunctVal extends ValBase {
|
|
|
141
125
|
)
|
|
142
126
|
) {
|
|
143
127
|
|
|
144
|
-
// console.log('CONJUNCT PUSH A', u0.id, u0.canon)
|
|
145
128
|
outvals.push(u0)
|
|
146
|
-
// console.log('CJ outvals A', outvals.map(v => v.canon))
|
|
147
129
|
continue next_term
|
|
148
130
|
}
|
|
149
131
|
else {
|
|
@@ -152,27 +134,20 @@ class ConjunctVal extends ValBase {
|
|
|
152
134
|
}
|
|
153
135
|
|
|
154
136
|
let t1 = upeer[pI + 1]
|
|
155
|
-
// console.log('CJ TERM t1', pI + 1, t1?.done, t1?.canon)
|
|
156
137
|
|
|
157
138
|
if (null == t1) {
|
|
158
|
-
// console.log('CONJUNCT PUSH B', t0.canon)
|
|
159
139
|
outvals.push(t0)
|
|
160
|
-
// console.log('CJ outvals B', outvals.map(v => v.canon))
|
|
161
140
|
}
|
|
162
141
|
|
|
163
142
|
// Can't unite with a RefVal, unless also a RefVal with same path.
|
|
164
143
|
else if (t0 instanceof RefVal && !(t1 instanceof RefVal)) {
|
|
165
|
-
// console.log('CONJUNCT PUSH D', t0.canon)
|
|
166
144
|
outvals.push(t0)
|
|
167
145
|
t0 = t1
|
|
168
|
-
// console.log('CJ outvals C', outvals.map(v => v.canon))
|
|
169
146
|
}
|
|
170
147
|
|
|
171
148
|
else if (t1 instanceof RefVal && !(t0 instanceof RefVal)) {
|
|
172
|
-
// console.log('CONJUNCT PUSH D', t0.canon)
|
|
173
149
|
outvals.push(t0)
|
|
174
150
|
t0 = t1
|
|
175
|
-
// console.log('CJ outvals C', outvals.map(v => v.canon))
|
|
176
151
|
}
|
|
177
152
|
|
|
178
153
|
|
|
@@ -182,12 +157,8 @@ class ConjunctVal extends ValBase {
|
|
|
182
157
|
|
|
183
158
|
// Unite was just a conjunt anyway, so discard.
|
|
184
159
|
if (val instanceof ConjunctVal) {
|
|
185
|
-
// if (t0.id === val.peg[0].id) {
|
|
186
|
-
// val = t0
|
|
187
160
|
outvals.push(t0)
|
|
188
161
|
t0 = t1
|
|
189
|
-
// console.log('CJ outvals D', outvals.map(v => v.canon))
|
|
190
|
-
//}
|
|
191
162
|
}
|
|
192
163
|
else if (val instanceof Nil) {
|
|
193
164
|
return val
|
|
@@ -196,15 +167,12 @@ class ConjunctVal extends ValBase {
|
|
|
196
167
|
t0 = val
|
|
197
168
|
}
|
|
198
169
|
// TODO: t0 should become this to avoid unnecessary repasses
|
|
199
|
-
// console.log('CONJUNCT PUSH C', val.canon)
|
|
200
170
|
// outvals.push(val)
|
|
201
171
|
|
|
202
172
|
// pI++
|
|
203
173
|
}
|
|
204
174
|
}
|
|
205
175
|
|
|
206
|
-
// console.log('CJ outvals', mark, outvals.map(v => v.canon))
|
|
207
|
-
|
|
208
176
|
let out: Val
|
|
209
177
|
|
|
210
178
|
if (0 === outvals.length) {
|
|
@@ -223,8 +191,6 @@ class ConjunctVal extends ValBase {
|
|
|
223
191
|
|
|
224
192
|
out.done = done ? DONE : this.done + 1
|
|
225
193
|
|
|
226
|
-
// console.log('CJ out', out.done, out.canon)
|
|
227
|
-
|
|
228
194
|
return out
|
|
229
195
|
}
|
|
230
196
|
|
|
@@ -238,8 +204,10 @@ class ConjunctVal extends ValBase {
|
|
|
238
204
|
|
|
239
205
|
// TODO: need a well-defined val order so conjunt canon is always the same
|
|
240
206
|
get canon() {
|
|
241
|
-
|
|
242
|
-
|
|
207
|
+
return this.peg.map((v: Val) => {
|
|
208
|
+
return (v as any).isBinaryOp && Array.isArray(v.peg) && 1 < v.peg.length ?
|
|
209
|
+
'(' + v.canon + ')' : v.canon
|
|
210
|
+
}).join('&')
|
|
243
211
|
}
|
|
244
212
|
|
|
245
213
|
|
package/lib/val/DisjunctVal.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { ValBase } from '../val/ValBase'
|
|
|
43
43
|
// TODO: move main logic to op/disjunct
|
|
44
44
|
class DisjunctVal extends ValBase {
|
|
45
45
|
isDisjunctVal = true
|
|
46
|
+
isBinaryOp = true
|
|
46
47
|
|
|
47
48
|
// TODO: sites from normalization of orginal Disjuncts, as well as child pegs
|
|
48
49
|
constructor(
|
|
@@ -66,19 +67,13 @@ class DisjunctVal extends ValBase {
|
|
|
66
67
|
|
|
67
68
|
let oval: Val[] = []
|
|
68
69
|
|
|
69
|
-
// console.log('oval', this.canon, peer.canon)
|
|
70
|
-
|
|
71
70
|
// Conjunction (&) distributes over disjunction (|)
|
|
72
71
|
for (let vI = 0; vI < this.peg.length; vI++) {
|
|
73
72
|
//oval[vI] = this.peg[vI].unify(peer, ctx)
|
|
74
73
|
oval[vI] = unite(ctx, this.peg[vI], peer)
|
|
75
|
-
// console.log('ovalA', vI, this.peg[vI].canon, peer.canon, oval[vI].canon)
|
|
76
|
-
|
|
77
74
|
done = done && DONE === oval[vI].done
|
|
78
75
|
}
|
|
79
76
|
|
|
80
|
-
// console.log('ovalB', oval.map(v => v.canon))
|
|
81
|
-
|
|
82
77
|
// Remove duplicates, and normalize
|
|
83
78
|
if (1 < oval.length) {
|
|
84
79
|
for (let vI = 0; vI < oval.length; vI++) {
|
|
@@ -87,8 +82,6 @@ class DisjunctVal extends ValBase {
|
|
|
87
82
|
}
|
|
88
83
|
}
|
|
89
84
|
|
|
90
|
-
//console.log('ovalC', oval.map(v => v.canon))
|
|
91
|
-
|
|
92
85
|
// TODO: not an error Nil!
|
|
93
86
|
let remove = new Nil()
|
|
94
87
|
for (let vI = 0; vI < oval.length; vI++) {
|
|
@@ -99,8 +92,6 @@ class DisjunctVal extends ValBase {
|
|
|
99
92
|
}
|
|
100
93
|
}
|
|
101
94
|
|
|
102
|
-
//console.log('ovalD', oval.map(v => v.canon))
|
|
103
|
-
|
|
104
95
|
oval = oval.filter(v => !(v instanceof Nil))
|
|
105
96
|
}
|
|
106
97
|
|
|
@@ -130,7 +121,10 @@ class DisjunctVal extends ValBase {
|
|
|
130
121
|
|
|
131
122
|
|
|
132
123
|
get canon() {
|
|
133
|
-
return this.peg.map((v: Val) =>
|
|
124
|
+
return this.peg.map((v: Val) => {
|
|
125
|
+
return (v as any).isBinaryOp && Array.isArray(v.peg) && 1 < v.peg.length ?
|
|
126
|
+
'(' + v.canon + ')' : v.canon
|
|
127
|
+
}).join('|')
|
|
134
128
|
}
|
|
135
129
|
|
|
136
130
|
|
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)
|
package/lib/val/NullVal.ts
CHANGED
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
package/lib/val.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aontu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"main": "dist/aontu.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"browser": "dist/aontu.min.js",
|
|
@@ -47,24 +47,24 @@
|
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@jsonic/directive": "^1.1.0",
|
|
50
|
-
"@jsonic/expr": "^1.
|
|
50
|
+
"@jsonic/expr": "^1.3.0",
|
|
51
51
|
"jsonic": "^2.16.0",
|
|
52
52
|
"@jsonic/multisource": "^1.9.0",
|
|
53
|
-
"@jsonic/path": "^1.
|
|
53
|
+
"@jsonic/path": "^1.4.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@types/jest": "^
|
|
57
|
-
"@types/node": "^
|
|
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.
|
|
62
|
-
"jest": "^
|
|
63
|
-
"prettier": "^3.
|
|
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.
|
|
67
|
-
"typescript": "^5.
|
|
66
|
+
"ts-jest": "^29.4.1",
|
|
67
|
+
"typescript": "^5.9.2"
|
|
68
68
|
},
|
|
69
69
|
"aliasify": {
|
|
70
70
|
"aliases": {
|