aontu 0.21.1 → 0.23.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 +1 -12
- package/dist/aontu.js +3 -13
- package/dist/aontu.js.map +1 -1
- package/dist/aontu.min.js +64 -1
- package/dist/aontu.min.js.tmp-browserify-24272745041996834914 +0 -0
- package/dist/lib/err.js +3 -3
- package/dist/lib/err.js.map +1 -1
- package/dist/lib/lang.js +25 -10
- package/dist/lib/lang.js.map +1 -1
- package/dist/lib/type.d.ts +1 -0
- package/dist/lib/type.js.map +1 -1
- package/dist/lib/unify.js +1 -0
- package/dist/lib/unify.js.map +1 -1
- package/dist/lib/utility.js +1 -2
- package/dist/lib/utility.js.map +1 -1
- package/dist/lib/val/ConjunctVal.js +2 -2
- package/dist/lib/val/ConjunctVal.js.map +1 -1
- package/dist/lib/val/MapVal.js +18 -9
- package/dist/lib/val/MapVal.js.map +1 -1
- package/dist/lib/val/OpVal.d.ts +17 -0
- package/dist/lib/val/OpVal.js +89 -0
- package/dist/lib/val/OpVal.js.map +1 -0
- package/dist/lib/val/PlusVal.d.ts +12 -0
- package/dist/lib/val/PlusVal.js +32 -0
- package/dist/lib/val/PlusVal.js.map +1 -0
- package/dist/lib/val/RefVal.js +23 -15
- package/dist/lib/val/RefVal.js.map +1 -1
- package/dist/lib/val/ValBase.d.ts +1 -0
- package/dist/lib/val/ValBase.js +13 -6
- package/dist/lib/val/ValBase.js.map +1 -1
- package/lib/err.ts +3 -1
- package/lib/lang.ts +33 -7
- package/lib/type.ts +1 -0
- package/lib/unify.ts +2 -0
- package/lib/val/MapVal.ts +26 -12
- package/lib/val/OpVal.ts +159 -0
- package/lib/val/OpVal.ts~ +158 -0
- package/lib/val/PlusVal.ts +76 -0
- package/lib/val/PlusVal.ts~ +158 -0
- package/lib/val/RefVal.ts +33 -17
- package/lib/val/ValBase.ts +16 -5
- package/package.json +11 -11
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Richard Rodger, MIT License */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
Val,
|
|
6
|
+
ValSpec,
|
|
7
|
+
} from '../type'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
DONE,
|
|
11
|
+
} from '../type'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
descErr
|
|
15
|
+
} from '../err'
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Context,
|
|
19
|
+
} from '../unify'
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
unite
|
|
23
|
+
} from '../op/op'
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
import { TOP, IntegerVal, NumberVal, StringVal } from '../val'
|
|
27
|
+
import { Nil } from '../val/Nil'
|
|
28
|
+
import { OpVal } from '../val/OpVal'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class PlusVal extends OpVal {
|
|
35
|
+
isOpVal = true
|
|
36
|
+
|
|
37
|
+
constructor(
|
|
38
|
+
spec: {
|
|
39
|
+
peg: any[],
|
|
40
|
+
},
|
|
41
|
+
ctx?: Context
|
|
42
|
+
) {
|
|
43
|
+
super(spec, ctx)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
operate(ctx: Context) {
|
|
48
|
+
super.operate(ctx)
|
|
49
|
+
|
|
50
|
+
if (this.peg.find((v: any) => v.isRefVal)) {
|
|
51
|
+
return undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let peg = this.peg[0].peg + this.peg[1].peg
|
|
55
|
+
let pegtype = typeof peg
|
|
56
|
+
if ('string' === pegtype) {
|
|
57
|
+
return new StringVal({ peg })
|
|
58
|
+
}
|
|
59
|
+
else if ('number' === pegtype) {
|
|
60
|
+
return Number.isInteger(peg) ? new IntegerVal({ peg }) : new NumberVal({ peg })
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return undefined
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
get canon() {
|
|
68
|
+
return this.peg[0].canon + '+' + this.peg[1].canon
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
PlusVal,
|
|
76
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/* Copyright (c) 2024 Richard Rodger, MIT License */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
Val,
|
|
6
|
+
ValSpec,
|
|
7
|
+
} from '../type'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
DONE,
|
|
11
|
+
} from '../type'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
descErr
|
|
15
|
+
} from '../err'
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
Context,
|
|
19
|
+
} from '../unify'
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
unite
|
|
23
|
+
} from '../op/op'
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
TOP,
|
|
27
|
+
StringVal,
|
|
28
|
+
} from '../val'
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
import { ConjunctVal } from '../val/ConjunctVal'
|
|
32
|
+
import { MapVal } from '../val/MapVal'
|
|
33
|
+
import { Nil } from '../val/Nil'
|
|
34
|
+
import { VarVal } from '../val/VarVal'
|
|
35
|
+
import { ValBase } from '../val/ValBase'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class OpVal extends ValBase {
|
|
42
|
+
isOpVal = true
|
|
43
|
+
|
|
44
|
+
constructor(
|
|
45
|
+
spec: {
|
|
46
|
+
peg: any[],
|
|
47
|
+
},
|
|
48
|
+
ctx?: Context
|
|
49
|
+
) {
|
|
50
|
+
super(spec, ctx)
|
|
51
|
+
this.peg = []
|
|
52
|
+
|
|
53
|
+
for (let pI = 0; pI < spec.peg.length; pI++) {
|
|
54
|
+
this.append(spec.peg[pI])
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
append(part: any) {
|
|
60
|
+
this.peg.push(part)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
unify(peer: Val, ctx: Context): Val {
|
|
65
|
+
let out: Val = this
|
|
66
|
+
|
|
67
|
+
if (this.id !== peer.id) {
|
|
68
|
+
let result: Val | undefined = null == ctx ? this : this.operate(ctx)
|
|
69
|
+
|
|
70
|
+
result = result || this
|
|
71
|
+
|
|
72
|
+
if (null == result && this.canon === peer.canon) {
|
|
73
|
+
out = this
|
|
74
|
+
}
|
|
75
|
+
else if (result instanceof OpVal) {
|
|
76
|
+
if (TOP === peer) {
|
|
77
|
+
out = this
|
|
78
|
+
}
|
|
79
|
+
else if (peer instanceof Nil) {
|
|
80
|
+
out = Nil.make(ctx, 'op[' + this.peg + ']', this, peer)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
else if (this.canon === peer.canon) {
|
|
84
|
+
out = this
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
else {
|
|
88
|
+
this.done = DONE === this.done ? DONE : this.done + 1
|
|
89
|
+
out = new ConjunctVal({ peg: [this, peer] }, ctx)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
out = unite(ctx, result, peer, 'op')
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
out.done = DONE === out.done ? DONE : this.done + 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return out
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
same(peer: Val): boolean {
|
|
104
|
+
return null == peer ? false : this.peg === peer.peg
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
clone(spec?: ValSpec, ctx?: Context): Val {
|
|
109
|
+
let out = (super.clone({
|
|
110
|
+
peg: this.peg,
|
|
111
|
+
}, ctx) as OpVal)
|
|
112
|
+
return out
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
operate(_ctx: Context) {
|
|
117
|
+
return undefined
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
get canon() {
|
|
123
|
+
return ''
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
gen(ctx?: Context) {
|
|
128
|
+
// Unresolved ref cannot be generated, so always an error.
|
|
129
|
+
let nil = Nil.make(
|
|
130
|
+
ctx,
|
|
131
|
+
'ref',
|
|
132
|
+
this, // (formatPath(this.peg, this.absolute) as any),
|
|
133
|
+
undefined
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
// TODO: refactor to use Site
|
|
137
|
+
nil.path = this.path
|
|
138
|
+
nil.url = this.url
|
|
139
|
+
nil.row = this.row
|
|
140
|
+
nil.col = this.col
|
|
141
|
+
|
|
142
|
+
descErr(nil)
|
|
143
|
+
|
|
144
|
+
if (ctx) {
|
|
145
|
+
ctx.err.push(nil)
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(nil.msg)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return undefined
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
export {
|
|
157
|
+
OpVal,
|
|
158
|
+
}
|
package/lib/val/RefVal.ts
CHANGED
|
@@ -41,8 +41,6 @@ import {
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
import { ConjunctVal } from '../val/ConjunctVal'
|
|
44
|
-
// import { DisjunctVal } from '../val/DisjunctVal'
|
|
45
|
-
// import { ListVal } from '../val/ListVal'
|
|
46
44
|
import { MapVal } from '../val/MapVal'
|
|
47
45
|
import { Nil } from '../val/Nil'
|
|
48
46
|
import { VarVal } from '../val/VarVal'
|
|
@@ -193,7 +191,9 @@ class RefVal extends ValBase {
|
|
|
193
191
|
|
|
194
192
|
let modes: string[] = []
|
|
195
193
|
|
|
196
|
-
// console.log('
|
|
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
197
|
|
|
198
198
|
for (let pI = 0; pI < this.peg.length; pI++) {
|
|
199
199
|
let part = this.peg[pI]
|
|
@@ -267,6 +267,22 @@ class RefVal extends ValBase {
|
|
|
267
267
|
.reduce(((a: string[], p: string) =>
|
|
268
268
|
(p === sep ? a.length = a.length - 1 : a.push(p), a)), [])
|
|
269
269
|
|
|
270
|
+
// console.log('REF', this.id, this.path, this.done, 'FULLPATH', fullpath)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
if (modes.includes('KEY')) {
|
|
274
|
+
let key = this.path[this.path.length - 2]
|
|
275
|
+
let sv = new StringVal({ peg: null == key ? '' : key }, ctx)
|
|
276
|
+
|
|
277
|
+
// TODO: other props?
|
|
278
|
+
sv.done = DONE
|
|
279
|
+
sv.path = this.path
|
|
280
|
+
|
|
281
|
+
return sv
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
|
|
270
286
|
let node = ctx.root
|
|
271
287
|
let pI = 0
|
|
272
288
|
for (; pI < fullpath.length; pI++) {
|
|
@@ -285,20 +301,20 @@ class RefVal extends ValBase {
|
|
|
285
301
|
|
|
286
302
|
if (pI === fullpath.length) {
|
|
287
303
|
// if (this.attr && 'KEY' === this.attr.kind) {
|
|
288
|
-
if (modes.includes('KEY')) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
304
|
+
// if (modes.includes('KEY')) {
|
|
305
|
+
// let key = fullpath[fullpath.length - 1]
|
|
306
|
+
// let sv = new StringVal({ peg: null == key ? '' : key }, ctx)
|
|
307
|
+
|
|
308
|
+
// // TODO: other props?
|
|
309
|
+
// sv.done = DONE
|
|
310
|
+
// sv.path = this.path
|
|
311
|
+
|
|
312
|
+
// return sv
|
|
313
|
+
// }
|
|
314
|
+
// else {
|
|
315
|
+
// console.log('REF', this.id, this.path, this.done, 'FOUND', node.canon)
|
|
316
|
+
return node
|
|
317
|
+
// }
|
|
302
318
|
}
|
|
303
319
|
}
|
|
304
320
|
|
package/lib/val/ValBase.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* Copyright (c) 2021-
|
|
1
|
+
/* Copyright (c) 2021-2024 Richard Rodger, MIT License */
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from '../lang'
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
let ID = 0
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
class ValBase implements Val {
|
|
@@ -39,11 +40,15 @@ class ValBase implements Val {
|
|
|
39
40
|
err: any[] = []
|
|
40
41
|
// deps?: any
|
|
41
42
|
|
|
43
|
+
uh: number[]
|
|
44
|
+
|
|
42
45
|
|
|
43
46
|
constructor(spec: ValSpec, ctx?: Context) {
|
|
44
47
|
this.peg = spec?.peg
|
|
45
48
|
this.path = ctx?.path || []
|
|
46
|
-
this.id = (9e9 + Math.floor(Math.random() * (1e9)))
|
|
49
|
+
// this.id = (9e9 + Math.floor(Math.random() * (1e9)))
|
|
50
|
+
this.id = ++ID // (9e9 + Math.floor(Math.random() * (1e5)))
|
|
51
|
+
this.uh = []
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
|
|
@@ -53,9 +58,15 @@ class ValBase implements Val {
|
|
|
53
58
|
|
|
54
59
|
|
|
55
60
|
clone(spec?: ValSpec, ctx?: Context): Val {
|
|
56
|
-
let cloneCtx
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
let cloneCtx
|
|
62
|
+
|
|
63
|
+
if (ctx) {
|
|
64
|
+
let cut = this.path.indexOf('&')
|
|
65
|
+
cut = -1 < cut ? cut + 1 : ctx.path.length
|
|
66
|
+
cloneCtx = ctx.clone({
|
|
67
|
+
path: ctx.path.concat(this.path.slice(cut))
|
|
68
|
+
})
|
|
69
|
+
}
|
|
59
70
|
|
|
60
71
|
let out = new (this as any)
|
|
61
72
|
.constructor(spec || { peg: this.peg }, cloneCtx)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aontu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"main": "dist/aontu.js",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"browser": "dist/aontu.min.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"version": "node -r fs -e \"v=require('./package.json').version;s=fs.readFileSync('./aontu.ts').toString();if(!s.includes('VERSION = \\''+v+'\\'')){s=s.replace(/VERSION = '.*?'/,'VERSION = \\''+v+'\\'');fs.writeFileSync('./aontu.ts',s)}\"",
|
|
33
33
|
"repo-tag": "REPO_VERSION=`node -e \"console.log(require('./package').version)\"` && echo TAG: v$REPO_VERSION && git commit -a -m v$REPO_VERSION && git push && git tag v$REPO_VERSION && git push --tags;",
|
|
34
34
|
"repo-publish": "npm run clean && npm i && npm run repo-publish-quick",
|
|
35
|
-
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run
|
|
35
|
+
"repo-publish-quick": "npm run prettier && npm run build && npm run test && npm run repo-tag && npm publish --registry https://registry.npmjs.org "
|
|
36
36
|
},
|
|
37
37
|
"license": "MIT",
|
|
38
38
|
"engines": {
|
|
@@ -49,22 +49,22 @@
|
|
|
49
49
|
"@jsonic/directive": "^0.11.4",
|
|
50
50
|
"@jsonic/expr": "^0.8.3",
|
|
51
51
|
"@jsonic/jsonic-next": "^2.12.1",
|
|
52
|
-
"@jsonic/multisource": "^1.
|
|
52
|
+
"@jsonic/multisource": "^1.3.0",
|
|
53
53
|
"@jsonic/path": "^0.7.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@types/jest": "^29.5.
|
|
57
|
-
"@types/node": "^
|
|
56
|
+
"@types/jest": "^29.5.13",
|
|
57
|
+
"@types/node": "^22.7.8",
|
|
58
58
|
"aliasify": "^2.1.0",
|
|
59
|
-
"browserify": "^17.0.
|
|
59
|
+
"browserify": "^17.0.1",
|
|
60
60
|
"es-jest": "^2.1.0",
|
|
61
|
-
"esbuild": "^0.
|
|
61
|
+
"esbuild": "^0.24.0",
|
|
62
62
|
"jest": "^29.7.0",
|
|
63
|
-
"prettier": "^3.
|
|
64
|
-
"serve": "^14.2.
|
|
63
|
+
"prettier": "^3.3.3",
|
|
64
|
+
"serve": "^14.2.4",
|
|
65
65
|
"tinyify": "^4.0.0",
|
|
66
|
-
"ts-jest": "^29.
|
|
67
|
-
"typescript": "^5.
|
|
66
|
+
"ts-jest": "^29.2.5",
|
|
67
|
+
"typescript": "^5.6.3"
|
|
68
68
|
},
|
|
69
69
|
"aliasify": {
|
|
70
70
|
"aliases": {
|