tpmkms_4wp 9.1.1 → 9.2.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/common/animals.instance.json +13 -0
- package/common/articles.js +3 -0
- package/common/asking.test.json +193 -72
- package/common/avatar.js +0 -6
- package/common/colors.instance.json +42 -0
- package/common/comparable.instance.json +3 -0
- package/common/comparable.js +6 -0
- package/common/concept.js +1 -1
- package/common/crew.instance.json +26 -39
- package/common/crew.js +0 -7
- package/common/dialogues.js +2 -1
- package/common/dimension.instance.json +1 -0
- package/common/edible.instance.json +92 -0
- package/common/emotions.instance.json +1 -0
- package/common/events.js +3 -3
- package/common/events.test.json +107 -36
- package/common/fastfood.instance.json +1053 -12554
- package/common/fastfood.js +2 -1
- package/common/formulas.instance.json +1 -0
- package/common/formulas.js +3 -1
- package/common/formulas.test.json +643 -711
- package/common/helpers/concept.js +6 -2
- package/common/helpers/dialogues.js +1 -1
- package/common/helpers/menus.js +154 -0
- package/common/helpers.js +16 -0
- package/common/kirk.instance.json +1 -0
- package/common/length.instance.json +15 -0
- package/common/math.instance.json +1 -0
- package/common/menus.instance.json +10097 -0
- package/common/menus.js +260 -0
- package/common/menus.test.json +26163 -0
- package/common/negation.js +5 -0
- package/common/ordering.instance.json +2 -0
- package/common/people.instance.json +96 -8
- package/common/pipboy.instance.json +105 -123
- package/common/pipboy.js +0 -7
- package/common/pokemon.instance.json +13 -8
- package/common/pressure.instance.json +4 -0
- package/common/properties.instance.json +1 -0
- package/common/properties.js +1 -0
- package/common/reports.instance.json +18 -23
- package/common/reports.js +12 -3
- package/common/sdefaults.js +28 -3
- package/common/spock.instance.json +1 -0
- package/common/stm.js +2 -1
- package/common/temperature.instance.json +4 -0
- package/common/tester.js +24 -2
- package/common/ui.instance.json +446 -0
- package/common/ui.js +9 -4
- package/common/ui.test.json +6794 -0
- package/common/weight.instance.json +14 -0
- package/common/wp.instance.json +6262 -2
- package/main.js +2 -0
- package/package.json +8 -3
package/common/menus.js
ADDED
@@ -0,0 +1,260 @@
|
|
1
|
+
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
|
+
const { defaultContextCheck } = require('./helpers')
|
3
|
+
const ui = require('./ui')
|
4
|
+
const helpers = require('./helpers/menus')
|
5
|
+
const tests = require('./menus.test.json')
|
6
|
+
const instance = require('./menus.instance.json')
|
7
|
+
|
8
|
+
class MenusAPI {
|
9
|
+
initialize({ objects, config }) {
|
10
|
+
this._config = config
|
11
|
+
this._objects = objects
|
12
|
+
this._objects.show = []
|
13
|
+
this._objects.menuDefs = []
|
14
|
+
this._objects.directions = {}
|
15
|
+
}
|
16
|
+
|
17
|
+
setup() {
|
18
|
+
this._objects.directions = {
|
19
|
+
right: helpers.calculateRights(this._objects.menuDefs),
|
20
|
+
left: helpers.calculateLefts(this._objects.menuDefs),
|
21
|
+
up: helpers.calculateUps(this._objects.menuDefs),
|
22
|
+
down: helpers.calculateDowns(this._objects.menuDefs),
|
23
|
+
parents: helpers.calculateParents(this._objects.menuDefs),
|
24
|
+
paths: helpers.calculatePaths(this._objects.menuDefs),
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
close() {
|
29
|
+
this._objects.close = true
|
30
|
+
}
|
31
|
+
|
32
|
+
move(direction, steps = 1, units = undefined) {
|
33
|
+
this._objects.move = { direction, steps, units }
|
34
|
+
let next = this.current()
|
35
|
+
if (direction === 'left' || direction === 'right' ){
|
36
|
+
next = this._objects.directions.parents[next]
|
37
|
+
}
|
38
|
+
for (let i = 0; i < steps; ++i) {
|
39
|
+
next = this._objects.directions[direction][next]
|
40
|
+
}
|
41
|
+
if (next) {
|
42
|
+
this.show(next)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
show(item) {
|
47
|
+
this._objects.show.push(item)
|
48
|
+
this._objects.current = item
|
49
|
+
}
|
50
|
+
|
51
|
+
current() {
|
52
|
+
return this._objects.current
|
53
|
+
}
|
54
|
+
|
55
|
+
select(item) {
|
56
|
+
this._objects.select = { item }
|
57
|
+
}
|
58
|
+
|
59
|
+
unselect(item) {
|
60
|
+
this._objects.unselect = { item }
|
61
|
+
}
|
62
|
+
|
63
|
+
cancel(direction) {
|
64
|
+
this._objects.cancel = true
|
65
|
+
}
|
66
|
+
|
67
|
+
stop(action) {
|
68
|
+
this._objects.stop = action
|
69
|
+
}
|
70
|
+
|
71
|
+
addMenu(name) {
|
72
|
+
const config = this._config
|
73
|
+
const id = name
|
74
|
+
const languageId = `${name}Menu_menus`
|
75
|
+
config.addOperator(`([${languageId}|])`)
|
76
|
+
config.addBridge({
|
77
|
+
id: `${languageId}`,
|
78
|
+
associations: [languageId, 'menus'],
|
79
|
+
isA: ['menu_menus'],
|
80
|
+
words: [{ word: name, value: id, instance: true }],
|
81
|
+
})
|
82
|
+
this._objects.menuDefs.push({
|
83
|
+
key: name,
|
84
|
+
text: name,
|
85
|
+
children: [],
|
86
|
+
})
|
87
|
+
this.setup()
|
88
|
+
return { languageId, id }
|
89
|
+
}
|
90
|
+
|
91
|
+
addMenuItem(menuId, id, name) {
|
92
|
+
const config = this._config
|
93
|
+
const languageId = `${id}MenuItem_menus`
|
94
|
+
config.addOperator(`([${languageId}|])`)
|
95
|
+
config.addBridge({
|
96
|
+
id: `${languageId}`,
|
97
|
+
associations: [menuId.languageId, 'menus'],
|
98
|
+
isA: ['menu_menus_item_menus'],
|
99
|
+
words: [{ word: name, value: id, path: [menuId.id, id], instance: true }],
|
100
|
+
})
|
101
|
+
const menu = this._objects.menuDefs.find((md) => md.key == menuId.id)
|
102
|
+
menu.children.push({
|
103
|
+
key: id,
|
104
|
+
text: name,
|
105
|
+
})
|
106
|
+
this.setup()
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
const config = {
|
111
|
+
name: 'menus',
|
112
|
+
};
|
113
|
+
|
114
|
+
const template = {
|
115
|
+
configs: [
|
116
|
+
'setidsuffix _menus',
|
117
|
+
"menu is a concept",
|
118
|
+
"item is a concept",
|
119
|
+
"menu modifies item",
|
120
|
+
"menus and menu items are showable",
|
121
|
+
{
|
122
|
+
operators: [
|
123
|
+
"([show_menus|show] (showable_menus))",
|
124
|
+
"([close_menus|close] (menu_menus/*))",
|
125
|
+
"((@<= menu_menus) [typeOfMenu_menus|show] (@== menu_menus))",
|
126
|
+
],
|
127
|
+
bridges: [
|
128
|
+
{
|
129
|
+
id: 'close_menus',
|
130
|
+
isA: ['verb'],
|
131
|
+
associations: ['menus'],
|
132
|
+
bridge: "{ ...next(operator), closee: after[0], generate: ['this', 'closee'] }",
|
133
|
+
semantic: ({context, api}) => {
|
134
|
+
api.close()
|
135
|
+
}
|
136
|
+
},
|
137
|
+
{
|
138
|
+
id: 'show_menus',
|
139
|
+
isA: ['verb'],
|
140
|
+
bridge: "{ ...next(operator), show: after[0], generate: ['this', 'show'] }",
|
141
|
+
semantic: ({context, api}) => {
|
142
|
+
if (context.show.instance) {
|
143
|
+
api.show(context.show.value)
|
144
|
+
}
|
145
|
+
}
|
146
|
+
},
|
147
|
+
{
|
148
|
+
id: 'typeOfMenu_menus',
|
149
|
+
convolution: true,
|
150
|
+
isA: ['adjective'],
|
151
|
+
bridge: "{ ...after[0], modifiers: ['menus'], menus: before[0] }",
|
152
|
+
},
|
153
|
+
],
|
154
|
+
semantics: [
|
155
|
+
{
|
156
|
+
where: where(),
|
157
|
+
match: ({context, isA}) => isA(context, 'showable_menus'),
|
158
|
+
apply: async ({context, insert, s, fragments}) => {
|
159
|
+
const value = context
|
160
|
+
const fragment = fragments("show showable")
|
161
|
+
const mappings = [{
|
162
|
+
where: where(),
|
163
|
+
match: ({context}) => context.value == 'showable_menus',
|
164
|
+
apply: ({context}) => Object.assign(context, value),
|
165
|
+
}]
|
166
|
+
const instantiation = await fragment.instantiate(mappings)
|
167
|
+
await s(instantiation)
|
168
|
+
}
|
169
|
+
},
|
170
|
+
]
|
171
|
+
},
|
172
|
+
"resetidsuffix",
|
173
|
+
],
|
174
|
+
fragments: [
|
175
|
+
"show showable",
|
176
|
+
],
|
177
|
+
}
|
178
|
+
|
179
|
+
class UIAPI {
|
180
|
+
constructor(menusAPI) {
|
181
|
+
this.menusAPI = menusAPI
|
182
|
+
}
|
183
|
+
|
184
|
+
initialize() {
|
185
|
+
}
|
186
|
+
|
187
|
+
move(direction, steps = 1, units = undefined) {
|
188
|
+
this.menusAPI.move(direction, steps, units)
|
189
|
+
}
|
190
|
+
|
191
|
+
select(item) {
|
192
|
+
this.menusAPI.select(item)
|
193
|
+
}
|
194
|
+
|
195
|
+
unselect(item) {
|
196
|
+
this.menusAPI.unselect(item)
|
197
|
+
}
|
198
|
+
|
199
|
+
cancel(direction) {
|
200
|
+
this.menusAPI.cancel(direction)
|
201
|
+
}
|
202
|
+
|
203
|
+
stop(action) {
|
204
|
+
this.menusAPI.stop(action)
|
205
|
+
}
|
206
|
+
|
207
|
+
}
|
208
|
+
|
209
|
+
/*
|
210
|
+
show the file menu
|
211
|
+
pick the file open item
|
212
|
+
show file
|
213
|
+
|
214
|
+
file (<- instance of menu) menu (<- concept of menu)
|
215
|
+
*/
|
216
|
+
// called for the non-module load to setup fixtures
|
217
|
+
const fixtures = async ({api, fragment, s, config, objects, kms, isModule}) => {
|
218
|
+
const fileMenuId = api.addMenu('file')
|
219
|
+
const objectMenuId = api.addMenu('object')
|
220
|
+
|
221
|
+
api.addMenuItem(fileMenuId, 'fileOpen', 'open')
|
222
|
+
api.addMenuItem(fileMenuId, 'fileOpenRemote', 'open remote')
|
223
|
+
api.addMenuItem(fileMenuId, 'fileClose', 'close')
|
224
|
+
|
225
|
+
api.addMenuItem(objectMenuId, 'objectOpen', 'open')
|
226
|
+
api.addMenuItem(objectMenuId, 'objectClose', 'close')
|
227
|
+
}
|
228
|
+
|
229
|
+
knowledgeModule({
|
230
|
+
config,
|
231
|
+
includes: [ui],
|
232
|
+
// api: () => new API(),
|
233
|
+
api: () => {
|
234
|
+
const menusAPI = new MenusAPI()
|
235
|
+
return {
|
236
|
+
'menus': menusAPI,
|
237
|
+
'ui': new UIAPI(menusAPI)
|
238
|
+
}
|
239
|
+
},
|
240
|
+
apiKMs: ['menus', 'ui'],
|
241
|
+
initializer: ({apis}) => {
|
242
|
+
apis('sdefaults').addAssociation('menus')
|
243
|
+
},
|
244
|
+
|
245
|
+
module,
|
246
|
+
description: 'Control menues with speech',
|
247
|
+
test: {
|
248
|
+
name: './menus.test.json',
|
249
|
+
contents: tests,
|
250
|
+
fixtures,
|
251
|
+
checks: {
|
252
|
+
objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show', 'menuDefs', 'close'],
|
253
|
+
context: defaultContextCheck(['operator', 'direction', 'moveable']),
|
254
|
+
},
|
255
|
+
},
|
256
|
+
template: {
|
257
|
+
template,
|
258
|
+
instance,
|
259
|
+
}
|
260
|
+
})
|