@niscorp/tide 0.1.0 → 0.1.2
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/CHANGELOG.md +13 -0
- package/DESIGN.md +20 -7
- package/DOCS.md +205 -25
- package/README.md +3 -3
- package/dist/index.cjs +12 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ var versionOf = (reflex) => {
|
|
|
55
55
|
var isGuarded = (reflex) => reflex.select !== void 0 || reflex.when !== void 0;
|
|
56
56
|
var buildGraph = (reflexes, effects) => {
|
|
57
57
|
const edges = [];
|
|
58
|
-
const
|
|
58
|
+
const refusals = [];
|
|
59
59
|
const warnings = [];
|
|
60
60
|
const blind = [];
|
|
61
61
|
const byId = new Map(reflexes.map((reflex) => [reflex.id, reflex]));
|
|
@@ -71,13 +71,13 @@ var buildGraph = (reflexes, effects) => {
|
|
|
71
71
|
const existing = runWatchers.get(fact.run) ?? [];
|
|
72
72
|
runWatchers.set(fact.run, [...existing, reflex.id]);
|
|
73
73
|
if (fact.run === reflex.id) warnings.push(`${reflex.id} subscribes to its own run \u2014 a drain loop; make sure it narrows`);
|
|
74
|
-
if (!byId.has(fact.run))
|
|
74
|
+
if (!byId.has(fact.run)) refusals.push({ code: "unknown_reflex", message: `${reflex.id} watches the run of unknown reflex "${fact.run}"` });
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
for (const reflex of reflexes) {
|
|
78
78
|
const handler = effects[reflex.effect.name];
|
|
79
79
|
if (handler === void 0) {
|
|
80
|
-
|
|
80
|
+
refusals.push({ code: "unknown_effect", message: `${reflex.id} names effect "${reflex.effect.name}", which is not registered` });
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
if (handler.writes === void 0) {
|
|
@@ -98,10 +98,11 @@ var buildGraph = (reflexes, effects) => {
|
|
|
98
98
|
}));
|
|
99
99
|
for (const cycle of cycles)
|
|
100
100
|
if (!cycle.guarded)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
refusals.push({
|
|
102
|
+
code: "unguarded_cycle",
|
|
103
|
+
message: `unguarded cycle: ${cycle.reflexIds.join(" \u2192 ")} \u2192 ${cycle.reflexIds[0]} \u2014 no selection and no \`when\` anywhere on the loop, so it diverges by construction`
|
|
104
|
+
});
|
|
105
|
+
return { edges, cycles, blind, errors: refusals.map((refusal) => refusal.message), refusals, warnings };
|
|
105
106
|
};
|
|
106
107
|
var findCycles = (reflexes, edges) => {
|
|
107
108
|
const adjacency = /* @__PURE__ */ new Map();
|
|
@@ -1017,9 +1018,10 @@ var createTide = (config) => {
|
|
|
1017
1018
|
parsed.push(result.data);
|
|
1018
1019
|
}
|
|
1019
1020
|
const graph = buildGraph(parsed, mergedEffects(parsed));
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1021
|
+
const refused = graph.refusals[0];
|
|
1022
|
+
if (refused !== void 0)
|
|
1023
|
+
throw new TideError(refused.code, `tide refused to load:
|
|
1024
|
+
${graph.errors.join("\n ")}`, { errors: graph.errors, refusals: graph.refusals });
|
|
1023
1025
|
const previously = new Set(loaded.keys());
|
|
1024
1026
|
const next = /* @__PURE__ */ new Map();
|
|
1025
1027
|
for (const reflex of parsed) {
|