theprogrammablemind_4wp 7.5.8-beta.21 → 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 +34 -24
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]
|
@@ -1836,27 +1861,22 @@ class Config {
|
|
1836
1861
|
}
|
1837
1862
|
*/
|
1838
1863
|
const objects = {}
|
1839
|
-
const km = (name) => this.getConfig(name)
|
1840
1864
|
if (config instanceof Config) {
|
1841
1865
|
// const aw = addWord(this.config, config.uuid)
|
1842
|
-
const aw = (word, def) => this.addWord(word, def)
|
1843
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1844
1866
|
this.get('objects').namespaced[config._uuid] = objects
|
1845
1867
|
if (config._api) {
|
1846
1868
|
config._api.objects = objects
|
1847
1869
|
config._api.config = () => this
|
1848
1870
|
}
|
1849
|
-
config.initializerFn(
|
1871
|
+
config.initializerFn(setupInitializerFNArgs(this, { testConfig: config, currentConfig: config, objects, namespace, uuid }))
|
1850
1872
|
} else {
|
1851
1873
|
// const aw = addWord(this.config, this.uuid)
|
1852
|
-
const aw = (word, def) => this.addWord(word, def)
|
1853
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1854
1874
|
this.get('objects').namespaced[this._uuid] = objects
|
1855
1875
|
if (config._api) {
|
1856
1876
|
config._api.objects = objects
|
1857
1877
|
config._api.config = () => this
|
1858
1878
|
}
|
1859
|
-
this.initializerFn(
|
1879
|
+
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, namespace, uuid }))
|
1860
1880
|
}
|
1861
1881
|
})
|
1862
1882
|
this.instances.forEach((instance) => client.processInstance(this, instance))
|
@@ -1865,12 +1885,9 @@ class Config {
|
|
1865
1885
|
initialize ({ force = true } = {}) {
|
1866
1886
|
if (force || !this.wasInitialized) {
|
1867
1887
|
// const aw = addWord(this.config, this.uuid)
|
1868
|
-
const aw = (word, def) => this.addWord(word, def)
|
1869
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
1870
|
-
const km = (name) => this.getConfig(name)
|
1871
1888
|
// this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects: this.get('objects'), uuid: this._uuid, namespace: '', api: this.api })
|
1872
1889
|
const objects = this.config.objects.namespaced[this._uuid]
|
1873
|
-
this.initializerFn(
|
1890
|
+
this.initializerFn(setupInitializerFNArgs(this, { testConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '' }))
|
1874
1891
|
this.wasInitialized = true
|
1875
1892
|
}
|
1876
1893
|
}
|
@@ -2122,27 +2139,24 @@ class Config {
|
|
2122
2139
|
return config
|
2123
2140
|
}
|
2124
2141
|
// const hierarchy = new DigraphInternal((config.config || {}).hierarchy)
|
2125
|
-
const args = new Object({
|
2142
|
+
const args = new Object(setupInitializerFNArgs(this, {
|
2126
2143
|
isModule,
|
2127
|
-
addWord: aw,
|
2128
|
-
addGenerator: ag,
|
2129
|
-
km: kmFn,
|
2130
2144
|
hierarchy: this.hierarchy,
|
2131
2145
|
testConfig: config,
|
2132
|
-
config: this.getPsuedoConfig(),
|
2133
|
-
baseConfig: this,
|
2134
2146
|
currentConfig: config,
|
2135
2147
|
uuid: config._uuid,
|
2136
2148
|
objects: namespacedObjects,
|
2137
2149
|
namespace,
|
2138
2150
|
motivation: (m) => this.addMotivation(m),
|
2139
2151
|
get api() {
|
2152
|
+
/*
|
2140
2153
|
if (!isAfterApi) {
|
2141
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.")
|
2142
2155
|
}
|
2156
|
+
*/
|
2143
2157
|
return config.api
|
2144
2158
|
}
|
2145
|
-
})
|
2159
|
+
}))
|
2146
2160
|
config.initializerFn(args)
|
2147
2161
|
if (config.initAfterApi) {
|
2148
2162
|
// reverse the list
|
@@ -2378,14 +2392,10 @@ class Config {
|
|
2378
2392
|
const km = (name) => this.getConfig(name)
|
2379
2393
|
if (config instanceof Config) {
|
2380
2394
|
// const aw = addWord(this.config, config.uuid)
|
2381
|
-
|
2382
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
2383
|
-
config.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: config, testConfig: config, config: this.getPsuedoConfig(), objects: nsobjects, namespace, uuid, api: config.api })
|
2395
|
+
config.initializerFn(setupInitializerFNArgs(this, { isModule: this.isModule, currentConfig: config, testConfig: config, objects: nsobjects, namespace, uuid }))
|
2384
2396
|
} else {
|
2385
2397
|
// const aw = addWord(this.config, this.uuid)
|
2386
|
-
|
2387
|
-
const ag = (matchOrGenerator, applyOrNothing) => this.addGenerator(matchOrGenerator, applyOrNothing)
|
2388
|
-
this.initializerFn({ isModule: this.isModule, addWord: aw, addGenerator: ag, baseConfig: this, km, currentConfig: this, testConfig: this, config: this.getPsuedoConfig(), objects: nsobjects, namespace, uuid, api: this.api })
|
2398
|
+
this.initializerFn(setupInitializerFNArgs(this, { isModule: this.isModule, currentConfig: this, testConfig: this, objects: nsobjects, namespace, uuid }))
|
2389
2399
|
}
|
2390
2400
|
})
|
2391
2401
|
}
|