tpmkms_4wp 9.1.1-beta.7 → 9.1.1-beta.9
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/colors.instance.json +0 -28
- package/common/concept.js +1 -1
- package/common/edible.instance.json +0 -112
- package/common/fastfood.instance.json +240 -412
- package/common/helpers/menus.js +132 -0
- package/common/menus.instance.json +2 -2
- package/common/menus.js +49 -3
- package/common/menus.test.json +6996 -5
- package/common/pipboy.instance.json +0 -56
- package/common/reports.instance.json +2 -2
- package/common/sdefaults.js +25 -0
- package/common/ui.js +3 -1
- package/common/wp.instance.json +0 -56
- package/package.json +3 -2
@@ -0,0 +1,132 @@
|
|
1
|
+
const calculateLefts = (defs) => {
|
2
|
+
const lefts = {}
|
3
|
+
calculateLeftsHelper(defs, lefts)
|
4
|
+
return lefts
|
5
|
+
}
|
6
|
+
|
7
|
+
const calculateLeftsHelper = (defs, lefts) => {
|
8
|
+
if (Array.isArray(defs)) {
|
9
|
+
let previous
|
10
|
+
for (const def of defs) {
|
11
|
+
if (previous) {
|
12
|
+
lefts[def.key] = previous.key
|
13
|
+
previous = def
|
14
|
+
} else {
|
15
|
+
previous = def
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
return lefts
|
20
|
+
}
|
21
|
+
|
22
|
+
const calculateRights = (defs) => {
|
23
|
+
const rights = {}
|
24
|
+
calculateRightsHelper(defs, rights)
|
25
|
+
return rights
|
26
|
+
}
|
27
|
+
|
28
|
+
const calculateRightsHelper = (defs, rights) => {
|
29
|
+
if (Array.isArray(defs)) {
|
30
|
+
let previous
|
31
|
+
for (const def of defs) {
|
32
|
+
if (previous) {
|
33
|
+
rights[previous.key] = def.key
|
34
|
+
previous = def
|
35
|
+
} else {
|
36
|
+
previous = def
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return rights
|
41
|
+
}
|
42
|
+
|
43
|
+
const calculateDowns = (defs) => {
|
44
|
+
const downs = {}
|
45
|
+
calculateDownsHelper(defs, downs)
|
46
|
+
return downs
|
47
|
+
}
|
48
|
+
|
49
|
+
const calculateDownsHelper = (defs, downs) => {
|
50
|
+
if (Array.isArray(defs)) {
|
51
|
+
for (const def of defs) {
|
52
|
+
calculateDownsHelper(def, downs)
|
53
|
+
}
|
54
|
+
} else if (defs.children) {
|
55
|
+
if (defs.children.length > 0) {
|
56
|
+
downs[defs.key] = defs.children[0].key
|
57
|
+
}
|
58
|
+
|
59
|
+
let previous
|
60
|
+
for (const child of defs.children) {
|
61
|
+
if (child.divider) {
|
62
|
+
continue
|
63
|
+
}
|
64
|
+
if (previous) {
|
65
|
+
downs[previous.key] = child.key
|
66
|
+
previous = child
|
67
|
+
} else {
|
68
|
+
previous = child
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
return downs
|
73
|
+
}
|
74
|
+
|
75
|
+
const calculateUps = (defs) => {
|
76
|
+
const ups = {}
|
77
|
+
calculateUpsHelper(defs, ups)
|
78
|
+
return ups
|
79
|
+
}
|
80
|
+
|
81
|
+
const calculateUpsHelper = (defs, ups) => {
|
82
|
+
if (Array.isArray(defs)) {
|
83
|
+
for (const def of defs) {
|
84
|
+
calculateUpsHelper(def, ups)
|
85
|
+
}
|
86
|
+
} else if (defs.children) {
|
87
|
+
let previous
|
88
|
+
for (const child of defs.children) {
|
89
|
+
if (child.divider) {
|
90
|
+
continue
|
91
|
+
}
|
92
|
+
if (previous) {
|
93
|
+
ups[child.key] = previous.key
|
94
|
+
previous = child
|
95
|
+
} else {
|
96
|
+
previous = child
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return ups
|
101
|
+
}
|
102
|
+
|
103
|
+
const calculateParents = (defs) => {
|
104
|
+
const parents = {}
|
105
|
+
calculateParentsHelper(defs, parents)
|
106
|
+
return parents
|
107
|
+
}
|
108
|
+
|
109
|
+
const calculateParentsHelper = (defs, parents) => {
|
110
|
+
if (Array.isArray(defs)) {
|
111
|
+
for (const def of defs) {
|
112
|
+
parents[def.key] = def.key
|
113
|
+
calculateParentsHelper(def, parents)
|
114
|
+
}
|
115
|
+
} else if (defs.children) {
|
116
|
+
for (const child of defs.children) {
|
117
|
+
if (child.divider) {
|
118
|
+
continue
|
119
|
+
}
|
120
|
+
parents[child.key] = defs.key
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return parents
|
124
|
+
}
|
125
|
+
|
126
|
+
module.exports = {
|
127
|
+
calculateRights,
|
128
|
+
calculateLefts,
|
129
|
+
calculateDowns,
|
130
|
+
calculateUps,
|
131
|
+
calculateParents,
|
132
|
+
}
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"verb"
|
18
18
|
],
|
19
19
|
"bridge": "{ ...next(operator), show: after[0], generate: ['this', 'show'] }",
|
20
|
-
"semantic": "({context, api}) => {\n if (context.show.instance) {\n api.show(context.show.
|
20
|
+
"semantic": "({context, api}) => {\n if (context.show.instance) {\n api.show(context.show.value)\n }\n }"
|
21
21
|
},
|
22
22
|
{
|
23
23
|
"id": "typeOfMenu_menus",
|
@@ -4353,7 +4353,7 @@
|
|
4353
4353
|
],
|
4354
4354
|
"semantics": [
|
4355
4355
|
{
|
4356
|
-
"where": "/home/dev/code/theprogrammablemind/kms/common/menus.js:
|
4356
|
+
"where": "/home/dev/code/theprogrammablemind/kms/common/menus.js:140"
|
4357
4357
|
}
|
4358
4358
|
]
|
4359
4359
|
}
|
package/common/menus.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
const { knowledgeModule, where, Digraph } = require('./runtime').theprogrammablemind
|
2
2
|
const { defaultContextCheck } = require('./helpers')
|
3
3
|
const ui = require('./ui')
|
4
|
+
const helpers = require('./helpers/menus')
|
4
5
|
const tests = require('./menus.test.json')
|
5
6
|
const instance = require('./menus.instance.json')
|
6
7
|
|
@@ -8,14 +9,41 @@ class API {
|
|
8
9
|
initialize({ objects }) {
|
9
10
|
this._objects = objects
|
10
11
|
this._objects.show = []
|
12
|
+
this._objects.menuDefs = []
|
13
|
+
this._objects.directions = {}
|
14
|
+
}
|
15
|
+
|
16
|
+
setup() {
|
17
|
+
this._objects.directions = {
|
18
|
+
right: helpers.calculateRights(this._objects.menuDefs),
|
19
|
+
left: helpers.calculateLefts(this._objects.menuDefs),
|
20
|
+
up: helpers.calculateUps(this._objects.menuDefs),
|
21
|
+
down: helpers.calculateDowns(this._objects.menuDefs),
|
22
|
+
parents: helpers.calculateParents(this._objects.menuDefs),
|
23
|
+
}
|
11
24
|
}
|
12
25
|
|
13
26
|
move(direction, steps = 1, units = undefined) {
|
14
27
|
this._objects.move = { direction, steps, units }
|
28
|
+
let next = this.current()
|
29
|
+
if (direction === 'left' || direction === 'right' ){
|
30
|
+
next = this._objects.directions.parents[next]
|
31
|
+
}
|
32
|
+
for (let i = 0; i < steps; ++i) {
|
33
|
+
next = this._objects.directions[direction][next]
|
34
|
+
}
|
35
|
+
if (next) {
|
36
|
+
this.show(next)
|
37
|
+
}
|
15
38
|
}
|
16
39
|
|
17
40
|
show(item) {
|
18
41
|
this._objects.show.push(item)
|
42
|
+
this._objects.current = item
|
43
|
+
}
|
44
|
+
|
45
|
+
current() {
|
46
|
+
return this._objects.current
|
19
47
|
}
|
20
48
|
|
21
49
|
select(item) {
|
@@ -41,10 +69,16 @@ class API {
|
|
41
69
|
config.addOperator(`([${languageId}|])`)
|
42
70
|
config.addBridge({
|
43
71
|
id: `${languageId}`,
|
44
|
-
associations: [languageId],
|
72
|
+
associations: [languageId, 'menus'],
|
45
73
|
isA: ['menu_menus'],
|
46
74
|
words: [{ word: name, value: id, instance: true }],
|
47
75
|
})
|
76
|
+
this._objects.menuDefs.push({
|
77
|
+
key: name,
|
78
|
+
text: name,
|
79
|
+
children: [],
|
80
|
+
})
|
81
|
+
this.setup()
|
48
82
|
return { languageId, id }
|
49
83
|
}
|
50
84
|
|
@@ -54,10 +88,16 @@ class API {
|
|
54
88
|
config.addOperator(`([${languageId}|])`)
|
55
89
|
config.addBridge({
|
56
90
|
id: `${languageId}`,
|
57
|
-
associations: [menuId.languageId],
|
91
|
+
associations: [menuId.languageId, 'menus'],
|
58
92
|
isA: ['menu_menus_item_menus'],
|
59
93
|
words: [{ word: name, value: id, path: [menuId.id, id], instance: true }],
|
60
94
|
})
|
95
|
+
const menu = this._objects.menuDefs.find((md) => md.key == menuId.id)
|
96
|
+
menu.children.push({
|
97
|
+
key: id,
|
98
|
+
text: name,
|
99
|
+
})
|
100
|
+
this.setup()
|
61
101
|
}
|
62
102
|
}
|
63
103
|
|
@@ -132,13 +172,19 @@ const fixtures = async ({api, fragment, s, config, objects, kms, isModule}) => {
|
|
132
172
|
const objectMenuId = api.addMenu('object')
|
133
173
|
|
134
174
|
api.addMenuItem(fileMenuId, 'fileOpen', 'open')
|
175
|
+
api.addMenuItem(fileMenuId, 'fileClose', 'close')
|
135
176
|
api.addMenuItem(objectMenuId, 'objectOpen', 'open')
|
177
|
+
api.addMenuItem(objectMenuId, 'objectClose', 'close')
|
136
178
|
}
|
137
179
|
|
138
180
|
knowledgeModule({
|
139
181
|
config,
|
140
182
|
includes: [ui],
|
141
183
|
api: () => new API(),
|
184
|
+
apiKMs: ['menus', 'ui'],
|
185
|
+
initializer: ({apis}) => {
|
186
|
+
apis('sdefaults').addAssociation('menus')
|
187
|
+
},
|
142
188
|
|
143
189
|
module,
|
144
190
|
description: 'Control menues with speech',
|
@@ -147,7 +193,7 @@ knowledgeModule({
|
|
147
193
|
contents: tests,
|
148
194
|
fixtures,
|
149
195
|
checks: {
|
150
|
-
objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show'],
|
196
|
+
objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show', 'menuDefs'],
|
151
197
|
context: defaultContextCheck(['operator', 'direction', 'moveable']),
|
152
198
|
},
|
153
199
|
},
|