tpmkms_4wp 9.5.1-beta.3 → 9.5.1-beta.31
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 +21 -61
- package/common/asking.js +112 -102
- package/common/avatar.test.json +1001 -860
- package/common/can.instance.json +2174 -0
- package/common/can.js +254 -0
- package/common/can.test.json +51307 -0
- package/common/characters.js +3 -3
- package/common/colors.instance.json +10 -10
- package/common/comparable.instance.json +2 -2
- package/common/concept.js +19 -22
- package/common/concept.test.json +54 -40
- package/common/conjunction.js +13 -5
- package/common/conjunction.test.json +32 -42
- package/common/crew.instance.json +164 -150
- package/common/crew.js +1 -1
- package/common/currency.js +1 -1
- package/common/dateTimeSelectors.instance.json +2 -2
- package/common/dateTimeSelectors.js +3 -3
- package/common/dateTimeSelectors.test.json +76935 -35739
- package/common/dates.instance.json +3 -3
- package/common/dates.test.json +284 -287
- package/common/dialogues.js +41 -119
- package/common/dialogues.test.json +1171 -996
- package/common/dimension.instance.json +21374 -562
- package/common/dimension.js +145 -51
- package/common/dimension.test.json +8753 -3495
- package/common/drone.instance.json +23710 -0
- package/common/drone.js +429 -0
- package/common/drone.test.json +61113 -0
- package/common/edible.instance.json +23 -95
- package/common/emotions.instance.json +53 -80
- package/common/emotions.js +1 -1
- package/common/english_helpers.js +277 -67
- package/common/fastfood.instance.json +180 -372
- package/common/fastfood.js +4 -4
- package/common/fastfood.test.json +6970 -6829
- package/common/formulas.instance.json +1 -1
- package/common/gdefaults.js +94 -17
- package/common/help.js +11 -11
- 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 +7 -2
- package/common/helpers/formulas.js +13 -11
- package/common/helpers/menus.js +12 -12
- package/common/helpers/meta.js +8 -8
- package/common/helpers/properties.js +104 -23
- package/common/helpers.js +114 -48
- package/common/hierarchy.js +6 -4
- package/common/kirk.instance.json +1 -1
- package/common/kirk.test.json +600 -424
- package/common/latin.instance.json +10 -10
- package/common/latin.js +5 -5
- package/common/length.instance.json +27612 -2890
- package/common/length.js +6 -1
- package/common/length.test.json +45315 -3925
- package/common/math.instance.json +20 -20
- package/common/math.js +45 -44
- package/common/menus.instance.json +6 -9
- package/common/menus.js +2 -9
- package/common/meta.js +50 -33
- package/common/nameable.js +13 -6
- package/common/nameable.test.json +436 -0
- package/common/numbers.js +1 -1
- package/common/ordering.instance.json +20 -30
- package/common/ordering.js +1 -1
- package/common/ordering.test.json +414 -426
- package/common/people.instance.json +82 -348
- package/common/people.js +1 -1
- package/common/people.test.json +952 -681
- package/common/pipboy.instance.json +16 -16
- package/common/pokemon.instance.json +8 -8
- package/common/pokemon.js +1 -1
- package/common/pressure.instance.json +3579 -1610
- package/common/pressure.test.json +433 -477
- package/common/properties.instance.json +6 -17
- package/common/properties.js +19 -6
- package/common/properties.test.json +8746 -6638
- package/common/rates.instance.json +59 -0
- package/common/rates.js +97 -0
- package/common/rates.test.json +27702 -0
- package/common/reminders.js +1 -1
- package/common/reminders.test.json +64635 -25787
- package/common/reports.instance.json +3 -3
- package/common/reports.js +18 -16
- package/common/scorekeeper.js +4 -4
- package/common/sdefaults.js +22 -2
- package/common/spock.instance.json +1 -1
- package/common/spock.test.json +606 -430
- package/common/stgame.js +1 -1
- package/common/stm.js +15 -4
- package/common/tell.js +1 -1
- package/common/temperature.instance.json +3786 -1705
- package/common/temperature.test.json +433 -477
- package/common/tester.js +3 -3
- package/common/time.instance.json +24762 -0
- package/common/time.js +137 -141
- package/common/time.test.json +31876 -3757
- package/common/tokenize.js +1 -1
- package/common/ui.instance.json +2 -5
- package/common/ui.js +1 -8
- package/common/weight.instance.json +10359 -4077
- package/common/weight.test.json +2601 -2263
- package/common/words.instance.json +9 -0
- package/common/words.js +53 -0
- package/common/words.test.json +2 -0
- package/common/wp.instance.json +336 -8
- package/common/wp.js +8 -4
- package/common/wp.test.json +7385 -6906
- package/main.js +4 -2
- package/package.json +18 -5
- package/common/listener.js +0 -50
- package/common/listener.test.json +0 -142
package/common/helpers.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
const pluralize = require('pluralize')
|
|
2
|
+
const { flatten } = require('./runtime').theprogrammablemind
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
function unshiftL(list, element, max) {
|
|
4
5
|
if (list.length >= max) {
|
|
5
6
|
list.pop()
|
|
6
7
|
}
|
|
7
8
|
list.unshift(element)
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
function pushL(list, element, max) {
|
|
11
12
|
if (list.length >= max) {
|
|
12
13
|
list.shift()
|
|
13
14
|
}
|
|
@@ -15,11 +16,11 @@ const pushL = (list, element, max) => {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
// X pm today or tomorrow
|
|
18
|
-
|
|
19
|
+
function millisecondsUntilHourOfDay(newDate, hour) {
|
|
19
20
|
const now = newDate()
|
|
20
21
|
const target = newDate(now)
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
function addHours(date, h) {
|
|
23
24
|
date.setTime(date.getTime() + (h*60*60*1000));
|
|
24
25
|
}
|
|
25
26
|
const hours = target.getHours()
|
|
@@ -34,11 +35,11 @@ const millisecondsUntilHourOfDay = (newDate, hour) => {
|
|
|
34
35
|
return diff;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
function indent(string, indent) {
|
|
38
39
|
return string.replace(/^/gm, ' '.repeat(indent));
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
function getCount(context) {
|
|
42
43
|
if (context.quantity) {
|
|
43
44
|
return context.quantity.value
|
|
44
45
|
}
|
|
@@ -47,13 +48,23 @@ const getCount = (context) => {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
function words(word, additional = {}) {
|
|
51
52
|
return [{ word: pluralize.singular(word), number: 'one', ...additional }, { word: pluralize.plural(word), number: 'many', ...additional }]
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
55
|
+
function isMany(context) {
|
|
56
|
+
if (!context) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
// if (((context || {}).value || {}).marker == 'list' && (((context || {}).value || {}).value || []).length > 1) {
|
|
60
|
+
const isList = context.marker == 'list' || context.value?.marker == 'list'
|
|
61
|
+
if (isList) {
|
|
62
|
+
if (context.value?.length > 1) {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
if (context.value?.value?.length > 1) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
57
68
|
}
|
|
58
69
|
|
|
59
70
|
let number = context.number
|
|
@@ -77,13 +88,13 @@ const isMany = (context) => {
|
|
|
77
88
|
return false
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
|
|
91
|
+
function requiredArgument(value, name) {
|
|
81
92
|
if (!value) {
|
|
82
93
|
throw new Error(`${name} is a required argument`)
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
|
|
86
|
-
|
|
97
|
+
function chooseNumber(context, one, many) {
|
|
87
98
|
if (isMany(context)) {
|
|
88
99
|
return many;
|
|
89
100
|
} else {
|
|
@@ -91,7 +102,7 @@ const chooseNumber = (context, one, many) => {
|
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
104
|
|
|
94
|
-
|
|
105
|
+
function zip(...arrays) {
|
|
95
106
|
if (arrays == []) {
|
|
96
107
|
return []
|
|
97
108
|
}
|
|
@@ -107,15 +118,21 @@ const zip = (...arrays) => {
|
|
|
107
118
|
}
|
|
108
119
|
|
|
109
120
|
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
function focus(context) {
|
|
122
|
+
function helper(context) {
|
|
112
123
|
if (!context || !context.focusable) {
|
|
113
124
|
return null
|
|
114
125
|
}
|
|
115
126
|
for (const property of context.focusable) {
|
|
116
127
|
let focus = helper(context[property])
|
|
117
|
-
if (!focus
|
|
118
|
-
|
|
128
|
+
if (!focus) {
|
|
129
|
+
const flat = flatten(['list'], context[property])[0]
|
|
130
|
+
for (const element of flat) {
|
|
131
|
+
if (element.focus) {
|
|
132
|
+
focus = context[property]
|
|
133
|
+
break
|
|
134
|
+
}
|
|
135
|
+
}
|
|
119
136
|
}
|
|
120
137
|
return focus
|
|
121
138
|
}
|
|
@@ -126,7 +143,7 @@ const focus = (context) => {
|
|
|
126
143
|
|
|
127
144
|
// if property is a list make array of elements of the list, if not return an array with the property value
|
|
128
145
|
// fromList
|
|
129
|
-
|
|
146
|
+
function propertyToArray(value) {
|
|
130
147
|
if (Array.isArray(value)) {
|
|
131
148
|
return value
|
|
132
149
|
} else if (value.marker == 'list') {
|
|
@@ -136,7 +153,23 @@ const propertyToArray = (value) => {
|
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
|
|
139
|
-
|
|
156
|
+
// values is marker: 'list' or some context
|
|
157
|
+
function concats(values) {
|
|
158
|
+
combined = []
|
|
159
|
+
for (const value of values) {
|
|
160
|
+
if (value.marker == 'list') {
|
|
161
|
+
combined = combined.concat(value.value)
|
|
162
|
+
} else {
|
|
163
|
+
combined.push(value)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
marker: 'list',
|
|
168
|
+
value: combined
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function wordNumber(word, toPlural) {
|
|
140
173
|
if (toPlural) {
|
|
141
174
|
return pluralize.plural(word)
|
|
142
175
|
} else {
|
|
@@ -144,17 +177,18 @@ wordNumber = (word, toPlural) => {
|
|
|
144
177
|
}
|
|
145
178
|
}
|
|
146
179
|
|
|
147
|
-
|
|
180
|
+
function toEValue(context) {
|
|
148
181
|
while( context.evalue ) {
|
|
149
182
|
context = context.evalue
|
|
150
183
|
}
|
|
151
184
|
return context;
|
|
152
185
|
}
|
|
153
186
|
|
|
154
|
-
|
|
187
|
+
function defaultObjectCheck(extra = []) {
|
|
155
188
|
return {
|
|
156
189
|
objects: [
|
|
157
190
|
{
|
|
191
|
+
extra,
|
|
158
192
|
match: ({objects}) => true,
|
|
159
193
|
apply: () => extra
|
|
160
194
|
},
|
|
@@ -162,57 +196,62 @@ const defaultObjectCheck = (extra = []) => {
|
|
|
162
196
|
}
|
|
163
197
|
}
|
|
164
198
|
|
|
165
|
-
|
|
199
|
+
function defaultContextCheckProperties(extra) {
|
|
166
200
|
return ['marker', 'text', 'verbatim', 'value', 'evalue', 'isResponse', { properties: 'modifiers' }, { properties: 'postModifiers' }, ...extra]
|
|
167
201
|
}
|
|
168
202
|
|
|
169
|
-
|
|
203
|
+
function defaultContextCheck({marker, extra = [], exported = false} = {}) {
|
|
170
204
|
let match
|
|
171
205
|
if (marker) {
|
|
172
206
|
match = ({context}) => context.marker == marker
|
|
173
207
|
} else {
|
|
174
|
-
match = ({context}) => !Array.isArray(context)
|
|
175
208
|
}
|
|
176
209
|
return {
|
|
210
|
+
marker,
|
|
177
211
|
match,
|
|
178
212
|
exported,
|
|
179
213
|
apply: () => ['marker', 'text', 'verbatim', 'value', 'evalue', 'isResponse', { properties: 'modifiers' }, { properties: 'postModifiers' }, ...extra],
|
|
180
214
|
}
|
|
181
215
|
}
|
|
182
216
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (strict) {
|
|
189
|
-
if (child.marker) {
|
|
190
|
-
child = child.marker
|
|
217
|
+
function isA(hierarchy) {
|
|
218
|
+
return (child, parent, { strict=false } = {}) => {
|
|
219
|
+
if (!child || !parent) {
|
|
220
|
+
return false
|
|
191
221
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
|
|
223
|
+
if (strict) {
|
|
224
|
+
if (child.marker) {
|
|
225
|
+
child = child.marker
|
|
226
|
+
}
|
|
227
|
+
if (parent.marker) {
|
|
228
|
+
parent = parent.marker
|
|
229
|
+
}
|
|
230
|
+
return hierarchy.isA(child, parent)
|
|
231
|
+
} else {
|
|
232
|
+
if (hierarchy.isA(child.marker || child, parent.marker || parent)) {
|
|
233
|
+
return true
|
|
234
|
+
}
|
|
235
|
+
for (const childT of child.types || [child]) {
|
|
236
|
+
for (const parentT of parent.types || [parent]) {
|
|
237
|
+
if (hierarchy.isA(childT, parentT)) {
|
|
238
|
+
return true
|
|
239
|
+
}
|
|
204
240
|
}
|
|
205
241
|
}
|
|
242
|
+
return false
|
|
206
243
|
}
|
|
207
|
-
return false
|
|
208
244
|
}
|
|
209
245
|
}
|
|
210
246
|
|
|
211
|
-
|
|
247
|
+
function getValue(propertyPath, object) {
|
|
212
248
|
if (!propertyPath) {
|
|
213
249
|
return
|
|
214
250
|
}
|
|
215
|
-
|
|
251
|
+
let path = propertyPath
|
|
252
|
+
if (typeof path == 'string') {
|
|
253
|
+
path = propertyPath.split('.')
|
|
254
|
+
}
|
|
216
255
|
let value = object
|
|
217
256
|
for (const name of path) {
|
|
218
257
|
if (!value) {
|
|
@@ -223,7 +262,30 @@ const getValue = (propertyPath, object) => {
|
|
|
223
262
|
return value
|
|
224
263
|
}
|
|
225
264
|
|
|
226
|
-
|
|
265
|
+
function setValue(propertyPath, object, newValue) {
|
|
266
|
+
if (!propertyPath) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
let path = propertyPath;
|
|
270
|
+
if (typeof path === 'string') {
|
|
271
|
+
path = propertyPath.split('.');
|
|
272
|
+
}
|
|
273
|
+
let current = object;
|
|
274
|
+
for (let i = 0; i < path.length; i++) {
|
|
275
|
+
const name = path[i];
|
|
276
|
+
if (i === path.length - 1) {
|
|
277
|
+
// Set the value at the final step
|
|
278
|
+
current[name] = newValue;
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
if (current[name] === undefined || current[name] === null) {
|
|
282
|
+
current[name] = {}; // Create a plain object for nesting
|
|
283
|
+
}
|
|
284
|
+
current = current[name];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async function processTemplateString(template, evaluate) {
|
|
227
289
|
async function resolveWithCallback(strings, ...keys) {
|
|
228
290
|
// const resolvedValues = await Promise.all(keys.map(key => lookupVariable(key)));
|
|
229
291
|
const resolvedValues = await Promise.all(keys.map(async (key) => {
|
|
@@ -319,7 +381,10 @@ module.exports = {
|
|
|
319
381
|
processTemplateString,
|
|
320
382
|
unshiftL,
|
|
321
383
|
pushL,
|
|
384
|
+
|
|
322
385
|
getValue,
|
|
386
|
+
setValue,
|
|
387
|
+
|
|
323
388
|
defaultContextCheck,
|
|
324
389
|
defaultContextCheckProperties,
|
|
325
390
|
defaultObjectCheck,
|
|
@@ -337,4 +402,5 @@ module.exports = {
|
|
|
337
402
|
requiredArgument,
|
|
338
403
|
isA,
|
|
339
404
|
removeProp,
|
|
405
|
+
concats
|
|
340
406
|
}
|
package/common/hierarchy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { knowledgeModule, where } = require('./runtime').theprogrammablemind
|
|
1
|
+
const { debug, knowledgeModule, where } = require('./runtime').theprogrammablemind
|
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
|
3
3
|
const properties = require('./properties')
|
|
4
4
|
const hierarchy_tests = require('./hierarchy.test.json')
|
|
@@ -6,11 +6,11 @@ const pluralize = require('pluralize')
|
|
|
6
6
|
const _ = require('lodash')
|
|
7
7
|
const { isMany } = require('./helpers')
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
function getTypes( km, concept, instance ) {
|
|
10
10
|
const propertiesAPI = km('properties').api;
|
|
11
11
|
const conceptAPI = km('concept').api;
|
|
12
12
|
const digraph = propertiesAPI.digraph;
|
|
13
|
-
|
|
13
|
+
function intersect(set1, set2) {
|
|
14
14
|
return new Set([...set1].filter(x => set2.has(x)))
|
|
15
15
|
}
|
|
16
16
|
const descendants = digraph.descendants(concept.value)
|
|
@@ -253,9 +253,11 @@ const config = {
|
|
|
253
253
|
const twoConcepts = asList(context.same);
|
|
254
254
|
for (const oneConcept of oneConcepts.value) {
|
|
255
255
|
for (const twoConcept of twoConcepts.value) {
|
|
256
|
+
// debug.counter('greg23', { breakAt: 39 })
|
|
256
257
|
oneConceptId = await api.makeObject({...args, context: oneConcept})
|
|
257
258
|
twoConceptId = await api.makeObject({...args, context: twoConcept})
|
|
258
259
|
api.rememberIsA(oneConceptId, twoConceptId)
|
|
260
|
+
api.seenHierarchyWatcher({ childId: oneConceptId, child: oneConcept, parentId: twoConceptId, parent: twoConcept })
|
|
259
261
|
context.sameWasProcessed = true
|
|
260
262
|
}
|
|
261
263
|
}
|
|
@@ -286,7 +288,7 @@ const config = {
|
|
|
286
288
|
]
|
|
287
289
|
};
|
|
288
290
|
|
|
289
|
-
|
|
291
|
+
function initializer({apis, hierarchy}) {
|
|
290
292
|
apis('stm').addIsA( (child, parent) => {
|
|
291
293
|
return hierarchy.isA(child, parent)
|
|
292
294
|
})
|