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

@khanacademy/perseus-core

Package Overview
Dependencies
Maintainers
1
Versions
282
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-PR686-20230822002019 to 0.0.0-PR711-20231005191758

dist/utils/add-library-version-to-perseus-debug.d.ts

20

CHANGELOG.md
# @khanacademy/perseus-core
## 0.0.0-PR686-20230822002019
## 0.0.0-PR711-20231005191758
### Patch Changes
- 55d4cd00: Print package name and version when loaded in the page
## 1.1.0
### Minor Changes
- 4f4fe4f9: Added new analytics event "perseus:expression-focused"
## 1.0.0
### Major Changes
- 2af4f9fa: Switch from using ProvideKeypad in ArticleRenderer to passing the keypad element down instead
## 0.2.0
### Minor Changes
- dd800c22: Rename analytics prop from onEvent to onAnalyticsEvent

@@ -8,0 +26,0 @@

export type VirtualKeypadVersion = "PERSEUS_MATH_INPUT" | "MATH_INPUT_KEYPAD_V1" | "MATH_INPUT_KEYPAD_V2" | "REACT_NATIVE_KEYPAD";
/**
* A type union of all the events that any package in the Perseus ecosystem can
* send.
*/
export type PerseusAnalyticsEvent = {

@@ -9,2 +13,5 @@ type: "perseus:expression-evaluated";

} | {
type: "perseus:expression-focused";
payload: null;
} | {
type: "math-input:keypad-closed";

@@ -11,0 +18,0 @@ payload: {

@@ -0,2 +1,51 @@

import { addLibraryVersionToPerseusDebug as addLibraryVersionToPerseusDebug$1 } from '@khanacademy/perseus-core';
/**
* Adds the given perseus library version information to the __perseus_debug__
* object and ensures that the object is attached to `globalThis` (`window` in
* browser environments).
*
* This allows each library to provide runtime version information to assist in
* debugging in production environments.
*/
const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
// If the library version is the default value, then we don't want to
// prefix it with a "v" to indicate that it is a version number.
let prefix = "v";
if (libraryVersion === "__lib_version__") {
prefix = "";
}
const formattedVersion = `${prefix}${libraryVersion}`;
if (typeof globalThis !== "undefined") {
var _globalThis$__perseus;
globalThis.__perseus_debug__ = (_globalThis$__perseus = globalThis.__perseus_debug__) != null ? _globalThis$__perseus : {};
const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
if (existingVersionEntry) {
// If we already have an entry and it doesn't match the registered
// version, we morph the entry into an array and log a warning.
if (existingVersionEntry !== formattedVersion) {
// Existing entry might be an array already (oops, at least 2
// versions of the library already loaded!).
const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
allVersions.push(formattedVersion);
globalThis.__perseus_debug__[libraryName] = allVersions;
// eslint-disable-next-line no-console
console.warn(`Multiple versions of ${libraryName} loaded on this page: ${allVersions.sort().join(", ")}`);
}
} else {
globalThis.__perseus_debug__[libraryName] = formattedVersion;
}
} else {
// eslint-disable-next-line no-console
console.warn(`globalThis not found found (${formattedVersion})`);
}
};
// This file is processed by a Rollup plugin (replace) to inject the production
const libName = "@khanacademy/perseus-core";
const libVersion = "1.1.0";
addLibraryVersionToPerseusDebug$1(libName, libVersion);
export { addLibraryVersionToPerseusDebug, libVersion };
//# sourceMappingURL=index.js.map

4

dist/index.d.ts
export type { PerseusAnalyticsEvent, AnalyticsEventHandlerFn } from "./analytics";
export type { KEScore, RendererInterface } from "./types";
export type { KEScore, KeypadContextRendererInterface, RendererInterface, } from "./types";
export { addLibraryVersionToPerseusDebug } from "./utils/add-library-version-to-perseus-debug";
export { libVersion } from "./version";
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var perseusCore = require('@khanacademy/perseus-core');
/**
* Adds the given perseus library version information to the __perseus_debug__
* object and ensures that the object is attached to `globalThis` (`window` in
* browser environments).
*
* This allows each library to provide runtime version information to assist in
* debugging in production environments.
*/
const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
// If the library version is the default value, then we don't want to
// prefix it with a "v" to indicate that it is a version number.
let prefix = "v";
if (libraryVersion === "__lib_version__") {
prefix = "";
}
const formattedVersion = "".concat(prefix).concat(libraryVersion);
if (typeof globalThis !== "undefined") {
var _globalThis$__perseus;
globalThis.__perseus_debug__ = (_globalThis$__perseus = globalThis.__perseus_debug__) !== null && _globalThis$__perseus !== void 0 ? _globalThis$__perseus : {};
const existingVersionEntry = globalThis.__perseus_debug__[libraryName];
if (existingVersionEntry) {
// If we already have an entry and it doesn't match the registered
// version, we morph the entry into an array and log a warning.
if (existingVersionEntry !== formattedVersion) {
// Existing entry might be an array already (oops, at least 2
// versions of the library already loaded!).
const allVersions = Array.isArray(existingVersionEntry) ? existingVersionEntry : [existingVersionEntry];
allVersions.push(formattedVersion);
globalThis.__perseus_debug__[libraryName] = allVersions;
// eslint-disable-next-line no-console
console.warn("Multiple versions of ".concat(libraryName, " loaded on this page: ").concat(allVersions.sort().join(", ")));
}
} else {
globalThis.__perseus_debug__[libraryName] = formattedVersion;
}
} else {
// eslint-disable-next-line no-console
console.warn("globalThis not found found (".concat(formattedVersion, ")"));
}
};
// This file is processed by a Rollup plugin (replace) to inject the production
const libName = "@khanacademy/perseus-core";
const libVersion = "1.1.0";
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
exports.addLibraryVersionToPerseusDebug = addLibraryVersionToPerseusDebug;
exports.libVersion = libVersion;
//# sourceMappingURL=index.js.map

