theprogrammablemind_4wp 7.5.8-beta.20 → 7.5.8-beta.22
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 -26
package/package.json
CHANGED
package/src/config.js
CHANGED
@@ -30,6 +30,31 @@ const config_toServer = (config) => {
|
|
30
30
|
}
|
31
31
|
}
|
32
32
|
|
33
|
+
const setupInitializerFNArgs = (config, args) => {
|
34
|
+
const aw = (word, def) => config.addWord(word, def)
|
35
|
+
const ag = (matchOrGenerator, applyOrNothing) => config.addGenerator(matchOrGenerator, applyOrNothing)
|
36
|
+
const km = (name) => config.getConfig(name)
|
37
|
+
const apis = (name) => {
|
38
|
+
return config.getConfig(name).api
|
39
|
+
/*
|
40
|
+
if (args.isAfterApi) {
|
41
|
+
return config.getConfig(name).api
|
42
|
+
}
|
43
|
+
throw new Error("APIs should not be accessed in the initializer until after they are all initialized. Call initializer like config.initializer(fn, { initAfterApi: true }). Then the args to the initalizer will include isAfterApi which can be used to determine if the initialize is being run before or after the API's are initialized. The default is before.")
|
44
|
+
*/
|
45
|
+
}
|
46
|
+
|
47
|
+
return {
|
48
|
+
...args,
|
49
|
+
addWord: aw,
|
50
|
+
addGenerator: ag,
|
51
|
+
config: config.getPsuedoConfig(),
|
52
|
+
km,
|
53
|
+
baseConfig: config,
|
54
|
+
apis,
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
33
58
|
const contextual_priorities_toServer = (cp) => {
|
34
59
|
if (cp.context && cp.choose) {
|
35
60
|
return [cp.context, cp.choose]
|
@@ -581,6 +606,27 @@ class Config {
|
|
581
606
|
return config_toServer(config)
|
582
607
|
}
|
583
608
|
|
609
|
+
getPsuedoConfig() {
|
610
|
+
return {
|
611
|
+
description: "this is a pseudo config that has limited functionality due to being available in the initializer function context",
|
612
|
+
addAssociation: (...args) => this.addAssociation(...args),
|
613
|
+
addAssociations: (...args) => this.addAssociations(...args),
|
614
|
+
addBridge: (...args) => this.addBridge(...args),
|
615
|
+
addContextualPriority: (...args) => this.addContextualPriority(...args),
|
616
|
+
addGenerator: (...args) => this.addGenerator(...args),
|
617
|
+
addHierarchy: (...args) => this.addHierarchy(...args),
|
618
|
+
addOperator: (...args) => this.addOperator(...args),
|
619
|
+
addPriorities: (...args) => this.addPriorities(...args),
|
620
|
+
addSemantic: (...args) => this.addSemantic(...args),
|
621
|
+
addWord: (...args) => this.addWord(...args),
|
622
|
+
|
623
|
+
addArgs: (...args) => this.addArgs(...args),
|
624
|
+
getBridge: (...args) => this.getBridge(...args),
|
625
|
+
fragment: (...args) => this.fragment(...args),
|
626
|
+
addAPI: (...args) => this.addAPI(...args),
|
627
|
+
}
|
628
|
+
}
|
629
|
+
|
584
630
|
inDevelopmentMode (call) {
|
585
631
|
config.developmentModeOn += 1
|
586
632
|
try {
|
@@ -996,7 +1042,11 @@ class Config {
|
|
996
1042
|
}
|
997
1043
|
|
998
1044
|
getBridge (id, level) {
|
999
|
-
|
1045
|
+
if (level) {
|
1046
|
+
return this.config.bridges.find( (bridge) => bridge.id == id && bridge.level == level )
|
1047
|
+
} else {
|
1048
|
+
return this.config.bridges.find( (bridge) => bridge.id == id)
|
1049
|
+
}
|
1000
1050
|
}
|
1001
1051
|
|
1002
1052
|
addBridge (bridge) {
|
@@ -1811,27 +1861,22 @@ class Config {
|
|
1811
1861
|
}
|
1812
1862
|
*/
|
1813
1863
|
const objects = {}
|
1814
|
-
const km = (name) => this.getConfig(name)
|
1815
1864
|
if (config instanceof Config) {
|
1816
1865
|
// const aw = addWord(this.config, config.uuid)
|
1817
|
-
const aw = (word, def) => this.addWord(word, def)
|
1818
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1819
1866
|
this.get('objects').namespaced[config._uuid] = objects
|
1820
1867
|
if (config._api) {
|
1821
1868
|
config._api.objects = objects
|
1822
1869
|
config._api.config = () => this
|
1823
1870
|
}
|
1824
|
-
config.initializerFn({
|
1871
|
+
config.initializerFn(setupInitializerFNArgs(this, { testConfig: config, currentConfig: config, objects, namespace, uuid }))
|
1825
1872
|
} else {
|
1826
1873
|
// const aw = addWord(this.config, this.uuid)
|
1827
|
-
const aw = (word, def) => this.addWord(word, def)
|
1828
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1829
1874
|
this.get('objects').namespaced[this._uuid] = objects
|
1830
1875
|
if (config._api) {
|
1831
1876
|
config._api.objects = objects
|
1832
1877
|
config._api.config = () => this
|
1833
1878
|
}
|
1834
|
-
this.initializerFn(
|
1879
|
+
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, namespace, uuid }))
|
1835
1880
|
}
|
1836
1881
|
})
|
1837
1882
|
this.instances.forEach((instance) => client.processInstance(this, instance))
|
@@ -1840,12 +1885,9 @@ class Config {
|
|
1840
1885
|
initialize ({ force = true } = {}) {
|
1841
1886
|
if (force || !this.wasInitialized) {
|
1842
1887
|
// const aw = addWord(this.config, this.uuid)
|
1843
|
-
const aw = (word, def) => this.addWord(word, def)
|
1844
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1845
|
-
const km = (name) => this.getConfig(name)
|
1846
1888
|
// this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects: this.get('objects'), uuid: this._uuid, namespace: '', api: this.api })
|
1847
1889
|
const objects = this.config.objects.namespaced[this._uuid]
|
1848
|
-
this.initializerFn(
|
1890
|
+
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '' }))
|
1849
1891
|
this.wasInitialized = true
|
1850
1892
|
}
|
1851
1893
|
}
|
@@ -2097,26 +2139,24 @@ class Config {
|
|
2097
2139
|
return config
|
2098
2140
|
}
|
2099
2141
|
// const hierarchy = new DigraphInternal((config.config || {}).hierarchy)
|
2100
|
-
const args = new Object({
|
2142
|
+
const args = new Object(setupInitializerFNArgs(this, {
|
2101
2143
|
isModule,
|
2102
|
-
addWord: aw,
|
2103
|
-
addGenerator: ag,
|
2104
|
-
km: kmFn,
|
2105
2144
|
hierarchy: this.hierarchy,
|
2106
|
-
config,
|
2107
|
-
baseConfig: this,
|
2145
|
+
testConfig: config,
|
2108
2146
|
currentConfig: config,
|
2109
2147
|
uuid: config._uuid,
|
2110
2148
|
objects: namespacedObjects,
|
2111
2149
|
namespace,
|
2112
|
-
motivation: (m) =>
|
2150
|
+
motivation: (m) => this.addMotivation(m),
|
2113
2151
|
get api() {
|
2152
|
+
/*
|
2114
2153
|
if (!isAfterApi) {
|
2115
2154
|
throw new Error("APIs should not be accessed in the initializer until after they are all initialized. Call initializer like config.initializer(fn, { initAfterApi: true }). Then the args to the initalizer will include isAfterApi which can be used to determine if the initialize is being run before or after the API's are initialized. The default is before.")
|
2116
2155
|
}
|
2156
|
+
*/
|
2117
2157
|
return config.api
|
2118
2158
|
}
|
2119
|
-
})
|
2159
|
+
}))
|
2120
2160
|
config.initializerFn(args)
|
2121
2161
|
if (config.initAfterApi) {
|
2122
2162
|
// reverse the list
|
@@ -2352,14 +2392,10 @@ class Config {
|
|
2352
2392
|
const km = (name) => this.getConfig(name)
|
2353
2393
|
if (config instanceof Config) {
|
2354
2394
|
// const aw = addWord(this.config, config.uuid)
|
2355
|
-
|
2356
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
2357
|
-
config.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: config, config, objects: nsobjects, namespace, uuid, api: config.api })
|
2395
|
+
config.initializerFn(setupInitializerFNArgs(this, { isModule: this.isModule, currentConfig: config, testConfig: config, objects: nsobjects, namespace, uuid }))
|
2358
2396
|
} else {
|
2359
2397
|
// const aw = addWord(this.config, this.uuid)
|
2360
|
-
|
2361
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
2362
|
-
this.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: this, config: this, objects: nsobjects, namespace, uuid, api: this.api })
|
2398
|
+
this.initializerFn(setupInitializerFNArgs(this, { isModule: this.isModule, currentConfig: this, testConfig: this, objects: nsobjects, namespace, uuid }))
|
2363
2399
|
}
|
2364
2400
|
})
|
2365
2401
|
}
|