tpmkms_4wp 9.5.1 → 9.6.0-beta.1
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/common/animals.instance.json +151 -61
- package/common/animals.js +3 -5
- package/common/asking.js +116 -106
- package/common/avatar.test.json +1001 -860
- package/common/can.instance.json +2194 -0
- package/common/can.js +251 -0
- package/common/can.test.json +51307 -0
- package/common/characters.js +5 -5
- package/common/colors.instance.json +152 -12
- package/common/colors.js +3 -6
- package/common/comparable.instance.json +33 -3
- package/common/comparable.js +3 -6
- package/common/concept.js +25 -27
- package/common/concept.test.json +180 -144
- package/common/conjunction.js +13 -5
- package/common/conjunction.test.json +32 -42
- package/common/crew.instance.json +433 -173
- package/common/crew.js +4 -7
- package/common/crew.test.json +4148 -3324
- package/common/currency.js +1 -1
- package/common/dateTimeSelectors.instance.json +2 -2
- package/common/dateTimeSelectors.js +6 -9
- package/common/dateTimeSelectors.test.json +76935 -35739
- package/common/dates.instance.json +53 -3
- package/common/dates.js +3 -6
- package/common/dates.test.json +284 -287
- package/common/dialogues.js +43 -122
- package/common/dialogues.test.json +1248 -1152
- package/common/dimension.instance.json +21493 -561
- package/common/dimension.js +150 -55
- package/common/dimension.test.json +10979 -4625
- package/common/drone.instance.json +24709 -0
- package/common/drone.js +662 -0
- package/common/drone.test.json +30522 -0
- package/common/drone_v1.instance.json +24703 -0
- package/common/drone_v1.js +596 -0
- package/common/drone_v1.test.json +115538 -0
- package/common/edible.instance.json +388 -32
- package/common/edible.js +3 -5
- package/common/emotions.instance.json +85 -76
- package/common/emotions.js +4 -7
- package/common/emotions.test.json +242 -174
- package/common/english_helpers.js +336 -0
- package/common/errors.js +6 -6
- package/common/evaluate.js +2 -2
- package/common/events.js +8 -8
- package/common/fastfood.instance.json +1071 -393
- package/common/fastfood.js +14 -16
- package/common/fastfood.test.json +6970 -6829
- package/common/formulas.instance.json +11 -1
- package/common/formulas.js +3 -2
- package/common/gdefaults.js +111 -17
- package/common/help.js +12 -12
- package/common/help.test.json +65 -11
- package/common/helpers/concept.js +1 -1
- package/common/helpers/conjunction.js +54 -44
- package/common/helpers/dateTimeSelectors.js +2 -2
- package/common/helpers/dialogues.js +10 -2
- package/common/helpers/formulas.js +13 -11
- package/common/helpers/menus.js +12 -12
- package/common/helpers/meta.js +9 -9
- package/common/helpers/properties.js +186 -64
- package/common/helpers.js +167 -48
- package/common/hierarchy.js +12 -10
- package/common/kirk.instance.json +11 -1
- package/common/kirk.js +4 -6
- package/common/kirk.test.json +600 -424
- package/common/latin.instance.json +12 -12
- package/common/latin.js +12 -14
- package/common/length.instance.json +34660 -3158
- package/common/length.js +11 -6
- package/common/length.test.json +54357 -2557
- package/common/math.instance.json +39 -29
- package/common/math.js +49 -47
- package/common/menus.instance.json +77 -10
- package/common/menus.js +4 -13
- package/common/meta.js +80 -65
- package/common/nameable.js +36 -22
- package/common/nameable.test.json +436 -0
- package/common/numbers.js +1 -1
- package/common/ordering.instance.json +107 -19
- package/common/ordering.js +4 -6
- package/common/ordering.test.json +835 -417
- package/common/people.instance.json +176 -348
- package/common/people.js +9 -9
- package/common/people.test.json +4135 -3606
- package/common/pipboy.instance.json +187 -17
- package/common/pipboy.js +4 -4
- package/common/pokemon.instance.json +143 -13
- package/common/pokemon.js +4 -6
- package/common/pressure.instance.json +3610 -1601
- package/common/pressure.js +3 -5
- package/common/pressure.test.json +433 -477
- package/common/properties.instance.json +16 -17
- package/common/properties.js +32 -13
- package/common/properties.test.json +9565 -6951
- package/common/rates.instance.json +59 -0
- package/common/rates.js +95 -0
- package/common/rates.test.json +27702 -0
- package/common/reminders.instance.json +4 -4
- package/common/reminders.js +8 -11
- package/common/reminders.test.json +64635 -25787
- package/common/reports.instance.json +23 -3
- package/common/reports.js +21 -21
- package/common/scorekeeper.js +9 -12
- package/common/sdefaults.js +22 -2
- package/common/spock.instance.json +11 -1
- package/common/spock.js +4 -7
- package/common/spock.test.json +606 -430
- package/common/stgame.js +1 -1
- package/common/stm.js +41 -24
- package/common/tell.js +1 -1
- package/common/temperature.instance.json +3163 -1154
- package/common/temperature.js +3 -5
- package/common/temperature.test.json +433 -477
- package/common/tester.js +3 -3
- package/common/time.instance.json +24852 -0
- package/common/time.js +138 -141
- package/common/time.test.json +31876 -3757
- package/common/tokenize.js +5 -2
- package/common/ui.instance.json +12 -5
- package/common/ui.js +4 -13
- package/common/weight.instance.json +10501 -4099
- package/common/weight.js +3 -5
- package/common/weight.test.json +2601 -2263
- package/common/words.instance.json +9 -0
- package/common/words.js +50 -0
- package/common/words.test.json +2 -0
- package/common/wp.instance.json +548 -8
- package/common/wp.js +10 -8
- package/common/wp.test.json +7385 -6906
- package/main.js +6 -2
- package/package.json +25 -6
- package/common/listener.js +0 -50
- package/common/listener.test.json +0 -142
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
const { propertyToArray } = require('../helpers.js')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
if (context
|
|
3
|
+
function asList(context) {
|
|
4
|
+
if (Array.isArray(context)) {
|
|
5
|
+
return {
|
|
6
|
+
marker: 'list',
|
|
7
|
+
// types: [context.marker],
|
|
8
|
+
value: context
|
|
9
|
+
}
|
|
10
|
+
} else if (context.marker === 'list') {
|
|
5
11
|
return context
|
|
6
12
|
}
|
|
7
13
|
return {
|
|
@@ -11,60 +17,64 @@ const asList = (context) => {
|
|
|
11
17
|
}
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
function listable(hierarchy) {
|
|
21
|
+
return (c, type) => {
|
|
22
|
+
if (!c) {
|
|
23
|
+
return false
|
|
24
|
+
}
|
|
25
|
+
if (hierarchy.isA(c.marker, type)) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
if (c.marker === 'list') {
|
|
29
|
+
for (const t of c.types) {
|
|
30
|
+
if (hierarchy.isA(t, type)) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
|
-
}
|
|
28
|
-
return false
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const isA = (hierarchy) => (child, parent, { strict=false } = {}) => {
|
|
32
|
-
if (!child || !parent) {
|
|
33
35
|
return false
|
|
34
36
|
}
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if (parent.marker) {
|
|
41
|
-
parent = parent.marker
|
|
39
|
+
function isA(hierarchy) {
|
|
40
|
+
return (child, parent, { strict=false } = {}) => {
|
|
41
|
+
if (!child || !parent) {
|
|
42
|
+
return false
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
|
|
45
|
+
if (strict) {
|
|
46
|
+
if (child.marker) {
|
|
47
|
+
child = child.marker
|
|
48
|
+
}
|
|
49
|
+
if (parent.marker) {
|
|
50
|
+
parent = parent.marker
|
|
51
|
+
}
|
|
52
|
+
return hierarchy.isA(child, parent)
|
|
53
|
+
} else {
|
|
54
|
+
const children = propertyToArray(child)
|
|
55
|
+
for (const child of children) {
|
|
56
|
+
let okay = false
|
|
57
|
+
if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
|
|
58
|
+
okay = true
|
|
59
|
+
} else {
|
|
60
|
+
for (const childT of child.types || [child]) {
|
|
61
|
+
if (okay) {
|
|
58
62
|
break
|
|
59
63
|
}
|
|
64
|
+
for (const parentT of parent.types || [parent]) {
|
|
65
|
+
if (hierarchy.isA(childT, parentT)) {
|
|
66
|
+
okay = true
|
|
67
|
+
break
|
|
68
|
+
}
|
|
69
|
+
}
|
|
60
70
|
}
|
|
61
71
|
}
|
|
72
|
+
if (!okay) {
|
|
73
|
+
return false
|
|
74
|
+
}
|
|
62
75
|
}
|
|
63
|
-
|
|
64
|
-
return false
|
|
65
|
-
}
|
|
76
|
+
return true
|
|
66
77
|
}
|
|
67
|
-
return true
|
|
68
78
|
}
|
|
69
79
|
}
|
|
70
80
|
|
|
@@ -86,8 +86,8 @@ function getTime(time) {
|
|
|
86
86
|
return { hour, minute, second }
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
instantiate
|
|
90
|
-
|
|
89
|
+
function instantiate(isA, now, context) {
|
|
90
|
+
function getType(context, type) {
|
|
91
91
|
if (context.marker == 'onDate_dates' && context.date?.marker == type) {
|
|
92
92
|
return context.date
|
|
93
93
|
} if (context.marker == type) {
|
|
@@ -83,16 +83,24 @@ class API {
|
|
|
83
83
|
}
|
|
84
84
|
const { word, value, number } = context;
|
|
85
85
|
if (!value) {
|
|
86
|
+
if (config.exists(context.marker)) {
|
|
87
|
+
return context.marker
|
|
88
|
+
}
|
|
86
89
|
return
|
|
87
90
|
}
|
|
88
91
|
// const concept = pluralize.singular(value)
|
|
89
|
-
|
|
92
|
+
let concept = this.toScopedId(context)
|
|
93
|
+
const extraTypes = []
|
|
94
|
+
if (concept == 'unit' && context.objects) {
|
|
95
|
+
concept = context.objects.map((c) => this.toScopedId(c)).join("_")
|
|
96
|
+
types.push(this.toScopedId(context.objects[0]))
|
|
97
|
+
}
|
|
90
98
|
if (config.exists(concept)) {
|
|
91
99
|
return concept
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
// TODO handle the general case
|
|
95
|
-
|
|
103
|
+
function fixUps(concept) {
|
|
96
104
|
if (concept == '*') {
|
|
97
105
|
return '\\*'
|
|
98
106
|
}
|
|
@@ -13,7 +13,7 @@ function getVariables(expression, isVariable = (expression) => typeof expression
|
|
|
13
13
|
return []
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
function match(values, head, value) {
|
|
17
17
|
for (const prop in head) {
|
|
18
18
|
if (head[prop] instanceof Function) {
|
|
19
19
|
if (!head[prop](value[prop])) {
|
|
@@ -33,22 +33,24 @@ const match = (values, head, value) => {
|
|
|
33
33
|
return true
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
function unify(rule, value) {
|
|
37
37
|
const values = { ...rule.values }
|
|
38
38
|
if (match(values, rule.head(values), value)) {
|
|
39
39
|
return rule.body(values)
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
function f(values, variable) {
|
|
44
|
+
return (value) => {
|
|
45
|
+
if (!value) {
|
|
46
|
+
throw new Error("Value not present")
|
|
47
|
+
}
|
|
48
|
+
if (values[variable] && values[variable] != value) {
|
|
49
|
+
throw new Error("Variable already set to different value")
|
|
50
|
+
}
|
|
51
|
+
values[variable] = value
|
|
52
|
+
return true
|
|
49
53
|
}
|
|
50
|
-
values[variable] = value
|
|
51
|
-
return true
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
const rules = [
|
|
@@ -74,7 +76,7 @@ const rules = [
|
|
|
74
76
|
]
|
|
75
77
|
|
|
76
78
|
function solveFor(expression, variable, isVariable = (expression) => typeof expression.value != 'number') {
|
|
77
|
-
|
|
79
|
+
function sameVar(c1, c2) {
|
|
78
80
|
return c1.value == c2.value
|
|
79
81
|
}
|
|
80
82
|
|
package/common/helpers/menus.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
function calculateLefts(defs) {
|
|
2
2
|
const lefts = {}
|
|
3
3
|
calculateLeftsHelper(defs, lefts)
|
|
4
4
|
return lefts
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function calculateLeftsHelper(defs, lefts) {
|
|
8
8
|
if (Array.isArray(defs)) {
|
|
9
9
|
let previous
|
|
10
10
|
for (const def of defs) {
|
|
@@ -19,13 +19,13 @@ const calculateLeftsHelper = (defs, lefts) => {
|
|
|
19
19
|
return lefts
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function calculateRights(defs) {
|
|
23
23
|
const rights = {}
|
|
24
24
|
calculateRightsHelper(defs, rights)
|
|
25
25
|
return rights
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
function calculateRightsHelper(defs, rights) {
|
|
29
29
|
if (Array.isArray(defs)) {
|
|
30
30
|
let previous
|
|
31
31
|
for (const def of defs) {
|
|
@@ -40,13 +40,13 @@ const calculateRightsHelper = (defs, rights) => {
|
|
|
40
40
|
return rights
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
function calculateDowns(defs) {
|
|
44
44
|
const downs = {}
|
|
45
45
|
calculateDownsHelper(defs, downs)
|
|
46
46
|
return downs
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
function calculateDownsHelper(defs, downs) {
|
|
50
50
|
if (Array.isArray(defs)) {
|
|
51
51
|
for (const def of defs) {
|
|
52
52
|
calculateDownsHelper(def, downs)
|
|
@@ -72,13 +72,13 @@ const calculateDownsHelper = (defs, downs) => {
|
|
|
72
72
|
return downs
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
function calculateUps(defs) {
|
|
76
76
|
const ups = {}
|
|
77
77
|
calculateUpsHelper(defs, ups)
|
|
78
78
|
return ups
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
function calculateUpsHelper(defs, ups) {
|
|
82
82
|
if (Array.isArray(defs)) {
|
|
83
83
|
for (const def of defs) {
|
|
84
84
|
calculateUpsHelper(def, ups)
|
|
@@ -100,13 +100,13 @@ const calculateUpsHelper = (defs, ups) => {
|
|
|
100
100
|
return ups
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
function calculateParents(defs) {
|
|
104
104
|
const parents = {}
|
|
105
105
|
calculateParentsHelper(defs, parents)
|
|
106
106
|
return parents
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
function calculateParentsHelper(defs, parents) {
|
|
110
110
|
if (Array.isArray(defs)) {
|
|
111
111
|
for (const def of defs) {
|
|
112
112
|
parents[def.key] = def.key
|
|
@@ -123,13 +123,13 @@ const calculateParentsHelper = (defs, parents) => {
|
|
|
123
123
|
return parents
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
function calculatePaths(defs) {
|
|
127
127
|
const paths = {}
|
|
128
128
|
calculatePathsHelper(defs, paths)
|
|
129
129
|
return paths
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
function calculatePathsHelper(defs, paths) {
|
|
133
133
|
if (Array.isArray(defs)) {
|
|
134
134
|
for (const def of defs) {
|
|
135
135
|
calculatePathsHelper(def, paths)
|
package/common/helpers/meta.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = require('lodash')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function hashIndexesGet(hash, indexes) {
|
|
4
4
|
let value = hash
|
|
5
5
|
for (const i of indexes) {
|
|
6
6
|
value = value[i]
|
|
@@ -8,7 +8,7 @@ const hashIndexesGet = (hash, indexes) => {
|
|
|
8
8
|
return value
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
function hashIndexesSet(hash, indexes, value) {
|
|
12
12
|
let currentValue = hash
|
|
13
13
|
for (const i of indexes.slice(0, -1)) {
|
|
14
14
|
if (!currentValue[i]) {
|
|
@@ -19,7 +19,7 @@ const hashIndexesSet = (hash, indexes, value) => {
|
|
|
19
19
|
currentValue[indexes[indexes.length-1]] = value
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
function isPrefix(prefix, fix) {
|
|
23
23
|
return prefix.every((element, index) => {
|
|
24
24
|
return prefix[index] === fix[index]
|
|
25
25
|
})
|
|
@@ -27,11 +27,11 @@ const isPrefix = (prefix, fix) => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// assumes isPrefix is true
|
|
30
|
-
|
|
30
|
+
function replacePrefix(prefix, prefixPrime, fix) {
|
|
31
31
|
return prefixPrime.concat(fix.slice(prefix.length))
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
function compose(m1s, m2s) {
|
|
35
35
|
return m2s.map( (m2) => {
|
|
36
36
|
m1 = m1s.find( (m1) => isPrefix(m1.from, m2.from) )
|
|
37
37
|
if (m1) {
|
|
@@ -48,7 +48,7 @@ const compose = (m1s, m2s) => {
|
|
|
48
48
|
'[{"from":["two"],"to":["owner"]},{"from":["one"],"to":["ownee"]},{"from":["number"],"to":["number"]}]'
|
|
49
49
|
*/
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
function translationMapping(from, to) {
|
|
52
52
|
const mappings = []
|
|
53
53
|
if (from.atomic) {
|
|
54
54
|
return mappings
|
|
@@ -65,7 +65,7 @@ const translationMapping = (from, to) => {
|
|
|
65
65
|
if (matchField) {
|
|
66
66
|
let found = false
|
|
67
67
|
const todo = Object.keys(to).map( (key) => [key] )
|
|
68
|
-
while (!found) {
|
|
68
|
+
while (!found && todo.length > 0) {
|
|
69
69
|
const tkey = todo.shift()
|
|
70
70
|
const tvalue = hashIndexesGet(to, tkey);
|
|
71
71
|
const fvalue = hashIndexesGet(from, [fkey]);
|
|
@@ -89,7 +89,7 @@ const translationMapping = (from, to) => {
|
|
|
89
89
|
return mappings
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
function translationMappings(froms, to) {
|
|
93
93
|
const mappingss = []
|
|
94
94
|
for (const from of froms) {
|
|
95
95
|
mappingss.push(translationMapping(from, to))
|
|
@@ -97,7 +97,7 @@ const translationMappings = (froms, to) => {
|
|
|
97
97
|
return mappingss
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
function translationMappingToInstantiatorMappings(translationMapping, from , to) {
|
|
101
101
|
return translationMapping.map( (tm) => {
|
|
102
102
|
return {
|
|
103
103
|
// match: ({context}) => context.value == to[tm.to].value,
|