@ankhorage/zora 27.4.2 → 27.4.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 27.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 45d8aa9: Keep GraphView label sizing stable when renderer metrics contain floating-point noise above whole pixels.
8
+
3
9
  ## 27.4.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # ZORA
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v27.4.2](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v27.4.3](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
7
7
 
8
8
  Provides opinionated React Native and React Native Web UI components, theme primitives, registries, and reader surfaces built on @ankhorage/surface.
9
9
 
@@ -22,8 +22,8 @@ export function sizeGraphNodesToLabels(cy, sizedNodeIds, enabled) {
22
22
  });
23
23
  if (bounds.w <= 0 || bounds.h <= 0)
24
24
  return;
25
- const width = Math.ceil(bounds.w);
26
- const height = Math.ceil(bounds.h);
25
+ const width = getStableLabelDimension(bounds.w);
26
+ const height = getStableLabelDimension(bounds.h);
27
27
  if (node.width() !== width || node.height() !== height)
28
28
  node.style({ width, height });
29
29
  visibleIds.add(node.id());
@@ -37,4 +37,8 @@ export function sizeGraphNodesToLabels(cy, sizedNodeIds, enabled) {
37
37
  for (const id of visibleIds)
38
38
  sizedNodeIds.add(id);
39
39
  }
40
+ /*** Round upward while discarding only floating-point noise above whole label pixels. */
41
+ function getStableLabelDimension(dimension) {
42
+ return Math.ceil(dimension - Number.EPSILON * Math.max(1, dimension));
43
+ }
40
44
  //# sourceMappingURL=sizeGraphNodesToLabels.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sizeGraphNodesToLabels.js","sourceRoot":"","sources":["../../../../../../src/features/graph-view/adapters/inbound/web-artifact/sizeGraphNodesToLabels.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAQ,EAAE,YAAyB,EAAE,OAAgB;IAC1F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,KAAK,MAAM,EAAE,IAAI,YAAY;YAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACjF,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;YAC9B,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,KAAK;YACnB,aAAa,EAAE,IAAI;YACnB,eAAe,EAAE,KAAK;YACtB,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,MAAM;YAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACtF,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACxB,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;YAClD,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,UAAU;QAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC","sourcesContent":["import type { Core } from 'cytoscape';\n\n/***\n * Size plain leaf nodes from the renderer's styled label bounds, keeping padding in the stylesheet.\n * Reuse Cytoscape's cached text measurements during reconciliation, never a per-element\n * style callback or a pan/zoom listener. Only write changed dimensions; bold and Unicode labels must\n * not regress to character-count estimates. Compound dimensions remain owned by child bounds.\n */\nexport function sizeGraphNodesToLabels(cy: Core, sizedNodeIds: Set<string>, enabled: boolean) {\n if (!enabled) {\n for (const id of sizedNodeIds) cy.getElementById(id).removeStyle('width height');\n sizedNodeIds.clear();\n return;\n }\n const visibleIds = new Set<string>();\n cy.nodes(':childless').forEach((node) => {\n const bounds = node.boundingBox({\n includeNodes: false,\n includeEdges: false,\n includeLabels: true,\n includeOverlays: false,\n includeUnderlays: false,\n });\n if (bounds.w <= 0 || bounds.h <= 0) return;\n const width = Math.ceil(bounds.w);\n const height = Math.ceil(bounds.h);\n if (node.width() !== width || node.height() !== height) node.style({ width, height });\n visibleIds.add(node.id());\n });\n for (const id of sizedNodeIds) {\n if (!visibleIds.has(id)) {\n cy.getElementById(id).removeStyle('width height');\n sizedNodeIds.delete(id);\n }\n }\n for (const id of visibleIds) sizedNodeIds.add(id);\n}\n"]}
