@rotorsoft/act-diagram 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/dist/index.js CHANGED
@@ -207,11 +207,40 @@ function buildModel(result, files, expectedSlices) {
207
207
  model.reactions.push(r);
208
208
  }
209
209
  const entryPath = a._sourceFile ?? "app.ts";
210
+ const actSliceNames = new Set(
211
+ (a.slices ?? []).filter((s) => s != null).map((s) => s._varName ?? "").filter(Boolean)
212
+ );
213
+ for (const sl of model.slices) {
214
+ if (sl.error && !actSliceNames.has(sl.name)) {
215
+ const actSrc = files.find((f) => f.path === entryPath)?.content ?? "";
216
+ if (actSrc.includes(sl.name)) {
217
+ actSliceNames.add(sl.name);
218
+ }
219
+ }
220
+ }
221
+ const entrySlices = model.slices.filter((s) => actSliceNames.has(s.name));
222
+ const sliceStateKeys = new Set(entrySlices.flatMap((s) => s.states));
223
+ const actStateKeys = /* @__PURE__ */ new Set();
224
+ for (const s of a.states ?? []) {
225
+ try {
226
+ if (s && s._tag === "State") {
227
+ actStateKeys.add(s._modelKey ?? s.name);
228
+ }
229
+ } catch {
230
+ }
231
+ }
232
+ const allStateKeys = /* @__PURE__ */ new Set([...actStateKeys, ...sliceStateKeys]);
233
+ const actProjNames = new Set(
234
+ (a.projections ?? []).filter((p) => p && p._tag === "Projection").map((p) => p.target)
235
+ );
236
+ for (const sl of entrySlices) {
237
+ for (const pn of sl.projections) actProjNames.add(pn);
238
+ }
210
239
  model.entries.push({
211
240
  path: entryPath,
212
- states: model.states,
213
- slices: model.slices,
214
- projections: model.projections,
241
+ states: model.states.filter((s) => allStateKeys.has(s.varName)),
242
+ slices: entrySlices,
243
+ projections: model.projections.filter((p) => actProjNames.has(p.name)),
215
244
  reactions: a.reactions ?? []
216
245
  });
217
246
  }
@@ -2832,6 +2861,8 @@ export {
2832
2861
  Diagram,
2833
2862
  Logo,
2834
2863
  Tooltip,
2864
+ buildModel,
2865
+ computeLayout,
2835
2866
  deriveProjectName,
2836
2867
  emptyModel,
2837
2868
  extractModel,