@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.d.cts CHANGED
@@ -734,8 +734,6 @@ interface ManifestPaths {
734
734
  */
735
735
  declare class ManifestUpdater {
736
736
  private config;
737
- private parser;
738
- private builder;
739
737
  constructor(config: PatchAdamsConfig);
740
738
  /**
741
739
  * Update manifest files based on package format
@@ -746,14 +744,6 @@ declare class ManifestUpdater {
746
744
  * Uses string manipulation to preserve original XML formatting exactly
747
745
  */
748
746
  private updateImsManifest;
749
- /**
750
- * Extract XML declaration from original content
751
- */
752
- private extractXmlDeclaration;
753
- /**
754
- * Add file entries to the manifest
755
- */
756
- private addFilesToManifest;
757
747
  /**
758
748
  * Get the file paths that will be added to the package
759
749
  */
package/dist/index.d.ts CHANGED
@@ -734,8 +734,6 @@ interface ManifestPaths {
734
734
  */
735
735
  declare class ManifestUpdater {
736
736
  private config;
737
- private parser;
738
- private builder;
739
737
  constructor(config: PatchAdamsConfig);
740
738
  /**
741
739
  * Update manifest files based on package format
@@ -746,14 +744,6 @@ declare class ManifestUpdater {
746
744
  * Uses string manipulation to preserve original XML formatting exactly
747
745
  */
748
746
  private updateImsManifest;
749
- /**
750
- * Extract XML declaration from original content
751
- */
752
- private extractXmlDeclaration;
753
- /**
754
- * Add file entries to the manifest
755
- */
756
- private addFilesToManifest;
757
747
  /**
758
748
  * Get the file paths that will be added to the package
759
749
  */
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ import { pathToFileURL } from 'url';
5
5
  import AdmZip from 'adm-zip';
6
6
  import archiver from 'archiver';
7
7
  import { PassThrough } from 'stream';
8
- import { XMLParser, XMLBuilder } from 'fast-xml-parser';
9
8
  import { createHash } from 'crypto';
10
9
  import chalk from 'chalk';
11
10
 
@@ -2612,9 +2611,28 @@ function generateLrsBridgeCode(options) {
2612
2611
  };
2613
2612
  }
2614
2613
 
2614
+ /**
2615
+ * Format seconds into MM:SS or HH:MM:SS format
2616
+ */
2617
+ function formatMediaTime(seconds) {
2618
+ if (typeof seconds !== 'number' || isNaN(seconds)) return '0:00';
2619
+ var totalSeconds = Math.floor(seconds);
2620
+ var hours = Math.floor(totalSeconds / 3600);
2621
+ var minutes = Math.floor((totalSeconds % 3600) / 60);
2622
+ var secs = totalSeconds % 60;
2623
+
2624
+ if (hours > 0) {
2625
+ return hours + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (secs < 10 ? '0' : '') + secs;
2626
+ }
2627
+ return minutes + ':' + (secs < 10 ? '0' : '') + secs;
2628
+ }
2629
+
2615
2630
  /**
2616
2631
  * Build activity object for media (video/audio) with human-readable name
2617
- * Name format: "Video: Title" or "Audio: Title"
2632
+ * Name format varies by action:
2633
+ * - played: "Video: Title (started at 1:23)"
2634
+ * - paused: "Video: Title (paused at 2:45)"
2635
+ * - completed: "Video: Title (completed)"
2618
2636
  */
2619
2637
  function buildMediaActivityObject(mediaInfo) {
2620
2638
  var mediaGuid = mediaInfo.mediaGuid || generateUUID();
@@ -2622,11 +2640,22 @@ function generateLrsBridgeCode(options) {
2622
2640
  var resourceType = mediaInfo.type === 'audio' ? 'Audio' : 'Video';
2623
2641
 
2624
2642
  // Build human-readable display name
2625
- var displayName = mediaInfo.name || '';
2626
- if (!displayName || displayName === 'video' || displayName === 'audio' || displayName === 'Media') {
2627
- displayName = resourceType + ': ' + (mediaInfo.lessonName || 'Media');
2628
- } else {
2629
- displayName = resourceType + ': ' + displayName;
2643
+ var baseName = mediaInfo.name || '';
2644
+ if (!baseName || baseName === 'video' || baseName === 'audio' || baseName === 'Media') {
2645
+ baseName = mediaInfo.lessonName || 'Media';
2646
+ }
2647
+
2648
+ // Add time context based on action
2649
+ var displayName = resourceType + ': ' + baseName;
2650
+ var currentTime = mediaInfo.currentTime || 0;
2651
+ var action = mediaInfo.action;
2652
+
2653
+ if (action === 'play' || action === 'played') {
2654
+ displayName += ' (started at ' + formatMediaTime(currentTime) + ')';
2655
+ } else if (action === 'pause' || action === 'paused') {
2656
+ displayName += ' (paused at ' + formatMediaTime(currentTime) + ')';
2657
+ } else if (action === 'completed' || action === 'complete') {
2658
+ displayName += ' (completed)';
2630
2659
  }
2631
2660
 
2632
2661
  return {
@@ -2951,14 +2980,16 @@ function generateLrsBridgeCode(options) {
2951
2980
  data.action === 'pause' ? 'paused' :
2952
2981
  data.action === 'completed' ? 'completed' : 'played';
2953
2982
 
2954
- // Build activity-specific object with human-readable name
2955
- // e.g., "Video: Introduction" or "Audio: Podcast Episode 1"
2983
+ // Build activity-specific object with human-readable name including time context
2984
+ // e.g., "Video: Introduction (started at 1:23)" or "Audio: Podcast (paused at 2:45)"
2956
2985
  var mediaObject = buildMediaActivityObject({
2957
2986
  type: data.type,
2958
2987
  src: data.src,
2959
2988
  name: data.name,
2960
2989
  duration: data.duration,
2961
- lessonName: lessonInfo.name
2990
+ lessonName: lessonInfo.name,
2991
+ action: data.action,
2992
+ currentTime: data.currentTime
2962
2993
  });
2963
2994
 
2964
2995
  var result = {
@@ -4671,26 +4702,12 @@ ${loader}`);
4671
4702
  </body>`);
4672
4703
  }
4673
4704
  };
4705
+
4706
+ // src/patcher/manifest-updater.ts
4674
4707
  var ManifestUpdater = class {
4675
4708
  config;
4676
- parser;
4677
- builder;
4678
4709
  constructor(config) {
4679
4710
  this.config = config;
4680
- this.parser = new XMLParser({
4681
- ignoreAttributes: false,
4682
- attributeNamePrefix: "@_",
4683
- preserveOrder: false,
4684
- parseAttributeValue: false,
4685
- trimValues: true
4686
- });
4687
- this.builder = new XMLBuilder({
4688
- ignoreAttributes: false,
4689
- attributeNamePrefix: "@_",
4690
- format: true,
4691
- indentBy: " ",
4692
- suppressEmptyNode: true
4693
- });
4694
4711
  }
4695
4712
  /**
4696
4713
  * Update manifest files based on package format
@@ -4757,47 +4774,6 @@ $1</resource>`
4757
4774
  return [];
4758
4775
  }
4759
4776
  }
4760
- /**
4761
- * Extract XML declaration from original content
4762
- */
4763
- extractXmlDeclaration(xml) {
4764
- const match = xml.match(/<\?xml[^?]*\?>/);
4765
- return match ? match[0] + "\n" : '<?xml version="1.0" encoding="UTF-8"?>\n';
4766
- }
4767
- /**
4768
- * Add file entries to the manifest
4769
- */
4770
- addFilesToManifest(parsed, paths) {
4771
- const manifest = parsed.manifest;
4772
- if (!manifest) return;
4773
- const resources = manifest.resources;
4774
- if (!resources) return;
4775
- let resource = resources.resource;
4776
- if (!resource) return;
4777
- if (Array.isArray(resource)) {
4778
- resource = resource[0];
4779
- }
4780
- if (!resource.file) {
4781
- resource.file = [];
4782
- }
4783
- let files = resource.file;
4784
- if (!Array.isArray(files)) {
4785
- files = [files];
4786
- resource.file = files;
4787
- }
4788
- const filesToAdd = [
4789
- paths.cssBefore,
4790
- paths.cssAfter,
4791
- paths.jsBefore,
4792
- paths.jsAfter
4793
- ].filter(Boolean);
4794
- for (const filePath of filesToAdd) {
4795
- const exists = files.some((f) => f["@_href"] === filePath);
4796
- if (!exists) {
4797
- files.push({ "@_href": filePath });
4798
- }
4799
- }
4800
- }
4801
4777
  /**
4802
4778
  * Get the file paths that will be added to the package
4803
4779
  */