libpetri 5.1.0 → 6.0.0

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.
@@ -1,6 +1,6 @@
1
1
  import { Writable } from 'node:stream';
2
- import { P as PetriNet, b as Transition, T as Token } from '../petri-net-6G5r1Wwb.js';
3
- import { E as EventStore, N as NetEvent } from '../event-store-CUyHiIH7.js';
2
+ import { P as PetriNet, b as Transition, T as Token } from '../petri-net-34SkD5RT.js';
3
+ import { E as EventStore, N as NetEvent } from '../event-store-D6i4u41W.js';
4
4
 
5
5
  /**
6
6
  * Commands sent from debug UI client to server via WebSocket.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  eventInstancePrefix
3
- } from "../chunk-SXK2Z45Z.js";
3
+ } from "../chunk-H2KAMPGN.js";
4
4
  import {
5
5
  dotExport,
6
6
  instancePrefixOf,
@@ -1,5 +1,5 @@
1
1
  import { Application } from 'typedoc';
2
- import { P as PetriNet, S as SubnetDef, o as Instance } from '../petri-net-6G5r1Wwb.js';
2
+ import { P as PetriNet, S as SubnetDef, o as Instance } from '../petri-net-34SkD5RT.js';
3
3
 
4
4
  /**
5
5
  * TypeDoc plugin for `@petrinet` and `@subnet` tags — auto-generates
@@ -6354,7 +6354,7 @@ textContent??"").replace(/^cluster_/,"");Mn.classList.toggle("is-hidden",!N.has(
6354
6354
  en",!bn.has(v))}if(!Q)for(let Mn of Array.from(P.querySelectorAll("g.node.petri-replica")))Mn.classList.add("is-hidden");let Sn=new Map;for(let Mn of Array.from(P.querySelectorAll("g.node"))){let v=Mn.getAttribute("data-id");v&&Sn.set(v,Mn)}for(let Mn of Array.from(P.querySelectorAll("g.edge"))){let v=Mn.getAttribute("data-src")??"",Vn=Mn.getAttribute("data-dst")??"",te=Sn.get(v)?.classList.contains(
6355
6355
  "is-hidden")??!1,pe=Sn.get(Vn)?.classList.contains("is-hidden")??!1;Mn.classList.toggle("is-hidden",te||pe)}}var Pfe=["--lpv-bg","--lpv-header-bg","--lpv-border","--lpv-text","--lpv-muted","--lpv-cluster-bg","--lpv-cluster-bg-collapsed","--lpv-cluster-stroke-width","--lpv-cluster-stroke-dash","--lpv-cluster-fill-tint","--lpv-dim-opacity","--lpv-active-filter-outline","--lpv-legend-bg","--lpv-chip-bg","--lpv-chip-active-bg","--lpv-sidebar-bg","--lpv-sidebar-border","--lpv-sidebar-text","--lpv-sidebar-mute\
6356
6356
  d","--lpv-sidebar-chip-bg","--lpv-sidebar-chip-hover-bg","--lpv-sidebar-chip-off-opacity","--lpv-shared-glyph-color","--lpv-replica-fill","--lpv-replica-stroke","--lpv-highlight-stroke","--lpv-highlight-glow","--lpv-neighbor-stroke","--lpv-faded-node-opacity","--lpv-faded-edge-opacity","--lpv-faded-cluster-opacity"];var XPe=/^\s*subgraph\s+cluster_[A-Za-z0-9_]+\s*\{\s*$/,KPe=/^\s*\}\s*$/;function Cfe(P){let O=P.split("\n"),N=[],Q=0;for(let bn of O){if(XPe.test(bn)){Q++;continue}if(Q>0){if(KPe.test(bn)){Q--;continue}(bn.includes("[")||bn.includes("->"))&&N.push(_fe(bn));continue}if(bn.includes("->")&&(bn.includes("ltail=")||bn.includes("lhead="))){N.push(_fe(bn));continue}N.push(bn)}return N.join("\n")}function _fe(P){
6357
- return P.replace(/,\s*ltail="cluster_[^"]*"/g,"").replace(/,\s*lhead="cluster_[^"]*"/g,"").replace(/\[\s*ltail="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*lhead="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*ltail="cluster_[^"]*"\s*\]/g,"[]").replace(/\[\s*lhead="cluster_[^"]*"\s*\]/g,"[]")}var Ofe="5.1.0";async function ale(P,O,N={}){let Q=N.previousHandle??null,bn=Q?new Set(Q.collapsedPrefixes):new Set,Sn=Q?.activeFilter??null,Mn=N.subnets??Q?.subnets??"show";Q&&Q.dispose();let v=await Promise.resolve().then(()=>(lle(),fle)),Vn=(N.layout??"elk")==="elk",te=Mn==="hide"?Cfe(P):P,pe={clusterLayout:N.clusterLayout,leafPacking:N.leafPacking},Fe=Vn?await v.renderDotToSvgWithElkLayout(te,pe):await v.renderDotToSvg(
6357
+ return P.replace(/,\s*ltail="cluster_[^"]*"/g,"").replace(/,\s*lhead="cluster_[^"]*"/g,"").replace(/\[\s*ltail="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*lhead="cluster_[^"]*"\s*,\s*/g,"[").replace(/\[\s*ltail="cluster_[^"]*"\s*\]/g,"[]").replace(/\[\s*lhead="cluster_[^"]*"\s*\]/g,"[]")}var Ofe="6.0.0";async function ale(P,O,N={}){let Q=N.previousHandle??null,bn=Q?new Set(Q.collapsedPrefixes):new Set,Sn=Q?.activeFilter??null,Mn=N.subnets??Q?.subnets??"show";Q&&Q.dispose();let v=await Promise.resolve().then(()=>(lle(),fle)),Vn=(N.layout??"elk")==="elk",te=Mn==="hide"?Cfe(P):P,pe={clusterLayout:N.clusterLayout,leafPacking:N.leafPacking},Fe=Vn?await v.renderDotToSvgWithElkLayout(te,pe):await v.renderDotToSvg(
6358
6358
  te);O.innerHTML="",O.appendChild(Fe),O.classList.add("libpetri-viewer");let ft=mfe(Fe,N.panzoom),gt=X0n(Fe);Ffe(gt);let $t=N.layout??"elk";$t==="elk"&&(xfe(Fe),vX(Fe));let $e=new Set,dt=null,Ie=null,Ct=!1,We=null,Pn=null,Bt=!0;function It(){if(!N.chrome||We&&We.parentNode===O)return;We=document.createElement("div"),We.className="libpetri-viewer-chrome",We.style.position="absolute",We.style.inset="\
6359
6359
  0",We.style.pointerEvents="none";let Rt=document.createElement("div");Rt.className="diagram-controls",Rt.style.pointerEvents="auto";let or=document.createElement("button");or.type="button",or.className="diagram-btn btn-reset",or.title="Reset view",or.textContent="Reset",or.addEventListener("click",()=>Ir.fit());let ui=document.createElement("button");ui.type="button",ui.className="diagram-btn btn-\
6360
6360
  fullscreen",ui.title="Toggle fullscreen",ui.textContent="Fullscreen",ui.addEventListener("click",()=>Yr(O,ui));let wr=document.createElement("button");wr.type="button",wr.className="diagram-btn btn-subnets",wr.title=Mn==="show"?"Hide subnet groupings":"Show subnet groupings",wr.textContent=Mn==="show"?"Flat view":"Subnets view",wr.addEventListener("click",()=>{Ir.toggleSubnets()}),Rt.appendChild(wr),
@@ -1,4 +1,4 @@
1
- import { T as Token } from './petri-net-6G5r1Wwb.js';
1
+ import { T as Token } from './petri-net-34SkD5RT.js';
2
2
 
3
3
  /**
4
4
  * Events emitted during Petri Net execution.
@@ -23,6 +23,12 @@ interface TransitionEnabled {
23
23
  readonly timestamp: number;
24
24
  readonly transitionName: string;
25
25
  }
26
+ /**
27
+ * A transition's clock restarted while it stayed marked enabled: another firing took tokens
28
+ * it needed and its places were refilled before the executor re-evaluated it (TIME-012).
29
+ * This executor re-evaluates between a firing and its deposit, so it reports such a restart
30
+ * as `transition-enabled`.
31
+ */
26
32
  interface TransitionClockRestarted {
27
33
  readonly type: 'transition-clock-restarted';
28
34
  readonly timestamp: number;
@@ -1,4 +1,4 @@
1
- import { P as PetriNet } from '../petri-net-6G5r1Wwb.js';
1
+ import { P as PetriNet } from '../petri-net-34SkD5RT.js';
2
2
 
3
3
  /**
4
4
  * Format-agnostic typed graph model.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { P as PetriNet, S as SubnetDef, a as Place, T as Token, b as Transition, E as EnvironmentPlace, c as TransitionContext, O as Out } from './petri-net-6G5r1Wwb.js';
2
- export { A as Arc, d as ArcInhibitor, e as ArcInput, f as ArcOutput, g as ArcRead, h as ArcReset, C as Channel, i as ComposeBindings, F as FusionSet, j as FusionSetBuilder, I as In, k as InAll, l as InAtLeast, m as InExactly, n as InOne, o as Instance, p as Interface, q as InterfaceBuilder, K as KeyFn, L as LogFn, M as MAX_DURATION_MS, r as MatchKey, s as MatchSpec, N as NameId, t as OutAnd, u as OutForwardInput, v as OutPlace, w as OutTimeout, x as OutXor, y as OutputEntry, z as PetriNetBuilder, B as Port, D as PortDirection, G as SubnetDefBuilder, H as SubnetInstance, J as Timing, Q as TimingDeadline, R as TimingDelayed, U as TimingExact, V as TimingImmediate, W as TimingWindow, X as TokenInput, Y as TokenOutput, Z as TransitionAction, _ as TransitionBuilder, $ as VerificationHarness, a0 as VerificationResult, a1 as all, a2 as allPlaces, a3 as and, a4 as andPlaces, a5 as arcPlace, a6 as atLeast, a7 as consumptionCount, a8 as deadline, a9 as delayed, aa as earliest, ab as enumerateBranches, ac as environmentPlace, ad as exact, ae as exactly, af as fork, ag as forwardInput, ah as hasDeadline, ai as immediate, aj as inhibitorArc, ak as inputArc, al as isPassthrough, am as isUnit, an as keyForPlace, ao as latest, ap as matchCorrelates, aq as matchKey, ar as matchSpec, as as nameId, at as one, au as outPlace, av as outputArc, aw as passthrough, ax as place, ay as produce, az as readArc, aA as requiredCount, aB as resetArc, aC as timeout, aD as timeoutPlace, aE as tokenAt, aF as tokenOf, aG as transform, aH as transformAsync, aI as transformFrom, aJ as unitToken, aK as window, aL as withTimeout, aM as xor, aN as xorPlaces } from './petri-net-6G5r1Wwb.js';
3
- import { E as EventStore } from './event-store-CUyHiIH7.js';
4
- export { A as ActionTimedOut, a as ExecutionCompleted, b as ExecutionStarted, I as InMemoryEventStore, L as LogMessage, M as MarkingSnapshot, N as NetEvent, T as TokenAdded, c as TokenRemoved, d as TransitionClockRestarted, e as TransitionCompleted, f as TransitionEnabled, g as TransitionFailed, h as TransitionStarted, i as TransitionTimedOut, j as eventTransitionName, k as eventsOfType, l as failures, m as filterEvents, n as inMemoryEventStore, o as isFailureEvent, p as noopEventStore, t as transitionEvents } from './event-store-CUyHiIH7.js';
1
+ import { P as PetriNet, S as SubnetDef, a as Place, T as Token, b as Transition, E as EnvironmentPlace, c as TransitionContext, O as Out } from './petri-net-34SkD5RT.js';
2
+ export { A as Arc, d as ArcInhibitor, e as ArcInput, f as ArcOutput, g as ArcRead, h as ArcReset, C as Channel, i as ComposeBindings, F as FusionSet, j as FusionSetBuilder, I as In, k as InAll, l as InAtLeast, m as InExactly, n as InOne, o as Instance, p as Interface, q as InterfaceBuilder, K as KeyFn, L as LogFn, M as MAX_DURATION_MS, r as MatchKey, s as MatchSpec, N as NameId, t as OutAnd, u as OutForwardInput, v as OutPlace, w as OutTimeout, x as OutXor, y as OutputEntry, z as PetriNetBuilder, B as Port, D as PortDirection, G as SubnetDefBuilder, H as SubnetInstance, J as Timing, Q as TimingDeadline, R as TimingDelayed, U as TimingExact, V as TimingImmediate, W as TimingWindow, X as TokenInput, Y as TokenOutput, Z as TransitionAction, _ as TransitionBuilder, $ as VerificationHarness, a0 as VerificationResult, a1 as all, a2 as allPlaces, a3 as and, a4 as andPlaces, a5 as arcPlace, a6 as atLeast, a7 as consumptionCount, a8 as deadline, a9 as delayed, aa as earliest, ab as enumerateBranches, ac as environmentPlace, ad as exact, ae as exactly, af as fork, ag as forwardInput, ah as hasDeadline, ai as immediate, aj as inhibitorArc, ak as inputArc, al as isPassthrough, am as isUnit, an as keyForPlace, ao as latest, ap as matchCorrelates, aq as matchKey, ar as matchSpec, as as nameId, at as one, au as outPlace, av as outputArc, aw as passthrough, ax as place, ay as produce, az as readArc, aA as requiredCount, aB as resetArc, aC as timeout, aD as timeoutPlace, aE as tokenAt, aF as tokenOf, aG as transform, aH as transformAsync, aI as transformFrom, aJ as unitToken, aK as window, aL as withTimeout, aM as xor, aN as xorPlaces } from './petri-net-34SkD5RT.js';
3
+ import { E as EventStore } from './event-store-D6i4u41W.js';
4
+ export { A as ActionTimedOut, a as ExecutionCompleted, b as ExecutionStarted, I as InMemoryEventStore, L as LogMessage, M as MarkingSnapshot, N as NetEvent, T as TokenAdded, c as TokenRemoved, d as TransitionClockRestarted, e as TransitionCompleted, f as TransitionEnabled, g as TransitionFailed, h as TransitionStarted, i as TransitionTimedOut, j as eventTransitionName, k as eventsOfType, l as failures, m as filterEvents, n as inMemoryEventStore, o as isFailureEvent, p as noopEventStore, t as transitionEvents } from './event-store-D6i4u41W.js';
5
5
 
6
6
  /**
7
7
  * Discriminated sum-type abstraction over Petri nets, distinguishing **closed**
@@ -325,7 +325,16 @@ declare class BitmapNetExecutor implements PetriNetExecutor {
325
325
  private readonly externalQueue;
326
326
  private wakeUpResolve;
327
327
  private readonly readyBuffer;
328
- private readonly pendingResetPlaces;
328
+ /**
329
+ * Per transition, one bit: a firing left it disabled in the intermediate marking while it
330
+ * was marked enabled (TIME-012), so the next dirty scan that finds it enabled restarts its
331
+ * clock. Set at fire time, cleared at the end of every scan; `anyRestartPending` lets the
332
+ * scan skip the clear when nothing was flagged.
333
+ */
334
+ private readonly restartPendingWords;
335
+ private anyRestartPending;
336
+ /** Per place, the count a firing must leave it at to have disabled nothing through it. */
337
+ private readonly restartThresholds;
329
338
  /**
330
339
  * Undeclared place names already reported (CORE-072 AC4). Keyed by name — TS
331
340
  * Place identity is name-based — so a hot loop warns once, not per token.
@@ -333,7 +342,6 @@ declare class BitmapNetExecutor implements PetriNetExecutor {
333
342
  private readonly warnedUnknownPlaces;
334
343
  /** Transitions already warned for writing several tokens to a place their spec names once (IO-016 AC4). */
335
344
  private readonly warnedMultiplicity;
336
- private readonly transitionInputPlaceNames;
337
345
  private running;
338
346
  private draining;
339
347
  private closed;
@@ -368,7 +376,14 @@ declare class BitmapNetExecutor implements PetriNetExecutor {
368
376
  */
369
377
  private enforceDeadlines;
370
378
  private canEnable;
371
- private hasInputFromResetPlace;
379
+ /**
380
+ * Flags each other transition that firing `tid` has just disabled through `pid`
381
+ * (TIME-012). Called from {@link updateBitmapAfterConsumption} on the intermediate marking
382
+ * M - Pre(t) (inputs consumed and resets drained, outputs not yet deposited), and only for
383
+ * a place the firing left below its restart threshold. Removing tokens never trips an
384
+ * inhibitor arc, so the bit tests reject every other kind of neighbour cheaply.
385
+ */
386
+ private flagIntermediateDisablements;
372
387
  private fireReadyTransitions;
373
388
  /**
374
389
  * Fast path for nets where all transitions are immediate and same priority.
@@ -518,6 +533,10 @@ declare class PrecompiledNet {
518
533
  /** -2=no spec, -1=complex, >=0=single output place ID. */
519
534
  readonly simpleOutputPlaceId: Int32Array;
520
535
  readonly inputPlaceCount: Uint32Array;
536
+ /**
537
+ * @deprecated Not read by the executor. Kept so the exported shape of `PrecompiledNet`
538
+ * stays stable; scheduled for removal in the next major release.
539
+ */
521
540
  readonly inputPlaceMaskWords: readonly Uint32Array[];
522
541
  readonly placeToTransitions: readonly (readonly number[])[];
523
542
  readonly consumptionPlaceIds: readonly (readonly number[])[];
@@ -645,8 +664,16 @@ declare class PrecompiledNetExecutor implements PetriNetExecutor {
645
664
  private readonly inFlightResolves;
646
665
  private readonly inFlightErrors;
647
666
  private inFlightCount;
648
- private readonly pendingResetWords;
649
- private hasPendingResets;
667
+ /**
668
+ * Per transition, one bit: a firing left it disabled in the intermediate marking while it
669
+ * was marked enabled (TIME-012), so the next dirty scan that finds it enabled restarts its
670
+ * clock. Set at fire time, cleared at the end of every scan; `anyRestartPending` lets the
671
+ * scan skip the clear when nothing was flagged.
672
+ */
673
+ private readonly restartPendingWords;
674
+ private anyRestartPending;
675
+ /** Per place, the count a firing must leave it at to have disabled nothing through it. */
676
+ private readonly restartThresholds;
650
677
  private readonly completionQueue;
651
678
  private readonly externalQueue;
652
679
  private wakeUpResolve;
@@ -687,7 +714,13 @@ declare class PrecompiledNetExecutor implements PetriNetExecutor {
687
714
  private canEnable;
688
715
  private countMatching;
689
716
  private removeFirstMatching;
690
- private hasInputFromResetPlace;
717
+ /**
718
+ * Flags each other transition that firing `tid` has just disabled through `pid`
719
+ * (TIME-012). Called from {@link updateBitmapAfterConsumption} on the intermediate marking,
720
+ * only for a place the firing left below its restart threshold. Mirrors the bitmap
721
+ * executor, which gives the rationale.
722
+ */
723
+ private flagIntermediateDisablements;
691
724
  private fireReadyTransitions;
692
725
  /**
693
726
  * Fast path for nets where all transitions are immediate and same priority.