theprogrammablemind_4wp 8.3.0-beta.5 → 8.3.0-beta.6
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 +62 -40
- package/src/configHelpers.js +0 -1
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -387,32 +387,45 @@ const handleBridgeProps = (config, bridge, { addFirst, uuid } = {}) => {
|
|
387
387
|
config.config.generators.push(addUUID(generator))
|
388
388
|
}
|
389
389
|
}
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
390
|
+
|
391
|
+
const addSemantic = (semantic, evaluate) => {
|
392
|
+
const match = semantic.match || (() => true)
|
393
|
+
let apply = semantic
|
394
|
+
// if I do apply == semantic.apply or semantic there is one function that has apply defined for some reason even though not explicitly set
|
395
|
+
if (semantic.apply && typeof semantic !== 'function') {
|
396
|
+
apply = semantic.apply
|
397
|
+
}
|
398
|
+
const semanticDef = {
|
399
|
+
where: semantic.where || bridge.where || helpers.where(4),
|
400
|
+
match: (args) => bridge.id == args.context.marker && !!args.context.evaluate == evaluate && match(args),
|
401
|
+
apply: (args) => apply(args),
|
402
|
+
applyWrapped: semantic,
|
403
|
+
property: evaluate ? 'evaluator':'semantic',
|
397
404
|
}
|
398
405
|
if (addFirst) {
|
399
|
-
config.config.semantics.unshift(addUUID(
|
406
|
+
config.config.semantics.unshift(addUUID(semanticDef))
|
400
407
|
} else {
|
401
|
-
config.config.semantics.push(addUUID(
|
408
|
+
config.config.semantics.push(addUUID(semanticDef))
|
402
409
|
}
|
403
410
|
}
|
411
|
+
|
412
|
+
if (bridge.evaluator) {
|
413
|
+
addSemantic(bridge.evaluator, true)
|
414
|
+
}
|
415
|
+
|
404
416
|
if (bridge.semantic) {
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
417
|
+
addSemantic(bridge.semantic, false)
|
418
|
+
}
|
419
|
+
|
420
|
+
if (bridge.evaluators) {
|
421
|
+
for (const evaluator of bridge.evaluators) {
|
422
|
+
addSemantic(evaluator, true)
|
411
423
|
}
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
424
|
+
}
|
425
|
+
|
426
|
+
if (bridge.semantics) {
|
427
|
+
for (const semantic of bridge.semantics) {
|
428
|
+
addSemantic(semantic, false)
|
416
429
|
}
|
417
430
|
}
|
418
431
|
}
|
@@ -423,8 +436,8 @@ const handleCalculatedProps = (baseConfig, moreConfig, { addFirst, uuid } = {})
|
|
423
436
|
if (moreConfig.bridges) {
|
424
437
|
moreConfig.bridges = moreConfig.bridges.map((bridge) => {
|
425
438
|
bridge = { ...bridge }
|
426
|
-
const valid = ['after', 'before', 'bridge', 'development', 'evaluator', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'operator', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
427
|
-
'level', 'optional', 'selector', 'semantic', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
|
439
|
+
const valid = ['after', 'before', 'bridge', 'development', 'evaluator', 'evaluators', 'generatorp', 'generatorr', 'generatorpr', 'generators', 'operator', 'id', 'convolution', 'inverted', 'isA', 'children', 'parents',
|
440
|
+
'level', 'optional', 'selector', 'semantic', 'semantics', 'words', /Bridge$/, 'localHierarchy', 'levelSpecificHierarchy', 'where', 'uuid']
|
428
441
|
helpers.validProps(valid, bridge, 'bridge')
|
429
442
|
handleBridgeProps(baseConfig, bridge, { addFirst, uuid })
|
430
443
|
return bridge
|
@@ -1149,44 +1162,53 @@ class Config {
|
|
1149
1162
|
delete bridge.generatorr
|
1150
1163
|
delete bridge.generatorpr
|
1151
1164
|
delete bridge.evaluator
|
1165
|
+
delete bridge.evaluators
|
1152
1166
|
delete bridge.semantic
|
1167
|
+
delete bridge.semantics
|
1153
1168
|
if (!bridge.bridge) {
|
1154
1169
|
bridge.bridge = "{ ...next(operator) }"
|
1155
1170
|
}
|
1156
1171
|
return bridge
|
1157
1172
|
})
|
1158
1173
|
} else {
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1174
|
+
const toCanonical = (def) => {
|
1175
|
+
if (typeof def == 'function') {
|
1176
|
+
return def.toString()
|
1177
|
+
} else if (typeof def == 'string') {
|
1178
|
+
return def
|
1179
|
+
}
|
1180
|
+
def = { ...def }
|
1181
|
+
delete def.where
|
1182
|
+
def.match = def.match ? def.match.toString() : ""
|
1183
|
+
def.apply = def.apply ? def.apply.toString() : ""
|
1184
|
+
return def
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
config.generators = (config.generators || []).map(toCanonical)
|
1188
|
+
config.semantics = (config.semantics || []).map(toCanonical)
|
1173
1189
|
config.bridges = (config.bridges || []).map((bridge) => {
|
1174
1190
|
bridge = { ...bridge }
|
1175
1191
|
delete bridge.where
|
1176
1192
|
if (bridge.generatorp) {
|
1177
|
-
bridge.generatorp = bridge.generatorp
|
1193
|
+
bridge.generatorp = toCanonical(bridge.generatorp)
|
1178
1194
|
}
|
1179
1195
|
if (bridge.generatorr) {
|
1180
|
-
bridge.generatorr = bridge.generatorr
|
1196
|
+
bridge.generatorr = toCanonical(bridge.generatorr)
|
1181
1197
|
}
|
1182
1198
|
if (bridge.generatorpr) {
|
1183
|
-
bridge.generatorpr = bridge.generatorpr
|
1199
|
+
bridge.generatorpr = toCanonical(bridge.generatorpr)
|
1184
1200
|
}
|
1185
1201
|
if (bridge.evaluator) {
|
1186
|
-
bridge.evaluator = bridge.evaluator
|
1202
|
+
bridge.evaluator = toCanonical(bridge.evaluator)
|
1187
1203
|
}
|
1188
1204
|
if (bridge.semantic) {
|
1189
|
-
bridge.semantic = bridge.semantic
|
1205
|
+
bridge.semantic = toCanonical(bridge.semantic)
|
1206
|
+
}
|
1207
|
+
if (bridge.evaluators) {
|
1208
|
+
bridge.evaluators = bridge.evaluators.map(toCanonical).toString()
|
1209
|
+
}
|
1210
|
+
if (bridge.semantics) {
|
1211
|
+
bridge.semantics = bridge.semantics.map(toCanonical).toString()
|
1190
1212
|
}
|
1191
1213
|
return bridge
|
1192
1214
|
})
|
package/src/configHelpers.js
CHANGED
@@ -321,7 +321,6 @@ const processContextsB = async ({ config, hierarchy, semantics, generators, json
|
|
321
321
|
const mostCalled = semantics.getMostCalled()
|
322
322
|
e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
|
323
323
|
}
|
324
|
-
// contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
|
325
324
|
if (isInstance) {
|
326
325
|
console.log('error', e.error)
|
327
326
|
}
|