@self-review/core 2.0.4 → 2.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/README.md +441 -0
- package/dist/chunk-5SGPWHGH.cjs +106 -0
- package/dist/chunk-5SGPWHGH.cjs.map +1 -0
- package/dist/chunk-6OEFXBIZ.cjs +5212 -0
- package/dist/chunk-6OEFXBIZ.cjs.map +1 -0
- package/dist/chunk-6X3PJHP5.cjs +416 -0
- package/dist/chunk-6X3PJHP5.cjs.map +1 -0
- package/dist/chunk-CJQEOLI3.js +37 -0
- package/dist/chunk-CJQEOLI3.js.map +1 -0
- package/dist/chunk-IG2YF5LH.js +416 -0
- package/dist/chunk-IG2YF5LH.js.map +1 -0
- package/dist/chunk-IX226KG4.js +106 -0
- package/dist/chunk-IX226KG4.js.map +1 -0
- package/dist/chunk-LSLCQQBN.cjs +3684 -0
- package/dist/chunk-LSLCQQBN.cjs.map +1 -0
- package/dist/chunk-MOYO4RIX.js +3684 -0
- package/dist/chunk-MOYO4RIX.js.map +1 -0
- package/dist/chunk-TOUYY7I6.js +5212 -0
- package/dist/chunk-TOUYY7I6.js.map +1 -0
- package/dist/chunk-VOYTFLPH.cjs +37 -0
- package/dist/chunk-VOYTFLPH.cjs.map +1 -0
- package/dist/filesystem.cjs +56 -0
- package/dist/filesystem.cjs.map +1 -0
- package/dist/filesystem.d.cts +22 -0
- package/dist/filesystem.d.ts +22 -0
- package/dist/filesystem.js +56 -0
- package/dist/index.cjs +348 -6192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +80 -1332
- package/dist/index.d.ts +80 -1332
- package/dist/index.js +234 -5172
- package/dist/index.js.map +1 -1
- package/dist/node-scan-fs-CaufzUZR.d.cts +5 -0
- package/dist/node-scan-fs-DcHI_BYB.d.ts +5 -0
- package/dist/operations-Bqhi9EBH.d.ts +765 -0
- package/dist/operations-UyiUD2Nx.d.cts +765 -0
- package/dist/operations.cjs +91 -0
- package/dist/operations.cjs.map +1 -0
- package/dist/operations.d.cts +6 -0
- package/dist/operations.d.ts +6 -0
- package/dist/operations.js +91 -0
- package/dist/resume-worker.cjs +152 -0
- package/dist/resume-worker.cjs.map +1 -0
- package/dist/resume-worker.d.cts +56 -0
- package/dist/resume-worker.d.ts +56 -0
- package/dist/resume-worker.js +152 -0
- package/dist/resume-worker.js.map +1 -0
- package/dist/review-request-validation-VJG7XZiE.d.cts +62 -0
- package/dist/review-request-validation-VJG7XZiE.d.ts +62 -0
- package/dist/review-xml-decoder-COgRtfkf.d.cts +33 -0
- package/dist/review-xml-decoder-COgRtfkf.d.ts +33 -0
- package/dist/source-identity-CQpAzugz.d.cts +959 -0
- package/dist/source-identity-CQpAzugz.d.ts +959 -0
- package/dist/validation.cjs +67 -0
- package/dist/validation.cjs.map +1 -0
- package/dist/validation.d.cts +30 -0
- package/dist/validation.d.ts +30 -0
- package/dist/validation.js +67 -0
- package/dist/validation.js.map +1 -0
- package/package.json +44 -3
- package/dist/chunk-4YO2MI6B.js +0 -269
- package/dist/chunk-4YO2MI6B.js.map +0 -1
- package/dist/chunk-QHS36X6T.js +0 -450
- package/dist/chunk-QHS36X6T.js.map +0 -1
- package/dist/diff-parser-B6S3KG5T.js +0 -9
- package/dist/git-N5HVNPKQ.js +0 -24
- /package/dist/{diff-parser-B6S3KG5T.js.map → filesystem.js.map} +0 -0
- /package/dist/{git-N5HVNPKQ.js.map → operations.js.map} +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var _chunk6OEFXBIZcjs = require('./chunk-6OEFXBIZ.cjs');
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
var _chunkLSLCQQBNcjs = require('./chunk-LSLCQQBN.cjs');
|
|
46
|
+
require('./chunk-5SGPWHGH.cjs');
|
|
47
|
+
require('./chunk-6X3PJHP5.cjs');
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
exports.ConfiguredDiffArgsError = _chunk6OEFXBIZcjs.ConfiguredDiffArgsError; exports.ReviewPublishError = _chunk6OEFXBIZcjs.ReviewPublishError; exports.adoptResumeDocument = _chunk6OEFXBIZcjs.adoptResumeDocument; exports.applySuggestionForSession = _chunkLSLCQQBNcjs.applySuggestionForSession; exports.applySuggestionForSessionAsync = _chunkLSLCQQBNcjs.applySuggestionForSessionAsync; exports.bootstrapRemoteDiff = _chunk6OEFXBIZcjs.bootstrapRemoteDiff; exports.commitDiffData = _chunkLSLCQQBNcjs.commitDiffData; exports.commitLoadedReview = _chunkLSLCQQBNcjs.commitLoadedReview; exports.commitReviewStart = _chunk6OEFXBIZcjs.commitReviewStart; exports.createReviewSession = _chunkLSLCQQBNcjs.createReviewSession; exports.getDiffLoad = _chunkLSLCQQBNcjs.getDiffLoad; exports.inspectOutputPath = _chunk6OEFXBIZcjs.inspectOutputPath; exports.inspectOutputPathAsync = _chunk6OEFXBIZcjs.inspectOutputPathAsync; exports.loadConfig = _chunk6OEFXBIZcjs.loadConfig; exports.loadConfigWithProvenance = _chunk6OEFXBIZcjs.loadConfigWithProvenance; exports.loadGitReviewSnapshot = _chunk6OEFXBIZcjs.loadGitReviewSnapshot; exports.loadGuide = _chunk6OEFXBIZcjs.loadGuide; exports.loadImage = _chunk6OEFXBIZcjs.loadImage; exports.loadLocalReview = _chunk6OEFXBIZcjs.loadLocalReview; exports.loadResumeDocument = _chunk6OEFXBIZcjs.loadResumeDocument; exports.loadedReviewIdentity = _chunkLSLCQQBNcjs.loadedReviewIdentity; exports.loadedReviewPaths = _chunkLSLCQQBNcjs.loadedReviewPaths; exports.nodeOutputPathInspection = _chunk6OEFXBIZcjs.nodeOutputPathInspection; exports.prepareDirectoryReview = _chunk6OEFXBIZcjs.prepareDirectoryReview; exports.publishOptionsFor = _chunk6OEFXBIZcjs.publishOptionsFor; exports.publishReview = _chunk6OEFXBIZcjs.publishReview; exports.readAttachment = _chunk6OEFXBIZcjs.readAttachment; exports.readLoadedReviewContent = _chunk6OEFXBIZcjs.readLoadedReviewContent; exports.recordResumedAttachments = _chunk6OEFXBIZcjs.recordResumedAttachments; exports.resolveAttachmentOrigins = _chunk6OEFXBIZcjs.resolveAttachmentOrigins; exports.resolveAttachmentOriginsAtDirectory = _chunk6OEFXBIZcjs.resolveAttachmentOriginsAtDirectory; exports.resolveLocalSourceIdentityAsync = _chunkLSLCQQBNcjs.resolveLocalSourceIdentityAsync; exports.resolveOutputTarget = _chunk6OEFXBIZcjs.resolveOutputTarget; exports.resolveStartupDiffArgs = _chunk6OEFXBIZcjs.resolveStartupDiffArgs; exports.resolveStartupSourceAsync = _chunk6OEFXBIZcjs.resolveStartupSourceAsync; exports.runFetchComments = _chunk6OEFXBIZcjs.runFetchComments; exports.scanDirectory = _chunk6OEFXBIZcjs.scanDirectory; exports.scanFile = _chunk6OEFXBIZcjs.scanFile; exports.setApplyDestination = _chunkLSLCQQBNcjs.setApplyDestination; exports.submitReviewState = _chunkLSLCQQBNcjs.submitReviewState; exports.takeReviewState = _chunkLSLCQQBNcjs.takeReviewState;
|
|
91
|
+
//# sourceMappingURL=operations.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/self-review/self-review/packages/core/dist/operations.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,swFAAC","file":"/home/runner/work/self-review/self-review/packages/core/dist/operations.cjs"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { aB as AsyncInspectOutputPathOptions, aC as AttachmentReader, aD as BoundedGuideReader, C as ConfigProvenance, f as ConfiguredDiffArgsError, g as FetchCommentsOptions, G as GitSnapshotDependencies, L as LoadConfigOptions, j as LoadGuideOptions, aE as LoadImageOptions, k as LoadedConfig, l as LoadedLocalReview, m as LocalReviewDependencies, n as LocalReviewLoadOptions, aF as OutputPathInspection, P as PublishReviewOptions, s as PublishReviewResult, aG as ReadAttachmentOptions, t as RemoteBootstrapResult, u as RemoteLifetimeOptions, y as ResolvedDiffArgs, aH as ResumeDocumentOptions, A as ReviewOutputTarget, H as ReviewPublishError, R as ReviewSchemaValidator, U as SourceScanOptions, V as SourceScanResult, aI as StartupPathProbe, aJ as StartupPathStats, X as StartupSource, aK as StartupSourceOptions, Y as adoptResumeDocument, _ as bootstrapRemoteDiff, a0 as commitReviewStart, a7 as inspectOutputPath, aL as inspectOutputPathAsync, a8 as loadConfig, a9 as loadConfigWithProvenance, ab as loadGitReviewSnapshot, ac as loadGuide, ad as loadImage, ae as loadLocalReview, ag as loadResumeDocument, aM as nodeOutputPathInspection, aj as prepareDirectoryReview, ak as publishOptionsFor, al as publishReview, am as readAttachment, ap as readLoadedReviewContent, aq as recordResumedAttachments, aN as resolveAttachmentOriginsAtDirectory, as as resolveOutputTarget, au as resolveStartupDiffArgs, aw as resolveStartupSourceAsync, ax as runFetchComments, ay as scanDirectory, az as scanFile } from './operations-UyiUD2Nx.cjs';
|
|
2
|
+
export { a0 as ApplySuggestionForSessionAsyncOptions, bw as ApplySuggestionForSessionOptions, Q as DiagnosticReporter, as as LoadedReview, L as LocalSourcePaths, P as PublicationFileSystem, bv as ResolvedAttachmentLocation, Y as ReviewSession, aM as SuggestionOperationOptions, T as TemporaryCloneStorage, aR as applySuggestionForSession, aS as applySuggestionForSessionAsync, aV as commitDiffData, aW as commitLoadedReview, aX as createReviewSession, b2 as getDiffLoad, bb as loadedReviewIdentity, bc as loadedReviewPaths, bj as resolveAttachmentOrigins, bm as resolveLocalSourceIdentityAsync, bx as setApplyDestination, bs as submitReviewState, bt as takeReviewState } from './source-identity-CQpAzugz.cjs';
|
|
3
|
+
import '@self-review/types';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import './review-xml-decoder-COgRtfkf.cjs';
|
|
6
|
+
import 'node:fs/promises';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { aB as AsyncInspectOutputPathOptions, aC as AttachmentReader, aD as BoundedGuideReader, C as ConfigProvenance, f as ConfiguredDiffArgsError, g as FetchCommentsOptions, G as GitSnapshotDependencies, L as LoadConfigOptions, j as LoadGuideOptions, aE as LoadImageOptions, k as LoadedConfig, l as LoadedLocalReview, m as LocalReviewDependencies, n as LocalReviewLoadOptions, aF as OutputPathInspection, P as PublishReviewOptions, s as PublishReviewResult, aG as ReadAttachmentOptions, t as RemoteBootstrapResult, u as RemoteLifetimeOptions, y as ResolvedDiffArgs, aH as ResumeDocumentOptions, A as ReviewOutputTarget, H as ReviewPublishError, R as ReviewSchemaValidator, U as SourceScanOptions, V as SourceScanResult, aI as StartupPathProbe, aJ as StartupPathStats, X as StartupSource, aK as StartupSourceOptions, Y as adoptResumeDocument, _ as bootstrapRemoteDiff, a0 as commitReviewStart, a7 as inspectOutputPath, aL as inspectOutputPathAsync, a8 as loadConfig, a9 as loadConfigWithProvenance, ab as loadGitReviewSnapshot, ac as loadGuide, ad as loadImage, ae as loadLocalReview, ag as loadResumeDocument, aM as nodeOutputPathInspection, aj as prepareDirectoryReview, ak as publishOptionsFor, al as publishReview, am as readAttachment, ap as readLoadedReviewContent, aq as recordResumedAttachments, aN as resolveAttachmentOriginsAtDirectory, as as resolveOutputTarget, au as resolveStartupDiffArgs, aw as resolveStartupSourceAsync, ax as runFetchComments, ay as scanDirectory, az as scanFile } from './operations-Bqhi9EBH.js';
|
|
2
|
+
export { a0 as ApplySuggestionForSessionAsyncOptions, bw as ApplySuggestionForSessionOptions, Q as DiagnosticReporter, as as LoadedReview, L as LocalSourcePaths, P as PublicationFileSystem, bv as ResolvedAttachmentLocation, Y as ReviewSession, aM as SuggestionOperationOptions, T as TemporaryCloneStorage, aR as applySuggestionForSession, aS as applySuggestionForSessionAsync, aV as commitDiffData, aW as commitLoadedReview, aX as createReviewSession, b2 as getDiffLoad, bb as loadedReviewIdentity, bc as loadedReviewPaths, bj as resolveAttachmentOrigins, bm as resolveLocalSourceIdentityAsync, bx as setApplyDestination, bs as submitReviewState, bt as takeReviewState } from './source-identity-CQpAzugz.js';
|
|
3
|
+
import '@self-review/types';
|
|
4
|
+
import 'node:fs';
|
|
5
|
+
import './review-xml-decoder-COgRtfkf.js';
|
|
6
|
+
import 'node:fs/promises';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfiguredDiffArgsError,
|
|
3
|
+
ReviewPublishError,
|
|
4
|
+
adoptResumeDocument,
|
|
5
|
+
bootstrapRemoteDiff,
|
|
6
|
+
commitReviewStart,
|
|
7
|
+
inspectOutputPath,
|
|
8
|
+
inspectOutputPathAsync,
|
|
9
|
+
loadConfig,
|
|
10
|
+
loadConfigWithProvenance,
|
|
11
|
+
loadGitReviewSnapshot,
|
|
12
|
+
loadGuide,
|
|
13
|
+
loadImage,
|
|
14
|
+
loadLocalReview,
|
|
15
|
+
loadResumeDocument,
|
|
16
|
+
nodeOutputPathInspection,
|
|
17
|
+
prepareDirectoryReview,
|
|
18
|
+
publishOptionsFor,
|
|
19
|
+
publishReview,
|
|
20
|
+
readAttachment,
|
|
21
|
+
readLoadedReviewContent,
|
|
22
|
+
recordResumedAttachments,
|
|
23
|
+
resolveAttachmentOrigins,
|
|
24
|
+
resolveAttachmentOriginsAtDirectory,
|
|
25
|
+
resolveOutputTarget,
|
|
26
|
+
resolveStartupDiffArgs,
|
|
27
|
+
resolveStartupSourceAsync,
|
|
28
|
+
runFetchComments,
|
|
29
|
+
scanDirectory,
|
|
30
|
+
scanFile
|
|
31
|
+
} from "./chunk-TOUYY7I6.js";
|
|
32
|
+
import {
|
|
33
|
+
applySuggestionForSession,
|
|
34
|
+
applySuggestionForSessionAsync,
|
|
35
|
+
commitDiffData,
|
|
36
|
+
commitLoadedReview,
|
|
37
|
+
createReviewSession,
|
|
38
|
+
getDiffLoad,
|
|
39
|
+
loadedReviewIdentity,
|
|
40
|
+
loadedReviewPaths,
|
|
41
|
+
resolveLocalSourceIdentityAsync,
|
|
42
|
+
setApplyDestination,
|
|
43
|
+
submitReviewState,
|
|
44
|
+
takeReviewState
|
|
45
|
+
} from "./chunk-MOYO4RIX.js";
|
|
46
|
+
import "./chunk-IX226KG4.js";
|
|
47
|
+
import "./chunk-IG2YF5LH.js";
|
|
48
|
+
export {
|
|
49
|
+
ConfiguredDiffArgsError,
|
|
50
|
+
ReviewPublishError,
|
|
51
|
+
adoptResumeDocument,
|
|
52
|
+
applySuggestionForSession,
|
|
53
|
+
applySuggestionForSessionAsync,
|
|
54
|
+
bootstrapRemoteDiff,
|
|
55
|
+
commitDiffData,
|
|
56
|
+
commitLoadedReview,
|
|
57
|
+
commitReviewStart,
|
|
58
|
+
createReviewSession,
|
|
59
|
+
getDiffLoad,
|
|
60
|
+
inspectOutputPath,
|
|
61
|
+
inspectOutputPathAsync,
|
|
62
|
+
loadConfig,
|
|
63
|
+
loadConfigWithProvenance,
|
|
64
|
+
loadGitReviewSnapshot,
|
|
65
|
+
loadGuide,
|
|
66
|
+
loadImage,
|
|
67
|
+
loadLocalReview,
|
|
68
|
+
loadResumeDocument,
|
|
69
|
+
loadedReviewIdentity,
|
|
70
|
+
loadedReviewPaths,
|
|
71
|
+
nodeOutputPathInspection,
|
|
72
|
+
prepareDirectoryReview,
|
|
73
|
+
publishOptionsFor,
|
|
74
|
+
publishReview,
|
|
75
|
+
readAttachment,
|
|
76
|
+
readLoadedReviewContent,
|
|
77
|
+
recordResumedAttachments,
|
|
78
|
+
resolveAttachmentOrigins,
|
|
79
|
+
resolveAttachmentOriginsAtDirectory,
|
|
80
|
+
resolveLocalSourceIdentityAsync,
|
|
81
|
+
resolveOutputTarget,
|
|
82
|
+
resolveStartupDiffArgs,
|
|
83
|
+
resolveStartupSourceAsync,
|
|
84
|
+
runFetchComments,
|
|
85
|
+
scanDirectory,
|
|
86
|
+
scanFile,
|
|
87
|
+
setApplyDestination,
|
|
88
|
+
submitReviewState,
|
|
89
|
+
takeReviewState
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=operations.js.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/resume-worker-protocol.ts
|
|
2
|
+
function readResumeReply(reply, id, restoreFailure) {
|
|
3
|
+
if (!isRecord(reply) || reply.id !== id) {
|
|
4
|
+
throw new Error("Resume parser returned an unowned reply");
|
|
5
|
+
}
|
|
6
|
+
if (reply.kind === "failed" && isFailure(reply.error)) throw restoreFailure(reply.error);
|
|
7
|
+
if (reply.kind === "parsed" && isRecord(reply.parsed) && Array.isArray(reply.parsed.comments) && Array.isArray(reply.parsed.viewedFiles) && Array.isArray(reply.parsed.importDiagnostics)) {
|
|
8
|
+
return reply.parsed;
|
|
9
|
+
}
|
|
10
|
+
throw new Error("Resume parser returned an invalid reply");
|
|
11
|
+
}
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return value !== null && typeof value === "object";
|
|
14
|
+
}
|
|
15
|
+
function isFailure(value) {
|
|
16
|
+
return isRecord(value) && typeof value.message === "string" && ["name", "stack", "code"].every(
|
|
17
|
+
(key) => value[key] === void 0 || typeof value[key] === "string"
|
|
18
|
+
) && (value.details === void 0 || Array.isArray(value.details) && value.details.every((detail) => typeof detail === "string"));
|
|
19
|
+
}
|
|
20
|
+
function describeResumeFailure(error, xmlDetails) {
|
|
21
|
+
if (!(error instanceof Error)) return { name: "Error", message: String(error) };
|
|
22
|
+
return {
|
|
23
|
+
name: error.name,
|
|
24
|
+
message: error.message,
|
|
25
|
+
stack: error.stack,
|
|
26
|
+
...xmlDetails(error),
|
|
27
|
+
cause: describeCause(error.cause)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function restoreResumeFailure(failure, createXmlError) {
|
|
31
|
+
const cause = restoreCause(failure.cause);
|
|
32
|
+
const error = failure.code ? createXmlError(failure.code, failure.message, { details: failure.details, cause }) : Object.assign(new Error(failure.message), cause === void 0 ? {} : { cause });
|
|
33
|
+
if (failure.name !== void 0) error.name = failure.name;
|
|
34
|
+
if (failure.stack) error.stack = failure.stack;
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
function describeCause(cause) {
|
|
38
|
+
if (!(cause instanceof Error)) return cause;
|
|
39
|
+
const native = cause;
|
|
40
|
+
return {
|
|
41
|
+
name: native.name,
|
|
42
|
+
message: native.message,
|
|
43
|
+
stack: native.stack,
|
|
44
|
+
code: native.code,
|
|
45
|
+
errno: native.errno,
|
|
46
|
+
path: native.path,
|
|
47
|
+
syscall: native.syscall
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function restoreCause(cause) {
|
|
51
|
+
if (!isRecord(cause) || typeof cause.message !== "string") return cause;
|
|
52
|
+
return Object.assign(new Error(cause.message), cause);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/resume-worker.ts
|
|
56
|
+
function checkResumeOwnership(options) {
|
|
57
|
+
_optionalChain([options, 'access', _ => _.signal, 'optionalAccess', _2 => _2.throwIfAborted, 'call', _3 => _3()]);
|
|
58
|
+
if (options.isCurrent && !options.isCurrent()) {
|
|
59
|
+
throw new DOMException("Resume operation is no longer current", "AbortError");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var ResumeWorkerTerminationError = class extends Error {
|
|
63
|
+
constructor(terminationError, cause) {
|
|
64
|
+
super("Resume parser termination failed; worker release is unconfirmed");
|
|
65
|
+
this.name = "ResumeWorkerTerminationError";
|
|
66
|
+
this.cause = cause;
|
|
67
|
+
this.terminationError = terminationError;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
async function runResumeWorker(worker, request, options, restoreFailure) {
|
|
71
|
+
let cancellation;
|
|
72
|
+
let timer;
|
|
73
|
+
let onMessage;
|
|
74
|
+
let onError;
|
|
75
|
+
let onExit;
|
|
76
|
+
let onAbort;
|
|
77
|
+
const outcome = await new Promise((resolve, reject) => {
|
|
78
|
+
const cancel = (reason) => {
|
|
79
|
+
_nullishCoalesce(cancellation, () => ( (cancellation = { reason })));
|
|
80
|
+
reject(cancellation.reason);
|
|
81
|
+
};
|
|
82
|
+
onAbort = () => cancel(options.signal.reason);
|
|
83
|
+
onMessage = (reply) => {
|
|
84
|
+
try {
|
|
85
|
+
resolve(readResumeReply(reply, request.id, restoreFailure));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
reject(error);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
onError = reject;
|
|
91
|
+
onExit = (code) => reject(new Error(`Resume parser exited before replying (code ${code})`));
|
|
92
|
+
worker.on("message", onMessage);
|
|
93
|
+
worker.on("error", onError);
|
|
94
|
+
worker.on("exit", onExit);
|
|
95
|
+
_optionalChain([options, 'access', _4 => _4.signal, 'optionalAccess', _5 => _5.addEventListener, 'call', _6 => _6("abort", onAbort, { once: true })]);
|
|
96
|
+
try {
|
|
97
|
+
const requested = _nullishCoalesce(options.timeoutMs, () => ( 3e4));
|
|
98
|
+
if (!Number.isFinite(requested) || requested < 0) {
|
|
99
|
+
throw new RangeError("Resume timeout must be a nonnegative finite number");
|
|
100
|
+
}
|
|
101
|
+
const timeoutMs = requested === 0 ? 3e4 : Math.min(Math.ceil(requested), 2147483647);
|
|
102
|
+
timer = setTimeout(
|
|
103
|
+
() => cancel(new DOMException("Resume parsing timed out", "TimeoutError")),
|
|
104
|
+
timeoutMs
|
|
105
|
+
);
|
|
106
|
+
checkResumeOwnership(options);
|
|
107
|
+
if (!request || typeof request.id !== "string" || typeof request.path !== "string") {
|
|
108
|
+
throw new Error("Invalid resume parser request");
|
|
109
|
+
}
|
|
110
|
+
worker.postMessage(request);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
reject(error);
|
|
113
|
+
}
|
|
114
|
+
}).then(
|
|
115
|
+
(parsed) => ({ ok: true, parsed }),
|
|
116
|
+
(error) => ({ ok: false, error })
|
|
117
|
+
);
|
|
118
|
+
let termination;
|
|
119
|
+
try {
|
|
120
|
+
await worker.terminate();
|
|
121
|
+
} catch (error) {
|
|
122
|
+
termination = { error };
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
worker.off("message", onMessage);
|
|
126
|
+
worker.off("error", onError);
|
|
127
|
+
worker.off("exit", onExit);
|
|
128
|
+
_optionalChain([options, 'access', _7 => _7.signal, 'optionalAccess', _8 => _8.removeEventListener, 'call', _9 => _9("abort", onAbort)]);
|
|
129
|
+
}
|
|
130
|
+
let failure = _nullishCoalesce(cancellation, () => ( (outcome.ok ? void 0 : { reason: outcome.error })));
|
|
131
|
+
try {
|
|
132
|
+
checkResumeOwnership(options);
|
|
133
|
+
} catch (reason) {
|
|
134
|
+
failure = { reason };
|
|
135
|
+
}
|
|
136
|
+
if (termination) {
|
|
137
|
+
if (failure) throw new ResumeWorkerTerminationError(termination.error, failure.reason);
|
|
138
|
+
throw termination.error;
|
|
139
|
+
}
|
|
140
|
+
if (failure) throw failure.reason;
|
|
141
|
+
if (outcome.ok) return outcome.parsed;
|
|
142
|
+
throw outcome.error;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
exports.ResumeWorkerTerminationError = ResumeWorkerTerminationError; exports.checkResumeOwnership = checkResumeOwnership; exports.describeResumeFailure = describeResumeFailure; exports.readResumeReply = readResumeReply; exports.restoreResumeFailure = restoreResumeFailure; exports.runResumeWorker = runResumeWorker;
|
|
152
|
+
//# sourceMappingURL=resume-worker.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/self-review/self-review/packages/core/dist/resume-worker.cjs","../src/resume-worker-protocol.ts","../src/resume-worker.ts"],"names":[],"mappings":"AAAA;ACsBO,SAAS,eAAA,CACd,KAAA,EACA,EAAA,EACA,cAAA,EACc;AACd,EAAA,GAAA,CAAI,CAAC,QAAA,CAAS,KAAK,EAAA,GAAK,KAAA,CAAM,GAAA,IAAO,EAAA,EAAI;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,yCAAyC,CAAA;AAAA,EAC3D;AACA,EAAA,GAAA,CAAI,KAAA,CAAM,KAAA,IAAS,SAAA,GAAY,SAAA,CAAU,KAAA,CAAM,KAAK,CAAA,EAAG,MAAM,cAAA,CAAe,KAAA,CAAM,KAAK,CAAA;AACvF,EAAA,GAAA,CACE,KAAA,CAAM,KAAA,IAAS,SAAA,GACf,QAAA,CAAS,KAAA,CAAM,MAAM,EAAA,GACrB,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,QAAQ,EAAA,GACnC,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,WAAW,EAAA,GACtC,KAAA,CAAM,OAAA,CAAQ,KAAA,CAAM,MAAA,CAAO,iBAAiB,CAAA,EAC5C;AACA,IAAA,OAAO,KAAA,CAAM,MAAA;AAAA,EACf;AACA,EAAA,MAAM,IAAI,KAAA,CAAM,yCAAyC,CAAA;AAC3D;AAEA,SAAS,QAAA,CAAS,KAAA,EAAkD;AAClE,EAAA,OAAO,MAAA,IAAU,KAAA,GAAQ,OAAO,MAAA,IAAU,QAAA;AAC5C;AAEA,SAAS,SAAA,CAAU,KAAA,EAA6C;AAC9D,EAAA,OACE,QAAA,CAAS,KAAK,EAAA,GACd,OAAO,KAAA,CAAM,QAAA,IAAY,SAA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AAa;AACf,IAAA,GAAA,CAAI,OAAA,EAAS,MAAM,IAAI,4BAAA,CAA6B,WAAA,CAAY,KAAA,EAAO,OAAA,CAAQ,MAAM,CAAA;AACrF,IAAA,MAAM,WAAA,CAAY,KAAA;AAAA,EACpB;AACA,EAAA,GAAA,CAAI,OAAA,EAAS,MAAM,OAAA,CAAQ,MAAA;AAC3B,EAAA,GAAA,CAAI,OAAA,CAAQ,EAAA,EAAI,OAAO,OAAA,CAAQ,MAAA;AAC/B,EAAA,MAAM,OAAA,CAAQ,KAAA;AAChB;AFwBA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,2TAAC","file":"/home/runner/work/self-review/self-review/packages/core/dist/resume-worker.cjs","sourcesContent":[null,"import type { ParsedReview } from './xml-parser';\n\nexport interface ResumeParseRequest {\n id: string;\n path: string;\n}\n\n/** Name/stack/cause are additive; legacy serve failures only carried message/code/details. */\nexport interface ResumeParseFailure {\n name?: string;\n message: string;\n stack?: string;\n code?: string;\n details?: readonly string[];\n cause?: unknown;\n}\n\nexport type ResumeParseReply =\n | { id: string; kind: 'parsed'; parsed: ParsedReview }\n | { id: string; kind: 'failed'; error: ResumeParseFailure };\n\n/** Validates the reply envelope without changing the parser's result or optional metadata. */\nexport function readResumeReply(\n reply: unknown,\n id: string,\n restoreFailure: (failure: ResumeParseFailure) => Error\n): ParsedReview {\n if (!isRecord(reply) || reply.id !== id) {\n throw new Error('Resume parser returned an unowned reply');\n }\n if (reply.kind === 'failed' && isFailure(reply.error)) throw restoreFailure(reply.error);\n if (\n reply.kind === 'parsed' &&\n isRecord(reply.parsed) &&\n Array.isArray(reply.parsed.comments) &&\n Array.isArray(reply.parsed.viewedFiles) &&\n Array.isArray(reply.parsed.importDiagnostics)\n ) {\n return reply.parsed as unknown as ParsedReview;\n }\n throw new Error('Resume parser returned an invalid reply');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object';\n}\n\nfunction isFailure(value: unknown): value is ResumeParseFailure {\n return (\n isRecord(value) &&\n typeof value.message === 'string' &&\n ['name', 'stack', 'code'].every(\n key => value[key] === undefined || typeof value[key] === 'string'\n ) &&\n (value.details === undefined ||\n (Array.isArray(value.details) && value.details.every(detail => typeof detail === 'string')))\n );\n}\n\nexport function describeResumeFailure(\n error: unknown,\n xmlDetails: (error: Error) => Pick<ResumeParseFailure, 'code' | 'details'> | undefined\n): ResumeParseFailure {\n if (!(error instanceof Error)) return { name: 'Error', message: String(error) };\n return {\n name: error.name,\n message: error.message,\n stack: error.stack,\n ...xmlDetails(error),\n cause: describeCause((error as Error & { cause?: unknown }).cause),\n };\n}\n\nexport function restoreResumeFailure(\n failure: ResumeParseFailure,\n createXmlError: (\n code: string,\n message: string,\n options: { details?: readonly string[]; cause?: unknown }\n ) => Error\n): Error {\n const cause = restoreCause(failure.cause);\n const error = failure.code\n ? createXmlError(failure.code, failure.message, { details: failure.details, cause })\n : Object.assign(new Error(failure.message), cause === undefined ? {} : { cause });\n if (failure.name !== undefined) error.name = failure.name;\n if (failure.stack) error.stack = failure.stack;\n return error;\n}\n\n// Native Error structured cloning drops errno/code/path. Preserve read diagnostics explicitly.\nfunction describeCause(cause: unknown): unknown {\n if (!(cause instanceof Error)) return cause;\n const native = cause as NodeJS.ErrnoException;\n return {\n name: native.name,\n message: native.message,\n stack: native.stack,\n code: native.code,\n errno: native.errno,\n path: native.path,\n syscall: native.syscall,\n };\n}\n\nfunction restoreCause(cause: unknown): unknown {\n if (!isRecord(cause) || typeof cause.message !== 'string') return cause;\n return Object.assign(new Error(cause.message), cause);\n}\n","// Host-owned one-shot resume work. No parser, filesystem or runtime Core class imports.\nimport type { Worker } from 'node:worker_threads';\nimport type { ParsedReview } from './xml-parser';\nimport { readResumeReply } from './resume-worker-protocol';\nimport type { ResumeParseFailure, ResumeParseRequest } from './resume-worker-protocol';\nexport * from './resume-worker-protocol';\n\nexport interface ResumeWorkerOptions {\n signal?: AbortSignal;\n /** Omitted/zero: 30s; positive fractions round up; capped at 2^31-1 ms. */\n timeoutMs?: number;\n /** The host must revoke ownership when replacing the operation. */\n isCurrent?: () => boolean;\n}\n\nexport function checkResumeOwnership(options: ResumeWorkerOptions): void {\n options.signal?.throwIfAborted();\n if (options.isCurrent && !options.isCurrent()) {\n throw new DOMException('Resume operation is no longer current', 'AbortError');\n }\n}\n\n/** A rejected terminate cannot establish that cancellation released the worker. */\nexport class ResumeWorkerTerminationError extends Error {\n readonly cause: unknown;\n readonly terminationError: unknown;\n\n constructor(terminationError: unknown, cause: unknown) {\n super('Resume parser termination failed; worker release is unconfirmed');\n this.name = 'ResumeWorkerTerminationError';\n this.cause = cause;\n this.terminationError = terminationError;\n }\n}\n\n/**\n * Owns the supplied worker immediately, even on admission/delivery failure. Never\n * adopts a reply before termination. Abort/deadline remain active until reaped.\n * The host reconstructs failures with its installed peer's error constructors.\n */\nexport async function runResumeWorker(\n worker: Pick<Worker, 'on' | 'off' | 'postMessage' | 'terminate'>,\n request: ResumeParseRequest,\n options: ResumeWorkerOptions,\n restoreFailure: (failure: ResumeParseFailure) => Error\n): Promise<ParsedReview> {\n let cancellation: { reason: unknown } | undefined;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let onMessage!: (reply: unknown) => void;\n let onError!: (error: Error) => void;\n let onExit!: (code: number) => void;\n let onAbort!: () => void;\n const outcome = await new Promise<ParsedReview>((resolve, reject) => {\n const cancel = (reason: unknown) => {\n // Retain even falsy abort reasons, and the first deadline/abort identity.\n cancellation ??= { reason };\n reject(cancellation.reason);\n };\n onAbort = () => cancel(options.signal!.reason);\n onMessage = reply => {\n try {\n resolve(readResumeReply(reply, request.id, restoreFailure));\n } catch (error) {\n reject(error);\n }\n };\n onError = reject;\n onExit = code => reject(new Error(`Resume parser exited before replying (code ${code})`));\n worker.on('message', onMessage);\n worker.on('error', onError);\n worker.on('exit', onExit);\n options.signal?.addEventListener('abort', onAbort, { once: true });\n try {\n const requested = options.timeoutMs ?? 30_000;\n if (!Number.isFinite(requested) || requested < 0) {\n throw new RangeError('Resume timeout must be a nonnegative finite number');\n }\n const timeoutMs = requested === 0 ? 30_000 : Math.min(Math.ceil(requested), 2_147_483_647);\n timer = setTimeout(\n () => cancel(new DOMException('Resume parsing timed out', 'TimeoutError')),\n timeoutMs\n );\n checkResumeOwnership(options);\n if (!request || typeof request.id !== 'string' || typeof request.path !== 'string') {\n throw new Error('Invalid resume parser request');\n }\n worker.postMessage(request);\n } catch (error) {\n reject(error);\n }\n }).then(\n parsed => ({ ok: true as const, parsed }),\n (error: unknown) => ({ ok: false as const, error })\n );\n let termination: { error: unknown } | undefined;\n try {\n await worker.terminate();\n } catch (error) {\n termination = { error };\n } finally {\n clearTimeout(timer);\n worker.off('message', onMessage);\n worker.off('error', onError);\n worker.off('exit', onExit);\n options.signal?.removeEventListener('abort', onAbort);\n }\n let failure = cancellation ?? (outcome.ok ? undefined : { reason: outcome.error });\n try {\n checkResumeOwnership(options);\n } catch (reason) {\n failure = { reason };\n }\n if (termination) {\n if (failure) throw new ResumeWorkerTerminationError(termination.error, failure.reason);\n throw termination.error;\n }\n if (failure) throw failure.reason;\n if (outcome.ok) return outcome.parsed;\n throw outcome.error;\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Worker } from 'node:worker_threads';
|
|
2
|
+
import { P as ParsedReview } from './review-xml-decoder-COgRtfkf.cjs';
|
|
3
|
+
import '@self-review/types';
|
|
4
|
+
|
|
5
|
+
interface ResumeParseRequest {
|
|
6
|
+
id: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}
|
|
9
|
+
/** Name/stack/cause are additive; legacy serve failures only carried message/code/details. */
|
|
10
|
+
interface ResumeParseFailure {
|
|
11
|
+
name?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
stack?: string;
|
|
14
|
+
code?: string;
|
|
15
|
+
details?: readonly string[];
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
}
|
|
18
|
+
type ResumeParseReply = {
|
|
19
|
+
id: string;
|
|
20
|
+
kind: 'parsed';
|
|
21
|
+
parsed: ParsedReview;
|
|
22
|
+
} | {
|
|
23
|
+
id: string;
|
|
24
|
+
kind: 'failed';
|
|
25
|
+
error: ResumeParseFailure;
|
|
26
|
+
};
|
|
27
|
+
/** Validates the reply envelope without changing the parser's result or optional metadata. */
|
|
28
|
+
declare function readResumeReply(reply: unknown, id: string, restoreFailure: (failure: ResumeParseFailure) => Error): ParsedReview;
|
|
29
|
+
declare function describeResumeFailure(error: unknown, xmlDetails: (error: Error) => Pick<ResumeParseFailure, 'code' | 'details'> | undefined): ResumeParseFailure;
|
|
30
|
+
declare function restoreResumeFailure(failure: ResumeParseFailure, createXmlError: (code: string, message: string, options: {
|
|
31
|
+
details?: readonly string[];
|
|
32
|
+
cause?: unknown;
|
|
33
|
+
}) => Error): Error;
|
|
34
|
+
|
|
35
|
+
interface ResumeWorkerOptions {
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
/** Omitted/zero: 30s; positive fractions round up; capped at 2^31-1 ms. */
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
/** The host must revoke ownership when replacing the operation. */
|
|
40
|
+
isCurrent?: () => boolean;
|
|
41
|
+
}
|
|
42
|
+
declare function checkResumeOwnership(options: ResumeWorkerOptions): void;
|
|
43
|
+
/** A rejected terminate cannot establish that cancellation released the worker. */
|
|
44
|
+
declare class ResumeWorkerTerminationError extends Error {
|
|
45
|
+
readonly cause: unknown;
|
|
46
|
+
readonly terminationError: unknown;
|
|
47
|
+
constructor(terminationError: unknown, cause: unknown);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Owns the supplied worker immediately, even on admission/delivery failure. Never
|
|
51
|
+
* adopts a reply before termination. Abort/deadline remain active until reaped.
|
|
52
|
+
* The host reconstructs failures with its installed peer's error constructors.
|
|
53
|
+
*/
|
|
54
|
+
declare function runResumeWorker(worker: Pick<Worker, 'on' | 'off' | 'postMessage' | 'terminate'>, request: ResumeParseRequest, options: ResumeWorkerOptions, restoreFailure: (failure: ResumeParseFailure) => Error): Promise<ParsedReview>;
|
|
55
|
+
|
|
56
|
+
export { type ResumeParseFailure, type ResumeParseReply, type ResumeParseRequest, type ResumeWorkerOptions, ResumeWorkerTerminationError, checkResumeOwnership, describeResumeFailure, readResumeReply, restoreResumeFailure, runResumeWorker };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Worker } from 'node:worker_threads';
|
|
2
|
+
import { P as ParsedReview } from './review-xml-decoder-COgRtfkf.js';
|
|
3
|
+
import '@self-review/types';
|
|
4
|
+
|
|
5
|
+
interface ResumeParseRequest {
|
|
6
|
+
id: string;
|
|
7
|
+
path: string;
|
|
8
|
+
}
|
|
9
|
+
/** Name/stack/cause are additive; legacy serve failures only carried message/code/details. */
|
|
10
|
+
interface ResumeParseFailure {
|
|
11
|
+
name?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
stack?: string;
|
|
14
|
+
code?: string;
|
|
15
|
+
details?: readonly string[];
|
|
16
|
+
cause?: unknown;
|
|
17
|
+
}
|
|
18
|
+
type ResumeParseReply = {
|
|
19
|
+
id: string;
|
|
20
|
+
kind: 'parsed';
|
|
21
|
+
parsed: ParsedReview;
|
|
22
|
+
} | {
|
|
23
|
+
id: string;
|
|
24
|
+
kind: 'failed';
|
|
25
|
+
error: ResumeParseFailure;
|
|
26
|
+
};
|
|
27
|
+
/** Validates the reply envelope without changing the parser's result or optional metadata. */
|
|
28
|
+
declare function readResumeReply(reply: unknown, id: string, restoreFailure: (failure: ResumeParseFailure) => Error): ParsedReview;
|
|
29
|
+
declare function describeResumeFailure(error: unknown, xmlDetails: (error: Error) => Pick<ResumeParseFailure, 'code' | 'details'> | undefined): ResumeParseFailure;
|
|
30
|
+
declare function restoreResumeFailure(failure: ResumeParseFailure, createXmlError: (code: string, message: string, options: {
|
|
31
|
+
details?: readonly string[];
|
|
32
|
+
cause?: unknown;
|
|
33
|
+
}) => Error): Error;
|
|
34
|
+
|
|
35
|
+
interface ResumeWorkerOptions {
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
/** Omitted/zero: 30s; positive fractions round up; capped at 2^31-1 ms. */
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
/** The host must revoke ownership when replacing the operation. */
|
|
40
|
+
isCurrent?: () => boolean;
|
|
41
|
+
}
|
|
42
|
+
declare function checkResumeOwnership(options: ResumeWorkerOptions): void;
|
|
43
|
+
/** A rejected terminate cannot establish that cancellation released the worker. */
|
|
44
|
+
declare class ResumeWorkerTerminationError extends Error {
|
|
45
|
+
readonly cause: unknown;
|
|
46
|
+
readonly terminationError: unknown;
|
|
47
|
+
constructor(terminationError: unknown, cause: unknown);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Owns the supplied worker immediately, even on admission/delivery failure. Never
|
|
51
|
+
* adopts a reply before termination. Abort/deadline remain active until reaped.
|
|
52
|
+
* The host reconstructs failures with its installed peer's error constructors.
|
|
53
|
+
*/
|
|
54
|
+
declare function runResumeWorker(worker: Pick<Worker, 'on' | 'off' | 'postMessage' | 'terminate'>, request: ResumeParseRequest, options: ResumeWorkerOptions, restoreFailure: (failure: ResumeParseFailure) => Error): Promise<ParsedReview>;
|
|
55
|
+
|
|
56
|
+
export { type ResumeParseFailure, type ResumeParseReply, type ResumeParseRequest, type ResumeWorkerOptions, ResumeWorkerTerminationError, checkResumeOwnership, describeResumeFailure, readResumeReply, restoreResumeFailure, runResumeWorker };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// src/resume-worker-protocol.ts
|
|
2
|
+
function readResumeReply(reply, id, restoreFailure) {
|
|
3
|
+
if (!isRecord(reply) || reply.id !== id) {
|
|
4
|
+
throw new Error("Resume parser returned an unowned reply");
|
|
5
|
+
}
|
|
6
|
+
if (reply.kind === "failed" && isFailure(reply.error)) throw restoreFailure(reply.error);
|
|
7
|
+
if (reply.kind === "parsed" && isRecord(reply.parsed) && Array.isArray(reply.parsed.comments) && Array.isArray(reply.parsed.viewedFiles) && Array.isArray(reply.parsed.importDiagnostics)) {
|
|
8
|
+
return reply.parsed;
|
|
9
|
+
}
|
|
10
|
+
throw new Error("Resume parser returned an invalid reply");
|
|
11
|
+
}
|
|
12
|
+
function isRecord(value) {
|
|
13
|
+
return value !== null && typeof value === "object";
|
|
14
|
+
}
|
|
15
|
+
function isFailure(value) {
|
|
16
|
+
return isRecord(value) && typeof value.message === "string" && ["name", "stack", "code"].every(
|
|
17
|
+
(key) => value[key] === void 0 || typeof value[key] === "string"
|
|
18
|
+
) && (value.details === void 0 || Array.isArray(value.details) && value.details.every((detail) => typeof detail === "string"));
|
|
19
|
+
}
|
|
20
|
+
function describeResumeFailure(error, xmlDetails) {
|
|
21
|
+
if (!(error instanceof Error)) return { name: "Error", message: String(error) };
|
|
22
|
+
return {
|
|
23
|
+
name: error.name,
|
|
24
|
+
message: error.message,
|
|
25
|
+
stack: error.stack,
|
|
26
|
+
...xmlDetails(error),
|
|
27
|
+
cause: describeCause(error.cause)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function restoreResumeFailure(failure, createXmlError) {
|
|
31
|
+
const cause = restoreCause(failure.cause);
|
|
32
|
+
const error = failure.code ? createXmlError(failure.code, failure.message, { details: failure.details, cause }) : Object.assign(new Error(failure.message), cause === void 0 ? {} : { cause });
|
|
33
|
+
if (failure.name !== void 0) error.name = failure.name;
|
|
34
|
+
if (failure.stack) error.stack = failure.stack;
|
|
35
|
+
return error;
|
|
36
|
+
}
|
|
37
|
+
function describeCause(cause) {
|
|
38
|
+
if (!(cause instanceof Error)) return cause;
|
|
39
|
+
const native = cause;
|
|
40
|
+
return {
|
|
41
|
+
name: native.name,
|
|
42
|
+
message: native.message,
|
|
43
|
+
stack: native.stack,
|
|
44
|
+
code: native.code,
|
|
45
|
+
errno: native.errno,
|
|
46
|
+
path: native.path,
|
|
47
|
+
syscall: native.syscall
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function restoreCause(cause) {
|
|
51
|
+
if (!isRecord(cause) || typeof cause.message !== "string") return cause;
|
|
52
|
+
return Object.assign(new Error(cause.message), cause);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/resume-worker.ts
|
|
56
|
+
function checkResumeOwnership(options) {
|
|
57
|
+
options.signal?.throwIfAborted();
|
|
58
|
+
if (options.isCurrent && !options.isCurrent()) {
|
|
59
|
+
throw new DOMException("Resume operation is no longer current", "AbortError");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
var ResumeWorkerTerminationError = class extends Error {
|
|
63
|
+
constructor(terminationError, cause) {
|
|
64
|
+
super("Resume parser termination failed; worker release is unconfirmed");
|
|
65
|
+
this.name = "ResumeWorkerTerminationError";
|
|
66
|
+
this.cause = cause;
|
|
67
|
+
this.terminationError = terminationError;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
async function runResumeWorker(worker, request, options, restoreFailure) {
|
|
71
|
+
let cancellation;
|
|
72
|
+
let timer;
|
|
73
|
+
let onMessage;
|
|
74
|
+
let onError;
|
|
75
|
+
let onExit;
|
|
76
|
+
let onAbort;
|
|
77
|
+
const outcome = await new Promise((resolve, reject) => {
|
|
78
|
+
const cancel = (reason) => {
|
|
79
|
+
cancellation ?? (cancellation = { reason });
|
|
80
|
+
reject(cancellation.reason);
|
|
81
|
+
};
|
|
82
|
+
onAbort = () => cancel(options.signal.reason);
|
|
83
|
+
onMessage = (reply) => {
|
|
84
|
+
try {
|
|
85
|
+
resolve(readResumeReply(reply, request.id, restoreFailure));
|
|
86
|
+
} catch (error) {
|
|
87
|
+
reject(error);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
onError = reject;
|
|
91
|
+
onExit = (code) => reject(new Error(`Resume parser exited before replying (code ${code})`));
|
|
92
|
+
worker.on("message", onMessage);
|
|
93
|
+
worker.on("error", onError);
|
|
94
|
+
worker.on("exit", onExit);
|
|
95
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
96
|
+
try {
|
|
97
|
+
const requested = options.timeoutMs ?? 3e4;
|
|
98
|
+
if (!Number.isFinite(requested) || requested < 0) {
|
|
99
|
+
throw new RangeError("Resume timeout must be a nonnegative finite number");
|
|
100
|
+
}
|
|
101
|
+
const timeoutMs = requested === 0 ? 3e4 : Math.min(Math.ceil(requested), 2147483647);
|
|
102
|
+
timer = setTimeout(
|
|
103
|
+
() => cancel(new DOMException("Resume parsing timed out", "TimeoutError")),
|
|
104
|
+
timeoutMs
|
|
105
|
+
);
|
|
106
|
+
checkResumeOwnership(options);
|
|
107
|
+
if (!request || typeof request.id !== "string" || typeof request.path !== "string") {
|
|
108
|
+
throw new Error("Invalid resume parser request");
|
|
109
|
+
}
|
|
110
|
+
worker.postMessage(request);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
reject(error);
|
|
113
|
+
}
|
|
114
|
+
}).then(
|
|
115
|
+
(parsed) => ({ ok: true, parsed }),
|
|
116
|
+
(error) => ({ ok: false, error })
|
|
117
|
+
);
|
|
118
|
+
let termination;
|
|
119
|
+
try {
|
|
120
|
+
await worker.terminate();
|
|
121
|
+
} catch (error) {
|
|
122
|
+
termination = { error };
|
|
123
|
+
} finally {
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
worker.off("message", onMessage);
|
|
126
|
+
worker.off("error", onError);
|
|
127
|
+
worker.off("exit", onExit);
|
|
128
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
129
|
+
}
|
|
130
|
+
let failure = cancellation ?? (outcome.ok ? void 0 : { reason: outcome.error });
|
|
131
|
+
try {
|
|
132
|
+
checkResumeOwnership(options);
|
|
133
|
+
} catch (reason) {
|
|
134
|
+
failure = { reason };
|
|
135
|
+
}
|
|
136
|
+
if (termination) {
|
|
137
|
+
if (failure) throw new ResumeWorkerTerminationError(termination.error, failure.reason);
|
|
138
|
+
throw termination.error;
|
|
139
|
+
}
|
|
140
|
+
if (failure) throw failure.reason;
|
|
141
|
+
if (outcome.ok) return outcome.parsed;
|
|
142
|
+
throw outcome.error;
|
|
143
|
+
}
|
|
144
|
+
export {
|
|
145
|
+
ResumeWorkerTerminationError,
|
|
146
|
+
checkResumeOwnership,
|
|
147
|
+
describeResumeFailure,
|
|
148
|
+
readResumeReply,
|
|
149
|
+
restoreResumeFailure,
|
|
150
|
+
runResumeWorker
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=resume-worker.js.map
|