@khanacademy/perseus 79.2.0 → 80.0.0

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 (42) hide show
  1. package/dist/es/index.css +1 -1
  2. package/dist/es/index.css.map +1 -1
  3. package/dist/es/index.js +89 -49
  4. package/dist/es/index.js.map +1 -1
  5. package/dist/index.css +1 -1
  6. package/dist/index.css.map +1 -1
  7. package/dist/index.js +88 -48
  8. package/dist/index.js.map +1 -1
  9. package/dist/util/css-zoom-utils.d.ts +20 -0
  10. package/dist/widgets/interactive-graphs/backgrounds/graph-border.d.ts +17 -0
  11. package/dist/widgets/interactive-graphs/graphs/absolute-value.d.ts +0 -10
  12. package/dist/widgets/interactive-graphs/graphs/circle.d.ts +0 -1
  13. package/dist/widgets/interactive-graphs/graphs/linear-system.d.ts +0 -1
  14. package/dist/widgets/interactive-graphs/graphs/linear.d.ts +0 -1
  15. package/dist/widgets/interactive-graphs/graphs/point.d.ts +0 -5
  16. package/dist/widgets/interactive-graphs/graphs/quadratic.d.ts +0 -12
  17. package/dist/widgets/interactive-graphs/graphs/ray.d.ts +0 -1
  18. package/dist/widgets/interactive-graphs/graphs/segment.d.ts +0 -1
  19. package/dist/widgets/interactive-graphs/graphs/strings/absolute-value.d.ts +19 -0
  20. package/dist/widgets/interactive-graphs/graphs/strings/angle.d.ts +19 -0
  21. package/dist/widgets/interactive-graphs/graphs/strings/announcement.d.ts +3 -0
  22. package/dist/widgets/interactive-graphs/graphs/strings/circle.d.ts +15 -0
  23. package/dist/widgets/interactive-graphs/graphs/strings/coord-quadrant.d.ts +7 -0
  24. package/dist/widgets/interactive-graphs/graphs/strings/custom-point-label.d.ts +22 -0
  25. package/dist/widgets/interactive-graphs/graphs/strings/exponential.d.ts +20 -0
  26. package/dist/widgets/interactive-graphs/graphs/strings/format-number.d.ts +2 -0
  27. package/dist/widgets/interactive-graphs/graphs/strings/linear-system.d.ts +11 -0
  28. package/dist/widgets/interactive-graphs/graphs/strings/linear.d.ts +12 -0
  29. package/dist/widgets/interactive-graphs/graphs/strings/logarithm.d.ts +20 -0
  30. package/dist/widgets/interactive-graphs/graphs/strings/point.d.ts +6 -0
  31. package/dist/widgets/interactive-graphs/graphs/strings/polygon.d.ts +13 -0
  32. package/dist/widgets/interactive-graphs/graphs/strings/quadratic.d.ts +21 -0
  33. package/dist/widgets/interactive-graphs/graphs/strings/ray.d.ts +19 -0
  34. package/dist/widgets/interactive-graphs/graphs/strings/segment.d.ts +12 -0
  35. package/dist/widgets/interactive-graphs/graphs/strings/sinusoid.d.ts +19 -0
  36. package/dist/widgets/interactive-graphs/graphs/strings/tangent.d.ts +18 -0
  37. package/dist/widgets/interactive-graphs/graphs/strings/vector.d.ts +18 -0
  38. package/dist/widgets/interactive-graphs/graphs/utils.d.ts +13 -1
  39. package/dist/widgets/interactive-graphs/graphs/vector.d.ts +0 -1
  40. package/dist/widgets/interactive-graphs/utils.d.ts +0 -18
  41. package/package.json +7 -7
  42. package/dist/widgets/interactive-graphs/graphs/screenreader-text.d.ts +0 -13
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Gets the effective CSS zoom factor applied to an element or any of its ancestors.
3
+ * This is used to compensate for the mobile font scaling zoom applied to the body
4
+ * or exercise content via the fontScale query parameter.
5
+ *
6
+ * On mobile, the parent application may apply CSS zoom to accommodate device font
7
+ * size settings. This zoom affects coordinate calculations for click/touch events,
8
+ * as both clientX/clientY and getBoundingClientRect() return zoomed values, but
9
+ * the SVG coordinate system expects unzoomed pixel values. It also shrinks the
10
+ * widths reported by offsetWidth for viewport-constrained containers, which
11
+ * fit-to-width logic (e.g. Zoomable) must account for.
12
+ *
13
+ * Note: We calculate the cumulative zoom by traversing the DOM tree rather than
14
+ * targeting specific elements to avoid coupling Perseus to parent application
15
+ * implementation details (e.g., specific class names or DOM hierarchy).
16
+ *
17
+ * @param element - The DOM element to check for CSS zoom
18
+ * @returns The cumulative zoom factor (e.g., 1.5 for 150% zoom, 1.0 for no zoom)
19
+ */
20
+ export declare function getCSSZoomFactor(element: Element): number;
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import type { GraphRange, MarkingsType } from "@khanacademy/perseus-core";
3
+ interface Props {
4
+ range: GraphRange;
5
+ width: number;
6
+ height: number;
7
+ markings: MarkingsType;
8
+ }
9
+ /**
10
+ * Draws a 1px border at the exact graph bounds to match the design.
11
+ *
12
+ * A dedicated rect is needed because the old frame (the outermost grid line)
13
+ * is clipped to the bounds, losing the outer half of its stroke (~0.5px). Kept
14
+ * on top of the grid so the full stroke renders crisply.
15
+ */
16
+ export declare const GraphBorder: ({ range, width, height, markings }: Props) => React.JSX.Element | null;
17
+ export {};
@@ -3,16 +3,6 @@ import { type I18nContextType } from "../../../components/i18n-context";
3
3
  import type { AbsoluteValueGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
4
4
  import type { Coord } from "@khanacademy/perseus-core";
5
5
  export declare function renderAbsoluteValueGraph(state: AbsoluteValueGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
6
- export type AbsoluteValueCoefficients = {
7
- m: number;
8
- h: number;
9
- v: number;
10
- };
11
- /**
12
- * Compute the coefficients [m, h, v] for f(x) = m * |x - h| + v from two
13
- * control points: p1 (vertex) and p2 (a point on one arm).
14
- */
15
- export declare function getAbsoluteValueCoefficients(coords: ReadonlyArray<Coord>): AbsoluteValueCoefficients;
16
6
  /**
17
7
  * Keyboard constraint for absolute value control points.
18
8
  * Skips any horizontal position where both points would share the same x.
@@ -11,5 +11,4 @@ export declare const getCircleKeyboardConstraint: (center: vec.Vector2, radiusPo
11
11
  left: vec.Vector2;
12
12
  right: vec.Vector2;
13
13
  };
14
- export declare function describeCircleGraph(state: CircleGraphState, i18n: I18nContextType): Record<string, string>;
15
14
  export {};
@@ -1,4 +1,3 @@
1
1
  import type { I18nContextType } from "../../../components/i18n-context";
2
2
  import type { LinearSystemGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
3
3
  export declare function renderLinearSystemGraph(state: LinearSystemGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
4
- export declare function getLinearSystemGraphDescription(state: LinearSystemGraphState, i18n: I18nContextType): string;
@@ -1,4 +1,3 @@
1
1
  import type { I18nContextType } from "../../../components/i18n-context";
2
2
  import type { LinearGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
3
3
  export declare function renderLinearGraph(state: LinearGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
4
- export declare function describeLinearGraph(state: LinearGraphState, i18n: I18nContextType): Record<string, string>;
@@ -1,8 +1,3 @@
1
1
  import type { I18nContextType } from "../../../components/i18n-context";
2
- import type { PerseusStrings } from "../../../strings";
3
2
  import type { PointGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
4
3
  export declare function renderPointGraph(state: PointGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
5
- export declare function getPointGraphDescription(state: PointGraphState, i18n: {
6
- strings: PerseusStrings;
7
- locale: string;
8
- }): string;
@@ -2,22 +2,10 @@ import { vec } from "mafs";
2
2
  import type { I18nContextType } from "../../../components/i18n-context";
3
3
  import type { Coord } from "../../../interactive2/types";
4
4
  import type { QuadraticGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
5
- import type { QuadraticCoefficient, QuadraticCoords } from "@khanacademy/kmath";
6
5
  export declare function renderQuadraticGraph(state: QuadraticGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
7
- export declare const getQuadraticCoefficients: (coords: QuadraticCoords) => QuadraticCoefficient | undefined;
8
- type QuadraticGraphDescriptionStrings = {
9
- srQuadraticGraph: string;
10
- srQuadraticDirection?: string;
11
- srQuadraticVertex?: string;
12
- srQuadraticXIntercepts?: string;
13
- srQuadraticYIntercept: string;
14
- srQuadraticInteractiveElements: string;
15
- };
16
- export declare function describeQuadraticGraph(state: QuadraticGraphState, i18n: I18nContextType): QuadraticGraphDescriptionStrings;
17
6
  export declare const getQuadraticKeyboardConstraint: (coords: ReadonlyArray<Coord>, snapStep: vec.Vector2, pointMoved: number) => {
18
7
  up: vec.Vector2;
19
8
  down: vec.Vector2;
20
9
  left: vec.Vector2;
21
10
  right: vec.Vector2;
22
11
  };
23
- export {};
@@ -1,4 +1,3 @@
1
1
  import type { I18nContextType } from "../../../components/i18n-context";
2
2
  import type { Dispatch, InteractiveGraphElementSuite, RayGraphState } from "../types";
3
3
  export declare function renderRayGraph(state: RayGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
4
- export declare function describeRayGraph(state: RayGraphState, i18n: I18nContextType): Record<string, string>;
@@ -1,4 +1,3 @@
1
1
  import type { I18nContextType } from "../../../components/i18n-context";
2
2
  import type { Dispatch, InteractiveGraphElementSuite, SegmentGraphState } from "../types";
3
3
  export declare function renderSegmentGraph(state: SegmentGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
4
- export declare function getSegmentGraphDescription(state: SegmentGraphState, i18n: I18nContextType): string;
@@ -0,0 +1,19 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { AbsoluteValueGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srAbsoluteValuePointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ slope: number;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ type AbsoluteValueGraphDescriptionStrings = {
12
+ srAbsoluteValueGraph: string;
13
+ srAbsoluteValueVertexPoint: string;
14
+ srAbsoluteValueSecondPoint: string;
15
+ srAbsoluteValueDescription: string;
16
+ srAbsoluteValueSlope: string;
17
+ };
18
+ export declare function describeAbsoluteValueGraph(state: AbsoluteValueGraphState, i18n: I18nContextType): AbsoluteValueGraphDescriptionStrings;
19
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { AngleGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srAnglePointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ angleMeasure: number;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ type AngleGraphDescriptionStrings = {
12
+ srAngleGraphAriaLabel: string;
13
+ srAngleGraphAriaDescription: string;
14
+ srAngleStartingSide: string;
15
+ srAngleEndingSide: string;
16
+ srAngleVertex: string;
17
+ };
18
+ export declare function describeAngleGraph(state: AngleGraphState, i18n: I18nContextType): AngleGraphDescriptionStrings;
19
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { InteractiveGraphStateAnnouncement } from "../../types";
2
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
3
+ export declare function getAnnouncementText(state: InteractiveGraphStateAnnouncement, strings: PerseusStrings, locale: string): string;
@@ -0,0 +1,15 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { CircleGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srCircleRadiusPointLabel(x: number, y: number, centerX: number, strings: PerseusStrings, locale: string): string;
5
+ export declare function srCircleCenterLabel(x: number, y: number, strings: PerseusStrings, locale: string): string;
6
+ type CircleGraphDescriptionStrings = {
7
+ srCircleGraph: string;
8
+ srCircleShape: string;
9
+ srCircleRadiusPoint: string;
10
+ srCircleRadius: string;
11
+ srCircleOuterPoints: string;
12
+ srCircleInteractiveElement: string;
13
+ };
14
+ export declare function describeCircleGraph(state: CircleGraphState, i18n: I18nContextType): CircleGraphDescriptionStrings;
15
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
2
+ import type { Coord } from "@khanacademy/perseus-core";
3
+ type GraphLocations = "origin" | "x-axis" | "y-axis" | 1 | 2 | 3 | 4;
4
+ export declare function getCoordQuadrant(coord: Coord): GraphLocations;
5
+ export declare function getQuadraticVertexString(vertex: Coord, strings: PerseusStrings): string;
6
+ export declare function getQuadraticPointString(pointNumber: any, coord: Coord, strings: PerseusStrings, locale: string): string;
7
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
2
+ /**
3
+ * Resolves the x/y formatting and the "custom author label overrides the
4
+ * semantic label" fallback shared by every live point builder and by
5
+ * build-point-aria-label.
6
+ *
7
+ * Returns the locale-formatted `x`/`y` strings, plus a `customLabel`: the
8
+ * `srPointAtCoordinates` string when the author set a custom (string) label,
9
+ * otherwise `undefined` so the caller applies its own semantic label.
10
+ *
11
+ * TODO(LEMS-4206): Once we update the translation keys to allow custom labels
12
+ * we can remove the customLabel fallback in favor of the per-graph logic.
13
+ */
14
+ export declare function withCustomPointLabel(state: {
15
+ pointLabel: string | number;
16
+ x: number;
17
+ y: number;
18
+ }, strings: PerseusStrings, locale: string): {
19
+ x: string;
20
+ y: string;
21
+ customLabel: string | undefined;
22
+ };
@@ -0,0 +1,20 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { ExponentialGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srExponentialPointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ hasCurve: boolean;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ type ExponentialGraphDescriptionStrings = {
12
+ srExponentialGraph: string;
13
+ srExponentialDescription: string;
14
+ srExponentialAsymptote: string;
15
+ srExponentialPoint1: string;
16
+ srExponentialPoint2: string;
17
+ srExponentialInteractiveElements: string;
18
+ };
19
+ export declare function describeExponentialGraph(state: ExponentialGraphState, i18n: I18nContextType): ExponentialGraphDescriptionStrings;
20
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function srFormatNumber(a: number, locale: string, maximumFractionDigits?: number): string;
2
+ export declare function getPiMultiple(a: number): string | null;
@@ -0,0 +1,11 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { LinearSystemGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srLinearSystemPointLabel(state: {
5
+ lineIndex: number;
6
+ pointIndex: number;
7
+ pointLabel: string | number;
8
+ x: number;
9
+ y: number;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ export declare function describeLinearSystemGraph(state: LinearSystemGraphState, i18n: I18nContextType): string;
@@ -0,0 +1,12 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { LinearGraphState } from "../../types";
3
+ type LinearGraphDescriptionStrings = {
4
+ srLinearGraph: string;
5
+ srLinearGraphPoints: string;
6
+ srLinearGrabHandle: string;
7
+ slopeString: string;
8
+ interceptString: string;
9
+ srLinearInteractiveElement: string;
10
+ };
11
+ export declare function describeLinearGraph(state: LinearGraphState, i18n: I18nContextType): LinearGraphDescriptionStrings;
12
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { LogarithmGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srLogarithmPointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ hasCurve: boolean;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ type LogarithmGraphDescriptionStrings = {
12
+ srLogarithmGraph: string;
13
+ srLogarithmDescription: string;
14
+ srLogarithmAsymptote: string;
15
+ srLogarithmPoint1: string;
16
+ srLogarithmPoint2: string;
17
+ srLogarithmInteractiveElements: string;
18
+ };
19
+ export declare function describeLogarithmGraph(state: LogarithmGraphState, i18n: I18nContextType): LogarithmGraphDescriptionStrings;
20
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { PointGraphState } from "../../types";
2
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
3
+ export declare function describePointGraph(state: PointGraphState, i18n: {
4
+ strings: PerseusStrings;
5
+ locale: string;
6
+ }): string;
@@ -0,0 +1,13 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { InteractiveGraphProps, PolygonGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srPolygonLabel(coords: ReadonlyArray<readonly [number, number]>, pointLabels: ReadonlyArray<string> | undefined, strings: PerseusStrings, locale: string): string;
5
+ type PolygonGraphDescriptionStrings = {
6
+ srPolygonGraph: string;
7
+ srPolygonGraphPointsNum: string;
8
+ srPolygonGraphPoints?: string;
9
+ srPolygonElementsNum: string;
10
+ srPolygonInteractiveElements: string | null;
11
+ };
12
+ export declare function describePolygonGraph(state: PolygonGraphState, i18n: I18nContextType, markings: InteractiveGraphProps["markings"]): PolygonGraphDescriptionStrings;
13
+ export {};
@@ -0,0 +1,21 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { QuadraticGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ import type { Coord } from "@khanacademy/perseus-core";
5
+ export declare function srQuadraticPointLabel(state: {
6
+ pointIndex: number;
7
+ pointLabel: string | number;
8
+ x: number;
9
+ y: number;
10
+ vertex?: Coord;
11
+ }, strings: PerseusStrings, locale: string): string;
12
+ type QuadraticGraphDescriptionStrings = {
13
+ srQuadraticGraph: string;
14
+ srQuadraticDirection?: string;
15
+ srQuadraticVertex?: string;
16
+ srQuadraticXIntercepts?: string;
17
+ srQuadraticYIntercept: string;
18
+ srQuadraticInteractiveElements: string;
19
+ };
20
+ export declare function describeQuadraticGraph(state: QuadraticGraphState, i18n: I18nContextType): QuadraticGraphDescriptionStrings;
21
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { RayGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srRayPointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ }, strings: PerseusStrings, locale: string): string;
10
+ type RayGraphDescriptionStrings = {
11
+ srRayGraph: string;
12
+ srRayPoints: string;
13
+ srRayEndpoint: string;
14
+ srRayTerminalPoint: string;
15
+ srRayGrabHandle: string;
16
+ srRayInteractiveElement: string;
17
+ };
18
+ export declare function describeRayGraph(state: RayGraphState, i18n: I18nContextType): RayGraphDescriptionStrings;
19
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { SegmentGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srSegmentPointLabel(state: {
5
+ segmentIndex: number;
6
+ pointIndex: number;
7
+ pointLabel: string | number;
8
+ totalSegments: number;
9
+ x: number;
10
+ y: number;
11
+ }, strings: PerseusStrings, locale: string): string;
12
+ export declare function describeSegmentGraph(state: SegmentGraphState, i18n: I18nContextType): string;
@@ -0,0 +1,19 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { SinusoidGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srSinusoidPointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ otherY: number;
10
+ }, strings: PerseusStrings, locale: string): string;
11
+ type SinusoidGraphDescriptionStrings = {
12
+ srSinusoidGraph: string;
13
+ srSinusoidDescription: string;
14
+ srSinusoidRootPoint: string;
15
+ srSinusoidPeakPoint: string;
16
+ srSinusoidInteractiveElements: string;
17
+ };
18
+ export declare function describeSinusoidGraph(state: SinusoidGraphState, i18n: I18nContextType): SinusoidGraphDescriptionStrings;
19
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { TangentGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srTangentPointLabel(state: {
5
+ pointIndex: number;
6
+ pointLabel: string | number;
7
+ x: number;
8
+ y: number;
9
+ }, strings: PerseusStrings, locale: string): string;
10
+ type TangentGraphDescriptionStrings = {
11
+ srTangentGraph: string;
12
+ srTangentDescription: string;
13
+ srTangentInflectionPoint: string;
14
+ srTangentSecondPoint: string;
15
+ srTangentInteractiveElements: string;
16
+ };
17
+ export declare function describeTangentGraph(state: TangentGraphState, i18n: I18nContextType): TangentGraphDescriptionStrings;
18
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { I18nContextType } from "../../../../components/i18n-context";
2
+ import type { VectorGraphState } from "../../types";
3
+ import type { PerseusStrings } from "@khanacademy/perseus/strings";
4
+ export declare function srVectorPointLabel(state: {
5
+ pointIndex: number;
6
+ x: number;
7
+ y: number;
8
+ }, strings: PerseusStrings, locale: string): string;
9
+ type VectorGraphDescriptionStrings = {
10
+ srVectorGraph: string;
11
+ srVectorPoints: string;
12
+ srVectorDescription: string;
13
+ srVectorHeadPoint: string;
14
+ srVectorGrabHandle: string;
15
+ srVectorInteractiveElement: string;
16
+ };
17
+ export declare function describeVectorGraph(state: VectorGraphState, i18n: I18nContextType): VectorGraphDescriptionStrings;
18
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { vec } from "mafs";
2
2
  import type { PerseusStrings } from "../../../strings";
3
3
  import type { PairOfPoints } from "../types";
4
- import type { QuadraticCoefficient } from "@khanacademy/kmath";
4
+ import type { QuadraticCoefficient, QuadraticCoords } from "@khanacademy/kmath";
5
5
  import type { Coord } from "@khanacademy/perseus-core";
6
6
  import type { Interval } from "mafs";
7
7
  /**
@@ -75,3 +75,15 @@ export declare function getAsymptoteHandleCoord(orientation: "horizontal" | "ver
75
75
  * a valid position (up to 3 attempts).
76
76
  */
77
77
  export declare function skipAsymptoteKeyboardOverPoint(proposed: vec.Vector2, currentAsymptote: number, coords: ReadonlyArray<Coord>, handleCoord: vec.Vector2, snapStep: vec.Vector2, orientation: "horizontal" | "vertical"): vec.Vector2;
78
+ export declare const getQuadraticCoefficients: (coords: QuadraticCoords) => QuadraticCoefficient | undefined;
79
+ export declare function getLengthOfSegment(segment: PairOfPoints): number;
80
+ export type AbsoluteValueCoefficients = {
81
+ m: number;
82
+ h: number;
83
+ v: number;
84
+ };
85
+ /**
86
+ * Compute the coefficients [m, h, v] for f(x) = m * |x - h| + v from two
87
+ * control points: p1 (vertex) and p2 (a point on one arm).
88
+ */
89
+ export declare function getAbsoluteValueCoefficients(coords: ReadonlyArray<Coord>): AbsoluteValueCoefficients;
@@ -8,4 +8,3 @@ export declare const getVectorTipKeyboardConstraint: (tail: vec.Vector2, tip: ve
8
8
  left: vec.Vector2;
9
9
  right: vec.Vector2;
10
10
  };
11
- export declare function describeVectorGraph(state: VectorGraphState, i18n: I18nContextType): Record<string, string>;
@@ -42,21 +42,3 @@ export declare const calculateNestedSVGCoords: (range: vec.Vector2[], width: num
42
42
  viewboxX: number;
43
43
  viewboxY: number;
44
44
  };
45
- /**
46
- * Gets the effective CSS zoom factor applied to an element or any of its ancestors.
47
- * This is used to compensate for the mobile font scaling zoom applied to the body
48
- * or exercise content via the fontScale query parameter.
49
- *
50
- * On mobile, the parent application may apply CSS zoom to accommodate device font
51
- * size settings. This zoom affects coordinate calculations for click/touch events,
52
- * as both clientX/clientY and getBoundingClientRect() return zoomed values, but
53
- * the SVG coordinate system expects unzoomed pixel values.
54
- *
55
- * Note: We calculate the cumulative zoom by traversing the DOM tree rather than
56
- * targeting specific elements to avoid coupling Perseus to parent application
57
- * implementation details (e.g., specific class names or DOM hierarchy).
58
- *
59
- * @param element - The DOM element to check for CSS zoom
60
- * @returns The cumulative zoom factor (e.g., 1.5 for 150% zoom, 1.0 for no zoom)
61
- */
62
- export declare function getCSSZoomFactor(element: Element): number;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "79.2.0",
6
+ "version": "80.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -43,12 +43,12 @@
43
43
  "tiny-invariant": "1.3.1",
44
44
  "uuid": "^10.0.0",
45
45
  "@khanacademy/kas": "2.2.3",
46
- "@khanacademy/keypad-context": "3.2.72",
47
- "@khanacademy/kmath": "2.4.31",
48
- "@khanacademy/math-input": "26.5.0",
49
- "@khanacademy/perseus-core": "30.1.1",
50
- "@khanacademy/perseus-linter": "5.1.12",
51
- "@khanacademy/perseus-score": "8.12.4",
46
+ "@khanacademy/keypad-context": "3.2.73",
47
+ "@khanacademy/kmath": "2.4.32",
48
+ "@khanacademy/math-input": "26.6.0",
49
+ "@khanacademy/perseus-core": "31.0.0",
50
+ "@khanacademy/perseus-linter": "5.1.13",
51
+ "@khanacademy/perseus-score": "8.12.5",
52
52
  "@khanacademy/perseus-utils": "2.1.5",
53
53
  "@khanacademy/pure-markdown": "2.3.0",
54
54
  "@khanacademy/simple-markdown": "2.2.3"
@@ -1,13 +0,0 @@
1
- import type { InteractiveGraphStateAnnouncement } from "../types";
2
- import type { PerseusStrings } from "@khanacademy/perseus/strings";
3
- import type { Coord } from "@khanacademy/perseus-core";
4
- export declare function getAnnouncementText(state: InteractiveGraphStateAnnouncement, strings: PerseusStrings, locale: string): string;
5
- export declare function srCircleRadiusPointLabel(x: number, y: number, centerX: number, strings: PerseusStrings, locale: string): string;
6
- export declare function srCircleCenterLabel(x: number, y: number, strings: PerseusStrings, locale: string): string;
7
- type GraphLocations = "origin" | "x-axis" | "y-axis" | 1 | 2 | 3 | 4;
8
- export declare function getCoordQuadrant(coord: Coord): GraphLocations;
9
- export declare function getQuadraticVertexString(vertex: Coord, strings: PerseusStrings): string;
10
- export declare function getQuadraticPointString(pointNumber: any, coord: Coord, strings: PerseusStrings, locale: string): string;
11
- export declare function srFormatNumber(a: number, locale: string, maximumFractionDigits?: number): string;
12
- export declare function getPiMultiple(a: number): string | null;
13
- export {};