@flighthq/node 0.3.0-next.906.07cea63 → 0.3.1-next.209.43ef1bc

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 (44) hide show
  1. package/dist/boundsRectangle.d.ts +11 -0
  2. package/dist/boundsRectangle.d.ts.map +1 -1
  3. package/dist/boundsRectangle.js +50 -4
  4. package/dist/boundsRectangle.js.map +1 -1
  5. package/dist/contract.d.ts +1 -0
  6. package/dist/contract.d.ts.map +1 -1
  7. package/dist/contract.js +1 -0
  8. package/dist/contract.js.map +1 -1
  9. package/dist/hasBoundsRectangle.d.ts +1 -1
  10. package/dist/hasBoundsRectangle.d.ts.map +1 -1
  11. package/dist/hasBoundsRectangle.js +1 -0
  12. package/dist/hasBoundsRectangle.js.map +1 -1
  13. package/dist/hierarchy.d.ts.map +1 -1
  14. package/dist/hierarchy.js +19 -3
  15. package/dist/hierarchy.js.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/node.d.ts.map +1 -1
  21. package/dist/node.js +2 -0
  22. package/dist/node.js.map +1 -1
  23. package/dist/nodeOrderList.d.ts +88 -0
  24. package/dist/nodeOrderList.d.ts.map +1 -0
  25. package/dist/nodeOrderList.js +250 -0
  26. package/dist/nodeOrderList.js.map +1 -0
  27. package/dist/revision.d.ts +3 -1
  28. package/dist/revision.d.ts.map +1 -1
  29. package/dist/revision.js +8 -1
  30. package/dist/revision.js.map +1 -1
  31. package/dist/stageFit.d.ts.map +1 -1
  32. package/dist/stageFit.js +0 -2
  33. package/dist/stageFit.js.map +1 -1
  34. package/dist/traversal.d.ts +1 -1
  35. package/dist/traversal.d.ts.map +1 -1
  36. package/dist/traversal.js +1 -1
  37. package/dist/traversal.js.map +1 -1
  38. package/package.json +9 -7
  39. package/src/boundsRectangle.test.ts +58 -0
  40. package/src/hasBoundsRectangle.test.ts +8 -0
  41. package/src/hierarchy.test.ts +75 -1
  42. package/src/nodeOrderList.test.ts +617 -0
  43. package/src/revision.test.ts +25 -0
  44. package/src/traversal.test.ts +0 -1
@@ -31,7 +31,7 @@ import {
31
31
  } from './hierarchy';
32
32
  import { createNode, enableNodeSignals, getNodeRuntime } from './node';
33
33
  import { getNodeWorldMatrix } from './nodeTransform2d';
34
- import { invalidateNodeLocalTransform } from './revision';
34
+ import { getNodeChildrenRevision, getNodeParentReferenceRevision, invalidateNodeLocalTransform } from './revision';
35
35
 
36
36
  let container: Node<NodeTraits>;
37
37
  let childA: Node<NodeTraits>;
@@ -153,6 +153,16 @@ describe('addNodeChild', () => {
153
153
  });
154
154
 