@@ -0,1 +1,4 @@

export interface KeypadContextRendererInterface {
blur(): void;
}
type State = any;

@@ -2,0 +5,0 @@ export interface RendererInterface {

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

"license": "MIT",
"version": "0.0.0-PR686-20230822002019",
"version": "0.0.0-PR711-20231005191758",
"publishConfig": {

@@ -13,3 +13,4 @@ "access": "public"

"type": "git",
"url": "https://github.com/Khan/perseus.git"
"url": "https://github.com/Khan/perseus.git",
"directory": "packages/perseus-core"
},

@@ -16,0 +17,0 @@ "bugs": {

@@ -7,4 +7,6 @@ export type VirtualKeypadVersion =

// A type union of all the events that any package in the Perseus ecosystem can
// send.
/**
* A type union of all the events that any package in the Perseus ecosystem can
* send.
*/
export type PerseusAnalyticsEvent =

@@ -19,2 +21,6 @@ | {

| {
type: "perseus:expression-focused";
payload: null;
}
| {
type: "math-input:keypad-closed";

@@ -34,2 +40,6 @@ payload: {

// | {type: "b"; payload: {name: string}};
//
// Event types should be formatted as "package-name:event-name" (where the
// package name is the name of the package that emits the event without the
// `@khanacademy/` prefix and then the name of the event.)

@@ -36,0 +46,0 @@ /** A function that is called when Perseus emits an analytics event. */

export type {PerseusAnalyticsEvent, AnalyticsEventHandlerFn} from "./analytics";
export type {KEScore, RendererInterface} from "./types";
export type {
KEScore,
KeypadContextRendererInterface,
RendererInterface,
} from "./types";
// Careful, `version.ts` uses this function so it _must_ be imported above it
export {addLibraryVersionToPerseusDebug} from "./utils/add-library-version-to-perseus-debug";
export {libVersion} from "./version";
// Types that can be shared between Perseus packages
// ideally without causing circular dependencies
// Used by KeypadContext to pass around a renderer reference
export interface KeypadContextRendererInterface {
blur(): void;
}
// TODO: this should be typed

@@ -8,4 +13,3 @@ type State = any;

// Interfact currently only implemented by
// ServerItemRenderer and used by KeypadContext
// to pass around a renderer reference
// ServerItemRenderer
export interface RendererInterface {

@@ -12,0 +16,0 @@ getSerializedState(): State;

Sorry, the diff of this file is not supported yet

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