libpetri 0.4.0 → 0.5.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.
- package/dist/{chunk-ZE6RR3R4.js → chunk-MJPQNC5D.js} +1 -1
- package/dist/debug/index.d.ts +109 -4
- package/dist/debug/index.js +1213 -911
- package/dist/debug/index.js.map +1 -1
- package/dist/doclet/index.d.ts +108 -0
- package/dist/doclet/index.js +215 -0
- package/dist/doclet/index.js.map +1 -0
- package/dist/doclet/resources/petrinet-diagrams.css +126 -0
- package/dist/doclet/resources/petrinet-diagrams.js +111 -0
- package/dist/dot-exporter-U6BRCQNK.js +8 -0
- package/dist/dot-exporter-U6BRCQNK.js.map +1 -0
- package/dist/export/index.js +1 -1
- package/package.json +25 -3
- /package/dist/{chunk-ZE6RR3R4.js.map → chunk-MJPQNC5D.js.map} +0 -0
package/dist/debug/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { a as PetriNet, b as Transition, T as Token } from '../petri-net-C3Jy5HCt.js';
|
|
2
2
|
import { E as EventStore, N as NetEvent } from '../event-store-Y8q_wapJ.js';
|
|
3
|
+
import { Writable } from 'node:stream';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Commands sent from debug UI client to server via WebSocket.
|
|
@@ -242,10 +243,21 @@ declare class DebugEventStore implements EventStore {
|
|
|
242
243
|
eventsSince(from: number): readonly NetEvent[];
|
|
243
244
|
/** Returns events within a time range. */
|
|
244
245
|
eventsBetween(from: number, to: number): readonly NetEvent[];
|
|
246
|
+
/**
|
|
247
|
+
* Returns an iterator over all retained events.
|
|
248
|
+
* Useful for archive writers that need zero-copy traversal.
|
|
249
|
+
*/
|
|
250
|
+
[Symbol.iterator](): Iterator<NetEvent>;
|
|
245
251
|
/** Close the store (no-op in JS, but matches Java interface). */
|
|
246
252
|
close(): void;
|
|
247
253
|
}
|
|
248
254
|
|
|
255
|
+
/**
|
|
256
|
+
* Listener notified when a debug session completes.
|
|
257
|
+
*/
|
|
258
|
+
|
|
259
|
+
type SessionCompletionListener = (session: DebugSession) => void;
|
|
260
|
+
|
|
249
261
|
/**
|
|
250
262
|
* Registry for managing Petri net debug sessions.
|
|
251
263
|
* TypeScript port of Java's DebugSessionRegistry.
|
|
@@ -255,24 +267,30 @@ interface DebugSession {
|
|
|
255
267
|
readonly sessionId: string;
|
|
256
268
|
readonly netName: string;
|
|
257
269
|
readonly dotDiagram: string;
|
|
258
|
-
readonly places: PlaceAnalysis;
|
|
270
|
+
readonly places: PlaceAnalysis | null;
|
|
259
271
|
readonly transitions: ReadonlySet<Transition>;
|
|
260
272
|
readonly eventStore: DebugEventStore;
|
|
261
273
|
readonly startTime: number;
|
|
262
274
|
readonly active: boolean;
|
|
275
|
+
readonly importedStructure: NetStructure | null;
|
|
263
276
|
}
|
|
277
|
+
/** Builds the net structure from a session's stored place and transition info. */
|
|
278
|
+
declare function buildNetStructure(session: DebugSession): NetStructure;
|
|
264
279
|
type EventStoreFactory = (sessionId: string) => DebugEventStore;
|
|
265
280
|
declare class DebugSessionRegistry {
|
|
266
281
|
private readonly _sessions;
|
|
267
282
|
private readonly _maxSessions;
|
|
268
283
|
private readonly _eventStoreFactory;
|
|
269
|
-
|
|
284
|
+
private readonly _completionListeners;
|
|
285
|
+
constructor(maxSessions?: number, eventStoreFactory?: EventStoreFactory, completionListeners?: SessionCompletionListener[]);
|
|
270
286
|
/**
|
|
271
287
|
* Registers a new debug session for the given Petri net.
|
|
272
288
|
* Generates DOT diagram and extracts net structure.
|
|
273
289
|
*/
|
|
274
290
|
register(sessionId: string, net: PetriNet): DebugSession;
|
|
275
|
-
/**
|
|
291
|
+
/**
|
|
292
|
+
* Marks a session as completed (no longer active) and notifies completion listeners.
|
|
293
|
+
*/
|
|
276
294
|
complete(sessionId: string): void;
|
|
277
295
|
/** Removes a session from the registry. */
|
|
278
296
|
remove(sessionId: string): DebugSession | undefined;
|
|
@@ -284,6 +302,12 @@ declare class DebugSessionRegistry {
|
|
|
284
302
|
listActiveSessions(limit: number): readonly DebugSession[];
|
|
285
303
|
/** Total number of sessions. */
|
|
286
304
|
get size(): number;
|
|
305
|
+
/**
|
|
306
|
+
* Registers an imported (archived) session as an inactive, read-only session.
|
|
307
|
+
*/
|
|
308
|
+
registerImported(sessionId: string, netName: string, dotDiagram: string, structure: NetStructure, eventStore: DebugEventStore, startTime: number): DebugSession;
|
|
309
|
+
/** Notifies all completion listeners. Exceptions are caught and logged. */
|
|
310
|
+
private notifyCompletionListeners;
|
|
287
311
|
/** Evicts oldest inactive sessions if at capacity. */
|
|
288
312
|
private evictIfNecessary;
|
|
289
313
|
}
|
|
@@ -390,6 +414,87 @@ declare class DebugAwareEventStore implements EventStore {
|
|
|
390
414
|
get debugStore(): DebugEventStore;
|
|
391
415
|
}
|
|
392
416
|
|
|
417
|
+
/**
|
|
418
|
+
* Metadata header for a session archive file.
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
interface SessionArchive {
|
|
422
|
+
readonly version: number;
|
|
423
|
+
readonly sessionId: string;
|
|
424
|
+
readonly netName: string;
|
|
425
|
+
readonly dotDiagram: string;
|
|
426
|
+
readonly startTime: string;
|
|
427
|
+
readonly eventCount: number;
|
|
428
|
+
readonly structure: NetStructure;
|
|
429
|
+
}
|
|
430
|
+
/** Current archive format version. */
|
|
431
|
+
declare const CURRENT_VERSION = 1;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Storage backend interface for session archives.
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
interface ArchivedSessionSummary {
|
|
438
|
+
readonly sessionId: string;
|
|
439
|
+
readonly key: string;
|
|
440
|
+
readonly sizeBytes: number;
|
|
441
|
+
readonly lastModified: number;
|
|
442
|
+
}
|
|
443
|
+
type OutputStreamConsumer = (out: Writable) => Promise<void>;
|
|
444
|
+
interface SessionArchiveStorage {
|
|
445
|
+
storeStreaming(sessionId: string, writer: OutputStreamConsumer): Promise<void>;
|
|
446
|
+
list(limit: number, prefix?: string): Promise<readonly ArchivedSessionSummary[]>;
|
|
447
|
+
retrieve(sessionId: string): Promise<Buffer>;
|
|
448
|
+
isAvailable(): boolean;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* File-system backed storage for session archives.
|
|
453
|
+
* Uses Node.js fs/promises — no external dependencies.
|
|
454
|
+
*/
|
|
455
|
+
|
|
456
|
+
declare class FileSessionArchiveStorage implements SessionArchiveStorage {
|
|
457
|
+
private readonly _directory;
|
|
458
|
+
constructor(directory: string);
|
|
459
|
+
storeStreaming(sessionId: string, writer: OutputStreamConsumer): Promise<void>;
|
|
460
|
+
list(limit: number, prefix?: string): Promise<readonly ArchivedSessionSummary[]>;
|
|
461
|
+
retrieve(sessionId: string): Promise<Buffer>;
|
|
462
|
+
isAvailable(): boolean;
|
|
463
|
+
private archivePath;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* Writes a debug session to a length-prefixed binary archive format.
|
|
468
|
+
*
|
|
469
|
+
* Format (inside gzip):
|
|
470
|
+
* [4 bytes: metadata JSON length][N bytes: metadata JSON]
|
|
471
|
+
* [4 bytes: event JSON length][N bytes: event JSON]
|
|
472
|
+
* ...
|
|
473
|
+
* (EOF terminates the stream)
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
declare class SessionArchiveWriter {
|
|
477
|
+
/**
|
|
478
|
+
* Writes a complete session archive and returns the compressed bytes.
|
|
479
|
+
*/
|
|
480
|
+
write(session: DebugSession): Buffer;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Reads session archives from length-prefixed binary format.
|
|
485
|
+
*/
|
|
486
|
+
|
|
487
|
+
interface ImportedSession {
|
|
488
|
+
readonly metadata: SessionArchive;
|
|
489
|
+
readonly eventStore: DebugEventStore;
|
|
490
|
+
}
|
|
491
|
+
declare class SessionArchiveReader {
|
|
492
|
+
/** Reads only the metadata header from an archive. */
|
|
493
|
+
readMetadata(compressed: Buffer): SessionArchive;
|
|
494
|
+
/** Reads the full archive: metadata + all events into a DebugEventStore. */
|
|
495
|
+
readFull(compressed: Buffer): ImportedSession;
|
|
496
|
+
}
|
|
497
|
+
|
|
393
498
|
/**
|
|
394
499
|
* Debug infrastructure for Petri net execution visualization.
|
|
395
500
|
*
|
|
@@ -405,4 +510,4 @@ declare class DebugAwareEventStore implements EventStore {
|
|
|
405
510
|
*/
|
|
406
511
|
declare function debugUiAssetPath(): Promise<string>;
|
|
407
512
|
|
|
408
|
-
export { type BreakpointConfig, type BreakpointType, type ComputedState, DEFAULT_MAX_EVENTS, DebugAwareEventStore, type DebugCommand, DebugEventStore, DebugProtocolHandler, type DebugResponse, type DebugSession, DebugSessionRegistry, type EventFilter, type EventStoreFactory, MarkingCache, type NetEventInfo, type NetStructure, PlaceAnalysis, type PlaceAnalysisInfo, type PlaceInfo, type ResponseSink, SNAPSHOT_INTERVAL, type SessionSummary, type Subscription, type SubscriptionMode, type TokenInfo, type TransitionInfo, compactTokenInfo, convertMarking, debugUiAssetPath, eventFilterAll, toEventInfo, tokenInfo };
|
|
513
|
+
export { type ArchivedSessionSummary, type BreakpointConfig, type BreakpointType, CURRENT_VERSION, type ComputedState, DEFAULT_MAX_EVENTS, DebugAwareEventStore, type DebugCommand, DebugEventStore, DebugProtocolHandler, type DebugResponse, type DebugSession, DebugSessionRegistry, type EventFilter, type EventStoreFactory, FileSessionArchiveStorage, type ImportedSession, MarkingCache, type NetEventInfo, type NetStructure, type OutputStreamConsumer, PlaceAnalysis, type PlaceAnalysisInfo, type PlaceInfo, type ResponseSink, SNAPSHOT_INTERVAL, type SessionArchive, SessionArchiveReader, type SessionArchiveStorage, SessionArchiveWriter, type SessionCompletionListener, type SessionSummary, type Subscription, type SubscriptionMode, type TokenInfo, type TransitionInfo, buildNetStructure, compactTokenInfo, convertMarking, debugUiAssetPath, eventFilterAll, toEventInfo, tokenInfo };
|