tpmkms_4wp 9.1.1-beta.1 → 9.1.1-beta.11
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 +1 -0
- package/common/asking.test.json +193 -72
- package/common/colors.instance.json +14 -28
- package/common/comparable.instance.json +3 -0
- package/common/concept.js +1 -1
- package/common/crew.instance.json +26 -0
- package/common/dialogues.js +2 -1
- package/common/dimension.instance.json +1 -0
- package/common/edible.instance.json +36 -56
- 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 +1960 -13301
- 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 +132 -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 +6264 -1
- package/common/menus.js +150 -6
- package/common/menus.test.json +12297 -1
- package/common/ordering.instance.json +2 -0
- package/common/people.instance.json +96 -8
- package/common/pipboy.instance.json +21 -57
- package/common/pokemon.instance.json +13 -8
- package/common/pressure.instance.json +4 -0
- package/common/properties.instance.json +1 -0
- package/common/reports.instance.json +18 -23
- package/common/reports.js +12 -3
- package/common/sdefaults.js +25 -0
- package/common/spock.instance.json +1 -0
- package/common/temperature.instance.json +4 -112
- package/common/ui.instance.json +1 -0
- package/common/ui.js +3 -1
- package/common/weight.instance.json +14 -0
- package/common/wp.instance.json +28 -58
- package/package.json +3 -2
package/common/menus.js
CHANGED
@@ -1,16 +1,50 @@
|
|
1
1
|
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const ui = require('./ui')
|
4
|
-
const
|
5
|
-
const
|
4
|
+
const helpers = require('./helpers/menus')
|
5
|
+
const tests = require('./menus.test.json')
|
6
|
+
const instance = require('./menus.instance.json')
|
6
7
|
|
7
8
|
class API {
|
8
|
-
initialize({ objects }) {
|
9
|
+
initialize({ objects, config }) {
|
10
|
+
this._config = config
|
9
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
|
+
}
|
10
25
|
}
|
11
26
|
|
12
27
|
move(direction, steps = 1, units = undefined) {
|
13
28
|
this._objects.move = { direction, steps, units }
|
29
|
+
let next = this.current()
|
30
|
+
if (direction === 'left' || direction === 'right' ){
|
31
|
+
next = this._objects.directions.parents[next]
|
32
|
+
}
|
33
|
+
for (let i = 0; i < steps; ++i) {
|
34
|
+
next = this._objects.directions[direction][next]
|
35
|
+
}
|
36
|
+
if (next) {
|
37
|
+
this.show(next)
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
show(item) {
|
42
|
+
this._objects.show.push(item)
|
43
|
+
this._objects.current = item
|
44
|
+
}
|
45
|
+
|
46
|
+
current() {
|
47
|
+
return this._objects.current
|
14
48
|
}
|
15
49
|
|
16
50
|
select(item) {
|
@@ -28,6 +62,44 @@ class API {
|
|
28
62
|
stop(action) {
|
29
63
|
this._objects.stop = action
|
30
64
|
}
|
65
|
+
|
66
|
+
addMenu(name) {
|
67
|
+
const config = this._config
|
68
|
+
const id = name
|
69
|
+
const languageId = `${name}Menu_menus`
|
70
|
+
config.addOperator(`([${languageId}|])`)
|
71
|
+
config.addBridge({
|
72
|
+
id: `${languageId}`,
|
73
|
+
associations: [languageId, 'menus'],
|
74
|
+
isA: ['menu_menus'],
|
75
|
+
words: [{ word: name, value: id, instance: true }],
|
76
|
+
})
|
77
|
+
this._objects.menuDefs.push({
|
78
|
+
key: name,
|
79
|
+
text: name,
|
80
|
+
children: [],
|
81
|
+
})
|
82
|
+
this.setup()
|
83
|
+
return { languageId, id }
|
84
|
+
}
|
85
|
+
|
86
|
+
addMenuItem(menuId, id, name) {
|
87
|
+
const config = this._config
|
88
|
+
const languageId = `${id}MenuItem_menus`
|
89
|
+
config.addOperator(`([${languageId}|])`)
|
90
|
+
config.addBridge({
|
91
|
+
id: `${languageId}`,
|
92
|
+
associations: [menuId.languageId, 'menus'],
|
93
|
+
isA: ['menu_menus_item_menus'],
|
94
|
+
words: [{ word: name, value: id, path: [menuId.id, id], instance: true }],
|
95
|
+
})
|
96
|
+
const menu = this._objects.menuDefs.find((md) => md.key == menuId.id)
|
97
|
+
menu.children.push({
|
98
|
+
key: id,
|
99
|
+
text: name,
|
100
|
+
})
|
101
|
+
this.setup()
|
102
|
+
}
|
31
103
|
}
|
32
104
|
|
33
105
|
const config = {
|
@@ -35,27 +107,99 @@ const config = {
|
|
35
107
|
};
|
36
108
|
|
37
109
|
const template = {
|
110
|
+
configs: [
|
111
|
+
'setidsuffix _menus',
|
112
|
+
"menu is a concept",
|
113
|
+
"item is a concept",
|
114
|
+
"menu modifies item",
|
115
|
+
"menus and menu items are showable",
|
116
|
+
{
|
117
|
+
operators: [
|
118
|
+
"([show_menus|show] (showable_menus))",
|
119
|
+
"((@<= menu_menus) [typeOfMenu_menus|show] (@== menu_menus))",
|
120
|
+
],
|
121
|
+
bridges: [
|
122
|
+
{
|
123
|
+
id: 'show_menus',
|
124
|
+
isA: ['verb'],
|
125
|
+
bridge: "{ ...next(operator), show: after[0], generate: ['this', 'show'] }",
|
126
|
+
semantic: ({context, api}) => {
|
127
|
+
if (context.show.instance) {
|
128
|
+
api.show(context.show.value)
|
129
|
+
}
|
130
|
+
}
|
131
|
+
},
|
132
|
+
{
|
133
|
+
id: 'typeOfMenu_menus',
|
134
|
+
convolution: true,
|
135
|
+
isA: ['adjective'],
|
136
|
+
bridge: "{ ...after[0], modifiers: ['menus'], menus: before[0] }",
|
137
|
+
},
|
138
|
+
],
|
139
|
+
semantics: [
|
140
|
+
{
|
141
|
+
where: where(),
|
142
|
+
match: ({context, isA}) => isA(context, 'showable_menus'),
|
143
|
+
apply: async ({context, insert, s, fragments}) => {
|
144
|
+
const value = context
|
145
|
+
const fragment = fragments("show showable")
|
146
|
+
const mappings = [{
|
147
|
+
where: where(),
|
148
|
+
match: ({context}) => context.value == 'showable_menus',
|
149
|
+
apply: ({context}) => Object.assign(context, value),
|
150
|
+
}]
|
151
|
+
const instantiation = await fragment.instantiate(mappings)
|
152
|
+
await s(instantiation)
|
153
|
+
}
|
154
|
+
},
|
155
|
+
]
|
156
|
+
},
|
157
|
+
],
|
38
158
|
fragments: [
|
159
|
+
"show showable",
|
39
160
|
],
|
40
161
|
}
|
41
162
|
|
163
|
+
/*
|
164
|
+
show the file menu
|
165
|
+
pick the file open item
|
166
|
+
show file
|
167
|
+
|
168
|
+
file (<- instance of menu) menu (<- concept of menu)
|
169
|
+
*/
|
170
|
+
// called for the non-module load to setup fixtures
|
171
|
+
const fixtures = async ({api, fragment, s, config, objects, kms, isModule}) => {
|
172
|
+
const fileMenuId = api.addMenu('file')
|
173
|
+
const objectMenuId = api.addMenu('object')
|
174
|
+
|
175
|
+
api.addMenuItem(fileMenuId, 'fileOpen', 'open')
|
176
|
+
api.addMenuItem(fileMenuId, 'fileClose', 'close')
|
177
|
+
api.addMenuItem(objectMenuId, 'objectOpen', 'open')
|
178
|
+
api.addMenuItem(objectMenuId, 'objectClose', 'close')
|
179
|
+
}
|
180
|
+
|
42
181
|
knowledgeModule({
|
43
182
|
config,
|
44
183
|
includes: [ui],
|
45
184
|
api: () => new API(),
|
185
|
+
apiKMs: ['menus', 'ui'],
|
186
|
+
initializer: ({apis}) => {
|
187
|
+
apis('sdefaults').addAssociation('menus')
|
188
|
+
},
|
46
189
|
|
47
190
|
module,
|
48
191
|
description: 'Control menues with speech',
|
49
192
|
test: {
|
50
193
|
name: './menus.test.json',
|
51
|
-
contents:
|
194
|
+
contents: tests,
|
195
|
+
fixtures,
|
52
196
|
checks: {
|
53
|
-
objects: ['move', 'select', 'unselect', 'cancel', 'stop'],
|
197
|
+
objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show', 'menuDefs'],
|
54
198
|
context: defaultContextCheck(['operator', 'direction', 'moveable']),
|
55
199
|
},
|
56
200
|
},
|
57
201
|
template: {
|
58
202
|
template,
|
59
|
-
instance
|
203
|
+
instance,
|
60
204
|
}
|
61
205
|
})
|