nfkit 1.0.34 → 1.0.35
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 +25 -52
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +25 -52
- package/dist/index.mjs.map +2 -2
- package/dist/src/app-context/app-context.d.ts +0 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1302,7 +1302,6 @@ var AppContextCore = class {
|
|
|
1302
1302
|
this.provideRecords = [];
|
|
1303
1303
|
this.registry = /* @__PURE__ */ new Map();
|
|
1304
1304
|
this.objectSteps = [];
|
|
1305
|
-
this.parentContexts = /* @__PURE__ */ new Set();
|
|
1306
1305
|
this.started = false;
|
|
1307
1306
|
this.starting = false;
|
|
1308
1307
|
this.startingEntries = null;
|
|
@@ -1339,48 +1338,17 @@ var AppContextCore = class {
|
|
|
1339
1338
|
this.createdEntries?.set(record, entry);
|
|
1340
1339
|
this.registry.set(record.classRef, entry);
|
|
1341
1340
|
this.startingEntries?.push(entry);
|
|
1341
|
+
if (entry.inst?.then && typeof entry.inst.then === "function") {
|
|
1342
|
+
return entry.inst.then((resolvedInst) => {
|
|
1343
|
+
entry.inst = resolvedInst;
|
|
1344
|
+
return entry;
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1342
1347
|
return entry;
|
|
1343
1348
|
} finally {
|
|
1344
1349
|
this.loadingRecords.delete(record);
|
|
1345
1350
|
}
|
|
1346
1351
|
}
|
|
1347
|
-
applyUsedContext(other) {
|
|
1348
|
-
if (Array.isArray(other?.provideRecords)) {
|
|
1349
|
-
this.provideRecords.push(...other.provideRecords);
|
|
1350
|
-
}
|
|
1351
|
-
if (Array.isArray(other?.objectSteps)) {
|
|
1352
|
-
this.objectSteps.push(...other.objectSteps);
|
|
1353
|
-
for (const step of other.objectSteps) {
|
|
1354
|
-
step(this);
|
|
1355
|
-
}
|
|
1356
|
-
}
|
|
1357
|
-
if (other?.started) {
|
|
1358
|
-
if (other?.registry instanceof Map) {
|
|
1359
|
-
for (const [key, value] of other.registry.entries()) {
|
|
1360
|
-
this.registry.set(key, value);
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
hasStartedInParentChain(visited = /* @__PURE__ */ new Set()) {
|
|
1366
|
-
if (visited.has(this)) return false;
|
|
1367
|
-
visited.add(this);
|
|
1368
|
-
if (this.started) return true;
|
|
1369
|
-
for (const parent of this.parentContexts) {
|
|
1370
|
-
if (parent.hasStartedInParentChain(visited)) {
|
|
1371
|
-
return true;
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
return false;
|
|
1375
|
-
}
|
|
1376
|
-
propagateUsedContextToParents(other, visited = /* @__PURE__ */ new Set()) {
|
|
1377
|
-
if (visited.has(this)) return;
|
|
1378
|
-
visited.add(this);
|
|
1379
|
-
for (const parent of this.parentContexts) {
|
|
1380
|
-
parent.applyUsedContext(other);
|
|
1381
|
-
parent.propagateUsedContextToParents(other, visited);
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
1352
|
provide(cls, ...args) {
|
|
1385
1353
|
const last = args[args.length - 1];
|
|
1386
1354
|
const hasOptions = !!last && typeof last === "object" && ("provide" in last || "merge" in last || "useValue" in last || "useFactory" in last || "useClass" in last);
|
|
@@ -1462,23 +1430,33 @@ var AppContextCore = class {
|
|
|
1462
1430
|
const entry = this.registry.get(key);
|
|
1463
1431
|
return entry.inst;
|
|
1464
1432
|
}
|
|
1465
|
-
/**
|
|
1466
|
-
* @deprecated Use get() instead. getAsync() is no longer needed as all services are loaded synchronously during start().
|
|
1467
|
-
*/
|
|
1468
1433
|
async getAsync(cls) {
|
|
1469
|
-
return this.get(cls);
|
|
1434
|
+
return await this.get(cls);
|
|
1470
1435
|
}
|
|
1471
1436
|
use(...ctxes) {
|
|
1472
1437
|
for (const ctx of ctxes) {
|
|
1473
1438
|
const other = ctx;
|
|
1474
|
-
if (this.
|
|
1439
|
+
if (this.started && !other?.started) {
|
|
1475
1440
|
throw new Error(
|
|
1476
1441
|
"Cannot use an unstarted context into a started context."
|
|
1477
1442
|
);
|
|
1478
1443
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1444
|
+
if (Array.isArray(other?.provideRecords)) {
|
|
1445
|
+
this.provideRecords.push(...other.provideRecords);
|
|
1446
|
+
}
|
|
1447
|
+
if (Array.isArray(other?.objectSteps)) {
|
|
1448
|
+
this.objectSteps.push(...other.objectSteps);
|
|
1449
|
+
for (const step of other.objectSteps) {
|
|
1450
|
+
step(this);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
if (other?.started) {
|
|
1454
|
+
if (other?.registry instanceof Map) {
|
|
1455
|
+
for (const [key, value] of other.registry.entries()) {
|
|
1456
|
+
this.registry.set(key, value);
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1482
1460
|
}
|
|
1483
1461
|
return this;
|
|
1484
1462
|
}
|
|
@@ -1500,12 +1478,7 @@ var AppContextCore = class {
|
|
|
1500
1478
|
if (preloadedKeys.has(record.classRef)) {
|
|
1501
1479
|
continue;
|
|
1502
1480
|
}
|
|
1503
|
-
this.createEntryFromRecord(record);
|
|
1504
|
-
}
|
|
1505
|
-
for (const entry of startedEntries) {
|
|
1506
|
-
if (entry.inst && typeof entry.inst.then === "function") {
|
|
1507
|
-
entry.inst = await entry.inst;
|
|
1508
|
-
}
|
|
1481
|
+
await this.createEntryFromRecord(record);
|
|
1509
1482
|
}
|
|
1510
1483
|
for (const entry of startedEntries) {
|
|
1511
1484
|
const inst = entry.inst;
|