@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.js
CHANGED
|
@@ -9,7 +9,6 @@ import archiver from 'archiver';
|
|
|
9
9
|
import { PassThrough } from 'stream';
|
|
10
10
|
import { pathToFileURL } from 'url';
|
|
11
11
|
import { z } from 'zod';
|
|
12
|
-
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
|
|
13
12
|
|
|
14
13
|
var __defProp = Object.defineProperty;
|
|
15
14
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -2947,9 +2946,28 @@ function generateLrsBridgeCode(options) {
|
|
|
2947
2946
|
};
|
|
2948
2947
|
}
|
|
2949
2948
|
|
|
2949
|
+
/**
|
|
2950
|
+
* Format seconds into MM:SS or HH:MM:SS format
|
|
2951
|
+
*/
|
|
2952
|
+
function formatMediaTime(seconds) {
|
|
2953
|
+
if (typeof seconds !== 'number' || isNaN(seconds)) return '0:00';
|
|
2954
|
+
var totalSeconds = Math.floor(seconds);
|
|
2955
|
+
var hours = Math.floor(totalSeconds / 3600);
|
|
2956
|
+
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
2957
|
+
var secs = totalSeconds % 60;
|
|
2958
|
+
|
|
2959
|
+
if (hours > 0) {
|
|
2960
|
+
return hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (secs < 10 ? '0' : '') + secs;
|
|
2961
|
+
}
|
|
2962
|
+
return minutes + ':' + (secs < 10 ? '0' : '') + secs;
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2950
2965
|
/**
|
|
2951
2966
|
* Build activity object for media (video/audio) with human-readable name
|
|
2952
|
-
* Name format
|
|
2967
|
+
* Name format varies by action:
|
|
2968
|
+
* - played: "Video: Title (started at 1:23)"
|
|
2969
|
+
* - paused: "Video: Title (paused at 2:45)"
|
|
2970
|
+
* - completed: "Video: Title (completed)"
|
|
2953
2971
|
*/
|
|
2954
2972
|
function buildMediaActivityObject(mediaInfo) {
|
|
2955
2973
|
var mediaGuid = mediaInfo.mediaGuid || generateUUID();
|
|
@@ -2957,11 +2975,22 @@ function generateLrsBridgeCode(options) {
|
|
|
2957
2975
|
var resourceType = mediaInfo.type === 'audio' ? 'Audio' : 'Video';
|
|
2958
2976
|
|
|
2959
2977
|
// Build human-readable display name
|
|
2960
|
-
var
|
|
2961
|
-
if (!
|
|
2962
|
-
|
|
2963
|
-
}
|
|
2964
|
-
|
|
2978
|
+
var baseName = mediaInfo.name || '';
|
|
2979
|
+
if (!baseName || baseName === 'video' || baseName === 'audio' || baseName === 'Media') {
|
|
2980
|
+
baseName = mediaInfo.lessonName || 'Media';
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
// Add time context based on action
|
|
2984
|
+
var displayName = resourceType + ': ' + baseName;
|
|
2985
|
+
var currentTime = mediaInfo.currentTime || 0;
|
|
2986
|
+
var action = mediaInfo.action;
|
|
2987
|
+
|
|
2988
|
+
if (action === 'play' || action === 'played') {
|
|
2989
|
+
displayName += ' (started at ' + formatMediaTime(currentTime) + ')';
|
|
2990
|
+
} else if (action === 'pause' || action === 'paused') {
|
|
2991
|
+
displayName += ' (paused at ' + formatMediaTime(currentTime) + ')';
|
|
2992
|
+
} else if (action === 'completed' || action === 'complete') {
|
|
2993
|
+
displayName += ' (completed)';
|
|
2965
2994
|
}
|
|
2966
2995
|
|
|
2967
2996
|
return {
|
|
@@ -3286,14 +3315,16 @@ function generateLrsBridgeCode(options) {
|
|
|
3286
3315
|
data.action === 'pause' ? 'paused' :
|
|
3287
3316
|
data.action === 'completed' ? 'completed' : 'played';
|
|
3288
3317
|
|
|
3289
|
-
// Build activity-specific object with human-readable name
|
|
3290
|
-
// e.g., "Video: Introduction" or "Audio: Podcast
|
|
3318
|
+
// Build activity-specific object with human-readable name including time context
|
|
3319
|
+
// e.g., "Video: Introduction (started at 1:23)" or "Audio: Podcast (paused at 2:45)"
|
|
3291
3320
|
var mediaObject = buildMediaActivityObject({
|
|
3292
3321
|
type: data.type,
|
|
3293
3322
|
src: data.src,
|
|
3294
3323
|
name: data.name,
|
|
3295
3324
|
duration: data.duration,
|
|
3296
|
-
lessonName: lessonInfo.name
|
|
3325
|
+
lessonName: lessonInfo.name,
|
|
3326
|
+
action: data.action,
|
|
3327
|
+
currentTime: data.currentTime
|
|
3297
3328
|
});
|
|
3298
3329
|
|
|
3299
3330
|
var result = {
|
|
@@ -5006,26 +5037,12 @@ ${loader}`);
|
|
|
5006
5037
|
</body>`);
|
|
5007
5038
|
}
|
|
5008
5039
|
};
|
|
5040
|
+
|
|
5041
|
+
// src/patcher/manifest-updater.ts
|
|
5009
5042
|
var ManifestUpdater = class {
|
|
5010
5043
|
config;
|
|
5011
|
-
parser;
|
|
5012
|
-
builder;
|
|
5013
5044
|
constructor(config) {
|
|
5014
5045
|
this.config = config;
|
|
5015
|
-
this.parser = new XMLParser({
|
|
5016
|
-
ignoreAttributes: false,
|
|
5017
|
-
attributeNamePrefix: "@_",
|
|
5018
|
-
preserveOrder: false,
|
|
5019
|
-
parseAttributeValue: false,
|
|
5020
|
-
trimValues: true
|
|
5021
|
-
});
|
|
5022
|
-
this.builder = new XMLBuilder({
|
|
5023
|
-
ignoreAttributes: false,
|
|
5024
|
-
attributeNamePrefix: "@_",
|
|
5025
|
-
format: true,
|
|
5026
|
-
indentBy: " ",
|
|
5027
|
-
suppressEmptyNode: true
|
|
5028
|
-
});
|
|
5029
5046
|
}
|
|
5030
5047
|
/**
|
|
5031
5048
|
* Update manifest files based on package format
|
|
@@ -5092,47 +5109,6 @@ $1</resource>`
|
|
|
5092
5109
|
return [];
|
|
5093
5110
|
}
|
|
5094
5111
|
}
|
|
5095
|
-
/**
|
|
5096
|
-
* Extract XML declaration from original content
|
|
5097
|
-
*/
|
|
5098
|
-
extractXmlDeclaration(xml) {
|
|
5099
|
-
const match = xml.match(/<\?xml[^?]*\?>/);
|
|
5100
|
-
return match ? match[0] + "\n" : '<?xml version="1.0" encoding="UTF-8"?>\n';
|
|
5101
|
-
}
|
|
5102
|
-
/**
|
|
5103
|
-
* Add file entries to the manifest
|
|
5104
|
-
*/
|
|
5105
|
-
addFilesToManifest(parsed, paths) {
|
|
5106
|
-
const manifest = parsed.manifest;
|
|
5107
|
-
if (!manifest) return;
|
|
5108
|
-
const resources = manifest.resources;
|
|
5109
|
-
if (!resources) return;
|
|
5110
|
-
let resource = resources.resource;
|
|
5111
|
-
if (!resource) return;
|
|
5112
|
-
if (Array.isArray(resource)) {
|
|
5113
|
-
resource = resource[0];
|
|
5114
|
-
}
|
|
5115
|
-
if (!resource.file) {
|
|
5116
|
-
resource.file = [];
|
|
5117
|
-
}
|
|
5118
|
-
let files = resource.file;
|
|
5119
|
-
if (!Array.isArray(files)) {
|
|
5120
|
-
files = [files];
|
|
5121
|
-
resource.file = files;
|
|
5122
|
-
}
|
|
5123
|
-
const filesToAdd = [
|
|
5124
|
-
paths.cssBefore,
|
|
5125
|
-
paths.cssAfter,
|
|
5126
|
-
paths.jsBefore,
|
|
5127
|
-
paths.jsAfter
|
|
5128
|
-
].filter(Boolean);
|
|
5129
|
-
for (const filePath of filesToAdd) {
|
|
5130
|
-
const exists = files.some((f) => f["@_href"] === filePath);
|
|
5131
|
-
if (!exists) {
|
|
5132
|
-
files.push({ "@_href": filePath });
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5136
5112
|
/**
|
|
5137
5113
|
* Get the file paths that will be added to the package
|
|
5138
5114
|
*/
|