@chromahq/core 0.1.5 → 0.1.7

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 CHANGED
@@ -1313,16 +1313,29 @@ class ApplicationBootstrap {
1313
1313
  const constructorString = ServiceClass.toString();
1314
1314
  const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
1315
1315
  if (!constructorMatch) return [];
1316
- const parameters = constructorMatch[1].split(",").map((param) => param.trim().toLowerCase()).filter((param) => param.length > 0);
1316
+ const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
1317
1317
  const dependencies = [];
1318
1318
  for (const param of parameters) {
1319
+ const paramName = param.toLowerCase();
1320
+ if (paramName === "appstore") {
1321
+ let storeInstance;
1322
+ if (paramName === "appstore" && container.isBound("CentralStore")) {
1323
+ storeInstance = container.get("CentralStore");
1324
+ if (!storeInstance) {
1325
+ throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
1326
+ }
1327
+ Reflect.defineMetadata("name", param, storeInstance);
1328
+ }
1329
+ continue;
1330
+ }
1319
1331
  const matchingService = Array.from(this.serviceRegistry.entries()).find(
1320
- ([name]) => name.toLowerCase() === param
1332
+ ([name]) => name.toLowerCase() === paramName
1321
1333
  );
1322
1334
  if (matchingService) {
1323
1335
  dependencies.push(matchingService[1]);
1324
1336
  } else {
1325
1337
  this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
1338
+ dependencies.push(void 0);
1326
1339
  }
1327
1340
  }
1328
1341
  return dependencies;
@@ -1436,6 +1449,9 @@ class ApplicationBootstrap {
1436
1449
  serviceMetadata.dependencies.forEach((dependency, index) => {
1437
1450
  b(_$1(dependency), ServiceClass, index);
1438
1451
  });
1452
+ if (container.isBound("CentralStore")) {
1453
+ b(_$1("CentralStore"), ServiceClass, serviceMetadata.dependencies.length);
1454
+ }
1439
1455
  container.bind(ServiceClass).toSelf().inSingletonScope();
1440
1456
  serviceMetadata.registered = true;
1441
1457
  this.logger.success(`\u2705 Registered service: ${ServiceClass.name}`);
@@ -1497,6 +1513,9 @@ class ApplicationBootstrap {
1497
1513
  dependencies.forEach((dependency, index) => {
1498
1514
  b(_$1(dependency), MessageClass, index);
1499
1515
  });
1516
+ if (container.isBound("CentralStore")) {
1517
+ b(_$1("CentralStore"), MessageClass, dependencies.length);
1518
+ }
1500
1519
  const messageMetadata = Reflect.getMetadata("name", MessageClass);
1501
1520
  const messageName = messageMetadata || MessageClass.name;
1502
1521
  container.bind(messageName).to(MessageClass).inSingletonScope();
@@ -1555,6 +1574,9 @@ class ApplicationBootstrap {
1555
1574
  dependencies.forEach((dependency, index) => {
1556
1575
  b(_$1(dependency), JobClass, index);
1557
1576
  });
1577
+ if (container.isBound("CentralStore")) {
1578
+ b(_$1("CentralStore"), JobClass, dependencies.length);
1579
+ }
1558
1580
  const jobMetadata = Reflect.getMetadata("name", JobClass);
1559
1581
  const jobName = jobMetadata || JobClass.name;
1560
1582
  container.bind(JobClass).toSelf().inSingletonScope();
package/dist/index.es.js CHANGED
@@ -1311,16 +1311,29 @@ class ApplicationBootstrap {
1311
1311
  const constructorString = ServiceClass.toString();
1312
1312
  const constructorMatch = constructorString.match(/constructor\s*\(([^)]*)\)/);
1313
1313
  if (!constructorMatch) return [];
1314
- const parameters = constructorMatch[1].split(",").map((param) => param.trim().toLowerCase()).filter((param) => param.length > 0);
1314
+ const parameters = constructorMatch[1].split(",").map((param) => param.trim()).filter((param) => param.length > 0);
1315
1315
  const dependencies = [];
1316
1316
  for (const param of parameters) {
1317
+ const paramName = param.toLowerCase();
1318
+ if (paramName === "appstore") {
1319
+ let storeInstance;
1320
+ if (paramName === "appstore" && container.isBound("CentralStore")) {
1321
+ storeInstance = container.get("CentralStore");
1322
+ if (!storeInstance) {
1323
+ throw new Error(`No store found for parameter "${param}" in ${ServiceClass.name}`);
1324
+ }
1325
+ Reflect.defineMetadata("name", param, storeInstance);
1326
+ }
1327
+ continue;
1328
+ }
1317
1329
  const matchingService = Array.from(this.serviceRegistry.entries()).find(
1318
- ([name]) => name.toLowerCase() === param
1330
+ ([name]) => name.toLowerCase() === paramName
1319
1331
  );
1320
1332
  if (matchingService) {
1321
1333
  dependencies.push(matchingService[1]);
1322
1334
  } else {
1323
1335
  this.logger.warn(`\u26A0\uFE0F No service found for parameter "${param}" in ${ServiceClass.name}`);
1336
+ dependencies.push(void 0);
1324
1337
  }
1325
1338
  }
1326
1339
  return dependencies;
@@ -1434,6 +1447,9 @@ class ApplicationBootstrap {
1434
1447
  serviceMetadata.dependencies.forEach((dependency, index) => {
1435
1448
  b(_$1(dependency), ServiceClass, index);
1436
1449
  });
1450
+ if (container.isBound("CentralStore")) {
1451
+ b(_$1("CentralStore"), ServiceClass, serviceMetadata.dependencies.length);
1452
+ }
1437
1453
  container.bind(ServiceClass).toSelf().inSingletonScope();
1438
1454
  serviceMetadata.registered = true;
1439
1455
  this.logger.success(`\u2705 Registered service: ${ServiceClass.name}`);
@@ -1495,6 +1511,9 @@ class ApplicationBootstrap {
1495
1511
  dependencies.forEach((dependency, index) => {
1496
1512
  b(_$1(dependency), MessageClass, index);
1497
1513
  });
1514
+ if (container.isBound("CentralStore")) {
1515
+ b(_$1("CentralStore"), MessageClass, dependencies.length);
1516
+ }
1498
1517
  const messageMetadata = Reflect.getMetadata("name", MessageClass);
1499
1518
  const messageName = messageMetadata || MessageClass.name;
1500
1519
  container.bind(messageName).to(MessageClass).inSingletonScope();
@@ -1553,6 +1572,9 @@ class ApplicationBootstrap {
1553
1572
  dependencies.forEach((dependency, index) => {
1554
1573
  b(_$1(dependency), JobClass, index);
1555
1574
  });
1575
+ if (container.isBound("CentralStore")) {
1576
+ b(_$1("CentralStore"), JobClass, dependencies.length);
1577
+ }
1556
1578
  const jobMetadata = Reflect.getMetadata("name", JobClass);
1557
1579
  const jobName = jobMetadata || JobClass.name;
1558
1580
  container.bind(JobClass).toSelf().inSingletonScope();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chromahq/core",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Core library for building Chrome extensions with Chroma framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",