theprogrammablemind_4wp 7.5.8-beta.20 → 7.5.8-beta.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/config.js +34 -8
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "json-stable-stringify": "^1.0.1",
64
64
  "node-fetch": "^2.6.1"
65
65
  },
66
- "version": "7.5.8-beta.20",
66
+ "version": "7.5.8-beta.21",
67
67
  "license": "ISC"
68
68
  }
package/src/config.js CHANGED
@@ -581,6 +581,27 @@ class Config {
581
581
  return config_toServer(config)
582
582
  }
583
583
 
584
+ getPsuedoConfig() {
585
+ return {
586
+ description: "this is a pseudo config that has limited functionality due to being available in the initializer function context",
587
+ addAssociation: (...args) => this.addAssociation(...args),
588
+ addAssociations: (...args) => this.addAssociations(...args),
589
+ addBridge: (...args) => this.addBridge(...args),
590
+ addContextualPriority: (...args) => this.addContextualPriority(...args),
591
+ addGenerator: (...args) => this.addGenerator(...args),
592
+ addHierarchy: (...args) => this.addHierarchy(...args),
593
+ addOperator: (...args) => this.addOperator(...args),
594
+ addPriorities: (...args) => this.addPriorities(...args),
595
+ addSemantic: (...args) => this.addSemantic(...args),
596
+ addWord: (...args) => this.addWord(...args),
597
+
598
+ addArgs: (...args) => this.addArgs(...args),
599
+ getBridge: (...args) => this.getBridge(...args),
600
+ fragment: (...args) => this.fragment(...args),
601
+ addAPI: (...args) => this.addAPI(...args),
602
+ }
603
+ }
604
+
584
605
  inDevelopmentMode (call) {
585
606
  config.developmentModeOn += 1
586
607
  try {
@@ -996,7 +1017,11 @@ class Config {
996
1017
  }
997
1018
 
998
1019
  getBridge (id, level) {
999
- return this.config.bridges.find( (bridge) => bridge.id == id && bridge.level == level )
1020
+ if (level) {
1021
+ return this.config.bridges.find( (bridge) => bridge.id == id && bridge.level == level )
1022
+ } else {
1023
+ return this.config.bridges.find( (bridge) => bridge.id == id)
1024
+ }
1000
1025
  }
1001
1026
 
1002
1027
  addBridge (bridge) {
@@ -1821,7 +1846,7 @@ class Config {
1821
1846
  config._api.objects = objects
1822
1847
  config._api.config = () => this
1823
1848
  }
1824
- config.initializerFn({ addWord: aw, addGenerator: ag, km, config, baseConfig: this, currentConfig: config, objects, namespace, uuid, api: config.api })
1849
+ config.initializerFn({ addWord: aw, addGenerator: ag, km, testConfig: config, config: this.getPsuedoConfig(), baseConfig: this, currentConfig: config, objects, namespace, uuid, api: config.api })
1825
1850
  } else {
1826
1851
  // const aw = addWord(this.config, this.uuid)
1827
1852
  const aw = (word, def) => this.addWord(word, def)
@@ -1831,7 +1856,7 @@ class Config {
1831
1856
  config._api.objects = objects
1832
1857
  config._api.config = () => this
1833
1858
  }
1834
- this.initializerFn({ addWord: aw, addGenerator: ag, km, config: this, baseConfig: this, currentConfig: this, objects, namespace, uuid, api: this.api })
1859
+ this.initializerFn({ addWord: aw, addGenerator: ag, km, testConfig: this, config: this.getPsuedoConfig(), baseConfig: this, currentConfig: this, objects, namespace, uuid, api: this.api })
1835
1860
  }
1836
1861
  })
1837
1862
  this.instances.forEach((instance) => client.processInstance(this, instance))
@@ -1845,7 +1870,7 @@ class Config {
1845
1870
  const km = (name) => this.getConfig(name)
1846
1871
  // this.initializerFn({ addWord: aw, km, config: this, baseConfig: this, currentConfig: this, objects: this.get('objects'), uuid: this._uuid, namespace: '', api: this.api })
1847
1872
  const objects = this.config.objects.namespaced[this._uuid]
1848
- this.initializerFn({ addWord: aw, addGenerator: ag, km, config: this, baseConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '', api: this.api })
1873
+ this.initializerFn({ addWord: aw, addGenerator: ag, km, testConfig: this, config: this.getPsuedoConfig(), baseConfig: this, currentConfig: this, objects, uuid: this._uuid, namespace: '', api: this.api })
1849
1874
  this.wasInitialized = true
1850
1875
  }
1851
1876
  }
@@ -2103,13 +2128,14 @@ class Config {
2103
2128
  addGenerator: ag,
2104
2129
  km: kmFn,
2105
2130
  hierarchy: this.hierarchy,
2106
- config,
2131
+ testConfig: config,
2132
+ config: this.getPsuedoConfig(),
2107
2133
  baseConfig: this,
2108
2134
  currentConfig: config,
2109
2135
  uuid: config._uuid,
2110
2136
  objects: namespacedObjects,
2111
2137
  namespace,
2112
- motivation: (m) => config.addMotivation(m),
2138
+ motivation: (m) => this.addMotivation(m),
2113
2139
  get api() {
2114
2140
  if (!isAfterApi) {
2115
2141
  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.")
@@ -2354,12 +2380,12 @@ class Config {
2354
2380
  // const aw = addWord(this.config, config.uuid)
2355
2381
  const aw = (word, def) => this.addWord(word, def)
2356
2382
  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 })
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 })
2358
2384
  } else {
2359
2385
  // const aw = addWord(this.config, this.uuid)
2360
2386
  const aw = (word, def) => this.addWord(word, def)
2361
2387
  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 })
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 })
2363
2389
  }
2364
2390
  })
2365
2391
  }