@patternslib/dev 4.6.0 → 4.6.1

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/CHANGES.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.6.1](https://github.com/Patternslib/dev/compare/4.6.0...4.6.1) (2026-11-30)
4
+
5
+ ### Bug Fixes
6
+
7
+ - **jest:** Let the matchMedia mock emulate a desktop device. ([12e094e](https://github.com/Patternslib/dev/commit/12e094e49ebf0f2d3bf9ced0a6af6f4334cde882))
8
+
9
+ The mock returned matches: false for every query. TinyMCE 8.11 detects
10
+ touch devices with !matchMedia("(any-pointer:fine)") and therefore
11
+ treated jsDOM as a touch device, disabling the editor resize handle.
12
+
13
+ Fine pointer and hover queries now match, all other queries still don't.
14
+
15
+ Ref: ADR 0002
16
+
17
+ - **release-it:** Filter attribution trailers from changelogs. ([0d347c8](https://github.com/Patternslib/dev/commit/0d347c87e39d4d20e01a494fd20044b2283ad6fe))
18
+
19
+ Omit Assisted-by, Assisted by and Co-authored-by lines (case-insensitive)
20
+ from rendered commit bodies and footers. Add tests for the changelog commit
21
+ partial.
22
+
23
+ ### Maintenance
24
+
25
+ - **docs:** Add ADR 0002 about the matchMedia mock emulating a desktop device. ([f9d063a](https://github.com/Patternslib/dev/commit/f9d063a1c46a878367f3294e1519d641be307fc9))
26
+
27
+ Ref: ADR 0002
28
+
3
29
  ## [4.6.0](https://github.com/Patternslib/dev/compare/4.5.1...4.6.0) (2026-11-30)
4
30
 
5
31
  ### Features
@@ -16,16 +42,12 @@
16
42
 
17
43
  Ref: ADR 0001
18
44
 
19
- Assisted-by: Claude Opus 5.5
20
-
21
45
  ### Maintenance
22
46
 
23
47
  - **docs:** Add ADR 0001 about running upgrades from make update. ([7931180](https://github.com/Patternslib/dev/commit/7931180ac80e4195647b9aa0e82f776ba7943520))
24
48
 
25
49
  Ref: ADR 0001
26
50
 
27
- Assisted-by: Claude Opus 5.5
28
-
29
51
  - **docs:** Start with ADR records. ([c7add1e](https://github.com/Patternslib/dev/commit/c7add1e6e6923ed436b6d2853e5b00b4a49996b4))
30
52
 
31
53
  ## [4.5.1](https://github.com/Patternslib/dev/compare/4.5.0...4.5.1) (2026-11-30)
@@ -40,14 +62,10 @@
40
62
  .gitignore. Both commit their change and skip files with uncommitted
41
63
  changes, so that unrelated work is never committed.
42
64
 
43
- Assisted-by: Claude Opus 5.5
44
-
45
65
  ### Bug Fixes
46
66
 
47
67
  - **Makefile:** Fall back to webpack-cli config discovery for bundle analysis. ([fd4918d](https://github.com/Patternslib/dev/commit/fd4918de0dbce20be20aa1f8fc4a7b50ec9793f0))
48
68
 
49
- Assisted-by: Claude Opus 5.5
50
-
51
69
  ### Maintenance
52
70
 
53
71
  - **docs:** Update README with recent changes. ([92ad74b](https://github.com/Patternslib/dev/commit/92ad74ba9ad7192b14342b29a9c8d64c1ad8509e))
@@ -100,8 +118,6 @@
100
118
  in the actual release run. Also abort if the version cannot be
101
119
  determined.
102
120
 
103
- Assisted-by: Claude Opus 5.5
104
-
105
121
  - **Makefile:** Open sunburst stats.html directly in browser. ([fe885bf](https://github.com/Patternslib/dev/commit/fe885bfdf85b18e845f45ef67ba4e20f509dd540))
106
122
  - **webpack:** Fix test for loaders configured with resolved paths. ([5cf5071](https://github.com/Patternslib/dev/commit/5cf5071bfe5953004c1acd919149c196db62b1d1))
107
123
 
@@ -116,8 +132,6 @@
116
132
  style-loader. It now compares against the resolved path, and the
117
133
  resolveLoader workaround is no longer needed.
118
134
 
119
- Assisted-by: Claude Opus 5.5
120
-
121
135
  - **webpack:** Use imports relative to @patternslib/dev. ([b8032f1](https://github.com/Patternslib/dev/commit/b8032f1f108c30be1bdaadb5fba75ae2e3ab727f))
122
136
 
123
137
  Depending packages might not have all dependencies installed.
@@ -197,7 +211,7 @@
197
211
 
198
212
  ### Maintenance
199
213
 
200
- - Allow releases from alpha/* and beta/* branches, alongside to master, main and *.x. ([73c49fa](https://github.com/Patternslib/dev/commit/73c49fa2cb7d797626411da76f3b702f8e03a960))
214
+ - Allow releases from alpha/_and beta/_ branches, alongside to master, main and *.x. ([73c49fa](https://github.com/Patternslib/dev/commit/73c49fa2cb7d797626411da76f3b702f8e03a960))
201
215
  - Migrate handlebars changelog template to JavaScript render functions. ([a1685f9](https://github.com/Patternslib/dev/commit/a1685f9d84e7e36c6d2c1cc6426b454228ddf15d))
202
216
 
203
217
  Co-authored-by: Codex <noreply@openai.com>
@@ -260,10 +274,10 @@ projects do anyways, so this change is fine, IMO.
260
274
 
261
275
  The following problems are now fixed:
262
276
 
263
- * Whole history included in new changelog entries.
264
- * No dist/ published due to silent failures.
265
- * No GitHub release page updates.
266
- * No GutHub bundle zip upload.
277
+ - Whole history included in new changelog entries.
278
+ - No dist/ published due to silent failures.
279
+ - No GitHub release page updates.
280
+ - No GutHub bundle zip upload.
267
281
 
268
282
  ### Maintenance
269
283
 
@@ -0,0 +1,31 @@
1
+ # The `matchMedia` mock emulates a desktop device
2
+
3
+ Status: Accepted (2026-11-30)
4
+
5
+ ## Context
6
+
7
+ jsDOM does not implement `window.matchMedia`.
8
+ `jest/setup-tests.js` provides a mock for it, which until now returned `matches: false` for every media query.
9
+
10
+ TinyMCE 8.11 changed its touch device detection to `isTouch = isMobile || !matchMedia("(any-pointer:fine)")`.
11
+ With the mock, every query fails, so TinyMCE treats the jsDOM test environment as a touch device.
12
+ On touch devices TinyMCE disables the editor resize handle by default and adds the `tox-platform-touch` class.
13
+ This broke a TinyMCE test in Mockup which checks the translated label of the resize handle.
14
+
15
+ Other libraries use the same kind of check to switch between a touch and a desktop UI.
16
+ Our tests are written with a desktop browser in mind.
17
+
18
+ ## Decision
19
+
20
+ The `matchMedia` mock emulates a desktop device with a mouse.
21
+ The queries `(pointer:fine)`, `(any-pointer:fine)`, `(hover:hover)` and `(any-hover:hover)` match.
22
+ Whitespace in the query is ignored, so `(any-pointer: fine)` matches too.
23
+ All other queries still don't match.
24
+
25
+ ## Consequences
26
+
27
+ - Libraries which detect touch devices through pointer or hover media queries render their desktop UI in tests.
28
+ - Queries which don't match before, like `(prefers-reduced-motion: reduce)` or `(min-width: 768px)`, still don't match.
29
+ - Combined queries like `(pointer:fine) and (hover:hover)` don't match.
30
+ The mock does not parse media queries.
31
+ - Tests which relied on the touch UI in jsDOM need to override `window.matchMedia` themselves.
@@ -102,11 +102,21 @@ Range.prototype.getBoundingClientRect = () => {
102
102
  return { x: 0, y: 0, width: 0, height: 0, top: 0, right: 0, bottom: 0, left: 0 };
103
103
  };
104
104
 
105
- // Originally from pat-tinymce.
105
+ // jsDOM does not implement ``matchMedia``. Originally from pat-tinymce.
106
+ // Emulate a desktop device with a mouse: pointer and hover queries for a fine
107
+ // pointer match, all other queries don't. Libraries like TinyMCE treat a device
108
+ // without a fine pointer as a touch device and change their UI accordingly.
109
+ // See: docs/adr/0002-match-media-mock-emulates-desktop.md
110
+ const desktop_media_features = [
111
+ "(pointer:fine)",
112
+ "(any-pointer:fine)",
113
+ "(hover:hover)",
114
+ "(any-hover:hover)",
115
+ ];
106
116
  Object.defineProperty(window, "matchMedia", {
107
117
  writable: true,
108
118
  value: jest.fn().mockImplementation((query) => ({
109
- matches: false,
119
+ matches: desktop_media_features.includes(query.replace(/\s+/g, "")),
110
120
  media: query,
111
121
  onchange: null,
112
122
  addListener: jest.fn(), // Deprecated
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternslib/dev",
3
- "version": "4.6.0",
3
+ "version": "4.6.1",
4
4
  "description": "Development base files for working with Patternslib and add-ons.",
5
5
  "license": "MIT",
6
6
  "packageManager": "pnpm@12.23.0",
@@ -1,3 +1,10 @@
1
+ function stripAttribution(text) {
2
+ return text
3
+ ?.replace(/^[ \t]*(?:Assisted[- ]by|Co-authored-by):[^\r\n]*(?:\r?\n|$)/gim, "")
4
+ .replace(/^(?:[ \t]*\r?\n)+/, "")
5
+ .trimEnd();
6
+ }
7
+
1
8
  // The preset adds the list marker and indents continuation lines.
2
9
  module.exports = function commitPartial(context, commit) {
3
10
  const repoUrl = context.repository
@@ -36,8 +43,8 @@ module.exports = function commitPartial(context, commit) {
36
43
 
37
44
  return [
38
45
  summary,
39
- commit.body,
40
- commit.footer,
46
+ stripAttribution(commit.body),
47
+ stripAttribution(commit.footer),
41
48
  references.length && `closes ${references.join(" ")}`,
42
49
  ]
43
50
  .filter(Boolean)
@@ -0,0 +1,129 @@
1
+ const commitPartial = require("../release-it/conventional-changelog-commit");
2
+
3
+ // Commit objects are shaped like the output of conventional-commits-parser
4
+ // with the conventionalcommits preset, which puts the first trailer-like line
5
+ // and everything after it into `footer`.
6
+ function render(commit, context = {}) {
7
+ return commitPartial(
8
+ { linkReferences: false, ...context },
9
+ { hash: "abc123", shortHash: "abc", subject: "Subject.", ...commit },
10
+ );
11
+ }
12
+
13
+ describe("conventional-changelog-commit", () => {
14
+ it("renders scope, subject and hash.", () => {
15
+ expect(render({ scope: "pat-x" })).toBe("**pat-x:** Subject. abc123");
16
+ });
17
+
18
+ it("renders body and footer as separate paragraphs.", () => {
19
+ expect(render({ body: "Body.", footer: "Ref: ADR 0003" })).toBe(
20
+ "Subject. abc123\n\nBody.\n\nRef: ADR 0003",
21
+ );
22
+ });
23
+
24
+ describe("attribution trailers", () => {
25
+ it("removes an Assisted-by footer.", () => {
26
+ expect(render({ body: "Body.", footer: "Assisted-by: GPT-6" })).toBe(
27
+ "Subject. abc123\n\nBody.",
28
+ );
29
+ });
30
+
31
+ it.each([
32
+ "Assisted-by",
33
+ "Assisted-By",
34
+ "ASSISTED-BY",
35
+ "Assisted by",
36
+ "assisted by",
37
+ ])("removes an '%s' line.", (key) => {
38
+ // The parser does not recognize "Assisted by:" as a footer
39
+ // token, so it ends up in the body.
40
+ expect(render({ body: `Body.\n\n${key}: X`, footer: null })).toBe(
41
+ "Subject. abc123\n\nBody.",
42
+ );
43
+ expect(render({ body: "Body.", footer: `${key}: X` })).toBe(
44
+ "Subject. abc123\n\nBody.",
45
+ );
46
+ });
47
+
48
+ it.each([
49
+ "Co-authored-by",
50
+ "Co-Authored-By",
51
+ "co-authored-by",
52
+ "CO-AUTHORED-BY",
53
+ ])("removes a '%s' line.", (key) => {
54
+ expect(
55
+ render({
56
+ body: "Body.",
57
+ footer: `${key}: Someone <someone@example.com>`,
58
+ }),
59
+ ).toBe("Subject. abc123\n\nBody.");
60
+ });
61
+
62
+ it("keeps lines which only mention attribution words.", () => {
63
+ expect(
64
+ render({ body: "Assisted by the new API.\nCo-authored-by convention." }),
65
+ ).toBe(
66
+ "Subject. abc123\n\nAssisted by the new API.\nCo-authored-by convention.",
67
+ );
68
+ });
69
+
70
+ it("leaves no empty paragraph if only trailers are present.", () => {
71
+ expect(render({ body: "", footer: "Assisted-by: GPT-6" })).toBe(
72
+ "Subject. abc123",
73
+ );
74
+ });
75
+
76
+ it("keeps other footer lines.", () => {
77
+ expect(
78
+ render({
79
+ body: "Body.",
80
+ footer: [
81
+ "Ref: ADR 0003",
82
+ "Signed-off-by: A <a@example.com>",
83
+ "Assisted-by: X",
84
+ "Co-authored-by: Y <y@example.com>",
85
+ ].join("\n"),
86
+ }),
87
+ ).toBe(
88
+ "Subject. abc123\n\nBody.\n\nRef: ADR 0003\nSigned-off-by: A <a@example.com>",
89
+ );
90
+ });
91
+
92
+ it("keeps a BREAKING CHANGE footer.", () => {
93
+ expect(
94
+ render({
95
+ body: "Body.",
96
+ footer: "BREAKING CHANGE: API removed.\n\nAssisted-by: X",
97
+ }),
98
+ ).toBe("Subject. abc123\n\nBody.\n\nBREAKING CHANGE: API removed.");
99
+ });
100
+
101
+ it("keeps paragraphs following a trailer.", () => {
102
+ expect(render({ body: "First.", footer: "Assisted-by: X\n\nSecond." })).toBe(
103
+ "Subject. abc123\n\nFirst.\n\nSecond.",
104
+ );
105
+ });
106
+
107
+ it("handles CRLF line endings.", () => {
108
+ expect(
109
+ render({ body: "Body.", footer: "Assisted-by: X\r\nRef: ADR 0003\r\n" }),
110
+ ).toBe("Subject. abc123\n\nBody.\n\nRef: ADR 0003");
111
+ });
112
+
113
+ it("removes trailers from the body.", () => {
114
+ expect(render({ body: "Body.\nAssisted-by: X", footer: null })).toBe(
115
+ "Subject. abc123\n\nBody.",
116
+ );
117
+ });
118
+ });
119
+
120
+ it("appends issue references.", () => {
121
+ expect(
122
+ render({
123
+ body: "Body.",
124
+ footer: "Assisted-by: X",
125
+ references: [{ issue: "12" }],
126
+ }),
127
+ ).toBe("Subject. abc123\n\nBody.\n\ncloses #12");
128
+ });
129
+ });