flo-mat 3.0.13 → 3.0.15

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 (138) hide show
  1. package/__tests__/cp-node/check-clone-eql-calc.spec.ts +58 -0
  2. package/__tests__/cp-node/compare-cp-nodes-by-value.ts +35 -0
  3. package/__tests__/cp-node/compare-loops-by-value.ts +40 -0
  4. package/__tests__/cp-node/compare-poss-by-value.ts +25 -0
  5. package/__tests__/cp-node/fs/clone.spec.ts +19 -3
  6. package/__tests__/cp-node/fs/find-first.spec.ts +13 -3
  7. package/__tests__/cp-node/fs/get-all-between.spec.ts +20 -3
  8. package/__tests__/cp-node/fs/get-all-on-circle.spec.ts +2 -2
  9. package/__tests__/cp-node/fs/get-all-on-loop.spec.ts +16 -3
  10. package/__tests__/cp-node/fs/get-all-vertices.spec.ts +14 -3
  11. package/__tests__/cp-node/fs/get-children.spec.ts +18 -3
  12. package/__tests__/cp-node/fs/get-non-terminating-on-circle.spec.ts +14 -3
  13. package/__tests__/cp-node/fs/get-prong-count.spec.ts +16 -3
  14. package/__tests__/cp-node/fs/get-real-prong-count.spec.ts +11 -3
  15. package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +20 -3
  16. package/__tests__/cp-node/fs/is-fully-terminating.spec.ts +16 -3
  17. package/__tests__/cp-node/fs/is-on-same-circle.spec.ts +20 -3
  18. package/__tests__/cp-node/fs/is-one-prong.spec.ts +16 -3
  19. package/__tests__/cp-node/fs/is-sharp.spec.ts +10 -3
  20. package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +13 -3
  21. package/__tests__/cp-node/fs/is-special.spec.ts +12 -3
  22. package/__tests__/cp-node/fs/is-terminating.spec.ts +15 -3
  23. package/__tests__/cp-node/fs/is-trivial.spec.ts +13 -3
  24. package/__tests__/cp-node/fs/is-two-prong.spec.ts +11 -3
  25. package/__tests__/cp-node/fs/is-vertex-special.spec.ts +13 -3
  26. package/__tests__/cp-node/fs/is-vertex.spec.ts +14 -3
  27. package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +13 -3
  28. package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +10 -3
  29. package/__tests__/cp-node/fs/traverse-cp.spec.ts +9 -3
  30. package/__tests__/cp-node/fs/traverse-edges.spec.ts +13 -3
  31. package/__tests__/cp-node/fs/traverse-vertices.spec.ts +12 -3
  32. package/__tests__/cp-node/random-walk.ts +33 -0
  33. package/__tests__/cp-node/stringification/from-stringifyable.spec.ts +3 -0
  34. package/__tests__/cp-node/stringification/loop-from-stringifyable.spec.ts +4 -0
  35. package/__tests__/cp-node/stringification/loop-to-stringifyable.spec.ts +19 -0
  36. package/__tests__/cp-node/stringification/to-stringifyable.spec.ts +34 -0
  37. package/__tests__/get-mats1.ts +125 -0
  38. package/__tests__/jsog/check-jsog-eql-calc.spec.ts +47 -67
  39. package/__tests__/jsog/decode-jsog.ts +88 -85
  40. package/__tests__/jsog/mat-dummy-1.ts +19 -0
  41. package/__tests__/jsog/mat-dummys.ts +6197 -6195
  42. package/__tests__/jsog/to-jsog-breath-first.ts +110 -107
  43. package/__tests__/jsog/to-jsog-depth-first.ts +58 -55
  44. package/browser/index.js +7002 -6298
  45. package/browser/index.min.js +1 -1
  46. package/jest.config.cjs +1 -0
  47. package/node/closest-boundary-point/foot-and-endpoint-info.d.ts +1 -1
  48. package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +3 -3
  49. package/node/closest-boundary-point/get-close-boundary-points-certified.js +1 -1
  50. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  51. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.d.ts +2 -2
  52. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +7 -7
  53. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
  54. package/node/cp-node/cp-node.d.ts +2 -2
  55. package/node/cp-node/fs/clone.d.ts +1 -1
  56. package/node/cp-node/fs/clone.js +17 -13
  57. package/node/cp-node/fs/clone.js.map +1 -1
  58. package/node/cp-node/fs/enhance-cp-node.d.ts +2 -2
  59. package/node/cp-node/fs/find-first.d.ts +9 -2
  60. package/node/cp-node/fs/find-first.js +12 -9
  61. package/node/cp-node/fs/find-first.js.map +1 -1
  62. package/node/cp-node/fs/get-all-on-loop.js +5 -6
  63. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  64. package/node/cp-node/fs/get-edge-direction.d.ts +1 -1
  65. package/node/cp-node/fs/get-edge-direction.js.map +1 -1
  66. package/node/cp-node/fs/is-on-same-circle.d.ts +1 -0
  67. package/node/cp-node/fs/is-on-same-circle.js +1 -0
  68. package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
  69. package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +1 -1
  70. package/node/debug/functions/draw-elem/draw-dull-corner.js +1 -1
  71. package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
  72. package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +1 -1
  73. package/node/debug/functions/draw-elem/draw-sharp-corner.js +2 -1
  74. package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
  75. package/node/find-mat/find-mats.js +7 -2
  76. package/node/find-mat/find-mats.js.map +1 -1
  77. package/node/find-mat/get-meta.d.ts +4 -4
  78. package/node/find-mat/get-meta.js +1 -1
  79. package/node/find-mat/get-meta.js.map +1 -1
  80. package/node/geometry/circle.d.ts +4 -3
  81. package/node/geometry/circle.js +0 -7
  82. package/node/geometry/circle.js.map +1 -1
  83. package/node/index.d.ts +2 -2
  84. package/node/index.js +1 -0
  85. package/node/index.js.map +1 -1
  86. package/node/mat/curve-piece.d.ts +3 -3
  87. package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
  88. package/node/mat/mat-meta.d.ts +4 -4
  89. package/node/mat/simplify-mat.d.ts +10 -8
  90. package/node/mat/simplify-mat.js +12 -10
  91. package/node/mat/simplify-mat.js.map +1 -1
  92. package/node/point-on-shape/create-pos.d.ts +2 -2
  93. package/node/point-on-shape/create-pos.js.map +1 -1
  94. package/node/point-on-shape/point-on-shape.d.ts +6 -6
  95. package/node/svg/get-loop-bounds.d.ts +2 -2
  96. package/node/svg/get-loop-bounds.js +1 -1
  97. package/node/svg/get-loop-bounds.js.map +1 -1
  98. package/package.json +10 -10
  99. package/src/closest-boundary-point/foot-and-endpoint-info.ts +1 -1
  100. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -5
  101. package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +9 -9
  102. package/src/cp-node/cp-node.ts +8 -3
  103. package/src/cp-node/fs/add-distance-from.ts +37 -37
  104. package/src/cp-node/fs/clone.ts +23 -17
  105. package/src/cp-node/fs/find-first.ts +14 -11
  106. package/src/cp-node/fs/get-all-on-loop.ts +5 -6
  107. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +1 -1
  108. package/src/cp-node/fs/get-edge-direction.ts +3 -5
  109. package/src/cp-node/fs/is-on-same-circle.ts +1 -0
  110. package/src/cp-node/stringification/cp-node-stringifyable.ts +68 -0
  111. package/src/cp-node/stringification/from-stringifyable.ts +57 -0
  112. package/src/cp-node/stringification/loop-from-stringifyable.ts +15 -0
  113. package/src/cp-node/stringification/loop-stringifyable.ts +8 -0
  114. package/src/cp-node/stringification/loop-to-stringifyable.ts +14 -0
  115. package/src/cp-node/stringification/to-stringifyable.ts +71 -0
  116. package/src/curve/curve.ts +31 -33
  117. package/src/debug/functions/draw-elem/draw-dull-corner.ts +2 -2
  118. package/src/debug/functions/draw-elem/draw-sharp-corner.ts +4 -3
  119. package/src/find-mat/find-mats.ts +8 -2
  120. package/src/find-mat/get-meta.ts +7 -6
  121. package/src/geometry/circle.ts +5 -12
  122. package/src/index.ts +3 -4
  123. package/src/mat/curve-piece.ts +3 -3
  124. package/src/mat/get-boundary-piece-beziers.ts +3 -3
  125. package/src/mat/mat-meta.ts +4 -4
  126. package/src/mat/simplify-mat-map-only.ts +110 -110
  127. package/src/mat/simplify-mat.ts +15 -13
  128. package/src/point-on-shape/create-pos.ts +3 -3
  129. package/src/point-on-shape/point-on-shape.ts +6 -6
  130. package/src/svg/get-loop-bounds.ts +4 -5
  131. package/__tests__/cp-node/fs/add-distance-from.spec.ts +0 -7
  132. package/__tests__/cp-node/fs/cp-nodes-to-boundary-beziers.spec.ts +0 -7
  133. package/__tests__/cp-node/fs/create-cp-node.spec.ts +0 -7
  134. package/__tests__/cp-node/fs/enhance-cp-node.spec.ts +0 -7
  135. package/__tests__/jsog/get-mats1.ts +0 -41
  136. package/node/curve/curve.d.ts +0 -33
  137. package/node/curve/curve.js +0 -2
  138. package/node/curve/curve.js.map +0 -1
