@dogsbay/tree-diff 0.2.0-beta.173 → 0.2.0-beta.175

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.
Files changed (2) hide show
  1. package/dist/diff.js +14 -4
  2. package/package.json +3 -3
package/dist/diff.js CHANGED
@@ -50,12 +50,19 @@ export function sectionize(nodes) {
50
50
  /**
51
51
  * Whether two nodes have the same content. A node's source lines (`meta.line`, `meta.endLine`, from a
52
52
  * parser's `sourceLines`) and their origin (`meta.source`, from a source map) say where it is, not what
53
- * it is: compared, every block below an edit would show as changed.
53
+ * it is: compared, every block below an edit would show as changed. How it is written is not what
54
+ * it is either, when the page shows the same: a callout's form (`meta.form`, `:::note` or
55
+ * `> [!NOTE]`), a closer's label (`meta.closer`), a table's delimiter row (`meta.delimiter`).
56
+ * A list's `meta.loose` is compared: it changes the page (paragraph spacing).
54
57
  */
58
+ const WHERE_AND_HOW = new Set(["line", "endLine", "source", "form", "closer", "delimiter"]);
55
59
  const withoutLines = (key, value) => {
56
- if (key !== "meta" || !value || typeof value !== "object" || !("line" in value || "endLine" in value || "source" in value))
60
+ if (key !== "meta" || !value || typeof value !== "object")
57
61
  return value;
58
- const { line: _line, endLine: _endLine, source: _source, ...rest } = value;
62
+ const meta = value;
63
+ if (!Object.keys(meta).some((k) => WHERE_AND_HOW.has(k)))
64
+ return value;
65
+ const rest = Object.fromEntries(Object.entries(meta).filter(([k]) => !WHERE_AND_HOW.has(k)));
59
66
  return Object.keys(rest).length ? rest : undefined;
60
67
  };
61
68
  const sameContent = (a, b) => JSON.stringify(a, withoutLines) === JSON.stringify(b, withoutLines);
@@ -402,7 +409,10 @@ class Differ {
402
409
  }
403
410
  if (CONTAINER_TYPES.has(newB.type)) {
404
411
  const children = this.diffBlocks(oldB.children ?? [], newB.children ?? []);
405
- const propsChanged = JSON.stringify(oldB.props ?? {}) !== JSON.stringify(newB.props ?? {});
412
+ // A list turning loose (or tight) changes the page — its items spaced as paragraphs — so it is
413
+ // the container's own change, like a prop
414
+ const loose = (b) => b.meta?.loose === true;
415
+ const propsChanged = JSON.stringify(oldB.props ?? {}) !== JSON.stringify(newB.props ?? {}) || loose(oldB) !== loose(newB);
406
416
  const childChanged = children.some(hasAnyMark);
407
417
  // A container that carries its OWN prose (a `step` keeps its text in
408
418
  // `inline`, children usually empty) must diff that text too — otherwise
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dogsbay/tree-diff",
3
- "version": "0.2.0-beta.173",
3
+ "version": "0.2.0-beta.175",
4
4
  "license": "MIT",
5
5
  "description": "diffTrees: identity-driven version diffing over TreeNode — one DiffTree, many views (comparison pages, PR review, version-switcher compare, IDE change review)",
6
6
  "type": "module",
@@ -20,10 +20,10 @@
20
20
  "@types/node": "^25.9.5",
21
21
  "typescript": "^5.9.3",
22
22
  "vitest": "^4.1.10",
23
- "@dogsbay/format-dogsbay-md": "0.2.0-beta.173"
23
+ "@dogsbay/format-dogsbay-md": "0.2.0-beta.175"
24
24
  },
25
25
  "dependencies": {
26
- "@dogsbay/types": "0.2.0-beta.173"
26
+ "@dogsbay/types": "0.2.0-beta.175"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",