@imwz/wp-pattern-sentinel 1.0.0 → 1.0.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/bin/sentinel.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imwz/wp-pattern-sentinel",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Browser-based WordPress block pattern validator using Playwright",
5
5
  "type": "module",
6
6
  "engines": {
package/src/validation.js CHANGED
@@ -31,6 +31,15 @@ export async function checkBlockValidation(page) {
31
31
  }
32
32
  }
33
33
 
34
+ /**
35
+ * Strip the `ref` key WordPress injects into wp:navigation block comments when
36
+ * a pattern is first loaded in the editor. All FSE themes ship navigation
37
+ * patterns without a ref; WordPress assigns one automatically and it must not
38
+ * be treated as a content mismatch.
39
+ */
40
+ const stripNavRef = str =>
41
+ str.replace(/(<!-- wp:navigation \{)"ref":\d+,\s*/g, '$1');
42
+
34
43
  /**
35
44
  * Compare the editor's serialized output against the original source.
36
45
  * Whitespace-normalizes both sides before diffing to avoid false positives
@@ -46,12 +55,12 @@ export async function compareContent(page, originalContent) {
46
55
  result.savedContent = savedContent;
47
56
 
48
57
  const normalize = str => str.replace(/\s+/g, ' ').trim();
49
- if (normalize(savedContent) === normalize(originalContent)) return result;
58
+ if (normalize(stripNavRef(savedContent)) === normalize(stripNavRef(originalContent))) return result;
50
59
 
51
60
  result.matches = false;
52
61
 
53
- const origLines = originalContent.split('\n').map(l => l.trim()).filter(Boolean);
54
- const savedLines = savedContent.split('\n').map(l => l.trim()).filter(Boolean);
62
+ const origLines = stripNavRef(originalContent).split('\n').map(l => l.trim()).filter(Boolean);
63
+ const savedLines = stripNavRef(savedContent).split('\n').map(l => l.trim()).filter(Boolean);
55
64
 
56
65
  const removed = origLines.filter(l => !savedLines.includes(l)).slice(0, 5);
57
66
  const added = savedLines.filter(l => !origLines.includes(l)).slice(0, 5);