@pie-element/graphing 11.0.4-next.20261011174919 → 11.0.4
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/dist/author/configure.d.ts +23 -13
- package/dist/author/configure.js +84 -93
- package/dist/author/correct-response.d.ts +2 -0
- package/dist/author/correct-response.js +2 -0
- package/dist/author/defaults.d.ts +196 -80
- package/dist/author/graphing-config.d.ts +2 -0
- package/dist/author/graphing-config.js +2 -0
- package/dist/author/index.d.ts +18 -46
- package/dist/author/index.js +7 -2
- package/dist/browser/author/index.js +17 -19
- package/dist/browser/author/index.js.map +1 -1
- package/dist/browser/controller/index.js +125 -135
- package/dist/browser/controller/index.js.map +1 -1
- package/dist/browser/editor-runtime/author/index.js +17 -19
- package/dist/browser/editor-runtime/author/index.js.map +1 -1
- package/dist/browser/editor-runtime/controller/index.js +125 -135
- package/dist/browser/editor-runtime/controller/index.js.map +1 -1
- package/dist/controller/defaults.d.ts +18 -17
- package/dist/controller/index.d.ts +56 -16
- package/dist/controller/index.js +23 -20
- package/dist/controller/utils.d.ts +24 -28
- package/dist/controller/utils.js +77 -90
- package/dist/index.d.ts +1 -0
- package/dist/schemas/configuration.schema.json +757 -0
- package/dist/schemas/model.schema.json +702 -0
- package/dist/schemas/session.schema.json +127 -0
- package/dist/types.d.ts +346 -0
- package/package.json +20 -16
package/dist/controller/utils.js
CHANGED
|
@@ -1,111 +1,98 @@
|
|
|
1
1
|
import { differenceWith as e, isEqual as t, uniq as n, uniqWith as r } from "@pie-element/shared-lodash";
|
|
2
2
|
import { getAmplitudeAndFreq as i, pointsToABC as a, pointsToABForExponential as o, pointsToAForAbsolute as s } from "@pie-lib/graphing-utils";
|
|
3
3
|
//#region src/controller/utils.ts
|
|
4
|
-
var c = (e, n) => (e = { ...e }, n = { ...n }, t(e.x, n.x) && t(e.y, n.y)),
|
|
4
|
+
var c = (e) => ({ ...e }), l = (e, n) => (e = { ...e }, n = { ...n }, t(e.x, n.x) && t(e.y, n.y)), u = (e, n) => {
|
|
5
5
|
let r = !0;
|
|
6
6
|
return e = { ...e }, n = { ...n }, (e.label || n.label) && (r = t(e.label, n.label)), t(e.x, n.x) && t(e.y, n.y) && r;
|
|
7
|
-
},
|
|
8
|
-
e =
|
|
9
|
-
...e,
|
|
10
|
-
to: { ...e.to },
|
|
11
|
-
from: { ...e.from }
|
|
12
|
-
};
|
|
13
|
-
let t = e.from.x, n = e.from.y, r = e.to.x, i = e.to.y;
|
|
7
|
+
}, d = (e, n) => t(e.from, n.from) && t(e.to, n.to) || t(e.to, n.from) && t(e.from, n.to), f = (e, n) => t(e.from, n.from) && t(e.to, n.to), p = (e) => Object.keys(e || {}).sort().reduce((t, n) => (e && n !== "correctAnswer" && (t[n] = e[n]), t), {}), m = (e) => {
|
|
8
|
+
let t = c(e.from), n = c(e.to), r = t.x, i = t.y, a = n.x, o = n.y;
|
|
14
9
|
return {
|
|
15
|
-
a:
|
|
16
|
-
b:
|
|
17
|
-
c:
|
|
10
|
+
a: o - i,
|
|
11
|
+
b: r - a,
|
|
12
|
+
c: a * i - r * o
|
|
18
13
|
};
|
|
19
|
-
},
|
|
20
|
-
let { a: r, b: i, c: a } =
|
|
21
|
-
if (o !== 0) l.push(
|
|
14
|
+
}, h = (e) => Math.round(e * 1e4) / 1e4, g = (e, t) => {
|
|
15
|
+
let { a: r, b: i, c: a } = m(e), { a: o, b: s, c } = m(t), l = [];
|
|
16
|
+
if (o !== 0) l.push(h(r / o));
|
|
22
17
|
else if (r !== o) return !1;
|
|
23
|
-
if (s !== 0) l.push(
|
|
18
|
+
if (s !== 0) l.push(h(i / s));
|
|
24
19
|
else if (i !== s) return !1;
|
|
25
|
-
if (c !== 0) l.push(
|
|
20
|
+
if (c !== 0) l.push(h(a / c));
|
|
26
21
|
else if (a !== c) return !1;
|
|
27
22
|
return n(l).length === 1;
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
to:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
}, _ = (e, t) => {
|
|
24
|
+
let n = {
|
|
25
|
+
from: c(e.from),
|
|
26
|
+
to: c(e.to)
|
|
27
|
+
}, r = {
|
|
28
|
+
from: c(t.from),
|
|
29
|
+
to: c(t.to)
|
|
30
|
+
}, i = (n.to.y - n.from.y) / (n.to.x - n.from.x), a = (r.to.y - r.from.y) / (r.to.x - r.from.x), o = Math.atan2(n.to.y - n.from.y, n.to.x - n.from.x) * 180 / Math.PI, s = Math.atan2(r.to.y - r.from.y, r.to.x - r.from.x) * 180 / Math.PI;
|
|
31
|
+
return i === a && n.from.x === r.from.x && n.from.y === r.from.y && o === s;
|
|
32
|
+
}, v = (e) => {
|
|
33
|
+
let t = e || [];
|
|
34
|
+
return t.map((e, n) => ({
|
|
35
|
+
from: e,
|
|
36
|
+
to: t[(n + 1) % t.length]
|
|
37
|
+
}));
|
|
38
|
+
}, y = (e) => (e ||= [], r(e, (e, t) => d(e, t))), b = (e) => (e ||= [], e.filter((e) => !t(e.from, e.to))), x = (t, n) => {
|
|
39
|
+
let { points: r } = t, { points: i } = n, a = v(r), o = v(i), s = y(b(a)), c = y(b(o)), l = e(s, c, d), u = e(c, s, d);
|
|
40
|
+
return (!l || !l.length) && (!u || !u.length);
|
|
41
|
+
}, S = (e, n) => {
|
|
42
|
+
let r = {
|
|
43
|
+
root: c(e.root),
|
|
44
|
+
edge: c(e.edge)
|
|
45
|
+
}, i = {
|
|
46
|
+
root: c(n.root),
|
|
47
|
+
edge: c(n.edge)
|
|
37
48
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, x = (e, n) => {
|
|
47
|
-
if (e = {
|
|
48
|
-
...e,
|
|
49
|
-
root: { ...e.root },
|
|
50
|
-
edge: { ...e.edge }
|
|
51
|
-
}, n = {
|
|
52
|
-
...n,
|
|
53
|
-
root: { ...n.root },
|
|
54
|
-
edge: { ...n.edge }
|
|
55
|
-
}, t(n.edge, e.edge) && t(n.root, e.root)) return !0;
|
|
56
|
-
let r = Math.sqrt((e.edge.x - e.root.x) ** 2 + (e.edge.y - e.root.y) ** 2), i = Math.sqrt((n.edge.x - n.root.x) ** 2 + (n.edge.y - n.root.y) ** 2);
|
|
57
|
-
return t(n.root, e.root) && t(r, i);
|
|
58
|
-
}, S = (e, t) => {
|
|
59
|
-
let n = ({ root: e, edge: t }) => {
|
|
60
|
-
e = { ...e }, t = { ...t };
|
|
61
|
-
let { amplitude: n, freq: r } = i(e, t), a = Math.abs(e.y - t.y) * 2, o = Math.abs(e.x - t.x) * 2, s = t.x, c = t.y;
|
|
62
|
-
for (; s < 0 && o !== 0;) s += o, c = c < e.y ? c + a : c - a;
|
|
63
|
-
for (; s - o > 0 && o !== 0;) s -= o, c = c < e.y ? c + a : c - a;
|
|
49
|
+
if (t(i.edge, r.edge) && t(i.root, r.root)) return !0;
|
|
50
|
+
let a = Math.sqrt((r.edge.x - r.root.x) ** 2 + (r.edge.y - r.root.y) ** 2), o = Math.sqrt((i.edge.x - i.root.x) ** 2 + (i.edge.y - i.root.y) ** 2);
|
|
51
|
+
return t(i.root, r.root) && t(a, o);
|
|
52
|
+
}, C = (e, t) => {
|
|
53
|
+
let n = (e) => {
|
|
54
|
+
let t = c(e.root), n = c(e.edge), { amplitude: r, freq: a } = i(t, n), o = Math.abs(t.y - n.y) * 2, s = Math.abs(t.x - n.x) * 2, l = n.x, u = n.y;
|
|
55
|
+
for (; l < 0 && s !== 0;) l += s, u = u < t.y ? u + o : u - o;
|
|
56
|
+
for (; l - s > 0 && s !== 0;) l -= s, u = u < t.y ? u + o : u - o;
|
|
64
57
|
return {
|
|
65
|
-
amplitude:
|
|
66
|
-
freq:
|
|
67
|
-
min:
|
|
68
|
-
max:
|
|
69
|
-
edgeAboveZeroX:
|
|
70
|
-
edgeAboveZeroY:
|
|
58
|
+
amplitude: h(r),
|
|
59
|
+
freq: h(a),
|
|
60
|
+
min: h(n.y < t.y ? n.y : n.y - o),
|
|
61
|
+
max: h(n.y < t.y ? n.y + o : n.y),
|
|
62
|
+
edgeAboveZeroX: h(l),
|
|
63
|
+
edgeAboveZeroY: h(u)
|
|
71
64
|
};
|
|
72
|
-
}, r = n(e), a = n(t), { amplitude: o, freq: s, min:
|
|
73
|
-
return Math.abs(o) === Math.abs(
|
|
74
|
-
},
|
|
75
|
-
let { edge: n } = e, { edge: r } = t,
|
|
76
|
-
i = { ...i }, o = { ...o };
|
|
77
|
-
let s = n || { ...i }, c = r || { ...o }, l = {
|
|
65
|
+
}, r = n(e), a = n(t), { amplitude: o, freq: s, min: l, max: u, edgeAboveZeroX: d, edgeAboveZeroY: f } = r, { amplitude: p, freq: m, min: g, max: _, edgeAboveZeroX: v, edgeAboveZeroY: y } = a;
|
|
66
|
+
return Math.abs(o) === Math.abs(p) && Math.abs(s) === Math.abs(m) && l === g && u === _ && d === v && f === y;
|
|
67
|
+
}, w = (e, t) => {
|
|
68
|
+
let { edge: n } = e, { edge: r } = t, i = c(e.root), o = c(t.root), s = n || { ...i }, l = r || { ...o }, u = {
|
|
78
69
|
x: i.x - (s.x - i.x),
|
|
79
70
|
y: s.y
|
|
80
|
-
},
|
|
81
|
-
x: o.x - (
|
|
82
|
-
y:
|
|
71
|
+
}, d = {
|
|
72
|
+
x: o.x - (l.x - o.x),
|
|
73
|
+
y: l.y
|
|
83
74
|
};
|
|
84
75
|
if (!n || !r) return !1;
|
|
85
|
-
let { a:
|
|
86
|
-
return
|
|
87
|
-
}, w = (e, n) => {
|
|
88
|
-
let { edge: r } = e, { edge: i } = n, { root: a } = e, { root: o } = n;
|
|
89
|
-
a = { ...a }, o = { ...o };
|
|
90
|
-
let c = r || { ...a }, l = i || { ...o }, u = s(a, c), d = s(o, l);
|
|
91
|
-
return t(o, a) && t(d, u);
|
|
76
|
+
let { a: f, b: p, c: m } = a(i, n, u), { a: h, b: g, c: _ } = a(o, r, d), v = (e) => Math.round(e * 1e4) / 1e4;
|
|
77
|
+
return v(f) === v(h) && v(p) === v(g) && v(m) === v(_);
|
|
92
78
|
}, T = (e, n) => {
|
|
93
|
-
let { edge: r } = e, { edge: i } = n,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
79
|
+
let { edge: r } = e, { edge: i } = n, a = c(e.root), o = c(n.root), l = r || { ...a }, u = i || { ...o }, d = s(a, l), f = s(o, u);
|
|
80
|
+
return t(o, a) && t(f, d);
|
|
81
|
+
}, E = (e, n) => {
|
|
82
|
+
let { edge: r } = e, { edge: i } = n, a = c(e.root), s = c(n.root), l = r || { ...a }, u = i || { ...s }, { a: d, b: f } = o(a, l), { a: p, b: m } = o(s, u);
|
|
83
|
+
return t(p, d) && t(m, f);
|
|
84
|
+
}, D = {
|
|
85
|
+
circle: (e, t) => S(e, t),
|
|
86
|
+
line: (e, t) => g(e, t),
|
|
87
|
+
parabola: (e, t) => w(e, t),
|
|
88
|
+
absolute: (e, t) => T(e, t),
|
|
89
|
+
exponential: (e, t) => E(e, t),
|
|
90
|
+
point: (e, t) => l(e, t),
|
|
91
|
+
polygon: (e, t) => x(e, t),
|
|
92
|
+
ray: (e, t) => _(e, t),
|
|
93
|
+
segment: (e, t) => d(e, t),
|
|
94
|
+
sine: (e, t) => C(e, t),
|
|
95
|
+
vector: (e, t) => f(e, t)
|
|
109
96
|
};
|
|
110
97
|
//#endregion
|
|
111
|
-
export {
|
|
98
|
+
export { v as constructSegmentsFromPoints, T as equalAbsolute, S as equalCircle, E as equalExponential, g as equalLine, D as equalMarks, w as equalParabola, l as equalPoint, u as equalPointWithLabel, x as equalPolygon, _ as equalRay, d as equalSegment, C as equalSine, f as equalVector, y as removeDuplicateSegments, b as removeInvalidSegments, p as sortedAnswers };
|
package/dist/index.d.ts
CHANGED