@khanacademy/perseus-core
Advanced tools
Comparing version 1.1.0 to 1.1.1
# @khanacademy/perseus-core | ||
## 1.1.1 | ||
### Patch Changes | ||
- 55d4cd00: Print package name and version when loaded in the page | ||
## 1.1.0 | ||
@@ -4,0 +10,0 @@ |
@@ -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.1"; | ||
addLibraryVersionToPerseusDebug$1(libName, libVersion); | ||
export { addLibraryVersionToPerseusDebug, libVersion }; | ||
//# sourceMappingURL=index.js.map |
export type { PerseusAnalyticsEvent, AnalyticsEventHandlerFn } from "./analytics"; | ||
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.1"; | ||
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion); | ||
exports.addLibraryVersionToPerseusDebug = addLibraryVersionToPerseusDebug; | ||
exports.libVersion = libVersion; | ||
//# sourceMappingURL=index.js.map |
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"publishConfig": { | ||
@@ -9,0 +9,0 @@ "access": "public" |
@@ -7,1 +7,6 @@ export type {PerseusAnalyticsEvent, AnalyticsEventHandlerFn} from "./analytics"; | ||
} 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"; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73298
22
421
0