@ts-model-checker/worker 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/check.worker.cjs +51 -0
- package/dist/check.worker.cjs.map +1 -0
- package/dist/check.worker.d.cts +2 -0
- package/dist/check.worker.d.ts +2 -0
- package/dist/check.worker.js +49 -0
- package/dist/check.worker.js.map +1 -0
- package/dist/index.cjs +83 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +81 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alysson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@ts-model-checker/core');
|
|
4
|
+
|
|
5
|
+
// src/check.worker.ts
|
|
6
|
+
var activeRequests = /* @__PURE__ */ new Map();
|
|
7
|
+
function postWorkerMessage(msg) {
|
|
8
|
+
self.postMessage(msg);
|
|
9
|
+
}
|
|
10
|
+
self.addEventListener("message", (event) => {
|
|
11
|
+
const payload = event.data;
|
|
12
|
+
if (payload.type === "CANCEL") {
|
|
13
|
+
const state = activeRequests.get(payload.requestId);
|
|
14
|
+
if (state) {
|
|
15
|
+
state.cancelled = true;
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (payload.type === "CHECK_SPEC") {
|
|
20
|
+
const token = { cancelled: false };
|
|
21
|
+
activeRequests.set(payload.requestId, token);
|
|
22
|
+
try {
|
|
23
|
+
const result = core.verifySpec(payload.spec, {
|
|
24
|
+
...payload.options,
|
|
25
|
+
isAborted: () => token.cancelled,
|
|
26
|
+
onProgress: (progress) => {
|
|
27
|
+
postWorkerMessage({
|
|
28
|
+
type: "PROGRESS",
|
|
29
|
+
requestId: payload.requestId,
|
|
30
|
+
progress
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
postWorkerMessage({
|
|
35
|
+
type: "RESULT",
|
|
36
|
+
requestId: payload.requestId,
|
|
37
|
+
result
|
|
38
|
+
});
|
|
39
|
+
} catch (err) {
|
|
40
|
+
postWorkerMessage({
|
|
41
|
+
type: "ERROR",
|
|
42
|
+
requestId: payload.requestId,
|
|
43
|
+
message: err instanceof Error ? err.message : String(err)
|
|
44
|
+
});
|
|
45
|
+
} finally {
|
|
46
|
+
activeRequests.delete(payload.requestId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
//# sourceMappingURL=check.worker.cjs.map
|
|
51
|
+
//# sourceMappingURL=check.worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/check.worker.ts"],"names":["verifySpec"],"mappings":";;;;;AAGA,IAAM,cAAA,uBAAqB,GAAA,EAAoC;AAE/D,SAAS,kBAAkB,GAAA,EAA2B;AACpD,EAAA,IAAA,CAAK,YAAY,GAAG,CAAA;AACtB;AAEA,IAAA,CAAK,gBAAA,CAAiB,SAAA,EAAW,CAAC,KAAA,KAAuC;AACvE,EAAA,MAAM,UAAU,KAAA,CAAM,IAAA;AAEtB,EAAA,IAAI,OAAA,CAAQ,SAAS,QAAA,EAAU;AAC7B,IAAA,MAAM,KAAA,GAAQ,cAAA,CAAe,GAAA,CAAI,OAAA,CAAQ,SAAS,CAAA;AAClD,IAAA,IAAI,KAAA,EAAO;AACT,MAAA,KAAA,CAAM,SAAA,GAAY,IAAA;AAAA,IACpB;AACA,IAAA;AAAA,EACF;AAEA,EAAA,IAAI,OAAA,CAAQ,SAAS,YAAA,EAAc;AACjC,IAAA,MAAM,KAAA,GAAQ,EAAE,SAAA,EAAW,KAAA,EAAM;AACjC,IAAA,cAAA,CAAe,GAAA,CAAI,OAAA,CAAQ,SAAA,EAAW,KAAK,CAAA;AAE3C,IAAA,IAAI;AACF,MAAA,MAAM,MAAA,GAASA,eAAA,CAAW,OAAA,CAAQ,IAAA,EAAM;AAAA,QACtC,GAAG,OAAA,CAAQ,OAAA;AAAA,QACX,SAAA,EAAW,MAAM,KAAA,CAAM,SAAA;AAAA,QACvB,UAAA,EAAY,CAAC,QAAA,KAAa;AACxB,UAAA,iBAAA,CAAkB;AAAA,YAChB,IAAA,EAAM,UAAA;AAAA,YACN,WAAW,OAAA,CAAQ,SAAA;AAAA,YACnB;AAAA,WACD,CAAA;AAAA,QACH;AAAA,OACD,CAAA;AAED,MAAA,iBAAA,CAAkB;AAAA,QAChB,IAAA,EAAM,QAAA;AAAA,QACN,WAAW,OAAA,CAAQ,SAAA;AAAA,QACnB;AAAA,OACD,CAAA;AAAA,IACH,SAAS,GAAA,EAAK;AACZ,MAAA,iBAAA,CAAkB;AAAA,QAChB,IAAA,EAAM,OAAA;AAAA,QACN,WAAW,OAAA,CAAQ,SAAA;AAAA,QACnB,SAAS,GAAA,YAAe,KAAA,GAAQ,GAAA,CAAI,OAAA,GAAU,OAAO,GAAG;AAAA,OACzD,CAAA;AAAA,IACH,CAAA,SAAE;AACA,MAAA,cAAA,CAAe,MAAA,CAAO,QAAQ,SAAS,CAAA;AAAA,IACzC;AAAA,EACF;AACF,CAAC,CAAA","file":"check.worker.cjs","sourcesContent":["import { verifySpec } from \"@ts-model-checker/core\";\nimport type { WorkerRequest, WorkerResponse } from \"./protocol\";\n\nconst activeRequests = new Map<string, { cancelled: boolean }>();\n\nfunction postWorkerMessage(msg: WorkerResponse): void {\n self.postMessage(msg);\n}\n\nself.addEventListener(\"message\", (event: MessageEvent<WorkerRequest>) => {\n const payload = event.data;\n\n if (payload.type === \"CANCEL\") {\n const state = activeRequests.get(payload.requestId);\n if (state) {\n state.cancelled = true;\n }\n return;\n }\n\n if (payload.type === \"CHECK_SPEC\") {\n const token = { cancelled: false };\n activeRequests.set(payload.requestId, token);\n\n try {\n const result = verifySpec(payload.spec, {\n ...payload.options,\n isAborted: () => token.cancelled,\n onProgress: (progress) => {\n postWorkerMessage({\n type: \"PROGRESS\",\n requestId: payload.requestId,\n progress,\n });\n },\n });\n\n postWorkerMessage({\n type: \"RESULT\",\n requestId: payload.requestId,\n result,\n });\n } catch (err) {\n postWorkerMessage({\n type: \"ERROR\",\n requestId: payload.requestId,\n message: err instanceof Error ? err.message : String(err),\n });\n } finally {\n activeRequests.delete(payload.requestId);\n }\n }\n});\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { verifySpec } from '@ts-model-checker/core';
|
|
2
|
+
|
|
3
|
+
// src/check.worker.ts
|
|
4
|
+
var activeRequests = /* @__PURE__ */ new Map();
|
|
5
|
+
function postWorkerMessage(msg) {
|
|
6
|
+
self.postMessage(msg);
|
|
7
|
+
}
|
|
8
|
+
self.addEventListener("message", (event) => {
|
|
9
|
+
const payload = event.data;
|
|
10
|
+
if (payload.type === "CANCEL") {
|
|
11
|
+
const state = activeRequests.get(payload.requestId);
|
|
12
|
+
if (state) {
|
|
13
|
+
state.cancelled = true;
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (payload.type === "CHECK_SPEC") {
|
|
18
|
+
const token = { cancelled: false };
|
|
19
|
+
activeRequests.set(payload.requestId, token);
|
|
20
|
+
try {
|
|
21
|
+
const result = verifySpec(payload.spec, {
|
|
22
|
+
...payload.options,
|
|
23
|
+
isAborted: () => token.cancelled,
|
|
24
|
+
onProgress: (progress) => {
|
|
25
|
+
postWorkerMessage({
|
|
26
|
+
type: "PROGRESS",
|
|
27
|
+
requestId: payload.requestId,
|
|
28
|
+
progress
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
postWorkerMessage({
|
|
33
|
+
type: "RESULT",
|
|
34
|
+
requestId: payload.requestId,
|
|
35
|
+
result
|
|
36
|
+
});
|
|
37
|
+
} catch (err) {
|
|
38
|
+
postWorkerMessage({
|
|
39
|
+
type: "ERROR",
|
|
40
|
+
requestId: payload.requestId,
|
|
41
|
+
message: err instanceof Error ? err.message : String(err)
|
|
42
|
+
});
|
|
43
|
+
} finally {
|
|
44
|
+
activeRequests.delete(payload.requestId);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=check.worker.js.map
|
|
49
|
+
//# sourceMappingURL=check.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/check.worker.ts"],"names":[],"mappings":";;;AAGA,IAAM,cAAA,uBAAqB,GAAA,EAAoC;AAE/D,SAAS,kBAAkB,GAAA,EA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CAAI,OAAA,GAAU,OAAO,GAAG;AAAA,OACzD,CAAA;AAAA,IACH,CAAA,SAAE;AACA,MAAA,cAAA,CAAe,MAAA,CAAO,QAAQ,SAAS,CAAA;AAAA,IACzC;AAAA,EACF;AACF,CAAC,CAAA","file":"check.worker.js","sourcesContent":["import { verifySpec } from \"@ts-model-checker/core\";\nimport type { WorkerRequest, WorkerResponse } from \"./protocol\";\n\nconst activeRequests = new Map<string, { cancelled: boolean }>();\n\nfunction postWorkerMessage(msg: WorkerResponse): void {\n self.postMessage(msg);\n}\n\nself.addEventListener(\"message\", (event: MessageEvent<WorkerRequest>) => {\n const payload = event.data;\n\n if (payload.type === \"CANCEL\") {\n const state = activeRequests.get(payload.requestId);\n if (state) {\n state.cancelled = true;\n }\n return;\n }\n\n if (payload.type === \"CHECK_SPEC\") {\n const token = { cancelled: false };\n activeRequests.set(payload.requestId, token);\n\n try {\n const result = verifySpec(payload.spec, {\n ...payload.options,\n isAborted: () => token.cancelled,\n onProgress: (progress) => {\n postWorkerMessage({\n type: \"PROGRESS\",\n requestId: payload.requestId,\n progress,\n });\n },\n });\n\n postWorkerMessage({\n type: \"RESULT\",\n requestId: payload.requestId,\n result,\n });\n } catch (err) {\n postWorkerMessage({\n type: \"ERROR\",\n requestId: payload.requestId,\n message: err instanceof Error ? err.message : String(err),\n });\n } finally {\n activeRequests.delete(payload.requestId);\n }\n }\n});\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@ts-model-checker/core');
|
|
4
|
+
|
|
5
|
+
// src/client.ts
|
|
6
|
+
var requestCounter = 0;
|
|
7
|
+
function nextRequestId() {
|
|
8
|
+
requestCounter += 1;
|
|
9
|
+
return `req_${Date.now()}_${requestCounter}`;
|
|
10
|
+
}
|
|
11
|
+
function runModelCheckAsync(spec, options = {}) {
|
|
12
|
+
if (options.signal?.aborted) {
|
|
13
|
+
return Promise.resolve({ status: "CANCELLED", statesExplored: 0 });
|
|
14
|
+
}
|
|
15
|
+
const canUseWorker = typeof Worker !== "undefined" && typeof options.createWorker === "function";
|
|
16
|
+
if (!canUseWorker) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
const result = core.verifySpec(spec, {
|
|
20
|
+
maxStates: options.maxStates,
|
|
21
|
+
checkDeadlocks: options.checkDeadlocks,
|
|
22
|
+
checkLiveness: options.checkLiveness,
|
|
23
|
+
progressInterval: options.progressInterval,
|
|
24
|
+
onProgress: options.onProgress,
|
|
25
|
+
isAborted: () => options.signal?.aborted ?? false
|
|
26
|
+
});
|
|
27
|
+
resolve(result);
|
|
28
|
+
}, 0);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const requestId = nextRequestId();
|
|
33
|
+
const worker = options.createWorker();
|
|
34
|
+
const cleanup = () => {
|
|
35
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
36
|
+
worker.removeEventListener("message", onMessage);
|
|
37
|
+
worker.removeEventListener("error", onError);
|
|
38
|
+
worker.terminate();
|
|
39
|
+
};
|
|
40
|
+
const onAbort = () => {
|
|
41
|
+
const cancelMsg = { type: "CANCEL", requestId };
|
|
42
|
+
worker.postMessage(cancelMsg);
|
|
43
|
+
cleanup();
|
|
44
|
+
resolve({ status: "CANCELLED", statesExplored: 0 });
|
|
45
|
+
};
|
|
46
|
+
const onMessage = (event) => {
|
|
47
|
+
const msg = event.data;
|
|
48
|
+
if (msg.requestId !== requestId) return;
|
|
49
|
+
if (msg.type === "PROGRESS") {
|
|
50
|
+
options.onProgress?.(msg.progress);
|
|
51
|
+
} else if (msg.type === "RESULT") {
|
|
52
|
+
cleanup();
|
|
53
|
+
resolve(msg.result);
|
|
54
|
+
} else if (msg.type === "ERROR") {
|
|
55
|
+
cleanup();
|
|
56
|
+
reject(new Error(msg.message));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const onError = (err) => {
|
|
60
|
+
cleanup();
|
|
61
|
+
reject(new Error(err.message || "Web Worker execution failed"));
|
|
62
|
+
};
|
|
63
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
64
|
+
worker.addEventListener("message", onMessage);
|
|
65
|
+
worker.addEventListener("error", onError);
|
|
66
|
+
const request = {
|
|
67
|
+
type: "CHECK_SPEC",
|
|
68
|
+
requestId,
|
|
69
|
+
spec,
|
|
70
|
+
options: {
|
|
71
|
+
maxStates: options.maxStates,
|
|
72
|
+
checkDeadlocks: options.checkDeadlocks,
|
|
73
|
+
checkLiveness: options.checkLiveness,
|
|
74
|
+
progressInterval: options.progressInterval
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
worker.postMessage(request);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.runModelCheckAsync = runModelCheckAsync;
|
|
82
|
+
//# sourceMappingURL=index.cjs.map
|
|
83
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":["verifySpec"],"mappings":";;;;;AAmBA,IAAI,cAAA,GAAiB,CAAA;AACrB,SAAS,aAAA,GAAwB;AAC/B,EAAA,cAAA,IAAkB,CAAA;AAClB,EAAA,OAAO,CAAA,IAAA,EAAO,IAAA,CAAK,GAAA,EAAK,IAAI,cAAc,CAAA,CAAA;AAC5C;AAMO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,GAAiC,EAAC,EACL;AAC7B,EAAA,IAAI,OAAA,CAAQ,QAAQ,OAAA,EAAS;AAC3B,IAAA,OAAO,QAAQ,OAAA,CAAQ,EAAE,QAAQ,WAAA,EAAa,cAAA,EAAgB,GAAG,CAAA;AAAA,EACnE;AAEA,EAAA,MAAM,eACJ,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,QAAQ,YAAA,KAAiB,UAAA;AAEnE,EAAA,IAAI,CAAC,YAAA,E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KACF;AACA,IAAA,MAAA,CAAO,YAAY,OAAO,CAAA;AAAA,EAC5B,CAAC,CAAA;AACH","file":"index.cjs","sourcesContent":["import {\n verifySpec,\n type CheckerProgress,\n type VerificationResult,\n type VisualSpecIR,\n} from \"@ts-model-checker/core\";\nimport type {\n WorkerCheckOptions,\n WorkerRequest,\n WorkerResponse,\n} from \"./protocol\";\n\nexport interface RunWorkerCheckOptions extends WorkerCheckOptions {\n /** Optional custom Worker factory (e.g., `() => new Worker(new URL(...), { type: 'module' })`). */\n readonly createWorker?: () => Worker;\n readonly onProgress?: (progress: CheckerProgress) => void;\n readonly signal?: AbortSignal;\n}\n\nlet requestCounter = 0;\nfunction nextRequestId(): string {\n requestCounter += 1;\n return `req_${Date.now()}_${requestCounter}`;\n}\n\n/**\n * Runs model verification asynchronously inside a Web Worker when available,\n * with a clean async fallback when running in Node.js or environments without Worker.\n */\nexport function runModelCheckAsync(\n spec: VisualSpecIR,\n options: RunWorkerCheckOptions = {}\n): Promise<VerificationResult> {\n if (options.signal?.aborted) {\n return Promise.resolve({ status: \"CANCELLED\", statesExplored: 0 });\n }\n\n const canUseWorker =\n typeof Worker !== \"undefined\" && typeof options.createWorker === \"function\";\n\n if (!canUseWorker) {\n return new Promise((resolve) => {\n setTimeout(() => {\n const result = verifySpec(spec, {\n maxStates: options.maxStates,\n checkDeadlocks: options.checkDeadlocks,\n checkLiveness: options.checkLiveness,\n progressInterval: options.progressInterval,\n onProgress: options.onProgress,\n isAborted: () => options.signal?.aborted ?? false,\n });\n resolve(result);\n }, 0);\n });\n }\n\n return new Promise((resolve, reject) => {\n const requestId = nextRequestId();\n const worker = options.createWorker!();\n\n const cleanup = () => {\n options.signal?.removeEventListener(\"abort\", onAbort);\n worker.removeEventListener(\"message\", onMessage);\n worker.removeEventListener(\"error\", onError);\n worker.terminate();\n };\n\n const onAbort = () => {\n const cancelMsg: WorkerRequest = { type: \"CANCEL\", requestId };\n worker.postMessage(cancelMsg);\n cleanup();\n resolve({ status: \"CANCELLED\", statesExplored: 0 });\n };\n\n const onMessage = (event: MessageEvent<WorkerResponse>) => {\n const msg = event.data;\n if (msg.requestId !== requestId) return;\n\n if (msg.type === \"PROGRESS\") {\n options.onProgress?.(msg.progress);\n } else if (msg.type === \"RESULT\") {\n cleanup();\n resolve(msg.result);\n } else if (msg.type === \"ERROR\") {\n cleanup();\n reject(new Error(msg.message));\n }\n };\n\n const onError = (err: ErrorEvent) => {\n cleanup();\n reject(new Error(err.message || \"Web Worker execution failed\"));\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n worker.addEventListener(\"message\", onMessage);\n worker.addEventListener(\"error\", onError);\n\n const request: WorkerRequest = {\n type: \"CHECK_SPEC\",\n requestId,\n spec,\n options: {\n maxStates: options.maxStates,\n checkDeadlocks: options.checkDeadlocks,\n checkLiveness: options.checkLiveness,\n progressInterval: options.progressInterval,\n },\n };\n worker.postMessage(request);\n });\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CheckerOptions, VisualSpecIR, CheckerProgress, VerificationResult } from '@ts-model-checker/core';
|
|
2
|
+
|
|
3
|
+
type WorkerCheckOptions = Pick<CheckerOptions, "maxStates" | "checkDeadlocks" | "checkLiveness" | "progressInterval">;
|
|
4
|
+
type WorkerRequest = {
|
|
5
|
+
readonly type: "CHECK_SPEC";
|
|
6
|
+
readonly requestId: string;
|
|
7
|
+
readonly spec: VisualSpecIR;
|
|
8
|
+
readonly options?: WorkerCheckOptions;
|
|
9
|
+
} | {
|
|
10
|
+
readonly type: "CANCEL";
|
|
11
|
+
readonly requestId: string;
|
|
12
|
+
};
|
|
13
|
+
type WorkerResponse = {
|
|
14
|
+
readonly type: "PROGRESS";
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
readonly progress: CheckerProgress;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: "RESULT";
|
|
19
|
+
readonly requestId: string;
|
|
20
|
+
readonly result: VerificationResult;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "ERROR";
|
|
23
|
+
readonly requestId: string;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface RunWorkerCheckOptions extends WorkerCheckOptions {
|
|
28
|
+
/** Optional custom Worker factory (e.g., `() => new Worker(new URL(...), { type: 'module' })`). */
|
|
29
|
+
readonly createWorker?: () => Worker;
|
|
30
|
+
readonly onProgress?: (progress: CheckerProgress) => void;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs model verification asynchronously inside a Web Worker when available,
|
|
35
|
+
* with a clean async fallback when running in Node.js or environments without Worker.
|
|
36
|
+
*/
|
|
37
|
+
declare function runModelCheckAsync(spec: VisualSpecIR, options?: RunWorkerCheckOptions): Promise<VerificationResult>;
|
|
38
|
+
|
|
39
|
+
export { type RunWorkerCheckOptions, type WorkerCheckOptions, type WorkerRequest, type WorkerResponse, runModelCheckAsync };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CheckerOptions, VisualSpecIR, CheckerProgress, VerificationResult } from '@ts-model-checker/core';
|
|
2
|
+
|
|
3
|
+
type WorkerCheckOptions = Pick<CheckerOptions, "maxStates" | "checkDeadlocks" | "checkLiveness" | "progressInterval">;
|
|
4
|
+
type WorkerRequest = {
|
|
5
|
+
readonly type: "CHECK_SPEC";
|
|
6
|
+
readonly requestId: string;
|
|
7
|
+
readonly spec: VisualSpecIR;
|
|
8
|
+
readonly options?: WorkerCheckOptions;
|
|
9
|
+
} | {
|
|
10
|
+
readonly type: "CANCEL";
|
|
11
|
+
readonly requestId: string;
|
|
12
|
+
};
|
|
13
|
+
type WorkerResponse = {
|
|
14
|
+
readonly type: "PROGRESS";
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
readonly progress: CheckerProgress;
|
|
17
|
+
} | {
|
|
18
|
+
readonly type: "RESULT";
|
|
19
|
+
readonly requestId: string;
|
|
20
|
+
readonly result: VerificationResult;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: "ERROR";
|
|
23
|
+
readonly requestId: string;
|
|
24
|
+
readonly message: string;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
interface RunWorkerCheckOptions extends WorkerCheckOptions {
|
|
28
|
+
/** Optional custom Worker factory (e.g., `() => new Worker(new URL(...), { type: 'module' })`). */
|
|
29
|
+
readonly createWorker?: () => Worker;
|
|
30
|
+
readonly onProgress?: (progress: CheckerProgress) => void;
|
|
31
|
+
readonly signal?: AbortSignal;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs model verification asynchronously inside a Web Worker when available,
|
|
35
|
+
* with a clean async fallback when running in Node.js or environments without Worker.
|
|
36
|
+
*/
|
|
37
|
+
declare function runModelCheckAsync(spec: VisualSpecIR, options?: RunWorkerCheckOptions): Promise<VerificationResult>;
|
|
38
|
+
|
|
39
|
+
export { type RunWorkerCheckOptions, type WorkerCheckOptions, type WorkerRequest, type WorkerResponse, runModelCheckAsync };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { verifySpec } from '@ts-model-checker/core';
|
|
2
|
+
|
|
3
|
+
// src/client.ts
|
|
4
|
+
var requestCounter = 0;
|
|
5
|
+
function nextRequestId() {
|
|
6
|
+
requestCounter += 1;
|
|
7
|
+
return `req_${Date.now()}_${requestCounter}`;
|
|
8
|
+
}
|
|
9
|
+
function runModelCheckAsync(spec, options = {}) {
|
|
10
|
+
if (options.signal?.aborted) {
|
|
11
|
+
return Promise.resolve({ status: "CANCELLED", statesExplored: 0 });
|
|
12
|
+
}
|
|
13
|
+
const canUseWorker = typeof Worker !== "undefined" && typeof options.createWorker === "function";
|
|
14
|
+
if (!canUseWorker) {
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
setTimeout(() => {
|
|
17
|
+
const result = verifySpec(spec, {
|
|
18
|
+
maxStates: options.maxStates,
|
|
19
|
+
checkDeadlocks: options.checkDeadlocks,
|
|
20
|
+
checkLiveness: options.checkLiveness,
|
|
21
|
+
progressInterval: options.progressInterval,
|
|
22
|
+
onProgress: options.onProgress,
|
|
23
|
+
isAborted: () => options.signal?.aborted ?? false
|
|
24
|
+
});
|
|
25
|
+
resolve(result);
|
|
26
|
+
}, 0);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const requestId = nextRequestId();
|
|
31
|
+
const worker = options.createWorker();
|
|
32
|
+
const cleanup = () => {
|
|
33
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
34
|
+
worker.removeEventListener("message", onMessage);
|
|
35
|
+
worker.removeEventListener("error", onError);
|
|
36
|
+
worker.terminate();
|
|
37
|
+
};
|
|
38
|
+
const onAbort = () => {
|
|
39
|
+
const cancelMsg = { type: "CANCEL", requestId };
|
|
40
|
+
worker.postMessage(cancelMsg);
|
|
41
|
+
cleanup();
|
|
42
|
+
resolve({ status: "CANCELLED", statesExplored: 0 });
|
|
43
|
+
};
|
|
44
|
+
const onMessage = (event) => {
|
|
45
|
+
const msg = event.data;
|
|
46
|
+
if (msg.requestId !== requestId) return;
|
|
47
|
+
if (msg.type === "PROGRESS") {
|
|
48
|
+
options.onProgress?.(msg.progress);
|
|
49
|
+
} else if (msg.type === "RESULT") {
|
|
50
|
+
cleanup();
|
|
51
|
+
resolve(msg.result);
|
|
52
|
+
} else if (msg.type === "ERROR") {
|
|
53
|
+
cleanup();
|
|
54
|
+
reject(new Error(msg.message));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onError = (err) => {
|
|
58
|
+
cleanup();
|
|
59
|
+
reject(new Error(err.message || "Web Worker execution failed"));
|
|
60
|
+
};
|
|
61
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
62
|
+
worker.addEventListener("message", onMessage);
|
|
63
|
+
worker.addEventListener("error", onError);
|
|
64
|
+
const request = {
|
|
65
|
+
type: "CHECK_SPEC",
|
|
66
|
+
requestId,
|
|
67
|
+
spec,
|
|
68
|
+
options: {
|
|
69
|
+
maxStates: options.maxStates,
|
|
70
|
+
checkDeadlocks: options.checkDeadlocks,
|
|
71
|
+
checkLiveness: options.checkLiveness,
|
|
72
|
+
progressInterval: options.progressInterval
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
worker.postMessage(request);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { runModelCheckAsync };
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;AAmBA,IAAI,cAAA,GAAiB,CAAA;AACrB,SAAS,aAAA,GAAwB;AAC/B,EAAA,cAAA,IAAkB,CAAA;AAClB,EAAA,OAAO,CAAA,IAAA,EAAO,IAAA,CAAK,GAAA,EAAK,IAAI,cAAc,CAAA,CAAA;AAC5C;AAMO,SAAS,kBAAA,CACd,IAAA,EACA,OAAA,GAAiC,EAAC,EACL;AAC7B,EAAA,IAAI,OAAA,CAAQ,QAAQ,OAAA,EAAS;AAC3B,IAAA,OAAO,QAAQ,OAAA,CAAQ,EAAE,QAAQ,WAAA,EAAa,cAAA,EAAgB,GAAG,CAAA;AAAA,EACnE;AAEA,EAAA,MAAM,eACJ,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,QAAQ,YAAA,KAAiB,UAAA;AAEnE,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC9B,MAAA,UAAA,CAAW,MAAM;AACf,QAAA,MAAM,MAAA,GAAS,WAAW,IAAA,EAAM;AAAA,UAC9B,WAAW,OAAA,CAAQ,SAAA;AAAA,UACnB,gBAAgB,OAAA,CAAQ,cAAA;AAAA,UACxB,eAAe,OAAA,CAAQ,aAAA;AAAA,UACv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AW,GAAA,CAAI,IAAA,KAAS,QAAA,EAAU;AAChC,QAAA,OAAA,EAAQ;AACR,QAAA,OAAA,CAAQ,IAAI,MAAM,CAAA;AAAA,MACpB,CAAA,MAAA,IAAW,GAAA,CAAI,IAAA,KAAS,OAAA,EAAS;AAC/B,QAAA,OAAA,EAAQ;AACR,QAAA,MAAA,CAAO,IAAI,KAAA,CAAM,GAAA,CAAI,OAAO,CAAC,CAAA;AAAA,MAC/B;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,OAAA,GAAU,CAAC,GAAA,KAAoB;AACnC,MAAA,OAAA,EAAQ;AACR,MAAA,MAAA,CAAO,IAAI,KAAA,CAAM,GAAA,CAAI,OAAA,IAAW,6BAA6B,CAAC,CAAA;AAAA,IAChE,CAAA;AAEA,IAAA,OAAA,CAAQ,QAAQ,gBAAA,CAAiB,OAAA,EAAS,SAAS,EAAE,IAAA,EAAM,MAAM,CAAA;AACjE,IAAA,MAAA,CAAO,gBAAA,CAAiB,WAAW,SAAS,CAAA;AAC5C,IAAA,MAAA,CAAO,gBAAA,CAAiB,SAAS,OAAO,CAAA;AAExC,IAAA,MAAM,OAAA,GAAyB;AAAA,MAC7B,IAAA,EAAM,YAAA;AAAA,MACN,SAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAA,EAAS;AAAA,QACP,WAAW,OAAA,CAAQ,SAAA;AAAA,QACnB,gBAAgB,OAAA,CAAQ,cAAA;AAAA,QACxB,eAAe,OAAA,CAAQ,aAAA;AAAA,QACvB,kBAAkB,OAAA,CAAQ;AAAA;AAC5B,KACF;AACA,IAAA,MAAA,CAAO,YAAY,OAAO,CAAA;AAAA,EAC5B,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import {\n verifySpec,\n type CheckerProgress,\n type VerificationResult,\n type VisualSpecIR,\n} from \"@ts-model-checker/core\";\nimport type {\n WorkerCheckOptions,\n WorkerRequest,\n WorkerResponse,\n} from \"./protocol\";\n\nexport interface RunWorkerCheckOptions extends WorkerCheckOptions {\n /** Optional custom Worker factory (e.g., `() => new Worker(new URL(...), { type: 'module' })`). */\n readonly createWorker?: () => Worker;\n readonly onProgress?: (progress: CheckerProgress) => void;\n readonly signal?: AbortSignal;\n}\n\nlet requestCounter = 0;\nfunction nextRequestId(): string {\n requestCounter += 1;\n return `req_${Date.now()}_${requestCounter}`;\n}\n\n/**\n * Runs model verification asynchronously inside a Web Worker when available,\n * with a clean async fallback when running in Node.js or environments without Worker.\n */\nexport function runModelCheckAsync(\n spec: VisualSpecIR,\n options: RunWorkerCheckOptions = {}\n): Promise<VerificationResult> {\n if (options.signal?.aborted) {\n return Promise.resolve({ status: \"CANCELLED\", statesExplored: 0 });\n }\n\n const canUseWorker =\n typeof Worker !== \"undefined\" && typeof options.createWorker === \"function\";\n\n if (!canUseWorker) {\n return new Promise((resolve) => {\n setTimeout(() => {\n const result = verifySpec(spec, {\n maxStates: options.maxStates,\n checkDeadlocks: options.checkDeadlocks,\n checkLiveness: options.checkLiveness,\n progressInterval: options.progressInterval,\n onProgress: options.onProgress,\n isAborted: () => options.signal?.aborted ?? false,\n });\n resolve(result);\n }, 0);\n });\n }\n\n return new Promise((resolve, reject) => {\n const requestId = nextRequestId();\n const worker = options.createWorker!();\n\n const cleanup = () => {\n options.signal?.removeEventListener(\"abort\", onAbort);\n worker.removeEventListener(\"message\", onMessage);\n worker.removeEventListener(\"error\", onError);\n worker.terminate();\n };\n\n const onAbort = () => {\n const cancelMsg: WorkerRequest = { type: \"CANCEL\", requestId };\n worker.postMessage(cancelMsg);\n cleanup();\n resolve({ status: \"CANCELLED\", statesExplored: 0 });\n };\n\n const onMessage = (event: MessageEvent<WorkerResponse>) => {\n const msg = event.data;\n if (msg.requestId !== requestId) return;\n\n if (msg.type === \"PROGRESS\") {\n options.onProgress?.(msg.progress);\n } else if (msg.type === \"RESULT\") {\n cleanup();\n resolve(msg.result);\n } else if (msg.type === \"ERROR\") {\n cleanup();\n reject(new Error(msg.message));\n }\n };\n\n const onError = (err: ErrorEvent) => {\n cleanup();\n reject(new Error(err.message || \"Web Worker execution failed\"));\n };\n\n options.signal?.addEventListener(\"abort\", onAbort, { once: true });\n worker.addEventListener(\"message\", onMessage);\n worker.addEventListener(\"error\", onError);\n\n const request: WorkerRequest = {\n type: \"CHECK_SPEC\",\n requestId,\n spec,\n options: {\n maxStates: options.maxStates,\n checkDeadlocks: options.checkDeadlocks,\n checkLiveness: options.checkLiveness,\n progressInterval: options.progressInterval,\n },\n };\n worker.postMessage(request);\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-model-checker/worker",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web Worker wrapper and async client for @ts-model-checker/core",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./worker": {
|
|
16
|
+
"types": "./dist/check.worker.d.ts",
|
|
17
|
+
"import": "./dist/check.worker.js",
|
|
18
|
+
"require": "./dist/check.worker.cjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/k3ybladewielder/ts-model-checker.git",
|
|
30
|
+
"directory": "packages/worker"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@ts-model-checker/core": "0.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsup": "^8.3.5",
|
|
37
|
+
"typescript": "^5.7.2",
|
|
38
|
+
"vitest": "^2.1.8"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
}
|
|
6
45
|
}
|
package/README.md
DELETED