@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/index.cjs CHANGED
@@ -7,7 +7,6 @@ var url = require('url');
7
7
  var AdmZip = require('adm-zip');
8
8
  var archiver = require('archiver');
9
9
  var stream = require('stream');
10
- var fastXmlParser = require('fast-xml-parser');
11
10
  var crypto = require('crypto');
12
11
  var chalk = require('chalk');
13
12
 
@@ -2620,9 +2619,28 @@ function generateLrsBridgeCode(options) {
2620
2619
  };
2621
2620
  }
2622
2621
 
2622
+ /**
2623
+ * Format seconds into MM:SS or HH:MM:SS format
2624
+ */
2625
+ function formatMediaTime(seconds) {
2626
+ if (typeof seconds !== 'number' || isNaN(seconds)) return '0:00';
2627
+ var totalSeconds = Math.floor(seconds);
2628
+ var hours = Math.floor(totalSeconds / 3600);
2629
+ var minutes = Math.floor((totalSeconds % 3600) / 60);
2630
+ var secs = totalSeconds % 60;
2631
+
2632
+ if (hours > 0) {
2633
+ return hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (secs < 10 ? '0' : '') + secs;
2634
+ }
2635
+ return minutes + ':' + (secs < 10 ? '0' : '') + secs;
2636
+ }
2637
+
2623
2638
  /**
2624
2639
  * Build activity object for media (video/audio) with human-readable name
2625
- * Name format: "Video: Title" or "Audio: Title"
2640
+ * Name format varies by action:
2641
+ * - played: "Video: Title (started at 1:23)"
2642
+ * - paused: "Video: Title (paused at 2:45)"
2643
+ * - completed: "Video: Title (completed)"
2626
2644
  */
2627
2645
  function buildMediaActivityObject(mediaInfo) {
2628
2646
  var mediaGuid = mediaInfo.mediaGuid || generateUUID();
@@ -2630,11 +2648,22 @@ function generateLrsBridgeCode(options) {
2630
2648
  var resourceType = mediaInfo.type === 'audio' ? 'Audio' : 'Video';
2631
2649
 
2632
2650
  // Build human-readable display name
2633
- var displayName = mediaInfo.name || '';
2634
- if (!displayName || displayName === 'video' || displayName === 'audio' || displayName === 'Media') {
2635
- displayName = resourceType + ': ' + (mediaInfo.lessonName || 'Media');
2636
- } else {
2637
- displayName = resourceType + ': ' + displayName;
2651
+ var baseName = mediaInfo.name || '';
2652
+ if (!baseName || baseName === 'video' || baseName === 'audio' || baseName === 'Media') {
2653
+ baseName = mediaInfo.lessonName || 'Media';
2654
+ }
2655
+
2656
+ // Add time context based on action
2657
+ var displayName = resourceType + ': ' + baseName;
2658
+ var currentTime = mediaInfo.currentTime || 0;
2659
+ var action = mediaInfo.action;
2660
+
2661
+ if (action === 'play' || action === 'played') {
2662
+ displayName += ' (started at ' + formatMediaTime(currentTime) + ')';
2663
+ } else if (action === 'pause' || action === 'paused') {
2664
+ displayName += ' (paused at ' + formatMediaTime(currentTime) + ')';
2665
+ } else if (action === 'completed' || action === 'complete') {
2666
+ displayName += ' (completed)';
2638
2667
  }
2639
2668
 
2640
2669
  return {
@@ -2959,14 +2988,16 @@ function generateLrsBridgeCode(options) {
2959
2988
  data.action === 'pause' ? 'paused' :
2960
2989
  data.action === 'completed' ? 'completed' : 'played';
2961
2990
 
2962
- // Build activity-specific object with human-readable name
2963
- // e.g., "Video: Introduction" or "Audio: Podcast Episode 1"
2991
+ // Build activity-specific object with human-readable name including time context
2992
+ // e.g., "Video: Introduction (started at 1:23)" or "Audio: Podcast (paused at 2:45)"
2964
2993
  var mediaObject = buildMediaActivityObject({
2965
2994
  type: data.type,
2966
2995
  src: data.src,
2967
2996
  name: data.name,
2968
2997
  duration: data.duration,
2969
- lessonName: lessonInfo.name
2998
+ lessonName: lessonInfo.name,
2999
+ action: data.action,
3000
+ currentTime: data.currentTime
2970
3001
  });
2971
3002
 
2972
3003
  var result = {
@@ -4679,26 +4710,12 @@ ${loader}`);
4679
4710
  </body>`);
4680
4711
  }
4681
4712
  };
4713
+
4714
+ // src/patcher/manifest-updater.ts
4682
4715
  var ManifestUpdater = class {
4683
4716
  config;
4684
- parser;
4685
- builder;
4686
4717
  constructor(config) {
4687
4718
  this.config = config;
4688
- this.parser = new fastXmlParser.XMLParser({
4689
- ignoreAttributes: false,
4690
- attributeNamePrefix: "@_",
4691
- preserveOrder: false,
4692
- parseAttributeValue: false,
4693
- trimValues: true
4694
- });
4695
- this.builder = new fastXmlParser.XMLBuilder({
4696
- ignoreAttributes: false,
4697
- attributeNamePrefix: "@_",
4698
- format: true,
4699
- indentBy: " ",
4700
- suppressEmptyNode: true
4701
- });
4702
4719
  }
4703
4720
  /**
4704
4721
  * Update manifest files based on package format
@@ -4765,47 +4782,6 @@ $1</resource>`
4765
4782
  return [];
4766
4783
  }
4767
4784
  }
4768
- /**
4769
- * Extract XML declaration from original content
4770
- */
4771
- extractXmlDeclaration(xml) {
4772
- const match = xml.match(/<\?xml[^?]*\?>/);
4773
- return match ? match[0] + "\n" : '<?xml version="1.0" encoding="UTF-8"?>\n';
4774
- }
4775
- /**
4776
- * Add file entries to the manifest
4777
- */
4778
- addFilesToManifest(parsed, paths) {
4779
- const manifest = parsed.manifest;
4780
- if (!manifest) return;
4781
- const resources = manifest.resources;
4782
- if (!resources) return;
4783
- let resource = resources.resource;
4784
- if (!resource) return;
4785
- if (Array.isArray(resource)) {
4786
- resource = resource[0];
4787
- }
4788
- if (!resource.file) {
4789
- resource.file = [];
4790
- }
4791
- let files = resource.file;
4792
- if (!Array.isArray(files)) {
4793
- files = [files];
4794
- resource.file = files;
4795
- }
4796
- const filesToAdd = [
4797
- paths.cssBefore,
4798
- paths.cssAfter,
4799
- paths.jsBefore,
4800
- paths.jsAfter
4801
- ].filter(Boolean);
4802
- for (const filePath of filesToAdd) {
4803
- const exists = files.some((f) => f["@_href"] === filePath);
4804
- if (!exists) {
4805
- files.push({ "@_href": filePath });
4806
- }
4807
- }
4808
- }
4809
4785
  /**
4810
4786
  * Get the file paths that will be added to the package
4811
4787
  */