@neat.is/core 0.4.14 → 0.4.16
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/{chunk-QZRDQ7WX.js → chunk-VMLWUK7W.js} +41 -29
- package/dist/chunk-VMLWUK7W.js.map +1 -0
- package/dist/cli.cjs +558 -507
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.d.cts +8 -3
- package/dist/cli.d.ts +8 -3
- package/dist/cli.js +215 -169
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +89 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/neatd.cjs +89 -28
- package/dist/neatd.cjs.map +1 -1
- package/dist/neatd.js +1 -1
- package/package.json +3 -4
- package/dist/chunk-QZRDQ7WX.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1012,6 +1012,56 @@ eventBus.setMaxListeners(0);
|
|
|
1012
1012
|
function emitNeatEvent(envelope) {
|
|
1013
1013
|
eventBus.emit(EVENT_BUS_CHANNEL, envelope);
|
|
1014
1014
|
}
|
|
1015
|
+
function attachGraphToEventBus(graph, opts) {
|
|
1016
|
+
const { project } = opts;
|
|
1017
|
+
const onNodeAdded = (payload) => {
|
|
1018
|
+
emitNeatEvent({
|
|
1019
|
+
type: "node-added",
|
|
1020
|
+
project,
|
|
1021
|
+
payload: { node: payload.attributes }
|
|
1022
|
+
});
|
|
1023
|
+
};
|
|
1024
|
+
const onNodeDropped = (payload) => {
|
|
1025
|
+
emitNeatEvent({
|
|
1026
|
+
type: "node-removed",
|
|
1027
|
+
project,
|
|
1028
|
+
payload: { id: payload.key }
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
const onEdgeAdded = (payload) => {
|
|
1032
|
+
emitNeatEvent({
|
|
1033
|
+
type: "edge-added",
|
|
1034
|
+
project,
|
|
1035
|
+
payload: { edge: payload.attributes }
|
|
1036
|
+
});
|
|
1037
|
+
};
|
|
1038
|
+
const onEdgeDropped = (payload) => {
|
|
1039
|
+
emitNeatEvent({
|
|
1040
|
+
type: "edge-removed",
|
|
1041
|
+
project,
|
|
1042
|
+
payload: { id: payload.key }
|
|
1043
|
+
});
|
|
1044
|
+
};
|
|
1045
|
+
const onNodeAttrsUpdated = (payload) => {
|
|
1046
|
+
emitNeatEvent({
|
|
1047
|
+
type: "node-updated",
|
|
1048
|
+
project,
|
|
1049
|
+
payload: { id: payload.key, changes: payload.attributes }
|
|
1050
|
+
});
|
|
1051
|
+
};
|
|
1052
|
+
graph.on("nodeAdded", onNodeAdded);
|
|
1053
|
+
graph.on("nodeDropped", onNodeDropped);
|
|
1054
|
+
graph.on("edgeAdded", onEdgeAdded);
|
|
1055
|
+
graph.on("edgeDropped", onEdgeDropped);
|
|
1056
|
+
graph.on("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1057
|
+
return () => {
|
|
1058
|
+
graph.off("nodeAdded", onNodeAdded);
|
|
1059
|
+
graph.off("nodeDropped", onNodeDropped);
|
|
1060
|
+
graph.off("edgeAdded", onEdgeAdded);
|
|
1061
|
+
graph.off("edgeDropped", onEdgeDropped);
|
|
1062
|
+
graph.off("nodeAttributesUpdated", onNodeAttrsUpdated);
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1015
1065
|
|
|
1016
1066
|
// src/traverse.ts
|
|
1017
1067
|
init_cjs_shims();
|
|
@@ -6782,6 +6832,16 @@ function unroutedErrorsPath(neatHome2) {
|
|
|
6782
6832
|
}
|
|
6783
6833
|
|
|
6784
6834
|
// src/daemon.ts
|
|
6835
|
+
function teardownSlot(slot) {
|
|
6836
|
+
try {
|
|
6837
|
+
slot.stopPersist();
|
|
6838
|
+
} catch {
|
|
6839
|
+
}
|
|
6840
|
+
try {
|
|
6841
|
+
slot.detachEvents();
|
|
6842
|
+
} catch {
|
|
6843
|
+
}
|
|
6844
|
+
}
|
|
6785
6845
|
function neatHomeFor(opts) {
|
|
6786
6846
|
if (opts.neatHome && opts.neatHome.length > 0) return import_node_path41.default.resolve(opts.neatHome);
|
|
6787
6847
|
const env = process.env.NEAT_HOME;
|
|
@@ -6840,6 +6900,8 @@ async function bootstrapProject(entry) {
|
|
|
6840
6900
|
paths,
|
|
6841
6901
|
stopPersist: () => {
|
|
6842
6902
|
},
|
|
6903
|
+
detachEvents: () => {
|
|
6904
|
+
},
|
|
6843
6905
|
status: "broken",
|
|
6844
6906
|
errorReason: err.message
|
|
6845
6907
|
};
|
|
@@ -6848,18 +6910,25 @@ async function bootstrapProject(entry) {
|
|
|
6848
6910
|
const graph = getGraph(entry.name);
|
|
6849
6911
|
const outPath = paths.snapshotPath;
|
|
6850
6912
|
await loadGraphFromDisk(graph, outPath);
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6913
|
+
const detachEvents = attachGraphToEventBus(graph, { project: entry.name });
|
|
6914
|
+
try {
|
|
6915
|
+
await extractFromDirectory(graph, entry.path);
|
|
6916
|
+
const stopPersist = startPersistLoop(graph, outPath);
|
|
6917
|
+
await touchLastSeen(entry.name).catch(() => {
|
|
6918
|
+
});
|
|
6919
|
+
return {
|
|
6920
|
+
entry,
|
|
6921
|
+
graph,
|
|
6922
|
+
outPath,
|
|
6923
|
+
paths,
|
|
6924
|
+
stopPersist,
|
|
6925
|
+
detachEvents,
|
|
6926
|
+
status: "active"
|
|
6927
|
+
};
|
|
6928
|
+
} catch (err) {
|
|
6929
|
+
detachEvents();
|
|
6930
|
+
throw err;
|
|
6931
|
+
}
|
|
6863
6932
|
}
|
|
6864
6933
|
function resolveRestPort(opts) {
|
|
6865
6934
|
if (typeof opts.restPort === "number") return opts.restPort;
|
|
@@ -6941,6 +7010,8 @@ async function startDaemon(opts = {}) {
|
|
|
6941
7010
|
async function tryRecoverSlot(entry) {
|
|
6942
7011
|
try {
|
|
6943
7012
|
const fresh = await bootstrapProject(entry);
|
|
7013
|
+
const prior = slots.get(entry.name);
|
|
7014
|
+
if (prior) teardownSlot(prior);
|
|
6944
7015
|
slots.set(entry.name, fresh);
|
|
6945
7016
|
upsertRegistryFromSlot(fresh);
|
|
6946
7017
|
if (fresh.status === "active") {
|
|
@@ -6963,6 +7034,8 @@ async function startDaemon(opts = {}) {
|
|
|
6963
7034
|
bootstrapStartedAt.set(entry.name, Date.now());
|
|
6964
7035
|
try {
|
|
6965
7036
|
const slot = await bootstrapProject(entry);
|
|
7037
|
+
const prior = slots.get(entry.name);
|
|
7038
|
+
if (prior) teardownSlot(prior);
|
|
6966
7039
|
slots.set(entry.name, slot);
|
|
6967
7040
|
upsertRegistryFromSlot(slot);
|
|
6968
7041
|
bootstrapStatus.set(entry.name, slot.status === "broken" ? "broken" : "active");
|
|
@@ -6998,10 +7071,7 @@ async function startDaemon(opts = {}) {
|
|
|
6998
7071
|
}
|
|
6999
7072
|
for (const [name, slot] of [...slots.entries()]) {
|
|
7000
7073
|
if (seen.has(name)) continue;
|
|
7001
|
-
|
|
7002
|
-
slot.stopPersist();
|
|
7003
|
-
} catch {
|
|
7004
|
-
}
|
|
7074
|
+
teardownSlot(slot);
|
|
7005
7075
|
slots.delete(name);
|
|
7006
7076
|
bootstrapStatus.delete(name);
|
|
7007
7077
|
bootstrapStartedAt.delete(name);
|
|
@@ -7047,10 +7117,7 @@ async function startDaemon(opts = {}) {
|
|
|
7047
7117
|
console.log(`neatd: REST listening on ${restAddress}`);
|
|
7048
7118
|
} catch (err) {
|
|
7049
7119
|
for (const slot of slots.values()) {
|
|
7050
|
-
|
|
7051
|
-
slot.stopPersist();
|
|
7052
|
-
} catch {
|
|
7053
|
-
}
|
|
7120
|
+
teardownSlot(slot);
|
|
7054
7121
|
}
|
|
7055
7122
|
if (restApp) await restApp.close().catch(() => {
|
|
7056
7123
|
});
|
|
@@ -7151,10 +7218,7 @@ async function startDaemon(opts = {}) {
|
|
|
7151
7218
|
console.log(`neatd: OTLP listening on ${otlpAddress}/v1/traces`);
|
|
7152
7219
|
} catch (err) {
|
|
7153
7220
|
for (const slot of slots.values()) {
|
|
7154
|
-
|
|
7155
|
-
slot.stopPersist();
|
|
7156
|
-
} catch {
|
|
7157
|
-
}
|
|
7221
|
+
teardownSlot(slot);
|
|
7158
7222
|
}
|
|
7159
7223
|
if (restApp) await restApp.close().catch(() => {
|
|
7160
7224
|
});
|
|
@@ -7246,10 +7310,7 @@ async function startDaemon(opts = {}) {
|
|
|
7246
7310
|
if (restApp) await restApp.close().catch(() => {
|
|
7247
7311
|
});
|
|
7248
7312
|
for (const slot of slots.values()) {
|
|
7249
|
-
|
|
7250
|
-
slot.stopPersist();
|
|
7251
|
-
} catch {
|
|
7252
|
-
}
|
|
7313
|
+
teardownSlot(slot);
|
|
7253
7314
|
}
|
|
7254
7315
|
await import_node_fs25.promises.unlink(pidPath).catch(() => {
|
|
7255
7316
|
});
|