Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@khanacademy/perseus-core

Package Overview
Dependencies
Maintainers
0
Versions
336
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@khanacademy/perseus-core - npm Package Compare versions

Comparing version 0.0.0-PR2040-20241219191743 to 0.0.0-PR2077-20250110232805

dist/data-schema.d.ts

229

dist/es/index.js

@@ -45,3 +45,3 @@ /**

const libName = "@khanacademy/perseus-core";
const libVersion = "3.0.4";
const libVersion = "3.0.5";
addLibraryVersionToPerseusDebug(libName, libVersion);

@@ -101,3 +101,228 @@

export { Errors, PerseusError, addLibraryVersionToPerseusDebug, libVersion };
/**
* The Perseus "data schema" file.
*
* This file, and the types in it, represents the "data schema" that Perseus
* uses. The @khanacademy/perseus-editor package edits and produces objects
* that conform to the types in this file. Similarly, the top-level renderers
* in @khanacademy/perseus, consume objects that conform to these types.
*
* WARNING: This file should not import any types from elsewhere so that it is
* easy to reason about changes that alter the Perseus schema. This helps
* ensure that it is not changed accidentally when upgrading a dependant
* package or other part of Perseus code. Note that TypeScript does type
* checking via something called "structural typing". This means that as long
* as the shape of a type matches, the name it goes by doesn't matter. As a
* result, a `Coord` type that looks like this `[x: number, y: number]` is
* _identical_, in TypeScript's eyes, to this `Vector2` type `[x: number, y:
* number]`. Also, with tuples, the labels for each entry is ignored, so `[x:
* number, y: number]` is compatible with `[min: number, max: number]`. The
* labels are for humans, not TypeScript. :)
*
* If you make changes to types in this file, be very sure that:
*
* a) the changes are backwards compatible. If they are not, old data from
* previous versions of the "schema" could become unrenderable, or worse,
* introduce hard-to-diagnose bugs.
* b) the parsing code (`util/parse-perseus-json/`) is updated to handle
* the new format _as well as_ the old format.
*/
// TODO(FEI-4010): Remove `Perseus` prefix for all types here
// Same name as Mafs
/**
* Our core set of Perseus widgets.
*
* This interface is the basis for "registering" all Perseus widget types.
* There should be one key/value pair for each supported widget. If you create
* a new widget, an entry should be added to this interface. Note that this
* only registers the widget options type, you'll also need to register the
* widget so that it's available at runtime (@see
* {@link file://./widgets.ts#registerWidget}).
*
* Importantly, the key should be the name that is used in widget IDs. For most
* widgets that is the same as the widget option's `type` field. In cases where
* a widget has been deprecated and replaced with the deprecated-standin
* widget, it should be the original widget type!
*
* If you define the widget outside of this package, you can still add the new
* widget to this interface by writing the following in that package that
* contains the widget. TypeScript will merge that definition of the
* `PerseusWidgets` with the one defined below.
*
* ```typescript
* declare module "@khanacademy/perseus" {
* interface PerseusWidgetTypes {
* // A new widget
* "new-awesomeness": MyAwesomeNewWidget;
*
* // A deprecated widget
* "super-old-widget": DeprecatedStandinWidget;
* }
* }
*
* // The new widget's options definition
* type MyAwesomeNewWidget = WidgetOptions<'new-awesomeness', MyAwesomeNewWidgetOptions>;
*
* // The deprecated widget's options definition
* type SuperOldWidget = WidgetOptions<'super-old-widget', object>;
* ```
*
* This interface can be extended through the magic of TypeScript "Declaration
* merging". Specifically, we augment this module and extend this interface.
*
* @see {@link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation}
*/
/**
* A map of widget IDs to widget options. This is most often used as the type
* for a set of widgets defined in a `PerseusItem` but can also be useful to
* represent a function parameter where only `widgets` from a `PerseusItem` are
* needed. Today Widget IDs are made up of the widget type and an incrementing
* integer (eg. `interactive-graph 1` or `radio 3`). It is suggested to avoid
* reading/parsing the widget id to derive any information from it, except in
* the case of this map.
*
* @see {@link PerseusWidgetTypes} additional widgets can be added to this map type
* by augmenting the PerseusWidgetTypes with new widget types!
*/
/**
* A "PerseusItem" is a classic Perseus item. It is rendered by the
* `ServerItemRenderer` and the layout is pre-set.
*
* To render more complex Perseus items, see the `Item` type in the multi item
* area.
*/
/**
* A "PerseusArticle" is an item that is meant to be rendered as an article.
* This item is never scored and is rendered by the `ArticleRenderer`.
*/
const ItemExtras = [
// The user might benefit from using a Scientific Calculator. Provided on Khan Academy when true
"calculator",
// The user might benefit from using a statistics Chi Squared Table like https://people.richland.edu/james/lecture/m170/tbl-chi.html
"chi2Table",
// The user might benefit from a monthly payments calculator. Provided on Khan Academy when true
"financialCalculatorMonthlyPayment",
// The user might benefit from a total amount calculator. Provided on Khan Academy when true
"financialCalculatorTotalAmount",
// The user might benefit from a time to pay off calculator. Provided on Khan Academy when true
"financialCalculatorTimeToPayOff",
// The user might benefit from using a Periodic Table of Elements. Provided on Khan Academy when true
"periodicTable",
// The user might benefit from using a Periodic Table of Elements with key. Provided on Khan Academy when true
"periodicTableWithKey",
// The user might benefit from using a statistics T Table like https://www.statisticshowto.com/tables/t-distribution-table/
"tTable",
// The user might benefit from using a statistics Z Table like https://www.ztable.net/
"zTable"];
/**
* The type representing the common structure of all widget's options. The
* `Options` generic type represents the widget-specific option data.
*/
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
//prettier-ignore
/**
* A background image applied to various widgets.
*/
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
// 2D range: xMin, xMax, yMin, yMax
const lockedFigureColorNames = ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
const lockedFigureColors = {
blue: "#3D7586",
green: "#447A53",
grayH: "#3B3D45",
purple: "#594094",
pink: "#B25071",
red: "#D92916",
orange: "#946700"
};
const lockedFigureFillStyles = {
none: 0,
white: 1,
translucent: 0.4,
solid: 1
};
// Not associated with a specific figure
const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
export { Errors, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, addLibraryVersionToPerseusDebug, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, plotterPlotTypes };
//# sourceMappingURL=index.js.map

