Pipwerks SCORM API Wrapper

raw JSON →
0.1.2 verified Sat Apr 25 auth: no javascript

Module wrapper for the Pipwerks SCORM API Wrapper, providing a clean ES6 module interface for LMS communication in e-learning content. Current version 0.1.2. Exposes SCORM object with init, get, set, save, quit methods plus debug and utilities. Intended for browser use in SCORM 1.2/2004 compliant LMS environments. Key differentiator: simplifies the original pipwerks API with ES module exports and npm distribution, avoiding global pollution.

error TypeError: pipwerks is undefined
cause Attempting to access global pipwerks object from script that doesn't create it.
fix
Use import { SCORM } from 'pipwerks-scorm-api-wrapper'; then use SCORM directly instead of pipwerks.SCORM.
error Error: ERR_REQUIRE_ESM
cause Using require() to load the ESM-only package.
fix
Switch to ES module import syntax: import { SCORM } from 'pipwerks-scorm-api-wrapper';
error TypeError: SCORM.init is not a function
cause Incorrect import (default import instead of named).
fix
Use import { SCORM } from 'pipwerks-scorm-api-wrapper';
gotcha SCORM.init() must be called before any get/set operations, typically on page load. Failing to do so results in silent failures.
fix Call SCORM.init() at the beginning of your script; ensure the page is loaded in an LMS window.
gotcha SCORM.get() returns empty string for undefined data model elements, not null or undefined. Compare against '' or check 'isAvailable'.
fix Use SCORM.isAvailable() to confirm connection, or check result !== ''.
breaking Package is ESM-only (no CommonJS) since v0.1.0. Using require() throws 'ERR_REQUIRE_ESM' in Node.js.
fix Use import syntax in ESM context, or ensure bundler (webpack, rollup) resolves the module.
gotcha UTILS.StringToBoolean expects 'true'/'false' strings; passing numeric 0/1 or boolean true/false causes unexpected results.
fix Always pass string 'true' or 'false'; for numbers, use Boolean(Number(value)).
npm install pipwerks-scorm-api-wrapper
yarn add pipwerks-scorm-api-wrapper
pnpm add pipwerks-scorm-api-wrapper

Shows basic SCORM workflow: initialize, get student name, set lesson status, save, and quit.

import { SCORM } from 'pipwerks-scorm-api-wrapper';

// Initialize connection with LMS
SCORM.init();

// Get learner name
const studentName = SCORM.get('cmi.core.student_name');
console.log('Student:', studentName);

// Set lesson status to completed
SCORM.set('cmi.core.lesson_status', 'completed');

// Save data to LMS
SCORM.save();

// Terminate session
SCORM.quit();