@flighthq/node 0.2.1-next.701.409c279 → 0.2.1-next.840.857425c

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.
@@ -1,6 +1,6 @@
1
1
  import type { Matrix, MatrixLike, Transform2DLike, Transform2DNode, Vector2Like } from '@flighthq/types';
2
2
  /**
3
- * Converts the `vector` object from the Stage (global) coordinates
3
+ * Converts the `vector` object from the Scene2D (global) coordinates
4
4
  * to the display object's (local) coordinates.
5
5
  **/
6
6
  export declare function convertNodeVector2GlobalToLocal<Traits extends object>(out: Vector2Like, source: Transform2DNode<Traits>, vector: Readonly<Vector2Like>): void;
@@ -3,7 +3,7 @@ import { copyMatrix, createMatrix, decomposeMatrixToTransform2D, inverseMatrixTr
3
3
  import { computeNodeWorldTransformRevision } from '@flighthq/node';
4
4
  import { invalidateNodeLocalTransform } from './revision';
5
5
  /**
6
- * Converts the `vector` object from the Stage (global) coordinates
6
+ * Converts the `vector` object from the Scene2D (global) coordinates
7
7
  * to the display object's (local) coordinates.
8
8
  **/
9
9
  export function convertNodeVector2GlobalToLocal(out, source, vector) {
@@ -1,7 +1,7 @@
1
- import type { MatrixLike, NodeTraits, StageFitContext, ViewportAlign } from '@flighthq/types';
2
- export declare function computeStageFitAlignX(scaledContentWidth: number, viewWidth: number, align: ViewportAlign): number;
3
- export declare function computeStageFitAlignY(scaledContentHeight: number, viewHeight: number, align: ViewportAlign): number;
4
- export declare function computeStageFitFillScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
5
- export declare function computeStageFitScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
6
- export declare function computeStageFitTransform<Traits extends object = NodeTraits>(out: MatrixLike, stage: Readonly<StageFitContext<Traits>>, viewWidth: number, viewHeight: number): void;
1
+ import type { MatrixLike, NodeTraits, Scene2DFitContext, ViewportAlign } from '@flighthq/types';
2
+ export declare function computeScene2DFitAlignX(scaledContentWidth: number, viewWidth: number, align: ViewportAlign): number;
3
+ export declare function computeScene2DFitAlignY(scaledContentHeight: number, viewHeight: number, align: ViewportAlign): number;
4
+ export declare function computeScene2DFitFillScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
5
+ export declare function computeScene2DFitScale(contentWidth: number, contentHeight: number, viewWidth: number, viewHeight: number): number;
6
+ export declare function computeScene2DFitTransform<Traits extends object = NodeTraits>(out: MatrixLike, scene2d: Readonly<Scene2DFitContext<Traits>>, viewWidth: number, viewHeight: number): void;
7
7
  //# sourceMappingURL=stageFit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stageFit.d.ts","sourceRoot":"","sources":["../src/stageFit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,UAAU,EACV,UAAU,EAEV,eAAe,EACf,aAAa,EACd,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,qBAAqB,CAAC,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAIjH;AAGD,wBAAgB,qBAAqB,CAAC,mBAAmB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAInH;AAGD,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAGD,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAMD,wBAAgB,wBAAwB,CAAC,MAAM,SAAS,MAAM,GAAG,UAAU,EACzE,GAAG,EAAE,UAAU,EACf,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,EACxC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CA+CN"}
1
+ {"version":3,"file":"stageFit.d.ts","sourceRoot":"","sources":["../src/stageFit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,UAAU,EACV,UAAU,EAEV,iBAAiB,EACjB,aAAa,EACd,MAAM,iBAAiB,CAAC;AAQzB,wBAAgB,uBAAuB,CAAC,kBAAkB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAInH;AAGD,wBAAgB,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,CAIrH;AAGD,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAGD,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAMD,wBAAgB,0BAA0B,CAAC,MAAM,SAAS,MAAM,GAAG,UAAU,EAC3E,GAAG,EAAE,UAAU,EACf,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,EAC5C,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,IAAI,CA+CN"}
package/dist/stageFit.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createRectangle } from '@flighthq/geometry';
2
2
  import { getNodeRuntime } from './node';
3
- // The structural fit context these functions read: a root node plus how it maps into the view. `Stage`
3
+ // The structural fit context these functions read: a root node plus how it maps into the view. `Scene2D`
4
4
  // satisfies it (its `align`/`scaleMode`/`root` fields); kept structural and generic so the fit math stays in
5
- // `@flighthq/node` without depending on the display-object `Stage` type.
5
+ // `@flighthq/node` without depending on the display-object `Scene2D` type.
6
6
  // Horizontal alignment offset of scaled content within the view, per the `align` anchor.
7
- export function computeStageFitAlignX(scaledContentWidth, viewWidth, align) {
7
+ export function computeScene2DFitAlignX(scaledContentWidth, viewWidth, align) {
8
8
  if (align.includes('left'))
9
9
  return 0;
10
10
  if (align.includes('right'))
@@ -12,7 +12,7 @@ export function computeStageFitAlignX(scaledContentWidth, viewWidth, align) {
12
12
  return (viewWidth - scaledContentWidth) / 2;
13
13
  }
14
14
  // Vertical alignment offset of scaled content within the view, per the `align` anchor.
15
- export function computeStageFitAlignY(scaledContentHeight, viewHeight, align) {
15
+ export function computeScene2DFitAlignY(scaledContentHeight, viewHeight, align) {
16
16
  if (align.includes('top'))
17
17
  return 0;
18
18
  if (align.includes('bottom'))
@@ -20,28 +20,28 @@ export function computeStageFitAlignY(scaledContentHeight, viewHeight, align) {
20
20
  return (viewHeight - scaledContentHeight) / 2;
21
21
  }
22
22
  // Uniform scale that fills the view (covers it, cropping overflow) — the larger of the axis ratios.
23
- export function computeStageFitFillScale(contentWidth, contentHeight, viewWidth, viewHeight) {
23
+ export function computeScene2DFitFillScale(contentWidth, contentHeight, viewWidth, viewHeight) {
24
24
  return Math.max(viewWidth / contentWidth, viewHeight / contentHeight);
25
25
  }
26
26
  // Uniform scale that fits the content inside the view (letter/pillarboxing) — the smaller of the axis ratios.
27
- export function computeStageFitScale(contentWidth, contentHeight, viewWidth, viewHeight) {
27
+ export function computeScene2DFitScale(contentWidth, contentHeight, viewWidth, viewHeight) {
28
28
  return Math.min(viewWidth / contentWidth, viewHeight / contentHeight);
29
29
  }
30
- // Writes the scale-and-align matrix that maps a stage's `root` content into a `viewWidth`×`viewHeight` view,
30
+ // Writes the scale-and-align matrix that maps a scene2d's `root` content into a `viewWidth`×`viewHeight` view,
31
31
  // per its `scaleMode` (`noscale`/`exactfit`/`showall`/`noborder`) and `align`. Reads the root's local bounds
32
- // through its runtime; an empty or unmeasurable root yields identity. This is the stage-fit transform the 2D
32
+ // through its runtime; an empty or unmeasurable root yields identity. This is the scene2d-fit transform the 2D
33
33
  // present pass applies before drawing the tree.
34
- export function computeStageFitTransform(out, stage, viewWidth, viewHeight) {
34
+ export function computeScene2DFitTransform(out, scene2d, viewWidth, viewHeight) {
35
35
  let contentWidth = 0;
36
36
  let contentHeight = 0;
37
- if (stage.root !== null) {
37
+ if (scene2d.root !== null) {
38
38
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- const runtime = getNodeRuntime(stage.root);
39
+ const runtime = getNodeRuntime(scene2d.root);
40
40
  if (runtime?.computeLocalBoundsRectangle !== undefined) {
41
41
  _tempRectangle.width = 0;
42
42
  _tempRectangle.height = 0;
43
43
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- runtime.computeLocalBoundsRectangle(_tempRectangle, stage.root);
44
+ runtime.computeLocalBoundsRectangle(_tempRectangle, scene2d.root);
45
45
  contentWidth = _tempRectangle.width;
46
46
  contentHeight = _tempRectangle.height;
47
47
  }
@@ -57,26 +57,26 @@ export function computeStageFitTransform(out, stage, viewWidth, viewHeight) {
57
57
  }
58
58
  let sx;
59
59
  let sy;
60
- if (stage.scaleMode === 'noscale') {
60
+ if (scene2d.scaleMode === 'noscale') {
61
61
  sx = 1;
62
62
  sy = 1;
63
63
  }
64
- else if (stage.scaleMode === 'exactfit') {
64
+ else if (scene2d.scaleMode === 'exactfit') {
65
65
  sx = viewWidth / contentWidth;
66
66
  sy = viewHeight / contentHeight;
67
67
  }
68
- else if (stage.scaleMode === 'showall') {
69
- sx = sy = computeStageFitScale(contentWidth, contentHeight, viewWidth, viewHeight);
68
+ else if (scene2d.scaleMode === 'showall') {
69
+ sx = sy = computeScene2DFitScale(contentWidth, contentHeight, viewWidth, viewHeight);
70
70
  }
71
71
  else {
72
- sx = sy = computeStageFitFillScale(contentWidth, contentHeight, viewWidth, viewHeight);
72
+ sx = sy = computeScene2DFitFillScale(contentWidth, contentHeight, viewWidth, viewHeight);
73
73
  }
74
74
  out.a = sx;
75
75
  out.b = 0;
76
76
  out.c = 0;
77
77
  out.d = sy;
78
- out.tx = computeStageFitAlignX(contentWidth * sx, viewWidth, stage.align);
79
- out.ty = computeStageFitAlignY(contentHeight * sy, viewHeight, stage.align);
78
+ out.tx = computeScene2DFitAlignX(contentWidth * sx, viewWidth, scene2d.align);
79
+ out.ty = computeScene2DFitAlignY(contentHeight * sy, viewHeight, scene2d.align);
80
80
  }
81
81
  const _tempRectangle = createRectangle();
82
82
  //# sourceMappingURL=stageFit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stageFit.js","sourceRoot":"","sources":["../src/stageFit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAExC,uGAAuG;AACvG,6GAA6G;AAC7G,yEAAyE;AACzE,yFAAyF;AACzF,MAAM,UAAU,qBAAqB,CAAC,kBAA0B,EAAE,SAAiB,EAAE,KAAoB;IACvG,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,GAAG,kBAAkB,CAAC;IACnE,OAAO,CAAC,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC9C,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,qBAAqB,CAAC,mBAA2B,EAAE,UAAkB,EAAE,KAAoB;IACzG,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,UAAU,GAAG,mBAAmB,CAAC;IACtE,OAAO,CAAC,UAAU,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,wBAAwB,CACtC,YAAoB,EACpB,aAAqB,EACrB,SAAiB,EACjB,UAAkB;IA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AAG,aAAa,CAAC;IAClC,CAAC;SAAM,IAAI,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QAC3C,EAAE,GAAG,EAAE,GAAG,sBAAsB,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IACvF,CAAC;SAAM,CAAC;QACN,EAAE,GAAG,EAAE,GAAG,0BAA0B,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC;IAC3F,CAAC;IAED,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACX,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACV,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,uBAAuB,CAAC,YAAY,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9E,GAAG,CAAC,EAAE,GAAG,uBAAuB,CAAC,aAAa,GAAG,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,cAAc,GAAc,eAAe,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/node",
3
- "version": "0.2.1-next.701.409c279",
3
+ "version": "0.2.1-next.840.857425c",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/flighthq/flight.git",
@@ -32,10 +32,10 @@
32
32
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
33
33
  },
34
34
  "dependencies": {
35
- "@flighthq/entity": "0.2.1-next.701.409c279",
36
- "@flighthq/geometry": "0.2.1-next.701.409c279",
37
- "@flighthq/signals": "0.2.1-next.701.409c279",
38
- "@flighthq/types": "0.2.1-next.701.409c279"
35
+ "@flighthq/entity": "0.2.1-next.840.857425c",
36
+ "@flighthq/geometry": "0.2.1-next.840.857425c",
37
+ "@flighthq/signals": "0.2.1-next.840.857425c",
38
+ "@flighthq/types": "0.2.1-next.840.857425c"
39
39
  },
40
40
  "devDependencies": {
41
41
  "typescript": "^5.3.0"
@@ -3,11 +3,11 @@ import type { HasBoundsRectangleRuntime, Node, NodeTraits, ViewportAlign, Viewpo
3
3
 
4
4
  import { createNode, getNodeRuntime } from './node';
5
5
  import {
6
- computeStageFitAlignX,
7
- computeStageFitAlignY,
8
- computeStageFitFillScale,
9
- computeStageFitScale,
10
- computeStageFitTransform,
6
+ computeScene2DFitAlignX,
7
+ computeScene2DFitAlignY,
8
+ computeScene2DFitFillScale,
9
+ computeScene2DFitScale,
10
+ computeScene2DFitTransform,
11
11
  } from './stageFit';
12
12
 
13
13
  const TestNodeKind = 'TestNode';
@@ -22,7 +22,7 @@ function makeNodeWithBounds(width: number, height: number) {
22
22
  return node;
23
23
  }
24
24
 
25
- // A structural stage-fit context (what Stage supplies): root plus how it maps into the view.
25
+ // A structural scene2d-fit context (what Scene2D supplies): root plus how it maps into the view.
26
26
  function fit(overrides: { align?: ViewportAlign; root?: Node<NodeTraits> | null; scaleMode?: ViewportScaleMode }): {
27
27
  align: ViewportAlign;
28
28
  root: Node<NodeTraits> | null;
@@ -35,76 +35,76 @@ function fit(overrides: { align?: ViewportAlign; root?: Node<NodeTraits> | null;
35
35
  };
36
36
  }
37
37
 
38
- describe('computeStageFitAlignX', () => {
38
+ describe('computeScene2DFitAlignX', () => {
39
39
  it('returns 0 for left-anchored alignments', () => {
40
- expect(computeStageFitAlignX(400, 800, 'left')).toBe(0);
41
- expect(computeStageFitAlignX(400, 800, 'topleft')).toBe(0);
42
- expect(computeStageFitAlignX(400, 800, 'bottomleft')).toBe(0);
40
+ expect(computeScene2DFitAlignX(400, 800, 'left')).toBe(0);
41
+ expect(computeScene2DFitAlignX(400, 800, 'topleft')).toBe(0);
42
+ expect(computeScene2DFitAlignX(400, 800, 'bottomleft')).toBe(0);
43
43
  });
44
44
 
45
45
  it('returns viewWidth - scaledWidth for right-anchored alignments', () => {
46
- expect(computeStageFitAlignX(400, 800, 'right')).toBe(400);
47
- expect(computeStageFitAlignX(400, 800, 'topright')).toBe(400);
48
- expect(computeStageFitAlignX(400, 800, 'bottomright')).toBe(400);
46
+ expect(computeScene2DFitAlignX(400, 800, 'right')).toBe(400);
47
+ expect(computeScene2DFitAlignX(400, 800, 'topright')).toBe(400);
48
+ expect(computeScene2DFitAlignX(400, 800, 'bottomright')).toBe(400);
49
49
  });
50
50
 
51
51
  it('returns centered offset for top/bottom alignments', () => {
52
- expect(computeStageFitAlignX(400, 800, 'top')).toBe(200);
53
- expect(computeStageFitAlignX(400, 800, 'bottom')).toBe(200);
52
+ expect(computeScene2DFitAlignX(400, 800, 'top')).toBe(200);
53
+ expect(computeScene2DFitAlignX(400, 800, 'bottom')).toBe(200);
54
54
  });
55
55
  });
56
56
 
57
- describe('computeStageFitAlignY', () => {
57
+ describe('computeScene2DFitAlignY', () => {
58
58
  it('returns 0 for top-anchored alignments', () => {
59
- expect(computeStageFitAlignY(300, 600, 'top')).toBe(0);
60
- expect(computeStageFitAlignY(300, 600, 'topleft')).toBe(0);
61
- expect(computeStageFitAlignY(300, 600, 'topright')).toBe(0);
59
+ expect(computeScene2DFitAlignY(300, 600, 'top')).toBe(0);
60
+ expect(computeScene2DFitAlignY(300, 600, 'topleft')).toBe(0);
61
+ expect(computeScene2DFitAlignY(300, 600, 'topright')).toBe(0);
62
62
  });
63
63
 
64
64
  it('returns viewHeight - scaledHeight for bottom-anchored alignments', () => {
65
- expect(computeStageFitAlignY(300, 600, 'bottom')).toBe(300);
66
- expect(computeStageFitAlignY(300, 600, 'bottomleft')).toBe(300);
67
- expect(computeStageFitAlignY(300, 600, 'bottomright')).toBe(300);
65
+ expect(computeScene2DFitAlignY(300, 600, 'bottom')).toBe(300);
66
+ expect(computeScene2DFitAlignY(300, 600, 'bottomleft')).toBe(300);
67
+ expect(computeScene2DFitAlignY(300, 600, 'bottomright')).toBe(300);
68
68
  });
69
69
 
70
70
  it('returns centered offset for left/right alignments', () => {
71
- expect(computeStageFitAlignY(300, 600, 'left')).toBe(150);
72
- expect(computeStageFitAlignY(300, 600, 'right')).toBe(150);
71
+ expect(computeScene2DFitAlignY(300, 600, 'left')).toBe(150);
72
+ expect(computeScene2DFitAlignY(300, 600, 'right')).toBe(150);
73
73
  });
74
74
  });
75
75
 
76
- describe('computeStageFitFillScale', () => {
76
+ describe('computeScene2DFitFillScale', () => {
77
77
  it('returns max of width and height ratios', () => {
78
- expect(computeStageFitFillScale(400, 300, 800, 600)).toBe(2);
78
+ expect(computeScene2DFitFillScale(400, 300, 800, 600)).toBe(2);
79
79
  });
80
80
 
81
81
  it('uses the larger ratio when width ratio wins', () => {
82
- expect(computeStageFitFillScale(400, 300, 800, 400)).toBeCloseTo(2);
82
+ expect(computeScene2DFitFillScale(400, 300, 800, 400)).toBeCloseTo(2);
83
83
  });
84
84
 
85
85
  it('uses the larger ratio when height ratio wins', () => {
86
- expect(computeStageFitFillScale(400, 300, 400, 600)).toBe(2);
86
+ expect(computeScene2DFitFillScale(400, 300, 400, 600)).toBe(2);
87
87
  });
88
88
  });
89
89
 
90
- describe('computeStageFitScale', () => {
90
+ describe('computeScene2DFitScale', () => {
91
91
  it('returns min of width and height ratios', () => {
92
- expect(computeStageFitScale(400, 300, 800, 600)).toBe(2);
92
+ expect(computeScene2DFitScale(400, 300, 800, 600)).toBe(2);
93
93
  });
94
94
 
95
95
  it('uses the smaller ratio when width ratio wins', () => {
96
- expect(computeStageFitScale(400, 300, 400, 600)).toBe(1);
96
+ expect(computeScene2DFitScale(400, 300, 400, 600)).toBe(1);
97
97
  });
98
98
 
99
99
  it('uses the smaller ratio when height ratio wins', () => {
100
- expect(computeStageFitScale(400, 300, 800, 400)).toBeCloseTo(400 / 300);
100
+ expect(computeScene2DFitScale(400, 300, 800, 400)).toBeCloseTo(400 / 300);
101
101
  });
102
102
  });
103
103
 
104
- describe('computeStageFitTransform', () => {
104
+ describe('computeScene2DFitTransform', () => {
105
105
  it('sets identity when root is null', () => {
106
106
  const m = createMatrix();
107
- computeStageFitTransform(m, fit({}), 800, 600);
107
+ computeScene2DFitTransform(m, fit({}), 800, 600);
108
108
  expect(m.a).toBe(1);
109
109
  expect(m.b).toBe(0);
110
110
  expect(m.c).toBe(0);
@@ -116,7 +116,7 @@ describe('computeStageFitTransform', () => {
116
116
  it('sets identity when root has no bounds capability', () => {
117
117
  const m = createMatrix();
118
118
  const root = createNode(TestNodeKind);
119
- computeStageFitTransform(m, fit({ root }), 800, 600);
119
+ computeScene2DFitTransform(m, fit({ root }), 800, 600);
120
120
  expect(m.a).toBe(1);
121
121
  expect(m.d).toBe(1);
122
122
  expect(m.tx).toBe(0);
@@ -126,14 +126,14 @@ describe('computeStageFitTransform', () => {
126
126
  it('sets identity when root computeLocalBoundsRectangle returns zero size', () => {
127
127
  const m = createMatrix();
128
128
  const root = makeNodeWithBounds(0, 0);
129
- computeStageFitTransform(m, fit({ root }), 800, 600);
129
+ computeScene2DFitTransform(m, fit({ root }), 800, 600);
130
130
  expect(m.a).toBe(1);
131
131
  expect(m.d).toBe(1);
132
132
  });
133
133
 
134
134
  it('noscale with topleft: identity scale at origin', () => {
135
135
  const m = createMatrix();
136
- computeStageFitTransform(
136
+ computeScene2DFitTransform(
137
137
  m,
138
138
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'noscale' }),
139
139
  800,
@@ -147,7 +147,7 @@ describe('computeStageFitTransform', () => {
147
147
 
148
148
  it('noscale with top alignment: centers horizontally', () => {
149
149
  const m = createMatrix();
150
- computeStageFitTransform(
150
+ computeScene2DFitTransform(
151
151
  m,
152
152
  fit({ align: 'top', root: makeNodeWithBounds(400, 300), scaleMode: 'noscale' }),
153
153
  800,
@@ -161,7 +161,7 @@ describe('computeStageFitTransform', () => {
161
161
 
162
162
  it('exactfit: scales to fill viewport exactly', () => {
163
163
  const m = createMatrix();
164
- computeStageFitTransform(
164
+ computeScene2DFitTransform(
165
165
  m,
166
166
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'exactfit' }),
167
167
  800,
@@ -175,7 +175,7 @@ describe('computeStageFitTransform', () => {
175
175
 
176
176
  it('exactfit: uses independent x/y scales', () => {
177
177
  const m = createMatrix();
178
- computeStageFitTransform(
178
+ computeScene2DFitTransform(
179
179
  m,
180
180
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'exactfit' }),
181
181
  800,
@@ -187,7 +187,7 @@ describe('computeStageFitTransform', () => {
187
187
 
188
188
  it('showall: fits content within viewport with uniform scale', () => {
189
189
  const m = createMatrix();
190
- computeStageFitTransform(
190
+ computeScene2DFitTransform(
191
191
  m,
192
192
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'showall' }),
193
193
  800,
@@ -199,7 +199,7 @@ describe('computeStageFitTransform', () => {
199
199
 
200
200
  it('noborder: fills viewport with uniform scale', () => {
201
201
  const m = createMatrix();
202
- computeStageFitTransform(
202
+ computeScene2DFitTransform(
203
203
  m,
204
204
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'noborder' }),
205
205
  800,
@@ -211,7 +211,7 @@ describe('computeStageFitTransform', () => {
211
211
 
212
212
  it('sets b and c to 0', () => {
213
213
  const m = createMatrix();
214
- computeStageFitTransform(
214
+ computeScene2DFitTransform(
215
215
  m,
216
216
  fit({ align: 'topleft', root: makeNodeWithBounds(400, 300), scaleMode: 'showall' }),
217
217
  800,