@systemfsoftware/stryker-js-instrumenter 8.0.1 → 8.0.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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +110 -73
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @systemfsoftware/stryker-js-instrumenter
|
|
2
2
|
|
|
3
|
+
## 8.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Exported declarations that previously took `unknown` now take a defaulted type parameter: calls that omit the type argument are unchanged, and calls that were previously rejected for passing an unconstrained value are accepted. No runtime behaviour changes.
|
|
8
|
+
|
|
3
9
|
## 8.0.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import * as Effect from 'effect/Effect';
|
|
|
2
2
|
import * as S from 'effect/Schema';
|
|
3
3
|
import { YieldableError } from 'effect/Cause';
|
|
4
4
|
|
|
5
|
-
export declare const causeText: (cause:
|
|
5
|
+
export declare const causeText: <A = unknown>(cause: A, depth: number) => string | undefined;
|
|
6
6
|
|
|
7
7
|
export declare interface Coverage {
|
|
8
8
|
readonly static: CoverageData;
|
|
@@ -31,7 +31,7 @@ export declare const ERROR_CODES: Readonly<{
|
|
|
31
31
|
NoSuchFileOrDirectory: 'ENOENT';
|
|
32
32
|
}>;
|
|
33
33
|
|
|
34
|
-
export declare function errorToString(error:
|
|
34
|
+
export declare function errorToString<A = unknown>(error: A): string;
|
|
35
35
|
|
|
36
36
|
declare interface File_2 extends FileDescription {
|
|
37
37
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -542,24 +542,29 @@ const COMMENT_KEYS = /* @__PURE__ */ new Set(["leadingComments", "trailingCommen
|
|
|
542
542
|
function isCommentKey(key) {
|
|
543
543
|
return typeof key === "string" && COMMENT_KEYS.has(key);
|
|
544
544
|
}
|
|
545
|
+
function walkTraverse(root, stack, visitors) {
|
|
546
|
+
walk(walkableNode(root), {
|
|
547
|
+
enter(node, _parent, context) {
|
|
548
|
+
readPath(stack, node, this, context, visitors);
|
|
549
|
+
},
|
|
550
|
+
leave(_node, _parent, context) {
|
|
551
|
+
closePath(stack, context, visitors);
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
const toTraverseError = (error) => error instanceof Error ? error : new Error("Traversal failed", { cause: error });
|
|
556
|
+
const handleTraverseError = (error) => {
|
|
557
|
+
const err = toTraverseError(error);
|
|
558
|
+
if (!S.is(TraversalStopped)(err)) throw err;
|
|
559
|
+
};
|
|
545
560
|
function traverse(root, visitors) {
|
|
546
561
|
const stack = [];
|
|
547
562
|
try {
|
|
548
|
-
|
|
549
|
-
enter(node, _parent, context) {
|
|
550
|
-
readPath(stack, node, this, context, visitors);
|
|
551
|
-
},
|
|
552
|
-
leave(_node, _parent, context) {
|
|
553
|
-
closePath(stack, context, visitors);
|
|
554
|
-
}
|
|
555
|
-
});
|
|
563
|
+
walkTraverse(root, stack, visitors);
|
|
556
564
|
} catch (error) {
|
|
557
|
-
|
|
565
|
+
handleTraverseError(error);
|
|
558
566
|
}
|
|
559
567
|
}
|
|
560
|
-
const rethrowUnlessStopped = (error) => {
|
|
561
|
-
if (!S.is(TraversalStopped)(error)) throw error;
|
|
562
|
-
};
|
|
563
568
|
const readPath = (stack, node, controls, context, visitors) => {
|
|
564
569
|
if (isCommentKey(context.key)) return;
|
|
565
570
|
const path = createPath(node, parentOf(stack), controls, context);
|
|
@@ -627,7 +632,7 @@ function writeInto(parent, key, index, replacement) {
|
|
|
627
632
|
writeAtKey(parent, key, index, replacement);
|
|
628
633
|
}
|
|
629
634
|
function writeAtKey(parent, key, index, replacement) {
|
|
630
|
-
|
|
635
|
+
if (Predicate.isString(key)) writeAtSlot(parent, key, index, replacement);
|
|
631
636
|
}
|
|
632
637
|
function writeAtSlot(parent, key, index, replacement) {
|
|
633
638
|
Match.value(index).pipe(Match.when(Match.null, () => overwrite(parent, key, replacement)), Match.orElse((position) => writeElement(parent[key], position, replacement)));
|
|
@@ -713,17 +718,16 @@ function isRangedBaseNode(value) {
|
|
|
713
718
|
function isNonEmptyArray(value) {
|
|
714
719
|
return Array.isArray(value) && value.length > 0;
|
|
715
720
|
}
|
|
716
|
-
function
|
|
717
|
-
return isPlainRecord(value) &&
|
|
721
|
+
function hasContentField(value) {
|
|
722
|
+
return isPlainRecord(value) && "content" in value;
|
|
718
723
|
}
|
|
719
|
-
function
|
|
720
|
-
return
|
|
721
|
-
}
|
|
722
|
-
function hasHtml(value) {
|
|
723
|
-
return hasField(value, "html");
|
|
724
|
+
function hasHtmlField(value) {
|
|
725
|
+
return isPlainRecord(value) && "html" in value;
|
|
724
726
|
}
|
|
727
|
+
const readRecordField = (record, key) => record[key];
|
|
725
728
|
function fieldOf$1(value, key) {
|
|
726
|
-
|
|
729
|
+
if (!isPlainRecord(value)) return void 0;
|
|
730
|
+
return readRecordField(value, key);
|
|
727
731
|
}
|
|
728
732
|
function appendIfDefined(values, value) {
|
|
729
733
|
if (value !== void 0) values.push(value);
|
|
@@ -998,12 +1002,12 @@ function isTextRange(value) {
|
|
|
998
1002
|
function isTemplateExpressionTag(value) {
|
|
999
1003
|
return isTypedRecord(value) && TEMPLATE_EXPRESSION_TYPES[value["type"]] === true;
|
|
1000
1004
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
+
const firstChild = (element) => {
|
|
1006
|
+
const children = element["children"];
|
|
1007
|
+
return isNonEmptyArray(children) ? Option.getOrUndefined(Arr.head(children)) : void 0;
|
|
1008
|
+
};
|
|
1005
1009
|
function scriptChild(node) {
|
|
1006
|
-
return
|
|
1010
|
+
return isScriptElement(node) ? firstChild(node) : void 0;
|
|
1007
1011
|
}
|
|
1008
1012
|
function tryGetScriptRangeFromElement(node) {
|
|
1009
1013
|
return Match.value(scriptChild(node)).pipe(Match.when(isTextRange, (range) => ({
|
|
@@ -1013,14 +1017,14 @@ function tryGetScriptRangeFromElement(node) {
|
|
|
1013
1017
|
})), Match.orElse(() => void 0));
|
|
1014
1018
|
}
|
|
1015
1019
|
function templateExpressionRange(node) {
|
|
1016
|
-
return
|
|
1020
|
+
return isTemplateExpressionTag(node) ? rangedExpressionOf(node["expression"]) : void 0;
|
|
1017
1021
|
}
|
|
1018
1022
|
function rangedExpressionOf(payload) {
|
|
1019
|
-
|
|
1020
|
-
start:
|
|
1021
|
-
end:
|
|
1023
|
+
if (isRangedBaseNode(payload)) return {
|
|
1024
|
+
start: payload.start,
|
|
1025
|
+
end: payload.end,
|
|
1022
1026
|
isExpression: true
|
|
1023
|
-
}
|
|
1027
|
+
};
|
|
1024
1028
|
}
|
|
1025
1029
|
/**
|
|
1026
1030
|
* Allow instrumentation of Svelte 5 projects without dropping support for Svelte 4.
|
|
@@ -1032,9 +1036,10 @@ const loadWalker = (version, fileName) => Match.value(isAtLeast(version, SVELTE_
|
|
|
1032
1036
|
* The specifier is chosen at run time and both modules are optional peers of
|
|
1033
1037
|
* this package, so neither can be a static import.
|
|
1034
1038
|
*/
|
|
1039
|
+
const findWalker = (module) => isRecordWithWalk(module) ? module.walk : void 0;
|
|
1035
1040
|
const loadWalkerModule = (specifier, fileName, cause) => Effect.gen(function* () {
|
|
1036
1041
|
const module = yield* Effect.promise(() => import(specifier));
|
|
1037
|
-
const walk =
|
|
1042
|
+
const walk = findWalker(module);
|
|
1038
1043
|
if (walk === void 0) return yield* SvelteWalkerNotFound.make({
|
|
1039
1044
|
fileName,
|
|
1040
1045
|
cause
|
|
@@ -1109,29 +1114,31 @@ function getTemplateScriptRanges(ast, walker) {
|
|
|
1109
1114
|
return ranges;
|
|
1110
1115
|
}
|
|
1111
1116
|
function htmlRootOf(ast) {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}));
|
|
1117
|
+
if (!hasHtmlField(ast)) throw new Error("Svelte AST without html");
|
|
1118
|
+
return ast["html"];
|
|
1115
1119
|
}
|
|
1116
1120
|
function instanceScriptRange(ast) {
|
|
1117
|
-
|
|
1121
|
+
const record = contentFieldOf(fieldOf$1(ast, "instance"));
|
|
1122
|
+
return record === void 0 ? void 0 : scriptContentRange(record["content"], INSTANCE_RANGE_MISSING);
|
|
1118
1123
|
}
|
|
1119
1124
|
function scriptContentRange(content, missingRange) {
|
|
1120
|
-
|
|
1121
|
-
start:
|
|
1122
|
-
end:
|
|
1125
|
+
if (isRange(content)) return {
|
|
1126
|
+
start: content.start,
|
|
1127
|
+
end: content.end,
|
|
1123
1128
|
isExpression: false
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
}));
|
|
1129
|
+
};
|
|
1130
|
+
throw new Error(missingRange);
|
|
1127
1131
|
}
|
|
1128
1132
|
function getModuleScriptRange(svelteAst) {
|
|
1129
1133
|
return Match.value(fieldOf$1(svelteAst, "module")).pipe(Match.when(void 0, () => void 0), Match.when(null, () => void 0), Match.orElse((block) => moduleBlockRange(block)));
|
|
1130
1134
|
}
|
|
1135
|
+
function contentFieldOf(value) {
|
|
1136
|
+
return Option.getOrUndefined(Option.filter(Option.fromNullishOr(value), hasContentField));
|
|
1137
|
+
}
|
|
1131
1138
|
function moduleBlockRange(block) {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1139
|
+
const record = contentFieldOf(block);
|
|
1140
|
+
if (record === void 0) throw new Error(MODULE_RANGE_MISSING);
|
|
1141
|
+
return scriptContentRange(record["content"], MODULE_RANGE_MISSING);
|
|
1135
1142
|
}
|
|
1136
1143
|
/**
|
|
1137
1144
|
* Remaps script locations back to the original places using the script map
|
|
@@ -3331,16 +3338,19 @@ function literalWithoutRegex(node) {
|
|
|
3331
3338
|
return valueLiteralText(node.value);
|
|
3332
3339
|
}
|
|
3333
3340
|
function valueLiteralText(value) {
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3341
|
+
if (typeof value === "string") return JSON.stringify(value);
|
|
3342
|
+
return nonStringLiteralText(value);
|
|
3343
|
+
}
|
|
3344
|
+
function nonStringLiteralText(value) {
|
|
3345
|
+
if (typeof value === "number") return String(value);
|
|
3346
|
+
return booleanOrBigintText(value);
|
|
3347
|
+
}
|
|
3348
|
+
function booleanOrBigintText(value) {
|
|
3349
|
+
if (typeof value === "boolean") return String(value);
|
|
3350
|
+
return bigintText(value);
|
|
3351
|
+
}
|
|
3352
|
+
function bigintText(value) {
|
|
3353
|
+
return typeof value === "bigint" ? `${value}n` : "null";
|
|
3344
3354
|
}
|
|
3345
3355
|
function flagText(present, text) {
|
|
3346
3356
|
switch (Boolean(present)) {
|
|
@@ -3394,13 +3404,12 @@ const HASHBANG_FIELDS = {
|
|
|
3394
3404
|
function isHashbang(value) {
|
|
3395
3405
|
return Predicate.isObject(value) && Object.entries(HASHBANG_FIELDS).every(([key, accepts]) => accepts(value[key]));
|
|
3396
3406
|
}
|
|
3397
|
-
const
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
};
|
|
3402
|
-
const
|
|
3403
|
-
const tsPrint = (file) => printProgram(file.root, { hashbang: hashbangOf(file.root) });
|
|
3407
|
+
const toHashbang = (hashbang) => isHashbang(hashbang) ? hashbang : null;
|
|
3408
|
+
function getHashbang(root) {
|
|
3409
|
+
return toHashbang("hashbang" in root ? root.hashbang : null);
|
|
3410
|
+
}
|
|
3411
|
+
const jsPrint = (file) => printProgram(file.root, { hashbang: getHashbang(file.root) });
|
|
3412
|
+
const tsPrint = (file) => printProgram(file.root, { hashbang: getHashbang(file.root) });
|
|
3404
3413
|
function getScriptStart$1(script) {
|
|
3405
3414
|
const span = spanOf(script.root);
|
|
3406
3415
|
if (span === void 0) throw new Error("Script AST root without start");
|
|
@@ -3467,9 +3476,14 @@ function normalizeFileName(fileName) {
|
|
|
3467
3476
|
}
|
|
3468
3477
|
const hasText = (value) => Predicate.isString(value) && value.length > 0;
|
|
3469
3478
|
const textIfNonEmpty = (value) => Option.getOrUndefined(Option.filter(Option.fromUndefinedOr(value), hasText));
|
|
3470
|
-
|
|
3471
|
-
return
|
|
3472
|
-
}
|
|
3479
|
+
function readFieldOf(record, key) {
|
|
3480
|
+
return record[key];
|
|
3481
|
+
}
|
|
3482
|
+
const hasFieldIn = (value, key) => key in value;
|
|
3483
|
+
const fieldOf = (value, key) => {
|
|
3484
|
+
if (!hasFieldIn(value, key)) return;
|
|
3485
|
+
return readFieldOf(value, key);
|
|
3486
|
+
};
|
|
3473
3487
|
const hasStringCode = (error) => Match.value(fieldOf(error, "code")).pipe(Match.when(Match.string, () => true), Match.orElse(() => false));
|
|
3474
3488
|
function isErrnoException(error) {
|
|
3475
3489
|
return Match.value(error).pipe(Match.when(Match.instanceOf(Error), hasStringCode), Match.orElse(() => false));
|
|
@@ -3494,7 +3508,7 @@ const isNonPlaceholderText = (text) => Match.value({
|
|
|
3494
3508
|
isPlaceholder: false
|
|
3495
3509
|
}, () => true), Match.orElse(() => false));
|
|
3496
3510
|
const isUsableText = (value) => Match.value(value).pipe(Match.when(Match.string, isNonPlaceholderText), Match.orElse(() => false));
|
|
3497
|
-
const usableText = (value) =>
|
|
3511
|
+
const usableText = (value) => isUsableText(value) ? value : "";
|
|
3498
3512
|
const objectToStringText = (value) => Match.value(fieldOf(value, "toString")).pipe(Match.when(Match.instanceOf(Function), (callable) => {
|
|
3499
3513
|
try {
|
|
3500
3514
|
return usableText(Reflect.apply(callable, value, []));
|
|
@@ -3503,9 +3517,19 @@ const objectToStringText = (value) => Match.value(fieldOf(value, "toString")).pi
|
|
|
3503
3517
|
}
|
|
3504
3518
|
}), Match.orElse(() => ""));
|
|
3505
3519
|
const isObjectType = (cause) => typeof cause === "object";
|
|
3506
|
-
const
|
|
3507
|
-
const
|
|
3508
|
-
const
|
|
3520
|
+
const isNonNullObjectType = (error) => error !== null && isObjectType(error);
|
|
3521
|
+
const toStringText = (error) => isNonNullObjectType(error) ? objectToStringText(error) : "";
|
|
3522
|
+
const stringifyRest = (error) => {
|
|
3523
|
+
const json = jsonText(error);
|
|
3524
|
+
return hasText(json) ? json : toStringText(error);
|
|
3525
|
+
};
|
|
3526
|
+
function primitiveJsonOf(error) {
|
|
3527
|
+
return isJsonPrimitive(error) ? JSON.stringify(error) : void 0;
|
|
3528
|
+
}
|
|
3529
|
+
const stringifyNonError = (error) => typeof error === "string" ? error : nonStringTextOf(error);
|
|
3530
|
+
function nonStringTextOf(error) {
|
|
3531
|
+
return primitiveJsonOf(error) ?? stringifyRest(error);
|
|
3532
|
+
}
|
|
3509
3533
|
const errorText = (error) => Match.value(error).pipe(Match.when(isErrnoException, formatErrnoException), Match.orElse(() => formatError(error)));
|
|
3510
3534
|
function errorToString(error) {
|
|
3511
3535
|
return Match.value(error).pipe(Match.when(isEmptyError, () => ""), Match.when(Match.instanceOf(Error), errorText), Match.orElse(() => stringifyNonError(error)));
|
|
@@ -3519,7 +3543,18 @@ const errorMessage = (error) => Match.value(error.message.length > 0).pipe(Match
|
|
|
3519
3543
|
const errorMessageOrTag = (value) => Match.value(value).pipe(Match.when(Match.instanceOf(Error), errorMessage), Match.orElse(() => tagOf(value)));
|
|
3520
3544
|
const messageText = (value) => Match.value(textIfNonEmpty(fieldOf(value, "message"))).pipe(Match.when(hasText, (message) => message), Match.orElse(() => errorMessageOrTag(value)));
|
|
3521
3545
|
const ownCauseText = (value) => Match.value(textIfNonEmpty(fieldOf(value, "reason"))).pipe(Match.when(hasText, (reason) => reason), Match.orElse(() => messageText(value)));
|
|
3522
|
-
const
|
|
3546
|
+
const isPastDepth = (depth) => depth > 4;
|
|
3547
|
+
const isMissingCause = (cause) => cause === void 0 || cause === null;
|
|
3548
|
+
const causeText = (cause, depth) => isPastDepth(depth) ? void 0 : missingCauseTextOf(cause, depth);
|
|
3549
|
+
function missingCauseTextOf(cause, depth) {
|
|
3550
|
+
return isMissingCause(cause) ? void 0 : causeTextOfValue(cause, depth);
|
|
3551
|
+
}
|
|
3552
|
+
function causeTextOfValue(cause, depth) {
|
|
3553
|
+
return typeof cause === "string" ? textIfNonEmpty(cause) : objectCauseTextOf(cause, depth);
|
|
3554
|
+
}
|
|
3555
|
+
function objectCauseTextOf(cause, depth) {
|
|
3556
|
+
return isObjectType(cause) ? textWithNested(ownCauseText(cause), causeText(fieldOf(cause, "cause"), depth + 1)) : void 0;
|
|
3557
|
+
}
|
|
3523
3558
|
//#endregion
|
|
3524
3559
|
//#region src/Mutator.ts
|
|
3525
3560
|
/**
|
|
@@ -3809,9 +3844,10 @@ function withOperator(node, operator) {
|
|
|
3809
3844
|
function mutantsWhen(holds, build) {
|
|
3810
3845
|
return Match.value(holds).pipe(Match.when(true, build), Match.orElse(() => NO_MUTANTS));
|
|
3811
3846
|
}
|
|
3812
|
-
|
|
3847
|
+
const hasPropertyIn = (node, key) => key in node;
|
|
3848
|
+
const readPropertyOf = (node, key) => hasPropertyIn(node, key) ? node[key] : void 0;
|
|
3813
3849
|
function propertyOf(node, key) {
|
|
3814
|
-
return
|
|
3850
|
+
return Predicate.isObject(node) ? readPropertyOf(node, key) : void 0;
|
|
3815
3851
|
}
|
|
3816
3852
|
function isIdentifier(node) {
|
|
3817
3853
|
return nodeType(node) === "Identifier";
|
|
@@ -4877,7 +4913,8 @@ function frozenContainer(value) {
|
|
|
4877
4913
|
freezableChildren(object).forEach((child) => {
|
|
4878
4914
|
deepFreeze(child);
|
|
4879
4915
|
});
|
|
4880
|
-
|
|
4916
|
+
Object.freeze(object);
|
|
4917
|
+
return value;
|
|
4881
4918
|
});
|
|
4882
4919
|
}
|
|
4883
4920
|
function freezableChildren(value) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@systemfsoftware/stryker-js-instrumenter",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"@effect/tsgo": "^0.45.0",
|
|
35
35
|
"@microsoft/api-extractor": "^7",
|
|
36
36
|
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
37
|
-
"@systemfsoftware/effect-gherkin-spec": "^4.2.
|
|
38
|
-
"@systemfsoftware/oxlint-config-recommended": "^1.
|
|
37
|
+
"@systemfsoftware/effect-gherkin-spec": "^4.2.2",
|
|
38
|
+
"@systemfsoftware/oxlint-config-recommended": "^1.1.0",
|
|
39
39
|
"@systemfsoftware/tsconfig": "^1.3.6",
|
|
40
40
|
"@types/node": "^24",
|
|
41
41
|
"oxlint": "^1",
|