@khanacademy/perseus-utils 0.0.2 → 2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/add-library-version-to-perseus-debug.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","_globalThis$__perseus","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join"],"mappings":"AAAA;AACA;AACA;AACA;AACA;A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;AACAS,IAAAA,OAAO,CAACC,IAAI,CAAC,CAA+BV,4BAAAA,EAAAA,gBAAgB,GAAG,CAAC,CAAA;AACpE,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/add-library-version-to-perseus-debug.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","_globalThis$__perseus","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MAC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}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/add-library-version-to-perseus-debug.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaA,+BAA+B,GAAGA,CAC3CC,WAAmB,EACnBC,cAAsB,KACrB;AACD;AACA;EACA,IAAIC,MAAM,GAAG,GAAG,CAAA;EAChB,IAAID,cAAc,KAAK,iBAAiB,EAAE;AACtCC,IAAAA,MAAM,GAAG,EAAE,CAAA;AACf,GAAA;AACA,EAAA,MAAMC,gBAAgB,GAAG,CAAA,EAAGD,MAAM,CAAA,EAAGD,cAAc,CAAE,CAAA,CAAA;AAErD,EAAA,IAAI,OAAOG,UAAU,KAAK,WAAW,EAAE;IACnCA,UAAU,CAACC,iBAAiB,GAAGD,UAAU,CAACC,iBAAiB,IAAI,EAAE,CAAA;AAEjE,IAAA,MAAMC,oBAAoB,GAAGF,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC,CAAA;AACtE,IAAA,IAAIM,oBAAoB,EAAE;AACtB;AACA;MACA,IAAIA,oBAAoB,KAAKH,gBAAgB,EAAE;AAC3C;AACA;AACA,QAAA,MAAMI,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,oBAAoB,CAAC,GACjDA,oBAAoB,GACpB,CAACA,oBAAoB,CAAC,CAAA;AAC5BC,QAAAA,WAAW,CAACG,IAAI,CAACP,gBAAgB,CAAC,CAAA;AAElCC,QAAAA,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC,GAAGO,WAAW,CAAA;;AAEvD;AACAI,QAAAA,OAAO,CAACC,IAAI,CACR,CAAwBZ,qBAAAA,EAAAA,WAAW,yBAAyBO,WAAW,CAClEM,IAAI,EAAE,CACNC,IAAI,CAAC,IAAI,CAAC,EACnB,CAAC,CAAA;AACL,OAAA;AACJ,KAAC,MAAM;AACHV,MAAAA,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC,GAAGG,gBAAgB,CAAA;AAChE,KAAA;AACJ,GAAC,MAAM;AACH;AACAQ,IAAAA,OAAO,CAACC,IAAI,CAAC,CAA+BT,4BAAAA,EAAAA,gBAAgB,GAAG,CAAC,CAAA;AACpE,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/add-library-version-to-perseus-debug.ts"],"sourcesContent":["/**\n * Adds the given perseus library version information to the __perseus_debug__\n * object and ensures that the object is attached to `globalThis` (`window` in\n * browser environments).\n *\n * This allows each library to provide runtime version information to assist in\n * debugging in production environments.\n */\nexport const addLibraryVersionToPerseusDebug = (\n libraryName: string,\n libraryVersion: string,\n) => {\n // If the library version is the default value, then we don't want to\n // prefix it with a \"v\" to indicate that it is a version number.\n let prefix = \"v\";\n if (libraryVersion === \"__lib_version__\") {\n prefix = \"\";\n }\n const formattedVersion = `${prefix}${libraryVersion}`;\n\n if (typeof globalThis !== \"undefined\") {\n globalThis.__perseus_debug__ = globalThis.__perseus_debug__ ?? {};\n\n const existingVersionEntry = globalThis.__perseus_debug__[libraryName];\n if (existingVersionEntry) {\n // If we already have an entry and it doesn't match the registered\n // version, we morph the entry into an array and log a warning.\n if (existingVersionEntry !== formattedVersion) {\n // Existing entry might be an array already (oops, at least 2\n // versions of the library already loaded!).\n const allVersions = Array.isArray(existingVersionEntry)\n ? existingVersionEntry\n : [existingVersionEntry];\n allVersions.push(formattedVersion);\n\n globalThis.__perseus_debug__[libraryName] = allVersions;\n\n // eslint-disable-next-line no-console\n console.warn(\n `Multiple versions of ${libraryName} loaded on this page: ${allVersions\n .sort()\n .join(\", \")}`,\n );\n }\n } else {\n globalThis.__perseus_debug__[libraryName] = formattedVersion;\n }\n } else {\n // eslint-disable-next-line no-console\n console.warn(`globalThis not found found (${formattedVersion})`);\n }\n};\n"],"names":["addLibraryVersionToPerseusDebug","libraryName","libraryVersion","prefix","formattedVersion","globalThis","__perseus_debug__","existingVersionEntry","allVersions","Array","isArray","push","console","warn","sort","join"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;MACaA,+BAA+B,GAAGA,CAC3CC,WAAmB,EACnBC,cAAsB,KACrB;AACD;AACA;EACA,IAAIC,MAAM,GAAG,GAAG;EAChB,IAAID,cAAc,KAAK,iBAAiB,EAAE;AACtCC,IAAAA,MAAM,GAAG,EAAE;AACf;AACA,EAAA,MAAMC,gBAAgB,GAAG,CAAA,EAAGD,MAAM,CAAA,EAAGD,cAAc,CAAE,CAAA;AAErD,EAAA,IAAI,OAAOG,UAAU,KAAK,WAAW,EAAE;IACnCA,UAAU,CAACC,iBAAiB,GAAGD,UAAU,CAACC,iBAAiB,IAAI,EAAE;AAEjE,IAAA,MAAMC,oBAAoB,GAAGF,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC;AACtE,IAAA,IAAIM,oBAAoB,EAAE;AACtB;AACA;MACA,IAAIA,oBAAoB,KAAKH,gBAAgB,EAAE;AAC3C;AACA;AACA,QAAA,MAAMI,WAAW,GAAGC,KAAK,CAACC,OAAO,CAACH,oBAAoB,CAAC,GACjDA,oBAAoB,GACpB,CAACA,oBAAoB,CAAC;AAC5BC,QAAAA,WAAW,CAACG,IAAI,CAACP,gBAAgB,CAAC;AAElCC,QAAAA,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC,GAAGO,WAAW;;AAEvD;AACAI,QAAAA,OAAO,CAACC,IAAI,CACR,CAAwBZ,qBAAAA,EAAAA,WAAW,yBAAyBO,WAAW,CAClEM,IAAI,EAAE,CACNC,IAAI,CAAC,IAAI,CAAC,EACnB,CAAC;AACL;AACJ,KAAC,MAAM;AACHV,MAAAA,UAAU,CAACC,iBAAiB,CAACL,WAAW,CAAC,GAAGG,gBAAgB;AAChE;AACJ,GAAC,MAAM;AACH;AACAQ,IAAAA,OAAO,CAACC,IAAI,CAAC,CAA+BT,4BAAAA,EAAAA,gBAAgB,GAAG,CAAC;AACpE;AACJ;;;;"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Miscellaneous utilities used by the Khan Academy Perseus ecosystem",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "0.0.2",
6
+ "version": "2.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "dependencies": {},
26
26
  "devDependencies": {
27
- "perseus-build-settings": "0.5.1"
27
+ "perseus-build-settings": "0.6.0"
28
28
  },
29
29
  "scripts": {}
30
30
  }