tpmkms_4wp 9.1.1-beta.7 → 9.1.1-beta.8

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.
@@ -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.marker)\n }\n }"
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:74"
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
  },