@cnstra/core 2.0.1 → 2.2.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/README.md +40 -0
- package/dist/CNSPersistOptionsRegistry.d.ts +6 -0
- package/dist/CNSPersistOptionsRegistry.d.ts.map +1 -1
- package/dist/factory/index.d.ts +25 -0
- package/dist/factory/index.d.ts.map +1 -1
- package/dist/index.cjs +87 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/{CNSDrainGuard.d.ts → CNSStimulationGate.d.ts} +6 -6
- package/dist/utils/CNSStimulationGate.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/utils/CNSDrainGuard.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -948,6 +948,72 @@ var CNS = class {
|
|
|
948
948
|
}
|
|
949
949
|
};
|
|
950
950
|
|
|
951
|
+
// src/CNSPersistOptionsRegistry.ts
|
|
952
|
+
var CNSPersistOptionsRegistry = class {
|
|
953
|
+
constructor() {
|
|
954
|
+
this.neurons = /* @__PURE__ */ new Map();
|
|
955
|
+
this.neuronNames = /* @__PURE__ */ new WeakMap();
|
|
956
|
+
this.collaterals = /* @__PURE__ */ new Map();
|
|
957
|
+
this.stimulations = /* @__PURE__ */ new Map();
|
|
958
|
+
}
|
|
959
|
+
addNeuron(neuron2, options) {
|
|
960
|
+
this.neurons.set(options.name, neuron2);
|
|
961
|
+
this.neuronNames.set(neuron2, options.name);
|
|
962
|
+
}
|
|
963
|
+
getNeuron(name) {
|
|
964
|
+
return this.neurons.get(name);
|
|
965
|
+
}
|
|
966
|
+
getNeuronName(neuron2) {
|
|
967
|
+
return this.neuronNames.get(neuron2);
|
|
968
|
+
}
|
|
969
|
+
getNamedNeurons() {
|
|
970
|
+
return this.neurons;
|
|
971
|
+
}
|
|
972
|
+
getCollateralName(collateral2) {
|
|
973
|
+
for (const [name, col] of this.collaterals) {
|
|
974
|
+
if (col === collateral2) return name;
|
|
975
|
+
}
|
|
976
|
+
return void 0;
|
|
977
|
+
}
|
|
978
|
+
removeNeuron(name) {
|
|
979
|
+
const neuron2 = this.neurons.get(name);
|
|
980
|
+
if (neuron2) this.neuronNames.delete(neuron2);
|
|
981
|
+
this.neurons.delete(name);
|
|
982
|
+
}
|
|
983
|
+
addCollateral(collateral2, options) {
|
|
984
|
+
this.collaterals.set(options.name, collateral2);
|
|
985
|
+
}
|
|
986
|
+
getCollateral(name) {
|
|
987
|
+
return this.collaterals.get(name);
|
|
988
|
+
}
|
|
989
|
+
removeCollateral(name) {
|
|
990
|
+
this.collaterals.delete(name);
|
|
991
|
+
}
|
|
992
|
+
addStimulation(stimulation, options) {
|
|
993
|
+
this.stimulations.set(options.stimulationId, stimulation);
|
|
994
|
+
}
|
|
995
|
+
getStimulation(stimulationId) {
|
|
996
|
+
return this.stimulations.get(stimulationId);
|
|
997
|
+
}
|
|
998
|
+
removeStimulation(stimulationId) {
|
|
999
|
+
this.stimulations.delete(stimulationId);
|
|
1000
|
+
}
|
|
1001
|
+
register(name, neuron2, collateralNames) {
|
|
1002
|
+
this.addNeuron(neuron2, { name, neuron: neuron2 });
|
|
1003
|
+
for (const [key, col] of Object.entries(neuron2.axon)) {
|
|
1004
|
+
this.addCollateral(col, {
|
|
1005
|
+
name: collateralNames?.[key] ?? key,
|
|
1006
|
+
collateral: col
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
return this;
|
|
1010
|
+
}
|
|
1011
|
+
registerCollateral(name, collateral2) {
|
|
1012
|
+
this.addCollateral(collateral2, { name, collateral: collateral2 });
|
|
1013
|
+
return this;
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
|
|
951
1017
|
// src/CNSCollateral.ts
|
|
952
1018
|
var CNSCollateral = class {
|
|
953
1019
|
createSignal(payload) {
|
|
@@ -955,8 +1021,8 @@ var CNSCollateral = class {
|
|
|
955
1021
|
}
|
|
956
1022
|
};
|
|
957
1023
|
|
|
958
|
-
// src/utils/
|
|
959
|
-
var
|
|
1024
|
+
// src/utils/CNSStimulationGate.ts
|
|
1025
|
+
var CNSStimulationGate = class {
|
|
960
1026
|
constructor(guardOptions) {
|
|
961
1027
|
this.guardOptions = guardOptions;
|
|
962
1028
|
}
|
|
@@ -1146,7 +1212,23 @@ var modality = (afferentPaths) => {
|
|
|
1146
1212
|
afferentPaths
|
|
1147
1213
|
};
|
|
1148
1214
|
};
|
|
1215
|
+
var createPersistRegistry = (namedNeurons) => {
|
|
1216
|
+
const registry = new CNSPersistOptionsRegistry();
|
|
1217
|
+
for (const [name, entry] of Object.entries(namedNeurons)) {
|
|
1218
|
+
const isEntry = "neuron" in entry && !("axon" in entry);
|
|
1219
|
+
const neuron2 = isEntry ? entry.neuron : entry;
|
|
1220
|
+
const colNames = isEntry ? entry.collaterals ?? {} : {};
|
|
1221
|
+
registry.addNeuron(neuron2, { name, neuron: neuron2 });
|
|
1222
|
+
for (const [key, col] of Object.entries(neuron2.axon)) {
|
|
1223
|
+
registry.addCollateral(col, {
|
|
1224
|
+
name: colNames[key] ?? key,
|
|
1225
|
+
collateral: col
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
return registry;
|
|
1230
|
+
};
|
|
1149
1231
|
|
|
1150
|
-
export { CNS, CNSCollateral,
|
|
1232
|
+
export { CNS, CNSCollateral, CNSPersistOptionsRegistry, CNSStimulationContextStore, CNSStimulationGate, afferentPath, collateral, createPersistRegistry, modality, neuron, withCtx };
|
|
1151
1233
|
//# sourceMappingURL=index.js.map
|
|
1152
1234
|
//# sourceMappingURL=index.js.map
|