theprogrammablemind_4wp 9.6.3-beta.24 → 9.6.3-beta.26
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/package.json +1 -1
- package/src/config.js +4 -0
- package/src/configHelpers.js +26 -0
- package/src/semantics.js +8 -1
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -2878,6 +2878,9 @@ class Config {
|
|
|
2878
2878
|
}
|
|
2879
2879
|
|
|
2880
2880
|
getContextChecks() {
|
|
2881
|
+
if (this.getContextChecksCache) {
|
|
2882
|
+
return this.getContextChecksCache
|
|
2883
|
+
}
|
|
2881
2884
|
const allChecks = []
|
|
2882
2885
|
let defaults = () => []
|
|
2883
2886
|
if (this.loadOrdering) {
|
|
@@ -2914,6 +2917,7 @@ class Config {
|
|
|
2914
2917
|
match: () => true,
|
|
2915
2918
|
apply: defaults
|
|
2916
2919
|
})
|
|
2920
|
+
this.getContextChecksCache = allChecks
|
|
2917
2921
|
return allChecks
|
|
2918
2922
|
}
|
|
2919
2923
|
|
package/src/configHelpers.js
CHANGED
|
@@ -86,6 +86,30 @@ const cleanAssign = (dest, ...srcs) => {
|
|
|
86
86
|
Object.assign(dest, ...srcs)
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// handler is a semantic or a generator
|
|
90
|
+
class HandlerStack {
|
|
91
|
+
constructor(handlers = []) {
|
|
92
|
+
this.handlers = [...handlers]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
push(handler) {
|
|
96
|
+
this.handlers.push(handler)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
pop() {
|
|
100
|
+
this.handlers.pop()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
toString() {
|
|
104
|
+
let str = ''
|
|
105
|
+
for (let i = this.handlers.length - 1; i >= 0; --i) {
|
|
106
|
+
str += this.handlers[i].toLabel() + '\n'
|
|
107
|
+
str += this.handlers[i].toString() + '\n\n'
|
|
108
|
+
}
|
|
109
|
+
return str
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
89
113
|
class ContextHierarchy {
|
|
90
114
|
constructor(contexts = []) {
|
|
91
115
|
this.contexts = [...contexts]
|
|
@@ -139,6 +163,7 @@ const setupArgs = (args, config, logs, hierarchy, uuidForScoping) => {
|
|
|
139
163
|
}
|
|
140
164
|
}
|
|
141
165
|
args.contextHierarchy = new ContextHierarchy()
|
|
166
|
+
args.handlerStack = new HandlerStack()
|
|
142
167
|
args.cleanAssign = cleanAssign
|
|
143
168
|
args.km = (name) => config.getConfig(name)
|
|
144
169
|
args.api = (name) => config.getConfig(name).api
|
|
@@ -591,4 +616,5 @@ module.exports = {
|
|
|
591
616
|
loadInstance,
|
|
592
617
|
isA,
|
|
593
618
|
ContextHierarchy,
|
|
619
|
+
HandlerStack,
|
|
594
620
|
}
|
package/src/semantics.js
CHANGED
|
@@ -103,7 +103,14 @@ class Semantic {
|
|
|
103
103
|
if (args.breakOnSemantics) {
|
|
104
104
|
debugger // eslint-disable-line no-debugger
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
try {
|
|
107
|
+
args.handlerStack.push(this)
|
|
108
|
+
await this._apply(args)
|
|
109
|
+
args.handlerStack.pop()
|
|
110
|
+
} catch( e ) {
|
|
111
|
+
args.handlerStack.pop()
|
|
112
|
+
throw e
|
|
113
|
+
}
|
|
107
114
|
return contextPrime
|
|
108
115
|
}
|
|
109
116
|
}
|