@@ -8,1 +8,2 @@ export type { PerseusAnalyticsEvent, AnalyticsEventHandlerFn } from "./analytics";

export { PerseusError } from "./error/perseus-error";
export * from "./data-schema";

@@ -48,3 +48,3 @@ 'use strict';

const libName = "@khanacademy/perseus-core";
const libVersion = "3.0.4";
const libVersion = "3.0.5";
addLibraryVersionToPerseusDebug(libName, libVersion);

@@ -104,6 +104,237 @@

/**
* The Perseus "data schema" file.
*
* This file, and the types in it, represents the "data schema" that Perseus
* uses. The @khanacademy/perseus-editor package edits and produces objects
* that conform to the types in this file. Similarly, the top-level renderers
* in @khanacademy/perseus, consume objects that conform to these types.
*
* WARNING: This file should not import any types from elsewhere so that it is
* easy to reason about changes that alter the Perseus schema. This helps
* ensure that it is not changed accidentally when upgrading a dependant
* package or other part of Perseus code. Note that TypeScript does type
* checking via something called "structural typing". This means that as long
* as the shape of a type matches, the name it goes by doesn't matter. As a
* result, a `Coord` type that looks like this `[x: number, y: number]` is
* _identical_, in TypeScript's eyes, to this `Vector2` type `[x: number, y:
* number]`. Also, with tuples, the labels for each entry is ignored, so `[x:
* number, y: number]` is compatible with `[min: number, max: number]`. The
* labels are for humans, not TypeScript. :)
*
* If you make changes to types in this file, be very sure that:
*
* a) the changes are backwards compatible. If they are not, old data from
* previous versions of the "schema" could become unrenderable, or worse,
* introduce hard-to-diagnose bugs.
* b) the parsing code (`util/parse-perseus-json/`) is updated to handle
* the new format _as well as_ the old format.
*/
// TODO(FEI-4010): Remove `Perseus` prefix for all types here
// Same name as Mafs
/**
* Our core set of Perseus widgets.
*
* This interface is the basis for "registering" all Perseus widget types.
* There should be one key/value pair for each supported widget. If you create
* a new widget, an entry should be added to this interface. Note that this
* only registers the widget options type, you'll also need to register the
* widget so that it's available at runtime (@see
* {@link file://./widgets.ts#registerWidget}).
*
* Importantly, the key should be the name that is used in widget IDs. For most
* widgets that is the same as the widget option's `type` field. In cases where
* a widget has been deprecated and replaced with the deprecated-standin
* widget, it should be the original widget type!
*
* If you define the widget outside of this package, you can still add the new
* widget to this interface by writing the following in that package that
* contains the widget. TypeScript will merge that definition of the
* `PerseusWidgets` with the one defined below.
*
* ```typescript
* declare module "@khanacademy/perseus" {
* interface PerseusWidgetTypes {
* // A new widget
* "new-awesomeness": MyAwesomeNewWidget;
*
* // A deprecated widget
* "super-old-widget": DeprecatedStandinWidget;
* }
* }
*
* // The new widget's options definition
* type MyAwesomeNewWidget = WidgetOptions<'new-awesomeness', MyAwesomeNewWidgetOptions>;
*
* // The deprecated widget's options definition
* type SuperOldWidget = WidgetOptions<'super-old-widget', object>;
* ```
*
* This interface can be extended through the magic of TypeScript "Declaration
* merging". Specifically, we augment this module and extend this interface.
*
* @see {@link https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation}
*/
/**
* A map of widget IDs to widget options. This is most often used as the type
* for a set of widgets defined in a `PerseusItem` but can also be useful to
* represent a function parameter where only `widgets` from a `PerseusItem` are
* needed. Today Widget IDs are made up of the widget type and an incrementing
* integer (eg. `interactive-graph 1` or `radio 3`). It is suggested to avoid
* reading/parsing the widget id to derive any information from it, except in
* the case of this map.
*
* @see {@link PerseusWidgetTypes} additional widgets can be added to this map type
* by augmenting the PerseusWidgetTypes with new widget types!
*/
/**
* A "PerseusItem" is a classic Perseus item. It is rendered by the
* `ServerItemRenderer` and the layout is pre-set.
*
* To render more complex Perseus items, see the `Item` type in the multi item
* area.
*/
/**
* A "PerseusArticle" is an item that is meant to be rendered as an article.
* This item is never scored and is rendered by the `ArticleRenderer`.
*/
const ItemExtras = [
// The user might benefit from using a Scientific Calculator. Provided on Khan Academy when true
"calculator",
// The user might benefit from using a statistics Chi Squared Table like https://people.richland.edu/james/lecture/m170/tbl-chi.html
"chi2Table",
// The user might benefit from a monthly payments calculator. Provided on Khan Academy when true
"financialCalculatorMonthlyPayment",
// The user might benefit from a total amount calculator. Provided on Khan Academy when true
"financialCalculatorTotalAmount",
// The user might benefit from a time to pay off calculator. Provided on Khan Academy when true
"financialCalculatorTimeToPayOff",
// The user might benefit from using a Periodic Table of Elements. Provided on Khan Academy when true
"periodicTable",
// The user might benefit from using a Periodic Table of Elements with key. Provided on Khan Academy when true
"periodicTableWithKey",
// The user might benefit from using a statistics T Table like https://www.statisticshowto.com/tables/t-distribution-table/
"tTable",
// The user might benefit from using a statistics Z Table like https://www.ztable.net/
"zTable"];
/**
* The type representing the common structure of all widget's options. The
* `Options` generic type represents the widget-specific option data.
*/
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
// prettier-ignore
//prettier-ignore
/**
* A background image applied to various widgets.
*/
const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
// 2D range: xMin, xMax, yMin, yMax
const lockedFigureColorNames = ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
const lockedFigureColors = {
blue: "#3D7586",
green: "#447A53",
grayH: "#3B3D45",
purple: "#594094",
pink: "#B25071",
red: "#D92916",
orange: "#946700"
};
const lockedFigureFillStyles = {
none: 0,
white: 1,
translucent: 0.4,
solid: 1
};
// Not associated with a specific figure
const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
exports.Errors = Errors;
exports.ItemExtras = ItemExtras;
exports.PerseusError = PerseusError;
exports.PerseusExpressionAnswerFormConsidered = PerseusExpressionAnswerFormConsidered;
exports.addLibraryVersionToPerseusDebug = addLibraryVersionToPerseusDebug;
exports.libVersion = libVersion;
exports.lockedFigureColorNames = lockedFigureColorNames;
exports.lockedFigureColors = lockedFigureColors;
exports.lockedFigureFillStyles = lockedFigureFillStyles;
exports.plotterPlotTypes = plotterPlotTypes;
//# sourceMappingURL=index.js.map

2

package.json

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "0.0.0-PR2040-20241219191743",
"version": "0.0.0-PR2077-20250110232805",
"publishConfig": {

@@ -9,0 +9,0 @@ "access": "public"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc