@patch-adams/core 1.4.13 → 1.4.15
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.
- package/dist/cli.cjs +43 -67
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +43 -67
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +43 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -10
- package/dist/index.d.ts +0 -10
- package/dist/index.js +43 -67
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/cli.cjs
CHANGED
|
@@ -11,7 +11,6 @@ var archiver = require('archiver');
|
|
|
11
11
|
var stream = require('stream');
|
|
12
12
|
var url = require('url');
|
|
13
13
|
var zod = require('zod');
|
|
14
|
-
var fastXmlParser = require('fast-xml-parser');
|
|
15
14
|
|
|
16
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
16
|
|
|
@@ -2956,9 +2955,28 @@ function generateLrsBridgeCode(options) {
|
|
|
2956
2955
|
};
|
|
2957
2956
|
}
|
|
2958
2957
|
|
|
2958
|
+
/**
|
|
2959
|
+
* Format seconds into MM:SS or HH:MM:SS format
|
|
2960
|
+
*/
|
|
2961
|
+
function formatMediaTime(seconds) {
|
|
2962
|
+
if (typeof seconds !== 'number' || isNaN(seconds)) return '0:00';
|
|
2963
|
+
var totalSeconds = Math.floor(seconds);
|
|
2964
|
+
var hours = Math.floor(totalSeconds / 3600);
|
|
2965
|
+
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
2966
|
+
var secs = totalSeconds % 60;
|
|
2967
|
+
|
|
2968
|
+
if (hours > 0) {
|
|
2969
|
+
return hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (secs < 10 ? '0' : '') + secs;
|
|
2970
|
+
}
|
|
2971
|
+
return minutes + ':' + (secs < 10 ? '0' : '') + secs;
|
|
2972
|
+
}
|
|
2973
|
+
|
|
2959
2974
|
/**
|
|
2960
2975
|
* Build activity object for media (video/audio) with human-readable name
|
|
2961
|
-
* Name format
|
|
2976
|
+
* Name format varies by action:
|
|
2977
|
+
* - played: "Video: Title (started at 1:23)"
|
|
2978
|
+
* - paused: "Video: Title (paused at 2:45)"
|
|
2979
|
+
* - completed: "Video: Title (completed)"
|
|
2962
2980
|
*/
|
|
2963
2981
|
function buildMediaActivityObject(mediaInfo) {
|
|
2964
2982
|
var mediaGuid = mediaInfo.mediaGuid || generateUUID();
|
|
@@ -2966,11 +2984,22 @@ function generateLrsBridgeCode(options) {
|
|
|
2966
2984
|
var resourceType = mediaInfo.type === 'audio' ? 'Audio' : 'Video';
|
|
2967
2985
|
|
|
2968
2986
|
// Build human-readable display name
|
|
2969
|
-
var
|
|
2970
|
-
if (!
|
|
2971
|
-
|
|
2972
|
-
}
|
|
2973
|
-
|
|
2987
|
+
var baseName = mediaInfo.name || '';
|
|
2988
|
+
if (!baseName || baseName === 'video' || baseName === 'audio' || baseName === 'Media') {
|
|
2989
|
+
baseName = mediaInfo.lessonName || 'Media';
|
|
2990
|
+
}
|
|
2991
|
+
|
|
2992
|
+
// Add time context based on action
|
|
2993
|
+
var displayName = resourceType + ': ' + baseName;
|
|
2994
|
+
var currentTime = mediaInfo.currentTime || 0;
|
|
2995
|
+
var action = mediaInfo.action;
|
|
2996
|
+
|
|
2997
|
+
if (action === 'play' || action === 'played') {
|
|
2998
|
+
displayName += ' (started at ' + formatMediaTime(currentTime) + ')';
|
|
2999
|
+
} else if (action === 'pause' || action === 'paused') {
|
|
3000
|
+
displayName += ' (paused at ' + formatMediaTime(currentTime) + ')';
|
|
3001
|
+
} else if (action === 'completed' || action === 'complete') {
|
|
3002
|
+
displayName += ' (completed)';
|
|
2974
3003
|
}
|
|
2975
3004
|
|
|
2976
3005
|
return {
|
|
@@ -3295,14 +3324,16 @@ function generateLrsBridgeCode(options) {
|
|
|
3295
3324
|
data.action === 'pause' ? 'paused' :
|
|
3296
3325
|
data.action === 'completed' ? 'completed' : 'played';
|
|
3297
3326
|
|
|
3298
|
-
// Build activity-specific object with human-readable name
|
|
3299
|
-
// e.g., "Video: Introduction" or "Audio: Podcast
|
|
3327
|
+
// Build activity-specific object with human-readable name including time context
|
|
3328
|
+
// e.g., "Video: Introduction (started at 1:23)" or "Audio: Podcast (paused at 2:45)"
|
|
3300
3329
|
var mediaObject = buildMediaActivityObject({
|
|
3301
3330
|
type: data.type,
|
|
3302
3331
|
src: data.src,
|
|
3303
3332
|
name: data.name,
|
|
3304
3333
|
duration: data.duration,
|
|
3305
|
-
lessonName: lessonInfo.name
|
|
3334
|
+
lessonName: lessonInfo.name,
|
|
3335
|
+
action: data.action,
|
|
3336
|
+
currentTime: data.currentTime
|
|
3306
3337
|
});
|
|
3307
3338
|
|
|
3308
3339
|
var result = {
|
|
@@ -5015,26 +5046,12 @@ ${loader}`);
|
|
|
5015
5046
|
</body>`);
|
|
5016
5047
|
}
|
|
5017
5048
|
};
|
|
5049
|
+
|
|
5050
|
+
// src/patcher/manifest-updater.ts
|
|
5018
5051
|
var ManifestUpdater = class {
|
|
5019
5052
|
config;
|
|
5020
|
-
parser;
|
|
5021
|
-
builder;
|
|
5022
5053
|
constructor(config) {
|
|
5023
5054
|
this.config = config;
|
|
5024
|
-
this.parser = new fastXmlParser.XMLParser({
|
|
5025
|
-
ignoreAttributes: false,
|
|
5026
|
-
attributeNamePrefix: "@_",
|
|
5027
|
-
preserveOrder: false,
|
|
5028
|
-
parseAttributeValue: false,
|
|
5029
|
-
trimValues: true
|
|
5030
|
-
});
|
|
5031
|
-
this.builder = new fastXmlParser.XMLBuilder({
|
|
5032
|
-
ignoreAttributes: false,
|
|
5033
|
-
attributeNamePrefix: "@_",
|
|
5034
|
-
format: true,
|
|
5035
|
-
indentBy: " ",
|
|
5036
|
-
suppressEmptyNode: true
|
|
5037
|
-
});
|
|
5038
5055
|
}
|
|
5039
5056
|
/**
|
|
5040
5057
|
* Update manifest files based on package format
|
|
@@ -5101,47 +5118,6 @@ $1</resource>`
|
|
|
5101
5118
|
return [];
|
|
5102
5119
|
}
|
|
5103
5120
|
}
|
|
5104
|
-
/**
|
|
5105
|
-
* Extract XML declaration from original content
|
|
5106
|
-
*/
|
|
5107
|
-
extractXmlDeclaration(xml) {
|
|
5108
|
-
const match = xml.match(/<\?xml[^?]*\?>/);
|
|
5109
|
-
return match ? match[0] + "\n" : '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
5110
|
-
}
|
|
5111
|
-
/**
|
|
5112
|
-
* Add file entries to the manifest
|
|
5113
|
-
*/
|
|
5114
|
-
addFilesToManifest(parsed, paths) {
|
|
5115
|
-
const manifest = parsed.manifest;
|
|
5116
|
-
if (!manifest) return;
|
|
5117
|
-
const resources = manifest.resources;
|
|
5118
|
-
if (!resources) return;
|
|
5119
|
-
let resource = resources.resource;
|
|
5120
|
-
if (!resource) return;
|
|
5121
|
-
if (Array.isArray(resource)) {
|
|
5122
|
-
resource = resource[0];
|
|
5123
|
-
}
|
|
5124
|
-
if (!resource.file) {
|
|
5125
|
-
resource.file = [];
|
|
5126
|
-
}
|
|
5127
|
-
let files = resource.file;
|
|
5128
|
-
if (!Array.isArray(files)) {
|
|
5129
|
-
files = [files];
|
|
5130
|
-
resource.file = files;
|
|
5131
|
-
}
|
|
5132
|
-
const filesToAdd = [
|
|
5133
|
-
paths.cssBefore,
|
|
5134
|
-
paths.cssAfter,
|
|
5135
|
-
paths.jsBefore,
|
|
5136
|
-
paths.jsAfter
|
|
5137
|
-
].filter(Boolean);
|
|
5138
|
-
for (const filePath of filesToAdd) {
|
|
5139
|
-
const exists = files.some((f) => f["@_href"] === filePath);
|
|
5140
|
-
if (!exists) {
|
|
5141
|
-
files.push({ "@_href": filePath });
|
|
5142
|
-
}
|
|
5143
|
-
}
|
|
5144
|
-
}
|
|
5145
5121
|
/**
|
|
5146
5122
|
* Get the file paths that will be added to the package
|
|
5147
5123
|
*/
|