@systemfsoftware/stryker-js-angular 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/LICENSE +203 -0
- package/README.md +75 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +208 -0
- package/package.json +80 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @systemfsoftware/stryker-js-angular
|
|
2
|
+
|
|
3
|
+
## 0.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- First release. The Angular framework plugin claims `.html`, `.htm`, and `.vue`
|
|
8
|
+
files and hands their `script` regions to the instrumenter, so mutants land in
|
|
9
|
+
embedded JavaScript and TypeScript while template expressions are left
|
|
10
|
+
untouched.
|
|
11
|
+
|
|
12
|
+
List it by package name in `plugins`. The package's manifest declares
|
|
13
|
+
`strykerFramework` with the extensions it claims, so a run names it in a skip
|
|
14
|
+
report when a file type it owns is left unconfigured. Its format carries the
|
|
15
|
+
version of the HTML parser it resolved, so upgrading that parser invalidates the
|
|
16
|
+
mutant results an earlier incremental run remembered for its files.
|
|
17
|
+
|
|
18
|
+
Signal ignoring is not included: pair the plugin with
|
|
19
|
+
`@systemfsoftware/stryker-ignorer-angular` to keep the configuration objects of
|
|
20
|
+
the signal `input`, `model`, `output`, and query functions out of mutation.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Copyright (c) 2026 Ryan Lee (systemfsoftware)
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright 2026 Ryan Lee (systemfsoftware)
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @systemfsoftware/stryker-js-angular
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
> Covers Angular templates and Vue single-file components — `.html`, `.htm`,
|
|
7
|
+
> and `.vue` files — making their embedded scripts first-class mutation
|
|
8
|
+
> targets.
|
|
9
|
+
|
|
10
|
+
Installing the package and listing it in `plugins` is the whole setup.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add -D @systemfsoftware/stryker-js-angular
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Add the package name to `plugins` in your StrykerJS config:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { StrykerConfig } from '@systemfsoftware/stryker-js/config'
|
|
22
|
+
|
|
23
|
+
export default StrykerConfig.define({
|
|
24
|
+
testRunner: 'vitest',
|
|
25
|
+
plugins: ['@systemfsoftware/stryker-js-angular'],
|
|
26
|
+
mutate: [
|
|
27
|
+
'src/**/*.html',
|
|
28
|
+
'src/**/*.vue',
|
|
29
|
+
],
|
|
30
|
+
})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## What gets mutated
|
|
34
|
+
|
|
35
|
+
Only script regions are mutated. Each `<script>` in a document — a template may
|
|
36
|
+
hold any number of them — is handed to the core's own parser and mutated as
|
|
37
|
+
ordinary JavaScript or TypeScript: `type` and `lang` attributes select the
|
|
38
|
+
script format, defaulting to JavaScript, and the mutated script is printed back
|
|
39
|
+
between the tags it came from at its original offsets.
|
|
40
|
+
|
|
41
|
+
Template expressions are never parsed, never mutated, and never printed. In a
|
|
42
|
+
Vue component holding `<template>{{ count }}</template>` beside a
|
|
43
|
+
`<script lang="ts">`, only the script carries mutants.
|
|
44
|
+
|
|
45
|
+
## Signal APIs
|
|
46
|
+
|
|
47
|
+
Mutants inside the configuration objects of Angular's `input`, `model`, and
|
|
48
|
+
`output` signal functions — and of the signal query functions — break the
|
|
49
|
+
Angular compiler. This plugin does not suppress them. Pair it with the ignorer
|
|
50
|
+
package:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
ignorers: ['@systemfsoftware/stryker-ignorer-angular'],
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Boundaries
|
|
57
|
+
|
|
58
|
+
- The exported surface is `strykerFrameworks`: one plain `Framework` object
|
|
59
|
+
claiming the `html` format for `.html`, `.htm`, and `.vue`, typed against
|
|
60
|
+
[`@systemfsoftware/stryker-framework-interface`](https://www.npmjs.com/package/@systemfsoftware/stryker-framework-interface).
|
|
61
|
+
- The `package.json` declares `"strykerFramework": { "extensions": [".html",
|
|
62
|
+
".htm", ".vue"] }`: the host reads that field from installed packages to name
|
|
63
|
+
this package in a skip reason without importing the module.
|
|
64
|
+
- `angular-html-parser` is a hard dependency, resolved when the module loads —
|
|
65
|
+
there is no peer to install and no version to reconcile.
|
|
66
|
+
- There is no bundled ignorer: signal-configuration suppression lives in
|
|
67
|
+
`@systemfsoftware/stryker-ignorer-angular`.
|
|
68
|
+
|
|
69
|
+
## Contributing
|
|
70
|
+
|
|
71
|
+
Development setup and workflow: [AGENTS.md](../AGENTS.md).
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
[Apache 2.0](LICENSE)
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { parse, visitAll } from "angular-html-parser";
|
|
2
|
+
import parserManifest from "angular-html-parser/package.json" with { type: "json" };
|
|
3
|
+
//#region src/html-format.ts
|
|
4
|
+
/**
|
|
5
|
+
* The Angular format: HTML templates and single-file components that keep
|
|
6
|
+
* their script inside an HTML `<script>` tag. Only embedded script regions
|
|
7
|
+
* are claimed — template expressions are never parsed, never mutated, and
|
|
8
|
+
* never printed — which is why every region carries `isExpression: false`.
|
|
9
|
+
*
|
|
10
|
+
* The core owns the pipeline around these hooks: it slices each region,
|
|
11
|
+
* parses the slice through the toolkit context, mutates the resulting
|
|
12
|
+
* program, and hands the document back to `print` to be framed into the raw
|
|
13
|
+
* content. The hooks here are only the two things the core cannot know:
|
|
14
|
+
* where the script regions are, and how a mutation survives the trip back
|
|
15
|
+
* into the document.
|
|
16
|
+
*/
|
|
17
|
+
const FORMAT_ID_TEXT = "html";
|
|
18
|
+
const LANGUAGE = "html";
|
|
19
|
+
const CONTRACT_VERSION = "1";
|
|
20
|
+
const EXTENSIONS = [
|
|
21
|
+
".html",
|
|
22
|
+
".htm",
|
|
23
|
+
".vue"
|
|
24
|
+
];
|
|
25
|
+
const SCRIPT_TAG = "script";
|
|
26
|
+
const SRC_ATTRIBUTE = "src";
|
|
27
|
+
const TYPE_ATTRIBUTE = "type";
|
|
28
|
+
const LANG_ATTRIBUTE = "lang";
|
|
29
|
+
const DEFAULT_SCRIPT_FORMAT = "js";
|
|
30
|
+
const NEWLINE = "\n";
|
|
31
|
+
const NO_CHECK_COMMENT = "// @ts-nocheck";
|
|
32
|
+
const UNCLOSED_SCRIPT_MESSAGE = "the script element never closes";
|
|
33
|
+
const NON_ERROR_FAILURE = "the Angular parser reported a failure that is not an Error";
|
|
34
|
+
const PARSE_OPTIONS = {
|
|
35
|
+
canSelfClose: true,
|
|
36
|
+
allowHtmComponentClosingTags: true,
|
|
37
|
+
isTagNameCaseSensitive: true
|
|
38
|
+
};
|
|
39
|
+
const SCRIPT_TYPE_FORMATS = {
|
|
40
|
+
tsx: "tsx",
|
|
41
|
+
"text/tsx": "tsx",
|
|
42
|
+
ts: "ts",
|
|
43
|
+
"text/typescript": "ts",
|
|
44
|
+
typescript: "ts",
|
|
45
|
+
js: "js",
|
|
46
|
+
"text/javascript": "js",
|
|
47
|
+
javascript: "js",
|
|
48
|
+
module: "js"
|
|
49
|
+
};
|
|
50
|
+
const STARTING_COMMENT = /^\s*\/\*[\s\S]*?\*\//;
|
|
51
|
+
const HTML_FORMAT_ID = FORMAT_ID_TEXT;
|
|
52
|
+
const claimOf = (ownerVersion) => ({
|
|
53
|
+
formatId: HTML_FORMAT_ID,
|
|
54
|
+
extensions: [...EXTENSIONS],
|
|
55
|
+
language: LANGUAGE,
|
|
56
|
+
ownerVersion,
|
|
57
|
+
contractVersion: CONTRACT_VERSION
|
|
58
|
+
});
|
|
59
|
+
const isScriptRegionTag = (element) => element.name === SCRIPT_TAG && !element.attrs.some((attribute) => attribute.name === SRC_ATTRIBUTE);
|
|
60
|
+
const scriptTypeAttribute = (element) => element.attrs.find((attribute) => attribute.name === TYPE_ATTRIBUTE) ?? element.attrs.find((attribute) => attribute.name === LANG_ATTRIBUTE);
|
|
61
|
+
const scriptFormatOfAttribute = (attribute) => SCRIPT_TYPE_FORMATS[attribute.value.toLowerCase()];
|
|
62
|
+
const scriptFormatOfElement = (element) => {
|
|
63
|
+
const attribute = scriptTypeAttribute(element);
|
|
64
|
+
return attribute === void 0 ? DEFAULT_SCRIPT_FORMAT : scriptFormatOfAttribute(attribute);
|
|
65
|
+
};
|
|
66
|
+
const scriptFormatOf = (element) => isScriptRegionTag(element) ? scriptFormatOfElement(element) : void 0;
|
|
67
|
+
const locationOf = (element, scriptFormat) => {
|
|
68
|
+
const endSpan = element.endSourceSpan;
|
|
69
|
+
return endSpan === null ? {
|
|
70
|
+
kind: "Problem",
|
|
71
|
+
message: UNCLOSED_SCRIPT_MESSAGE
|
|
72
|
+
} : {
|
|
73
|
+
kind: "Location",
|
|
74
|
+
start: element.startSourceSpan.end.offset,
|
|
75
|
+
end: endSpan.start.offset,
|
|
76
|
+
scriptFormat
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const appendLocation = (element, findings) => {
|
|
80
|
+
const scriptFormat = scriptFormatOf(element);
|
|
81
|
+
if (scriptFormat !== void 0) findings.push(locationOf(element, scriptFormat));
|
|
82
|
+
};
|
|
83
|
+
const ignoreVisited = () => void 0;
|
|
84
|
+
const collectorOf = (findings) => {
|
|
85
|
+
const walk = {
|
|
86
|
+
visitElement: (element) => {
|
|
87
|
+
appendLocation(element, findings);
|
|
88
|
+
visitAll(walk, element.children);
|
|
89
|
+
},
|
|
90
|
+
visitAttribute: ignoreVisited,
|
|
91
|
+
visitText: ignoreVisited,
|
|
92
|
+
visitComment: ignoreVisited,
|
|
93
|
+
visitDocType: ignoreVisited,
|
|
94
|
+
visitExpansion: ignoreVisited,
|
|
95
|
+
visitExpansionCase: ignoreVisited,
|
|
96
|
+
visitBlock: ignoreVisited,
|
|
97
|
+
visitBlockParameter: ignoreVisited,
|
|
98
|
+
visitLetDeclaration: ignoreVisited,
|
|
99
|
+
visitCdata: ignoreVisited,
|
|
100
|
+
visitComponent: ignoreVisited,
|
|
101
|
+
visitDirective: ignoreVisited
|
|
102
|
+
};
|
|
103
|
+
return walk;
|
|
104
|
+
};
|
|
105
|
+
const isProblem = (finding) => finding.kind === "Problem";
|
|
106
|
+
const isLocation = (finding) => finding.kind === "Location";
|
|
107
|
+
const reportedProblemOf = (findings, firstError) => firstError === void 0 ? findings.find(isProblem) : {
|
|
108
|
+
kind: "Problem",
|
|
109
|
+
message: firstError.msg
|
|
110
|
+
};
|
|
111
|
+
const scriptFindings = (rootNodes) => {
|
|
112
|
+
const findings = [];
|
|
113
|
+
visitAll(collectorOf(findings), rootNodes);
|
|
114
|
+
return findings;
|
|
115
|
+
};
|
|
116
|
+
const locationsOf = (rawContent) => {
|
|
117
|
+
const { rootNodes, errors } = parse(rawContent, PARSE_OPTIONS);
|
|
118
|
+
const findings = scriptFindings(rootNodes);
|
|
119
|
+
const problem = reportedProblemOf(findings, errors.at(0));
|
|
120
|
+
return problem === void 0 ? {
|
|
121
|
+
kind: "Parsed",
|
|
122
|
+
value: findings.filter(isLocation)
|
|
123
|
+
} : {
|
|
124
|
+
kind: "ParseFailed",
|
|
125
|
+
message: problem.message
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const failureMessage = (cause) => cause instanceof Error ? cause.message : NON_ERROR_FAILURE;
|
|
129
|
+
const documentOf = (rawContent, context, locations) => ({
|
|
130
|
+
formatId: HTML_FORMAT_ID,
|
|
131
|
+
rawContent,
|
|
132
|
+
regions: locations.map((location) => ({
|
|
133
|
+
start: location.start,
|
|
134
|
+
end: location.end,
|
|
135
|
+
isExpression: false,
|
|
136
|
+
scriptAst: context.parseScript(rawContent.substring(location.start, location.end), location.scriptFormat)
|
|
137
|
+
}))
|
|
138
|
+
});
|
|
139
|
+
const documentResult = (rawContent, context) => {
|
|
140
|
+
const locations = locationsOf(rawContent);
|
|
141
|
+
return locations.kind === "Parsed" ? {
|
|
142
|
+
kind: "Parsed",
|
|
143
|
+
value: documentOf(rawContent, context, locations.value)
|
|
144
|
+
} : locations;
|
|
145
|
+
};
|
|
146
|
+
const parseDocument = (rawContent, context) => {
|
|
147
|
+
try {
|
|
148
|
+
return documentResult(rawContent, context);
|
|
149
|
+
} catch (cause) {
|
|
150
|
+
return {
|
|
151
|
+
kind: "ParseFailed",
|
|
152
|
+
message: failureMessage(cause)
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const unchangedDocument = (document) => document;
|
|
157
|
+
const byStart = (left, right) => left.start - right.start;
|
|
158
|
+
const printedDocument = (document, context) => {
|
|
159
|
+
let printed = "";
|
|
160
|
+
let cursor = 0;
|
|
161
|
+
for (const region of document.regions.toSorted(byStart)) {
|
|
162
|
+
printed += document.rawContent.substring(cursor, region.start);
|
|
163
|
+
printed += context.printScript(region.scriptAst);
|
|
164
|
+
cursor = region.end;
|
|
165
|
+
}
|
|
166
|
+
return printed + document.rawContent.substring(cursor);
|
|
167
|
+
};
|
|
168
|
+
const afterHashbang = (code) => {
|
|
169
|
+
const newLineIndex = code.indexOf(NEWLINE);
|
|
170
|
+
return newLineIndex <= 0 ? code : `${code.substring(0, newLineIndex)}${NEWLINE}${NO_CHECK_COMMENT}${NEWLINE}${code.substring(newLineIndex + 1)}`;
|
|
171
|
+
};
|
|
172
|
+
const leadingCommentOf = (code) => STARTING_COMMENT.exec(code)?.[0];
|
|
173
|
+
const afterLeadingComment = (code) => {
|
|
174
|
+
const leadingComment = leadingCommentOf(code);
|
|
175
|
+
return leadingComment === void 0 ? `${NO_CHECK_COMMENT}${NEWLINE}${code}` : `${leadingComment}${NEWLINE}${NO_CHECK_COMMENT}${NEWLINE}${code.substring(leadingComment.length)}`;
|
|
176
|
+
};
|
|
177
|
+
const noCheckedScript = (code) => code.startsWith("#") ? afterHashbang(code) : afterLeadingComment(code);
|
|
178
|
+
const withNoCheckSplices = (rawContent, locations) => {
|
|
179
|
+
let spliced = "";
|
|
180
|
+
let cursor = 0;
|
|
181
|
+
for (const location of locations) {
|
|
182
|
+
spliced += rawContent.substring(cursor, location.start);
|
|
183
|
+
spliced += noCheckedScript(rawContent.substring(location.start, location.end));
|
|
184
|
+
cursor = location.end;
|
|
185
|
+
}
|
|
186
|
+
return spliced + rawContent.substring(cursor);
|
|
187
|
+
};
|
|
188
|
+
const splicedResult = (rawContent) => {
|
|
189
|
+
const locations = locationsOf(rawContent);
|
|
190
|
+
return locations.kind === "Parsed" ? {
|
|
191
|
+
kind: "Parsed",
|
|
192
|
+
value: withNoCheckSplices(rawContent, locations.value)
|
|
193
|
+
} : locations;
|
|
194
|
+
};
|
|
195
|
+
const disableTypeChecksIn = (rawContent) => splicedResult(rawContent);
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/mod.ts
|
|
198
|
+
const strykerFrameworks = [{
|
|
199
|
+
kind: "Framework",
|
|
200
|
+
name: "angular",
|
|
201
|
+
claim: claimOf(parserManifest.version),
|
|
202
|
+
parse: parseDocument,
|
|
203
|
+
transform: unchangedDocument,
|
|
204
|
+
print: printedDocument,
|
|
205
|
+
disableTypeChecks: disableTypeChecksIn
|
|
206
|
+
}];
|
|
207
|
+
//#endregion
|
|
208
|
+
export { strykerFrameworks };
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@systemfsoftware/stryker-js-angular",
|
|
3
|
+
"license": "Apache-2.0",
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"author": "Ryan Lee <drdgvhbh@gmail.com>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/systemfsoftware/stryker-js-effect.git",
|
|
9
|
+
"directory": "packages/frameworks/angular"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/systemfsoftware/stryker-js-effect/tree/main/packages/frameworks/angular#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/systemfsoftware/stryker-js-effect/issues"
|
|
14
|
+
},
|
|
15
|
+
"description": "Stryker framework plugin for Angular and Vue templates: claims .html, .htm, and .vue files and instruments their embedded script regions, never template expressions.",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"stryker",
|
|
18
|
+
"stryker-mutator",
|
|
19
|
+
"mutation-testing",
|
|
20
|
+
"angular",
|
|
21
|
+
"vue",
|
|
22
|
+
"html",
|
|
23
|
+
"framework",
|
|
24
|
+
"plugin"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"strykerFramework": {
|
|
28
|
+
"extensions": [
|
|
29
|
+
".html",
|
|
30
|
+
".htm",
|
|
31
|
+
".vue"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"default": "./dist/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"angular-html-parser": "~10.12.0",
|
|
46
|
+
"@systemfsoftware/stryker-framework-interface": "^0.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@effect/tsgo": "^0.45.0",
|
|
50
|
+
"@microsoft/api-extractor": "^7",
|
|
51
|
+
"@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
|
|
52
|
+
"@systemfsoftware/tsconfig": "^2.0.1",
|
|
53
|
+
"@types/node": "^24",
|
|
54
|
+
"@vitest/coverage-v8": "^5",
|
|
55
|
+
"oxc-parser": "^0.150.0",
|
|
56
|
+
"oxlint": "^1",
|
|
57
|
+
"rimraf": "^6.1.3",
|
|
58
|
+
"tsdown": "^0.23.0",
|
|
59
|
+
"typescript": "^7",
|
|
60
|
+
"vitest": "^5",
|
|
61
|
+
"@systemfsoftware/oxlint-ignorer-config": "^0.1.1",
|
|
62
|
+
"@systemfsoftware/tsdown-config": "^0.1.0",
|
|
63
|
+
"@systemfsoftware/vitest-config": "^0.1.0"
|
|
64
|
+
},
|
|
65
|
+
"publishConfig": {
|
|
66
|
+
"access": "public",
|
|
67
|
+
"provenance": true
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsdown",
|
|
71
|
+
"clean": "rimraf dist",
|
|
72
|
+
"typecheck": "tsc -b",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",
|
|
75
|
+
"attw": "attw --pack .",
|
|
76
|
+
"api:check": "api-extractor run",
|
|
77
|
+
"api:update": "api-extractor run --local",
|
|
78
|
+
"lint:tsgo": "effect-tsgo diagnostics --project tsconfig.app.json --format ${TSGO_FORMAT:-text} && effect-tsgo diagnostics --project tsconfig.test.json --format ${TSGO_FORMAT:-text}"
|
|
79
|
+
}
|
|
80
|
+
}
|