theprogrammablemind_4wp 7.5.0-beta.2 → 7.5.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/config.js +11 -32
- package/src/helpers.js +7 -0
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -412,11 +412,11 @@ class Config {
|
|
412
412
|
}
|
413
413
|
|
414
414
|
getSemantics (logs = []) {
|
415
|
-
return new Semantics(this.config.semantics
|
415
|
+
return new Semantics(this.config.semantics, logs, { km: this.name })
|
416
416
|
}
|
417
417
|
|
418
418
|
getGenerators (logs = []) {
|
419
|
-
return new Generators(this.config.generators
|
419
|
+
return new Generators(this.config.generators, logs, { km: this.name })
|
420
420
|
}
|
421
421
|
|
422
422
|
warningNotEvaluated (log, value) {
|
@@ -601,9 +601,6 @@ class Config {
|
|
601
601
|
if (typeof parent !== 'string') {
|
602
602
|
throw `addHierarchy expected parent property to be a string. got ${JSON.stringify(parent)}`
|
603
603
|
}
|
604
|
-
if (!this.config.hierarchy) {
|
605
|
-
this.config.hierarchy = []
|
606
|
-
}
|
607
604
|
if (global.entodictonDebugHierarchy) {
|
608
605
|
if (deepEqual(global.entodictonDebugHierarchy, [child, parent])) {
|
609
606
|
debugger; // debug hierarchy hit
|
@@ -622,9 +619,6 @@ class Config {
|
|
622
619
|
throw `addHierarchy expected parent to be a string. got ${JSON.stringify(parent)}`
|
623
620
|
}
|
624
621
|
|
625
|
-
if (!this.config.hierarchy) {
|
626
|
-
this.config.hierarchy = []
|
627
|
-
}
|
628
622
|
if (global.entodictonDebugHierarchy) {
|
629
623
|
if (deepEqual(global.entodictonDebugHierarchy, [child, parent])) {
|
630
624
|
debugger; // debug hierarchy hit
|
@@ -962,17 +956,11 @@ class Config {
|
|
962
956
|
if (!config) {
|
963
957
|
return
|
964
958
|
}
|
965
|
-
config.operators = config.operators || []
|
966
|
-
config.bridges = config.bridges || []
|
967
|
-
config.words = config.words || {}
|
968
|
-
config.generators = config.generators || []
|
969
|
-
config.semantics = config.semantics || []
|
970
|
-
|
971
959
|
config.operators = config.operators.filter( (element) => !element.development )
|
972
960
|
config.bridges = config.bridges.filter( (element) => !element.development )
|
973
961
|
config.generators = config.generators.filter( (element) => !element.development )
|
974
962
|
config.semantics = config.semantics.filter( (element) => !element.development )
|
975
|
-
config.hierarchy = (config.hierarchy
|
963
|
+
config.hierarchy = (config.hierarchy).filter( (element) => !element.development )
|
976
964
|
for (const word in config.words) {
|
977
965
|
const defs = config.words[word] || []
|
978
966
|
config.words[word] = defs.filter( (def) => !def.development )
|
@@ -1101,16 +1089,7 @@ class Config {
|
|
1101
1089
|
if (config) {
|
1102
1090
|
config = _.cloneDeep(config)
|
1103
1091
|
this.config = config
|
1104
|
-
|
1105
|
-
this.config.generators = []
|
1106
|
-
}
|
1107
|
-
if (!this.config.semantics) {
|
1108
|
-
this.config.semantics = []
|
1109
|
-
}
|
1110
|
-
if (!this.config.words) {
|
1111
|
-
// this.config.words = {}
|
1112
|
-
}
|
1113
|
-
for (let bridge of (this.config.bridges || [])) {
|
1092
|
+
for (let bridge of this.config.bridges) {
|
1114
1093
|
const valid = [ 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generators', 'id', 'inverted', 'isA',
|
1115
1094
|
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy' ]
|
1116
1095
|
helpers.validProps(valid, bridge, 'bridge')
|
@@ -1196,6 +1175,7 @@ class Config {
|
|
1196
1175
|
})
|
1197
1176
|
}
|
1198
1177
|
}
|
1178
|
+
this.hierarchy = new Digraph(this.config.hierarchy)
|
1199
1179
|
this.initConfig = _.cloneDeep(this.config)
|
1200
1180
|
this.configs.push(new KM({ config: this.config, getCounter: (name) => this.config.getCounter(name), uuid: this._uuid }))
|
1201
1181
|
|
@@ -1450,7 +1430,7 @@ class Config {
|
|
1450
1430
|
this.config.bridges && this.config.bridges.forEach((bridge) => { bridge.uuid = this._uuid })
|
1451
1431
|
this.config.words && setWordsUUIDs(this.config.words, this._uuid)
|
1452
1432
|
this.config.operators && this.config.operators.forEach((operator) => { operator.uuid = this._uuid })
|
1453
|
-
const ids = Array.from(new Set(
|
1433
|
+
const ids = Array.from(new Set(this.config.bridges.map((bridge) => bridge.id)))
|
1454
1434
|
ids.sort()
|
1455
1435
|
this.config.namespaces = {}
|
1456
1436
|
// if (true || ids.length > 0) {
|
@@ -1682,7 +1662,7 @@ class Config {
|
|
1682
1662
|
}
|
1683
1663
|
|
1684
1664
|
const kmsUuids = this.configs.map((km) => km.uuid)
|
1685
|
-
const bridgesUuids =
|
1665
|
+
const bridgesUuids = this.config.bridges.map((bridge) => bridge.uuid).filter((uuid) => uuid)
|
1686
1666
|
let result = true
|
1687
1667
|
bridgesUuids.forEach((buuid) => {
|
1688
1668
|
if (!kmsUuids.includes(buuid)) {
|
@@ -1752,6 +1732,7 @@ class Config {
|
|
1752
1732
|
this.resetDelta()
|
1753
1733
|
const debug = this.config.debug;
|
1754
1734
|
this.config = _.cloneDeep(this.initConfig)
|
1735
|
+
this.hierarchy = new Digraph(this.config.hierarchy)
|
1755
1736
|
if (debug) {
|
1756
1737
|
this.config.debug = debug
|
1757
1738
|
}
|
@@ -1811,8 +1792,8 @@ class Config {
|
|
1811
1792
|
config.wasInitialized = false
|
1812
1793
|
// TODO change name of config: to baseConfig:
|
1813
1794
|
const kmFn = (name) => this.getConfig(name)
|
1814
|
-
const hierarchy = new Digraph((config.config || {}).hierarchy
|
1815
|
-
const args = { isModule, addWord: aw, km: kmFn, hierarchy, config, baseConfig: this, currentConfig: config, uuid: config._uuid, objects: namespacedObjects, namespace, api: config.api }
|
1795
|
+
// const hierarchy = new Digraph((config.config || {}).hierarchy)
|
1796
|
+
const args = { isModule, addWord: aw, km: kmFn, hierarchy: this.hierarchy, config, baseConfig: this, currentConfig: config, uuid: config._uuid, objects: namespacedObjects, namespace, api: config.api }
|
1816
1797
|
config.initializerFn(args)
|
1817
1798
|
if (config.initAfterApi) {
|
1818
1799
|
initAfterApis.push({ config, args })
|
@@ -2009,8 +1990,7 @@ class Config {
|
|
2009
1990
|
}
|
2010
1991
|
|
2011
1992
|
if (config.hierarchy) {
|
2012
|
-
|
2013
|
-
hierarchy = hierarchy.map((h) => {
|
1993
|
+
helpers.mapInPlace(config.hierarchy, (h) => {
|
2014
1994
|
if (Array.isArray(h)) {
|
2015
1995
|
return h.map((id) => toNS(id))
|
2016
1996
|
} else {
|
@@ -2019,7 +1999,6 @@ class Config {
|
|
2019
1999
|
return Object.assign({}, h, { child: toNS(h.child), parent: toNS(h.parent) })
|
2020
2000
|
}
|
2021
2001
|
})
|
2022
|
-
config.hierarchy = hierarchy
|
2023
2002
|
}
|
2024
2003
|
|
2025
2004
|
if (config.priorities) {
|
package/src/helpers.js
CHANGED
@@ -232,7 +232,14 @@ const validProps = (valids, object, type) => {
|
|
232
232
|
}
|
233
233
|
}
|
234
234
|
|
235
|
+
const mapInPlace = (list, fn) => {
|
236
|
+
for (let i = 0; i < list.length; ++i) {
|
237
|
+
list[i] =fn(list[i])
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
235
241
|
module.exports = {
|
242
|
+
mapInPlace,
|
236
243
|
validProps,
|
237
244
|
args,
|
238
245
|
safeEquals,
|