@@ -1,85 +1,88 @@
1
-
2
- /**
3
- * Decodes a JSOG-encoded object back into a live circular graph.
4
- */
5
- function decodeJSOG(jsog: any) {
6
- const idMap = new Map<string, any>();
7
-
8
- // Pass 1: catalog all objects that have an @id.
9
- function findIds(obj: any) {
10
- if (!obj || typeof obj !== 'object') return;
11
-
12
- if (Array.isArray(obj)) {
13
- obj.forEach(findIds);
14
- return;
15
- }
16
-
17
- if (obj['@id'] !== undefined) {
18
- const id = String(obj['@id']);
19
- if (!idMap.has(id)) {
20
- if (obj['@type'] === 'Map') {
21
- idMap.set(id, new Map());
22
- } else if (obj['@type'] === 'Set') {
23
- idMap.set(id, new Set());
24
- } else {
25
- idMap.set(id, {});
26
- }
27
- }
28
- }
29
-
30
- Object.entries(obj).forEach(([key, val]) => {
31
- if (key !== '@ref') {
32
- findIds(val);
33
- }
34
- });
35
- }
36
-
37
- // Pass 2: reconstruct the graph by swapping @ref for the actual object.
38
- function resolve(obj: any): any {
39
- if (!obj || typeof obj !== 'object') return obj;
40
-
41
- if (Array.isArray(obj)) {
42
- return obj.map(resolve);
43
- }
44
-
45
- if (obj['@ref'] !== undefined) {
46
- const refId = String(obj['@ref']);
47
- if (!idMap.has(refId)) {
48
- throw new Error(`Invalid JSOG: missing @id for @ref "${refId}".`);
49
- }
50
- return idMap.get(refId);
51
- }
52
-
53
- const result = obj['@id'] !== undefined
54
- ? idMap.get(String(obj['@id']))
55
- : {};
56
-
57
- if (obj['@type'] === 'Map') {
58
- for (const pair of obj.entries ?? []) {
59
- if (!Array.isArray(pair) || pair.length !== 2) continue;
60
- result.set(resolve(pair[0]), resolve(pair[1]));
61
- }
62
- return result;
63
- }
64
-
65
- if (obj['@type'] === 'Set') {
66
- for (const value of obj.values ?? []) {
67
- result.add(resolve(value));
68
- }
69
- return result;
70
- }
71
-
72
- for (const key in obj) {
73
- if (key === '@id' || key === '@type') continue;
74
- result[key] = resolve(obj[key]);
75
- }
76
-
77
- return result;
78
- }
79
-
80
- findIds(jsog);
81
- return resolve(jsog);
82
- }
83
-
84
-
85
- export { decodeJSOG }
1
+ //=======================================
2
+ // NOTE! JSOG not used in tests anymore!
3
+ //=======================================
4
+
5
+ // /**
6
+ // * Decodes a JSOG-encoded object back into a live circular graph.
7
+ // */
8
+ // function decodeJSOG(jsog: any) {
9
+ // const idMap = new Map<string, any>();
10
+
11
+ // // Pass 1: catalog all objects that have an @id.
12
+ // function findIds(obj: any) {
13
+ // if (!obj || typeof obj !== 'object') return;
14
+
15
+ // if (Array.isArray(obj)) {
16
+ // obj.forEach(findIds);
17
+ // return;
18
+ // }
19
+
20
+ // if (obj['@id'] !== undefined) {
21
+ // const id = String(obj['@id']);
22
+ // if (!idMap.has(id)) {
23
+ // if (obj['@type'] === 'Map') {
24
+ // idMap.set(id, new Map());
25
+ // } else if (obj['@type'] === 'Set') {
26
+ // idMap.set(id, new Set());
27
+ // } else {
28
+ // idMap.set(id, {});
29
+ // }
30
+ // }
31
+ // }
32
+
33
+ // Object.entries(obj).forEach(([key, val]) => {
34
+ // if (key !== '@ref') {
35
+ // findIds(val);
36
+ // }
37
+ // });
38
+ // }
39
+
40
+ // // Pass 2: reconstruct the graph by swapping @ref for the actual object.
41
+ // function resolve(obj: any): any {
42
+ // if (!obj || typeof obj !== 'object') return obj;
43
+
44
+ // if (Array.isArray(obj)) {
45
+ // return obj.map(resolve);
46
+ // }
47
+
48
+ // if (obj['@ref'] !== undefined) {
49
+ // const refId = String(obj['@ref']);
50
+ // if (!idMap.has(refId)) {
51
+ // throw new Error(`Invalid JSOG: missing @id for @ref "${refId}".`);
52
+ // }
53
+ // return idMap.get(refId);
54
+ // }
55
+
56
+ // const result = obj['@id'] !== undefined
57
+ // ? idMap.get(String(obj['@id']))
58
+ // : {};
59
+
60
+ // if (obj['@type'] === 'Map') {
61
+ // for (const pair of obj.entries ?? []) {
62
+ // if (!Array.isArray(pair) || pair.length !== 2) continue;
63
+ // result.set(resolve(pair[0]), resolve(pair[1]));
64
+ // }
65
+ // return result;
66
+ // }
67
+
68
+ // if (obj['@type'] === 'Set') {
69
+ // for (const value of obj.values ?? []) {
70
+ // result.add(resolve(value));
71
+ // }
72
+ // return result;
73
+ // }
74
+
75
+ // for (const key in obj) {
76
+ // if (key === '@id' || key === '@type') continue;
77
+ // result[key] = resolve(obj[key]);
78
+ // }
79
+
80
+ // return result;
81
+ // }
82
+
83
+ // findIds(jsog);
84
+ // return resolve(jsog);
85
+ // }
86
+
87
+
88
+ // export { decodeJSOG }
@@ -0,0 +1,19 @@
1
+ // import { fromStringifyable } from "../../src/cp-node/stringification/from-stringifyable.js";
2
+ // import { toStringifyable } from "../../src/cp-node/stringification/to-stringifyable.js";
3
+ // import { Mat } from "../../src/mat/mat.js";
4
+ // import { getMats1 } from "./get-mats1.js";
5
+
6
+
7
+ // const mats1 = getMats1();
8
+
9
+ // const cpNode1_stringifyable = toStringifyable(mats1[0].cpNode);
10
+
11
+ // const mats1_: Mat[] = [{
12
+ // cpNode: fromStringifyable(cpNode1_stringifyable),
13
+ // meta: mats1[0].meta // technically should also be
14
+ // }];
15
+
16
+
17
+ // console.log(JSON.stringify(mats1_[0].cpNode)); //?
18
+
19
+ // export { mats1_ };