155
155
  describe('addNodeChildAt', () => {
156
+ it('advances structural revisions when attaching a child', () => {
157
+ const childrenId = getNodeChildrenRevision(container);
158
+ const parentReferenceId = getNodeParentReferenceRevision(childA);
159
+
160
+ addNodeChildAt(container, childA, 0);
161
+
162
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
163
+ expect(getNodeParentReferenceRevision(childA)).toBe(parentReferenceId + 1);
164
+ });
165
+
156
166
  it('addNodeChildAt inserts a child at the given index', () => {
157
167
  addNodeChild(container, childA);
158
168
  addNodeChildAt(container, childB, 0);
@@ -189,6 +199,29 @@ describe('addNodeChildAt', () => {
189
199
  expect(getChildren(container)[1]).toBe(childA);
190
200
  });
191
201
 
202
+ it('advances only the child-list revision when reordering within one parent', () => {
203
+ addNodeChild(container, childA);
204
+ addNodeChild(container, childB);
205
+ const childrenId = getNodeChildrenRevision(container);
206
+ const parentReferenceId = getNodeParentReferenceRevision(childA);
207
+
208
+ addNodeChildAt(container, childA, 1);
209
+
210
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
211
+ expect(getNodeParentReferenceRevision(childA)).toBe(parentReferenceId);
212
+ });
213
+
214
+ it('does not advance structural revisions for an unchanged index', () => {
215
+ addNodeChild(container, childA);
216
+ const childrenId = getNodeChildrenRevision(container);
217
+ const parentReferenceId = getNodeParentReferenceRevision(childA);
218
+
219
+ addNodeChildAt(container, childA, 0);
220
+
221
+ expect(getNodeChildrenRevision(container)).toBe(childrenId);
222
+ expect(getNodeParentReferenceRevision(childA)).toBe(parentReferenceId);
223
+ });
224
+
192
225
  it('calls onParentChanged on the child', () => {
193
226
  let called = false;
194
227
  connectSignal(enableNodeSignals(childA).onParentChanged, () => {
@@ -456,6 +489,17 @@ describe('isNodeAncestorOf', () => {
456
489
  });
457
490
 
458
491
  describe('removeNodeChild', () => {
492
+ it('advances structural revisions when detaching a child', () => {
493
+ addNodeChild(container, childA);
494
+ const childrenId = getNodeChildrenRevision(container);
495
+ const parentReferenceId = getNodeParentReferenceRevision(childA);
496
+
497
+ removeNodeChild(container, childA);
498
+
499
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
500
+ expect(getNodeParentReferenceRevision(childA)).toBe(parentReferenceId + 1);
501
+ });
502
+
459
503
  it('removes the child and clears its parent', () => {
460
504
  addNodeChild(container, childA);
461
505
  expect(getNodeChildCount(container)).toBe(1);
@@ -864,6 +908,16 @@ describe('replaceNodeChild', () => {
864
908
  });
865
909
 
866
910
  describe('setNodeChildIndex', () => {
911
+ it('advances the child-list revision when order changes', () => {
912
+ addNodeChild(container, childA);
913
+ addNodeChild(container, childB);
914
+ const childrenId = getNodeChildrenRevision(container);
915
+
916
+ setNodeChildIndex(container, childA, 1);
917
+
918
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
919
+ });
920
+
867
921
  it('setChildIndex moves an existing child to a new index', () => {
868
922
  addNodeChild(container, childA);
869
923
  addNodeChild(container, childB);
@@ -908,6 +962,16 @@ describe('setNodeChildIndex', () => {
908
962
  });
909
963
 
910
964
  describe('swapNodeChildren', () => {
965
+ it('advances the child-list revision when order changes', () => {
966
+ addNodeChild(container, childA);
967
+ addNodeChild(container, childB);
968
+ const childrenId = getNodeChildrenRevision(container);
969
+
970
+ swapNodeChildren(container, childA, childB);
971
+
972
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
973
+ });
974
+
911
975
  it('swapNodeChildren swaps two children', () => {
912
976
  addNodeChild(container, childA);
913
977
  addNodeChild(container, childB);
@@ -943,6 +1007,16 @@ describe('swapNodeChildren', () => {
943
1007
  });
944
1008
 
945
1009
  describe('swapNodeChildrenAt', () => {
1010
+ it('advances the child-list revision when order changes', () => {
1011
+ addNodeChild(container, childA);
1012
+ addNodeChild(container, childB);
1013
+ const childrenId = getNodeChildrenRevision(container);
1014
+
1015
+ swapNodeChildrenAt(container, 0, 1);
1016
+
1017
+ expect(getNodeChildrenRevision(container)).toBe(childrenId + 1);
1018
+ });
1019
+
946
1020
  it('swapNodeChildrenAt swaps children by index', () => {
947
1021
  addNodeChild(container, childA);
948
1022
  addNodeChild(container, childB);