@chromahq/core 0.1.4 → 0.1.6
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.cjs.js +33 -4
- package/dist/index.es.js +33 -4
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1197,8 +1197,8 @@ class ApplicationBootstrap {
|
|
|
1197
1197
|
}) {
|
|
1198
1198
|
try {
|
|
1199
1199
|
this.logger.info("\u{1F680} Starting Chroma application bootstrap...");
|
|
1200
|
-
await this.discoverServices();
|
|
1201
1200
|
await this.discoverAndInitializeStores();
|
|
1201
|
+
await this.discoverServices();
|
|
1202
1202
|
await this.validateDependencies();
|
|
1203
1203
|
await this.registerServices();
|
|
1204
1204
|
await this.registerMessages();
|
|
@@ -1270,8 +1270,15 @@ class ApplicationBootstrap {
|
|
|
1270
1270
|
this.logger.info(`Initializing ${this.storeDefinitions.length} store(s)...`);
|
|
1271
1271
|
const chromaGlobal = globalThis.__CHROMA__;
|
|
1272
1272
|
if (chromaGlobal?.initStores && typeof chromaGlobal.initStores === "function") {
|
|
1273
|
+
let isFirstStore = true;
|
|
1273
1274
|
for (const store of this.storeDefinitions) {
|
|
1274
|
-
const { classes } = await chromaGlobal.initStores(store);
|
|
1275
|
+
const { classes, store: storeInstance } = await chromaGlobal.initStores(store);
|
|
1276
|
+
const diKey = `CentralStore:${store.name}`;
|
|
1277
|
+
container.bind(diKey).toConstantValue(storeInstance);
|
|
1278
|
+
if (isFirstStore) {
|
|
1279
|
+
container.bind("CentralStore").toConstantValue(storeInstance);
|
|
1280
|
+
isFirstStore = false;
|
|
1281
|
+
}
|
|
1275
1282
|
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
1276
1283
|
this.registerMessageClass(classes.SetStoreStateMessage, `store:${store.name}:setState`);
|
|
1277
1284
|
this.registerMessageClass(
|
|
@@ -1306,16 +1313,38 @@ class ApplicationBootstrap {
|
|
|
1306
1313
|
const constructorString = ServiceClass.toString();
|
|
1307
1314
|
const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
|
|
1308
1315
|
if (!constructorMatch) return [];
|
|
1309
|
-
const parameters = constructorMatch[1].split(",").map((param) => param.trim()
|
|
1316
|
+
const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
|
|
1310
1317
|
const dependencies = [];
|
|
1311
1318
|
for (const param of parameters) {
|
|
1319
|
+
const paramName = param.toLowerCase();
|
|
1320
|
+
if (paramName === "store" || paramName.startsWith("store")) {
|
|
1321
|
+
let storeInstance;
|
|
1322
|
+
if (paramName === "store" && container.isBound("CentralStore")) {
|
|
1323
|
+
storeInstance = container.get("CentralStore");
|
|
1324
|
+
} else {
|
|
1325
|
+
const storeKeyMatch = paramName.match(/^store(.+)$/);
|
|
1326
|
+
if (storeKeyMatch && storeKeyMatch[1]) {
|
|
1327
|
+
const storeName = storeKeyMatch[1].replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
1328
|
+
const diKey = `CentralStore:${storeName}`;
|
|
1329
|
+
if (container.isBound(diKey)) {
|
|
1330
|
+
storeInstance = container.get(diKey);
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
if (!storeInstance) {
|
|
1335
|
+
this.logger.warn(`\u26A0\uFE0F No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1336
|
+
}
|
|
1337
|
+
dependencies.push(storeInstance);
|
|
1338
|
+
continue;
|
|
1339
|
+
}
|
|
1312
1340
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
1313
|
-
([name]) => name.toLowerCase() ===
|
|
1341
|
+
([name]) => name.toLowerCase() === paramName
|
|
1314
1342
|
);
|
|
1315
1343
|
if (matchingService) {
|
|
1316
1344
|
dependencies.push(matchingService[1]);
|
|
1317
1345
|
} else {
|
|
1318
1346
|
this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1347
|
+
dependencies.push(void 0);
|
|
1319
1348
|
}
|
|
1320
1349
|
}
|
|
1321
1350
|
return dependencies;
|
package/dist/index.es.js
CHANGED
|
@@ -1195,8 +1195,8 @@ class ApplicationBootstrap {
|
|
|
1195
1195
|
}) {
|
|
1196
1196
|
try {
|
|
1197
1197
|
this.logger.info("\u{1F680} Starting Chroma application bootstrap...");
|
|
1198
|
-
await this.discoverServices();
|
|
1199
1198
|
await this.discoverAndInitializeStores();
|
|
1199
|
+
await this.discoverServices();
|
|
1200
1200
|
await this.validateDependencies();
|
|
1201
1201
|
await this.registerServices();
|
|
1202
1202
|
await this.registerMessages();
|
|
@@ -1268,8 +1268,15 @@ class ApplicationBootstrap {
|
|
|
1268
1268
|
this.logger.info(`Initializing ${this.storeDefinitions.length} store(s)...`);
|
|
1269
1269
|
const chromaGlobal = globalThis.__CHROMA__;
|
|
1270
1270
|
if (chromaGlobal?.initStores && typeof chromaGlobal.initStores === "function") {
|
|
1271
|
+
let isFirstStore = true;
|
|
1271
1272
|
for (const store of this.storeDefinitions) {
|
|
1272
|
-
const { classes } = await chromaGlobal.initStores(store);
|
|
1273
|
+
const { classes, store: storeInstance } = await chromaGlobal.initStores(store);
|
|
1274
|
+
const diKey = `CentralStore:${store.name}`;
|
|
1275
|
+
container.bind(diKey).toConstantValue(storeInstance);
|
|
1276
|
+
if (isFirstStore) {
|
|
1277
|
+
container.bind("CentralStore").toConstantValue(storeInstance);
|
|
1278
|
+
isFirstStore = false;
|
|
1279
|
+
}
|
|
1273
1280
|
this.registerMessageClass(classes.GetStoreStateMessage, `store:${store.name}:getState`);
|
|
1274
1281
|
this.registerMessageClass(classes.SetStoreStateMessage, `store:${store.name}:setState`);
|
|
1275
1282
|
this.registerMessageClass(
|
|
@@ -1304,16 +1311,38 @@ class ApplicationBootstrap {
|
|
|
1304
1311
|
const constructorString = ServiceClass.toString();
|
|
1305
1312
|
const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
|
|
1306
1313
|
if (!constructorMatch) return [];
|
|
1307
|
-
const parameters = constructorMatch[1].split(",").map((param) => param.trim()
|
|
1314
|
+
const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
|
|
1308
1315
|
const dependencies = [];
|
|
1309
1316
|
for (const param of parameters) {
|
|
1317
|
+
const paramName = param.toLowerCase();
|
|
1318
|
+
if (paramName === "store" || paramName.startsWith("store")) {
|
|
1319
|
+
let storeInstance;
|
|
1320
|
+
if (paramName === "store" && container.isBound("CentralStore")) {
|
|
1321
|
+
storeInstance = container.get("CentralStore");
|
|
1322
|
+
} else {
|
|
1323
|
+
const storeKeyMatch = paramName.match(/^store(.+)$/);
|
|
1324
|
+
if (storeKeyMatch && storeKeyMatch[1]) {
|
|
1325
|
+
const storeName = storeKeyMatch[1].replace(/^([A-Z])/, (m) => m.toLowerCase());
|
|
1326
|
+
const diKey = `CentralStore:${storeName}`;
|
|
1327
|
+
if (container.isBound(diKey)) {
|
|
1328
|
+
storeInstance = container.get(diKey);
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (!storeInstance) {
|
|
1333
|
+
this.logger.warn(`\u26A0\uFE0F No store found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1334
|
+
}
|
|
1335
|
+
dependencies.push(storeInstance);
|
|
1336
|
+
continue;
|
|
1337
|
+
}
|
|
1310
1338
|
const matchingService = Array.from(this.serviceRegistry.entries()).find(
|
|
1311
|
-
([name]) => name.toLowerCase() ===
|
|
1339
|
+
([name]) => name.toLowerCase() === paramName
|
|
1312
1340
|
);
|
|
1313
1341
|
if (matchingService) {
|
|
1314
1342
|
dependencies.push(matchingService[1]);
|
|
1315
1343
|
} else {
|
|
1316
1344
|
this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
|
|
1345
|
+
dependencies.push(void 0);
|
|
1317
1346
|
}
|
|
1318
1347
|
}
|
|
1319
1348
|
return dependencies;
|