ekms 9.7.1-beta.20 → 9.7.1-beta.22

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.
@@ -0,0 +1,73 @@
1
+ const { debug, getByPath, setByPath } = require('../runtime').theprogrammablemind
2
+
3
+ const _ = require('lodash')
4
+
5
+ function getPaths(context) {
6
+ const todo = [{context, path: []}]
7
+ const paths = (context.flattenInPlace || []).map((_) => [])
8
+ while (todo.length > 0) {
9
+ const { context, groupIndex, path } = todo.pop()
10
+ if (context?.flattenInPlace) {
11
+ for (const [currentGroupIndex, props] of context.flattenInPlace.entries()) {
12
+ nextGroupIndex = groupIndex ?? currentGroupIndex
13
+ for (const prop of props) {
14
+ if (prop == 'value') {
15
+ paths[nextGroupIndex].push([...path, prop])
16
+ } else {
17
+ todo.push({ context: getByPath(context, prop), groupIndex: nextGroupIndex, path: [...path, prop] })
18
+ }
19
+ }
20
+ }
21
+ }
22
+ }
23
+ return paths.filter((paths) => paths.length > 0)
24
+ }
25
+
26
+ function remove(context) {
27
+ for (const prop of context.flattenInPlaceRemove || []) {
28
+ delete context[prop]
29
+ }
30
+ delete context.flattenInPlace
31
+ delete context.flattenInPlaceRemove
32
+ return context
33
+ }
34
+
35
+ function flattenInPlace(context) {
36
+ const paths = getPaths(context)
37
+ if (paths.length == 0) {
38
+ return [context]
39
+ }
40
+ let currents = [context]
41
+ for (const pathGroup of paths) {
42
+ const src = getByPath(context, pathGroup[0].slice(0, -1))
43
+ if (!src.isList) {
44
+ // remove(context)
45
+ // currents = [context]
46
+ currents.map((c) => remove(c))
47
+ continue
48
+ }
49
+ const n = getByPath(context, pathGroup[0]).length
50
+ const nexts = []
51
+ for (const current of currents) {
52
+ for (let i = 0; i < n; ++i) {
53
+ const nxt = _.cloneDeep(current)
54
+ if (true || nxt.isList) {
55
+ for (const path of pathGroup) {
56
+ const value = getByPath(context, path)[i]
57
+ const dest = getByPath(nxt, path.slice(0, -1))
58
+ remove(dest)
59
+ Object.assign(dest, value)
60
+ }
61
+ nexts.push(nxt)
62
+ } else {
63
+ remove(nxt)
64
+ nexts.push(nxt)
65
+ }
66
+ }
67
+ }
68
+ currents = nexts
69
+ }
70
+ return currents
71
+ }
72
+
73
+ module.exports = { remove, flattenInPlace, getPaths }
package/common/wp.js CHANGED
@@ -243,6 +243,7 @@ template = {
243
243
  ],
244
244
  associations: {
245
245
  positive: [
246
+ { context: [["style_wp", 0], ["the", 0], ["letter_wp", 0], ["statefulElementInContext_wp", 0], ["the", 0], ["ordinal", 1], ["word_wp", 0]], choose: { index: 0, increment: true } },
246
247
  { context: [["style_wp", 0], ["the", 0], ["letter_wp", 0], ["statefulElementInContext_wp", 0], ["the", 0], ["ordinal", 1], ["paragraph_wp", 0]], choose: { index: 0, increment: true } },
247
248
 
248
249
  { context: [["style_wp", 0], ["the", 0], ["ordinal", 0], ["word_wp", 0], ["statefulElementInContext_wp", 0], ["the", 0], ["ordinal", 0], ["list", 0], ["ordinal", 0], ["paragraph_wp", 0]], choose: { index: 0, increment: true } },
@@ -502,7 +503,7 @@ knowledgeModule({
502
503
  checks: {
503
504
  context: [defaultContextCheck({ extra: ['distributer', 'subject', 'element', 'letters', 'target', 'conditions' ] })],
504
505
  objects: [
505
- 'changeState',
506
+ { property: 'changeState', all: true },
506
507
  { km: 'ui' },
507
508
  ],
508
509
  },
package/package.json CHANGED
@@ -256,6 +256,7 @@
256
256
  "common/helpers/dateTimeSelectors.js",
257
257
  "common/helpers/dialogues.js",
258
258
  "common/helpers/drone.js",
259
+ "common/helpers/flatten_in_place.js",
259
260
  "common/helpers/formulas.js",
260
261
  "common/helpers/frankenhash.js",
261
262
  "common/helpers/gdefaults.js",
@@ -397,8 +398,8 @@
397
398
  "scriptjs": "^2.5.9",
398
399
  "table": "^6.7.1",
399
400
  "uuid": "^9.0.0",
400
- "theprogrammablemind": "9.7.1-beta.20"
401
+ "theprogrammablemind": "9.7.1-beta.22"
401
402
  },
402
- "version": "9.7.1-beta.20",
403
+ "version": "9.7.1-beta.22",
403
404
  "license": "UNLICENSED"
404
405
  }