1
+ {"version":3,"file":"sizeGraphNodesToLabels.js","sourceRoot":"","sources":["../../../../../../src/features/graph-view/adapters/inbound/web-artifact/sizeGraphNodesToLabels.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,EAAQ,EAAE,YAAyB,EAAE,OAAgB;IAC1F,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,KAAK,MAAM,EAAE,IAAI,YAAY;YAAE,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QACjF,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;YAC9B,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,KAAK;YACnB,aAAa,EAAE,IAAI;YACnB,eAAe,EAAE,KAAK;YACtB,gBAAgB,EAAE,KAAK;SACxB,CAAC,CAAC;QACH,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC;YAAE,OAAO;QAC3C,MAAM,KAAK,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChD,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACjD,IAAI,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,MAAM;YAAE,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACtF,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,KAAK,MAAM,EAAE,IAAI,YAAY,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACxB,EAAE,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;YAClD,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;IACD,KAAK,MAAM,EAAE,IAAI,UAAU;QAAE,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,yFAAyF;AACzF,SAAS,uBAAuB,CAAC,SAAiB;IAChD,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import type { Core } from 'cytoscape';\n\n/***\n * Size plain leaf nodes from the renderer's styled label bounds, keeping padding in the stylesheet.\n * Reuse Cytoscape's cached text measurements during reconciliation, never a per-element\n * style callback or a pan/zoom listener. Only write changed dimensions; bold and Unicode labels must\n * not regress to character-count estimates. Compound dimensions remain owned by child bounds.\n */\nexport function sizeGraphNodesToLabels(cy: Core, sizedNodeIds: Set<string>, enabled: boolean) {\n if (!enabled) {\n for (const id of sizedNodeIds) cy.getElementById(id).removeStyle('width height');\n sizedNodeIds.clear();\n return;\n }\n const visibleIds = new Set<string>();\n cy.nodes(':childless').forEach((node) => {\n const bounds = node.boundingBox({\n includeNodes: false,\n includeEdges: false,\n includeLabels: true,\n includeOverlays: false,\n includeUnderlays: false,\n });\n if (bounds.w <= 0 || bounds.h <= 0) return;\n const width = getStableLabelDimension(bounds.w);\n const height = getStableLabelDimension(bounds.h);\n if (node.width() !== width || node.height() !== height) node.style({ width, height });\n visibleIds.add(node.id());\n });\n for (const id of sizedNodeIds) {\n if (!visibleIds.has(id)) {\n cy.getElementById(id).removeStyle('width height');\n sizedNodeIds.delete(id);\n }\n }\n for (const id of visibleIds) sizedNodeIds.add(id);\n}\n\n/*** Round upward while discarding only floating-point noise above whole label pixels. */\nfunction getStableLabelDimension(dimension: number): number {\n return Math.ceil(dimension - Number.EPSILON * Math.max(1, dimension));\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/zora",
3
3
  "type": "module",
4
- "version": "27.4.2",
4
+ "version": "27.4.3",
5
5
  "description": "Opinionated React Native and React Native Web UI kit built on @ankhorage/surface.",
6
6
  "homepage": "https://github.com/ankhorage/zora#readme",
7
7
  "bugs": {
@@ -36,3 +36,35 @@ test('uses rendered label bounds, retains padding, and releases sizing when disa
36
36
  cy.destroy();
37
37
  }
38
38
  });
39
+
40
+ test('keeps mathematically whole fractional label metrics idempotent while growing for real fractions', () => {
41
+ const cy = cytoscape({
42
+ headless: true,
43
+ styleEnabled: true,
44
+ elements: [{ data: { id: 'fractional-label' } }],
45
+ style: [{ selector: 'node', style: { width: 30, height: 20 } }],
46
+ });
47
+ const sized = new Set<string>();
48
+ const node = cy.getElementById('fractional-label');
49
+ const bounds = { height: 18.000000000000004, width: 50.00000000000001 };
50
+ node.boundingBox = () => ({
51
+ x1: 0,
52
+ x2: bounds.width,
53
+ y1: 0,
54
+ y2: bounds.height,
55
+ w: bounds.width,
56
+ h: bounds.height,
57
+ });
58
+ try {
59
+ sizeGraphNodesToLabels(cy, sized, true);
60
+ expect(node.width()).toBe(50);
61
+ expect(node.height()).toBe(18);
62
+ sizeGraphNodesToLabels(cy, sized, true);
63
+ expect(node.width()).toBe(50);
64
+ bounds.width = 50.0001;
65
+ sizeGraphNodesToLabels(cy, sized, true);
66
+ expect(node.width()).toBe(51);
67
+ } finally {
68
+ cy.destroy();
69
+ }
70
+ });
@@ -22,8 +22,8 @@ export function sizeGraphNodesToLabels(cy: Core, sizedNodeIds: Set<string>, enab
22
22
  includeUnderlays: false,
23
23
  });
24
24
  if (bounds.w <= 0 || bounds.h <= 0) return;
25
- const width = Math.ceil(bounds.w);
26
- const height = Math.ceil(bounds.h);
25
+ const width = getStableLabelDimension(bounds.w);
26
+ const height = getStableLabelDimension(bounds.h);
27
27
  if (node.width() !== width || node.height() !== height) node.style({ width, height });
28
28
  visibleIds.add(node.id());
29
29
  });
@@ -35,3 +35,8 @@ export function sizeGraphNodesToLabels(cy: Core, sizedNodeIds: Set<string>, enab
35
35
  }
36
36
  for (const id of visibleIds) sizedNodeIds.add(id);
37
37
  }
38
+
39
+ /*** Round upward while discarding only floating-point noise above whole label pixels. */
40
+ function getStableLabelDimension(dimension: number): number {
41
+ return Math.ceil(dimension - Number.EPSILON * Math.max(1, dimension));
42
+ }
@@ -123973,8 +123973,8 @@ function sizeGraphNodesToLabels(cy, sizedNodeIds, enabled) {
123973
123973
  });
123974
123974
  if (bounds.w <= 0 || bounds.h <= 0)
123975
123975
  return;
123976
- const width = Math.ceil(bounds.w);
123977
- const height = Math.ceil(bounds.h);
123976
+ const width = getStableLabelDimension(bounds.w);
123977
+ const height = getStableLabelDimension(bounds.h);
123978
123978
  if (node.width() !== width || node.height() !== height)
123979
123979
  node.style({ width, height });
123980
123980
  visibleIds.add(node.id());
@@ -123988,6 +123988,9 @@ function sizeGraphNodesToLabels(cy, sizedNodeIds, enabled) {
123988
123988
  for (const id of visibleIds)
123989
123989
  sizedNodeIds.add(id);
123990
123990
  }
123991
+ function getStableLabelDimension(dimension) {
123992
+ return Math.ceil(dimension - Number.EPSILON * Math.max(1, dimension));
123993
+ }
123991
123994
 
123992
123995
  // src/features/graph-view/adapters/inbound/web-artifact/createRenderableGraphElements.ts
123993
123996
  function createRenderableGraphElements(nodes, edges) {