@cnstra/core 2.3.0 → 2.4.0

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/dist/index.d.ts CHANGED
@@ -7,6 +7,7 @@ export type { ICNS } from './interfaces/ICNS';
7
7
  export type { TCNSNeuron } from './types/TCNSNeuron';
8
8
  export type { TCNSAxon } from './types/TCNSAxon';
9
9
  export type { TCNSDendrite } from './types/TCNSDendrite';
10
+ export type { TCNSHandlerContext } from './types/TCNSHandlerContext';
10
11
  export type { TCNSSignal } from './types/TCNSSignal';
11
12
  export type { TCNSNeuronActivationTask } from './types/TCNSNeuronActivationTask';
12
13
  export type { TCNSStimulationOptions } from './types/TCNSStimulationOptions';
@@ -15,5 +16,6 @@ export type { TCNSAfferentPath } from './types/TCNSAfferentPath';
15
16
  export type { TCNSNeuronActivationTaskFailure } from './types/TCNSNeuronActivationTaskFailure';
16
17
  export type { TCNSNeuronPersistOptions, TCNSCollateralPersistOptions, TCNSStimulationPersistOptions } from './types/TCNSPersist';
17
18
  export type { TCNSStimulationGateOptions, TCNSStimulationGateSignal } from './utils/CNSStimulationGate';
18
- export { collateral, neuron, withCtx, afferentPath, modality, createPersistRegistry, } from './factory/index';
19
+ export { collateral, neuron, neuronFactory, withCtx, withGlobal, afferentPath, modality, createPersistRegistry, createCNS, } from './factory/index';
20
+ export type { TNeuronFactory } from './factory/index';
19
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,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E,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AACjF,YAAY,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAC7E,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,YAAY,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC/F,YAAY,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACjI,YAAY,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAGxG,OAAO,EACH,UAAU,EACV,MAAM,EACN,aAAa,EACb,OAAO,EACP,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,qBAAqB,EACrB,SAAS,GACZ,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -31,6 +31,12 @@ var CNSDendriteContext = class {
31
31
  this.abortSignal = abortSignal;
32
32
  this.cns = cns;
33
33
  }
34
+ // Prototype getter, not a constructor field: the per-activation allocation is
35
+ // unchanged (still 4 fields) and you only pay a single `cns.global` read on the
36
+ // dendrites that actually reach for it. Value getter, so `{ global }` destructuring is safe.
37
+ get global() {
38
+ return this.cns.global;
39
+ }
34
40
  get() {
35
41
  return this.stimulation.getContext().get(this.neuron);
36
42
  }
@@ -942,7 +948,7 @@ var CNSNetwork = class {
942
948
 
943
949
  // src/CNS.ts
944
950
  var CNS = class {
945
- constructor(neurons, options) {
951
+ constructor(neurons, options, global) {
946
952
  this.neurons = neurons;
947
953
  this.options = options;
948
954
  /**
@@ -955,6 +961,7 @@ var CNS = class {
955
961
  */
956
962
  this.globalResponseListeners = [];
957
963
  this.network = new CNSNetwork(this.neurons);
964
+ this.global = global;
958
965
  }
959
966
  addResponseListener(listener) {
960
967
  this.globalResponseListeners.push(listener);
@@ -1280,11 +1287,16 @@ var neuron = (axon) => {
1280
1287
  };
1281
1288
  return api;
1282
1289
  };
1283
- var withCtx = () => ({
1284
- neuron: (axon) => {
1285
- return neuron(axon);
1286
- }
1287
- });
1290
+ var neuronFactory = () => {
1291
+ const factory = {
1292
+ withCtx: () => factory,
1293
+ withGlobal: () => factory,
1294
+ neuron: (axon) => neuron(axon)
1295
+ };
1296
+ return factory;
1297
+ };
1298
+ var withCtx = () => neuronFactory();
1299
+ var withGlobal = () => neuronFactory();
1288
1300
  var afferentPath = (parentAfferentPath) => {
1289
1301
  return {
1290
1302
  ...parentAfferentPath !== void 0 && {
@@ -1313,7 +1325,15 @@ var createPersistRegistry = (namedNeurons) => {
1313
1325
  }
1314
1326
  return registry;
1315
1327
  };
1328
+ var createCNS = (namedNeurons, options) => {
1329
+ const neurons = Object.values(namedNeurons).map(
1330
+ (entry) => entry && typeof entry === "object" && "neuron" in entry ? entry.neuron : entry
1331
+ );
1332
+ const cns = new CNS(neurons, options, options?.global);
1333
+ const registry = createPersistRegistry(namedNeurons);
1334
+ return { cns, registry };
1335
+ };
1316
1336
 
1317
- export { CNS, CNSCollateral, CNSPersistOptionsRegistry, CNSStimulationContextStore, CNSStimulationGate, afferentPath, collateral, createPersistRegistry, modality, neuron, withCtx };
1337
+ export { CNS, CNSCollateral, CNSPersistOptionsRegistry, CNSStimulationContextStore, CNSStimulationGate, afferentPath, collateral, createCNS, createPersistRegistry, modality, neuron, neuronFactory, withCtx, withGlobal };
1318
1338
  //# sourceMappingURL=index.js.map
1319
1339
  //# sourceMappingURL=index.js.map